babylonjs.loaders.js 555 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("babylonjs"));
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs-loaders", ["babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-loaders"] = factory(require("babylonjs"));
  8. else
  9. root["LOADERS"] = factory(root["BABYLON"]);
  10. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function(__WEBPACK_EXTERNAL_MODULE_core_Misc_observable__) {
  11. return /******/ (() => { // webpackBootstrap
  12. /******/ "use strict";
  13. /******/ var __webpack_modules__ = ({
  14. /***/ "../../../../node_modules/tslib/tslib.es6.js":
  15. /*!***************************************************!*\
  16. !*** ../../../../node_modules/tslib/tslib.es6.js ***!
  17. \***************************************************/
  18. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  19. __webpack_require__.r(__webpack_exports__);
  20. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  21. /* harmony export */ "__assign": () => (/* binding */ __assign),
  22. /* harmony export */ "__asyncDelegator": () => (/* binding */ __asyncDelegator),
  23. /* harmony export */ "__asyncGenerator": () => (/* binding */ __asyncGenerator),
  24. /* harmony export */ "__asyncValues": () => (/* binding */ __asyncValues),
  25. /* harmony export */ "__await": () => (/* binding */ __await),
  26. /* harmony export */ "__awaiter": () => (/* binding */ __awaiter),
  27. /* harmony export */ "__classPrivateFieldGet": () => (/* binding */ __classPrivateFieldGet),
  28. /* harmony export */ "__classPrivateFieldSet": () => (/* binding */ __classPrivateFieldSet),
  29. /* harmony export */ "__createBinding": () => (/* binding */ __createBinding),
  30. /* harmony export */ "__decorate": () => (/* binding */ __decorate),
  31. /* harmony export */ "__exportStar": () => (/* binding */ __exportStar),
  32. /* harmony export */ "__extends": () => (/* binding */ __extends),
  33. /* harmony export */ "__generator": () => (/* binding */ __generator),
  34. /* harmony export */ "__importDefault": () => (/* binding */ __importDefault),
  35. /* harmony export */ "__importStar": () => (/* binding */ __importStar),
  36. /* harmony export */ "__makeTemplateObject": () => (/* binding */ __makeTemplateObject),
  37. /* harmony export */ "__metadata": () => (/* binding */ __metadata),
  38. /* harmony export */ "__param": () => (/* binding */ __param),
  39. /* harmony export */ "__read": () => (/* binding */ __read),
  40. /* harmony export */ "__rest": () => (/* binding */ __rest),
  41. /* harmony export */ "__spread": () => (/* binding */ __spread),
  42. /* harmony export */ "__spreadArray": () => (/* binding */ __spreadArray),
  43. /* harmony export */ "__spreadArrays": () => (/* binding */ __spreadArrays),
  44. /* harmony export */ "__values": () => (/* binding */ __values)
  45. /* harmony export */ });
  46. /*! *****************************************************************************
  47. Copyright (c) Microsoft Corporation.
  48. Permission to use, copy, modify, and/or distribute this software for any
  49. purpose with or without fee is hereby granted.
  50. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  51. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  52. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  53. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  54. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  55. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  56. PERFORMANCE OF THIS SOFTWARE.
  57. ***************************************************************************** */
  58. /* global Reflect, Promise */
  59. var extendStatics = function(d, b) {
  60. extendStatics = Object.setPrototypeOf ||
  61. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  62. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  63. return extendStatics(d, b);
  64. };
  65. function __extends(d, b) {
  66. if (typeof b !== "function" && b !== null)
  67. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  68. extendStatics(d, b);
  69. function __() { this.constructor = d; }
  70. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  71. }
  72. var __assign = function() {
  73. __assign = Object.assign || function __assign(t) {
  74. for (var s, i = 1, n = arguments.length; i < n; i++) {
  75. s = arguments[i];
  76. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  77. }
  78. return t;
  79. }
  80. return __assign.apply(this, arguments);
  81. }
  82. function __rest(s, e) {
  83. var t = {};
  84. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  85. t[p] = s[p];
  86. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  87. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  88. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  89. t[p[i]] = s[p[i]];
  90. }
  91. return t;
  92. }
  93. function __decorate(decorators, target, key, desc) {
  94. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  95. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  96. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  97. return c > 3 && r && Object.defineProperty(target, key, r), r;
  98. }
  99. function __param(paramIndex, decorator) {
  100. return function (target, key) { decorator(target, key, paramIndex); }
  101. }
  102. function __metadata(metadataKey, metadataValue) {
  103. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  104. }
  105. function __awaiter(thisArg, _arguments, P, generator) {
  106. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  107. return new (P || (P = Promise))(function (resolve, reject) {
  108. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  109. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  110. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  111. step((generator = generator.apply(thisArg, _arguments || [])).next());
  112. });
  113. }
  114. function __generator(thisArg, body) {
  115. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  116. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  117. function verb(n) { return function (v) { return step([n, v]); }; }
  118. function step(op) {
  119. if (f) throw new TypeError("Generator is already executing.");
  120. while (_) try {
  121. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  122. if (y = 0, t) op = [op[0] & 2, t.value];
  123. switch (op[0]) {
  124. case 0: case 1: t = op; break;
  125. case 4: _.label++; return { value: op[1], done: false };
  126. case 5: _.label++; y = op[1]; op = [0]; continue;
  127. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  128. default:
  129. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  130. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  131. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  132. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  133. if (t[2]) _.ops.pop();
  134. _.trys.pop(); continue;
  135. }
  136. op = body.call(thisArg, _);
  137. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  138. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  139. }
  140. }
  141. var __createBinding = Object.create ? (function(o, m, k, k2) {
  142. if (k2 === undefined) k2 = k;
  143. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  144. }) : (function(o, m, k, k2) {
  145. if (k2 === undefined) k2 = k;
  146. o[k2] = m[k];
  147. });
  148. function __exportStar(m, o) {
  149. for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
  150. }
  151. function __values(o) {
  152. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  153. if (m) return m.call(o);
  154. if (o && typeof o.length === "number") return {
  155. next: function () {
  156. if (o && i >= o.length) o = void 0;
  157. return { value: o && o[i++], done: !o };
  158. }
  159. };
  160. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  161. }
  162. function __read(o, n) {
  163. var m = typeof Symbol === "function" && o[Symbol.iterator];
  164. if (!m) return o;
  165. var i = m.call(o), r, ar = [], e;
  166. try {
  167. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  168. }
  169. catch (error) { e = { error: error }; }
  170. finally {
  171. try {
  172. if (r && !r.done && (m = i["return"])) m.call(i);
  173. }
  174. finally { if (e) throw e.error; }
  175. }
  176. return ar;
  177. }
  178. /** @deprecated */
  179. function __spread() {
  180. for (var ar = [], i = 0; i < arguments.length; i++)
  181. ar = ar.concat(__read(arguments[i]));
  182. return ar;
  183. }
  184. /** @deprecated */
  185. function __spreadArrays() {
  186. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  187. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  188. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  189. r[k] = a[j];
  190. return r;
  191. }
  192. function __spreadArray(to, from, pack) {
  193. if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
  194. if (ar || !(i in from)) {
  195. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  196. ar[i] = from[i];
  197. }
  198. }
  199. return to.concat(ar || Array.prototype.slice.call(from));
  200. }
  201. function __await(v) {
  202. return this instanceof __await ? (this.v = v, this) : new __await(v);
  203. }
  204. function __asyncGenerator(thisArg, _arguments, generator) {
  205. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  206. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  207. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  208. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  209. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  210. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  211. function fulfill(value) { resume("next", value); }
  212. function reject(value) { resume("throw", value); }
  213. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  214. }
  215. function __asyncDelegator(o) {
  216. var i, p;
  217. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  218. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  219. }
  220. function __asyncValues(o) {
  221. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  222. var m = o[Symbol.asyncIterator], i;
  223. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  224. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  225. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  226. }
  227. function __makeTemplateObject(cooked, raw) {
  228. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  229. return cooked;
  230. };
  231. var __setModuleDefault = Object.create ? (function(o, v) {
  232. Object.defineProperty(o, "default", { enumerable: true, value: v });
  233. }) : function(o, v) {
  234. o["default"] = v;
  235. };
  236. function __importStar(mod) {
  237. if (mod && mod.__esModule) return mod;
  238. var result = {};
  239. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  240. __setModuleDefault(result, mod);
  241. return result;
  242. }
  243. function __importDefault(mod) {
  244. return (mod && mod.__esModule) ? mod : { default: mod };
  245. }
  246. function __classPrivateFieldGet(receiver, state, kind, f) {
  247. if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
  248. if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
  249. return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
  250. }
  251. function __classPrivateFieldSet(receiver, state, value, kind, f) {
  252. if (kind === "m") throw new TypeError("Private method is not writable");
  253. if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
  254. if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
  255. return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
  256. }
  257. /***/ }),
  258. /***/ "../../../lts/loaders/dist/OBJ/index.js":
  259. /*!**********************************************!*\
  260. !*** ../../../lts/loaders/dist/OBJ/index.js ***!
  261. \**********************************************/
  262. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  263. __webpack_require__.r(__webpack_exports__);
  264. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  265. /* harmony export */ "MTLFileLoader": () => (/* reexport safe */ _mtlFileLoader__WEBPACK_IMPORTED_MODULE_0__.MTLFileLoader),
  266. /* harmony export */ "OBJFileLoader": () => (/* reexport safe */ _objFileLoader__WEBPACK_IMPORTED_MODULE_3__.OBJFileLoader),
  267. /* harmony export */ "SolidParser": () => (/* reexport safe */ _solidParser__WEBPACK_IMPORTED_MODULE_2__.SolidParser)
  268. /* harmony export */ });
  269. /* harmony import */ var _mtlFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./mtlFileLoader */ "../../../lts/loaders/dist/OBJ/mtlFileLoader.js");
  270. /* harmony import */ var _objLoadingOptions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./objLoadingOptions */ "../../../lts/loaders/dist/OBJ/objLoadingOptions.js");
  271. /* harmony import */ var _solidParser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./solidParser */ "../../../lts/loaders/dist/OBJ/solidParser.js");
  272. /* harmony import */ var _objFileLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./objFileLoader */ "../../../lts/loaders/dist/OBJ/objFileLoader.js");
  273. /***/ }),
  274. /***/ "../../../lts/loaders/dist/OBJ/mtlFileLoader.js":
  275. /*!******************************************************!*\
  276. !*** ../../../lts/loaders/dist/OBJ/mtlFileLoader.js ***!
  277. \******************************************************/
  278. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  279. __webpack_require__.r(__webpack_exports__);
  280. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  281. /* harmony export */ "MTLFileLoader": () => (/* binding */ MTLFileLoader)
  282. /* harmony export */ });
  283. /* harmony import */ var core_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Materials/standardMaterial */ "core/Misc/observable");
  284. /* harmony import */ var core_Maths_math_color__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__);
  285. /**
  286. * Class reading and parsing the MTL file bundled with the obj file.
  287. */
  288. var MTLFileLoader = /** @class */ (function () {
  289. function MTLFileLoader() {
  290. /**
  291. * All material loaded from the mtl will be set here
  292. */
  293. this.materials = [];
  294. }
  295. /**
  296. * This function will read the mtl file and create each material described inside
  297. * This function could be improve by adding :
  298. * -some component missing (Ni, Tf...)
  299. * -including the specific options available
  300. *
  301. * @param scene defines the scene the material will be created in
  302. * @param data defines the mtl data to parse
  303. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  304. * @param assetContainer defines the asset container to store the material in (can be null)
  305. */
  306. MTLFileLoader.prototype.parseMTL = function (scene, data, rootUrl, assetContainer) {
  307. if (data instanceof ArrayBuffer) {
  308. return;
  309. }
  310. //Split the lines from the file
  311. var lines = data.split("\n");
  312. // whitespace char ie: [ \t\r\n\f]
  313. var delimiter_pattern = /\s+/;
  314. //Array with RGB colors
  315. var color;
  316. //New material
  317. var material = null;
  318. //Look at each line
  319. for (var i = 0; i < lines.length; i++) {
  320. var line = lines[i].trim();
  321. // Blank line or comment
  322. if (line.length === 0 || line.charAt(0) === "#") {
  323. continue;
  324. }
  325. //Get the first parameter (keyword)
  326. var pos = line.indexOf(" ");
  327. var key = pos >= 0 ? line.substring(0, pos) : line;
  328. key = key.toLowerCase();
  329. //Get the data following the key
  330. var value = pos >= 0 ? line.substring(pos + 1).trim() : "";
  331. //This mtl keyword will create the new material
  332. if (key === "newmtl") {
  333. //Check if it is the first material.
  334. // Materials specifications are described after this keyword.
  335. if (material) {
  336. //Add the previous material in the material array.
  337. this.materials.push(material);
  338. }
  339. //Create a new material.
  340. // value is the name of the material read in the mtl file
  341. scene._blockEntityCollection = !!assetContainer;
  342. material = new core_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.StandardMaterial(value, scene);
  343. material._parentContainer = assetContainer;
  344. scene._blockEntityCollection = false;
  345. }
  346. else if (key === "kd" && material) {
  347. // Diffuse color (color under white light) using RGB values
  348. //value = "r g b"
  349. color = value.split(delimiter_pattern, 3).map(parseFloat);
  350. //color = [r,g,b]
  351. //Set tghe color into the material
  352. material.diffuseColor = core_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(color);
  353. }
  354. else if (key === "ka" && material) {
  355. // Ambient color (color under shadow) using RGB values
  356. //value = "r g b"
  357. color = value.split(delimiter_pattern, 3).map(parseFloat);
  358. //color = [r,g,b]
  359. //Set tghe color into the material
  360. material.ambientColor = core_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(color);
  361. }
  362. else if (key === "ks" && material) {
  363. // Specular color (color when light is reflected from shiny surface) using RGB values
  364. //value = "r g b"
  365. color = value.split(delimiter_pattern, 3).map(parseFloat);
  366. //color = [r,g,b]
  367. //Set the color into the material
  368. material.specularColor = core_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(color);
  369. }
  370. else if (key === "ke" && material) {
  371. // Emissive color using RGB values
  372. color = value.split(delimiter_pattern, 3).map(parseFloat);
  373. material.emissiveColor = core_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(color);
  374. }
  375. else if (key === "ns" && material) {
  376. //value = "Integer"
  377. material.specularPower = parseFloat(value);
  378. }
  379. else if (key === "d" && material) {
  380. //d is dissolve for current material. It mean alpha for BABYLON
  381. material.alpha = parseFloat(value);
  382. //Texture
  383. //This part can be improved by adding the possible options of texture
  384. }
  385. else if (key === "map_ka" && material) {
  386. // ambient texture map with a loaded image
  387. //We must first get the folder of the image
  388. material.ambientTexture = MTLFileLoader._getTexture(rootUrl, value, scene);
  389. }
  390. else if (key === "map_kd" && material) {
  391. // Diffuse texture map with a loaded image
  392. material.diffuseTexture = MTLFileLoader._getTexture(rootUrl, value, scene);
  393. }
  394. else if (key === "map_ks" && material) {
  395. // Specular texture map with a loaded image
  396. //We must first get the folder of the image
  397. material.specularTexture = MTLFileLoader._getTexture(rootUrl, value, scene);
  398. }
  399. else if (key === "map_ns") {
  400. //Specular
  401. //Specular highlight component
  402. //We must first get the folder of the image
  403. //
  404. //Not supported by BABYLON
  405. //
  406. // continue;
  407. }
  408. else if (key === "map_bump" && material) {
  409. //The bump texture
  410. var values = value.split(delimiter_pattern);
  411. var bumpMultiplierIndex = values.indexOf("-bm");
  412. var bumpMultiplier = null;
  413. if (bumpMultiplierIndex >= 0) {
  414. bumpMultiplier = values[bumpMultiplierIndex + 1];
  415. values.splice(bumpMultiplierIndex, 2); // remove
  416. }
  417. material.bumpTexture = MTLFileLoader._getTexture(rootUrl, values.join(" "), scene);
  418. if (material.bumpTexture && bumpMultiplier !== null) {
  419. material.bumpTexture.level = parseFloat(bumpMultiplier);
  420. }
  421. }
  422. else if (key === "map_d" && material) {
  423. // The dissolve of the material
  424. material.opacityTexture = MTLFileLoader._getTexture(rootUrl, value, scene);
  425. //Options for illumination
  426. }
  427. else if (key === "illum") {
  428. //Illumination
  429. if (value === "0") {
  430. //That mean Kd == Kd
  431. }
  432. else if (value === "1") {
  433. //Color on and Ambient on
  434. }
  435. else if (value === "2") {
  436. //Highlight on
  437. }
  438. else if (value === "3") {
  439. //Reflection on and Ray trace on
  440. }
  441. else if (value === "4") {
  442. //Transparency: Glass on, Reflection: Ray trace on
  443. }
  444. else if (value === "5") {
  445. //Reflection: Fresnel on and Ray trace on
  446. }
  447. else if (value === "6") {
  448. //Transparency: Refraction on, Reflection: Fresnel off and Ray trace on
  449. }
  450. else if (value === "7") {
  451. //Transparency: Refraction on, Reflection: Fresnel on and Ray trace on
  452. }
  453. else if (value === "8") {
  454. //Reflection on and Ray trace off
  455. }
  456. else if (value === "9") {
  457. //Transparency: Glass on, Reflection: Ray trace off
  458. }
  459. else if (value === "10") {
  460. //Casts shadows onto invisible surfaces
  461. }
  462. }
  463. else {
  464. // console.log("Unhandled expression at line : " + i +'\n' + "with value : " + line);
  465. }
  466. }
  467. //At the end of the file, add the last material
  468. if (material) {
  469. this.materials.push(material);
  470. }
  471. };
  472. /**
  473. * Gets the texture for the material.
  474. *
  475. * If the material is imported from input file,
  476. * We sanitize the url to ensure it takes the textre from aside the material.
  477. *
  478. * @param rootUrl The root url to load from
  479. * @param value The value stored in the mtl
  480. * @param scene
  481. * @return The Texture
  482. */
  483. MTLFileLoader._getTexture = function (rootUrl, value, scene) {
  484. if (!value) {
  485. return null;
  486. }
  487. var url = rootUrl;
  488. // Load from input file.
  489. if (rootUrl === "file:") {
  490. var lastDelimiter = value.lastIndexOf("\\");
  491. if (lastDelimiter === -1) {
  492. lastDelimiter = value.lastIndexOf("/");
  493. }
  494. if (lastDelimiter > -1) {
  495. url += value.substr(lastDelimiter + 1);
  496. }
  497. else {
  498. url += value;
  499. }
  500. }
  501. // Not from input file.
  502. else {
  503. url += value;
  504. }
  505. return new core_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Texture(url, scene, false, MTLFileLoader.INVERT_TEXTURE_Y);
  506. };
  507. /**
  508. * Invert Y-Axis of referenced textures on load
  509. */
  510. MTLFileLoader.INVERT_TEXTURE_Y = true;
  511. return MTLFileLoader;
  512. }());
  513. /***/ }),
  514. /***/ "../../../lts/loaders/dist/OBJ/objFileLoader.js":
  515. /*!******************************************************!*\
  516. !*** ../../../lts/loaders/dist/OBJ/objFileLoader.js ***!
  517. \******************************************************/
  518. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  519. __webpack_require__.r(__webpack_exports__);
  520. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  521. /* harmony export */ "OBJFileLoader": () => (/* binding */ OBJFileLoader)
  522. /* harmony export */ });
  523. /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/assetContainer */ "core/Misc/observable");
  524. /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  525. /* harmony import */ var _mtlFileLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mtlFileLoader */ "../../../lts/loaders/dist/OBJ/mtlFileLoader.js");
  526. /* harmony import */ var _solidParser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./solidParser */ "../../../lts/loaders/dist/OBJ/solidParser.js");
  527. /**
  528. * OBJ file type loader.
  529. * This is a babylon scene loader plugin.
  530. */
  531. var OBJFileLoader = /** @class */ (function () {
  532. /**
  533. * Creates loader for .OBJ files
  534. *
  535. * @param loadingOptions options for loading and parsing OBJ/MTL files.
  536. */
  537. function OBJFileLoader(loadingOptions) {
  538. /**
  539. * Defines the name of the plugin.
  540. */
  541. this.name = "obj";
  542. /**
  543. * Defines the extension the plugin is able to load.
  544. */
  545. this.extensions = ".obj";
  546. this._assetContainer = null;
  547. this._loadingOptions = loadingOptions || OBJFileLoader.DefaultLoadingOptions;
  548. }
  549. Object.defineProperty(OBJFileLoader, "INVERT_TEXTURE_Y", {
  550. /**
  551. * Invert Y-Axis of referenced textures on load
  552. */
  553. get: function () {
  554. return _mtlFileLoader__WEBPACK_IMPORTED_MODULE_1__.MTLFileLoader.INVERT_TEXTURE_Y;
  555. },
  556. set: function (value) {
  557. _mtlFileLoader__WEBPACK_IMPORTED_MODULE_1__.MTLFileLoader.INVERT_TEXTURE_Y = value;
  558. },
  559. enumerable: false,
  560. configurable: true
  561. });
  562. Object.defineProperty(OBJFileLoader, "DefaultLoadingOptions", {
  563. get: function () {
  564. return {
  565. computeNormals: OBJFileLoader.COMPUTE_NORMALS,
  566. optimizeNormals: OBJFileLoader.OPTIMIZE_NORMALS,
  567. importVertexColors: OBJFileLoader.IMPORT_VERTEX_COLORS,
  568. invertY: OBJFileLoader.INVERT_Y,
  569. invertTextureY: OBJFileLoader.INVERT_TEXTURE_Y,
  570. UVScaling: OBJFileLoader.UV_SCALING,
  571. materialLoadingFailsSilently: OBJFileLoader.MATERIAL_LOADING_FAILS_SILENTLY,
  572. optimizeWithUV: OBJFileLoader.OPTIMIZE_WITH_UV,
  573. skipMaterials: OBJFileLoader.SKIP_MATERIALS,
  574. };
  575. },
  576. enumerable: false,
  577. configurable: true
  578. });
  579. /**
  580. * Calls synchronously the MTL file attached to this obj.
  581. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  582. * Without this function materials are not displayed in the first frame (but displayed after).
  583. * In consequence it is impossible to get material information in your HTML file
  584. *
  585. * @param url The URL of the MTL file
  586. * @param rootUrl defines where to load data from
  587. * @param onSuccess Callback function to be called when the MTL file is loaded
  588. * @param onFailure
  589. */
  590. OBJFileLoader.prototype._loadMTL = function (url, rootUrl, onSuccess, onFailure) {
  591. //The complete path to the mtl file
  592. var pathOfFile = rootUrl + url;
  593. // Loads through the babylon tools to allow fileInput search.
  594. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.LoadFile(pathOfFile, onSuccess, undefined, undefined, false, function (request, exception) {
  595. onFailure(pathOfFile, exception);
  596. });
  597. };
  598. /**
  599. * Instantiates a OBJ file loader plugin.
  600. * @returns the created plugin
  601. */
  602. OBJFileLoader.prototype.createPlugin = function () {
  603. return new OBJFileLoader(OBJFileLoader.DefaultLoadingOptions);
  604. };
  605. /**
  606. * If the data string can be loaded directly.
  607. *
  608. * @param data string containing the file data
  609. * @returns if the data can be loaded directly
  610. */
  611. OBJFileLoader.prototype.canDirectLoad = function (data) {
  612. return false;
  613. };
  614. /**
  615. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  616. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  617. * @param scene the scene the meshes should be added to
  618. * @param data the OBJ data to load
  619. * @param rootUrl root url to load from
  620. * @param onProgress event that fires when loading progress has occured
  621. * @param fileName Defines the name of the file to load
  622. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  623. */
  624. OBJFileLoader.prototype.importMeshAsync = function (meshesNames, scene, data, rootUrl, onProgress, fileName) {
  625. //get the meshes from OBJ file
  626. return this._parseSolid(meshesNames, scene, data, rootUrl).then(function (meshes) {
  627. return {
  628. meshes: meshes,
  629. particleSystems: [],
  630. skeletons: [],
  631. animationGroups: [],
  632. transformNodes: [],
  633. geometries: [],
  634. lights: [],
  635. };
  636. });
  637. };
  638. /**
  639. * Imports all objects from the loaded OBJ data and adds them to the scene
  640. * @param scene the scene the objects should be added to
  641. * @param data the OBJ data to load
  642. * @param rootUrl root url to load from
  643. * @param onProgress event that fires when loading progress has occured
  644. * @param fileName Defines the name of the file to load
  645. * @returns a promise which completes when objects have been loaded to the scene
  646. */
  647. OBJFileLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fileName) {
  648. //Get the 3D model
  649. return this.importMeshAsync(null, scene, data, rootUrl, onProgress).then(function () {
  650. // return void
  651. });
  652. };
  653. /**
  654. * Load into an asset container.
  655. * @param scene The scene to load into
  656. * @param data The data to import
  657. * @param rootUrl The root url for scene and resources
  658. * @param onProgress The callback when the load progresses
  659. * @param fileName Defines the name of the file to load
  660. * @returns The loaded asset container
  661. */
  662. OBJFileLoader.prototype.loadAssetContainerAsync = function (scene, data, rootUrl, onProgress, fileName) {
  663. var _this = this;
  664. var container = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.AssetContainer(scene);
  665. this._assetContainer = container;
  666. return this.importMeshAsync(null, scene, data, rootUrl)
  667. .then(function (result) {
  668. result.meshes.forEach(function (mesh) { return container.meshes.push(mesh); });
  669. result.meshes.forEach(function (mesh) {
  670. var material = mesh.material;
  671. if (material) {
  672. // Materials
  673. if (container.materials.indexOf(material) == -1) {
  674. container.materials.push(material);
  675. // Textures
  676. var textures = material.getActiveTextures();
  677. textures.forEach(function (t) {
  678. if (container.textures.indexOf(t) == -1) {
  679. container.textures.push(t);
  680. }
  681. });
  682. }
  683. }
  684. });
  685. _this._assetContainer = null;
  686. return container;
  687. })
  688. .catch(function (ex) {
  689. _this._assetContainer = null;
  690. throw ex;
  691. });
  692. };
  693. /**
  694. * Read the OBJ file and create an Array of meshes.
  695. * Each mesh contains all information given by the OBJ and the MTL file.
  696. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  697. * @param meshesNames defines a string or array of strings of the mesh names that should be loaded from the file
  698. * @param scene defines the scene where are displayed the data
  699. * @param data defines the content of the obj file
  700. * @param rootUrl defines the path to the folder
  701. * @returns the list of loaded meshes
  702. */
  703. OBJFileLoader.prototype._parseSolid = function (meshesNames, scene, data, rootUrl) {
  704. var _this = this;
  705. var fileToLoad = ""; //The name of the mtlFile to load
  706. var materialsFromMTLFile = new _mtlFileLoader__WEBPACK_IMPORTED_MODULE_1__.MTLFileLoader();
  707. var materialToUse = new Array();
  708. var babylonMeshesArray = []; //The mesh for babylon
  709. // Main function
  710. var solidParser = new _solidParser__WEBPACK_IMPORTED_MODULE_2__.SolidParser(materialToUse, babylonMeshesArray, this._loadingOptions);
  711. solidParser.parse(meshesNames, data, scene, this._assetContainer, function (fileName) {
  712. fileToLoad = fileName;
  713. });
  714. // load the materials
  715. var mtlPromises = [];
  716. // Check if we have a file to load
  717. if (fileToLoad !== "" && !this._loadingOptions.skipMaterials) {
  718. //Load the file synchronously
  719. mtlPromises.push(new Promise(function (resolve, reject) {
  720. _this._loadMTL(fileToLoad, rootUrl, function (dataLoaded) {
  721. try {
  722. //Create materials thanks MTLLoader function
  723. materialsFromMTLFile.parseMTL(scene, dataLoaded, rootUrl, _this._assetContainer);
  724. //Look at each material loaded in the mtl file
  725. for (var n = 0; n < materialsFromMTLFile.materials.length; n++) {
  726. //Three variables to get all meshes with the same material
  727. var startIndex = 0;
  728. var _indices = [];
  729. var _index;
  730. //The material from MTL file is used in the meshes loaded
  731. //Push the indice in an array
  732. //Check if the material is not used for another mesh
  733. while ((_index = materialToUse.indexOf(materialsFromMTLFile.materials[n].name, startIndex)) > -1) {
  734. _indices.push(_index);
  735. startIndex = _index + 1;
  736. }
  737. //If the material is not used dispose it
  738. if (_index === -1 && _indices.length === 0) {
  739. //If the material is not needed, remove it
  740. materialsFromMTLFile.materials[n].dispose();
  741. }
  742. else {
  743. for (var o = 0; o < _indices.length; o++) {
  744. //Apply the material to the Mesh for each mesh with the material
  745. var mesh = babylonMeshesArray[_indices[o]];
  746. var material = materialsFromMTLFile.materials[n];
  747. mesh.material = material;
  748. if (!mesh.getTotalIndices()) {
  749. // No indices, we need to turn on point cloud
  750. material.pointsCloud = true;
  751. }
  752. }
  753. }
  754. }
  755. resolve();
  756. }
  757. catch (e) {
  758. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Error processing MTL file: '".concat(fileToLoad, "'"));
  759. if (_this._loadingOptions.materialLoadingFailsSilently) {
  760. resolve();
  761. }
  762. else {
  763. reject(e);
  764. }
  765. }
  766. }, function (pathOfFile, exception) {
  767. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Error downloading MTL file: '".concat(fileToLoad, "'"));
  768. if (_this._loadingOptions.materialLoadingFailsSilently) {
  769. resolve();
  770. }
  771. else {
  772. reject(exception);
  773. }
  774. });
  775. }));
  776. }
  777. //Return an array with all Mesh
  778. return Promise.all(mtlPromises).then(function () {
  779. return babylonMeshesArray;
  780. });
  781. };
  782. /**
  783. * Defines if UVs are optimized by default during load.
  784. */
  785. OBJFileLoader.OPTIMIZE_WITH_UV = true;
  786. /**
  787. * Invert model on y-axis (does a model scaling inversion)
  788. */
  789. OBJFileLoader.INVERT_Y = false;
  790. /**
  791. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  792. */
  793. OBJFileLoader.IMPORT_VERTEX_COLORS = false;
  794. /**
  795. * Compute the normals for the model, even if normals are present in the file.
  796. */
  797. OBJFileLoader.COMPUTE_NORMALS = false;
  798. /**
  799. * Optimize the normals for the model. Lighting can be uneven if you use OptimizeWithUV = true because new vertices can be created for the same location if they pertain to different faces.
  800. * Using OptimizehNormals = true will help smoothing the lighting by averaging the normals of those vertices.
  801. */
  802. OBJFileLoader.OPTIMIZE_NORMALS = false;
  803. /**
  804. * Defines custom scaling of UV coordinates of loaded meshes.
  805. */
  806. OBJFileLoader.UV_SCALING = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector2(1, 1);
  807. /**
  808. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  809. */
  810. OBJFileLoader.SKIP_MATERIALS = false;
  811. /**
  812. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  813. *
  814. * Defaults to true for backwards compatibility.
  815. */
  816. OBJFileLoader.MATERIAL_LOADING_FAILS_SILENTLY = true;
  817. return OBJFileLoader;
  818. }());
  819. if (core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.SceneLoader) {
  820. //Add this loader into the register plugin
  821. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.SceneLoader.RegisterPlugin(new OBJFileLoader());
  822. }
  823. /***/ }),
  824. /***/ "../../../lts/loaders/dist/OBJ/objLoadingOptions.js":
  825. /*!**********************************************************!*\
  826. !*** ../../../lts/loaders/dist/OBJ/objLoadingOptions.js ***!
  827. \**********************************************************/
  828. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  829. __webpack_require__.r(__webpack_exports__);
  830. /***/ }),
  831. /***/ "../../../lts/loaders/dist/OBJ/solidParser.js":
  832. /*!****************************************************!*\
  833. !*** ../../../lts/loaders/dist/OBJ/solidParser.js ***!
  834. \****************************************************/
  835. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  836. __webpack_require__.r(__webpack_exports__);
  837. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  838. /* harmony export */ "SolidParser": () => (/* binding */ SolidParser)
  839. /* harmony export */ });
  840. /* harmony import */ var core_Buffers_buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Meshes/mesh.vertexData */ "core/Misc/observable");
  841. /* harmony import */ var core_Buffers_buffer__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Buffers_buffer__WEBPACK_IMPORTED_MODULE_0__);
  842. /**
  843. * Class used to load mesh data from OBJ content
  844. */
  845. var SolidParser = /** @class */ (function () {
  846. /**
  847. * Creates a new SolidParser
  848. * @param materialToUse defines the array to fill with the list of materials to use (it will be filled by the parse function)
  849. * @param babylonMeshesArray defines the array to fill with the list of loaded meshes (it will be filled by the parse function)
  850. * @param loadingOptions defines the loading options to use
  851. */
  852. function SolidParser(materialToUse, babylonMeshesArray, loadingOptions) {
  853. this._positions = []; //values for the positions of vertices
  854. this._normals = []; //Values for the normals
  855. this._uvs = []; //Values for the textures
  856. this._colors = [];
  857. this._meshesFromObj = []; //[mesh] Contains all the obj meshes
  858. this._indicesForBabylon = []; //The list of indices for VertexData
  859. this._wrappedPositionForBabylon = []; //The list of position in vectors
  860. this._wrappedUvsForBabylon = []; //Array with all value of uvs to match with the indices
  861. this._wrappedColorsForBabylon = []; // Array with all color values to match with the indices
  862. this._wrappedNormalsForBabylon = []; //Array with all value of normals to match with the indices
  863. this._tuplePosNorm = []; //Create a tuple with indice of Position, Normal, UV [pos, norm, uvs]
  864. this._curPositionInIndices = 0;
  865. this._hasMeshes = false; //Meshes are defined in the file
  866. this._unwrappedPositionsForBabylon = []; //Value of positionForBabylon w/o Vector3() [x,y,z]
  867. this._unwrappedColorsForBabylon = []; // Value of colorForBabylon w/o Color4() [r,g,b,a]
  868. this._unwrappedNormalsForBabylon = []; //Value of normalsForBabylon w/o Vector3() [x,y,z]
  869. this._unwrappedUVForBabylon = []; //Value of uvsForBabylon w/o Vector3() [x,y,z]
  870. this._triangles = []; //Indices from new triangles coming from polygons
  871. this._materialNameFromObj = ""; //The name of the current material
  872. this._objMeshName = ""; //The name of the current obj mesh
  873. this._increment = 1; //Id for meshes created by the multimaterial
  874. this._isFirstMaterial = true;
  875. this._grayColor = new core_Buffers_buffer__WEBPACK_IMPORTED_MODULE_0__.Color4(0.5, 0.5, 0.5, 1);
  876. this._materialToUse = materialToUse;
  877. this._babylonMeshesArray = babylonMeshesArray;
  878. this._loadingOptions = loadingOptions;
  879. }
  880. /**
  881. * Search for obj in the given array.
  882. * This function is called to check if a couple of data already exists in an array.
  883. *
  884. * If found, returns the index of the founded tuple index. Returns -1 if not found
  885. * @param arr Array<{ normals: Array<number>, idx: Array<number> }>
  886. * @param obj Array<number>
  887. * @returns {boolean}
  888. */
  889. SolidParser.prototype._isInArray = function (arr, obj) {
  890. if (!arr[obj[0]]) {
  891. arr[obj[0]] = { normals: [], idx: [] };
  892. }
  893. var idx = arr[obj[0]].normals.indexOf(obj[1]);
  894. return idx === -1 ? -1 : arr[obj[0]].idx[idx];
  895. };
  896. SolidParser.prototype._isInArrayUV = function (arr, obj) {
  897. if (!arr[obj[0]]) {
  898. arr[obj[0]] = { normals: [], idx: [], uv: [] };
  899. }
  900. var idx = arr[obj[0]].normals.indexOf(obj[1]);
  901. if (idx != 1 && obj[2] === arr[obj[0]].uv[idx]) {
  902. return arr[obj[0]].idx[idx];
  903. }
  904. return -1;
  905. };
  906. /**
  907. * This function set the data for each triangle.
  908. * Data are position, normals and uvs
  909. * If a tuple of (position, normal) is not set, add the data into the corresponding array
  910. * If the tuple already exist, add only their indice
  911. *
  912. * @param indicePositionFromObj Integer The index in positions array
  913. * @param indiceUvsFromObj Integer The index in uvs array
  914. * @param indiceNormalFromObj Integer The index in normals array
  915. * @param positionVectorFromOBJ Vector3 The value of position at index objIndice
  916. * @param textureVectorFromOBJ Vector3 The value of uvs
  917. * @param normalsVectorFromOBJ Vector3 The value of normals at index objNormale
  918. * @param positionColorsFromOBJ
  919. */
  920. SolidParser.prototype._setData = function (indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, positionVectorFromOBJ, textureVectorFromOBJ, normalsVectorFromOBJ, positionColorsFromOBJ) {
  921. //Check if this tuple already exists in the list of tuples
  922. var _index;
  923. if (this._loadingOptions.optimizeWithUV) {
  924. _index = this._isInArrayUV(this._tuplePosNorm, [indicePositionFromObj, indiceNormalFromObj, indiceUvsFromObj]);
  925. }
  926. else {
  927. _index = this._isInArray(this._tuplePosNorm, [indicePositionFromObj, indiceNormalFromObj]);
  928. }
  929. //If it not exists
  930. if (_index === -1) {
  931. //Add an new indice.
  932. //The array of indices is only an array with his length equal to the number of triangles - 1.
  933. //We add vertices data in this order
  934. this._indicesForBabylon.push(this._wrappedPositionForBabylon.length);
  935. //Push the position of vertice for Babylon
  936. //Each element is a Vector3(x,y,z)
  937. this._wrappedPositionForBabylon.push(positionVectorFromOBJ);
  938. //Push the uvs for Babylon
  939. //Each element is a Vector3(u,v)
  940. this._wrappedUvsForBabylon.push(textureVectorFromOBJ);
  941. //Push the normals for Babylon
  942. //Each element is a Vector3(x,y,z)
  943. this._wrappedNormalsForBabylon.push(normalsVectorFromOBJ);
  944. if (positionColorsFromOBJ !== undefined) {
  945. //Push the colors for Babylon
  946. //Each element is a BABYLON.Color4(r,g,b,a)
  947. this._wrappedColorsForBabylon.push(positionColorsFromOBJ);
  948. }
  949. //Add the tuple in the comparison list
  950. this._tuplePosNorm[indicePositionFromObj].normals.push(indiceNormalFromObj);
  951. this._tuplePosNorm[indicePositionFromObj].idx.push(this._curPositionInIndices++);
  952. if (this._loadingOptions.optimizeWithUV) {
  953. this._tuplePosNorm[indicePositionFromObj].uv.push(indiceUvsFromObj);
  954. }
  955. }
  956. else {
  957. //The tuple already exists
  958. //Add the index of the already existing tuple
  959. //At this index we can get the value of position, normal, color and uvs of vertex
  960. this._indicesForBabylon.push(_index);
  961. }
  962. };
  963. /**
  964. * Transform Vector() and BABYLON.Color() objects into numbers in an array
  965. */
  966. SolidParser.prototype._unwrapData = function () {
  967. //Every array has the same length
  968. for (var l = 0; l < this._wrappedPositionForBabylon.length; l++) {
  969. //Push the x, y, z values of each element in the unwrapped array
  970. this._unwrappedPositionsForBabylon.push(this._wrappedPositionForBabylon[l].x, this._wrappedPositionForBabylon[l].y, this._wrappedPositionForBabylon[l].z);
  971. this._unwrappedNormalsForBabylon.push(this._wrappedNormalsForBabylon[l].x, this._wrappedNormalsForBabylon[l].y, this._wrappedNormalsForBabylon[l].z);
  972. this._unwrappedUVForBabylon.push(this._wrappedUvsForBabylon[l].x, this._wrappedUvsForBabylon[l].y); //z is an optional value not supported by BABYLON
  973. if (this._loadingOptions.importVertexColors) {
  974. //Push the r, g, b, a values of each element in the unwrapped array
  975. this._unwrappedColorsForBabylon.push(this._wrappedColorsForBabylon[l].r, this._wrappedColorsForBabylon[l].g, this._wrappedColorsForBabylon[l].b, this._wrappedColorsForBabylon[l].a);
  976. }
  977. }
  978. // Reset arrays for the next new meshes
  979. this._wrappedPositionForBabylon = [];
  980. this._wrappedNormalsForBabylon = [];
  981. this._wrappedUvsForBabylon = [];
  982. this._wrappedColorsForBabylon = [];
  983. this._tuplePosNorm = [];
  984. this._curPositionInIndices = 0;
  985. };
  986. /**
  987. * Create triangles from polygons
  988. * It is important to notice that a triangle is a polygon
  989. * We get 5 patterns of face defined in OBJ File :
  990. * facePattern1 = ["1","2","3","4","5","6"]
  991. * facePattern2 = ["1/1","2/2","3/3","4/4","5/5","6/6"]
  992. * facePattern3 = ["1/1/1","2/2/2","3/3/3","4/4/4","5/5/5","6/6/6"]
  993. * facePattern4 = ["1//1","2//2","3//3","4//4","5//5","6//6"]
  994. * facePattern5 = ["-1/-1/-1","-2/-2/-2","-3/-3/-3","-4/-4/-4","-5/-5/-5","-6/-6/-6"]
  995. * Each pattern is divided by the same method
  996. * @param face Array[String] The indices of elements
  997. * @param faces
  998. * @param v Integer The variable to increment
  999. */
  1000. SolidParser.prototype._getTriangles = function (faces, v) {
  1001. //Work for each element of the array
  1002. for (var faceIndex = v; faceIndex < faces.length - 1; faceIndex++) {
  1003. //Add on the triangle variable the indexes to obtain triangles
  1004. this._triangles.push(faces[0], faces[faceIndex], faces[faceIndex + 1]);
  1005. }
  1006. //Result obtained after 2 iterations:
  1007. //Pattern1 => triangle = ["1","2","3","1","3","4"];
  1008. //Pattern2 => triangle = ["1/1","2/2","3/3","1/1","3/3","4/4"];
  1009. //Pattern3 => triangle = ["1/1/1","2/2/2","3/3/3","1/1/1","3/3/3","4/4/4"];
  1010. //Pattern4 => triangle = ["1//1","2//2","3//3","1//1","3//3","4//4"];
  1011. //Pattern5 => triangle = ["-1/-1/-1","-2/-2/-2","-3/-3/-3","-1/-1/-1","-3/-3/-3","-4/-4/-4"];
  1012. };
  1013. /**
  1014. * Create triangles and push the data for each polygon for the pattern 1
  1015. * In this pattern we get vertice positions
  1016. * @param face
  1017. * @param v
  1018. */
  1019. SolidParser.prototype._setDataForCurrentFaceWithPattern1 = function (face, v) {
  1020. //Get the indices of triangles for each polygon
  1021. this._getTriangles(face, v);
  1022. //For each element in the triangles array.
  1023. //This var could contains 1 to an infinity of triangles
  1024. for (var k = 0; k < this._triangles.length; k++) {
  1025. // Set position indice
  1026. var indicePositionFromObj = parseInt(this._triangles[k]) - 1;
  1027. this._setData(indicePositionFromObj, 0, 0, // In the pattern 1, normals and uvs are not defined
  1028. this._positions[indicePositionFromObj], // Get the vectors data
  1029. core_Buffers_buffer__WEBPACK_IMPORTED_MODULE_0__.Vector2.Zero(), core_Buffers_buffer__WEBPACK_IMPORTED_MODULE_0__.Vector3.Up(), // Create default vectors
  1030. this._loadingOptions.importVertexColors ? this._colors[indicePositionFromObj] : undefined);
  1031. }
  1032. //Reset variable for the next line
  1033. this._triangles = [];
  1034. };
  1035. /**
  1036. * Create triangles and push the data for each polygon for the pattern 2
  1037. * In this pattern we get vertice positions and uvsu
  1038. * @param face
  1039. * @param v
  1040. */
  1041. SolidParser.prototype._setDataForCurrentFaceWithPattern2 = function (face, v) {
  1042. //Get the indices of triangles for each polygon
  1043. this._getTriangles(face, v);
  1044. for (var k = 0; k < this._triangles.length; k++) {
  1045. //triangle[k] = "1/1"
  1046. //Split the data for getting position and uv
  1047. var point = this._triangles[k].split("/"); // ["1", "1"]
  1048. //Set position indice
  1049. var indicePositionFromObj = parseInt(point[0]) - 1;
  1050. //Set uv indice
  1051. var indiceUvsFromObj = parseInt(point[1]) - 1;
  1052. this._setData(indicePositionFromObj, indiceUvsFromObj, 0, //Default value for normals
  1053. this._positions[indicePositionFromObj], //Get the values for each element
  1054. this._uvs[indiceUvsFromObj], core_Buffers_buffer__WEBPACK_IMPORTED_MODULE_0__.Vector3.Up(), //Default value for normals
  1055. this._loadingOptions.importVertexColors ? this._colors[indicePositionFromObj] : undefined);
  1056. }
  1057. //Reset variable for the next line
  1058. this._triangles = [];
  1059. };
  1060. /**
  1061. * Create triangles and push the data for each polygon for the pattern 3
  1062. * In this pattern we get vertice positions, uvs and normals
  1063. * @param face
  1064. * @param v
  1065. */
  1066. SolidParser.prototype._setDataForCurrentFaceWithPattern3 = function (face, v) {
  1067. //Get the indices of triangles for each polygon
  1068. this._getTriangles(face, v);
  1069. for (var k = 0; k < this._triangles.length; k++) {
  1070. //triangle[k] = "1/1/1"
  1071. //Split the data for getting position, uv, and normals
  1072. var point = this._triangles[k].split("/"); // ["1", "1", "1"]
  1073. // Set position indice
  1074. var indicePositionFromObj = parseInt(point[0]) - 1;
  1075. // Set uv indice
  1076. var indiceUvsFromObj = parseInt(point[1]) - 1;
  1077. // Set normal indice
  1078. var indiceNormalFromObj = parseInt(point[2]) - 1;
  1079. this._setData(indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, this._positions[indicePositionFromObj], this._uvs[indiceUvsFromObj], this._normals[indiceNormalFromObj] //Set the vector for each component
  1080. );
  1081. }
  1082. //Reset variable for the next line
  1083. this._triangles = [];
  1084. };
  1085. /**
  1086. * Create triangles and push the data for each polygon for the pattern 4
  1087. * In this pattern we get vertice positions and normals
  1088. * @param face
  1089. * @param v
  1090. */
  1091. SolidParser.prototype._setDataForCurrentFaceWithPattern4 = function (face, v) {
  1092. this._getTriangles(face, v);
  1093. for (var k = 0; k < this._triangles.length; k++) {
  1094. //triangle[k] = "1//1"
  1095. //Split the data for getting position and normals
  1096. var point = this._triangles[k].split("//"); // ["1", "1"]
  1097. // We check indices, and normals
  1098. var indicePositionFromObj = parseInt(point[0]) - 1;
  1099. var indiceNormalFromObj = parseInt(point[1]) - 1;
  1100. this._setData(indicePositionFromObj, 1, //Default value for uv
  1101. indiceNormalFromObj, this._positions[indicePositionFromObj], //Get each vector of data
  1102. core_Buffers_buffer__WEBPACK_IMPORTED_MODULE_0__.Vector2.Zero(), this._normals[indiceNormalFromObj], this._loadingOptions.importVertexColors ? this._colors[indicePositionFromObj] : undefined);
  1103. }
  1104. //Reset variable for the next line
  1105. this._triangles = [];
  1106. };
  1107. /*
  1108. * Create triangles and push the data for each polygon for the pattern 3
  1109. * In this pattern we get vertice positions, uvs and normals
  1110. * @param face
  1111. * @param v
  1112. */
  1113. SolidParser.prototype._setDataForCurrentFaceWithPattern5 = function (face, v) {
  1114. //Get the indices of triangles for each polygon
  1115. this._getTriangles(face, v);
  1116. for (var k = 0; k < this._triangles.length; k++) {
  1117. //triangle[k] = "-1/-1/-1"
  1118. //Split the data for getting position, uv, and normals
  1119. var point = this._triangles[k].split("/"); // ["-1", "-1", "-1"]
  1120. // Set position indice
  1121. var indicePositionFromObj = this._positions.length + parseInt(point[0]);
  1122. // Set uv indice
  1123. var indiceUvsFromObj = this._uvs.length + parseInt(point[1]);
  1124. // Set normal indice
  1125. var indiceNormalFromObj = this._normals.length + parseInt(point[2]);
  1126. this._setData(indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, this._positions[indicePositionFromObj], this._uvs[indiceUvsFromObj], this._normals[indiceNormalFromObj], //Set the vector for each component
  1127. this._loadingOptions.importVertexColors ? this._colors[indicePositionFromObj] : undefined);
  1128. }
  1129. //Reset variable for the next line
  1130. this._triangles = [];
  1131. };
  1132. SolidParser.prototype._addPreviousObjMesh = function () {
  1133. //Check if it is not the first mesh. Otherwise we don't have data.
  1134. if (this._meshesFromObj.length > 0) {
  1135. //Get the previous mesh for applying the data about the faces
  1136. //=> in obj file, faces definition append after the name of the mesh
  1137. this._handledMesh = this._meshesFromObj[this._meshesFromObj.length - 1];
  1138. //Set the data into Array for the mesh
  1139. this._unwrapData();
  1140. // Reverse tab. Otherwise face are displayed in the wrong sens
  1141. this._indicesForBabylon.reverse();
  1142. //Set the information for the mesh
  1143. //Slice the array to avoid rewriting because of the fact this is the same var which be rewrited
  1144. this._handledMesh.indices = this._indicesForBabylon.slice();
  1145. this._handledMesh.positions = this._unwrappedPositionsForBabylon.slice();
  1146. this._handledMesh.normals = this._unwrappedNormalsForBabylon.slice();
  1147. this._handledMesh.uvs = this._unwrappedUVForBabylon.slice();
  1148. if (this._loadingOptions.importVertexColors) {
  1149. this._handledMesh.colors = this._unwrappedColorsForBabylon.slice();
  1150. }
  1151. //Reset the array for the next mesh
  1152. this._indicesForBabylon = [];
  1153. this._unwrappedPositionsForBabylon = [];
  1154. this._unwrappedColorsForBabylon = [];
  1155. this._unwrappedNormalsForBabylon = [];
  1156. this._unwrappedUVForBabylon = [];
  1157. }
  1158. };
  1159. SolidParser.prototype._optimizeNormals = function (mesh) {
  1160. var positions = mesh.getVerticesData(core_Buffers_buffer__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind);
  1161. var normals = mesh.getVerticesData(core_Buffers_buffer__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind);
  1162. var mapVertices = {};
  1163. if (!positions || !normals) {
  1164. return;
  1165. }
  1166. for (var i = 0; i < positions.length / 3; i++) {
  1167. var x = positions[i * 3 + 0];
  1168. var y = positions[i * 3 + 1];
  1169. var z = positions[i * 3 + 2];
  1170. var key = x + "_" + y + "_" + z;
  1171. var lst = mapVertices[key];
  1172. if (!lst) {
  1173. lst = [];
  1174. mapVertices[key] = lst;
  1175. }
  1176. lst.push(i);
  1177. }
  1178. var normal = new core_Buffers_buffer__WEBPACK_IMPORTED_MODULE_0__.Vector3();
  1179. for (var key in mapVertices) {
  1180. var lst = mapVertices[key];
  1181. if (lst.length < 2) {
  1182. continue;
  1183. }
  1184. var v0Idx = lst[0];
  1185. for (var i = 1; i < lst.length; ++i) {
  1186. var vIdx = lst[i];
  1187. normals[v0Idx * 3 + 0] += normals[vIdx * 3 + 0];
  1188. normals[v0Idx * 3 + 1] += normals[vIdx * 3 + 1];
  1189. normals[v0Idx * 3 + 2] += normals[vIdx * 3 + 2];
  1190. }
  1191. normal.copyFromFloats(normals[v0Idx * 3 + 0], normals[v0Idx * 3 + 1], normals[v0Idx * 3 + 2]);
  1192. normal.normalize();
  1193. for (var i = 0; i < lst.length; ++i) {
  1194. var vIdx = lst[i];
  1195. normals[vIdx * 3 + 0] = normal.x;
  1196. normals[vIdx * 3 + 1] = normal.y;
  1197. normals[vIdx * 3 + 2] = normal.z;
  1198. }
  1199. }
  1200. mesh.setVerticesData(core_Buffers_buffer__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind, normals);
  1201. };
  1202. /**
  1203. * Function used to parse an OBJ string
  1204. * @param meshesNames defines the list of meshes to load (all if not defined)
  1205. * @param data defines the OBJ string
  1206. * @param scene defines the hosting scene
  1207. * @param assetContainer defines the asset container to load data in
  1208. * @param onFileToLoadFound defines a callback that will be called if a MTL file is found
  1209. */
  1210. SolidParser.prototype.parse = function (meshesNames, data, scene, assetContainer, onFileToLoadFound) {
  1211. var _a;
  1212. // Split the file into lines
  1213. var lines = data.split("\n");
  1214. // Look at each line
  1215. for (var i = 0; i < lines.length; i++) {
  1216. var line = lines[i].trim().replace(/\s\s/g, " ");
  1217. var result;
  1218. // Comment or newLine
  1219. if (line.length === 0 || line.charAt(0) === "#") {
  1220. continue;
  1221. //Get information about one position possible for the vertices
  1222. }
  1223. else if (SolidParser.VertexPattern.test(line)) {
  1224. result = line.match(/[^ ]+/g); // match will return non-null due to passing regex pattern
  1225. // Value of result with line: "v 1.0 2.0 3.0"
  1226. // ["v", "1.0", "2.0", "3.0"]
  1227. // Create a Vector3 with the position x, y, z
  1228. this._positions.push(new core_Buffers_buffer__WEBPACK_IMPORTED_MODULE_0__.Vector3(parseFloat(result[1]), parseFloat(result[2]), parseFloat(result[3])));
  1229. if (this._loadingOptions.importVertexColors) {
  1230. if (result.length >= 7) {
  1231. var r = parseFloat(result[4]);
  1232. var g = parseFloat(result[5]);
  1233. var b = parseFloat(result[6]);
  1234. this._colors.push(new core_Buffers_buffer__WEBPACK_IMPORTED_MODULE_0__.Color4(r > 1 ? r / 255 : r, g > 1 ? g / 255 : g, b > 1 ? b / 255 : b, result.length === 7 || result[7] === undefined ? 1 : parseFloat(result[7])));
  1235. }
  1236. else {
  1237. // TODO: maybe push NULL and if all are NULL to skip (and remove grayColor var).
  1238. this._colors.push(this._grayColor);
  1239. }
  1240. }
  1241. }
  1242. else if ((result = SolidParser.NormalPattern.exec(line)) !== null) {
  1243. //Create a Vector3 with the normals x, y, z
  1244. //Value of result
  1245. // ["vn 1.0 2.0 3.0", "1.0", "2.0", "3.0"]
  1246. //Add the Vector in the list of normals
  1247. this._normals.push(new core_Buffers_buffer__WEBPACK_IMPORTED_MODULE_0__.Vector3(parseFloat(result[1]), parseFloat(result[2]), parseFloat(result[3])));
  1248. }
  1249. else if ((result = SolidParser.UVPattern.exec(line)) !== null) {
  1250. //Create a Vector2 with the normals u, v
  1251. //Value of result
  1252. // ["vt 0.1 0.2 0.3", "0.1", "0.2"]
  1253. //Add the Vector in the list of uvs
  1254. this._uvs.push(new core_Buffers_buffer__WEBPACK_IMPORTED_MODULE_0__.Vector2(parseFloat(result[1]) * this._loadingOptions.UVScaling.x, parseFloat(result[2]) * this._loadingOptions.UVScaling.y));
  1255. //Identify patterns of faces
  1256. //Face could be defined in different type of pattern
  1257. }
  1258. else if ((result = SolidParser.FacePattern3.exec(line)) !== null) {
  1259. //Value of result:
  1260. //["f 1/1/1 2/2/2 3/3/3", "1/1/1 2/2/2 3/3/3"...]
  1261. //Set the data for this face
  1262. this._setDataForCurrentFaceWithPattern3(result[1].trim().split(" "), // ["1/1/1", "2/2/2", "3/3/3"]
  1263. 1);
  1264. }
  1265. else if ((result = SolidParser.FacePattern4.exec(line)) !== null) {
  1266. //Value of result:
  1267. //["f 1//1 2//2 3//3", "1//1 2//2 3//3"...]
  1268. //Set the data for this face
  1269. this._setDataForCurrentFaceWithPattern4(result[1].trim().split(" "), // ["1//1", "2//2", "3//3"]
  1270. 1);
  1271. }
  1272. else if ((result = SolidParser.FacePattern5.exec(line)) !== null) {
  1273. //Value of result:
  1274. //["f -1/-1/-1 -2/-2/-2 -3/-3/-3", "-1/-1/-1 -2/-2/-2 -3/-3/-3"...]
  1275. //Set the data for this face
  1276. this._setDataForCurrentFaceWithPattern5(result[1].trim().split(" "), // ["-1/-1/-1", "-2/-2/-2", "-3/-3/-3"]
  1277. 1);
  1278. }
  1279. else if ((result = SolidParser.FacePattern2.exec(line)) !== null) {
  1280. //Value of result:
  1281. //["f 1/1 2/2 3/3", "1/1 2/2 3/3"...]
  1282. //Set the data for this face
  1283. this._setDataForCurrentFaceWithPattern2(result[1].trim().split(" "), // ["1/1", "2/2", "3/3"]
  1284. 1);
  1285. }
  1286. else if ((result = SolidParser.FacePattern1.exec(line)) !== null) {
  1287. //Value of result
  1288. //["f 1 2 3", "1 2 3"...]
  1289. //Set the data for this face
  1290. this._setDataForCurrentFaceWithPattern1(result[1].trim().split(" "), // ["1", "2", "3"]
  1291. 1);
  1292. // Define a mesh or an object
  1293. // Each time this keyword is analysed, create a new Object with all data for creating a babylonMesh
  1294. }
  1295. else if (SolidParser.GroupDescriptor.test(line) || SolidParser.ObjectDescriptor.test(line)) {
  1296. // Create a new mesh corresponding to the name of the group.
  1297. // Definition of the mesh
  1298. var objMesh = {
  1299. name: line.substring(2).trim(),
  1300. indices: undefined,
  1301. positions: undefined,
  1302. normals: undefined,
  1303. uvs: undefined,
  1304. colors: undefined,
  1305. materialName: "",
  1306. };
  1307. this._addPreviousObjMesh();
  1308. //Push the last mesh created with only the name
  1309. this._meshesFromObj.push(objMesh);
  1310. //Set this variable to indicate that now meshesFromObj has objects defined inside
  1311. this._hasMeshes = true;
  1312. this._isFirstMaterial = true;
  1313. this._increment = 1;
  1314. //Keyword for applying a material
  1315. }
  1316. else if (SolidParser.UseMtlDescriptor.test(line)) {
  1317. //Get the name of the material
  1318. this._materialNameFromObj = line.substring(7).trim();
  1319. //If this new material is in the same mesh
  1320. if (!this._isFirstMaterial || !this._hasMeshes) {
  1321. //Set the data for the previous mesh
  1322. this._addPreviousObjMesh();
  1323. //Create a new mesh
  1324. var objMesh =
  1325. //Set the name of the current obj mesh
  1326. {
  1327. name: (this._objMeshName || "mesh") + "_mm" + this._increment.toString(),
  1328. indices: undefined,
  1329. positions: undefined,
  1330. normals: undefined,
  1331. uvs: undefined,
  1332. colors: undefined,
  1333. materialName: this._materialNameFromObj,
  1334. };
  1335. this._increment++;
  1336. //If meshes are already defined
  1337. this._meshesFromObj.push(objMesh);
  1338. this._hasMeshes = true;
  1339. }
  1340. //Set the material name if the previous line define a mesh
  1341. if (this._hasMeshes && this._isFirstMaterial) {
  1342. //Set the material name to the previous mesh (1 material per mesh)
  1343. this._meshesFromObj[this._meshesFromObj.length - 1].materialName = this._materialNameFromObj;
  1344. this._isFirstMaterial = false;
  1345. }
  1346. // Keyword for loading the mtl file
  1347. }
  1348. else if (SolidParser.MtlLibGroupDescriptor.test(line)) {
  1349. // Get the name of mtl file
  1350. onFileToLoadFound(line.substring(7).trim());
  1351. // Apply smoothing
  1352. }
  1353. else if (SolidParser.SmoothDescriptor.test(line)) {
  1354. // smooth shading => apply smoothing
  1355. // Today I don't know it work with babylon and with obj.
  1356. // With the obj file an integer is set
  1357. }
  1358. else {
  1359. //If there is another possibility
  1360. console.log("Unhandled expression at line : " + line);
  1361. }
  1362. }
  1363. // At the end of the file, add the last mesh into the meshesFromObj array
  1364. if (this._hasMeshes) {
  1365. // Set the data for the last mesh
  1366. this._handledMesh = this._meshesFromObj[this._meshesFromObj.length - 1];
  1367. //Reverse indices for displaying faces in the good sense
  1368. this._indicesForBabylon.reverse();
  1369. //Get the good array
  1370. this._unwrapData();
  1371. //Set array
  1372. this._handledMesh.indices = this._indicesForBabylon;
  1373. this._handledMesh.positions = this._unwrappedPositionsForBabylon;
  1374. this._handledMesh.normals = this._unwrappedNormalsForBabylon;
  1375. this._handledMesh.uvs = this._unwrappedUVForBabylon;
  1376. if (this._loadingOptions.importVertexColors) {
  1377. this._handledMesh.colors = this._unwrappedColorsForBabylon;
  1378. }
  1379. }
  1380. // If any o or g keyword not found, create a mesh with a random id
  1381. if (!this._hasMeshes) {
  1382. var newMaterial = null;
  1383. if (this._indicesForBabylon.length) {
  1384. // reverse tab of indices
  1385. this._indicesForBabylon.reverse();
  1386. //Get positions normals uvs
  1387. this._unwrapData();
  1388. }
  1389. else {
  1390. // There is no indices in the file. We will have to switch to point cloud rendering
  1391. for (var _i = 0, _b = this._positions; _i < _b.length; _i++) {
  1392. var pos = _b[_i];
  1393. this._unwrappedPositionsForBabylon.push(pos.x, pos.y, pos.z);
  1394. }
  1395. if (this._normals.length) {
  1396. for (var _c = 0, _d = this._normals; _c < _d.length; _c++) {
  1397. var normal = _d[_c];
  1398. this._unwrappedNormalsForBabylon.push(normal.x, normal.y, normal.z);
  1399. }
  1400. }
  1401. if (this._uvs.length) {
  1402. for (var _e = 0, _f = this._uvs; _e < _f.length; _e++) {
  1403. var uv = _f[_e];
  1404. this._unwrappedUVForBabylon.push(uv.x, uv.y);
  1405. }
  1406. }
  1407. if (this._colors.length) {
  1408. for (var _g = 0, _h = this._colors; _g < _h.length; _g++) {
  1409. var color = _h[_g];
  1410. this._unwrappedColorsForBabylon.push(color.r, color.g, color.b, color.a);
  1411. }
  1412. }
  1413. if (!this._materialNameFromObj) {
  1414. // Create a material with point cloud on
  1415. newMaterial = new core_Buffers_buffer__WEBPACK_IMPORTED_MODULE_0__.StandardMaterial(core_Buffers_buffer__WEBPACK_IMPORTED_MODULE_0__.Geometry.RandomId(), scene);
  1416. newMaterial.pointsCloud = true;
  1417. this._materialNameFromObj = newMaterial.name;
  1418. if (!this._normals.length) {
  1419. newMaterial.disableLighting = true;
  1420. newMaterial.emissiveColor = core_Buffers_buffer__WEBPACK_IMPORTED_MODULE_0__.Color3.White();
  1421. }
  1422. }
  1423. }
  1424. //Set data for one mesh
  1425. this._meshesFromObj.push({
  1426. name: core_Buffers_buffer__WEBPACK_IMPORTED_MODULE_0__.Geometry.RandomId(),
  1427. indices: this._indicesForBabylon,
  1428. positions: this._unwrappedPositionsForBabylon,
  1429. colors: this._unwrappedColorsForBabylon,
  1430. normals: this._unwrappedNormalsForBabylon,
  1431. uvs: this._unwrappedUVForBabylon,
  1432. materialName: this._materialNameFromObj,
  1433. directMaterial: newMaterial,
  1434. });
  1435. }
  1436. //Set data for each mesh
  1437. for (var j = 0; j < this._meshesFromObj.length; j++) {
  1438. //check meshesNames (stlFileLoader)
  1439. if (meshesNames && this._meshesFromObj[j].name) {
  1440. if (meshesNames instanceof Array) {
  1441. if (meshesNames.indexOf(this._meshesFromObj[j].name) === -1) {
  1442. continue;
  1443. }
  1444. }
  1445. else {
  1446. if (this._meshesFromObj[j].name !== meshesNames) {
  1447. continue;
  1448. }
  1449. }
  1450. }
  1451. //Get the current mesh
  1452. //Set the data with VertexBuffer for each mesh
  1453. this._handledMesh = this._meshesFromObj[j];
  1454. //Create a Mesh with the name of the obj mesh
  1455. scene._blockEntityCollection = !!assetContainer;
  1456. var babylonMesh = new core_Buffers_buffer__WEBPACK_IMPORTED_MODULE_0__.Mesh(this._meshesFromObj[j].name, scene);
  1457. babylonMesh._parentContainer = assetContainer;
  1458. scene._blockEntityCollection = false;
  1459. //Push the name of the material to an array
  1460. //This is indispensable for the importMesh function
  1461. this._materialToUse.push(this._meshesFromObj[j].materialName);
  1462. if (((_a = this._handledMesh.positions) === null || _a === void 0 ? void 0 : _a.length) === 0) {
  1463. //Push the mesh into an array
  1464. this._babylonMeshesArray.push(babylonMesh);
  1465. continue;
  1466. }
  1467. var vertexData = new core_Buffers_buffer__WEBPACK_IMPORTED_MODULE_0__.VertexData(); //The container for the values
  1468. //Set the data for the babylonMesh
  1469. vertexData.uvs = this._handledMesh.uvs;
  1470. vertexData.indices = this._handledMesh.indices;
  1471. vertexData.positions = this._handledMesh.positions;
  1472. if (this._loadingOptions.computeNormals) {
  1473. var normals = new Array();
  1474. core_Buffers_buffer__WEBPACK_IMPORTED_MODULE_0__.VertexData.ComputeNormals(this._handledMesh.positions, this._handledMesh.indices, normals);
  1475. vertexData.normals = normals;
  1476. }
  1477. else {
  1478. vertexData.normals = this._handledMesh.normals;
  1479. }
  1480. if (this._loadingOptions.importVertexColors) {
  1481. vertexData.colors = this._handledMesh.colors;
  1482. }
  1483. //Set the data from the VertexBuffer to the current Mesh
  1484. vertexData.applyToMesh(babylonMesh);
  1485. if (this._loadingOptions.invertY) {
  1486. babylonMesh.scaling.y *= -1;
  1487. }
  1488. if (this._loadingOptions.optimizeNormals) {
  1489. this._optimizeNormals(babylonMesh);
  1490. }
  1491. //Push the mesh into an array
  1492. this._babylonMeshesArray.push(babylonMesh);
  1493. if (this._handledMesh.directMaterial) {
  1494. babylonMesh.material = this._handledMesh.directMaterial;
  1495. }
  1496. }
  1497. };
  1498. // Descriptor
  1499. /** Object descriptor */
  1500. SolidParser.ObjectDescriptor = /^o/;
  1501. /** Group descriptor */
  1502. SolidParser.GroupDescriptor = /^g/;
  1503. /** Material lib descriptor */
  1504. SolidParser.MtlLibGroupDescriptor = /^mtllib /;
  1505. /** Use a material descriptor */
  1506. SolidParser.UseMtlDescriptor = /^usemtl /;
  1507. /** Smooth descriptor */
  1508. SolidParser.SmoothDescriptor = /^s /;
  1509. // Patterns
  1510. /** Pattern used to detect a vertex */
  1511. SolidParser.VertexPattern = /v(\s+[\d|\.|\+|\-|e|E]+){3,7}/;
  1512. /** Pattern used to detect a normal */
  1513. SolidParser.NormalPattern = /vn(\s+[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/;
  1514. /** Pattern used to detect a UV set */
  1515. SolidParser.UVPattern = /vt(\s+[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/;
  1516. /** Pattern used to detect a first kind of face (f vertex vertex vertex) */
  1517. SolidParser.FacePattern1 = /f\s+(([\d]{1,}[\s]?){3,})+/;
  1518. /** Pattern used to detect a second kind of face (f vertex/uvs vertex/uvs vertex/uvs) */
  1519. SolidParser.FacePattern2 = /f\s+((([\d]{1,}\/[\d]{1,}[\s]?){3,})+)/;
  1520. /** Pattern used to detect a third kind of face (f vertex/uvs/normal vertex/uvs/normal vertex/uvs/normal) */
  1521. SolidParser.FacePattern3 = /f\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){3,})+)/;
  1522. /** Pattern used to detect a fourth kind of face (f vertex//normal vertex//normal vertex//normal)*/
  1523. SolidParser.FacePattern4 = /f\s+((([\d]{1,}\/\/[\d]{1,}[\s]?){3,})+)/;
  1524. /** Pattern used to detect a fifth kind of face (f -vertex/-uvs/-normal -vertex/-uvs/-normal -vertex/-uvs/-normal) */
  1525. SolidParser.FacePattern5 = /f\s+(((-[\d]{1,}\/-[\d]{1,}\/-[\d]{1,}[\s]?){3,})+)/;
  1526. return SolidParser;
  1527. }());
  1528. /***/ }),
  1529. /***/ "../../../lts/loaders/dist/STL/index.js":
  1530. /*!**********************************************!*\
  1531. !*** ../../../lts/loaders/dist/STL/index.js ***!
  1532. \**********************************************/
  1533. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1534. __webpack_require__.r(__webpack_exports__);
  1535. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1536. /* harmony export */ "STLFileLoader": () => (/* reexport safe */ _stlFileLoader__WEBPACK_IMPORTED_MODULE_0__.STLFileLoader)
  1537. /* harmony export */ });
  1538. /* harmony import */ var _stlFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./stlFileLoader */ "../../../lts/loaders/dist/STL/stlFileLoader.js");
  1539. /***/ }),
  1540. /***/ "../../../lts/loaders/dist/STL/stlFileLoader.js":
  1541. /*!******************************************************!*\
  1542. !*** ../../../lts/loaders/dist/STL/stlFileLoader.js ***!
  1543. \******************************************************/
  1544. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1545. __webpack_require__.r(__webpack_exports__);
  1546. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1547. /* harmony export */ "STLFileLoader": () => (/* binding */ STLFileLoader)
  1548. /* harmony export */ });
  1549. /* harmony import */ var core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/assetContainer */ "core/Misc/observable");
  1550. /* harmony import */ var core_Misc_tools__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__);
  1551. /**
  1552. * STL file type loader.
  1553. * This is a babylon scene loader plugin.
  1554. */
  1555. var STLFileLoader = /** @class */ (function () {
  1556. function STLFileLoader() {
  1557. /** @hidden */
  1558. this.solidPattern = /solid (\S*)([\S\s]*?)endsolid[ ]*(\S*)/g;
  1559. /** @hidden */
  1560. this.facetsPattern = /facet([\s\S]*?)endfacet/g;
  1561. /** @hidden */
  1562. this.normalPattern = /normal[\s]+([\-+]?[0-9]+\.?[0-9]*([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+/g;
  1563. /** @hidden */
  1564. this.vertexPattern = /vertex[\s]+([\-+]?[0-9]+\.?[0-9]*([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+/g;
  1565. /**
  1566. * Defines the name of the plugin.
  1567. */
  1568. this.name = "stl";
  1569. /**
  1570. * Defines the extensions the stl loader is able to load.
  1571. * force data to come in as an ArrayBuffer
  1572. * we'll convert to string if it looks like it's an ASCII .stl
  1573. */
  1574. this.extensions = {
  1575. ".stl": { isBinary: true },
  1576. };
  1577. }
  1578. /**
  1579. * Import meshes into a scene.
  1580. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  1581. * @param scene The scene to import into
  1582. * @param data The data to import
  1583. * @param rootUrl The root url for scene and resources
  1584. * @param meshes The meshes array to import into
  1585. * @param particleSystems The particle systems array to import into
  1586. * @param skeletons The skeletons array to import into
  1587. * @param onError The callback when import fails
  1588. * @returns True if successful or false otherwise
  1589. */
  1590. STLFileLoader.prototype.importMesh = function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons) {
  1591. var matches;
  1592. if (typeof data !== "string") {
  1593. if (this._isBinary(data)) {
  1594. // binary .stl
  1595. var babylonMesh = new core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.Mesh("stlmesh", scene);
  1596. this._parseBinary(babylonMesh, data);
  1597. if (meshes) {
  1598. meshes.push(babylonMesh);
  1599. }
  1600. return true;
  1601. }
  1602. // ASCII .stl
  1603. // convert to string
  1604. var array_buffer = new Uint8Array(data);
  1605. var str = "";
  1606. for (var i = 0; i < data.byteLength; i++) {
  1607. str += String.fromCharCode(array_buffer[i]); // implicitly assumes little-endian
  1608. }
  1609. data = str;
  1610. }
  1611. //if arrived here, data is a string, containing the STLA data.
  1612. while ((matches = this.solidPattern.exec(data))) {
  1613. var meshName = matches[1];
  1614. var meshNameFromEnd = matches[3];
  1615. if (meshName != meshNameFromEnd) {
  1616. core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("Error in STL, solid name != endsolid name");
  1617. return false;
  1618. }
  1619. // check meshesNames
  1620. if (meshesNames && meshName) {
  1621. if (meshesNames instanceof Array) {
  1622. if (!meshesNames.indexOf(meshName)) {
  1623. continue;
  1624. }
  1625. }
  1626. else {
  1627. if (meshName !== meshesNames) {
  1628. continue;
  1629. }
  1630. }
  1631. }
  1632. // stl mesh name can be empty as well
  1633. meshName = meshName || "stlmesh";
  1634. var babylonMesh = new core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.Mesh(meshName, scene);
  1635. this._parseASCII(babylonMesh, matches[2]);
  1636. if (meshes) {
  1637. meshes.push(babylonMesh);
  1638. }
  1639. }
  1640. return true;
  1641. };
  1642. /**
  1643. * Load into a scene.
  1644. * @param scene The scene to load into
  1645. * @param data The data to import
  1646. * @param rootUrl The root url for scene and resources
  1647. * @param onError The callback when import fails
  1648. * @returns true if successful or false otherwise
  1649. */
  1650. STLFileLoader.prototype.load = function (scene, data, rootUrl) {
  1651. var result = this.importMesh(null, scene, data, rootUrl, null, null, null);
  1652. return result;
  1653. };
  1654. /**
  1655. * Load into an asset container.
  1656. * @param scene The scene to load into
  1657. * @param data The data to import
  1658. * @param rootUrl The root url for scene and resources
  1659. * @param onError The callback when import fails
  1660. * @returns The loaded asset container
  1661. */
  1662. STLFileLoader.prototype.loadAssetContainer = function (scene, data, rootUrl, onError) {
  1663. var container = new core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.AssetContainer(scene);
  1664. scene._blockEntityCollection = true;
  1665. this.importMesh(null, scene, data, rootUrl, container.meshes, null, null);
  1666. scene._blockEntityCollection = false;
  1667. return container;
  1668. };
  1669. STLFileLoader.prototype._isBinary = function (data) {
  1670. // check if file size is correct for binary stl
  1671. var faceSize, nFaces, reader;
  1672. reader = new DataView(data);
  1673. // A Binary STL header is 80 bytes, if the data size is not great than
  1674. // that then it's not a binary STL.
  1675. if (reader.byteLength <= 80) {
  1676. return false;
  1677. }
  1678. faceSize = (32 / 8) * 3 + (32 / 8) * 3 * 3 + 16 / 8;
  1679. nFaces = reader.getUint32(80, true);
  1680. if (80 + 32 / 8 + nFaces * faceSize === reader.byteLength) {
  1681. return true;
  1682. }
  1683. // check characters higher than ASCII to confirm binary
  1684. var fileLength = reader.byteLength;
  1685. for (var index = 0; index < fileLength; index++) {
  1686. if (reader.getUint8(index) > 127) {
  1687. return true;
  1688. }
  1689. }
  1690. return false;
  1691. };
  1692. STLFileLoader.prototype._parseBinary = function (mesh, data) {
  1693. var reader = new DataView(data);
  1694. var faces = reader.getUint32(80, true);
  1695. var dataOffset = 84;
  1696. var faceLength = 12 * 4 + 2;
  1697. var offset = 0;
  1698. var positions = new Float32Array(faces * 3 * 3);
  1699. var normals = new Float32Array(faces * 3 * 3);
  1700. var indices = new Uint32Array(faces * 3);
  1701. var indicesCount = 0;
  1702. for (var face = 0; face < faces; face++) {
  1703. var start = dataOffset + face * faceLength;
  1704. var normalX = reader.getFloat32(start, true);
  1705. var normalY = reader.getFloat32(start + 4, true);
  1706. var normalZ = reader.getFloat32(start + 8, true);
  1707. for (var i = 1; i <= 3; i++) {
  1708. var vertexstart = start + i * 12;
  1709. // ordering is intentional to match ascii import
  1710. positions[offset] = reader.getFloat32(vertexstart, true);
  1711. normals[offset] = normalX;
  1712. if (!STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES) {
  1713. positions[offset + 2] = reader.getFloat32(vertexstart + 4, true);
  1714. positions[offset + 1] = reader.getFloat32(vertexstart + 8, true);
  1715. normals[offset + 2] = normalY;
  1716. normals[offset + 1] = normalZ;
  1717. }
  1718. else {
  1719. positions[offset + 1] = reader.getFloat32(vertexstart + 4, true);
  1720. positions[offset + 2] = reader.getFloat32(vertexstart + 8, true);
  1721. normals[offset + 1] = normalY;
  1722. normals[offset + 2] = normalZ;
  1723. }
  1724. offset += 3;
  1725. }
  1726. indices[indicesCount] = indicesCount++;
  1727. indices[indicesCount] = indicesCount++;
  1728. indices[indicesCount] = indicesCount++;
  1729. }
  1730. mesh.setVerticesData(core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind, positions);
  1731. mesh.setVerticesData(core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind, normals);
  1732. mesh.setIndices(indices);
  1733. mesh.computeWorldMatrix(true);
  1734. };
  1735. STLFileLoader.prototype._parseASCII = function (mesh, solidData) {
  1736. var positions = [];
  1737. var normals = [];
  1738. var indices = [];
  1739. var indicesCount = 0;
  1740. //load facets, ignoring loop as the standard doesn't define it can contain more than vertices
  1741. var matches;
  1742. while ((matches = this.facetsPattern.exec(solidData))) {
  1743. var facet = matches[1];
  1744. //one normal per face
  1745. var normalMatches = this.normalPattern.exec(facet);
  1746. this.normalPattern.lastIndex = 0;
  1747. if (!normalMatches) {
  1748. continue;
  1749. }
  1750. var normal = [Number(normalMatches[1]), Number(normalMatches[5]), Number(normalMatches[3])];
  1751. var vertexMatch;
  1752. while ((vertexMatch = this.vertexPattern.exec(facet))) {
  1753. if (!STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES) {
  1754. positions.push(Number(vertexMatch[1]), Number(vertexMatch[5]), Number(vertexMatch[3]));
  1755. normals.push(normal[0], normal[1], normal[2]);
  1756. }
  1757. else {
  1758. positions.push(Number(vertexMatch[1]), Number(vertexMatch[3]), Number(vertexMatch[5]));
  1759. // Flipping the second and third component because inverted
  1760. // when normal was declared.
  1761. normals.push(normal[0], normal[2], normal[1]);
  1762. }
  1763. }
  1764. indices.push(indicesCount++, indicesCount++, indicesCount++);
  1765. this.vertexPattern.lastIndex = 0;
  1766. }
  1767. this.facetsPattern.lastIndex = 0;
  1768. mesh.setVerticesData(core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind, positions);
  1769. mesh.setVerticesData(core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind, normals);
  1770. mesh.setIndices(indices);
  1771. mesh.computeWorldMatrix(true);
  1772. };
  1773. /**
  1774. * Defines if Y and Z axes are swapped or not when loading an STL file.
  1775. * The default is false to maintain backward compatibility. When set to
  1776. * true, coordinates from the STL file are used without change.
  1777. */
  1778. STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES = false;
  1779. return STLFileLoader;
  1780. }());
  1781. if (core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.SceneLoader) {
  1782. core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.SceneLoader.RegisterPlugin(new STLFileLoader());
  1783. }
  1784. /***/ }),
  1785. /***/ "../../../lts/loaders/dist/glTF/1.0/glTFBinaryExtension.js":
  1786. /*!*****************************************************************!*\
  1787. !*** ../../../lts/loaders/dist/glTF/1.0/glTFBinaryExtension.js ***!
  1788. \*****************************************************************/
  1789. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1790. __webpack_require__.r(__webpack_exports__);
  1791. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1792. /* harmony export */ "GLTFBinaryExtension": () => (/* binding */ GLTFBinaryExtension)
  1793. /* harmony export */ });
  1794. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.js");
  1795. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFLoader */ "../../../lts/loaders/dist/glTF/1.0/glTFLoader.js");
  1796. /* harmony import */ var _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFLoaderUtils */ "../../../lts/loaders/dist/glTF/1.0/glTFLoaderUtils.js");
  1797. /* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "../../../lts/loaders/dist/glTF/1.0/glTFLoaderInterfaces.js");
  1798. var BinaryExtensionBufferName = "binary_glTF";
  1799. /** @hidden */
  1800. var GLTFBinaryExtension = /** @class */ (function (_super) {
  1801. (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(GLTFBinaryExtension, _super);
  1802. function GLTFBinaryExtension() {
  1803. return _super.call(this, "KHR_binary_glTF") || this;
  1804. }
  1805. GLTFBinaryExtension.prototype.loadRuntimeAsync = function (scene, data, rootUrl, onSuccess, onError) {
  1806. var extensionsUsed = data.json.extensionsUsed;
  1807. if (!extensionsUsed || extensionsUsed.indexOf(this.name) === -1 || !data.bin) {
  1808. return false;
  1809. }
  1810. this._bin = data.bin;
  1811. onSuccess(_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderBase.CreateRuntime(data.json, scene, rootUrl));
  1812. return true;
  1813. };
  1814. GLTFBinaryExtension.prototype.loadBufferAsync = function (gltfRuntime, id, onSuccess, onError) {
  1815. if (gltfRuntime.extensionsUsed.indexOf(this.name) === -1) {
  1816. return false;
  1817. }
  1818. if (id !== BinaryExtensionBufferName) {
  1819. return false;
  1820. }
  1821. this._bin.readAsync(0, this._bin.byteLength).then(onSuccess, function (error) { return onError(error.message); });
  1822. return true;
  1823. };
  1824. GLTFBinaryExtension.prototype.loadTextureBufferAsync = function (gltfRuntime, id, onSuccess, onError) {
  1825. var texture = gltfRuntime.textures[id];
  1826. var source = gltfRuntime.images[texture.source];
  1827. if (!source.extensions || !(this.name in source.extensions)) {
  1828. return false;
  1829. }
  1830. var sourceExt = source.extensions[this.name];
  1831. var bufferView = gltfRuntime.bufferViews[sourceExt.bufferView];
  1832. var buffer = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, 0, bufferView.byteLength, _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_3__.EComponentType.UNSIGNED_BYTE);
  1833. onSuccess(buffer);
  1834. return true;
  1835. };
  1836. GLTFBinaryExtension.prototype.loadShaderStringAsync = function (gltfRuntime, id, onSuccess, onError) {
  1837. var shader = gltfRuntime.shaders[id];
  1838. if (!shader.extensions || !(this.name in shader.extensions)) {
  1839. return false;
  1840. }
  1841. var binaryExtensionShader = shader.extensions[this.name];
  1842. var bufferView = gltfRuntime.bufferViews[binaryExtensionShader.bufferView];
  1843. var shaderBytes = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, 0, bufferView.byteLength, _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_3__.EComponentType.UNSIGNED_BYTE);
  1844. setTimeout(function () {
  1845. var shaderString = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.DecodeBufferToText(shaderBytes);
  1846. onSuccess(shaderString);
  1847. });
  1848. return true;
  1849. };
  1850. return GLTFBinaryExtension;
  1851. }(_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderExtension));
  1852. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(new GLTFBinaryExtension());
  1853. /***/ }),
  1854. /***/ "../../../lts/loaders/dist/glTF/1.0/glTFLoader.js":
  1855. /*!********************************************************!*\
  1856. !*** ../../../lts/loaders/dist/glTF/1.0/glTFLoader.js ***!
  1857. \********************************************************/
  1858. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  1859. __webpack_require__.r(__webpack_exports__);
  1860. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  1861. /* harmony export */ "GLTFLoader": () => (/* binding */ GLTFLoader),
  1862. /* harmony export */ "GLTFLoaderBase": () => (/* binding */ GLTFLoaderBase),
  1863. /* harmony export */ "GLTFLoaderExtension": () => (/* binding */ GLTFLoaderExtension)
  1864. /* harmony export */ });
  1865. /* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "../../../lts/loaders/dist/glTF/1.0/glTFLoaderInterfaces.js");
  1866. /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core/Engines/constants */ "core/Misc/observable");
  1867. /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  1868. /* harmony import */ var _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFLoaderUtils */ "../../../lts/loaders/dist/glTF/1.0/glTFLoaderUtils.js");
  1869. /* harmony import */ var _glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../glTFFileLoader */ "../../../lts/loaders/dist/glTF/glTFFileLoader.js");
  1870. /**
  1871. * Tokenizer. Used for shaders compatibility
  1872. * Automatically map world, view, projection, worldViewProjection, attributes and so on
  1873. */
  1874. var ETokenType;
  1875. (function (ETokenType) {
  1876. ETokenType[ETokenType["IDENTIFIER"] = 1] = "IDENTIFIER";
  1877. ETokenType[ETokenType["UNKNOWN"] = 2] = "UNKNOWN";
  1878. ETokenType[ETokenType["END_OF_INPUT"] = 3] = "END_OF_INPUT";
  1879. })(ETokenType || (ETokenType = {}));
  1880. var Tokenizer = /** @class */ (function () {
  1881. function Tokenizer(toParse) {
  1882. this._pos = 0;
  1883. this.currentToken = ETokenType.UNKNOWN;
  1884. this.currentIdentifier = "";
  1885. this.currentString = "";
  1886. this.isLetterOrDigitPattern = /^[a-zA-Z0-9]+$/;
  1887. this._toParse = toParse;
  1888. this._maxPos = toParse.length;
  1889. }
  1890. Tokenizer.prototype.getNextToken = function () {
  1891. if (this.isEnd()) {
  1892. return ETokenType.END_OF_INPUT;
  1893. }
  1894. this.currentString = this.read();
  1895. this.currentToken = ETokenType.UNKNOWN;
  1896. if (this.currentString === "_" || this.isLetterOrDigitPattern.test(this.currentString)) {
  1897. this.currentToken = ETokenType.IDENTIFIER;
  1898. this.currentIdentifier = this.currentString;
  1899. while (!this.isEnd() && (this.isLetterOrDigitPattern.test((this.currentString = this.peek())) || this.currentString === "_")) {
  1900. this.currentIdentifier += this.currentString;
  1901. this.forward();
  1902. }
  1903. }
  1904. return this.currentToken;
  1905. };
  1906. Tokenizer.prototype.peek = function () {
  1907. return this._toParse[this._pos];
  1908. };
  1909. Tokenizer.prototype.read = function () {
  1910. return this._toParse[this._pos++];
  1911. };
  1912. Tokenizer.prototype.forward = function () {
  1913. this._pos++;
  1914. };
  1915. Tokenizer.prototype.isEnd = function () {
  1916. return this._pos >= this._maxPos;
  1917. };
  1918. return Tokenizer;
  1919. }());
  1920. /**
  1921. * Values
  1922. */
  1923. var glTFTransforms = ["MODEL", "VIEW", "PROJECTION", "MODELVIEW", "MODELVIEWPROJECTION", "JOINTMATRIX"];
  1924. var babylonTransforms = ["world", "view", "projection", "worldView", "worldViewProjection", "mBones"];
  1925. var glTFAnimationPaths = ["translation", "rotation", "scale"];
  1926. var babylonAnimationPaths = ["position", "rotationQuaternion", "scaling"];
  1927. /**
  1928. * Parse
  1929. * @param parsedBuffers
  1930. * @param gltfRuntime
  1931. */
  1932. var parseBuffers = function (parsedBuffers, gltfRuntime) {
  1933. for (var buf in parsedBuffers) {
  1934. var parsedBuffer = parsedBuffers[buf];
  1935. gltfRuntime.buffers[buf] = parsedBuffer;
  1936. gltfRuntime.buffersCount++;
  1937. }
  1938. };
  1939. var parseShaders = function (parsedShaders, gltfRuntime) {
  1940. for (var sha in parsedShaders) {
  1941. var parsedShader = parsedShaders[sha];
  1942. gltfRuntime.shaders[sha] = parsedShader;
  1943. gltfRuntime.shaderscount++;
  1944. }
  1945. };
  1946. var parseObject = function (parsedObjects, runtimeProperty, gltfRuntime) {
  1947. for (var object in parsedObjects) {
  1948. var parsedObject = parsedObjects[object];
  1949. gltfRuntime[runtimeProperty][object] = parsedObject;
  1950. }
  1951. };
  1952. /**
  1953. * Utils
  1954. * @param buffer
  1955. */
  1956. var normalizeUVs = function (buffer) {
  1957. if (!buffer) {
  1958. return;
  1959. }
  1960. for (var i = 0; i < buffer.length / 2; i++) {
  1961. buffer[i * 2 + 1] = 1.0 - buffer[i * 2 + 1];
  1962. }
  1963. };
  1964. var getAttribute = function (attributeParameter) {
  1965. if (attributeParameter.semantic === "NORMAL") {
  1966. return "normal";
  1967. }
  1968. else if (attributeParameter.semantic === "POSITION") {
  1969. return "position";
  1970. }
  1971. else if (attributeParameter.semantic === "JOINT") {
  1972. return "matricesIndices";
  1973. }
  1974. else if (attributeParameter.semantic === "WEIGHT") {
  1975. return "matricesWeights";
  1976. }
  1977. else if (attributeParameter.semantic === "COLOR") {
  1978. return "color";
  1979. }
  1980. else if (attributeParameter.semantic && attributeParameter.semantic.indexOf("TEXCOORD_") !== -1) {
  1981. var channel = Number(attributeParameter.semantic.split("_")[1]);
  1982. return "uv" + (channel === 0 ? "" : channel + 1);
  1983. }
  1984. return null;
  1985. };
  1986. /**
  1987. * Loads and creates animations
  1988. * @param gltfRuntime
  1989. */
  1990. var loadAnimations = function (gltfRuntime) {
  1991. for (var anim in gltfRuntime.animations) {
  1992. var animation = gltfRuntime.animations[anim];
  1993. if (!animation.channels || !animation.samplers) {
  1994. continue;
  1995. }
  1996. var lastAnimation = null;
  1997. for (var i = 0; i < animation.channels.length; i++) {
  1998. // Get parameters and load buffers
  1999. var channel = animation.channels[i];
  2000. var sampler = animation.samplers[channel.sampler];
  2001. if (!sampler) {
  2002. continue;
  2003. }
  2004. var inputData = null;
  2005. var outputData = null;
  2006. if (animation.parameters) {
  2007. inputData = animation.parameters[sampler.input];
  2008. outputData = animation.parameters[sampler.output];
  2009. }
  2010. else {
  2011. inputData = sampler.input;
  2012. outputData = sampler.output;
  2013. }
  2014. var bufferInput = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetBufferFromAccessor(gltfRuntime, gltfRuntime.accessors[inputData]);
  2015. var bufferOutput = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetBufferFromAccessor(gltfRuntime, gltfRuntime.accessors[outputData]);
  2016. var targetId = channel.target.id;
  2017. var targetNode = gltfRuntime.scene.getNodeById(targetId);
  2018. if (targetNode === null) {
  2019. targetNode = gltfRuntime.scene.getNodeByName(targetId);
  2020. }
  2021. if (targetNode === null) {
  2022. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn("Creating animation named " + anim + ". But cannot find node named " + targetId + " to attach to");
  2023. continue;
  2024. }
  2025. var isBone = targetNode instanceof core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Bone;
  2026. // Get target path (position, rotation or scaling)
  2027. var targetPath = channel.target.path;
  2028. var targetPathIndex = glTFAnimationPaths.indexOf(targetPath);
  2029. if (targetPathIndex !== -1) {
  2030. targetPath = babylonAnimationPaths[targetPathIndex];
  2031. }
  2032. // Determine animation type
  2033. var animationType = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_MATRIX;
  2034. if (!isBone) {
  2035. if (targetPath === "rotationQuaternion") {
  2036. animationType = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_QUATERNION;
  2037. targetNode.rotationQuaternion = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion();
  2038. }
  2039. else {
  2040. animationType = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_VECTOR3;
  2041. }
  2042. }
  2043. // Create animation and key frames
  2044. var babylonAnimation = null;
  2045. var keys = [];
  2046. var arrayOffset = 0;
  2047. var modifyKey = false;
  2048. if (isBone && lastAnimation && lastAnimation.getKeys().length === bufferInput.length) {
  2049. babylonAnimation = lastAnimation;
  2050. modifyKey = true;
  2051. }
  2052. if (!modifyKey) {
  2053. gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;
  2054. babylonAnimation = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Animation(anim, isBone ? "_matrix" : targetPath, 1, animationType, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONLOOPMODE_CYCLE);
  2055. gltfRuntime.scene._blockEntityCollection = false;
  2056. }
  2057. // For each frame
  2058. for (var j = 0; j < bufferInput.length; j++) {
  2059. var value = null;
  2060. if (targetPath === "rotationQuaternion") {
  2061. // VEC4
  2062. value = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion.FromArray([bufferOutput[arrayOffset], bufferOutput[arrayOffset + 1], bufferOutput[arrayOffset + 2], bufferOutput[arrayOffset + 3]]);
  2063. arrayOffset += 4;
  2064. }
  2065. else {
  2066. // Position and scaling are VEC3
  2067. value = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray([bufferOutput[arrayOffset], bufferOutput[arrayOffset + 1], bufferOutput[arrayOffset + 2]]);
  2068. arrayOffset += 3;
  2069. }
  2070. if (isBone) {
  2071. var bone = targetNode;
  2072. var translation = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero();
  2073. var rotationQuaternion = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion();
  2074. var scaling = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero();
  2075. // Warning on decompose
  2076. var mat = bone.getBaseMatrix();
  2077. if (modifyKey && lastAnimation) {
  2078. mat = lastAnimation.getKeys()[j].value;
  2079. }
  2080. mat.decompose(scaling, rotationQuaternion, translation);
  2081. if (targetPath === "position") {
  2082. translation = value;
  2083. }
  2084. else if (targetPath === "rotationQuaternion") {
  2085. rotationQuaternion = value;
  2086. }
  2087. else {
  2088. scaling = value;
  2089. }
  2090. value = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.Compose(scaling, rotationQuaternion, translation);
  2091. }
  2092. if (!modifyKey) {
  2093. keys.push({
  2094. frame: bufferInput[j],
  2095. value: value,
  2096. });
  2097. }
  2098. else if (lastAnimation) {
  2099. lastAnimation.getKeys()[j].value = value;
  2100. }
  2101. }
  2102. // Finish
  2103. if (!modifyKey && babylonAnimation) {
  2104. babylonAnimation.setKeys(keys);
  2105. targetNode.animations.push(babylonAnimation);
  2106. }
  2107. lastAnimation = babylonAnimation;
  2108. gltfRuntime.scene.stopAnimation(targetNode);
  2109. gltfRuntime.scene.beginAnimation(targetNode, 0, bufferInput[bufferInput.length - 1], true, 1.0);
  2110. }
  2111. }
  2112. };
  2113. /**
  2114. * Returns the bones transformation matrix
  2115. * @param node
  2116. */
  2117. var configureBoneTransformation = function (node) {
  2118. var mat = null;
  2119. if (node.translation || node.rotation || node.scale) {
  2120. var scale = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(node.scale || [1, 1, 1]);
  2121. var rotation = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion.FromArray(node.rotation || [0, 0, 0, 1]);
  2122. var position = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(node.translation || [0, 0, 0]);
  2123. mat = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.Compose(scale, rotation, position);
  2124. }
  2125. else {
  2126. mat = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.FromArray(node.matrix);
  2127. }
  2128. return mat;
  2129. };
  2130. /**
  2131. * Returns the parent bone
  2132. * @param gltfRuntime
  2133. * @param skins
  2134. * @param jointName
  2135. * @param newSkeleton
  2136. */
  2137. var getParentBone = function (gltfRuntime, skins, jointName, newSkeleton) {
  2138. // Try to find
  2139. for (var i = 0; i < newSkeleton.bones.length; i++) {
  2140. if (newSkeleton.bones[i].name === jointName) {
  2141. return newSkeleton.bones[i];
  2142. }
  2143. }
  2144. // Not found, search in gltf nodes
  2145. var nodes = gltfRuntime.nodes;
  2146. for (var nde in nodes) {
  2147. var node = nodes[nde];
  2148. if (!node.jointName) {
  2149. continue;
  2150. }
  2151. var children = node.children;
  2152. for (var i = 0; i < children.length; i++) {
  2153. var child = gltfRuntime.nodes[children[i]];
  2154. if (!child.jointName) {
  2155. continue;
  2156. }
  2157. if (child.jointName === jointName) {
  2158. var mat = configureBoneTransformation(node);
  2159. var bone = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Bone(node.name || "", newSkeleton, getParentBone(gltfRuntime, skins, node.jointName, newSkeleton), mat);
  2160. bone.id = nde;
  2161. return bone;
  2162. }
  2163. }
  2164. }
  2165. return null;
  2166. };
  2167. /**
  2168. * Returns the appropriate root node
  2169. * @param nodesToRoot
  2170. * @param id
  2171. */
  2172. var getNodeToRoot = function (nodesToRoot, id) {
  2173. for (var i = 0; i < nodesToRoot.length; i++) {
  2174. var nodeToRoot = nodesToRoot[i];
  2175. for (var j = 0; j < nodeToRoot.node.children.length; j++) {
  2176. var child = nodeToRoot.node.children[j];
  2177. if (child === id) {
  2178. return nodeToRoot.bone;
  2179. }
  2180. }
  2181. }
  2182. return null;
  2183. };
  2184. /**
  2185. * Returns the node with the joint name
  2186. * @param gltfRuntime
  2187. * @param jointName
  2188. */
  2189. var getJointNode = function (gltfRuntime, jointName) {
  2190. var nodes = gltfRuntime.nodes;
  2191. var node = nodes[jointName];
  2192. if (node) {
  2193. return {
  2194. node: node,
  2195. id: jointName,
  2196. };
  2197. }
  2198. for (var nde in nodes) {
  2199. node = nodes[nde];
  2200. if (node.jointName === jointName) {
  2201. return {
  2202. node: node,
  2203. id: nde,
  2204. };
  2205. }
  2206. }
  2207. return null;
  2208. };
  2209. /**
  2210. * Checks if a nodes is in joints
  2211. * @param skins
  2212. * @param id
  2213. */
  2214. var nodeIsInJoints = function (skins, id) {
  2215. for (var i = 0; i < skins.jointNames.length; i++) {
  2216. if (skins.jointNames[i] === id) {
  2217. return true;
  2218. }
  2219. }
  2220. return false;
  2221. };
  2222. /**
  2223. * Fills the nodes to root for bones and builds hierarchy
  2224. * @param gltfRuntime
  2225. * @param newSkeleton
  2226. * @param skins
  2227. * @param nodesToRoot
  2228. */
  2229. var getNodesToRoot = function (gltfRuntime, newSkeleton, skins, nodesToRoot) {
  2230. // Creates nodes for root
  2231. for (var nde in gltfRuntime.nodes) {
  2232. var node = gltfRuntime.nodes[nde];
  2233. var id = nde;
  2234. if (!node.jointName || nodeIsInJoints(skins, node.jointName)) {
  2235. continue;
  2236. }
  2237. // Create node to root bone
  2238. var mat = configureBoneTransformation(node);
  2239. var bone = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Bone(node.name || "", newSkeleton, null, mat);
  2240. bone.id = id;
  2241. nodesToRoot.push({ bone: bone, node: node, id: id });
  2242. }
  2243. // Parenting
  2244. for (var i = 0; i < nodesToRoot.length; i++) {
  2245. var nodeToRoot = nodesToRoot[i];
  2246. var children = nodeToRoot.node.children;
  2247. for (var j = 0; j < children.length; j++) {
  2248. var child = null;
  2249. for (var k = 0; k < nodesToRoot.length; k++) {
  2250. if (nodesToRoot[k].id === children[j]) {
  2251. child = nodesToRoot[k];
  2252. break;
  2253. }
  2254. }
  2255. if (child) {
  2256. child.bone._parent = nodeToRoot.bone;
  2257. nodeToRoot.bone.children.push(child.bone);
  2258. }
  2259. }
  2260. }
  2261. };
  2262. /**
  2263. * Imports a skeleton
  2264. * @param gltfRuntime
  2265. * @param skins
  2266. * @param mesh
  2267. * @param newSkeleton
  2268. * @param id
  2269. */
  2270. var importSkeleton = function (gltfRuntime, skins, mesh, newSkeleton, id) {
  2271. if (!newSkeleton) {
  2272. newSkeleton = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Skeleton(skins.name || "", "", gltfRuntime.scene);
  2273. }
  2274. if (!skins.babylonSkeleton) {
  2275. return newSkeleton;
  2276. }
  2277. // Find the root bones
  2278. var nodesToRoot = [];
  2279. var nodesToRootToAdd = [];
  2280. getNodesToRoot(gltfRuntime, newSkeleton, skins, nodesToRoot);
  2281. newSkeleton.bones = [];
  2282. // Joints
  2283. for (var i = 0; i < skins.jointNames.length; i++) {
  2284. var jointNode = getJointNode(gltfRuntime, skins.jointNames[i]);
  2285. if (!jointNode) {
  2286. continue;
  2287. }
  2288. var node = jointNode.node;
  2289. if (!node) {
  2290. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn("Joint named " + skins.jointNames[i] + " does not exist");
  2291. continue;
  2292. }
  2293. var id = jointNode.id;
  2294. // Optimize, if the bone already exists...
  2295. var existingBone = gltfRuntime.scene.getBoneById(id);
  2296. if (existingBone) {
  2297. newSkeleton.bones.push(existingBone);
  2298. continue;
  2299. }
  2300. // Search for parent bone
  2301. var foundBone = false;
  2302. var parentBone = null;
  2303. for (var j = 0; j < i; j++) {
  2304. var jointNode_1 = getJointNode(gltfRuntime, skins.jointNames[j]);
  2305. if (!jointNode_1) {
  2306. continue;
  2307. }
  2308. var joint = jointNode_1.node;
  2309. if (!joint) {
  2310. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn("Joint named " + skins.jointNames[j] + " does not exist when looking for parent");
  2311. continue;
  2312. }
  2313. var children = joint.children;
  2314. if (!children) {
  2315. continue;
  2316. }
  2317. foundBone = false;
  2318. for (var k = 0; k < children.length; k++) {
  2319. if (children[k] === id) {
  2320. parentBone = getParentBone(gltfRuntime, skins, skins.jointNames[j], newSkeleton);
  2321. foundBone = true;
  2322. break;
  2323. }
  2324. }
  2325. if (foundBone) {
  2326. break;
  2327. }
  2328. }
  2329. // Create bone
  2330. var mat = configureBoneTransformation(node);
  2331. if (!parentBone && nodesToRoot.length > 0) {
  2332. parentBone = getNodeToRoot(nodesToRoot, id);
  2333. if (parentBone) {
  2334. if (nodesToRootToAdd.indexOf(parentBone) === -1) {
  2335. nodesToRootToAdd.push(parentBone);
  2336. }
  2337. }
  2338. }
  2339. var bone = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Bone(node.jointName || "", newSkeleton, parentBone, mat);
  2340. bone.id = id;
  2341. }
  2342. // Polish
  2343. var bones = newSkeleton.bones;
  2344. newSkeleton.bones = [];
  2345. for (var i = 0; i < skins.jointNames.length; i++) {
  2346. var jointNode = getJointNode(gltfRuntime, skins.jointNames[i]);
  2347. if (!jointNode) {
  2348. continue;
  2349. }
  2350. for (var j = 0; j < bones.length; j++) {
  2351. if (bones[j].id === jointNode.id) {
  2352. newSkeleton.bones.push(bones[j]);
  2353. break;
  2354. }
  2355. }
  2356. }
  2357. newSkeleton.prepare();
  2358. // Finish
  2359. for (var i = 0; i < nodesToRootToAdd.length; i++) {
  2360. newSkeleton.bones.push(nodesToRootToAdd[i]);
  2361. }
  2362. return newSkeleton;
  2363. };
  2364. /**
  2365. * Imports a mesh and its geometries
  2366. * @param gltfRuntime
  2367. * @param node
  2368. * @param meshes
  2369. * @param id
  2370. * @param newMesh
  2371. */
  2372. var importMesh = function (gltfRuntime, node, meshes, id, newMesh) {
  2373. if (!newMesh) {
  2374. gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;
  2375. newMesh = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Mesh(node.name || "", gltfRuntime.scene);
  2376. newMesh._parentContainer = gltfRuntime.assetContainer;
  2377. gltfRuntime.scene._blockEntityCollection = false;
  2378. newMesh.id = id;
  2379. }
  2380. if (!node.babylonNode) {
  2381. return newMesh;
  2382. }
  2383. var subMaterials = [];
  2384. var vertexData = null;
  2385. var verticesStarts = new Array();
  2386. var verticesCounts = new Array();
  2387. var indexStarts = new Array();
  2388. var indexCounts = new Array();
  2389. for (var meshIndex = 0; meshIndex < meshes.length; meshIndex++) {
  2390. var meshId = meshes[meshIndex];
  2391. var mesh = gltfRuntime.meshes[meshId];
  2392. if (!mesh) {
  2393. continue;
  2394. }
  2395. // Positions, normals and UVs
  2396. for (var i = 0; i < mesh.primitives.length; i++) {
  2397. // Temporary vertex data
  2398. var tempVertexData = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.VertexData();
  2399. var primitive = mesh.primitives[i];
  2400. if (primitive.mode !== 4) {
  2401. // continue;
  2402. }
  2403. var attributes = primitive.attributes;
  2404. var accessor = null;
  2405. var buffer = null;
  2406. // Set positions, normal and uvs
  2407. for (var semantic in attributes) {
  2408. // Link accessor and buffer view
  2409. accessor = gltfRuntime.accessors[attributes[semantic]];
  2410. buffer = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetBufferFromAccessor(gltfRuntime, accessor);
  2411. if (semantic === "NORMAL") {
  2412. tempVertexData.normals = new Float32Array(buffer.length);
  2413. tempVertexData.normals.set(buffer);
  2414. }
  2415. else if (semantic === "POSITION") {
  2416. if (_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__.GLTFFileLoader.HomogeneousCoordinates) {
  2417. tempVertexData.positions = new Float32Array(buffer.length - buffer.length / 4);
  2418. for (var j = 0; j < buffer.length; j += 4) {
  2419. tempVertexData.positions[j] = buffer[j];
  2420. tempVertexData.positions[j + 1] = buffer[j + 1];
  2421. tempVertexData.positions[j + 2] = buffer[j + 2];
  2422. }
  2423. }
  2424. else {
  2425. tempVertexData.positions = new Float32Array(buffer.length);
  2426. tempVertexData.positions.set(buffer);
  2427. }
  2428. verticesCounts.push(tempVertexData.positions.length);
  2429. }
  2430. else if (semantic.indexOf("TEXCOORD_") !== -1) {
  2431. var channel = Number(semantic.split("_")[1]);
  2432. var uvKind = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.VertexBuffer.UVKind + (channel === 0 ? "" : channel + 1);
  2433. var uvs = new Float32Array(buffer.length);
  2434. uvs.set(buffer);
  2435. normalizeUVs(uvs);
  2436. tempVertexData.set(uvs, uvKind);
  2437. }
  2438. else if (semantic === "JOINT") {
  2439. tempVertexData.matricesIndices = new Float32Array(buffer.length);
  2440. tempVertexData.matricesIndices.set(buffer);
  2441. }
  2442. else if (semantic === "WEIGHT") {
  2443. tempVertexData.matricesWeights = new Float32Array(buffer.length);
  2444. tempVertexData.matricesWeights.set(buffer);
  2445. }
  2446. else if (semantic === "COLOR") {
  2447. tempVertexData.colors = new Float32Array(buffer.length);
  2448. tempVertexData.colors.set(buffer);
  2449. }
  2450. }
  2451. // Indices
  2452. accessor = gltfRuntime.accessors[primitive.indices];
  2453. if (accessor) {
  2454. buffer = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetBufferFromAccessor(gltfRuntime, accessor);
  2455. tempVertexData.indices = new Int32Array(buffer.length);
  2456. tempVertexData.indices.set(buffer);
  2457. indexCounts.push(tempVertexData.indices.length);
  2458. }
  2459. else {
  2460. // Set indices on the fly
  2461. var indices = [];
  2462. for (var j = 0; j < tempVertexData.positions.length / 3; j++) {
  2463. indices.push(j);
  2464. }
  2465. tempVertexData.indices = new Int32Array(indices);
  2466. indexCounts.push(tempVertexData.indices.length);
  2467. }
  2468. if (!vertexData) {
  2469. vertexData = tempVertexData;
  2470. }
  2471. else {
  2472. vertexData.merge(tempVertexData);
  2473. }
  2474. // Sub material
  2475. var material_1 = gltfRuntime.scene.getMaterialById(primitive.material);
  2476. subMaterials.push(material_1 === null ? _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetDefaultMaterial(gltfRuntime.scene) : material_1);
  2477. // Update vertices start and index start
  2478. verticesStarts.push(verticesStarts.length === 0 ? 0 : verticesStarts[verticesStarts.length - 1] + verticesCounts[verticesCounts.length - 2]);
  2479. indexStarts.push(indexStarts.length === 0 ? 0 : indexStarts[indexStarts.length - 1] + indexCounts[indexCounts.length - 2]);
  2480. }
  2481. }
  2482. var material;
  2483. gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;
  2484. if (subMaterials.length > 1) {
  2485. material = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.MultiMaterial("multimat" + id, gltfRuntime.scene);
  2486. material.subMaterials = subMaterials;
  2487. }
  2488. else {
  2489. material = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.StandardMaterial("multimat" + id, gltfRuntime.scene);
  2490. }
  2491. if (subMaterials.length === 1) {
  2492. material = subMaterials[0];
  2493. }
  2494. material._parentContainer = gltfRuntime.assetContainer;
  2495. if (!newMesh.material) {
  2496. newMesh.material = material;
  2497. }
  2498. // Apply geometry
  2499. new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Geometry(id, gltfRuntime.scene, vertexData, false, newMesh);
  2500. newMesh.computeWorldMatrix(true);
  2501. gltfRuntime.scene._blockEntityCollection = false;
  2502. // Apply submeshes
  2503. newMesh.subMeshes = [];
  2504. var index = 0;
  2505. for (var meshIndex = 0; meshIndex < meshes.length; meshIndex++) {
  2506. var meshId = meshes[meshIndex];
  2507. var mesh = gltfRuntime.meshes[meshId];
  2508. if (!mesh) {
  2509. continue;
  2510. }
  2511. for (var i = 0; i < mesh.primitives.length; i++) {
  2512. if (mesh.primitives[i].mode !== 4) {
  2513. //continue;
  2514. }
  2515. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.SubMesh.AddToMesh(index, verticesStarts[index], verticesCounts[index], indexStarts[index], indexCounts[index], newMesh, newMesh, true);
  2516. index++;
  2517. }
  2518. }
  2519. // Finish
  2520. return newMesh;
  2521. };
  2522. /**
  2523. * Configure node transformation from position, rotation and scaling
  2524. * @param newNode
  2525. * @param position
  2526. * @param rotation
  2527. * @param scaling
  2528. */
  2529. var configureNode = function (newNode, position, rotation, scaling) {
  2530. if (newNode.position) {
  2531. newNode.position = position;
  2532. }
  2533. if (newNode.rotationQuaternion || newNode.rotation) {
  2534. newNode.rotationQuaternion = rotation;
  2535. }
  2536. if (newNode.scaling) {
  2537. newNode.scaling = scaling;
  2538. }
  2539. };
  2540. /**
  2541. * Configures node from transformation matrix
  2542. * @param newNode
  2543. * @param node
  2544. * @param parent
  2545. */
  2546. var configureNodeFromMatrix = function (newNode, node, parent) {
  2547. if (node.matrix) {
  2548. var position = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 0, 0);
  2549. var rotation = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion();
  2550. var scaling = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 0, 0);
  2551. var mat = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.FromArray(node.matrix);
  2552. mat.decompose(scaling, rotation, position);
  2553. configureNode(newNode, position, rotation, scaling);
  2554. }
  2555. else if (node.translation && node.rotation && node.scale) {
  2556. configureNode(newNode, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(node.translation), core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion.FromArray(node.rotation), core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(node.scale));
  2557. }
  2558. newNode.computeWorldMatrix(true);
  2559. };
  2560. /**
  2561. * Imports a node
  2562. * @param gltfRuntime
  2563. * @param node
  2564. * @param id
  2565. * @param parent
  2566. */
  2567. var importNode = function (gltfRuntime, node, id, parent) {
  2568. var lastNode = null;
  2569. if (gltfRuntime.importOnlyMeshes && (node.skin || node.meshes)) {
  2570. if (gltfRuntime.importMeshesNames && gltfRuntime.importMeshesNames.length > 0 && gltfRuntime.importMeshesNames.indexOf(node.name || "") === -1) {
  2571. return null;
  2572. }
  2573. }
  2574. // Meshes
  2575. if (node.skin) {
  2576. if (node.meshes) {
  2577. var skin = gltfRuntime.skins[node.skin];
  2578. var newMesh = importMesh(gltfRuntime, node, node.meshes, id, node.babylonNode);
  2579. newMesh.skeleton = gltfRuntime.scene.getLastSkeletonById(node.skin);
  2580. if (newMesh.skeleton === null) {
  2581. newMesh.skeleton = importSkeleton(gltfRuntime, skin, newMesh, skin.babylonSkeleton, node.skin);
  2582. if (!skin.babylonSkeleton) {
  2583. skin.babylonSkeleton = newMesh.skeleton;
  2584. }
  2585. }
  2586. lastNode = newMesh;
  2587. }
  2588. }
  2589. else if (node.meshes) {
  2590. /**
  2591. * Improve meshes property
  2592. */
  2593. var newMesh = importMesh(gltfRuntime, node, node.mesh ? [node.mesh] : node.meshes, id, node.babylonNode);
  2594. lastNode = newMesh;
  2595. }
  2596. // Lights
  2597. else if (node.light && !node.babylonNode && !gltfRuntime.importOnlyMeshes) {
  2598. var light = gltfRuntime.lights[node.light];
  2599. if (light) {
  2600. if (light.type === "ambient") {
  2601. var ambienLight = light[light.type];
  2602. var hemiLight = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.HemisphericLight(node.light, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), gltfRuntime.scene);
  2603. hemiLight.name = node.name || "";
  2604. if (ambienLight.color) {
  2605. hemiLight.diffuse = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(ambienLight.color);
  2606. }
  2607. lastNode = hemiLight;
  2608. }
  2609. else if (light.type === "directional") {
  2610. var directionalLight = light[light.type];
  2611. var dirLight = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.DirectionalLight(node.light, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), gltfRuntime.scene);
  2612. dirLight.name = node.name || "";
  2613. if (directionalLight.color) {
  2614. dirLight.diffuse = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(directionalLight.color);
  2615. }
  2616. lastNode = dirLight;
  2617. }
  2618. else if (light.type === "point") {
  2619. var pointLight = light[light.type];
  2620. var ptLight = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.PointLight(node.light, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), gltfRuntime.scene);
  2621. ptLight.name = node.name || "";
  2622. if (pointLight.color) {
  2623. ptLight.diffuse = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(pointLight.color);
  2624. }
  2625. lastNode = ptLight;
  2626. }
  2627. else if (light.type === "spot") {
  2628. var spotLight = light[light.type];
  2629. var spLight = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.SpotLight(node.light, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), 0, 0, gltfRuntime.scene);
  2630. spLight.name = node.name || "";
  2631. if (spotLight.color) {
  2632. spLight.diffuse = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(spotLight.color);
  2633. }
  2634. if (spotLight.fallOfAngle) {
  2635. spLight.angle = spotLight.fallOfAngle;
  2636. }
  2637. if (spotLight.fallOffExponent) {
  2638. spLight.exponent = spotLight.fallOffExponent;
  2639. }
  2640. lastNode = spLight;
  2641. }
  2642. }
  2643. }
  2644. // Cameras
  2645. else if (node.camera && !node.babylonNode && !gltfRuntime.importOnlyMeshes) {
  2646. var camera = gltfRuntime.cameras[node.camera];
  2647. if (camera) {
  2648. gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;
  2649. if (camera.type === "orthographic") {
  2650. var orthoCamera = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.FreeCamera(node.camera, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), gltfRuntime.scene, false);
  2651. orthoCamera.name = node.name || "";
  2652. orthoCamera.mode = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Camera.ORTHOGRAPHIC_CAMERA;
  2653. orthoCamera.attachControl();
  2654. lastNode = orthoCamera;
  2655. orthoCamera._parentContainer = gltfRuntime.assetContainer;
  2656. }
  2657. else if (camera.type === "perspective") {
  2658. var perspectiveCamera = camera[camera.type];
  2659. var persCamera = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.FreeCamera(node.camera, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), gltfRuntime.scene, false);
  2660. persCamera.name = node.name || "";
  2661. persCamera.attachControl();
  2662. if (!perspectiveCamera.aspectRatio) {
  2663. perspectiveCamera.aspectRatio = gltfRuntime.scene.getEngine().getRenderWidth() / gltfRuntime.scene.getEngine().getRenderHeight();
  2664. }
  2665. if (perspectiveCamera.znear && perspectiveCamera.zfar) {
  2666. persCamera.maxZ = perspectiveCamera.zfar;
  2667. persCamera.minZ = perspectiveCamera.znear;
  2668. }
  2669. lastNode = persCamera;
  2670. persCamera._parentContainer = gltfRuntime.assetContainer;
  2671. }
  2672. gltfRuntime.scene._blockEntityCollection = false;
  2673. }
  2674. }
  2675. // Empty node
  2676. if (!node.jointName) {
  2677. if (node.babylonNode) {
  2678. return node.babylonNode;
  2679. }
  2680. else if (lastNode === null) {
  2681. gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;
  2682. var dummy = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Mesh(node.name || "", gltfRuntime.scene);
  2683. dummy._parentContainer = gltfRuntime.assetContainer;
  2684. gltfRuntime.scene._blockEntityCollection = false;
  2685. node.babylonNode = dummy;
  2686. lastNode = dummy;
  2687. }
  2688. }
  2689. if (lastNode !== null) {
  2690. if (node.matrix && lastNode instanceof core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Mesh) {
  2691. configureNodeFromMatrix(lastNode, node, parent);
  2692. }
  2693. else {
  2694. var translation = node.translation || [0, 0, 0];
  2695. var rotation = node.rotation || [0, 0, 0, 1];
  2696. var scale = node.scale || [1, 1, 1];
  2697. configureNode(lastNode, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(translation), core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion.FromArray(rotation), core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(scale));
  2698. }
  2699. lastNode.updateCache(true);
  2700. node.babylonNode = lastNode;
  2701. }
  2702. return lastNode;
  2703. };
  2704. /**
  2705. * Traverses nodes and creates them
  2706. * @param gltfRuntime
  2707. * @param id
  2708. * @param parent
  2709. * @param meshIncluded
  2710. */
  2711. var traverseNodes = function (gltfRuntime, id, parent, meshIncluded) {
  2712. if (meshIncluded === void 0) { meshIncluded = false; }
  2713. var node = gltfRuntime.nodes[id];
  2714. var newNode = null;
  2715. if (gltfRuntime.importOnlyMeshes && !meshIncluded && gltfRuntime.importMeshesNames) {
  2716. if (gltfRuntime.importMeshesNames.indexOf(node.name || "") !== -1 || gltfRuntime.importMeshesNames.length === 0) {
  2717. meshIncluded = true;
  2718. }
  2719. else {
  2720. meshIncluded = false;
  2721. }
  2722. }
  2723. else {
  2724. meshIncluded = true;
  2725. }
  2726. if (!node.jointName && meshIncluded) {
  2727. newNode = importNode(gltfRuntime, node, id, parent);
  2728. if (newNode !== null) {
  2729. newNode.id = id;
  2730. newNode.parent = parent;
  2731. }
  2732. }
  2733. if (node.children) {
  2734. for (var i = 0; i < node.children.length; i++) {
  2735. traverseNodes(gltfRuntime, node.children[i], newNode, meshIncluded);
  2736. }
  2737. }
  2738. };
  2739. /**
  2740. * do stuff after buffers, shaders are loaded (e.g. hook up materials, load animations, etc.)
  2741. * @param gltfRuntime
  2742. */
  2743. var postLoad = function (gltfRuntime) {
  2744. // Nodes
  2745. var currentScene = gltfRuntime.currentScene;
  2746. if (currentScene) {
  2747. for (var i = 0; i < currentScene.nodes.length; i++) {
  2748. traverseNodes(gltfRuntime, currentScene.nodes[i], null);
  2749. }
  2750. }
  2751. else {
  2752. for (var thing in gltfRuntime.scenes) {
  2753. currentScene = gltfRuntime.scenes[thing];
  2754. for (var i = 0; i < currentScene.nodes.length; i++) {
  2755. traverseNodes(gltfRuntime, currentScene.nodes[i], null);
  2756. }
  2757. }
  2758. }
  2759. // Set animations
  2760. loadAnimations(gltfRuntime);
  2761. for (var i = 0; i < gltfRuntime.scene.skeletons.length; i++) {
  2762. var skeleton = gltfRuntime.scene.skeletons[i];
  2763. gltfRuntime.scene.beginAnimation(skeleton, 0, Number.MAX_VALUE, true, 1.0);
  2764. }
  2765. };
  2766. /**
  2767. * onBind shaderrs callback to set uniforms and matrices
  2768. * @param mesh
  2769. * @param gltfRuntime
  2770. * @param shaderMaterial
  2771. * @param technique
  2772. * @param material
  2773. * @param onSuccess
  2774. */
  2775. var onBindShaderMaterial = function (mesh, gltfRuntime, unTreatedUniforms, shaderMaterial, technique, material, onSuccess) {
  2776. var materialValues = material.values || technique.parameters;
  2777. for (var unif in unTreatedUniforms) {
  2778. var uniform = unTreatedUniforms[unif];
  2779. var type = uniform.type;
  2780. if (type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_MAT2 || type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_MAT3 || type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_MAT4) {
  2781. if (uniform.semantic && !uniform.source && !uniform.node) {
  2782. _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.SetMatrix(gltfRuntime.scene, mesh, uniform, unif, shaderMaterial.getEffect());
  2783. }
  2784. else if (uniform.semantic && (uniform.source || uniform.node)) {
  2785. var source = gltfRuntime.scene.getNodeByName(uniform.source || uniform.node || "");
  2786. if (source === null) {
  2787. source = gltfRuntime.scene.getNodeById(uniform.source || uniform.node || "");
  2788. }
  2789. if (source === null) {
  2790. continue;
  2791. }
  2792. _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.SetMatrix(gltfRuntime.scene, source, uniform, unif, shaderMaterial.getEffect());
  2793. }
  2794. }
  2795. else {
  2796. var value = materialValues[technique.uniforms[unif]];
  2797. if (!value) {
  2798. continue;
  2799. }
  2800. if (type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.SAMPLER_2D) {
  2801. var texture = gltfRuntime.textures[material.values ? value : uniform.value].babylonTexture;
  2802. if (texture === null || texture === undefined) {
  2803. continue;
  2804. }
  2805. shaderMaterial.getEffect().setTexture(unif, texture);
  2806. }
  2807. else {
  2808. _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.SetUniform(shaderMaterial.getEffect(), unif, value, type);
  2809. }
  2810. }
  2811. }
  2812. onSuccess(shaderMaterial);
  2813. };
  2814. /**
  2815. * Prepare uniforms to send the only one time
  2816. * Loads the appropriate textures
  2817. * @param gltfRuntime
  2818. * @param shaderMaterial
  2819. * @param technique
  2820. * @param material
  2821. */
  2822. var prepareShaderMaterialUniforms = function (gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms) {
  2823. var materialValues = material.values || technique.parameters;
  2824. var techniqueUniforms = technique.uniforms;
  2825. /**
  2826. * Prepare values here (not matrices)
  2827. */
  2828. for (var unif in unTreatedUniforms) {
  2829. var uniform = unTreatedUniforms[unif];
  2830. var type = uniform.type;
  2831. var value = materialValues[techniqueUniforms[unif]];
  2832. if (value === undefined) {
  2833. // In case the value is the same for all materials
  2834. value = uniform.value;
  2835. }
  2836. if (!value) {
  2837. continue;
  2838. }
  2839. var onLoadTexture = function (uniformName) {
  2840. return function (texture) {
  2841. if (uniform.value && uniformName) {
  2842. // Static uniform
  2843. shaderMaterial.setTexture(uniformName, texture);
  2844. delete unTreatedUniforms[uniformName];
  2845. }
  2846. };
  2847. };
  2848. // Texture (sampler2D)
  2849. if (type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.SAMPLER_2D) {
  2850. GLTFLoaderExtension.LoadTextureAsync(gltfRuntime, material.values ? value : uniform.value, onLoadTexture(unif), function () { return onLoadTexture(null); });
  2851. }
  2852. // Others
  2853. else {
  2854. if (uniform.value && _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.SetUniform(shaderMaterial, unif, material.values ? value : uniform.value, type)) {
  2855. // Static uniform
  2856. delete unTreatedUniforms[unif];
  2857. }
  2858. }
  2859. }
  2860. };
  2861. /**
  2862. * Shader compilation failed
  2863. * @param program
  2864. * @param shaderMaterial
  2865. * @param onError
  2866. */
  2867. var onShaderCompileError = function (program, shaderMaterial, onError) {
  2868. return function (effect, error) {
  2869. shaderMaterial.dispose(true);
  2870. onError("Cannot compile program named " + program.name + ". Error: " + error + ". Default material will be applied");
  2871. };
  2872. };
  2873. /**
  2874. * Shader compilation success
  2875. * @param gltfRuntime
  2876. * @param shaderMaterial
  2877. * @param technique
  2878. * @param material
  2879. * @param onSuccess
  2880. */
  2881. var onShaderCompileSuccess = function (gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms, onSuccess) {
  2882. return function (_) {
  2883. prepareShaderMaterialUniforms(gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms);
  2884. shaderMaterial.onBind = function (mesh) {
  2885. onBindShaderMaterial(mesh, gltfRuntime, unTreatedUniforms, shaderMaterial, technique, material, onSuccess);
  2886. };
  2887. };
  2888. };
  2889. /**
  2890. * Returns the appropriate uniform if already handled by babylon
  2891. * @param tokenizer
  2892. * @param technique
  2893. */
  2894. var parseShaderUniforms = function (tokenizer, technique, unTreatedUniforms) {
  2895. for (var unif in technique.uniforms) {
  2896. var uniform = technique.uniforms[unif];
  2897. var uniformParameter = technique.parameters[uniform];
  2898. if (tokenizer.currentIdentifier === unif) {
  2899. if (uniformParameter.semantic && !uniformParameter.source && !uniformParameter.node) {
  2900. var transformIndex = glTFTransforms.indexOf(uniformParameter.semantic);
  2901. if (transformIndex !== -1) {
  2902. delete unTreatedUniforms[unif];
  2903. return babylonTransforms[transformIndex];
  2904. }
  2905. }
  2906. }
  2907. }
  2908. return tokenizer.currentIdentifier;
  2909. };
  2910. /**
  2911. * All shaders loaded. Create materials one by one
  2912. * @param gltfRuntime
  2913. */
  2914. var importMaterials = function (gltfRuntime) {
  2915. // Create materials
  2916. for (var mat in gltfRuntime.materials) {
  2917. GLTFLoaderExtension.LoadMaterialAsync(gltfRuntime, mat, function (material) { }, function () { });
  2918. }
  2919. };
  2920. /**
  2921. * Implementation of the base glTF spec
  2922. * @hidden
  2923. */
  2924. var GLTFLoaderBase = /** @class */ (function () {
  2925. function GLTFLoaderBase() {
  2926. }
  2927. GLTFLoaderBase.CreateRuntime = function (parsedData, scene, rootUrl) {
  2928. var gltfRuntime = {
  2929. extensions: {},
  2930. accessors: {},
  2931. buffers: {},
  2932. bufferViews: {},
  2933. meshes: {},
  2934. lights: {},
  2935. cameras: {},
  2936. nodes: {},
  2937. images: {},
  2938. textures: {},
  2939. shaders: {},
  2940. programs: {},
  2941. samplers: {},
  2942. techniques: {},
  2943. materials: {},
  2944. animations: {},
  2945. skins: {},
  2946. extensionsUsed: [],
  2947. scenes: {},
  2948. buffersCount: 0,
  2949. shaderscount: 0,
  2950. scene: scene,
  2951. rootUrl: rootUrl,
  2952. loadedBufferCount: 0,
  2953. loadedBufferViews: {},
  2954. loadedShaderCount: 0,
  2955. importOnlyMeshes: false,
  2956. dummyNodes: [],
  2957. assetContainer: null,
  2958. };
  2959. // Parse
  2960. if (parsedData.extensions) {
  2961. parseObject(parsedData.extensions, "extensions", gltfRuntime);
  2962. }
  2963. if (parsedData.extensionsUsed) {
  2964. parseObject(parsedData.extensionsUsed, "extensionsUsed", gltfRuntime);
  2965. }
  2966. if (parsedData.buffers) {
  2967. parseBuffers(parsedData.buffers, gltfRuntime);
  2968. }
  2969. if (parsedData.bufferViews) {
  2970. parseObject(parsedData.bufferViews, "bufferViews", gltfRuntime);
  2971. }
  2972. if (parsedData.accessors) {
  2973. parseObject(parsedData.accessors, "accessors", gltfRuntime);
  2974. }
  2975. if (parsedData.meshes) {
  2976. parseObject(parsedData.meshes, "meshes", gltfRuntime);
  2977. }
  2978. if (parsedData.lights) {
  2979. parseObject(parsedData.lights, "lights", gltfRuntime);
  2980. }
  2981. if (parsedData.cameras) {
  2982. parseObject(parsedData.cameras, "cameras", gltfRuntime);
  2983. }
  2984. if (parsedData.nodes) {
  2985. parseObject(parsedData.nodes, "nodes", gltfRuntime);
  2986. }
  2987. if (parsedData.images) {
  2988. parseObject(parsedData.images, "images", gltfRuntime);
  2989. }
  2990. if (parsedData.textures) {
  2991. parseObject(parsedData.textures, "textures", gltfRuntime);
  2992. }
  2993. if (parsedData.shaders) {
  2994. parseShaders(parsedData.shaders, gltfRuntime);
  2995. }
  2996. if (parsedData.programs) {
  2997. parseObject(parsedData.programs, "programs", gltfRuntime);
  2998. }
  2999. if (parsedData.samplers) {
  3000. parseObject(parsedData.samplers, "samplers", gltfRuntime);
  3001. }
  3002. if (parsedData.techniques) {
  3003. parseObject(parsedData.techniques, "techniques", gltfRuntime);
  3004. }
  3005. if (parsedData.materials) {
  3006. parseObject(parsedData.materials, "materials", gltfRuntime);
  3007. }
  3008. if (parsedData.animations) {
  3009. parseObject(parsedData.animations, "animations", gltfRuntime);
  3010. }
  3011. if (parsedData.skins) {
  3012. parseObject(parsedData.skins, "skins", gltfRuntime);
  3013. }
  3014. if (parsedData.scenes) {
  3015. gltfRuntime.scenes = parsedData.scenes;
  3016. }
  3017. if (parsedData.scene && parsedData.scenes) {
  3018. gltfRuntime.currentScene = parsedData.scenes[parsedData.scene];
  3019. }
  3020. return gltfRuntime;
  3021. };
  3022. GLTFLoaderBase.LoadBufferAsync = function (gltfRuntime, id, onSuccess, onError, onProgress) {
  3023. var buffer = gltfRuntime.buffers[id];
  3024. if (core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.IsBase64(buffer.uri)) {
  3025. setTimeout(function () { return onSuccess(new Uint8Array(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.DecodeBase64(buffer.uri))); });
  3026. }
  3027. else {
  3028. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.LoadFile(gltfRuntime.rootUrl + buffer.uri, function (data) { return onSuccess(new Uint8Array(data)); }, onProgress, undefined, true, function (request) {
  3029. if (request) {
  3030. onError(request.status + " " + request.statusText);
  3031. }
  3032. });
  3033. }
  3034. };
  3035. GLTFLoaderBase.LoadTextureBufferAsync = function (gltfRuntime, id, onSuccess, onError) {
  3036. var texture = gltfRuntime.textures[id];
  3037. if (!texture || !texture.source) {
  3038. onError("");
  3039. return;
  3040. }
  3041. if (texture.babylonTexture) {
  3042. onSuccess(null);
  3043. return;
  3044. }
  3045. var source = gltfRuntime.images[texture.source];
  3046. if (core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.IsBase64(source.uri)) {
  3047. setTimeout(function () { return onSuccess(new Uint8Array(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.DecodeBase64(source.uri))); });
  3048. }
  3049. else {
  3050. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.LoadFile(gltfRuntime.rootUrl + source.uri, function (data) { return onSuccess(new Uint8Array(data)); }, undefined, undefined, true, function (request) {
  3051. if (request) {
  3052. onError(request.status + " " + request.statusText);
  3053. }
  3054. });
  3055. }
  3056. };
  3057. GLTFLoaderBase.CreateTextureAsync = function (gltfRuntime, id, buffer, onSuccess, onError) {
  3058. var texture = gltfRuntime.textures[id];
  3059. if (texture.babylonTexture) {
  3060. onSuccess(texture.babylonTexture);
  3061. return;
  3062. }
  3063. var sampler = gltfRuntime.samplers[texture.sampler];
  3064. var createMipMaps = sampler.minFilter === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.NEAREST_MIPMAP_NEAREST ||
  3065. sampler.minFilter === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.NEAREST_MIPMAP_LINEAR ||
  3066. sampler.minFilter === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.LINEAR_MIPMAP_NEAREST ||
  3067. sampler.minFilter === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.LINEAR_MIPMAP_LINEAR;
  3068. var samplingMode = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.BILINEAR_SAMPLINGMODE;
  3069. var blob = buffer == null ? new Blob() : new Blob([buffer]);
  3070. var blobURL = URL.createObjectURL(blob);
  3071. var revokeBlobURL = function () { return URL.revokeObjectURL(blobURL); };
  3072. var newTexture = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture(blobURL, gltfRuntime.scene, !createMipMaps, true, samplingMode, revokeBlobURL, revokeBlobURL);
  3073. if (sampler.wrapS !== undefined) {
  3074. newTexture.wrapU = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetWrapMode(sampler.wrapS);
  3075. }
  3076. if (sampler.wrapT !== undefined) {
  3077. newTexture.wrapV = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetWrapMode(sampler.wrapT);
  3078. }
  3079. newTexture.name = id;
  3080. texture.babylonTexture = newTexture;
  3081. onSuccess(newTexture);
  3082. };
  3083. GLTFLoaderBase.LoadShaderStringAsync = function (gltfRuntime, id, onSuccess, onError) {
  3084. var shader = gltfRuntime.shaders[id];
  3085. if (core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.IsBase64(shader.uri)) {
  3086. var shaderString = atob(shader.uri.split(",")[1]);
  3087. if (onSuccess) {
  3088. onSuccess(shaderString);
  3089. }
  3090. }
  3091. else {
  3092. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.LoadFile(gltfRuntime.rootUrl + shader.uri, onSuccess, undefined, undefined, false, function (request) {
  3093. if (request && onError) {
  3094. onError(request.status + " " + request.statusText);
  3095. }
  3096. });
  3097. }
  3098. };
  3099. GLTFLoaderBase.LoadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) {
  3100. var material = gltfRuntime.materials[id];
  3101. if (!material.technique) {
  3102. if (onError) {
  3103. onError("No technique found.");
  3104. }
  3105. return;
  3106. }
  3107. var technique = gltfRuntime.techniques[material.technique];
  3108. if (!technique) {
  3109. gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer;
  3110. var defaultMaterial = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.StandardMaterial(id, gltfRuntime.scene);
  3111. defaultMaterial._parentContainer = gltfRuntime.assetContainer;
  3112. gltfRuntime.scene._blockEntityCollection = false;
  3113. defaultMaterial.diffuseColor = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3(0.5, 0.5, 0.5);
  3114. defaultMaterial.sideOrientation = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Material.CounterClockWiseSideOrientation;
  3115. onSuccess(defaultMaterial);
  3116. return;
  3117. }
  3118. var program = gltfRuntime.programs[technique.program];
  3119. var states = technique.states;
  3120. var vertexShader = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore[program.vertexShader + "VertexShader"];
  3121. var pixelShader = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore[program.fragmentShader + "PixelShader"];
  3122. var newVertexShader = "";
  3123. var newPixelShader = "";
  3124. var vertexTokenizer = new Tokenizer(vertexShader);
  3125. var pixelTokenizer = new Tokenizer(pixelShader);
  3126. var unTreatedUniforms = {};
  3127. var uniforms = [];
  3128. var attributes = [];
  3129. var samplers = [];
  3130. // Fill uniform, sampler2D and attributes
  3131. for (var unif in technique.uniforms) {
  3132. var uniform = technique.uniforms[unif];
  3133. var uniformParameter = technique.parameters[uniform];
  3134. unTreatedUniforms[unif] = uniformParameter;
  3135. if (uniformParameter.semantic && !uniformParameter.node && !uniformParameter.source) {
  3136. var transformIndex = glTFTransforms.indexOf(uniformParameter.semantic);
  3137. if (transformIndex !== -1) {
  3138. uniforms.push(babylonTransforms[transformIndex]);
  3139. delete unTreatedUniforms[unif];
  3140. }
  3141. else {
  3142. uniforms.push(unif);
  3143. }
  3144. }
  3145. else if (uniformParameter.type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.SAMPLER_2D) {
  3146. samplers.push(unif);
  3147. }
  3148. else {
  3149. uniforms.push(unif);
  3150. }
  3151. }
  3152. for (var attr in technique.attributes) {
  3153. var attribute = technique.attributes[attr];
  3154. var attributeParameter = technique.parameters[attribute];
  3155. if (attributeParameter.semantic) {
  3156. var name_1 = getAttribute(attributeParameter);
  3157. if (name_1) {
  3158. attributes.push(name_1);
  3159. }
  3160. }
  3161. }
  3162. // Configure vertex shader
  3163. while (!vertexTokenizer.isEnd() && vertexTokenizer.getNextToken()) {
  3164. var tokenType = vertexTokenizer.currentToken;
  3165. if (tokenType !== ETokenType.IDENTIFIER) {
  3166. newVertexShader += vertexTokenizer.currentString;
  3167. continue;
  3168. }
  3169. var foundAttribute = false;
  3170. for (var attr in technique.attributes) {
  3171. var attribute = technique.attributes[attr];
  3172. var attributeParameter = technique.parameters[attribute];
  3173. if (vertexTokenizer.currentIdentifier === attr && attributeParameter.semantic) {
  3174. newVertexShader += getAttribute(attributeParameter);
  3175. foundAttribute = true;
  3176. break;
  3177. }
  3178. }
  3179. if (foundAttribute) {
  3180. continue;
  3181. }
  3182. newVertexShader += parseShaderUniforms(vertexTokenizer, technique, unTreatedUniforms);
  3183. }
  3184. // Configure pixel shader
  3185. while (!pixelTokenizer.isEnd() && pixelTokenizer.getNextToken()) {
  3186. var tokenType = pixelTokenizer.currentToken;
  3187. if (tokenType !== ETokenType.IDENTIFIER) {
  3188. newPixelShader += pixelTokenizer.currentString;
  3189. continue;
  3190. }
  3191. newPixelShader += parseShaderUniforms(pixelTokenizer, technique, unTreatedUniforms);
  3192. }
  3193. // Create shader material
  3194. var shaderPath = {
  3195. vertex: program.vertexShader + id,
  3196. fragment: program.fragmentShader + id,
  3197. };
  3198. var options = {
  3199. attributes: attributes,
  3200. uniforms: uniforms,
  3201. samplers: samplers,
  3202. needAlphaBlending: states && states.enable && states.enable.indexOf(3042) !== -1,
  3203. };
  3204. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore[program.vertexShader + id + "VertexShader"] = newVertexShader;
  3205. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore[program.fragmentShader + id + "PixelShader"] = newPixelShader;
  3206. var shaderMaterial = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.ShaderMaterial(id, gltfRuntime.scene, shaderPath, options);
  3207. shaderMaterial.onError = onShaderCompileError(program, shaderMaterial, onError);
  3208. shaderMaterial.onCompiled = onShaderCompileSuccess(gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms, onSuccess);
  3209. shaderMaterial.sideOrientation = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Material.CounterClockWiseSideOrientation;
  3210. if (states && states.functions) {
  3211. var functions = states.functions;
  3212. if (functions.cullFace && functions.cullFace[0] !== _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ECullingType.BACK) {
  3213. shaderMaterial.backFaceCulling = false;
  3214. }
  3215. var blendFunc = functions.blendFuncSeparate;
  3216. if (blendFunc) {
  3217. if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.SRC_ALPHA &&
  3218. blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE_MINUS_SRC_ALPHA &&
  3219. blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE &&
  3220. blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE) {
  3221. shaderMaterial.alphaMode = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_COMBINE;
  3222. }
  3223. else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE &&
  3224. blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE &&
  3225. blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ZERO &&
  3226. blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE) {
  3227. shaderMaterial.alphaMode = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_ONEONE;
  3228. }
  3229. else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.SRC_ALPHA &&
  3230. blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE &&
  3231. blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ZERO &&
  3232. blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE) {
  3233. shaderMaterial.alphaMode = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_ADD;
  3234. }
  3235. else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ZERO &&
  3236. blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE_MINUS_SRC_COLOR &&
  3237. blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE &&
  3238. blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE) {
  3239. shaderMaterial.alphaMode = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_SUBTRACT;
  3240. }
  3241. else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.DST_COLOR &&
  3242. blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ZERO &&
  3243. blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE &&
  3244. blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE) {
  3245. shaderMaterial.alphaMode = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_MULTIPLY;
  3246. }
  3247. else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.SRC_ALPHA &&
  3248. blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE_MINUS_SRC_COLOR &&
  3249. blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE &&
  3250. blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE) {
  3251. shaderMaterial.alphaMode = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_MAXIMIZED;
  3252. }
  3253. }
  3254. }
  3255. };
  3256. return GLTFLoaderBase;
  3257. }());
  3258. /**
  3259. * glTF V1 Loader
  3260. * @hidden
  3261. */
  3262. var GLTFLoader = /** @class */ (function () {
  3263. function GLTFLoader() {
  3264. }
  3265. GLTFLoader.RegisterExtension = function (extension) {
  3266. if (GLTFLoader.Extensions[extension.name]) {
  3267. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error('Tool with the same name "' + extension.name + '" already exists');
  3268. return;
  3269. }
  3270. GLTFLoader.Extensions[extension.name] = extension;
  3271. };
  3272. GLTFLoader.prototype.dispose = function () {
  3273. // do nothing
  3274. };
  3275. GLTFLoader.prototype._importMeshAsync = function (meshesNames, scene, data, rootUrl, assetContainer, onSuccess, onProgress, onError) {
  3276. var _this = this;
  3277. scene.useRightHandedSystem = true;
  3278. GLTFLoaderExtension.LoadRuntimeAsync(scene, data, rootUrl, function (gltfRuntime) {
  3279. gltfRuntime.assetContainer = assetContainer;
  3280. gltfRuntime.importOnlyMeshes = true;
  3281. if (meshesNames === "") {
  3282. gltfRuntime.importMeshesNames = [];
  3283. }
  3284. else if (typeof meshesNames === "string") {
  3285. gltfRuntime.importMeshesNames = [meshesNames];
  3286. }
  3287. else if (meshesNames && !(meshesNames instanceof Array)) {
  3288. gltfRuntime.importMeshesNames = [meshesNames];
  3289. }
  3290. else {
  3291. gltfRuntime.importMeshesNames = [];
  3292. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn("Argument meshesNames must be of type string or string[]");
  3293. }
  3294. // Create nodes
  3295. _this._createNodes(gltfRuntime);
  3296. var meshes = new Array();
  3297. var skeletons = new Array();
  3298. // Fill arrays of meshes and skeletons
  3299. for (var nde in gltfRuntime.nodes) {
  3300. var node = gltfRuntime.nodes[nde];
  3301. if (node.babylonNode instanceof core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.AbstractMesh) {
  3302. meshes.push(node.babylonNode);
  3303. }
  3304. }
  3305. for (var skl in gltfRuntime.skins) {
  3306. var skin = gltfRuntime.skins[skl];
  3307. if (skin.babylonSkeleton instanceof core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Skeleton) {
  3308. skeletons.push(skin.babylonSkeleton);
  3309. }
  3310. }
  3311. // Load buffers, shaders, materials, etc.
  3312. _this._loadBuffersAsync(gltfRuntime, function () {
  3313. _this._loadShadersAsync(gltfRuntime, function () {
  3314. importMaterials(gltfRuntime);
  3315. postLoad(gltfRuntime);
  3316. if (!_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__.GLTFFileLoader.IncrementalLoading && onSuccess) {
  3317. onSuccess(meshes, skeletons);
  3318. }
  3319. });
  3320. }, onProgress);
  3321. if (_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__.GLTFFileLoader.IncrementalLoading && onSuccess) {
  3322. onSuccess(meshes, skeletons);
  3323. }
  3324. }, onError);
  3325. return true;
  3326. };
  3327. /**
  3328. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  3329. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  3330. * @param scene the scene the meshes should be added to
  3331. * @param assetContainer defines the asset container to use (can be null)
  3332. * @param data gltf data containing information of the meshes in a loaded file
  3333. * @param rootUrl root url to load from
  3334. * @param onProgress event that fires when loading progress has occured
  3335. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  3336. */
  3337. GLTFLoader.prototype.importMeshAsync = function (meshesNames, scene, assetContainer, data, rootUrl, onProgress) {
  3338. var _this = this;
  3339. return new Promise(function (resolve, reject) {
  3340. _this._importMeshAsync(meshesNames, scene, data, rootUrl, assetContainer, function (meshes, skeletons) {
  3341. resolve({
  3342. meshes: meshes,
  3343. particleSystems: [],
  3344. skeletons: skeletons,
  3345. animationGroups: [],
  3346. lights: [],
  3347. transformNodes: [],
  3348. geometries: [],
  3349. });
  3350. }, onProgress, function (message) {
  3351. reject(new Error(message));
  3352. });
  3353. });
  3354. };
  3355. GLTFLoader.prototype._loadAsync = function (scene, data, rootUrl, onSuccess, onProgress, onError) {
  3356. var _this = this;
  3357. scene.useRightHandedSystem = true;
  3358. GLTFLoaderExtension.LoadRuntimeAsync(scene, data, rootUrl, function (gltfRuntime) {
  3359. // Load runtime extensios
  3360. GLTFLoaderExtension.LoadRuntimeExtensionsAsync(gltfRuntime, function () {
  3361. // Create nodes
  3362. _this._createNodes(gltfRuntime);
  3363. // Load buffers, shaders, materials, etc.
  3364. _this._loadBuffersAsync(gltfRuntime, function () {
  3365. _this._loadShadersAsync(gltfRuntime, function () {
  3366. importMaterials(gltfRuntime);
  3367. postLoad(gltfRuntime);
  3368. if (!_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__.GLTFFileLoader.IncrementalLoading) {
  3369. onSuccess();
  3370. }
  3371. });
  3372. });
  3373. if (_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__.GLTFFileLoader.IncrementalLoading) {
  3374. onSuccess();
  3375. }
  3376. }, onError);
  3377. }, onError);
  3378. };
  3379. /**
  3380. * Imports all objects from a loaded gltf file and adds them to the scene
  3381. * @param scene the scene the objects should be added to
  3382. * @param data gltf data containing information of the meshes in a loaded file
  3383. * @param rootUrl root url to load from
  3384. * @param onProgress event that fires when loading progress has occured
  3385. * @returns a promise which completes when objects have been loaded to the scene
  3386. */
  3387. GLTFLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress) {
  3388. var _this = this;
  3389. return new Promise(function (resolve, reject) {
  3390. _this._loadAsync(scene, data, rootUrl, function () {
  3391. resolve();
  3392. }, onProgress, function (message) {
  3393. reject(new Error(message));
  3394. });
  3395. });
  3396. };
  3397. GLTFLoader.prototype._loadShadersAsync = function (gltfRuntime, onload) {
  3398. var hasShaders = false;
  3399. var processShader = function (sha, shader) {
  3400. GLTFLoaderExtension.LoadShaderStringAsync(gltfRuntime, sha, function (shaderString) {
  3401. if (shaderString instanceof ArrayBuffer) {
  3402. return;
  3403. }
  3404. gltfRuntime.loadedShaderCount++;
  3405. if (shaderString) {
  3406. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore[sha + (shader.type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EShaderType.VERTEX ? "VertexShader" : "PixelShader")] = shaderString;
  3407. }
  3408. if (gltfRuntime.loadedShaderCount === gltfRuntime.shaderscount) {
  3409. onload();
  3410. }
  3411. }, function () {
  3412. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error("Error when loading shader program named " + sha + " located at " + shader.uri);
  3413. });
  3414. };
  3415. for (var sha in gltfRuntime.shaders) {
  3416. hasShaders = true;
  3417. var shader = gltfRuntime.shaders[sha];
  3418. if (shader) {
  3419. processShader.bind(this, sha, shader)();
  3420. }
  3421. else {
  3422. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error("No shader named: " + sha);
  3423. }
  3424. }
  3425. if (!hasShaders) {
  3426. onload();
  3427. }
  3428. };
  3429. GLTFLoader.prototype._loadBuffersAsync = function (gltfRuntime, onLoad, onProgress) {
  3430. var hasBuffers = false;
  3431. var processBuffer = function (buf, buffer) {
  3432. GLTFLoaderExtension.LoadBufferAsync(gltfRuntime, buf, function (bufferView) {
  3433. gltfRuntime.loadedBufferCount++;
  3434. if (bufferView) {
  3435. if (bufferView.byteLength != gltfRuntime.buffers[buf].byteLength) {
  3436. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error("Buffer named " + buf + " is length " + bufferView.byteLength + ". Expected: " + buffer.byteLength); // Improve error message
  3437. }
  3438. gltfRuntime.loadedBufferViews[buf] = bufferView;
  3439. }
  3440. if (gltfRuntime.loadedBufferCount === gltfRuntime.buffersCount) {
  3441. onLoad();
  3442. }
  3443. }, function () {
  3444. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error("Error when loading buffer named " + buf + " located at " + buffer.uri);
  3445. });
  3446. };
  3447. for (var buf in gltfRuntime.buffers) {
  3448. hasBuffers = true;
  3449. var buffer = gltfRuntime.buffers[buf];
  3450. if (buffer) {
  3451. processBuffer.bind(this, buf, buffer)();
  3452. }
  3453. else {
  3454. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error("No buffer named: " + buf);
  3455. }
  3456. }
  3457. if (!hasBuffers) {
  3458. onLoad();
  3459. }
  3460. };
  3461. GLTFLoader.prototype._createNodes = function (gltfRuntime) {
  3462. var currentScene = gltfRuntime.currentScene;
  3463. if (currentScene) {
  3464. // Only one scene even if multiple scenes are defined
  3465. for (var i = 0; i < currentScene.nodes.length; i++) {
  3466. traverseNodes(gltfRuntime, currentScene.nodes[i], null);
  3467. }
  3468. }
  3469. else {
  3470. // Load all scenes
  3471. for (var thing in gltfRuntime.scenes) {
  3472. currentScene = gltfRuntime.scenes[thing];
  3473. for (var i = 0; i < currentScene.nodes.length; i++) {
  3474. traverseNodes(gltfRuntime, currentScene.nodes[i], null);
  3475. }
  3476. }
  3477. }
  3478. };
  3479. GLTFLoader.Extensions = {};
  3480. return GLTFLoader;
  3481. }());
  3482. /** @hidden */
  3483. var GLTFLoaderExtension = /** @class */ (function () {
  3484. function GLTFLoaderExtension(name) {
  3485. this._name = name;
  3486. }
  3487. Object.defineProperty(GLTFLoaderExtension.prototype, "name", {
  3488. get: function () {
  3489. return this._name;
  3490. },
  3491. enumerable: false,
  3492. configurable: true
  3493. });
  3494. /**
  3495. * Defines an override for loading the runtime
  3496. * Return true to stop further extensions from loading the runtime
  3497. * @param scene
  3498. * @param data
  3499. * @param rootUrl
  3500. * @param onSuccess
  3501. * @param onError
  3502. */
  3503. GLTFLoaderExtension.prototype.loadRuntimeAsync = function (scene, data, rootUrl, onSuccess, onError) {
  3504. return false;
  3505. };
  3506. /**
  3507. * Defines an onverride for creating gltf runtime
  3508. * Return true to stop further extensions from creating the runtime
  3509. * @param gltfRuntime
  3510. * @param onSuccess
  3511. * @param onError
  3512. */
  3513. GLTFLoaderExtension.prototype.loadRuntimeExtensionsAsync = function (gltfRuntime, onSuccess, onError) {
  3514. return false;
  3515. };
  3516. /**
  3517. * Defines an override for loading buffers
  3518. * Return true to stop further extensions from loading this buffer
  3519. * @param gltfRuntime
  3520. * @param id
  3521. * @param onSuccess
  3522. * @param onError
  3523. * @param onProgress
  3524. */
  3525. GLTFLoaderExtension.prototype.loadBufferAsync = function (gltfRuntime, id, onSuccess, onError, onProgress) {
  3526. return false;
  3527. };
  3528. /**
  3529. * Defines an override for loading texture buffers
  3530. * Return true to stop further extensions from loading this texture data
  3531. * @param gltfRuntime
  3532. * @param id
  3533. * @param onSuccess
  3534. * @param onError
  3535. */
  3536. GLTFLoaderExtension.prototype.loadTextureBufferAsync = function (gltfRuntime, id, onSuccess, onError) {
  3537. return false;
  3538. };
  3539. /**
  3540. * Defines an override for creating textures
  3541. * Return true to stop further extensions from loading this texture
  3542. * @param gltfRuntime
  3543. * @param id
  3544. * @param buffer
  3545. * @param onSuccess
  3546. * @param onError
  3547. */
  3548. GLTFLoaderExtension.prototype.createTextureAsync = function (gltfRuntime, id, buffer, onSuccess, onError) {
  3549. return false;
  3550. };
  3551. /**
  3552. * Defines an override for loading shader strings
  3553. * Return true to stop further extensions from loading this shader data
  3554. * @param gltfRuntime
  3555. * @param id
  3556. * @param onSuccess
  3557. * @param onError
  3558. */
  3559. GLTFLoaderExtension.prototype.loadShaderStringAsync = function (gltfRuntime, id, onSuccess, onError) {
  3560. return false;
  3561. };
  3562. /**
  3563. * Defines an override for loading materials
  3564. * Return true to stop further extensions from loading this material
  3565. * @param gltfRuntime
  3566. * @param id
  3567. * @param onSuccess
  3568. * @param onError
  3569. */
  3570. GLTFLoaderExtension.prototype.loadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) {
  3571. return false;
  3572. };
  3573. // ---------
  3574. // Utilities
  3575. // ---------
  3576. GLTFLoaderExtension.LoadRuntimeAsync = function (scene, data, rootUrl, onSuccess, onError) {
  3577. GLTFLoaderExtension.ApplyExtensions(function (loaderExtension) {
  3578. return loaderExtension.loadRuntimeAsync(scene, data, rootUrl, onSuccess, onError);
  3579. }, function () {
  3580. setTimeout(function () {
  3581. if (!onSuccess) {
  3582. return;
  3583. }
  3584. onSuccess(GLTFLoaderBase.CreateRuntime(data.json, scene, rootUrl));
  3585. });
  3586. });
  3587. };
  3588. GLTFLoaderExtension.LoadRuntimeExtensionsAsync = function (gltfRuntime, onSuccess, onError) {
  3589. GLTFLoaderExtension.ApplyExtensions(function (loaderExtension) {
  3590. return loaderExtension.loadRuntimeExtensionsAsync(gltfRuntime, onSuccess, onError);
  3591. }, function () {
  3592. setTimeout(function () {
  3593. onSuccess();
  3594. });
  3595. });
  3596. };
  3597. GLTFLoaderExtension.LoadBufferAsync = function (gltfRuntime, id, onSuccess, onError, onProgress) {
  3598. GLTFLoaderExtension.ApplyExtensions(function (loaderExtension) {
  3599. return loaderExtension.loadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress);
  3600. }, function () {
  3601. GLTFLoaderBase.LoadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress);
  3602. });
  3603. };
  3604. GLTFLoaderExtension.LoadTextureAsync = function (gltfRuntime, id, onSuccess, onError) {
  3605. GLTFLoaderExtension.LoadTextureBufferAsync(gltfRuntime, id, function (buffer) {
  3606. if (buffer) {
  3607. GLTFLoaderExtension.CreateTextureAsync(gltfRuntime, id, buffer, onSuccess, onError);
  3608. }
  3609. }, onError);
  3610. };
  3611. GLTFLoaderExtension.LoadShaderStringAsync = function (gltfRuntime, id, onSuccess, onError) {
  3612. GLTFLoaderExtension.ApplyExtensions(function (loaderExtension) {
  3613. return loaderExtension.loadShaderStringAsync(gltfRuntime, id, onSuccess, onError);
  3614. }, function () {
  3615. GLTFLoaderBase.LoadShaderStringAsync(gltfRuntime, id, onSuccess, onError);
  3616. });
  3617. };
  3618. GLTFLoaderExtension.LoadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) {
  3619. GLTFLoaderExtension.ApplyExtensions(function (loaderExtension) {
  3620. return loaderExtension.loadMaterialAsync(gltfRuntime, id, onSuccess, onError);
  3621. }, function () {
  3622. GLTFLoaderBase.LoadMaterialAsync(gltfRuntime, id, onSuccess, onError);
  3623. });
  3624. };
  3625. GLTFLoaderExtension.LoadTextureBufferAsync = function (gltfRuntime, id, onSuccess, onError) {
  3626. GLTFLoaderExtension.ApplyExtensions(function (loaderExtension) {
  3627. return loaderExtension.loadTextureBufferAsync(gltfRuntime, id, onSuccess, onError);
  3628. }, function () {
  3629. GLTFLoaderBase.LoadTextureBufferAsync(gltfRuntime, id, onSuccess, onError);
  3630. });
  3631. };
  3632. GLTFLoaderExtension.CreateTextureAsync = function (gltfRuntime, id, buffer, onSuccess, onError) {
  3633. GLTFLoaderExtension.ApplyExtensions(function (loaderExtension) {
  3634. return loaderExtension.createTextureAsync(gltfRuntime, id, buffer, onSuccess, onError);
  3635. }, function () {
  3636. GLTFLoaderBase.CreateTextureAsync(gltfRuntime, id, buffer, onSuccess, onError);
  3637. });
  3638. };
  3639. GLTFLoaderExtension.ApplyExtensions = function (func, defaultFunc) {
  3640. for (var extensionName in GLTFLoader.Extensions) {
  3641. var loaderExtension = GLTFLoader.Extensions[extensionName];
  3642. if (func(loaderExtension)) {
  3643. return;
  3644. }
  3645. }
  3646. defaultFunc();
  3647. };
  3648. return GLTFLoaderExtension;
  3649. }());
  3650. _glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__.GLTFFileLoader._CreateGLTF1Loader = function () { return new GLTFLoader(); };
  3651. /***/ }),
  3652. /***/ "../../../lts/loaders/dist/glTF/1.0/glTFLoaderInterfaces.js":
  3653. /*!******************************************************************!*\
  3654. !*** ../../../lts/loaders/dist/glTF/1.0/glTFLoaderInterfaces.js ***!
  3655. \******************************************************************/
  3656. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3657. __webpack_require__.r(__webpack_exports__);
  3658. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3659. /* harmony export */ "EBlendingFunction": () => (/* binding */ EBlendingFunction),
  3660. /* harmony export */ "EComponentType": () => (/* binding */ EComponentType),
  3661. /* harmony export */ "ECullingType": () => (/* binding */ ECullingType),
  3662. /* harmony export */ "EParameterType": () => (/* binding */ EParameterType),
  3663. /* harmony export */ "EShaderType": () => (/* binding */ EShaderType),
  3664. /* harmony export */ "ETextureFilterType": () => (/* binding */ ETextureFilterType),
  3665. /* harmony export */ "ETextureFormat": () => (/* binding */ ETextureFormat),
  3666. /* harmony export */ "ETextureWrapMode": () => (/* binding */ ETextureWrapMode)
  3667. /* harmony export */ });
  3668. /**
  3669. * Enums
  3670. * @hidden
  3671. */
  3672. var EComponentType;
  3673. (function (EComponentType) {
  3674. EComponentType[EComponentType["BYTE"] = 5120] = "BYTE";
  3675. EComponentType[EComponentType["UNSIGNED_BYTE"] = 5121] = "UNSIGNED_BYTE";
  3676. EComponentType[EComponentType["SHORT"] = 5122] = "SHORT";
  3677. EComponentType[EComponentType["UNSIGNED_SHORT"] = 5123] = "UNSIGNED_SHORT";
  3678. EComponentType[EComponentType["FLOAT"] = 5126] = "FLOAT";
  3679. })(EComponentType || (EComponentType = {}));
  3680. /** @hidden */
  3681. var EShaderType;
  3682. (function (EShaderType) {
  3683. EShaderType[EShaderType["FRAGMENT"] = 35632] = "FRAGMENT";
  3684. EShaderType[EShaderType["VERTEX"] = 35633] = "VERTEX";
  3685. })(EShaderType || (EShaderType = {}));
  3686. /** @hidden */
  3687. var EParameterType;
  3688. (function (EParameterType) {
  3689. EParameterType[EParameterType["BYTE"] = 5120] = "BYTE";
  3690. EParameterType[EParameterType["UNSIGNED_BYTE"] = 5121] = "UNSIGNED_BYTE";
  3691. EParameterType[EParameterType["SHORT"] = 5122] = "SHORT";
  3692. EParameterType[EParameterType["UNSIGNED_SHORT"] = 5123] = "UNSIGNED_SHORT";
  3693. EParameterType[EParameterType["INT"] = 5124] = "INT";
  3694. EParameterType[EParameterType["UNSIGNED_INT"] = 5125] = "UNSIGNED_INT";
  3695. EParameterType[EParameterType["FLOAT"] = 5126] = "FLOAT";
  3696. EParameterType[EParameterType["FLOAT_VEC2"] = 35664] = "FLOAT_VEC2";
  3697. EParameterType[EParameterType["FLOAT_VEC3"] = 35665] = "FLOAT_VEC3";
  3698. EParameterType[EParameterType["FLOAT_VEC4"] = 35666] = "FLOAT_VEC4";
  3699. EParameterType[EParameterType["INT_VEC2"] = 35667] = "INT_VEC2";
  3700. EParameterType[EParameterType["INT_VEC3"] = 35668] = "INT_VEC3";
  3701. EParameterType[EParameterType["INT_VEC4"] = 35669] = "INT_VEC4";
  3702. EParameterType[EParameterType["BOOL"] = 35670] = "BOOL";
  3703. EParameterType[EParameterType["BOOL_VEC2"] = 35671] = "BOOL_VEC2";
  3704. EParameterType[EParameterType["BOOL_VEC3"] = 35672] = "BOOL_VEC3";
  3705. EParameterType[EParameterType["BOOL_VEC4"] = 35673] = "BOOL_VEC4";
  3706. EParameterType[EParameterType["FLOAT_MAT2"] = 35674] = "FLOAT_MAT2";
  3707. EParameterType[EParameterType["FLOAT_MAT3"] = 35675] = "FLOAT_MAT3";
  3708. EParameterType[EParameterType["FLOAT_MAT4"] = 35676] = "FLOAT_MAT4";
  3709. EParameterType[EParameterType["SAMPLER_2D"] = 35678] = "SAMPLER_2D";
  3710. })(EParameterType || (EParameterType = {}));
  3711. /** @hidden */
  3712. var ETextureWrapMode;
  3713. (function (ETextureWrapMode) {
  3714. ETextureWrapMode[ETextureWrapMode["CLAMP_TO_EDGE"] = 33071] = "CLAMP_TO_EDGE";
  3715. ETextureWrapMode[ETextureWrapMode["MIRRORED_REPEAT"] = 33648] = "MIRRORED_REPEAT";
  3716. ETextureWrapMode[ETextureWrapMode["REPEAT"] = 10497] = "REPEAT";
  3717. })(ETextureWrapMode || (ETextureWrapMode = {}));
  3718. /** @hidden */
  3719. var ETextureFilterType;
  3720. (function (ETextureFilterType) {
  3721. ETextureFilterType[ETextureFilterType["NEAREST"] = 9728] = "NEAREST";
  3722. ETextureFilterType[ETextureFilterType["LINEAR"] = 9728] = "LINEAR";
  3723. ETextureFilterType[ETextureFilterType["NEAREST_MIPMAP_NEAREST"] = 9984] = "NEAREST_MIPMAP_NEAREST";
  3724. ETextureFilterType[ETextureFilterType["LINEAR_MIPMAP_NEAREST"] = 9985] = "LINEAR_MIPMAP_NEAREST";
  3725. ETextureFilterType[ETextureFilterType["NEAREST_MIPMAP_LINEAR"] = 9986] = "NEAREST_MIPMAP_LINEAR";
  3726. ETextureFilterType[ETextureFilterType["LINEAR_MIPMAP_LINEAR"] = 9987] = "LINEAR_MIPMAP_LINEAR";
  3727. })(ETextureFilterType || (ETextureFilterType = {}));
  3728. /** @hidden */
  3729. var ETextureFormat;
  3730. (function (ETextureFormat) {
  3731. ETextureFormat[ETextureFormat["ALPHA"] = 6406] = "ALPHA";
  3732. ETextureFormat[ETextureFormat["RGB"] = 6407] = "RGB";
  3733. ETextureFormat[ETextureFormat["RGBA"] = 6408] = "RGBA";
  3734. ETextureFormat[ETextureFormat["LUMINANCE"] = 6409] = "LUMINANCE";
  3735. ETextureFormat[ETextureFormat["LUMINANCE_ALPHA"] = 6410] = "LUMINANCE_ALPHA";
  3736. })(ETextureFormat || (ETextureFormat = {}));
  3737. /** @hidden */
  3738. var ECullingType;
  3739. (function (ECullingType) {
  3740. ECullingType[ECullingType["FRONT"] = 1028] = "FRONT";
  3741. ECullingType[ECullingType["BACK"] = 1029] = "BACK";
  3742. ECullingType[ECullingType["FRONT_AND_BACK"] = 1032] = "FRONT_AND_BACK";
  3743. })(ECullingType || (ECullingType = {}));
  3744. /** @hidden */
  3745. var EBlendingFunction;
  3746. (function (EBlendingFunction) {
  3747. EBlendingFunction[EBlendingFunction["ZERO"] = 0] = "ZERO";
  3748. EBlendingFunction[EBlendingFunction["ONE"] = 1] = "ONE";
  3749. EBlendingFunction[EBlendingFunction["SRC_COLOR"] = 768] = "SRC_COLOR";
  3750. EBlendingFunction[EBlendingFunction["ONE_MINUS_SRC_COLOR"] = 769] = "ONE_MINUS_SRC_COLOR";
  3751. EBlendingFunction[EBlendingFunction["DST_COLOR"] = 774] = "DST_COLOR";
  3752. EBlendingFunction[EBlendingFunction["ONE_MINUS_DST_COLOR"] = 775] = "ONE_MINUS_DST_COLOR";
  3753. EBlendingFunction[EBlendingFunction["SRC_ALPHA"] = 770] = "SRC_ALPHA";
  3754. EBlendingFunction[EBlendingFunction["ONE_MINUS_SRC_ALPHA"] = 771] = "ONE_MINUS_SRC_ALPHA";
  3755. EBlendingFunction[EBlendingFunction["DST_ALPHA"] = 772] = "DST_ALPHA";
  3756. EBlendingFunction[EBlendingFunction["ONE_MINUS_DST_ALPHA"] = 773] = "ONE_MINUS_DST_ALPHA";
  3757. EBlendingFunction[EBlendingFunction["CONSTANT_COLOR"] = 32769] = "CONSTANT_COLOR";
  3758. EBlendingFunction[EBlendingFunction["ONE_MINUS_CONSTANT_COLOR"] = 32770] = "ONE_MINUS_CONSTANT_COLOR";
  3759. EBlendingFunction[EBlendingFunction["CONSTANT_ALPHA"] = 32771] = "CONSTANT_ALPHA";
  3760. EBlendingFunction[EBlendingFunction["ONE_MINUS_CONSTANT_ALPHA"] = 32772] = "ONE_MINUS_CONSTANT_ALPHA";
  3761. EBlendingFunction[EBlendingFunction["SRC_ALPHA_SATURATE"] = 776] = "SRC_ALPHA_SATURATE";
  3762. })(EBlendingFunction || (EBlendingFunction = {}));
  3763. /***/ }),
  3764. /***/ "../../../lts/loaders/dist/glTF/1.0/glTFLoaderUtils.js":
  3765. /*!*************************************************************!*\
  3766. !*** ../../../lts/loaders/dist/glTF/1.0/glTFLoaderUtils.js ***!
  3767. \*************************************************************/
  3768. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  3769. __webpack_require__.r(__webpack_exports__);
  3770. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  3771. /* harmony export */ "GLTFUtils": () => (/* binding */ GLTFUtils)
  3772. /* harmony export */ });
  3773. /* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "../../../lts/loaders/dist/glTF/1.0/glTFLoaderInterfaces.js");
  3774. /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core/Materials/Textures/texture */ "core/Misc/observable");
  3775. /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  3776. /**
  3777. * Utils functions for GLTF
  3778. * @hidden
  3779. */
  3780. var GLTFUtils = /** @class */ (function () {
  3781. function GLTFUtils() {
  3782. }
  3783. /**
  3784. * Sets the given "parameter" matrix
  3785. * @param scene: the Scene object
  3786. * @param source: the source node where to pick the matrix
  3787. * @param parameter: the GLTF technique parameter
  3788. * @param uniformName: the name of the shader's uniform
  3789. * @param shaderMaterial: the shader material
  3790. * @param scene
  3791. * @param source
  3792. * @param parameter
  3793. * @param uniformName
  3794. * @param shaderMaterial
  3795. */
  3796. GLTFUtils.SetMatrix = function (scene, source, parameter, uniformName, shaderMaterial) {
  3797. var mat = null;
  3798. if (parameter.semantic === "MODEL") {
  3799. mat = source.getWorldMatrix();
  3800. }
  3801. else if (parameter.semantic === "PROJECTION") {
  3802. mat = scene.getProjectionMatrix();
  3803. }
  3804. else if (parameter.semantic === "VIEW") {
  3805. mat = scene.getViewMatrix();
  3806. }
  3807. else if (parameter.semantic === "MODELVIEWINVERSETRANSPOSE") {
  3808. mat = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.Transpose(source.getWorldMatrix().multiply(scene.getViewMatrix()).invert());
  3809. }
  3810. else if (parameter.semantic === "MODELVIEW") {
  3811. mat = source.getWorldMatrix().multiply(scene.getViewMatrix());
  3812. }
  3813. else if (parameter.semantic === "MODELVIEWPROJECTION") {
  3814. mat = source.getWorldMatrix().multiply(scene.getTransformMatrix());
  3815. }
  3816. else if (parameter.semantic === "MODELINVERSE") {
  3817. mat = source.getWorldMatrix().invert();
  3818. }
  3819. else if (parameter.semantic === "VIEWINVERSE") {
  3820. mat = scene.getViewMatrix().invert();
  3821. }
  3822. else if (parameter.semantic === "PROJECTIONINVERSE") {
  3823. mat = scene.getProjectionMatrix().invert();
  3824. }
  3825. else if (parameter.semantic === "MODELVIEWINVERSE") {
  3826. mat = source.getWorldMatrix().multiply(scene.getViewMatrix()).invert();
  3827. }
  3828. else if (parameter.semantic === "MODELVIEWPROJECTIONINVERSE") {
  3829. mat = source.getWorldMatrix().multiply(scene.getTransformMatrix()).invert();
  3830. }
  3831. else if (parameter.semantic === "MODELINVERSETRANSPOSE") {
  3832. mat = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.Transpose(source.getWorldMatrix().invert());
  3833. }
  3834. else {
  3835. debugger;
  3836. }
  3837. if (mat) {
  3838. switch (parameter.type) {
  3839. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_MAT2:
  3840. shaderMaterial.setMatrix2x2(uniformName, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.GetAsMatrix2x2(mat));
  3841. break;
  3842. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_MAT3:
  3843. shaderMaterial.setMatrix3x3(uniformName, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.GetAsMatrix3x3(mat));
  3844. break;
  3845. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_MAT4:
  3846. shaderMaterial.setMatrix(uniformName, mat);
  3847. break;
  3848. default:
  3849. break;
  3850. }
  3851. }
  3852. };
  3853. /**
  3854. * Sets the given "parameter" matrix
  3855. * @param shaderMaterial: the shader material
  3856. * @param uniform: the name of the shader's uniform
  3857. * @param value: the value of the uniform
  3858. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  3859. * @param shaderMaterial
  3860. * @param uniform
  3861. * @param value
  3862. * @param type
  3863. */
  3864. GLTFUtils.SetUniform = function (shaderMaterial, uniform, value, type) {
  3865. switch (type) {
  3866. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT:
  3867. shaderMaterial.setFloat(uniform, value);
  3868. return true;
  3869. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_VEC2:
  3870. shaderMaterial.setVector2(uniform, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector2.FromArray(value));
  3871. return true;
  3872. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_VEC3:
  3873. shaderMaterial.setVector3(uniform, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(value));
  3874. return true;
  3875. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_VEC4:
  3876. shaderMaterial.setVector4(uniform, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector4.FromArray(value));
  3877. return true;
  3878. default:
  3879. return false;
  3880. }
  3881. };
  3882. /**
  3883. * Returns the wrap mode of the texture
  3884. * @param mode: the mode value
  3885. * @param mode
  3886. */
  3887. GLTFUtils.GetWrapMode = function (mode) {
  3888. switch (mode) {
  3889. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureWrapMode.CLAMP_TO_EDGE:
  3890. return core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.CLAMP_ADDRESSMODE;
  3891. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureWrapMode.MIRRORED_REPEAT:
  3892. return core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.MIRROR_ADDRESSMODE;
  3893. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureWrapMode.REPEAT:
  3894. return core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.WRAP_ADDRESSMODE;
  3895. default:
  3896. return core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.WRAP_ADDRESSMODE;
  3897. }
  3898. };
  3899. /**
  3900. * Returns the byte stride giving an accessor
  3901. * @param accessor: the GLTF accessor objet
  3902. * @param accessor
  3903. */
  3904. GLTFUtils.GetByteStrideFromType = function (accessor) {
  3905. // Needs this function since "byteStride" isn't requiered in glTF format
  3906. var type = accessor.type;
  3907. switch (type) {
  3908. case "VEC2":
  3909. return 2;
  3910. case "VEC3":
  3911. return 3;
  3912. case "VEC4":
  3913. return 4;
  3914. case "MAT2":
  3915. return 4;
  3916. case "MAT3":
  3917. return 9;
  3918. case "MAT4":
  3919. return 16;
  3920. default:
  3921. return 1;
  3922. }
  3923. };
  3924. /**
  3925. * Returns the texture filter mode giving a mode value
  3926. * @param mode: the filter mode value
  3927. * @param mode
  3928. */
  3929. GLTFUtils.GetTextureFilterMode = function (mode) {
  3930. switch (mode) {
  3931. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.LINEAR:
  3932. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.LINEAR_MIPMAP_NEAREST:
  3933. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.LINEAR_MIPMAP_LINEAR:
  3934. return core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.TRILINEAR_SAMPLINGMODE;
  3935. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.NEAREST:
  3936. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.NEAREST_MIPMAP_NEAREST:
  3937. return core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.NEAREST_SAMPLINGMODE;
  3938. default:
  3939. return core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.BILINEAR_SAMPLINGMODE;
  3940. }
  3941. };
  3942. GLTFUtils.GetBufferFromBufferView = function (gltfRuntime, bufferView, byteOffset, byteLength, componentType) {
  3943. var byteOffset = bufferView.byteOffset + byteOffset;
  3944. var loadedBufferView = gltfRuntime.loadedBufferViews[bufferView.buffer];
  3945. if (byteOffset + byteLength > loadedBufferView.byteLength) {
  3946. throw new Error("Buffer access is out of range");
  3947. }
  3948. var buffer = loadedBufferView.buffer;
  3949. byteOffset += loadedBufferView.byteOffset;
  3950. switch (componentType) {
  3951. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EComponentType.BYTE:
  3952. return new Int8Array(buffer, byteOffset, byteLength);
  3953. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EComponentType.UNSIGNED_BYTE:
  3954. return new Uint8Array(buffer, byteOffset, byteLength);
  3955. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EComponentType.SHORT:
  3956. return new Int16Array(buffer, byteOffset, byteLength);
  3957. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EComponentType.UNSIGNED_SHORT:
  3958. return new Uint16Array(buffer, byteOffset, byteLength);
  3959. default:
  3960. return new Float32Array(buffer, byteOffset, byteLength);
  3961. }
  3962. };
  3963. /**
  3964. * Returns a buffer from its accessor
  3965. * @param gltfRuntime: the GLTF runtime
  3966. * @param accessor: the GLTF accessor
  3967. * @param gltfRuntime
  3968. * @param accessor
  3969. */
  3970. GLTFUtils.GetBufferFromAccessor = function (gltfRuntime, accessor) {
  3971. var bufferView = gltfRuntime.bufferViews[accessor.bufferView];
  3972. var byteLength = accessor.count * GLTFUtils.GetByteStrideFromType(accessor);
  3973. return GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, accessor.byteOffset, byteLength, accessor.componentType);
  3974. };
  3975. /**
  3976. * Decodes a buffer view into a string
  3977. * @param view: the buffer view
  3978. * @param view
  3979. */
  3980. GLTFUtils.DecodeBufferToText = function (view) {
  3981. var result = "";
  3982. var length = view.byteLength;
  3983. for (var i = 0; i < length; ++i) {
  3984. result += String.fromCharCode(view[i]);
  3985. }
  3986. return result;
  3987. };
  3988. /**
  3989. * Returns the default material of gltf. Related to
  3990. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  3991. * @param scene: the Babylon.js scene
  3992. * @param scene
  3993. */
  3994. GLTFUtils.GetDefaultMaterial = function (scene) {
  3995. if (!GLTFUtils._DefaultMaterial) {
  3996. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore.GLTFDefaultMaterialVertexShader = [
  3997. "precision highp float;",
  3998. "",
  3999. "uniform mat4 worldView;",
  4000. "uniform mat4 projection;",
  4001. "",
  4002. "attribute vec3 position;",
  4003. "",
  4004. "void main(void)",
  4005. "{",
  4006. " gl_Position = projection * worldView * vec4(position, 1.0);",
  4007. "}",
  4008. ].join("\n");
  4009. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore.GLTFDefaultMaterialPixelShader = [
  4010. "precision highp float;",
  4011. "",
  4012. "uniform vec4 u_emission;",
  4013. "",
  4014. "void main(void)",
  4015. "{",
  4016. " gl_FragColor = u_emission;",
  4017. "}",
  4018. ].join("\n");
  4019. var shaderPath = {
  4020. vertex: "GLTFDefaultMaterial",
  4021. fragment: "GLTFDefaultMaterial",
  4022. };
  4023. var options = {
  4024. attributes: ["position"],
  4025. uniforms: ["worldView", "projection", "u_emission"],
  4026. samplers: new Array(),
  4027. needAlphaBlending: false,
  4028. };
  4029. GLTFUtils._DefaultMaterial = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.ShaderMaterial("GLTFDefaultMaterial", scene, shaderPath, options);
  4030. GLTFUtils._DefaultMaterial.setColor4("u_emission", new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color4(0.5, 0.5, 0.5, 1.0));
  4031. }
  4032. return GLTFUtils._DefaultMaterial;
  4033. };
  4034. // The GLTF default material
  4035. GLTFUtils._DefaultMaterial = null;
  4036. return GLTFUtils;
  4037. }());
  4038. /***/ }),
  4039. /***/ "../../../lts/loaders/dist/glTF/1.0/glTFMaterialsCommonExtension.js":
  4040. /*!**************************************************************************!*\
  4041. !*** ../../../lts/loaders/dist/glTF/1.0/glTFMaterialsCommonExtension.js ***!
  4042. \**************************************************************************/
  4043. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4044. __webpack_require__.r(__webpack_exports__);
  4045. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4046. /* harmony export */ "GLTFMaterialsCommonExtension": () => (/* binding */ GLTFMaterialsCommonExtension)
  4047. /* harmony export */ });
  4048. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.js");
  4049. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFLoader */ "../../../lts/loaders/dist/glTF/1.0/glTFLoader.js");
  4050. /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! core/Lights/spotLight */ "core/Misc/observable");
  4051. /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__);
  4052. /** @hidden */
  4053. var GLTFMaterialsCommonExtension = /** @class */ (function (_super) {
  4054. (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__extends)(GLTFMaterialsCommonExtension, _super);
  4055. function GLTFMaterialsCommonExtension() {
  4056. return _super.call(this, "KHR_materials_common") || this;
  4057. }
  4058. GLTFMaterialsCommonExtension.prototype.loadRuntimeExtensionsAsync = function (gltfRuntime, onSuccess, onError) {
  4059. if (!gltfRuntime.extensions) {
  4060. return false;
  4061. }
  4062. var extension = gltfRuntime.extensions[this.name];
  4063. if (!extension) {
  4064. return false;
  4065. }
  4066. // Create lights
  4067. var lights = extension.lights;
  4068. if (lights) {
  4069. for (var thing in lights) {
  4070. var light = lights[thing];
  4071. switch (light.type) {
  4072. case "ambient":
  4073. var ambientLight = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.HemisphericLight(light.name, new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Vector3(0, 1, 0), gltfRuntime.scene);
  4074. var ambient = light.ambient;
  4075. if (ambient) {
  4076. ambientLight.diffuse = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Color3.FromArray(ambient.color || [1, 1, 1]);
  4077. }
  4078. break;
  4079. case "point":
  4080. var pointLight = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.PointLight(light.name, new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Vector3(10, 10, 10), gltfRuntime.scene);
  4081. var point = light.point;
  4082. if (point) {
  4083. pointLight.diffuse = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Color3.FromArray(point.color || [1, 1, 1]);
  4084. }
  4085. break;
  4086. case "directional":
  4087. var dirLight = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.DirectionalLight(light.name, new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Vector3(0, -1, 0), gltfRuntime.scene);
  4088. var directional = light.directional;
  4089. if (directional) {
  4090. dirLight.diffuse = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Color3.FromArray(directional.color || [1, 1, 1]);
  4091. }
  4092. break;
  4093. case "spot":
  4094. var spot = light.spot;
  4095. if (spot) {
  4096. var spotLight = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.SpotLight(light.name, new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Vector3(0, 10, 0), new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Vector3(0, -1, 0), spot.fallOffAngle || Math.PI, spot.fallOffExponent || 0.0, gltfRuntime.scene);
  4097. spotLight.diffuse = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Color3.FromArray(spot.color || [1, 1, 1]);
  4098. }
  4099. break;
  4100. default:
  4101. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Tools.Warn('GLTF Material Common extension: light type "' + light.type + "” not supported");
  4102. break;
  4103. }
  4104. }
  4105. }
  4106. return false;
  4107. };
  4108. GLTFMaterialsCommonExtension.prototype.loadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) {
  4109. var material = gltfRuntime.materials[id];
  4110. if (!material || !material.extensions) {
  4111. return false;
  4112. }
  4113. var extension = material.extensions[this.name];
  4114. if (!extension) {
  4115. return false;
  4116. }
  4117. var standardMaterial = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.StandardMaterial(id, gltfRuntime.scene);
  4118. standardMaterial.sideOrientation = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Material.CounterClockWiseSideOrientation;
  4119. if (extension.technique === "CONSTANT") {
  4120. standardMaterial.disableLighting = true;
  4121. }
  4122. standardMaterial.backFaceCulling = extension.doubleSided === undefined ? false : !extension.doubleSided;
  4123. standardMaterial.alpha = extension.values.transparency === undefined ? 1.0 : extension.values.transparency;
  4124. standardMaterial.specularPower = extension.values.shininess === undefined ? 0.0 : extension.values.shininess;
  4125. // Ambient
  4126. if (typeof extension.values.ambient === "string") {
  4127. this._loadTexture(gltfRuntime, extension.values.ambient, standardMaterial, "ambientTexture", onError);
  4128. }
  4129. else {
  4130. standardMaterial.ambientColor = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Color3.FromArray(extension.values.ambient || [0, 0, 0]);
  4131. }
  4132. // Diffuse
  4133. if (typeof extension.values.diffuse === "string") {
  4134. this._loadTexture(gltfRuntime, extension.values.diffuse, standardMaterial, "diffuseTexture", onError);
  4135. }
  4136. else {
  4137. standardMaterial.diffuseColor = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Color3.FromArray(extension.values.diffuse || [0, 0, 0]);
  4138. }
  4139. // Emission
  4140. if (typeof extension.values.emission === "string") {
  4141. this._loadTexture(gltfRuntime, extension.values.emission, standardMaterial, "emissiveTexture", onError);
  4142. }
  4143. else {
  4144. standardMaterial.emissiveColor = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Color3.FromArray(extension.values.emission || [0, 0, 0]);
  4145. }
  4146. // Specular
  4147. if (typeof extension.values.specular === "string") {
  4148. this._loadTexture(gltfRuntime, extension.values.specular, standardMaterial, "specularTexture", onError);
  4149. }
  4150. else {
  4151. standardMaterial.specularColor = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__.Color3.FromArray(extension.values.specular || [0, 0, 0]);
  4152. }
  4153. return true;
  4154. };
  4155. GLTFMaterialsCommonExtension.prototype._loadTexture = function (gltfRuntime, id, material, propertyPath, onError) {
  4156. // Create buffer from texture url
  4157. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderBase.LoadTextureBufferAsync(gltfRuntime, id, function (buffer) {
  4158. // Create texture from buffer
  4159. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderBase.CreateTextureAsync(gltfRuntime, id, buffer, function (texture) { return (material[propertyPath] = texture); }, onError);
  4160. }, onError);
  4161. };
  4162. return GLTFMaterialsCommonExtension;
  4163. }(_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderExtension));
  4164. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(new GLTFMaterialsCommonExtension());
  4165. /***/ }),
  4166. /***/ "../../../lts/loaders/dist/glTF/1.0/index.js":
  4167. /*!***************************************************!*\
  4168. !*** ../../../lts/loaders/dist/glTF/1.0/index.js ***!
  4169. \***************************************************/
  4170. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4171. __webpack_require__.r(__webpack_exports__);
  4172. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4173. /* harmony export */ "EBlendingFunction": () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.EBlendingFunction),
  4174. /* harmony export */ "EComponentType": () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.EComponentType),
  4175. /* harmony export */ "ECullingType": () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.ECullingType),
  4176. /* harmony export */ "EParameterType": () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.EParameterType),
  4177. /* harmony export */ "EShaderType": () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.EShaderType),
  4178. /* harmony export */ "ETextureFilterType": () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.ETextureFilterType),
  4179. /* harmony export */ "ETextureFormat": () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.ETextureFormat),
  4180. /* harmony export */ "ETextureWrapMode": () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.ETextureWrapMode),
  4181. /* harmony export */ "GLTFBinaryExtension": () => (/* reexport safe */ _glTFBinaryExtension__WEBPACK_IMPORTED_MODULE_0__.GLTFBinaryExtension),
  4182. /* harmony export */ "GLTFLoader": () => (/* reexport safe */ _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader),
  4183. /* harmony export */ "GLTFLoaderBase": () => (/* reexport safe */ _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderBase),
  4184. /* harmony export */ "GLTFLoaderExtension": () => (/* reexport safe */ _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderExtension),
  4185. /* harmony export */ "GLTFMaterialsCommonExtension": () => (/* reexport safe */ _glTFMaterialsCommonExtension__WEBPACK_IMPORTED_MODULE_4__.GLTFMaterialsCommonExtension),
  4186. /* harmony export */ "GLTFUtils": () => (/* reexport safe */ _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_3__.GLTFUtils)
  4187. /* harmony export */ });
  4188. /* harmony import */ var _glTFBinaryExtension__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFBinaryExtension */ "../../../lts/loaders/dist/glTF/1.0/glTFBinaryExtension.js");
  4189. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFLoader */ "../../../lts/loaders/dist/glTF/1.0/glTFLoader.js");
  4190. /* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "../../../lts/loaders/dist/glTF/1.0/glTFLoaderInterfaces.js");
  4191. /* harmony import */ var _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./glTFLoaderUtils */ "../../../lts/loaders/dist/glTF/1.0/glTFLoaderUtils.js");
  4192. /* harmony import */ var _glTFMaterialsCommonExtension__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./glTFMaterialsCommonExtension */ "../../../lts/loaders/dist/glTF/1.0/glTFMaterialsCommonExtension.js");
  4193. /***/ }),
  4194. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/EXT_lights_image_based.js":
  4195. /*!*******************************************************************************!*\
  4196. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/EXT_lights_image_based.js ***!
  4197. \*******************************************************************************/
  4198. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4199. __webpack_require__.r(__webpack_exports__);
  4200. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4201. /* harmony export */ "EXT_lights_image_based": () => (/* binding */ EXT_lights_image_based)
  4202. /* harmony export */ });
  4203. /* harmony import */ var core_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Materials/Textures/rawCubeTexture */ "core/Misc/observable");
  4204. /* harmony import */ var core_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__);
  4205. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  4206. var NAME = "EXT_lights_image_based";
  4207. /**
  4208. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  4209. */
  4210. var EXT_lights_image_based = /** @class */ (function () {
  4211. /**
  4212. * @param loader
  4213. * @hidden
  4214. */
  4215. function EXT_lights_image_based(loader) {
  4216. /**
  4217. * The name of this extension.
  4218. */
  4219. this.name = NAME;
  4220. this._loader = loader;
  4221. this.enabled = this._loader.isExtensionUsed(NAME);
  4222. }
  4223. /** @hidden */
  4224. EXT_lights_image_based.prototype.dispose = function () {
  4225. this._loader = null;
  4226. delete this._lights;
  4227. };
  4228. /** @hidden */
  4229. EXT_lights_image_based.prototype.onLoading = function () {
  4230. var extensions = this._loader.gltf.extensions;
  4231. if (extensions && extensions[this.name]) {
  4232. var extension = extensions[this.name];
  4233. this._lights = extension.lights;
  4234. }
  4235. };
  4236. /**
  4237. * @param context
  4238. * @param scene
  4239. * @hidden
  4240. */
  4241. EXT_lights_image_based.prototype.loadSceneAsync = function (context, scene) {
  4242. var _this = this;
  4243. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, scene, this.name, function (extensionContext, extension) {
  4244. var promises = new Array();
  4245. promises.push(_this._loader.loadSceneAsync(context, scene));
  4246. _this._loader.logOpen("".concat(extensionContext));
  4247. var light = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(extensionContext, "/light"), _this._lights, extension.light);
  4248. promises.push(_this._loadLightAsync("/extensions/".concat(_this.name, "/lights/").concat(extension.light), light).then(function (texture) {
  4249. _this._loader.babylonScene.environmentTexture = texture;
  4250. }));
  4251. _this._loader.logClose();
  4252. return Promise.all(promises).then(function () { });
  4253. });
  4254. };
  4255. EXT_lights_image_based.prototype._loadLightAsync = function (context, light) {
  4256. var _this = this;
  4257. if (!light._loaded) {
  4258. var promises = new Array();
  4259. this._loader.logOpen("".concat(context));
  4260. var imageData_1 = new Array(light.specularImages.length);
  4261. var _loop_1 = function (mipmap) {
  4262. var faces = light.specularImages[mipmap];
  4263. imageData_1[mipmap] = new Array(faces.length);
  4264. var _loop_2 = function (face) {
  4265. var specularImageContext = "".concat(context, "/specularImages/").concat(mipmap, "/").concat(face);
  4266. this_1._loader.logOpen("".concat(specularImageContext));
  4267. var index = faces[face];
  4268. var image = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get(specularImageContext, this_1._loader.gltf.images, index);
  4269. promises.push(this_1._loader.loadImageAsync("/images/".concat(index), image).then(function (data) {
  4270. imageData_1[mipmap][face] = data;
  4271. }));
  4272. this_1._loader.logClose();
  4273. };
  4274. for (var face = 0; face < faces.length; face++) {
  4275. _loop_2(face);
  4276. }
  4277. };
  4278. var this_1 = this;
  4279. for (var mipmap = 0; mipmap < light.specularImages.length; mipmap++) {
  4280. _loop_1(mipmap);
  4281. }
  4282. this._loader.logClose();
  4283. light._loaded = Promise.all(promises).then(function () {
  4284. var babylonTexture = new core_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.RawCubeTexture(_this._loader.babylonScene, null, light.specularImageSize);
  4285. babylonTexture.name = light.name || "environment";
  4286. light._babylonTexture = babylonTexture;
  4287. if (light.intensity != undefined) {
  4288. babylonTexture.level = light.intensity;
  4289. }
  4290. if (light.rotation) {
  4291. var rotation = core_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray(light.rotation);
  4292. // Invert the rotation so that positive rotation is counter-clockwise.
  4293. if (!_this._loader.babylonScene.useRightHandedSystem) {
  4294. rotation = core_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.Quaternion.Inverse(rotation);
  4295. }
  4296. core_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.Matrix.FromQuaternionToRef(rotation, babylonTexture.getReflectionTextureMatrix());
  4297. }
  4298. if (!light.irradianceCoefficients) {
  4299. throw new Error("".concat(context, ": Irradiance coefficients are missing"));
  4300. }
  4301. var sphericalHarmonics = core_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.SphericalHarmonics.FromArray(light.irradianceCoefficients);
  4302. sphericalHarmonics.scaleInPlace(light.intensity);
  4303. sphericalHarmonics.convertIrradianceToLambertianRadiance();
  4304. var sphericalPolynomial = core_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.SphericalPolynomial.FromHarmonics(sphericalHarmonics);
  4305. // Compute the lod generation scale to fit exactly to the number of levels available.
  4306. var lodGenerationScale = (imageData_1.length - 1) / core_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.Scalar.Log2(light.specularImageSize);
  4307. return babylonTexture.updateRGBDAsync(imageData_1, sphericalPolynomial, lodGenerationScale);
  4308. });
  4309. }
  4310. return light._loaded.then(function () {
  4311. return light._babylonTexture;
  4312. });
  4313. };
  4314. return EXT_lights_image_based;
  4315. }());
  4316. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new EXT_lights_image_based(loader); });
  4317. /***/ }),
  4318. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js":
  4319. /*!********************************************************************************!*\
  4320. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js ***!
  4321. \********************************************************************************/
  4322. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4323. __webpack_require__.r(__webpack_exports__);
  4324. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4325. /* harmony export */ "EXT_mesh_gpu_instancing": () => (/* binding */ EXT_mesh_gpu_instancing)
  4326. /* harmony export */ });
  4327. /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Meshes/thinInstanceMesh */ "core/Misc/observable");
  4328. /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  4329. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  4330. var NAME = "EXT_mesh_gpu_instancing";
  4331. /**
  4332. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  4333. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  4334. * !!! Experimental Extension Subject to Changes !!!
  4335. */
  4336. var EXT_mesh_gpu_instancing = /** @class */ (function () {
  4337. /**
  4338. * @param loader
  4339. * @hidden
  4340. */
  4341. function EXT_mesh_gpu_instancing(loader) {
  4342. /**
  4343. * The name of this extension.
  4344. */
  4345. this.name = NAME;
  4346. this._loader = loader;
  4347. this.enabled = this._loader.isExtensionUsed(NAME);
  4348. }
  4349. /** @hidden */
  4350. EXT_mesh_gpu_instancing.prototype.dispose = function () {
  4351. this._loader = null;
  4352. };
  4353. /**
  4354. * @param context
  4355. * @param node
  4356. * @param assign
  4357. * @hidden
  4358. */
  4359. EXT_mesh_gpu_instancing.prototype.loadNodeAsync = function (context, node, assign) {
  4360. var _this = this;
  4361. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) {
  4362. _this._loader._disableInstancedMesh++;
  4363. var promise = _this._loader.loadNodeAsync("/nodes/".concat(node.index), node, assign);
  4364. _this._loader._disableInstancedMesh--;
  4365. if (!node._primitiveBabylonMeshes) {
  4366. return promise;
  4367. }
  4368. var promises = new Array();
  4369. var instanceCount = 0;
  4370. var loadAttribute = function (attribute) {
  4371. if (extension.attributes[attribute] == undefined) {
  4372. promises.push(Promise.resolve(null));
  4373. return;
  4374. }
  4375. var accessor = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(extensionContext, "/attributes/").concat(attribute), _this._loader.gltf.accessors, extension.attributes[attribute]);
  4376. promises.push(_this._loader._loadFloatAccessorAsync("/accessors/".concat(accessor.bufferView), accessor));
  4377. if (instanceCount === 0) {
  4378. instanceCount = accessor.count;
  4379. }
  4380. else if (instanceCount !== accessor.count) {
  4381. throw new Error("".concat(extensionContext, "/attributes: Instance buffer accessors do not have the same count."));
  4382. }
  4383. };
  4384. loadAttribute("TRANSLATION");
  4385. loadAttribute("ROTATION");
  4386. loadAttribute("SCALE");
  4387. return promise.then(function (babylonTransformNode) {
  4388. return Promise.all(promises).then(function (_a) {
  4389. var translationBuffer = _a[0], rotationBuffer = _a[1], scaleBuffer = _a[2];
  4390. var matrices = new Float32Array(instanceCount * 16);
  4391. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0].copyFromFloats(0, 0, 0); // translation
  4392. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Quaternion[0].copyFromFloats(0, 0, 0, 1); // rotation
  4393. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[1].copyFromFloats(1, 1, 1); // scale
  4394. for (var i = 0; i < instanceCount; ++i) {
  4395. translationBuffer && core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArrayToRef(translationBuffer, i * 3, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0]);
  4396. rotationBuffer && core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArrayToRef(rotationBuffer, i * 4, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Quaternion[0]);
  4397. scaleBuffer && core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArrayToRef(scaleBuffer, i * 3, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[1]);
  4398. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Matrix.ComposeToRef(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[1], core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Quaternion[0], core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0], core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Matrix[0]);
  4399. core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Matrix[0].copyToArray(matrices, i * 16);
  4400. }
  4401. for (var _i = 0, _b = node._primitiveBabylonMeshes; _i < _b.length; _i++) {
  4402. var babylonMesh = _b[_i];
  4403. babylonMesh.thinInstanceSetBuffer("matrix", matrices, 16, true);
  4404. }
  4405. return babylonTransformNode;
  4406. });
  4407. });
  4408. });
  4409. };
  4410. return EXT_mesh_gpu_instancing;
  4411. }());
  4412. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new EXT_mesh_gpu_instancing(loader); });
  4413. /***/ }),
  4414. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/EXT_meshopt_compression.js":
  4415. /*!********************************************************************************!*\
  4416. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/EXT_meshopt_compression.js ***!
  4417. \********************************************************************************/
  4418. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4419. __webpack_require__.r(__webpack_exports__);
  4420. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4421. /* harmony export */ "EXT_meshopt_compression": () => (/* binding */ EXT_meshopt_compression)
  4422. /* harmony export */ });
  4423. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  4424. /* harmony import */ var core_Meshes_Compression_meshoptCompression__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core/Meshes/Compression/meshoptCompression */ "core/Misc/observable");
  4425. /* harmony import */ var core_Meshes_Compression_meshoptCompression__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_Meshes_Compression_meshoptCompression__WEBPACK_IMPORTED_MODULE_1__);
  4426. var NAME = "EXT_meshopt_compression";
  4427. /**
  4428. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression)
  4429. *
  4430. * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js
  4431. * @since 5.0.0
  4432. */
  4433. var EXT_meshopt_compression = /** @class */ (function () {
  4434. /**
  4435. * @param loader
  4436. * @hidden
  4437. */
  4438. function EXT_meshopt_compression(loader) {
  4439. /**
  4440. * The name of this extension.
  4441. */
  4442. this.name = NAME;
  4443. this.enabled = loader.isExtensionUsed(NAME);
  4444. this._loader = loader;
  4445. }
  4446. /** @hidden */
  4447. EXT_meshopt_compression.prototype.dispose = function () {
  4448. this._loader = null;
  4449. };
  4450. /**
  4451. * @param context
  4452. * @param bufferView
  4453. * @hidden
  4454. */
  4455. EXT_meshopt_compression.prototype.loadBufferViewAsync = function (context, bufferView) {
  4456. var _this = this;
  4457. return _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.LoadExtensionAsync(context, bufferView, this.name, function (extensionContext, extension) {
  4458. var bufferViewMeshopt = bufferView;
  4459. if (bufferViewMeshopt._meshOptData) {
  4460. return bufferViewMeshopt._meshOptData;
  4461. }
  4462. var buffer = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(context, "/buffer"), _this._loader.gltf.buffers, extension.buffer);
  4463. bufferViewMeshopt._meshOptData = _this._loader.loadBufferAsync("/buffers/".concat(buffer.index), buffer, extension.byteOffset || 0, extension.byteLength).then(function (buffer) {
  4464. return core_Meshes_Compression_meshoptCompression__WEBPACK_IMPORTED_MODULE_1__.MeshoptCompression.Default.decodeGltfBufferAsync(buffer, extension.count, extension.byteStride, extension.mode, extension.filter);
  4465. });
  4466. return bufferViewMeshopt._meshOptData;
  4467. });
  4468. };
  4469. return EXT_meshopt_compression;
  4470. }());
  4471. _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new EXT_meshopt_compression(loader); });
  4472. /***/ }),
  4473. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/EXT_texture_webp.js":
  4474. /*!*************************************************************************!*\
  4475. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/EXT_texture_webp.js ***!
  4476. \*************************************************************************/
  4477. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4478. __webpack_require__.r(__webpack_exports__);
  4479. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4480. /* harmony export */ "EXT_texture_webp": () => (/* binding */ EXT_texture_webp)
  4481. /* harmony export */ });
  4482. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  4483. var NAME = "EXT_texture_webp";
  4484. /**
  4485. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  4486. */
  4487. var EXT_texture_webp = /** @class */ (function () {
  4488. /**
  4489. * @param loader
  4490. * @hidden
  4491. */
  4492. function EXT_texture_webp(loader) {
  4493. /** The name of this extension. */
  4494. this.name = NAME;
  4495. this._loader = loader;
  4496. this.enabled = loader.isExtensionUsed(NAME);
  4497. }
  4498. /** @hidden */
  4499. EXT_texture_webp.prototype.dispose = function () {
  4500. this._loader = null;
  4501. };
  4502. /**
  4503. * @param context
  4504. * @param texture
  4505. * @param assign
  4506. * @hidden
  4507. */
  4508. EXT_texture_webp.prototype._loadTextureAsync = function (context, texture, assign) {
  4509. var _this = this;
  4510. return _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.LoadExtensionAsync(context, texture, this.name, function (extensionContext, extension) {
  4511. var sampler = texture.sampler == undefined ? _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.DefaultSampler : _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(context, "/sampler"), _this._loader.gltf.samplers, texture.sampler);
  4512. var image = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(extensionContext, "/source"), _this._loader.gltf.images, extension.source);
  4513. return _this._loader._createTextureAsync(context, sampler, image, function (babylonTexture) {
  4514. assign(babylonTexture);
  4515. }, undefined, !texture._textureInfo.nonColorData);
  4516. });
  4517. };
  4518. return EXT_texture_webp;
  4519. }());
  4520. _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new EXT_texture_webp(loader); });
  4521. /***/ }),
  4522. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/ExtrasAsMetadata.js":
  4523. /*!*************************************************************************!*\
  4524. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/ExtrasAsMetadata.js ***!
  4525. \*************************************************************************/
  4526. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4527. __webpack_require__.r(__webpack_exports__);
  4528. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4529. /* harmony export */ "ExtrasAsMetadata": () => (/* binding */ ExtrasAsMetadata)
  4530. /* harmony export */ });
  4531. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  4532. var NAME = "ExtrasAsMetadata";
  4533. /**
  4534. * Store glTF extras (if present) in BJS objects' metadata
  4535. */
  4536. var ExtrasAsMetadata = /** @class */ (function () {
  4537. /**
  4538. * @param loader
  4539. * @hidden
  4540. */
  4541. function ExtrasAsMetadata(loader) {
  4542. /**
  4543. * The name of this extension.
  4544. */
  4545. this.name = NAME;
  4546. /**
  4547. * Defines whether this extension is enabled.
  4548. */
  4549. this.enabled = true;
  4550. this._loader = loader;
  4551. }
  4552. ExtrasAsMetadata.prototype._assignExtras = function (babylonObject, gltfProp) {
  4553. if (gltfProp.extras && Object.keys(gltfProp.extras).length > 0) {
  4554. var metadata = (babylonObject.metadata = babylonObject.metadata || {});
  4555. var gltf = (metadata.gltf = metadata.gltf || {});
  4556. gltf.extras = gltfProp.extras;
  4557. }
  4558. };
  4559. /** @hidden */
  4560. ExtrasAsMetadata.prototype.dispose = function () {
  4561. this._loader = null;
  4562. };
  4563. /**
  4564. * @param context
  4565. * @param node
  4566. * @param assign
  4567. * @hidden
  4568. */
  4569. ExtrasAsMetadata.prototype.loadNodeAsync = function (context, node, assign) {
  4570. var _this = this;
  4571. return this._loader.loadNodeAsync(context, node, function (babylonTransformNode) {
  4572. _this._assignExtras(babylonTransformNode, node);
  4573. assign(babylonTransformNode);
  4574. });
  4575. };
  4576. /**
  4577. * @param context
  4578. * @param camera
  4579. * @param assign
  4580. * @hidden
  4581. */
  4582. ExtrasAsMetadata.prototype.loadCameraAsync = function (context, camera, assign) {
  4583. var _this = this;
  4584. return this._loader.loadCameraAsync(context, camera, function (babylonCamera) {
  4585. _this._assignExtras(babylonCamera, camera);
  4586. assign(babylonCamera);
  4587. });
  4588. };
  4589. /**
  4590. * @param context
  4591. * @param material
  4592. * @param babylonDrawMode
  4593. * @hidden
  4594. */
  4595. ExtrasAsMetadata.prototype.createMaterial = function (context, material, babylonDrawMode) {
  4596. var babylonMaterial = this._loader.createMaterial(context, material, babylonDrawMode);
  4597. this._assignExtras(babylonMaterial, material);
  4598. return babylonMaterial;
  4599. };
  4600. return ExtrasAsMetadata;
  4601. }());
  4602. _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new ExtrasAsMetadata(loader); });
  4603. /***/ }),
  4604. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_draco_mesh_compression.js":
  4605. /*!***********************************************************************************!*\
  4606. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_draco_mesh_compression.js ***!
  4607. \***********************************************************************************/
  4608. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4609. __webpack_require__.r(__webpack_exports__);
  4610. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4611. /* harmony export */ "KHR_draco_mesh_compression": () => (/* binding */ KHR_draco_mesh_compression)
  4612. /* harmony export */ });
  4613. /* harmony import */ var core_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Meshes/geometry */ "core/Misc/observable");
  4614. /* harmony import */ var core_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__);
  4615. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  4616. var NAME = "KHR_draco_mesh_compression";
  4617. /**
  4618. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  4619. */
  4620. var KHR_draco_mesh_compression = /** @class */ (function () {
  4621. /**
  4622. * @param loader
  4623. * @hidden
  4624. */
  4625. function KHR_draco_mesh_compression(loader) {
  4626. /**
  4627. * The name of this extension.
  4628. */
  4629. this.name = NAME;
  4630. this._loader = loader;
  4631. this.enabled = core_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.DracoCompression.DecoderAvailable && this._loader.isExtensionUsed(NAME);
  4632. }
  4633. /** @hidden */
  4634. KHR_draco_mesh_compression.prototype.dispose = function () {
  4635. delete this.dracoCompression;
  4636. this._loader = null;
  4637. };
  4638. /**
  4639. * @param context
  4640. * @param primitive
  4641. * @param babylonMesh
  4642. * @hidden
  4643. */
  4644. KHR_draco_mesh_compression.prototype._loadVertexDataAsync = function (context, primitive, babylonMesh) {
  4645. var _this = this;
  4646. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, primitive, this.name, function (extensionContext, extension) {
  4647. if (primitive.mode != undefined) {
  4648. if (primitive.mode !== 5 /* TRIANGLE_STRIP */ && primitive.mode !== 4 /* TRIANGLES */) {
  4649. throw new Error("".concat(context, ": Unsupported mode ").concat(primitive.mode));
  4650. }
  4651. // TODO: handle triangle strips
  4652. if (primitive.mode === 5 /* TRIANGLE_STRIP */) {
  4653. throw new Error("".concat(context, ": Mode ").concat(primitive.mode, " is not currently supported"));
  4654. }
  4655. }
  4656. var attributes = {};
  4657. var dividers = {};
  4658. var loadAttribute = function (name, kind) {
  4659. var uniqueId = extension.attributes[name];
  4660. if (uniqueId === undefined || primitive.attributes[name] === undefined) {
  4661. return;
  4662. }
  4663. attributes[kind] = uniqueId;
  4664. var accessor = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(context, "/attributes/").concat(name), _this._loader.gltf.accessors, primitive.attributes[name]);
  4665. if (accessor.normalized && accessor.componentType !== 5126 /* FLOAT */) {
  4666. var divider = 1;
  4667. switch (accessor.componentType) {
  4668. case 5120 /* BYTE */:
  4669. divider = 127.0;
  4670. break;
  4671. case 5121 /* UNSIGNED_BYTE */:
  4672. divider = 255.0;
  4673. break;
  4674. case 5122 /* SHORT */:
  4675. divider = 32767.0;
  4676. break;
  4677. case 5123 /* UNSIGNED_SHORT */:
  4678. divider = 65535.0;
  4679. break;
  4680. }
  4681. dividers[kind] = divider;
  4682. }
  4683. babylonMesh._delayInfo = babylonMesh._delayInfo || [];
  4684. if (babylonMesh._delayInfo.indexOf(kind) === -1) {
  4685. babylonMesh._delayInfo.push(kind);
  4686. }
  4687. };
  4688. loadAttribute("POSITION", core_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind);
  4689. loadAttribute("NORMAL", core_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind);
  4690. loadAttribute("TANGENT", core_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind);
  4691. loadAttribute("TEXCOORD_0", core_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UVKind);
  4692. loadAttribute("TEXCOORD_1", core_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV2Kind);
  4693. loadAttribute("TEXCOORD_2", core_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV3Kind);
  4694. loadAttribute("TEXCOORD_3", core_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV4Kind);
  4695. loadAttribute("TEXCOORD_4", core_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV5Kind);
  4696. loadAttribute("TEXCOORD_5", core_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV6Kind);
  4697. loadAttribute("JOINTS_0", core_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesKind);
  4698. loadAttribute("WEIGHTS_0", core_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsKind);
  4699. loadAttribute("COLOR_0", core_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ColorKind);
  4700. var bufferView = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get(extensionContext, _this._loader.gltf.bufferViews, extension.bufferView);
  4701. if (!bufferView._dracoBabylonGeometry) {
  4702. bufferView._dracoBabylonGeometry = _this._loader.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) {
  4703. var dracoCompression = _this.dracoCompression || core_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.DracoCompression.Default;
  4704. return dracoCompression
  4705. .decodeMeshAsync(data, attributes, dividers)
  4706. .then(function (babylonVertexData) {
  4707. var babylonGeometry = new core_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.Geometry(babylonMesh.name, _this._loader.babylonScene);
  4708. babylonVertexData.applyToGeometry(babylonGeometry);
  4709. return babylonGeometry;
  4710. })
  4711. .catch(function (error) {
  4712. throw new Error("".concat(context, ": ").concat(error.message));
  4713. });
  4714. });
  4715. }
  4716. return bufferView._dracoBabylonGeometry;
  4717. });
  4718. };
  4719. return KHR_draco_mesh_compression;
  4720. }());
  4721. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_draco_mesh_compression(loader); });
  4722. /***/ }),
  4723. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_lights_punctual.js":
  4724. /*!****************************************************************************!*\
  4725. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_lights_punctual.js ***!
  4726. \****************************************************************************/
  4727. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4728. __webpack_require__.r(__webpack_exports__);
  4729. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4730. /* harmony export */ "KHR_lights": () => (/* binding */ KHR_lights)
  4731. /* harmony export */ });
  4732. /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Lights/light */ "core/Misc/observable");
  4733. /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  4734. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  4735. var NAME = "KHR_lights_punctual";
  4736. /**
  4737. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  4738. */
  4739. var KHR_lights = /** @class */ (function () {
  4740. /**
  4741. * @param loader
  4742. * @hidden
  4743. */
  4744. function KHR_lights(loader) {
  4745. /**
  4746. * The name of this extension.
  4747. */
  4748. this.name = NAME;
  4749. this._loader = loader;
  4750. this.enabled = this._loader.isExtensionUsed(NAME);
  4751. }
  4752. /** @hidden */
  4753. KHR_lights.prototype.dispose = function () {
  4754. this._loader = null;
  4755. delete this._lights;
  4756. };
  4757. /** @hidden */
  4758. KHR_lights.prototype.onLoading = function () {
  4759. var extensions = this._loader.gltf.extensions;
  4760. if (extensions && extensions[this.name]) {
  4761. var extension = extensions[this.name];
  4762. this._lights = extension.lights;
  4763. }
  4764. };
  4765. /**
  4766. * @param context
  4767. * @param node
  4768. * @param assign
  4769. * @hidden
  4770. */
  4771. KHR_lights.prototype.loadNodeAsync = function (context, node, assign) {
  4772. var _this = this;
  4773. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) {
  4774. return _this._loader.loadNodeAsync(context, node, function (babylonMesh) {
  4775. var babylonLight;
  4776. var light = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get(extensionContext, _this._lights, extension.light);
  4777. var name = light.name || babylonMesh.name;
  4778. _this._loader.babylonScene._blockEntityCollection = !!_this._loader._assetContainer;
  4779. switch (light.type) {
  4780. case "directional" /* DIRECTIONAL */: {
  4781. babylonLight = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.DirectionalLight(name, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Backward(), _this._loader.babylonScene);
  4782. break;
  4783. }
  4784. case "point" /* POINT */: {
  4785. babylonLight = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.PointLight(name, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(), _this._loader.babylonScene);
  4786. break;
  4787. }
  4788. case "spot" /* SPOT */: {
  4789. var babylonSpotLight = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.SpotLight(name, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(), core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Backward(), 0, 1, _this._loader.babylonScene);
  4790. babylonSpotLight.angle = ((light.spot && light.spot.outerConeAngle) || Math.PI / 4) * 2;
  4791. babylonSpotLight.innerAngle = ((light.spot && light.spot.innerConeAngle) || 0) * 2;
  4792. babylonLight = babylonSpotLight;
  4793. break;
  4794. }
  4795. default: {
  4796. _this._loader.babylonScene._blockEntityCollection = false;
  4797. throw new Error("".concat(extensionContext, ": Invalid light type (").concat(light.type, ")"));
  4798. }
  4799. }
  4800. babylonLight._parentContainer = _this._loader._assetContainer;
  4801. _this._loader.babylonScene._blockEntityCollection = false;
  4802. babylonLight.falloffType = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Light.FALLOFF_GLTF;
  4803. babylonLight.diffuse = light.color ? core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(light.color) : core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.White();
  4804. babylonLight.intensity = light.intensity == undefined ? 1 : light.intensity;
  4805. babylonLight.range = light.range == undefined ? Number.MAX_VALUE : light.range;
  4806. babylonLight.parent = babylonMesh;
  4807. _this._loader._babylonLights.push(babylonLight);
  4808. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.AddPointerMetadata(babylonLight, extensionContext);
  4809. assign(babylonMesh);
  4810. });
  4811. });
  4812. };
  4813. return KHR_lights;
  4814. }());
  4815. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_lights(loader); });
  4816. /***/ }),
  4817. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_clearcoat.js":
  4818. /*!********************************************************************************!*\
  4819. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_clearcoat.js ***!
  4820. \********************************************************************************/
  4821. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4822. __webpack_require__.r(__webpack_exports__);
  4823. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4824. /* harmony export */ "KHR_materials_clearcoat": () => (/* binding */ KHR_materials_clearcoat)
  4825. /* harmony export */ });
  4826. /* harmony import */ var core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Materials/PBR/pbrMaterial */ "core/Misc/observable");
  4827. /* harmony import */ var core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__);
  4828. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  4829. var NAME = "KHR_materials_clearcoat";
  4830. /**
  4831. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  4832. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  4833. */
  4834. var KHR_materials_clearcoat = /** @class */ (function () {
  4835. /**
  4836. * @param loader
  4837. * @hidden
  4838. */
  4839. function KHR_materials_clearcoat(loader) {
  4840. /**
  4841. * The name of this extension.
  4842. */
  4843. this.name = NAME;
  4844. /**
  4845. * Defines a number that determines the order the extensions are applied.
  4846. */
  4847. this.order = 190;
  4848. this._loader = loader;
  4849. this.enabled = this._loader.isExtensionUsed(NAME);
  4850. }
  4851. /** @hidden */
  4852. KHR_materials_clearcoat.prototype.dispose = function () {
  4853. this._loader = null;
  4854. };
  4855. /**
  4856. * @param context
  4857. * @param material
  4858. * @param babylonMaterial
  4859. * @hidden
  4860. */
  4861. KHR_materials_clearcoat.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
  4862. var _this = this;
  4863. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
  4864. var promises = new Array();
  4865. promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
  4866. promises.push(_this._loadClearCoatPropertiesAsync(extensionContext, extension, babylonMaterial));
  4867. return Promise.all(promises).then(function () { });
  4868. });
  4869. };
  4870. KHR_materials_clearcoat.prototype._loadClearCoatPropertiesAsync = function (context, properties, babylonMaterial) {
  4871. if (!(babylonMaterial instanceof core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) {
  4872. throw new Error("".concat(context, ": Material type not supported"));
  4873. }
  4874. var promises = new Array();
  4875. babylonMaterial.clearCoat.isEnabled = true;
  4876. babylonMaterial.clearCoat.useRoughnessFromMainTexture = false;
  4877. babylonMaterial.clearCoat.remapF0OnInterfaceChange = false;
  4878. if (properties.clearcoatFactor != undefined) {
  4879. babylonMaterial.clearCoat.intensity = properties.clearcoatFactor;
  4880. }
  4881. else {
  4882. babylonMaterial.clearCoat.intensity = 0;
  4883. }
  4884. if (properties.clearcoatTexture) {
  4885. promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/clearcoatTexture"), properties.clearcoatTexture, function (texture) {
  4886. texture.name = "".concat(babylonMaterial.name, " (ClearCoat Intensity)");
  4887. babylonMaterial.clearCoat.texture = texture;
  4888. }));
  4889. }
  4890. if (properties.clearcoatRoughnessFactor != undefined) {
  4891. babylonMaterial.clearCoat.roughness = properties.clearcoatRoughnessFactor;
  4892. }
  4893. else {
  4894. babylonMaterial.clearCoat.roughness = 0;
  4895. }
  4896. if (properties.clearcoatRoughnessTexture) {
  4897. properties.clearcoatRoughnessTexture.nonColorData = true;
  4898. promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/clearcoatRoughnessTexture"), properties.clearcoatRoughnessTexture, function (texture) {
  4899. texture.name = "".concat(babylonMaterial.name, " (ClearCoat Roughness)");
  4900. babylonMaterial.clearCoat.textureRoughness = texture;
  4901. }));
  4902. }
  4903. if (properties.clearcoatNormalTexture) {
  4904. properties.clearcoatNormalTexture.nonColorData = true;
  4905. promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/clearcoatNormalTexture"), properties.clearcoatNormalTexture, function (texture) {
  4906. texture.name = "".concat(babylonMaterial.name, " (ClearCoat Normal)");
  4907. babylonMaterial.clearCoat.bumpTexture = texture;
  4908. }));
  4909. babylonMaterial.invertNormalMapX = !babylonMaterial.getScene().useRightHandedSystem;
  4910. babylonMaterial.invertNormalMapY = babylonMaterial.getScene().useRightHandedSystem;
  4911. if (properties.clearcoatNormalTexture.scale != undefined) {
  4912. babylonMaterial.clearCoat.bumpTexture.level = properties.clearcoatNormalTexture.scale;
  4913. }
  4914. }
  4915. return Promise.all(promises).then(function () { });
  4916. };
  4917. return KHR_materials_clearcoat;
  4918. }());
  4919. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_clearcoat(loader); });
  4920. /***/ }),
  4921. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_emissive_strength.js":
  4922. /*!****************************************************************************************!*\
  4923. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_emissive_strength.js ***!
  4924. \****************************************************************************************/
  4925. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4926. __webpack_require__.r(__webpack_exports__);
  4927. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4928. /* harmony export */ "KHR_materials_emissive_strength": () => (/* binding */ KHR_materials_emissive_strength)
  4929. /* harmony export */ });
  4930. /* harmony import */ var core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Materials/PBR/pbrMaterial */ "core/Misc/observable");
  4931. /* harmony import */ var core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__);
  4932. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  4933. var NAME = "KHR_materials_emissive_strength";
  4934. /**
  4935. * [Experimental Spec](https://github.com/KhronosGroup/glTF/pull/1994)
  4936. */
  4937. var KHR_materials_emissive_strength = /** @class */ (function () {
  4938. /**
  4939. * @param loader
  4940. * @hidden
  4941. */
  4942. function KHR_materials_emissive_strength(loader) {
  4943. /**
  4944. * The name of this extension.
  4945. */
  4946. this.name = NAME;
  4947. /**
  4948. * Defines a number that determines the order the extensions are applied.
  4949. */
  4950. this.order = 170;
  4951. this._loader = loader;
  4952. this.enabled = this._loader.isExtensionUsed(NAME);
  4953. }
  4954. /** @hidden */
  4955. KHR_materials_emissive_strength.prototype.dispose = function () {
  4956. this._loader = null;
  4957. };
  4958. /**
  4959. * @param context
  4960. * @param material
  4961. * @param babylonMaterial
  4962. * @hidden
  4963. */
  4964. KHR_materials_emissive_strength.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
  4965. var _this = this;
  4966. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
  4967. return _this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial).then(function () {
  4968. _this._loadEmissiveProperties(extensionContext, extension, babylonMaterial);
  4969. });
  4970. });
  4971. };
  4972. KHR_materials_emissive_strength.prototype._loadEmissiveProperties = function (context, properties, babylonMaterial) {
  4973. if (!(babylonMaterial instanceof core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) {
  4974. throw new Error("".concat(context, ": Material type not supported"));
  4975. }
  4976. if (properties.emissiveStrength !== undefined) {
  4977. babylonMaterial.emissiveColor.scaleToRef(properties.emissiveStrength, babylonMaterial.emissiveColor);
  4978. }
  4979. };
  4980. return KHR_materials_emissive_strength;
  4981. }());
  4982. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_emissive_strength(loader); });
  4983. /***/ }),
  4984. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_ior.js":
  4985. /*!**************************************************************************!*\
  4986. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_ior.js ***!
  4987. \**************************************************************************/
  4988. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  4989. __webpack_require__.r(__webpack_exports__);
  4990. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  4991. /* harmony export */ "KHR_materials_ior": () => (/* binding */ KHR_materials_ior)
  4992. /* harmony export */ });
  4993. /* harmony import */ var core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Materials/PBR/pbrMaterial */ "core/Misc/observable");
  4994. /* harmony import */ var core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__);
  4995. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  4996. var NAME = "KHR_materials_ior";
  4997. /**
  4998. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_ior)
  4999. */
  5000. var KHR_materials_ior = /** @class */ (function () {
  5001. /**
  5002. * @param loader
  5003. * @hidden
  5004. */
  5005. function KHR_materials_ior(loader) {
  5006. /**
  5007. * The name of this extension.
  5008. */
  5009. this.name = NAME;
  5010. /**
  5011. * Defines a number that determines the order the extensions are applied.
  5012. */
  5013. this.order = 180;
  5014. this._loader = loader;
  5015. this.enabled = this._loader.isExtensionUsed(NAME);
  5016. }
  5017. /** @hidden */
  5018. KHR_materials_ior.prototype.dispose = function () {
  5019. this._loader = null;
  5020. };
  5021. /**
  5022. * @param context
  5023. * @param material
  5024. * @param babylonMaterial
  5025. * @hidden
  5026. */
  5027. KHR_materials_ior.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
  5028. var _this = this;
  5029. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
  5030. var promises = new Array();
  5031. promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
  5032. promises.push(_this._loadIorPropertiesAsync(extensionContext, extension, babylonMaterial));
  5033. return Promise.all(promises).then(function () { });
  5034. });
  5035. };
  5036. KHR_materials_ior.prototype._loadIorPropertiesAsync = function (context, properties, babylonMaterial) {
  5037. if (!(babylonMaterial instanceof core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) {
  5038. throw new Error("".concat(context, ": Material type not supported"));
  5039. }
  5040. if (properties.ior !== undefined) {
  5041. babylonMaterial.indexOfRefraction = properties.ior;
  5042. }
  5043. else {
  5044. babylonMaterial.indexOfRefraction = KHR_materials_ior._DEFAULT_IOR;
  5045. }
  5046. return Promise.resolve();
  5047. };
  5048. /**
  5049. * Default ior Value from the spec.
  5050. */
  5051. KHR_materials_ior._DEFAULT_IOR = 1.5;
  5052. return KHR_materials_ior;
  5053. }());
  5054. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_ior(loader); });
  5055. /***/ }),
  5056. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js":
  5057. /*!********************************************************************************************!*\
  5058. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js ***!
  5059. \********************************************************************************************/
  5060. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5061. __webpack_require__.r(__webpack_exports__);
  5062. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5063. /* harmony export */ "KHR_materials_pbrSpecularGlossiness": () => (/* binding */ KHR_materials_pbrSpecularGlossiness)
  5064. /* harmony export */ });
  5065. /* harmony import */ var core_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Materials/PBR/pbrMaterial */ "core/Misc/observable");
  5066. /* harmony import */ var core_Maths_math_color__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__);
  5067. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  5068. var NAME = "KHR_materials_pbrSpecularGlossiness";
  5069. /**
  5070. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  5071. */
  5072. var KHR_materials_pbrSpecularGlossiness = /** @class */ (function () {
  5073. /**
  5074. * @param loader
  5075. * @hidden
  5076. */
  5077. function KHR_materials_pbrSpecularGlossiness(loader) {
  5078. /**
  5079. * The name of this extension.
  5080. */
  5081. this.name = NAME;
  5082. /**
  5083. * Defines a number that determines the order the extensions are applied.
  5084. */
  5085. this.order = 200;
  5086. this._loader = loader;
  5087. this.enabled = this._loader.isExtensionUsed(NAME);
  5088. }
  5089. /** @hidden */
  5090. KHR_materials_pbrSpecularGlossiness.prototype.dispose = function () {
  5091. this._loader = null;
  5092. };
  5093. /**
  5094. * @param context
  5095. * @param material
  5096. * @param babylonMaterial
  5097. * @hidden
  5098. */
  5099. KHR_materials_pbrSpecularGlossiness.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
  5100. var _this = this;
  5101. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
  5102. var promises = new Array();
  5103. promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));
  5104. promises.push(_this._loadSpecularGlossinessPropertiesAsync(extensionContext, material, extension, babylonMaterial));
  5105. _this._loader.loadMaterialAlphaProperties(context, material, babylonMaterial);
  5106. return Promise.all(promises).then(function () { });
  5107. });
  5108. };
  5109. KHR_materials_pbrSpecularGlossiness.prototype._loadSpecularGlossinessPropertiesAsync = function (context, material, properties, babylonMaterial) {
  5110. if (!(babylonMaterial instanceof core_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) {
  5111. throw new Error("".concat(context, ": Material type not supported"));
  5112. }
  5113. var promises = new Array();
  5114. babylonMaterial.metallic = null;
  5115. babylonMaterial.roughness = null;
  5116. if (properties.diffuseFactor) {
  5117. babylonMaterial.albedoColor = core_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.diffuseFactor);
  5118. babylonMaterial.alpha = properties.diffuseFactor[3];
  5119. }
  5120. else {
  5121. babylonMaterial.albedoColor = core_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.White();
  5122. }
  5123. babylonMaterial.reflectivityColor = properties.specularFactor ? core_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.specularFactor) : core_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.White();
  5124. babylonMaterial.microSurface = properties.glossinessFactor == undefined ? 1 : properties.glossinessFactor;
  5125. if (properties.diffuseTexture) {
  5126. promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/diffuseTexture"), properties.diffuseTexture, function (texture) {
  5127. texture.name = "".concat(babylonMaterial.name, " (Diffuse)");
  5128. babylonMaterial.albedoTexture = texture;
  5129. }));
  5130. }
  5131. if (properties.specularGlossinessTexture) {
  5132. promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/specularGlossinessTexture"), properties.specularGlossinessTexture, function (texture) {
  5133. texture.name = "".concat(babylonMaterial.name, " (Specular Glossiness)");
  5134. babylonMaterial.reflectivityTexture = texture;
  5135. }));
  5136. babylonMaterial.reflectivityTexture.hasAlpha = true;
  5137. babylonMaterial.useMicroSurfaceFromReflectivityMapAlpha = true;
  5138. }
  5139. return Promise.all(promises).then(function () { });
  5140. };
  5141. return KHR_materials_pbrSpecularGlossiness;
  5142. }());
  5143. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_pbrSpecularGlossiness(loader); });
  5144. /***/ }),
  5145. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_sheen.js":
  5146. /*!****************************************************************************!*\
  5147. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_sheen.js ***!
  5148. \****************************************************************************/
  5149. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5150. __webpack_require__.r(__webpack_exports__);
  5151. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5152. /* harmony export */ "KHR_materials_sheen": () => (/* binding */ KHR_materials_sheen)
  5153. /* harmony export */ });
  5154. /* harmony import */ var core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Maths/math.color */ "core/Misc/observable");
  5155. /* harmony import */ var core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__);
  5156. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  5157. var NAME = "KHR_materials_sheen";
  5158. /**
  5159. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
  5160. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  5161. */
  5162. var KHR_materials_sheen = /** @class */ (function () {
  5163. /**
  5164. * @param loader
  5165. * @hidden
  5166. */
  5167. function KHR_materials_sheen(loader) {
  5168. /**
  5169. * The name of this extension.
  5170. */
  5171. this.name = NAME;
  5172. /**
  5173. * Defines a number that determines the order the extensions are applied.
  5174. */
  5175. this.order = 190;
  5176. this._loader = loader;
  5177. this.enabled = this._loader.isExtensionUsed(NAME);
  5178. }
  5179. /** @hidden */
  5180. KHR_materials_sheen.prototype.dispose = function () {
  5181. this._loader = null;
  5182. };
  5183. /**
  5184. * @param context
  5185. * @param material
  5186. * @param babylonMaterial
  5187. * @hidden
  5188. */
  5189. KHR_materials_sheen.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
  5190. var _this = this;
  5191. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
  5192. var promises = new Array();
  5193. promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
  5194. promises.push(_this._loadSheenPropertiesAsync(extensionContext, extension, babylonMaterial));
  5195. return Promise.all(promises).then(function () { });
  5196. });
  5197. };
  5198. KHR_materials_sheen.prototype._loadSheenPropertiesAsync = function (context, properties, babylonMaterial) {
  5199. if (!(babylonMaterial instanceof core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) {
  5200. throw new Error("".concat(context, ": Material type not supported"));
  5201. }
  5202. var promises = new Array();
  5203. babylonMaterial.sheen.isEnabled = true;
  5204. babylonMaterial.sheen.intensity = 1;
  5205. if (properties.sheenColorFactor != undefined) {
  5206. babylonMaterial.sheen.color = core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.sheenColorFactor);
  5207. }
  5208. else {
  5209. babylonMaterial.sheen.color = core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Color3.Black();
  5210. }
  5211. if (properties.sheenColorTexture) {
  5212. promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/sheenColorTexture"), properties.sheenColorTexture, function (texture) {
  5213. texture.name = "".concat(babylonMaterial.name, " (Sheen Color)");
  5214. babylonMaterial.sheen.texture = texture;
  5215. }));
  5216. }
  5217. if (properties.sheenRoughnessFactor !== undefined) {
  5218. babylonMaterial.sheen.roughness = properties.sheenRoughnessFactor;
  5219. }
  5220. else {
  5221. babylonMaterial.sheen.roughness = 0;
  5222. }
  5223. if (properties.sheenRoughnessTexture) {
  5224. properties.sheenRoughnessTexture.nonColorData = true;
  5225. promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/sheenRoughnessTexture"), properties.sheenRoughnessTexture, function (texture) {
  5226. texture.name = "".concat(babylonMaterial.name, " (Sheen Roughness)");
  5227. babylonMaterial.sheen.textureRoughness = texture;
  5228. }));
  5229. }
  5230. babylonMaterial.sheen.albedoScaling = true;
  5231. babylonMaterial.sheen.useRoughnessFromMainTexture = false;
  5232. return Promise.all(promises).then(function () { });
  5233. };
  5234. return KHR_materials_sheen;
  5235. }());
  5236. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_sheen(loader); });
  5237. /***/ }),
  5238. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_specular.js":
  5239. /*!*******************************************************************************!*\
  5240. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_specular.js ***!
  5241. \*******************************************************************************/
  5242. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5243. __webpack_require__.r(__webpack_exports__);
  5244. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5245. /* harmony export */ "KHR_materials_specular": () => (/* binding */ KHR_materials_specular)
  5246. /* harmony export */ });
  5247. /* harmony import */ var core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Maths/math.color */ "core/Misc/observable");
  5248. /* harmony import */ var core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__);
  5249. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  5250. var NAME = "KHR_materials_specular";
  5251. /**
  5252. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_specular)
  5253. */
  5254. var KHR_materials_specular = /** @class */ (function () {
  5255. /**
  5256. * @param loader
  5257. * @hidden
  5258. */
  5259. function KHR_materials_specular(loader) {
  5260. /**
  5261. * The name of this extension.
  5262. */
  5263. this.name = NAME;
  5264. /**
  5265. * Defines a number that determines the order the extensions are applied.
  5266. */
  5267. this.order = 190;
  5268. this._loader = loader;
  5269. this.enabled = this._loader.isExtensionUsed(NAME);
  5270. }
  5271. /** @hidden */
  5272. KHR_materials_specular.prototype.dispose = function () {
  5273. this._loader = null;
  5274. };
  5275. /**
  5276. * @param context
  5277. * @param material
  5278. * @param babylonMaterial
  5279. * @hidden
  5280. */
  5281. KHR_materials_specular.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
  5282. var _this = this;
  5283. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
  5284. var promises = new Array();
  5285. promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
  5286. promises.push(_this._loadSpecularPropertiesAsync(extensionContext, extension, babylonMaterial));
  5287. return Promise.all(promises).then(function () { });
  5288. });
  5289. };
  5290. KHR_materials_specular.prototype._loadSpecularPropertiesAsync = function (context, properties, babylonMaterial) {
  5291. if (!(babylonMaterial instanceof core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) {
  5292. throw new Error("".concat(context, ": Material type not supported"));
  5293. }
  5294. var promises = new Array();
  5295. if (properties.specularFactor !== undefined) {
  5296. babylonMaterial.metallicF0Factor = properties.specularFactor;
  5297. }
  5298. if (properties.specularColorFactor !== undefined) {
  5299. babylonMaterial.metallicReflectanceColor = core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.specularColorFactor);
  5300. }
  5301. if (properties.specularTexture) {
  5302. properties.specularTexture.nonColorData = true;
  5303. promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/specularTexture"), properties.specularTexture, function (texture) {
  5304. texture.name = "".concat(babylonMaterial.name, " (Specular F0 Strength)");
  5305. babylonMaterial.metallicReflectanceTexture = texture;
  5306. babylonMaterial.useOnlyMetallicFromMetallicReflectanceTexture = true;
  5307. }));
  5308. }
  5309. if (properties.specularColorTexture) {
  5310. promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/specularColorTexture"), properties.specularColorTexture, function (texture) {
  5311. texture.name = "".concat(babylonMaterial.name, " (Specular F0 Color)");
  5312. babylonMaterial.reflectanceTexture = texture;
  5313. }));
  5314. }
  5315. return Promise.all(promises).then(function () { });
  5316. };
  5317. return KHR_materials_specular;
  5318. }());
  5319. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_specular(loader); });
  5320. /***/ }),
  5321. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_translucency.js":
  5322. /*!***********************************************************************************!*\
  5323. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_translucency.js ***!
  5324. \***********************************************************************************/
  5325. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5326. __webpack_require__.r(__webpack_exports__);
  5327. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5328. /* harmony export */ "KHR_materials_translucency": () => (/* binding */ KHR_materials_translucency)
  5329. /* harmony export */ });
  5330. /* harmony import */ var core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Materials/PBR/pbrMaterial */ "core/Misc/observable");
  5331. /* harmony import */ var core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__);
  5332. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  5333. var NAME = "KHR_materials_translucency";
  5334. /**
  5335. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  5336. * !!! Experimental Extension Subject to Changes !!!
  5337. */
  5338. var KHR_materials_translucency = /** @class */ (function () {
  5339. /**
  5340. * @param loader
  5341. * @hidden
  5342. */
  5343. function KHR_materials_translucency(loader) {
  5344. /**
  5345. * The name of this extension.
  5346. */
  5347. this.name = NAME;
  5348. /**
  5349. * Defines a number that determines the order the extensions are applied.
  5350. */
  5351. this.order = 174;
  5352. this._loader = loader;
  5353. this.enabled = this._loader.isExtensionUsed(NAME);
  5354. if (this.enabled) {
  5355. loader.parent.transparencyAsCoverage = true;
  5356. }
  5357. }
  5358. /** @hidden */
  5359. KHR_materials_translucency.prototype.dispose = function () {
  5360. this._loader = null;
  5361. };
  5362. /**
  5363. * @param context
  5364. * @param material
  5365. * @param babylonMaterial
  5366. * @hidden
  5367. */
  5368. KHR_materials_translucency.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
  5369. var _this = this;
  5370. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
  5371. var promises = new Array();
  5372. promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));
  5373. promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
  5374. promises.push(_this._loadTranslucentPropertiesAsync(extensionContext, material, babylonMaterial, extension));
  5375. return Promise.all(promises).then(function () { });
  5376. });
  5377. };
  5378. KHR_materials_translucency.prototype._loadTranslucentPropertiesAsync = function (context, material, babylonMaterial, extension) {
  5379. if (!(babylonMaterial instanceof core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) {
  5380. throw new Error("".concat(context, ": Material type not supported"));
  5381. }
  5382. var pbrMaterial = babylonMaterial;
  5383. // Enables "translucency" texture which represents diffusely-transmitted light.
  5384. pbrMaterial.subSurface.isTranslucencyEnabled = true;
  5385. // Since this extension models thin-surface transmission only, we must make the
  5386. // internal IOR == 1.0 and set the thickness to 0.
  5387. pbrMaterial.subSurface.volumeIndexOfRefraction = 1.0;
  5388. pbrMaterial.subSurface.minimumThickness = 0.0;
  5389. pbrMaterial.subSurface.maximumThickness = 0.0;
  5390. // Albedo colour will tint transmission.
  5391. pbrMaterial.subSurface.useAlbedoToTintTranslucency = true;
  5392. if (extension.translucencyFactor !== undefined) {
  5393. pbrMaterial.subSurface.translucencyIntensity = extension.translucencyFactor;
  5394. }
  5395. else {
  5396. pbrMaterial.subSurface.translucencyIntensity = 0.0;
  5397. pbrMaterial.subSurface.isTranslucencyEnabled = false;
  5398. return Promise.resolve();
  5399. }
  5400. if (extension.translucencyTexture) {
  5401. extension.translucencyTexture.nonColorData = true;
  5402. return this._loader.loadTextureInfoAsync("".concat(context, "/translucencyTexture"), extension.translucencyTexture).then(function (texture) {
  5403. pbrMaterial.subSurface.translucencyIntensityTexture = texture;
  5404. });
  5405. }
  5406. else {
  5407. return Promise.resolve();
  5408. }
  5409. };
  5410. return KHR_materials_translucency;
  5411. }());
  5412. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_translucency(loader); });
  5413. /***/ }),
  5414. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_transmission.js":
  5415. /*!***********************************************************************************!*\
  5416. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_transmission.js ***!
  5417. \***********************************************************************************/
  5418. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5419. __webpack_require__.r(__webpack_exports__);
  5420. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5421. /* harmony export */ "KHR_materials_transmission": () => (/* binding */ KHR_materials_transmission)
  5422. /* harmony export */ });
  5423. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.js");
  5424. /* harmony import */ var core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core/Misc/tools */ "core/Misc/observable");
  5425. /* harmony import */ var core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__);
  5426. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  5427. /**
  5428. * A class to handle setting up the rendering of opaque objects to be shown through transmissive objects.
  5429. */
  5430. var TransmissionHelper = /** @class */ (function () {
  5431. /**
  5432. * constructor
  5433. * @param options Defines the options we want to customize the helper
  5434. * @param scene The scene to add the material to
  5435. */
  5436. function TransmissionHelper(options, scene) {
  5437. var _this = this;
  5438. this._opaqueRenderTarget = null;
  5439. this._opaqueMeshesCache = [];
  5440. this._transparentMeshesCache = [];
  5441. this._materialObservers = {};
  5442. this._options = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, TransmissionHelper._getDefaultOptions()), options);
  5443. this._scene = scene;
  5444. this._scene._transmissionHelper = this;
  5445. this.onErrorObservable = new core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.Observable();
  5446. this._scene.onDisposeObservable.addOnce(function (scene) {
  5447. _this.dispose();
  5448. });
  5449. this._parseScene();
  5450. this._setupRenderTargets();
  5451. }
  5452. /**
  5453. * Creates the default options for the helper.
  5454. */
  5455. TransmissionHelper._getDefaultOptions = function () {
  5456. return {
  5457. renderSize: 1024,
  5458. samples: 4,
  5459. lodGenerationScale: 1,
  5460. lodGenerationOffset: -4,
  5461. renderTargetTextureType: core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.Constants.TEXTURETYPE_HALF_FLOAT,
  5462. generateMipmaps: true,
  5463. };
  5464. };
  5465. /**
  5466. * Updates the background according to the new options
  5467. * @param options
  5468. */
  5469. TransmissionHelper.prototype.updateOptions = function (options) {
  5470. var _this = this;
  5471. // First check if any options are actually being changed. If not, exit.
  5472. var newValues = Object.keys(options).filter(function (key) { return _this._options[key] !== options[key]; });
  5473. if (!newValues.length) {
  5474. return;
  5475. }
  5476. var newOptions = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_0__.__assign)({}, this._options), options);
  5477. var oldOptions = this._options;
  5478. this._options = newOptions;
  5479. // If size changes, recreate everything
  5480. if (newOptions.renderSize !== oldOptions.renderSize ||
  5481. newOptions.renderTargetTextureType !== oldOptions.renderTargetTextureType ||
  5482. newOptions.generateMipmaps !== oldOptions.generateMipmaps ||
  5483. !this._opaqueRenderTarget) {
  5484. this._setupRenderTargets();
  5485. }
  5486. else {
  5487. this._opaqueRenderTarget.samples = newOptions.samples;
  5488. this._opaqueRenderTarget.lodGenerationScale = newOptions.lodGenerationScale;
  5489. this._opaqueRenderTarget.lodGenerationOffset = newOptions.lodGenerationOffset;
  5490. }
  5491. };
  5492. TransmissionHelper.prototype.getOpaqueTarget = function () {
  5493. return this._opaqueRenderTarget;
  5494. };
  5495. TransmissionHelper.prototype.shouldRenderAsTransmission = function (material) {
  5496. if (!material) {
  5497. return false;
  5498. }
  5499. if (material instanceof core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial && material.subSurface.isRefractionEnabled) {
  5500. return true;
  5501. }
  5502. return false;
  5503. };
  5504. TransmissionHelper.prototype._addMesh = function (mesh) {
  5505. var _this = this;
  5506. this._materialObservers[mesh.uniqueId] = mesh.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this));
  5507. // we need to defer the processing because _addMesh may be called as part as an instance mesh creation, in which case some
  5508. // internal properties are not setup yet, like _sourceMesh (needed when doing mesh.material below)
  5509. core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.Tools.SetImmediate(function () {
  5510. if (_this.shouldRenderAsTransmission(mesh.material)) {
  5511. mesh.material.refractionTexture = _this._opaqueRenderTarget;
  5512. _this._transparentMeshesCache.push(mesh);
  5513. }
  5514. else {
  5515. _this._opaqueMeshesCache.push(mesh);
  5516. }
  5517. });
  5518. };
  5519. TransmissionHelper.prototype._removeMesh = function (mesh) {
  5520. mesh.onMaterialChangedObservable.remove(this._materialObservers[mesh.uniqueId]);
  5521. delete this._materialObservers[mesh.uniqueId];
  5522. var idx = this._transparentMeshesCache.indexOf(mesh);
  5523. if (idx !== -1) {
  5524. this._transparentMeshesCache.splice(idx, 1);
  5525. }
  5526. idx = this._opaqueMeshesCache.indexOf(mesh);
  5527. if (idx !== -1) {
  5528. this._opaqueMeshesCache.splice(idx, 1);
  5529. }
  5530. };
  5531. TransmissionHelper.prototype._parseScene = function () {
  5532. this._scene.meshes.forEach(this._addMesh.bind(this));
  5533. // Listen for when a mesh is added to the scene and add it to our cache lists.
  5534. this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this));
  5535. // Listen for when a mesh is removed from to the scene and remove it from our cache lists.
  5536. this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this));
  5537. };
  5538. // When one of the meshes in the scene has its material changed, make sure that it's in the correct cache list.
  5539. TransmissionHelper.prototype._onMeshMaterialChanged = function (mesh) {
  5540. var transparentIdx = this._transparentMeshesCache.indexOf(mesh);
  5541. var opaqueIdx = this._opaqueMeshesCache.indexOf(mesh);
  5542. // If the material is transparent, make sure that it's added to the transparent list and removed from the opaque list
  5543. var useTransmission = this.shouldRenderAsTransmission(mesh.material);
  5544. if (useTransmission) {
  5545. if (mesh.material instanceof core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial) {
  5546. mesh.material.subSurface.refractionTexture = this._opaqueRenderTarget;
  5547. }
  5548. if (opaqueIdx !== -1) {
  5549. this._opaqueMeshesCache.splice(opaqueIdx, 1);
  5550. this._transparentMeshesCache.push(mesh);
  5551. }
  5552. else if (transparentIdx === -1) {
  5553. this._transparentMeshesCache.push(mesh);
  5554. }
  5555. // If the material is opaque, make sure that it's added to the opaque list and removed from the transparent list
  5556. }
  5557. else {
  5558. if (transparentIdx !== -1) {
  5559. this._transparentMeshesCache.splice(transparentIdx, 1);
  5560. this._opaqueMeshesCache.push(mesh);
  5561. }
  5562. else if (opaqueIdx === -1) {
  5563. this._opaqueMeshesCache.push(mesh);
  5564. }
  5565. }
  5566. };
  5567. /**
  5568. * Setup the render targets according to the specified options.
  5569. */
  5570. TransmissionHelper.prototype._setupRenderTargets = function () {
  5571. var _this = this;
  5572. var _a, _b;
  5573. if (this._opaqueRenderTarget) {
  5574. this._opaqueRenderTarget.dispose();
  5575. }
  5576. this._opaqueRenderTarget = new core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.RenderTargetTexture("opaqueSceneTexture", this._options.renderSize, this._scene, this._options.generateMipmaps, undefined, this._options.renderTargetTextureType);
  5577. this._opaqueRenderTarget.ignoreCameraViewport = true;
  5578. this._opaqueRenderTarget.renderList = this._opaqueMeshesCache;
  5579. this._opaqueRenderTarget.clearColor = (_b = (_a = this._options.clearColor) === null || _a === void 0 ? void 0 : _a.clone()) !== null && _b !== void 0 ? _b : this._scene.clearColor.clone();
  5580. this._opaqueRenderTarget.gammaSpace = false;
  5581. this._opaqueRenderTarget.lodGenerationScale = this._options.lodGenerationScale;
  5582. this._opaqueRenderTarget.lodGenerationOffset = this._options.lodGenerationOffset;
  5583. this._opaqueRenderTarget.samples = this._options.samples;
  5584. var sceneImageProcessingapplyByPostProcess;
  5585. var saveSceneEnvIntensity;
  5586. this._opaqueRenderTarget.onBeforeBindObservable.add(function (opaqueRenderTarget) {
  5587. saveSceneEnvIntensity = _this._scene.environmentIntensity;
  5588. _this._scene.environmentIntensity = 1.0;
  5589. sceneImageProcessingapplyByPostProcess = _this._scene.imageProcessingConfiguration.applyByPostProcess;
  5590. if (!_this._options.clearColor) {
  5591. _this._scene.clearColor.toLinearSpaceToRef(opaqueRenderTarget.clearColor);
  5592. }
  5593. else {
  5594. opaqueRenderTarget.clearColor.copyFrom(_this._options.clearColor);
  5595. }
  5596. // we do not use the applyByPostProcess setter to avoid flagging all the materials as "image processing dirty"!
  5597. _this._scene.imageProcessingConfiguration._applyByPostProcess = true;
  5598. });
  5599. this._opaqueRenderTarget.onAfterUnbindObservable.add(function () {
  5600. _this._scene.environmentIntensity = saveSceneEnvIntensity;
  5601. _this._scene.imageProcessingConfiguration._applyByPostProcess = sceneImageProcessingapplyByPostProcess;
  5602. });
  5603. this._transparentMeshesCache.forEach(function (mesh) {
  5604. if (_this.shouldRenderAsTransmission(mesh.material)) {
  5605. mesh.material.refractionTexture = _this._opaqueRenderTarget;
  5606. }
  5607. });
  5608. };
  5609. /**
  5610. * Dispose all the elements created by the Helper.
  5611. */
  5612. TransmissionHelper.prototype.dispose = function () {
  5613. this._scene._transmissionHelper = undefined;
  5614. if (this._opaqueRenderTarget) {
  5615. this._opaqueRenderTarget.dispose();
  5616. this._opaqueRenderTarget = null;
  5617. }
  5618. this._transparentMeshesCache = [];
  5619. this._opaqueMeshesCache = [];
  5620. };
  5621. return TransmissionHelper;
  5622. }());
  5623. var NAME = "KHR_materials_transmission";
  5624. /**
  5625. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
  5626. */
  5627. var KHR_materials_transmission = /** @class */ (function () {
  5628. /**
  5629. * @param loader
  5630. * @hidden
  5631. */
  5632. function KHR_materials_transmission(loader) {
  5633. /**
  5634. * The name of this extension.
  5635. */
  5636. this.name = NAME;
  5637. /**
  5638. * Defines a number that determines the order the extensions are applied.
  5639. */
  5640. this.order = 175;
  5641. this._loader = loader;
  5642. this.enabled = this._loader.isExtensionUsed(NAME);
  5643. if (this.enabled) {
  5644. loader.parent.transparencyAsCoverage = true;
  5645. }
  5646. }
  5647. /** @hidden */
  5648. KHR_materials_transmission.prototype.dispose = function () {
  5649. this._loader = null;
  5650. };
  5651. /**
  5652. * @param context
  5653. * @param material
  5654. * @param babylonMaterial
  5655. * @hidden
  5656. */
  5657. KHR_materials_transmission.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
  5658. var _this = this;
  5659. return _glTFLoader__WEBPACK_IMPORTED_MODULE_2__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
  5660. var promises = new Array();
  5661. promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));
  5662. promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
  5663. promises.push(_this._loadTransparentPropertiesAsync(extensionContext, material, babylonMaterial, extension));
  5664. return Promise.all(promises).then(function () { });
  5665. });
  5666. };
  5667. KHR_materials_transmission.prototype._loadTransparentPropertiesAsync = function (context, material, babylonMaterial, extension) {
  5668. if (!(babylonMaterial instanceof core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial)) {
  5669. throw new Error("".concat(context, ": Material type not supported"));
  5670. }
  5671. var pbrMaterial = babylonMaterial;
  5672. // Enables "refraction" texture which represents transmitted light.
  5673. pbrMaterial.subSurface.isRefractionEnabled = true;
  5674. // Since this extension models thin-surface transmission only, we must make IOR = 1.0
  5675. pbrMaterial.subSurface.volumeIndexOfRefraction = 1.0;
  5676. // Albedo colour will tint transmission.
  5677. pbrMaterial.subSurface.useAlbedoToTintRefraction = true;
  5678. if (extension.transmissionFactor !== undefined) {
  5679. pbrMaterial.subSurface.refractionIntensity = extension.transmissionFactor;
  5680. var scene = pbrMaterial.getScene();
  5681. if (pbrMaterial.subSurface.refractionIntensity && !scene._transmissionHelper) {
  5682. new TransmissionHelper({}, pbrMaterial.getScene());
  5683. }
  5684. }
  5685. else {
  5686. pbrMaterial.subSurface.refractionIntensity = 0.0;
  5687. pbrMaterial.subSurface.isRefractionEnabled = false;
  5688. return Promise.resolve();
  5689. }
  5690. pbrMaterial.subSurface.minimumThickness = 0.0;
  5691. pbrMaterial.subSurface.maximumThickness = 0.0;
  5692. if (extension.transmissionTexture) {
  5693. extension.transmissionTexture.nonColorData = true;
  5694. return this._loader.loadTextureInfoAsync("".concat(context, "/transmissionTexture"), extension.transmissionTexture, undefined).then(function (texture) {
  5695. pbrMaterial.subSurface.refractionIntensityTexture = texture;
  5696. pbrMaterial.subSurface.useGltfStyleTextures = true;
  5697. });
  5698. }
  5699. else {
  5700. return Promise.resolve();
  5701. }
  5702. };
  5703. return KHR_materials_transmission;
  5704. }());
  5705. _glTFLoader__WEBPACK_IMPORTED_MODULE_2__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_transmission(loader); });
  5706. /***/ }),
  5707. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_unlit.js":
  5708. /*!****************************************************************************!*\
  5709. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_unlit.js ***!
  5710. \****************************************************************************/
  5711. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5712. __webpack_require__.r(__webpack_exports__);
  5713. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5714. /* harmony export */ "KHR_materials_unlit": () => (/* binding */ KHR_materials_unlit)
  5715. /* harmony export */ });
  5716. /* harmony import */ var core_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Materials/PBR/pbrMaterial */ "core/Misc/observable");
  5717. /* harmony import */ var core_Maths_math_color__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__);
  5718. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  5719. var NAME = "KHR_materials_unlit";
  5720. /**
  5721. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  5722. */
  5723. var KHR_materials_unlit = /** @class */ (function () {
  5724. /**
  5725. * @param loader
  5726. * @hidden
  5727. */
  5728. function KHR_materials_unlit(loader) {
  5729. /**
  5730. * The name of this extension.
  5731. */
  5732. this.name = NAME;
  5733. /**
  5734. * Defines a number that determines the order the extensions are applied.
  5735. */
  5736. this.order = 210;
  5737. this._loader = loader;
  5738. this.enabled = this._loader.isExtensionUsed(NAME);
  5739. }
  5740. /** @hidden */
  5741. KHR_materials_unlit.prototype.dispose = function () {
  5742. this._loader = null;
  5743. };
  5744. /**
  5745. * @param context
  5746. * @param material
  5747. * @param babylonMaterial
  5748. * @hidden
  5749. */
  5750. KHR_materials_unlit.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
  5751. var _this = this;
  5752. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function () {
  5753. return _this._loadUnlitPropertiesAsync(context, material, babylonMaterial);
  5754. });
  5755. };
  5756. KHR_materials_unlit.prototype._loadUnlitPropertiesAsync = function (context, material, babylonMaterial) {
  5757. if (!(babylonMaterial instanceof core_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) {
  5758. throw new Error("".concat(context, ": Material type not supported"));
  5759. }
  5760. var promises = new Array();
  5761. babylonMaterial.unlit = true;
  5762. var properties = material.pbrMetallicRoughness;
  5763. if (properties) {
  5764. if (properties.baseColorFactor) {
  5765. babylonMaterial.albedoColor = core_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.baseColorFactor);
  5766. babylonMaterial.alpha = properties.baseColorFactor[3];
  5767. }
  5768. else {
  5769. babylonMaterial.albedoColor = core_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.White();
  5770. }
  5771. if (properties.baseColorTexture) {
  5772. promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/baseColorTexture"), properties.baseColorTexture, function (texture) {
  5773. texture.name = "".concat(babylonMaterial.name, " (Base Color)");
  5774. babylonMaterial.albedoTexture = texture;
  5775. }));
  5776. }
  5777. }
  5778. if (material.doubleSided) {
  5779. babylonMaterial.backFaceCulling = false;
  5780. babylonMaterial.twoSidedLighting = true;
  5781. }
  5782. this._loader.loadMaterialAlphaProperties(context, material, babylonMaterial);
  5783. return Promise.all(promises).then(function () { });
  5784. };
  5785. return KHR_materials_unlit;
  5786. }());
  5787. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_unlit(loader); });
  5788. /***/ }),
  5789. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_variants.js":
  5790. /*!*******************************************************************************!*\
  5791. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_variants.js ***!
  5792. \*******************************************************************************/
  5793. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  5794. __webpack_require__.r(__webpack_exports__);
  5795. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  5796. /* harmony export */ "KHR_materials_variants": () => (/* binding */ KHR_materials_variants)
  5797. /* harmony export */ });
  5798. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  5799. /* harmony import */ var core_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core/Meshes/mesh */ "core/Misc/observable");
  5800. /* harmony import */ var core_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__);
  5801. var NAME = "KHR_materials_variants";
  5802. /**
  5803. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
  5804. */
  5805. var KHR_materials_variants = /** @class */ (function () {
  5806. /**
  5807. * @param loader
  5808. * @hidden
  5809. */
  5810. function KHR_materials_variants(loader) {
  5811. /**
  5812. * The name of this extension.
  5813. */
  5814. this.name = NAME;
  5815. this._loader = loader;
  5816. this.enabled = this._loader.isExtensionUsed(NAME);
  5817. }
  5818. /** @hidden */
  5819. KHR_materials_variants.prototype.dispose = function () {
  5820. this._loader = null;
  5821. };
  5822. /**
  5823. * Gets the list of available variant names for this asset.
  5824. * @param rootMesh The glTF root mesh
  5825. * @returns the list of all the variant names for this model
  5826. */
  5827. KHR_materials_variants.GetAvailableVariants = function (rootMesh) {
  5828. var extensionMetadata = this._GetExtensionMetadata(rootMesh);
  5829. if (!extensionMetadata) {
  5830. return [];
  5831. }
  5832. return Object.keys(extensionMetadata.variants);
  5833. };
  5834. /**
  5835. * Gets the list of available variant names for this asset.
  5836. * @param rootMesh The glTF root mesh
  5837. * @returns the list of all the variant names for this model
  5838. */
  5839. KHR_materials_variants.prototype.getAvailableVariants = function (rootMesh) {
  5840. return KHR_materials_variants.GetAvailableVariants(rootMesh);
  5841. };
  5842. /**
  5843. * Select a variant given a variant name or a list of variant names.
  5844. * @param rootMesh The glTF root mesh
  5845. * @param variantName The variant name(s) to select.
  5846. */
  5847. KHR_materials_variants.SelectVariant = function (rootMesh, variantName) {
  5848. var extensionMetadata = this._GetExtensionMetadata(rootMesh);
  5849. if (!extensionMetadata) {
  5850. throw new Error("Cannot select variant on a glTF mesh that does not have the ".concat(NAME, " extension"));
  5851. }
  5852. var select = function (variantName) {
  5853. var entries = extensionMetadata.variants[variantName];
  5854. if (entries) {
  5855. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  5856. var entry = entries_1[_i];
  5857. entry.mesh.material = entry.material;
  5858. }
  5859. }
  5860. };
  5861. if (variantName instanceof Array) {
  5862. for (var _i = 0, variantName_1 = variantName; _i < variantName_1.length; _i++) {
  5863. var name_1 = variantName_1[_i];
  5864. select(name_1);
  5865. }
  5866. }
  5867. else {
  5868. select(variantName);
  5869. }
  5870. extensionMetadata.lastSelected = variantName;
  5871. };
  5872. /**
  5873. * Select a variant given a variant name or a list of variant names.
  5874. * @param rootMesh The glTF root mesh
  5875. * @param variantName The variant name(s) to select.
  5876. */
  5877. KHR_materials_variants.prototype.selectVariant = function (rootMesh, variantName) {
  5878. return KHR_materials_variants.SelectVariant(rootMesh, variantName);
  5879. };
  5880. /**
  5881. * Reset back to the original before selecting a variant.
  5882. * @param rootMesh The glTF root mesh
  5883. */
  5884. KHR_materials_variants.Reset = function (rootMesh) {
  5885. var extensionMetadata = this._GetExtensionMetadata(rootMesh);
  5886. if (!extensionMetadata) {
  5887. throw new Error("Cannot reset on a glTF mesh that does not have the ".concat(NAME, " extension"));
  5888. }
  5889. for (var _i = 0, _a = extensionMetadata.original; _i < _a.length; _i++) {
  5890. var entry = _a[_i];
  5891. entry.mesh.material = entry.material;
  5892. }
  5893. extensionMetadata.lastSelected = null;
  5894. };
  5895. /**
  5896. * Reset back to the original before selecting a variant.
  5897. * @param rootMesh The glTF root mesh
  5898. */
  5899. KHR_materials_variants.prototype.reset = function (rootMesh) {
  5900. return KHR_materials_variants.Reset(rootMesh);
  5901. };
  5902. /**
  5903. * Gets the last selected variant name(s) or null if original.
  5904. * @param rootMesh The glTF root mesh
  5905. * @returns The selected variant name(s).
  5906. */
  5907. KHR_materials_variants.GetLastSelectedVariant = function (rootMesh) {
  5908. var extensionMetadata = this._GetExtensionMetadata(rootMesh);
  5909. if (!extensionMetadata) {
  5910. throw new Error("Cannot get the last selected variant on a glTF mesh that does not have the ".concat(NAME, " extension"));
  5911. }
  5912. return extensionMetadata.lastSelected;
  5913. };
  5914. /**
  5915. * Gets the last selected variant name(s) or null if original.
  5916. * @param rootMesh The glTF root mesh
  5917. * @returns The selected variant name(s).
  5918. */
  5919. KHR_materials_variants.prototype.getLastSelectedVariant = function (rootMesh) {
  5920. return KHR_materials_variants.GetLastSelectedVariant(rootMesh);
  5921. };
  5922. KHR_materials_variants._GetExtensionMetadata = function (rootMesh) {
  5923. var _a, _b;
  5924. return ((_b = (_a = rootMesh === null || rootMesh === void 0 ? void 0 : rootMesh.metadata) === null || _a === void 0 ? void 0 : _a.gltf) === null || _b === void 0 ? void 0 : _b[NAME]) || null;
  5925. };
  5926. /** @hidden */
  5927. KHR_materials_variants.prototype.onLoading = function () {
  5928. var extensions = this._loader.gltf.extensions;
  5929. if (extensions && extensions[this.name]) {
  5930. var extension = extensions[this.name];
  5931. this._variants = extension.variants;
  5932. }
  5933. };
  5934. /**
  5935. * @param context
  5936. * @param name
  5937. * @param node
  5938. * @param mesh
  5939. * @param primitive
  5940. * @param assign
  5941. * @hidden
  5942. */
  5943. KHR_materials_variants.prototype._loadMeshPrimitiveAsync = function (context, name, node, mesh, primitive, assign) {
  5944. var _this = this;
  5945. return _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.LoadExtensionAsync(context, primitive, this.name, function (extensionContext, extension) {
  5946. var promises = new Array();
  5947. promises.push(_this._loader._loadMeshPrimitiveAsync(context, name, node, mesh, primitive, function (babylonMesh) {
  5948. assign(babylonMesh);
  5949. if (babylonMesh instanceof core_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__.Mesh) {
  5950. var babylonDrawMode = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader._GetDrawMode(context, primitive.mode);
  5951. var root_1 = _this._loader.rootBabylonMesh;
  5952. var metadata = root_1 ? (root_1.metadata = root_1.metadata || {}) : {};
  5953. var gltf = (metadata.gltf = metadata.gltf || {});
  5954. var extensionMetadata_1 = (gltf[NAME] = gltf[NAME] || { lastSelected: null, original: [], variants: {} });
  5955. // Store the original material.
  5956. extensionMetadata_1.original.push({ mesh: babylonMesh, material: babylonMesh.material });
  5957. var _loop_1 = function (mappingIndex) {
  5958. var mapping = extension.mappings[mappingIndex];
  5959. var material = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(extensionContext, "/mappings/").concat(mappingIndex, "/material"), _this._loader.gltf.materials, mapping.material);
  5960. promises.push(_this._loader._loadMaterialAsync("#/materials/".concat(mapping.material), material, babylonMesh, babylonDrawMode, function (babylonMaterial) {
  5961. var _loop_2 = function (mappingVariantIndex) {
  5962. var variantIndex = mapping.variants[mappingVariantIndex];
  5963. var variant = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("/extensions/".concat(NAME, "/variants/").concat(variantIndex), _this._variants, variantIndex);
  5964. extensionMetadata_1.variants[variant.name] = extensionMetadata_1.variants[variant.name] || [];
  5965. extensionMetadata_1.variants[variant.name].push({
  5966. mesh: babylonMesh,
  5967. material: babylonMaterial,
  5968. });
  5969. // Replace the target when original mesh is cloned
  5970. babylonMesh.onClonedObservable.add(function (newOne) {
  5971. var newMesh = newOne;
  5972. var metadata = null;
  5973. var newRoot = newMesh;
  5974. // Find root to get medata
  5975. do {
  5976. newRoot = newRoot.parent;
  5977. if (!newRoot) {
  5978. return;
  5979. }
  5980. metadata = KHR_materials_variants._GetExtensionMetadata(newRoot);
  5981. } while (metadata === null);
  5982. // Need to clone the metadata on the root (first time only)
  5983. if (root_1 && metadata === KHR_materials_variants._GetExtensionMetadata(root_1)) {
  5984. // Copy main metadata
  5985. newRoot.metadata = {};
  5986. for (var key in root_1.metadata) {
  5987. newRoot.metadata[key] = root_1.metadata[key];
  5988. }
  5989. // Copy the gltf metadata
  5990. newRoot.metadata.gltf = [];
  5991. for (var key in root_1.metadata.gltf) {
  5992. newRoot.metadata.gltf[key] = root_1.metadata.gltf[key];
  5993. }
  5994. // Duplicate the extension specific metadata
  5995. newRoot.metadata.gltf[NAME] = { lastSelected: null, original: [], variants: {} };
  5996. for (var _i = 0, _a = metadata.original; _i < _a.length; _i++) {
  5997. var original = _a[_i];
  5998. newRoot.metadata.gltf[NAME].original.push({
  5999. mesh: original.mesh,
  6000. material: original.material,
  6001. });
  6002. }
  6003. for (var key in metadata.variants) {
  6004. if (metadata.variants.hasOwnProperty(key)) {
  6005. newRoot.metadata.gltf[NAME].variants[key] = [];
  6006. for (var _b = 0, _c = metadata.variants[key]; _b < _c.length; _b++) {
  6007. var variantEntry = _c[_b];
  6008. newRoot.metadata.gltf[NAME].variants[key].push({
  6009. mesh: variantEntry.mesh,
  6010. material: variantEntry.material,
  6011. });
  6012. }
  6013. }
  6014. }
  6015. metadata = newRoot.metadata.gltf[NAME];
  6016. }
  6017. // Relocate
  6018. for (var _d = 0, _e = metadata.original; _d < _e.length; _d++) {
  6019. var target = _e[_d];
  6020. if (target.mesh === babylonMesh) {
  6021. target.mesh = newMesh;
  6022. }
  6023. }
  6024. for (var _f = 0, _g = metadata.variants[variant.name]; _f < _g.length; _f++) {
  6025. var target = _g[_f];
  6026. if (target.mesh === babylonMesh) {
  6027. target.mesh = newMesh;
  6028. }
  6029. }
  6030. });
  6031. };
  6032. for (var mappingVariantIndex = 0; mappingVariantIndex < mapping.variants.length; ++mappingVariantIndex) {
  6033. _loop_2(mappingVariantIndex);
  6034. }
  6035. }));
  6036. };
  6037. // For each mapping, look at the variants and make a new entry for them.
  6038. for (var mappingIndex = 0; mappingIndex < extension.mappings.length; ++mappingIndex) {
  6039. _loop_1(mappingIndex);
  6040. }
  6041. }
  6042. }));
  6043. return Promise.all(promises).then(function (_a) {
  6044. var babylonMesh = _a[0];
  6045. return babylonMesh;
  6046. });
  6047. });
  6048. };
  6049. return KHR_materials_variants;
  6050. }());
  6051. _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_variants(loader); });
  6052. /***/ }),
  6053. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_volume.js":
  6054. /*!*****************************************************************************!*\
  6055. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_volume.js ***!
  6056. \*****************************************************************************/
  6057. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6058. __webpack_require__.r(__webpack_exports__);
  6059. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6060. /* harmony export */ "KHR_materials_volume": () => (/* binding */ KHR_materials_volume)
  6061. /* harmony export */ });
  6062. /* harmony import */ var core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Materials/PBR/pbrMaterial */ "core/Misc/observable");
  6063. /* harmony import */ var core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__);
  6064. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  6065. var NAME = "KHR_materials_volume";
  6066. /**
  6067. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_volume)
  6068. * @since 5.0.0
  6069. */
  6070. var KHR_materials_volume = /** @class */ (function () {
  6071. /**
  6072. * @param loader
  6073. * @hidden
  6074. */
  6075. function KHR_materials_volume(loader) {
  6076. /**
  6077. * The name of this extension.
  6078. */
  6079. this.name = NAME;
  6080. /**
  6081. * Defines a number that determines the order the extensions are applied.
  6082. */
  6083. this.order = 173;
  6084. this._loader = loader;
  6085. this.enabled = this._loader.isExtensionUsed(NAME);
  6086. if (this.enabled) {
  6087. // We need to disable instance usage because the attenuation factor depends on the node scale of each individual mesh
  6088. this._loader._disableInstancedMesh++;
  6089. }
  6090. }
  6091. /** @hidden */
  6092. KHR_materials_volume.prototype.dispose = function () {
  6093. if (this.enabled) {
  6094. this._loader._disableInstancedMesh--;
  6095. }
  6096. this._loader = null;
  6097. };
  6098. /**
  6099. * @param context
  6100. * @param material
  6101. * @param babylonMaterial
  6102. * @hidden
  6103. */
  6104. KHR_materials_volume.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
  6105. var _this = this;
  6106. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
  6107. var promises = new Array();
  6108. promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));
  6109. promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
  6110. promises.push(_this._loadVolumePropertiesAsync(extensionContext, material, babylonMaterial, extension));
  6111. return Promise.all(promises).then(function () { });
  6112. });
  6113. };
  6114. KHR_materials_volume.prototype._loadVolumePropertiesAsync = function (context, material, babylonMaterial, extension) {
  6115. if (!(babylonMaterial instanceof core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) {
  6116. throw new Error("".concat(context, ": Material type not supported"));
  6117. }
  6118. // If transparency isn't enabled already, this extension shouldn't do anything.
  6119. // i.e. it requires either the KHR_materials_transmission or KHR_materials_translucency extensions.
  6120. if ((!babylonMaterial.subSurface.isRefractionEnabled && !babylonMaterial.subSurface.isTranslucencyEnabled) || !extension.thicknessFactor) {
  6121. return Promise.resolve();
  6122. }
  6123. // IOR in this extension only affects interior.
  6124. babylonMaterial.subSurface.volumeIndexOfRefraction = babylonMaterial.indexOfRefraction;
  6125. var attenuationDistance = extension.attenuationDistance !== undefined ? extension.attenuationDistance : Number.MAX_VALUE;
  6126. babylonMaterial.subSurface.tintColorAtDistance = attenuationDistance;
  6127. if (extension.attenuationColor !== undefined && extension.attenuationColor.length == 3) {
  6128. babylonMaterial.subSurface.tintColor.copyFromFloats(extension.attenuationColor[0], extension.attenuationColor[1], extension.attenuationColor[2]);
  6129. }
  6130. babylonMaterial.subSurface.minimumThickness = 0.0;
  6131. babylonMaterial.subSurface.maximumThickness = extension.thicknessFactor;
  6132. babylonMaterial.subSurface.useThicknessAsDepth = true;
  6133. if (extension.thicknessTexture) {
  6134. extension.thicknessTexture.nonColorData = true;
  6135. return this._loader.loadTextureInfoAsync("".concat(context, "/thicknessTexture"), extension.thicknessTexture).then(function (texture) {
  6136. babylonMaterial.subSurface.thicknessTexture = texture;
  6137. babylonMaterial.subSurface.useGltfStyleTextures = true;
  6138. });
  6139. }
  6140. else {
  6141. return Promise.resolve();
  6142. }
  6143. };
  6144. return KHR_materials_volume;
  6145. }());
  6146. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_volume(loader); });
  6147. /***/ }),
  6148. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_mesh_quantization.js":
  6149. /*!******************************************************************************!*\
  6150. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_mesh_quantization.js ***!
  6151. \******************************************************************************/
  6152. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6153. __webpack_require__.r(__webpack_exports__);
  6154. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6155. /* harmony export */ "KHR_mesh_quantization": () => (/* binding */ KHR_mesh_quantization)
  6156. /* harmony export */ });
  6157. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  6158. var NAME = "KHR_mesh_quantization";
  6159. /**
  6160. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  6161. */
  6162. var KHR_mesh_quantization = /** @class */ (function () {
  6163. /**
  6164. * @param loader
  6165. * @hidden
  6166. */
  6167. function KHR_mesh_quantization(loader) {
  6168. /**
  6169. * The name of this extension.
  6170. */
  6171. this.name = NAME;
  6172. this.enabled = loader.isExtensionUsed(NAME);
  6173. }
  6174. /** @hidden */
  6175. KHR_mesh_quantization.prototype.dispose = function () { };
  6176. return KHR_mesh_quantization;
  6177. }());
  6178. _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_mesh_quantization(loader); });
  6179. /***/ }),
  6180. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_texture_basisu.js":
  6181. /*!***************************************************************************!*\
  6182. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_texture_basisu.js ***!
  6183. \***************************************************************************/
  6184. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6185. __webpack_require__.r(__webpack_exports__);
  6186. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6187. /* harmony export */ "KHR_texture_basisu": () => (/* binding */ KHR_texture_basisu)
  6188. /* harmony export */ });
  6189. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  6190. var NAME = "KHR_texture_basisu";
  6191. /**
  6192. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_basisu)
  6193. */
  6194. var KHR_texture_basisu = /** @class */ (function () {
  6195. /**
  6196. * @param loader
  6197. * @hidden
  6198. */
  6199. function KHR_texture_basisu(loader) {
  6200. /** The name of this extension. */
  6201. this.name = NAME;
  6202. this._loader = loader;
  6203. this.enabled = loader.isExtensionUsed(NAME);
  6204. }
  6205. /** @hidden */
  6206. KHR_texture_basisu.prototype.dispose = function () {
  6207. this._loader = null;
  6208. };
  6209. /**
  6210. * @param context
  6211. * @param texture
  6212. * @param assign
  6213. * @hidden
  6214. */
  6215. KHR_texture_basisu.prototype._loadTextureAsync = function (context, texture, assign) {
  6216. var _this = this;
  6217. return _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.LoadExtensionAsync(context, texture, this.name, function (extensionContext, extension) {
  6218. var sampler = texture.sampler == undefined ? _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.DefaultSampler : _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(context, "/sampler"), _this._loader.gltf.samplers, texture.sampler);
  6219. var image = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(extensionContext, "/source"), _this._loader.gltf.images, extension.source);
  6220. return _this._loader._createTextureAsync(context, sampler, image, function (babylonTexture) {
  6221. assign(babylonTexture);
  6222. }, texture._textureInfo.nonColorData ? { useRGBAIfASTCBC7NotAvailableWhenUASTC: true } : undefined, !texture._textureInfo.nonColorData);
  6223. });
  6224. };
  6225. return KHR_texture_basisu;
  6226. }());
  6227. _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_texture_basisu(loader); });
  6228. /***/ }),
  6229. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_texture_transform.js":
  6230. /*!******************************************************************************!*\
  6231. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_texture_transform.js ***!
  6232. \******************************************************************************/
  6233. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6234. __webpack_require__.r(__webpack_exports__);
  6235. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6236. /* harmony export */ "KHR_texture_transform": () => (/* binding */ KHR_texture_transform)
  6237. /* harmony export */ });
  6238. /* harmony import */ var core_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Materials/Textures/texture */ "core/Misc/observable");
  6239. /* harmony import */ var core_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__);
  6240. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  6241. var NAME = "KHR_texture_transform";
  6242. /**
  6243. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  6244. */
  6245. var KHR_texture_transform = /** @class */ (function () {
  6246. /**
  6247. * @param loader
  6248. * @hidden
  6249. */
  6250. function KHR_texture_transform(loader) {
  6251. /**
  6252. * The name of this extension.
  6253. */
  6254. this.name = NAME;
  6255. this._loader = loader;
  6256. this.enabled = this._loader.isExtensionUsed(NAME);
  6257. }
  6258. /** @hidden */
  6259. KHR_texture_transform.prototype.dispose = function () {
  6260. this._loader = null;
  6261. };
  6262. /**
  6263. * @param context
  6264. * @param textureInfo
  6265. * @param assign
  6266. * @hidden
  6267. */
  6268. KHR_texture_transform.prototype.loadTextureInfoAsync = function (context, textureInfo, assign) {
  6269. var _this = this;
  6270. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, textureInfo, this.name, function (extensionContext, extension) {
  6271. return _this._loader.loadTextureInfoAsync(context, textureInfo, function (babylonTexture) {
  6272. if (!(babylonTexture instanceof core_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__.Texture)) {
  6273. throw new Error("".concat(extensionContext, ": Texture type not supported"));
  6274. }
  6275. if (extension.offset) {
  6276. babylonTexture.uOffset = extension.offset[0];
  6277. babylonTexture.vOffset = extension.offset[1];
  6278. }
  6279. // Always rotate around the origin.
  6280. babylonTexture.uRotationCenter = 0;
  6281. babylonTexture.vRotationCenter = 0;
  6282. if (extension.rotation) {
  6283. babylonTexture.wAng = -extension.rotation;
  6284. }
  6285. if (extension.scale) {
  6286. babylonTexture.uScale = extension.scale[0];
  6287. babylonTexture.vScale = extension.scale[1];
  6288. }
  6289. if (extension.texCoord != undefined) {
  6290. babylonTexture.coordinatesIndex = extension.texCoord;
  6291. }
  6292. assign(babylonTexture);
  6293. });
  6294. });
  6295. };
  6296. return KHR_texture_transform;
  6297. }());
  6298. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_texture_transform(loader); });
  6299. /***/ }),
  6300. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_xmp_json_ld.js":
  6301. /*!************************************************************************!*\
  6302. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_xmp_json_ld.js ***!
  6303. \************************************************************************/
  6304. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6305. __webpack_require__.r(__webpack_exports__);
  6306. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6307. /* harmony export */ "KHR_xmp_json_ld": () => (/* binding */ KHR_xmp_json_ld)
  6308. /* harmony export */ });
  6309. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  6310. var NAME = "KHR_xmp_json_ld";
  6311. /**
  6312. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_xmp_json_ld)
  6313. * @since 5.0.0
  6314. */
  6315. var KHR_xmp_json_ld = /** @class */ (function () {
  6316. /**
  6317. * @param loader
  6318. * @hidden
  6319. */
  6320. function KHR_xmp_json_ld(loader) {
  6321. /**
  6322. * The name of this extension.
  6323. */
  6324. this.name = NAME;
  6325. /**
  6326. * Defines a number that determines the order the extensions are applied.
  6327. */
  6328. this.order = 100;
  6329. this._loader = loader;
  6330. this.enabled = this._loader.isExtensionUsed(NAME);
  6331. }
  6332. /** @hidden */
  6333. KHR_xmp_json_ld.prototype.dispose = function () {
  6334. this._loader = null;
  6335. };
  6336. /**
  6337. * Called after the loader state changes to LOADING.
  6338. */
  6339. KHR_xmp_json_ld.prototype.onLoading = function () {
  6340. var _a, _b, _c;
  6341. if (this._loader.rootBabylonMesh === null) {
  6342. return;
  6343. }
  6344. var xmp_gltf = (_a = this._loader.gltf.extensions) === null || _a === void 0 ? void 0 : _a.KHR_xmp_json_ld;
  6345. var xmp_node = (_c = (_b = this._loader.gltf.asset) === null || _b === void 0 ? void 0 : _b.extensions) === null || _c === void 0 ? void 0 : _c.KHR_xmp_json_ld;
  6346. if (xmp_gltf && xmp_node) {
  6347. var packet = +xmp_node.packet;
  6348. if (xmp_gltf.packets && packet < xmp_gltf.packets.length) {
  6349. this._loader.rootBabylonMesh.metadata = this._loader.rootBabylonMesh.metadata || {};
  6350. this._loader.rootBabylonMesh.metadata.xmp = xmp_gltf.packets[packet];
  6351. }
  6352. }
  6353. };
  6354. return KHR_xmp_json_ld;
  6355. }());
  6356. _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_xmp_json_ld(loader); });
  6357. /***/ }),
  6358. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/MSFT_audio_emitter.js":
  6359. /*!***************************************************************************!*\
  6360. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/MSFT_audio_emitter.js ***!
  6361. \***************************************************************************/
  6362. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6363. __webpack_require__.r(__webpack_exports__);
  6364. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6365. /* harmony export */ "MSFT_audio_emitter": () => (/* binding */ MSFT_audio_emitter)
  6366. /* harmony export */ });
  6367. /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Audio/weightedsound */ "core/Misc/observable");
  6368. /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  6369. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  6370. var NAME = "MSFT_audio_emitter";
  6371. /**
  6372. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  6373. */
  6374. var MSFT_audio_emitter = /** @class */ (function () {
  6375. /**
  6376. * @param loader
  6377. * @hidden
  6378. */
  6379. function MSFT_audio_emitter(loader) {
  6380. /**
  6381. * The name of this extension.
  6382. */
  6383. this.name = NAME;
  6384. this._loader = loader;
  6385. this.enabled = this._loader.isExtensionUsed(NAME);
  6386. }
  6387. /** @hidden */
  6388. MSFT_audio_emitter.prototype.dispose = function () {
  6389. this._loader = null;
  6390. this._clips = null;
  6391. this._emitters = null;
  6392. };
  6393. /** @hidden */
  6394. MSFT_audio_emitter.prototype.onLoading = function () {
  6395. var extensions = this._loader.gltf.extensions;
  6396. if (extensions && extensions[this.name]) {
  6397. var extension = extensions[this.name];
  6398. this._clips = extension.clips;
  6399. this._emitters = extension.emitters;
  6400. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Assign(this._clips);
  6401. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Assign(this._emitters);
  6402. }
  6403. };
  6404. /**
  6405. * @param context
  6406. * @param scene
  6407. * @hidden
  6408. */
  6409. MSFT_audio_emitter.prototype.loadSceneAsync = function (context, scene) {
  6410. var _this = this;
  6411. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, scene, this.name, function (extensionContext, extension) {
  6412. var promises = new Array();
  6413. promises.push(_this._loader.loadSceneAsync(context, scene));
  6414. for (var _i = 0, _a = extension.emitters; _i < _a.length; _i++) {
  6415. var emitterIndex = _a[_i];
  6416. var emitter = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(extensionContext, "/emitters"), _this._emitters, emitterIndex);
  6417. if (emitter.refDistance != undefined ||
  6418. emitter.maxDistance != undefined ||
  6419. emitter.rolloffFactor != undefined ||
  6420. emitter.distanceModel != undefined ||
  6421. emitter.innerAngle != undefined ||
  6422. emitter.outerAngle != undefined) {
  6423. throw new Error("".concat(extensionContext, ": Direction or Distance properties are not allowed on emitters attached to a scene"));
  6424. }
  6425. promises.push(_this._loadEmitterAsync("".concat(extensionContext, "/emitters/").concat(emitter.index), emitter));
  6426. }
  6427. return Promise.all(promises).then(function () { });
  6428. });
  6429. };
  6430. /**
  6431. * @param context
  6432. * @param node
  6433. * @param assign
  6434. * @hidden
  6435. */
  6436. MSFT_audio_emitter.prototype.loadNodeAsync = function (context, node, assign) {
  6437. var _this = this;
  6438. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) {
  6439. var promises = new Array();
  6440. return _this._loader
  6441. .loadNodeAsync(extensionContext, node, function (babylonMesh) {
  6442. var _loop_1 = function (emitterIndex) {
  6443. var emitter = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(extensionContext, "/emitters"), _this._emitters, emitterIndex);
  6444. promises.push(_this._loadEmitterAsync("".concat(extensionContext, "/emitters/").concat(emitter.index), emitter).then(function () {
  6445. for (var _i = 0, _a = emitter._babylonSounds; _i < _a.length; _i++) {
  6446. var sound = _a[_i];
  6447. sound.attachToMesh(babylonMesh);
  6448. if (emitter.innerAngle != undefined || emitter.outerAngle != undefined) {
  6449. sound.setLocalDirectionToMesh(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Forward());
  6450. sound.setDirectionalCone(2 * core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.ToDegrees(emitter.innerAngle == undefined ? Math.PI : emitter.innerAngle), 2 * core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.ToDegrees(emitter.outerAngle == undefined ? Math.PI : emitter.outerAngle), 0);
  6451. }
  6452. }
  6453. }));
  6454. };
  6455. for (var _i = 0, _a = extension.emitters; _i < _a.length; _i++) {
  6456. var emitterIndex = _a[_i];
  6457. _loop_1(emitterIndex);
  6458. }
  6459. assign(babylonMesh);
  6460. })
  6461. .then(function (babylonMesh) {
  6462. return Promise.all(promises).then(function () {
  6463. return babylonMesh;
  6464. });
  6465. });
  6466. });
  6467. };
  6468. /**
  6469. * @param context
  6470. * @param animation
  6471. * @hidden
  6472. */
  6473. MSFT_audio_emitter.prototype.loadAnimationAsync = function (context, animation) {
  6474. var _this = this;
  6475. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, animation, this.name, function (extensionContext, extension) {
  6476. return _this._loader.loadAnimationAsync(context, animation).then(function (babylonAnimationGroup) {
  6477. var promises = new Array();
  6478. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Assign(extension.events);
  6479. for (var _i = 0, _a = extension.events; _i < _a.length; _i++) {
  6480. var event_1 = _a[_i];
  6481. promises.push(_this._loadAnimationEventAsync("".concat(extensionContext, "/events/").concat(event_1.index), context, animation, event_1, babylonAnimationGroup));
  6482. }
  6483. return Promise.all(promises).then(function () {
  6484. return babylonAnimationGroup;
  6485. });
  6486. });
  6487. });
  6488. };
  6489. MSFT_audio_emitter.prototype._loadClipAsync = function (context, clip) {
  6490. if (clip._objectURL) {
  6491. return clip._objectURL;
  6492. }
  6493. var promise;
  6494. if (clip.uri) {
  6495. promise = this._loader.loadUriAsync(context, clip, clip.uri);
  6496. }
  6497. else {
  6498. var bufferView = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(context, "/bufferView"), this._loader.gltf.bufferViews, clip.bufferView);
  6499. promise = this._loader.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView);
  6500. }
  6501. clip._objectURL = promise.then(function (data) {
  6502. return URL.createObjectURL(new Blob([data], { type: clip.mimeType }));
  6503. });
  6504. return clip._objectURL;
  6505. };
  6506. MSFT_audio_emitter.prototype._loadEmitterAsync = function (context, emitter) {
  6507. var _this = this;
  6508. emitter._babylonSounds = emitter._babylonSounds || [];
  6509. if (!emitter._babylonData) {
  6510. var clipPromises = new Array();
  6511. var name_1 = emitter.name || "emitter".concat(emitter.index);
  6512. var options_1 = {
  6513. loop: false,
  6514. autoplay: false,
  6515. volume: emitter.volume == undefined ? 1 : emitter.volume,
  6516. };
  6517. var _loop_2 = function (i) {
  6518. var clipContext = "/extensions/".concat(this_1.name, "/clips");
  6519. var clip = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get(clipContext, this_1._clips, emitter.clips[i].clip);
  6520. clipPromises.push(this_1._loadClipAsync("".concat(clipContext, "/").concat(emitter.clips[i].clip), clip).then(function (objectURL) {
  6521. var sound = (emitter._babylonSounds[i] = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Sound(name_1, objectURL, _this._loader.babylonScene, null, options_1));
  6522. sound.refDistance = emitter.refDistance || 1;
  6523. sound.maxDistance = emitter.maxDistance || 256;
  6524. sound.rolloffFactor = emitter.rolloffFactor || 1;
  6525. sound.distanceModel = emitter.distanceModel || "exponential";
  6526. }));
  6527. };
  6528. var this_1 = this;
  6529. for (var i = 0; i < emitter.clips.length; i++) {
  6530. _loop_2(i);
  6531. }
  6532. var promise = Promise.all(clipPromises).then(function () {
  6533. var weights = emitter.clips.map(function (clip) {
  6534. return clip.weight || 1;
  6535. });
  6536. var weightedSound = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.WeightedSound(emitter.loop || false, emitter._babylonSounds, weights);
  6537. if (emitter.innerAngle) {
  6538. weightedSound.directionalConeInnerAngle = 2 * core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.ToDegrees(emitter.innerAngle);
  6539. }
  6540. if (emitter.outerAngle) {
  6541. weightedSound.directionalConeOuterAngle = 2 * core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.ToDegrees(emitter.outerAngle);
  6542. }
  6543. if (emitter.volume) {
  6544. weightedSound.volume = emitter.volume;
  6545. }
  6546. emitter._babylonData.sound = weightedSound;
  6547. });
  6548. emitter._babylonData = {
  6549. loaded: promise,
  6550. };
  6551. }
  6552. return emitter._babylonData.loaded;
  6553. };
  6554. MSFT_audio_emitter.prototype._getEventAction = function (context, sound, action, time, startOffset) {
  6555. switch (action) {
  6556. case "play" /* play */: {
  6557. return function (currentFrame) {
  6558. var frameOffset = (startOffset || 0) + (currentFrame - time);
  6559. sound.play(frameOffset);
  6560. };
  6561. }
  6562. case "stop" /* stop */: {
  6563. return function (currentFrame) {
  6564. sound.stop();
  6565. };
  6566. }
  6567. case "pause" /* pause */: {
  6568. return function (currentFrame) {
  6569. sound.pause();
  6570. };
  6571. }
  6572. default: {
  6573. throw new Error("".concat(context, ": Unsupported action ").concat(action));
  6574. }
  6575. }
  6576. };
  6577. MSFT_audio_emitter.prototype._loadAnimationEventAsync = function (context, animationContext, animation, event, babylonAnimationGroup) {
  6578. var _this = this;
  6579. if (babylonAnimationGroup.targetedAnimations.length == 0) {
  6580. return Promise.resolve();
  6581. }
  6582. var babylonAnimation = babylonAnimationGroup.targetedAnimations[0];
  6583. var emitterIndex = event.emitter;
  6584. var emitter = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("/extensions/".concat(this.name, "/emitters"), this._emitters, emitterIndex);
  6585. return this._loadEmitterAsync(context, emitter).then(function () {
  6586. var sound = emitter._babylonData.sound;
  6587. if (sound) {
  6588. var babylonAnimationEvent = new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.AnimationEvent(event.time, _this._getEventAction(context, sound, event.action, event.time, event.startOffset));
  6589. babylonAnimation.animation.addEvent(babylonAnimationEvent);
  6590. // Make sure all started audio stops when this animation is terminated.
  6591. babylonAnimationGroup.onAnimationGroupEndObservable.add(function () {
  6592. sound.stop();
  6593. });
  6594. babylonAnimationGroup.onAnimationGroupPauseObservable.add(function () {
  6595. sound.pause();
  6596. });
  6597. }
  6598. });
  6599. };
  6600. return MSFT_audio_emitter;
  6601. }());
  6602. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_audio_emitter(loader); });
  6603. /***/ }),
  6604. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/MSFT_lod.js":
  6605. /*!*****************************************************************!*\
  6606. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/MSFT_lod.js ***!
  6607. \*****************************************************************/
  6608. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6609. __webpack_require__.r(__webpack_exports__);
  6610. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6611. /* harmony export */ "MSFT_lod": () => (/* binding */ MSFT_lod)
  6612. /* harmony export */ });
  6613. /* harmony import */ var core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Misc/deferred */ "core/Misc/observable");
  6614. /* harmony import */ var core_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  6615. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  6616. var NAME = "MSFT_lod";
  6617. /**
  6618. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  6619. */
  6620. var MSFT_lod = /** @class */ (function () {
  6621. /**
  6622. * @param loader
  6623. * @hidden
  6624. */
  6625. function MSFT_lod(loader) {
  6626. /**
  6627. * The name of this extension.
  6628. */
  6629. this.name = NAME;
  6630. /**
  6631. * Defines a number that determines the order the extensions are applied.
  6632. */
  6633. this.order = 100;
  6634. /**
  6635. * Maximum number of LODs to load, starting from the lowest LOD.
  6636. */
  6637. this.maxLODsToLoad = 10;
  6638. /**
  6639. * Observable raised when all node LODs of one level are loaded.
  6640. * The event data is the index of the loaded LOD starting from zero.
  6641. * Dispose the loader to cancel the loading of the next level of LODs.
  6642. */
  6643. this.onNodeLODsLoadedObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
  6644. /**
  6645. * Observable raised when all material LODs of one level are loaded.
  6646. * The event data is the index of the loaded LOD starting from zero.
  6647. * Dispose the loader to cancel the loading of the next level of LODs.
  6648. */
  6649. this.onMaterialLODsLoadedObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
  6650. this._bufferLODs = new Array();
  6651. this._nodeIndexLOD = null;
  6652. this._nodeSignalLODs = new Array();
  6653. this._nodePromiseLODs = new Array();
  6654. this._nodeBufferLODs = new Array();
  6655. this._materialIndexLOD = null;
  6656. this._materialSignalLODs = new Array();
  6657. this._materialPromiseLODs = new Array();
  6658. this._materialBufferLODs = new Array();
  6659. this._loader = loader;
  6660. this.enabled = this._loader.isExtensionUsed(NAME);
  6661. }
  6662. /** @hidden */
  6663. MSFT_lod.prototype.dispose = function () {
  6664. this._loader = null;
  6665. this._nodeIndexLOD = null;
  6666. this._nodeSignalLODs.length = 0;
  6667. this._nodePromiseLODs.length = 0;
  6668. this._nodeBufferLODs.length = 0;
  6669. this._materialIndexLOD = null;
  6670. this._materialSignalLODs.length = 0;
  6671. this._materialPromiseLODs.length = 0;
  6672. this._materialBufferLODs.length = 0;
  6673. this.onMaterialLODsLoadedObservable.clear();
  6674. this.onNodeLODsLoadedObservable.clear();
  6675. };
  6676. /** @hidden */
  6677. MSFT_lod.prototype.onReady = function () {
  6678. var _this = this;
  6679. var _loop_1 = function (indexLOD) {
  6680. var promise = Promise.all(this_1._nodePromiseLODs[indexLOD]).then(function () {
  6681. if (indexLOD !== 0) {
  6682. _this._loader.endPerformanceCounter("Node LOD ".concat(indexLOD));
  6683. _this._loader.log("Loaded node LOD ".concat(indexLOD));
  6684. }
  6685. _this.onNodeLODsLoadedObservable.notifyObservers(indexLOD);
  6686. if (indexLOD !== _this._nodePromiseLODs.length - 1) {
  6687. _this._loader.startPerformanceCounter("Node LOD ".concat(indexLOD + 1));
  6688. _this._loadBufferLOD(_this._nodeBufferLODs, indexLOD + 1);
  6689. if (_this._nodeSignalLODs[indexLOD]) {
  6690. _this._nodeSignalLODs[indexLOD].resolve();
  6691. }
  6692. }
  6693. });
  6694. this_1._loader._completePromises.push(promise);
  6695. };
  6696. var this_1 = this;
  6697. for (var indexLOD = 0; indexLOD < this._nodePromiseLODs.length; indexLOD++) {
  6698. _loop_1(indexLOD);
  6699. }
  6700. var _loop_2 = function (indexLOD) {
  6701. var promise = Promise.all(this_2._materialPromiseLODs[indexLOD]).then(function () {
  6702. if (indexLOD !== 0) {
  6703. _this._loader.endPerformanceCounter("Material LOD ".concat(indexLOD));
  6704. _this._loader.log("Loaded material LOD ".concat(indexLOD));
  6705. }
  6706. _this.onMaterialLODsLoadedObservable.notifyObservers(indexLOD);
  6707. if (indexLOD !== _this._materialPromiseLODs.length - 1) {
  6708. _this._loader.startPerformanceCounter("Material LOD ".concat(indexLOD + 1));
  6709. _this._loadBufferLOD(_this._materialBufferLODs, indexLOD + 1);
  6710. if (_this._materialSignalLODs[indexLOD]) {
  6711. _this._materialSignalLODs[indexLOD].resolve();
  6712. }
  6713. }
  6714. });
  6715. this_2._loader._completePromises.push(promise);
  6716. };
  6717. var this_2 = this;
  6718. for (var indexLOD = 0; indexLOD < this._materialPromiseLODs.length; indexLOD++) {
  6719. _loop_2(indexLOD);
  6720. }
  6721. };
  6722. /**
  6723. * @param context
  6724. * @param scene
  6725. * @hidden
  6726. */
  6727. MSFT_lod.prototype.loadSceneAsync = function (context, scene) {
  6728. var promise = this._loader.loadSceneAsync(context, scene);
  6729. this._loadBufferLOD(this._bufferLODs, 0);
  6730. return promise;
  6731. };
  6732. /**
  6733. * @param context
  6734. * @param node
  6735. * @param assign
  6736. * @hidden
  6737. */
  6738. MSFT_lod.prototype.loadNodeAsync = function (context, node, assign) {
  6739. var _this = this;
  6740. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) {
  6741. var firstPromise;
  6742. var nodeLODs = _this._getLODs(extensionContext, node, _this._loader.gltf.nodes, extension.ids);
  6743. _this._loader.logOpen("".concat(extensionContext));
  6744. var _loop_3 = function (indexLOD) {
  6745. var nodeLOD = nodeLODs[indexLOD];
  6746. if (indexLOD !== 0) {
  6747. _this._nodeIndexLOD = indexLOD;
  6748. _this._nodeSignalLODs[indexLOD] = _this._nodeSignalLODs[indexLOD] || new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Deferred();
  6749. }
  6750. var assignWrap = function (babylonTransformNode) {
  6751. assign(babylonTransformNode);
  6752. babylonTransformNode.setEnabled(false);
  6753. };
  6754. var promise = _this._loader.loadNodeAsync("/nodes/".concat(nodeLOD.index), nodeLOD, assignWrap).then(function (babylonMesh) {
  6755. if (indexLOD !== 0) {
  6756. // TODO: should not rely on _babylonTransformNode
  6757. var previousNodeLOD = nodeLODs[indexLOD - 1];
  6758. if (previousNodeLOD._babylonTransformNode) {
  6759. _this._disposeTransformNode(previousNodeLOD._babylonTransformNode);
  6760. delete previousNodeLOD._babylonTransformNode;
  6761. }
  6762. }
  6763. babylonMesh.setEnabled(true);
  6764. return babylonMesh;
  6765. });
  6766. _this._nodePromiseLODs[indexLOD] = _this._nodePromiseLODs[indexLOD] || [];
  6767. if (indexLOD === 0) {
  6768. firstPromise = promise;
  6769. }
  6770. else {
  6771. _this._nodeIndexLOD = null;
  6772. _this._nodePromiseLODs[indexLOD].push(promise);
  6773. }
  6774. };
  6775. for (var indexLOD = 0; indexLOD < nodeLODs.length; indexLOD++) {
  6776. _loop_3(indexLOD);
  6777. }
  6778. _this._loader.logClose();
  6779. return firstPromise;
  6780. });
  6781. };
  6782. /**
  6783. * @param context
  6784. * @param material
  6785. * @param babylonMesh
  6786. * @param babylonDrawMode
  6787. * @param assign
  6788. * @hidden
  6789. */
  6790. MSFT_lod.prototype._loadMaterialAsync = function (context, material, babylonMesh, babylonDrawMode, assign) {
  6791. var _this = this;
  6792. // Don't load material LODs if already loading a node LOD.
  6793. if (this._nodeIndexLOD) {
  6794. return null;
  6795. }
  6796. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
  6797. var firstPromise;
  6798. var materialLODs = _this._getLODs(extensionContext, material, _this._loader.gltf.materials, extension.ids);
  6799. _this._loader.logOpen("".concat(extensionContext));
  6800. var _loop_4 = function (indexLOD) {
  6801. var materialLOD = materialLODs[indexLOD];
  6802. if (indexLOD !== 0) {
  6803. _this._materialIndexLOD = indexLOD;
  6804. }
  6805. var promise = _this._loader
  6806. ._loadMaterialAsync("/materials/".concat(materialLOD.index), materialLOD, babylonMesh, babylonDrawMode, function (babylonMaterial) {
  6807. if (indexLOD === 0) {
  6808. assign(babylonMaterial);
  6809. }
  6810. })
  6811. .then(function (babylonMaterial) {
  6812. if (indexLOD !== 0) {
  6813. assign(babylonMaterial);
  6814. // TODO: should not rely on _data
  6815. var previousDataLOD = materialLODs[indexLOD - 1]._data;
  6816. if (previousDataLOD[babylonDrawMode]) {
  6817. _this._disposeMaterials([previousDataLOD[babylonDrawMode].babylonMaterial]);
  6818. delete previousDataLOD[babylonDrawMode];
  6819. }
  6820. }
  6821. return babylonMaterial;
  6822. });
  6823. _this._materialPromiseLODs[indexLOD] = _this._materialPromiseLODs[indexLOD] || [];
  6824. if (indexLOD === 0) {
  6825. firstPromise = promise;
  6826. }
  6827. else {
  6828. _this._materialIndexLOD = null;
  6829. _this._materialPromiseLODs[indexLOD].push(promise);
  6830. }
  6831. };
  6832. for (var indexLOD = 0; indexLOD < materialLODs.length; indexLOD++) {
  6833. _loop_4(indexLOD);
  6834. }
  6835. _this._loader.logClose();
  6836. return firstPromise;
  6837. });
  6838. };
  6839. /**
  6840. * @param context
  6841. * @param property
  6842. * @param uri
  6843. * @hidden
  6844. */
  6845. MSFT_lod.prototype._loadUriAsync = function (context, property, uri) {
  6846. var _this = this;
  6847. // Defer the loading of uris if loading a node or material LOD.
  6848. if (this._nodeIndexLOD !== null) {
  6849. this._loader.log("deferred");
  6850. var previousIndexLOD = this._nodeIndexLOD - 1;
  6851. this._nodeSignalLODs[previousIndexLOD] = this._nodeSignalLODs[previousIndexLOD] || new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Deferred();
  6852. return this._nodeSignalLODs[this._nodeIndexLOD - 1].promise.then(function () {
  6853. return _this._loader.loadUriAsync(context, property, uri);
  6854. });
  6855. }
  6856. else if (this._materialIndexLOD !== null) {
  6857. this._loader.log("deferred");
  6858. var previousIndexLOD = this._materialIndexLOD - 1;
  6859. this._materialSignalLODs[previousIndexLOD] = this._materialSignalLODs[previousIndexLOD] || new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Deferred();
  6860. return this._materialSignalLODs[previousIndexLOD].promise.then(function () {
  6861. return _this._loader.loadUriAsync(context, property, uri);
  6862. });
  6863. }
  6864. return null;
  6865. };
  6866. /**
  6867. * @param context
  6868. * @param buffer
  6869. * @param byteOffset
  6870. * @param byteLength
  6871. * @hidden
  6872. */
  6873. MSFT_lod.prototype.loadBufferAsync = function (context, buffer, byteOffset, byteLength) {
  6874. if (this._loader.parent.useRangeRequests && !buffer.uri) {
  6875. if (!this._loader.bin) {
  6876. throw new Error("".concat(context, ": Uri is missing or the binary glTF is missing its binary chunk"));
  6877. }
  6878. var loadAsync = function (bufferLODs, indexLOD) {
  6879. var start = byteOffset;
  6880. var end = start + byteLength - 1;
  6881. var bufferLOD = bufferLODs[indexLOD];
  6882. if (bufferLOD) {
  6883. bufferLOD.start = Math.min(bufferLOD.start, start);
  6884. bufferLOD.end = Math.max(bufferLOD.end, end);
  6885. }
  6886. else {
  6887. bufferLOD = { start: start, end: end, loaded: new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Deferred() };
  6888. bufferLODs[indexLOD] = bufferLOD;
  6889. }
  6890. return bufferLOD.loaded.promise.then(function (data) {
  6891. return new Uint8Array(data.buffer, data.byteOffset + byteOffset - bufferLOD.start, byteLength);
  6892. });
  6893. };
  6894. this._loader.log("deferred");
  6895. if (this._nodeIndexLOD !== null) {
  6896. return loadAsync(this._nodeBufferLODs, this._nodeIndexLOD);
  6897. }
  6898. else if (this._materialIndexLOD !== null) {
  6899. return loadAsync(this._materialBufferLODs, this._materialIndexLOD);
  6900. }
  6901. else {
  6902. return loadAsync(this._bufferLODs, 0);
  6903. }
  6904. }
  6905. return null;
  6906. };
  6907. MSFT_lod.prototype._loadBufferLOD = function (bufferLODs, indexLOD) {
  6908. var bufferLOD = bufferLODs[indexLOD];
  6909. if (bufferLOD) {
  6910. this._loader.log("Loading buffer range [".concat(bufferLOD.start, "-").concat(bufferLOD.end, "]"));
  6911. this._loader.bin.readAsync(bufferLOD.start, bufferLOD.end - bufferLOD.start + 1).then(function (data) {
  6912. bufferLOD.loaded.resolve(data);
  6913. }, function (error) {
  6914. bufferLOD.loaded.reject(error);
  6915. });
  6916. }
  6917. };
  6918. /**
  6919. * Gets an array of LOD properties from lowest to highest.
  6920. * @param context
  6921. * @param property
  6922. * @param array
  6923. * @param ids
  6924. */
  6925. MSFT_lod.prototype._getLODs = function (context, property, array, ids) {
  6926. if (this.maxLODsToLoad <= 0) {
  6927. throw new Error("maxLODsToLoad must be greater than zero");
  6928. }
  6929. var properties = new Array();
  6930. for (var i = ids.length - 1; i >= 0; i--) {
  6931. properties.push(_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(context, "/ids/").concat(ids[i]), array, ids[i]));
  6932. if (properties.length === this.maxLODsToLoad) {
  6933. return properties;
  6934. }
  6935. }
  6936. properties.push(property);
  6937. return properties;
  6938. };
  6939. MSFT_lod.prototype._disposeTransformNode = function (babylonTransformNode) {
  6940. var _this = this;
  6941. var babylonMaterials = new Array();
  6942. var babylonMaterial = babylonTransformNode.material;
  6943. if (babylonMaterial) {
  6944. babylonMaterials.push(babylonMaterial);
  6945. }
  6946. for (var _i = 0, _a = babylonTransformNode.getChildMeshes(); _i < _a.length; _i++) {
  6947. var babylonMesh = _a[_i];
  6948. if (babylonMesh.material) {
  6949. babylonMaterials.push(babylonMesh.material);
  6950. }
  6951. }
  6952. babylonTransformNode.dispose();
  6953. var babylonMaterialsToDispose = babylonMaterials.filter(function (babylonMaterial) { return _this._loader.babylonScene.meshes.every(function (mesh) { return mesh.material != babylonMaterial; }); });
  6954. this._disposeMaterials(babylonMaterialsToDispose);
  6955. };
  6956. MSFT_lod.prototype._disposeMaterials = function (babylonMaterials) {
  6957. var babylonTextures = {};
  6958. for (var _i = 0, babylonMaterials_1 = babylonMaterials; _i < babylonMaterials_1.length; _i++) {
  6959. var babylonMaterial = babylonMaterials_1[_i];
  6960. for (var _a = 0, _b = babylonMaterial.getActiveTextures(); _a < _b.length; _a++) {
  6961. var babylonTexture = _b[_a];
  6962. babylonTextures[babylonTexture.uniqueId] = babylonTexture;
  6963. }
  6964. babylonMaterial.dispose();
  6965. }
  6966. for (var uniqueId in babylonTextures) {
  6967. for (var _c = 0, _d = this._loader.babylonScene.materials; _c < _d.length; _c++) {
  6968. var babylonMaterial = _d[_c];
  6969. if (babylonMaterial.hasTexture(babylonTextures[uniqueId])) {
  6970. delete babylonTextures[uniqueId];
  6971. }
  6972. }
  6973. }
  6974. for (var uniqueId in babylonTextures) {
  6975. babylonTextures[uniqueId].dispose();
  6976. }
  6977. };
  6978. return MSFT_lod;
  6979. }());
  6980. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_lod(loader); });
  6981. /***/ }),
  6982. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/MSFT_minecraftMesh.js":
  6983. /*!***************************************************************************!*\
  6984. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/MSFT_minecraftMesh.js ***!
  6985. \***************************************************************************/
  6986. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  6987. __webpack_require__.r(__webpack_exports__);
  6988. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  6989. /* harmony export */ "MSFT_minecraftMesh": () => (/* binding */ MSFT_minecraftMesh)
  6990. /* harmony export */ });
  6991. /* harmony import */ var core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Materials/PBR/pbrMaterial */ "core/Misc/observable");
  6992. /* harmony import */ var core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__);
  6993. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  6994. var NAME = "MSFT_minecraftMesh";
  6995. /** @hidden */
  6996. var MSFT_minecraftMesh = /** @class */ (function () {
  6997. function MSFT_minecraftMesh(loader) {
  6998. this.name = NAME;
  6999. this._loader = loader;
  7000. this.enabled = this._loader.isExtensionUsed(NAME);
  7001. }
  7002. MSFT_minecraftMesh.prototype.dispose = function () {
  7003. this._loader = null;
  7004. };
  7005. MSFT_minecraftMesh.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
  7006. var _this = this;
  7007. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtraAsync(context, material, this.name, function (extraContext, extra) {
  7008. if (extra) {
  7009. if (!(babylonMaterial instanceof core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) {
  7010. throw new Error("".concat(extraContext, ": Material type not supported"));
  7011. }
  7012. var promise = _this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial);
  7013. if (babylonMaterial.needAlphaBlending()) {
  7014. babylonMaterial.forceDepthWrite = true;
  7015. babylonMaterial.separateCullingPass = true;
  7016. }
  7017. babylonMaterial.backFaceCulling = babylonMaterial.forceDepthWrite;
  7018. babylonMaterial.twoSidedLighting = true;
  7019. return promise;
  7020. }
  7021. return null;
  7022. });
  7023. };
  7024. return MSFT_minecraftMesh;
  7025. }());
  7026. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_minecraftMesh(loader); });
  7027. /***/ }),
  7028. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/MSFT_sRGBFactors.js":
  7029. /*!*************************************************************************!*\
  7030. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/MSFT_sRGBFactors.js ***!
  7031. \*************************************************************************/
  7032. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  7033. __webpack_require__.r(__webpack_exports__);
  7034. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  7035. /* harmony export */ "MSFT_sRGBFactors": () => (/* binding */ MSFT_sRGBFactors)
  7036. /* harmony export */ });
  7037. /* harmony import */ var core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Materials/PBR/pbrMaterial */ "core/Misc/observable");
  7038. /* harmony import */ var core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__);
  7039. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  7040. var NAME = "MSFT_sRGBFactors";
  7041. /** @hidden */
  7042. var MSFT_sRGBFactors = /** @class */ (function () {
  7043. function MSFT_sRGBFactors(loader) {
  7044. this.name = NAME;
  7045. this._loader = loader;
  7046. this.enabled = this._loader.isExtensionUsed(NAME);
  7047. }
  7048. MSFT_sRGBFactors.prototype.dispose = function () {
  7049. this._loader = null;
  7050. };
  7051. MSFT_sRGBFactors.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
  7052. var _this = this;
  7053. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtraAsync(context, material, this.name, function (extraContext, extra) {
  7054. if (extra) {
  7055. if (!(babylonMaterial instanceof core_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) {
  7056. throw new Error("".concat(extraContext, ": Material type not supported"));
  7057. }
  7058. var promise = _this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial);
  7059. if (!babylonMaterial.albedoTexture) {
  7060. babylonMaterial.albedoColor.toLinearSpaceToRef(babylonMaterial.albedoColor);
  7061. }
  7062. if (!babylonMaterial.reflectivityTexture) {
  7063. babylonMaterial.reflectivityColor.toLinearSpaceToRef(babylonMaterial.reflectivityColor);
  7064. }
  7065. return promise;
  7066. }
  7067. return null;
  7068. });
  7069. };
  7070. return MSFT_sRGBFactors;
  7071. }());
  7072. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_sRGBFactors(loader); });
  7073. /***/ }),
  7074. /***/ "../../../lts/loaders/dist/glTF/2.0/Extensions/index.js":
  7075. /*!**************************************************************!*\
  7076. !*** ../../../lts/loaders/dist/glTF/2.0/Extensions/index.js ***!
  7077. \**************************************************************/
  7078. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  7079. __webpack_require__.r(__webpack_exports__);
  7080. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  7081. /* harmony export */ "EXT_lights_image_based": () => (/* reexport safe */ _EXT_lights_image_based__WEBPACK_IMPORTED_MODULE_0__.EXT_lights_image_based),
  7082. /* harmony export */ "EXT_mesh_gpu_instancing": () => (/* reexport safe */ _EXT_mesh_gpu_instancing__WEBPACK_IMPORTED_MODULE_1__.EXT_mesh_gpu_instancing),
  7083. /* harmony export */ "EXT_meshopt_compression": () => (/* reexport safe */ _EXT_meshopt_compression__WEBPACK_IMPORTED_MODULE_2__.EXT_meshopt_compression),
  7084. /* harmony export */ "EXT_texture_webp": () => (/* reexport safe */ _EXT_texture_webp__WEBPACK_IMPORTED_MODULE_3__.EXT_texture_webp),
  7085. /* harmony export */ "ExtrasAsMetadata": () => (/* reexport safe */ _ExtrasAsMetadata__WEBPACK_IMPORTED_MODULE_25__.ExtrasAsMetadata),
  7086. /* harmony export */ "KHR_draco_mesh_compression": () => (/* reexport safe */ _KHR_draco_mesh_compression__WEBPACK_IMPORTED_MODULE_4__.KHR_draco_mesh_compression),
  7087. /* harmony export */ "KHR_lights": () => (/* reexport safe */ _KHR_lights_punctual__WEBPACK_IMPORTED_MODULE_5__.KHR_lights),
  7088. /* harmony export */ "KHR_materials_clearcoat": () => (/* reexport safe */ _KHR_materials_clearcoat__WEBPACK_IMPORTED_MODULE_8__.KHR_materials_clearcoat),
  7089. /* harmony export */ "KHR_materials_emissive_strength": () => (/* reexport safe */ _KHR_materials_emissive_strength__WEBPACK_IMPORTED_MODULE_9__.KHR_materials_emissive_strength),
  7090. /* harmony export */ "KHR_materials_ior": () => (/* reexport safe */ _KHR_materials_ior__WEBPACK_IMPORTED_MODULE_12__.KHR_materials_ior),
  7091. /* harmony export */ "KHR_materials_pbrSpecularGlossiness": () => (/* reexport safe */ _KHR_materials_pbrSpecularGlossiness__WEBPACK_IMPORTED_MODULE_6__.KHR_materials_pbrSpecularGlossiness),
  7092. /* harmony export */ "KHR_materials_sheen": () => (/* reexport safe */ _KHR_materials_sheen__WEBPACK_IMPORTED_MODULE_10__.KHR_materials_sheen),
  7093. /* harmony export */ "KHR_materials_specular": () => (/* reexport safe */ _KHR_materials_specular__WEBPACK_IMPORTED_MODULE_11__.KHR_materials_specular),
  7094. /* harmony export */ "KHR_materials_translucency": () => (/* reexport safe */ _KHR_materials_translucency__WEBPACK_IMPORTED_MODULE_15__.KHR_materials_translucency),
  7095. /* harmony export */ "KHR_materials_transmission": () => (/* reexport safe */ _KHR_materials_transmission__WEBPACK_IMPORTED_MODULE_14__.KHR_materials_transmission),
  7096. /* harmony export */ "KHR_materials_unlit": () => (/* reexport safe */ _KHR_materials_unlit__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_unlit),
  7097. /* harmony export */ "KHR_materials_variants": () => (/* reexport safe */ _KHR_materials_variants__WEBPACK_IMPORTED_MODULE_13__.KHR_materials_variants),
  7098. /* harmony export */ "KHR_materials_volume": () => (/* reexport safe */ _KHR_materials_volume__WEBPACK_IMPORTED_MODULE_16__.KHR_materials_volume),
  7099. /* harmony export */ "KHR_mesh_quantization": () => (/* reexport safe */ _KHR_mesh_quantization__WEBPACK_IMPORTED_MODULE_17__.KHR_mesh_quantization),
  7100. /* harmony export */ "KHR_texture_basisu": () => (/* reexport safe */ _KHR_texture_basisu__WEBPACK_IMPORTED_MODULE_18__.KHR_texture_basisu),
  7101. /* harmony export */ "KHR_texture_transform": () => (/* reexport safe */ _KHR_texture_transform__WEBPACK_IMPORTED_MODULE_19__.KHR_texture_transform),
  7102. /* harmony export */ "KHR_xmp_json_ld": () => (/* reexport safe */ _KHR_xmp_json_ld__WEBPACK_IMPORTED_MODULE_20__.KHR_xmp_json_ld),
  7103. /* harmony export */ "MSFT_audio_emitter": () => (/* reexport safe */ _MSFT_audio_emitter__WEBPACK_IMPORTED_MODULE_21__.MSFT_audio_emitter),
  7104. /* harmony export */ "MSFT_lod": () => (/* reexport safe */ _MSFT_lod__WEBPACK_IMPORTED_MODULE_22__.MSFT_lod),
  7105. /* harmony export */ "MSFT_minecraftMesh": () => (/* reexport safe */ _MSFT_minecraftMesh__WEBPACK_IMPORTED_MODULE_23__.MSFT_minecraftMesh),
  7106. /* harmony export */ "MSFT_sRGBFactors": () => (/* reexport safe */ _MSFT_sRGBFactors__WEBPACK_IMPORTED_MODULE_24__.MSFT_sRGBFactors)
  7107. /* harmony export */ });
  7108. /* harmony import */ var _EXT_lights_image_based__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./EXT_lights_image_based */ "../../../lts/loaders/dist/glTF/2.0/Extensions/EXT_lights_image_based.js");
  7109. /* harmony import */ var _EXT_mesh_gpu_instancing__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EXT_mesh_gpu_instancing */ "../../../lts/loaders/dist/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js");
  7110. /* harmony import */ var _EXT_meshopt_compression__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./EXT_meshopt_compression */ "../../../lts/loaders/dist/glTF/2.0/Extensions/EXT_meshopt_compression.js");
  7111. /* harmony import */ var _EXT_texture_webp__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./EXT_texture_webp */ "../../../lts/loaders/dist/glTF/2.0/Extensions/EXT_texture_webp.js");
  7112. /* harmony import */ var _KHR_draco_mesh_compression__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./KHR_draco_mesh_compression */ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_draco_mesh_compression.js");
  7113. /* harmony import */ var _KHR_lights_punctual__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./KHR_lights_punctual */ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_lights_punctual.js");
  7114. /* harmony import */ var _KHR_materials_pbrSpecularGlossiness__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./KHR_materials_pbrSpecularGlossiness */ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js");
  7115. /* harmony import */ var _KHR_materials_unlit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./KHR_materials_unlit */ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_unlit.js");
  7116. /* harmony import */ var _KHR_materials_clearcoat__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./KHR_materials_clearcoat */ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_clearcoat.js");
  7117. /* harmony import */ var _KHR_materials_emissive_strength__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./KHR_materials_emissive_strength */ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_emissive_strength.js");
  7118. /* harmony import */ var _KHR_materials_sheen__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./KHR_materials_sheen */ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_sheen.js");
  7119. /* harmony import */ var _KHR_materials_specular__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./KHR_materials_specular */ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_specular.js");
  7120. /* harmony import */ var _KHR_materials_ior__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./KHR_materials_ior */ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_ior.js");
  7121. /* harmony import */ var _KHR_materials_variants__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./KHR_materials_variants */ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_variants.js");
  7122. /* harmony import */ var _KHR_materials_transmission__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./KHR_materials_transmission */ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_transmission.js");
  7123. /* harmony import */ var _KHR_materials_translucency__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./KHR_materials_translucency */ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_translucency.js");
  7124. /* harmony import */ var _KHR_materials_volume__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./KHR_materials_volume */ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_materials_volume.js");
  7125. /* harmony import */ var _KHR_mesh_quantization__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./KHR_mesh_quantization */ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_mesh_quantization.js");
  7126. /* harmony import */ var _KHR_texture_basisu__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./KHR_texture_basisu */ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_texture_basisu.js");
  7127. /* harmony import */ var _KHR_texture_transform__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./KHR_texture_transform */ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_texture_transform.js");
  7128. /* harmony import */ var _KHR_xmp_json_ld__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./KHR_xmp_json_ld */ "../../../lts/loaders/dist/glTF/2.0/Extensions/KHR_xmp_json_ld.js");
  7129. /* harmony import */ var _MSFT_audio_emitter__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./MSFT_audio_emitter */ "../../../lts/loaders/dist/glTF/2.0/Extensions/MSFT_audio_emitter.js");
  7130. /* harmony import */ var _MSFT_lod__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./MSFT_lod */ "../../../lts/loaders/dist/glTF/2.0/Extensions/MSFT_lod.js");
  7131. /* harmony import */ var _MSFT_minecraftMesh__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./MSFT_minecraftMesh */ "../../../lts/loaders/dist/glTF/2.0/Extensions/MSFT_minecraftMesh.js");
  7132. /* harmony import */ var _MSFT_sRGBFactors__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./MSFT_sRGBFactors */ "../../../lts/loaders/dist/glTF/2.0/Extensions/MSFT_sRGBFactors.js");
  7133. /* harmony import */ var _ExtrasAsMetadata__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./ExtrasAsMetadata */ "../../../lts/loaders/dist/glTF/2.0/Extensions/ExtrasAsMetadata.js");
  7134. /***/ }),
  7135. /***/ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js":
  7136. /*!********************************************************!*\
  7137. !*** ../../../lts/loaders/dist/glTF/2.0/glTFLoader.js ***!
  7138. \********************************************************/
  7139. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  7140. __webpack_require__.r(__webpack_exports__);
  7141. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  7142. /* harmony export */ "ArrayItem": () => (/* binding */ ArrayItem),
  7143. /* harmony export */ "GLTFLoader": () => (/* binding */ GLTFLoader)
  7144. /* harmony export */ });
  7145. /* harmony import */ var core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Misc/stringTools */ "core/Misc/observable");
  7146. /* harmony import */ var core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__);
  7147. /* harmony import */ var _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFFileLoader */ "../../../lts/loaders/dist/glTF/glTFFileLoader.js");
  7148. /**
  7149. * Helper class for working with arrays when loading the glTF asset
  7150. */
  7151. var ArrayItem = /** @class */ (function () {
  7152. function ArrayItem() {
  7153. }
  7154. /**
  7155. * Gets an item from the given array.
  7156. * @param context The context when loading the asset
  7157. * @param array The array to get the item from
  7158. * @param index The index to the array
  7159. * @returns The array item
  7160. */
  7161. ArrayItem.Get = function (context, array, index) {
  7162. if (!array || index == undefined || !array[index]) {
  7163. throw new Error("".concat(context, ": Failed to find index (").concat(index, ")"));
  7164. }
  7165. return array[index];
  7166. };
  7167. /**
  7168. * Assign an `index` field to each item of the given array.
  7169. * @param array The array of items
  7170. */
  7171. ArrayItem.Assign = function (array) {
  7172. if (array) {
  7173. for (var index = 0; index < array.length; index++) {
  7174. array[index].index = index;
  7175. }
  7176. }
  7177. };
  7178. return ArrayItem;
  7179. }());
  7180. /**
  7181. * The glTF 2.0 loader
  7182. */
  7183. var GLTFLoader = /** @class */ (function () {
  7184. /**
  7185. * @param parent
  7186. * @hidden
  7187. */
  7188. function GLTFLoader(parent) {
  7189. /** @hidden */
  7190. this._completePromises = new Array();
  7191. /** @hidden */
  7192. this._assetContainer = null;
  7193. /** Storage */
  7194. this._babylonLights = [];
  7195. /** @hidden */
  7196. this._disableInstancedMesh = 0;
  7197. this._extensions = new Array();
  7198. this._disposed = false;
  7199. this._rootUrl = null;
  7200. this._fileName = null;
  7201. this._uniqueRootUrl = null;
  7202. this._bin = null;
  7203. this._rootBabylonMesh = null;
  7204. this._defaultBabylonMaterialData = {};
  7205. this._postSceneLoadActions = new Array();
  7206. this._parent = parent;
  7207. }
  7208. /**
  7209. * Registers a loader extension.
  7210. * @param name The name of the loader extension.
  7211. * @param factory The factory function that creates the loader extension.
  7212. */
  7213. GLTFLoader.RegisterExtension = function (name, factory) {
  7214. if (GLTFLoader.UnregisterExtension(name)) {
  7215. core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("Extension with the name '".concat(name, "' already exists"));
  7216. }
  7217. GLTFLoader._RegisteredExtensions[name] = {
  7218. factory: factory,
  7219. };
  7220. };
  7221. /**
  7222. * Unregisters a loader extension.
  7223. * @param name The name of the loader extension.
  7224. * @returns A boolean indicating whether the extension has been unregistered
  7225. */
  7226. GLTFLoader.UnregisterExtension = function (name) {
  7227. if (!GLTFLoader._RegisteredExtensions[name]) {
  7228. return false;
  7229. }
  7230. delete GLTFLoader._RegisteredExtensions[name];
  7231. return true;
  7232. };
  7233. Object.defineProperty(GLTFLoader.prototype, "gltf", {
  7234. /**
  7235. * The object that represents the glTF JSON.
  7236. */
  7237. get: function () {
  7238. if (!this._gltf) {
  7239. throw new Error("glTF JSON is not available");
  7240. }
  7241. return this._gltf;
  7242. },
  7243. enumerable: false,
  7244. configurable: true
  7245. });
  7246. Object.defineProperty(GLTFLoader.prototype, "bin", {
  7247. /**
  7248. * The BIN chunk of a binary glTF.
  7249. */
  7250. get: function () {
  7251. return this._bin;
  7252. },
  7253. enumerable: false,
  7254. configurable: true
  7255. });
  7256. Object.defineProperty(GLTFLoader.prototype, "parent", {
  7257. /**
  7258. * The parent file loader.
  7259. */
  7260. get: function () {
  7261. return this._parent;
  7262. },
  7263. enumerable: false,
  7264. configurable: true
  7265. });
  7266. Object.defineProperty(GLTFLoader.prototype, "babylonScene", {
  7267. /**
  7268. * The Babylon scene when loading the asset.
  7269. */
  7270. get: function () {
  7271. if (!this._babylonScene) {
  7272. throw new Error("Scene is not available");
  7273. }
  7274. return this._babylonScene;
  7275. },
  7276. enumerable: false,
  7277. configurable: true
  7278. });
  7279. Object.defineProperty(GLTFLoader.prototype, "rootBabylonMesh", {
  7280. /**
  7281. * The root Babylon mesh when loading the asset.
  7282. */
  7283. get: function () {
  7284. return this._rootBabylonMesh;
  7285. },
  7286. enumerable: false,
  7287. configurable: true
  7288. });
  7289. /** @hidden */
  7290. GLTFLoader.prototype.dispose = function () {
  7291. if (this._disposed) {
  7292. return;
  7293. }
  7294. this._disposed = true;
  7295. this._completePromises.length = 0;
  7296. this._extensions.forEach(function (extension) { return extension.dispose && extension.dispose(); });
  7297. this._extensions.length = 0;
  7298. this._gltf = null; // TODO
  7299. this._bin = null;
  7300. this._babylonScene = null; // TODO
  7301. this._rootBabylonMesh = null;
  7302. this._defaultBabylonMaterialData = {};
  7303. this._postSceneLoadActions.length = 0;
  7304. this._parent.dispose();
  7305. };
  7306. /**
  7307. * @param meshesNames
  7308. * @param scene
  7309. * @param container
  7310. * @param data
  7311. * @param rootUrl
  7312. * @param onProgress
  7313. * @param fileName
  7314. * @hidden
  7315. */
  7316. GLTFLoader.prototype.importMeshAsync = function (meshesNames, scene, container, data, rootUrl, onProgress, fileName) {
  7317. var _this = this;
  7318. if (fileName === void 0) { fileName = ""; }
  7319. return Promise.resolve().then(function () {
  7320. _this._babylonScene = scene;
  7321. _this._assetContainer = container;
  7322. _this._loadData(data);
  7323. var nodes = null;
  7324. if (meshesNames) {
  7325. var nodeMap_1 = {};
  7326. if (_this._gltf.nodes) {
  7327. for (var _i = 0, _a = _this._gltf.nodes; _i < _a.length; _i++) {
  7328. var node = _a[_i];
  7329. if (node.name) {
  7330. nodeMap_1[node.name] = node.index;
  7331. }
  7332. }
  7333. }
  7334. var names = meshesNames instanceof Array ? meshesNames : [meshesNames];
  7335. nodes = names.map(function (name) {
  7336. var node = nodeMap_1[name];
  7337. if (node === undefined) {
  7338. throw new Error("Failed to find node '".concat(name, "'"));
  7339. }
  7340. return node;
  7341. });
  7342. }
  7343. return _this._loadAsync(rootUrl, fileName, nodes, function () {
  7344. return {
  7345. meshes: _this._getMeshes(),
  7346. particleSystems: [],
  7347. skeletons: _this._getSkeletons(),
  7348. animationGroups: _this._getAnimationGroups(),
  7349. lights: _this._babylonLights,
  7350. transformNodes: _this._getTransformNodes(),
  7351. geometries: _this._getGeometries(),
  7352. };
  7353. });
  7354. });
  7355. };
  7356. /**
  7357. * @param scene
  7358. * @param data
  7359. * @param rootUrl
  7360. * @param onProgress
  7361. * @param fileName
  7362. * @hidden
  7363. */
  7364. GLTFLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fileName) {
  7365. var _this = this;
  7366. if (fileName === void 0) { fileName = ""; }
  7367. return Promise.resolve().then(function () {
  7368. _this._babylonScene = scene;
  7369. _this._loadData(data);
  7370. return _this._loadAsync(rootUrl, fileName, null, function () { return undefined; });
  7371. });
  7372. };
  7373. GLTFLoader.prototype._loadAsync = function (rootUrl, fileName, nodes, resultFunc) {
  7374. var _this = this;
  7375. return Promise.resolve()
  7376. .then(function () {
  7377. _this._rootUrl = rootUrl;
  7378. _this._uniqueRootUrl = !core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.StringTools.StartsWith(rootUrl, "file:") && fileName ? rootUrl : "".concat(rootUrl).concat(Date.now(), "/");
  7379. _this._fileName = fileName;
  7380. _this._loadExtensions();
  7381. _this._checkExtensions();
  7382. var loadingToReadyCounterName = "".concat(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState[_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.LOADING], " => ").concat(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState[_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.READY]);
  7383. var loadingToCompleteCounterName = "".concat(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState[_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.LOADING], " => ").concat(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState[_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.COMPLETE]);
  7384. _this._parent._startPerformanceCounter(loadingToReadyCounterName);
  7385. _this._parent._startPerformanceCounter(loadingToCompleteCounterName);
  7386. _this._parent._setState(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.LOADING);
  7387. _this._extensionsOnLoading();
  7388. var promises = new Array();
  7389. // Block the marking of materials dirty until the scene is loaded.
  7390. var oldBlockMaterialDirtyMechanism = _this._babylonScene.blockMaterialDirtyMechanism;
  7391. _this._babylonScene.blockMaterialDirtyMechanism = true;
  7392. if (!_this.parent.loadOnlyMaterials) {
  7393. if (nodes) {
  7394. promises.push(_this.loadSceneAsync("/nodes", { nodes: nodes, index: -1 }));
  7395. }
  7396. else if (_this._gltf.scene != undefined || (_this._gltf.scenes && _this._gltf.scenes[0])) {
  7397. var scene = ArrayItem.Get("/scene", _this._gltf.scenes, _this._gltf.scene || 0);
  7398. promises.push(_this.loadSceneAsync("/scenes/".concat(scene.index), scene));
  7399. }
  7400. }
  7401. if (!_this.parent.skipMaterials && _this.parent.loadAllMaterials && _this._gltf.materials) {
  7402. for (var m = 0; m < _this._gltf.materials.length; ++m) {
  7403. var material = _this._gltf.materials[m];
  7404. var context_1 = "/materials/" + m;
  7405. var babylonDrawMode = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFillMode;
  7406. promises.push(_this._loadMaterialAsync(context_1, material, null, babylonDrawMode, function (material) { }));
  7407. }
  7408. }
  7409. // Restore the blocking of material dirty.
  7410. _this._babylonScene.blockMaterialDirtyMechanism = oldBlockMaterialDirtyMechanism;
  7411. if (_this._parent.compileMaterials) {
  7412. promises.push(_this._compileMaterialsAsync());
  7413. }
  7414. if (_this._parent.compileShadowGenerators) {
  7415. promises.push(_this._compileShadowGeneratorsAsync());
  7416. }
  7417. var resultPromise = Promise.all(promises).then(function () {
  7418. if (_this._rootBabylonMesh) {
  7419. _this._rootBabylonMesh.setEnabled(true);
  7420. }
  7421. _this._extensionsOnReady();
  7422. _this._parent._setState(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.READY);
  7423. _this._startAnimations();
  7424. return resultFunc();
  7425. });
  7426. return resultPromise.then(function (result) {
  7427. _this._parent._endPerformanceCounter(loadingToReadyCounterName);
  7428. core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Tools.SetImmediate(function () {
  7429. if (!_this._disposed) {
  7430. Promise.all(_this._completePromises).then(function () {
  7431. _this._parent._endPerformanceCounter(loadingToCompleteCounterName);
  7432. _this._parent._setState(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.COMPLETE);
  7433. _this._parent.onCompleteObservable.notifyObservers(undefined);
  7434. _this._parent.onCompleteObservable.clear();
  7435. _this.dispose();
  7436. }, function (error) {
  7437. _this._parent.onErrorObservable.notifyObservers(error);
  7438. _this._parent.onErrorObservable.clear();
  7439. _this.dispose();
  7440. });
  7441. }
  7442. });
  7443. return result;
  7444. });
  7445. })
  7446. .catch(function (error) {
  7447. if (!_this._disposed) {
  7448. _this._parent.onErrorObservable.notifyObservers(error);
  7449. _this._parent.onErrorObservable.clear();
  7450. _this.dispose();
  7451. }
  7452. throw error;
  7453. });
  7454. };
  7455. GLTFLoader.prototype._loadData = function (data) {
  7456. this._gltf = data.json;
  7457. this._setupData();
  7458. if (data.bin) {
  7459. var buffers = this._gltf.buffers;
  7460. if (buffers && buffers[0] && !buffers[0].uri) {
  7461. var binaryBuffer = buffers[0];
  7462. if (binaryBuffer.byteLength < data.bin.byteLength - 3 || binaryBuffer.byteLength > data.bin.byteLength) {
  7463. core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("Binary buffer length (".concat(binaryBuffer.byteLength, ") from JSON does not match chunk length (").concat(data.bin.byteLength, ")"));
  7464. }
  7465. this._bin = data.bin;
  7466. }
  7467. else {
  7468. core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("Unexpected BIN chunk");
  7469. }
  7470. }
  7471. };
  7472. GLTFLoader.prototype._setupData = function () {
  7473. ArrayItem.Assign(this._gltf.accessors);
  7474. ArrayItem.Assign(this._gltf.animations);
  7475. ArrayItem.Assign(this._gltf.buffers);
  7476. ArrayItem.Assign(this._gltf.bufferViews);
  7477. ArrayItem.Assign(this._gltf.cameras);
  7478. ArrayItem.Assign(this._gltf.images);
  7479. ArrayItem.Assign(this._gltf.materials);
  7480. ArrayItem.Assign(this._gltf.meshes);
  7481. ArrayItem.Assign(this._gltf.nodes);
  7482. ArrayItem.Assign(this._gltf.samplers);
  7483. ArrayItem.Assign(this._gltf.scenes);
  7484. ArrayItem.Assign(this._gltf.skins);
  7485. ArrayItem.Assign(this._gltf.textures);
  7486. if (this._gltf.nodes) {
  7487. var nodeParents = {};
  7488. for (var _i = 0, _a = this._gltf.nodes; _i < _a.length; _i++) {
  7489. var node = _a[_i];
  7490. if (node.children) {
  7491. for (var _b = 0, _c = node.children; _b < _c.length; _b++) {
  7492. var index = _c[_b];
  7493. nodeParents[index] = node.index;
  7494. }
  7495. }
  7496. }
  7497. var rootNode = this._createRootNode();
  7498. for (var _d = 0, _e = this._gltf.nodes; _d < _e.length; _d++) {
  7499. var node = _e[_d];
  7500. var parentIndex = nodeParents[node.index];
  7501. node.parent = parentIndex === undefined ? rootNode : this._gltf.nodes[parentIndex];
  7502. }
  7503. }
  7504. };
  7505. GLTFLoader.prototype._loadExtensions = function () {
  7506. for (var name_1 in GLTFLoader._RegisteredExtensions) {
  7507. var extension = GLTFLoader._RegisteredExtensions[name_1].factory(this);
  7508. if (extension.name !== name_1) {
  7509. core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("The name of the glTF loader extension instance does not match the registered name: ".concat(extension.name, " !== ").concat(name_1));
  7510. }
  7511. this._extensions.push(extension);
  7512. this._parent.onExtensionLoadedObservable.notifyObservers(extension);
  7513. }
  7514. this._extensions.sort(function (a, b) { return (a.order || Number.MAX_VALUE) - (b.order || Number.MAX_VALUE); });
  7515. this._parent.onExtensionLoadedObservable.clear();
  7516. };
  7517. GLTFLoader.prototype._checkExtensions = function () {
  7518. if (this._gltf.extensionsRequired) {
  7519. var _loop_1 = function (name_2) {
  7520. var available = this_1._extensions.some(function (extension) { return extension.name === name_2 && extension.enabled; });
  7521. if (!available) {
  7522. throw new Error("Require extension ".concat(name_2, " is not available"));
  7523. }
  7524. };
  7525. var this_1 = this;
  7526. for (var _i = 0, _a = this._gltf.extensionsRequired; _i < _a.length; _i++) {
  7527. var name_2 = _a[_i];
  7528. _loop_1(name_2);
  7529. }
  7530. }
  7531. };
  7532. GLTFLoader.prototype._createRootNode = function () {
  7533. this._babylonScene._blockEntityCollection = !!this._assetContainer;
  7534. this._rootBabylonMesh = new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Mesh("__root__", this._babylonScene);
  7535. this._rootBabylonMesh._parentContainer = this._assetContainer;
  7536. this._babylonScene._blockEntityCollection = false;
  7537. this._rootBabylonMesh.setEnabled(false);
  7538. var rootNode = {
  7539. _babylonTransformNode: this._rootBabylonMesh,
  7540. index: -1,
  7541. };
  7542. switch (this._parent.coordinateSystemMode) {
  7543. case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderCoordinateSystemMode.AUTO: {
  7544. if (!this._babylonScene.useRightHandedSystem) {
  7545. rootNode.rotation = [0, 1, 0, 0];
  7546. rootNode.scale = [1, 1, -1];
  7547. GLTFLoader._LoadTransform(rootNode, this._rootBabylonMesh);
  7548. }
  7549. break;
  7550. }
  7551. case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderCoordinateSystemMode.FORCE_RIGHT_HANDED: {
  7552. this._babylonScene.useRightHandedSystem = true;
  7553. break;
  7554. }
  7555. default: {
  7556. throw new Error("Invalid coordinate system mode (".concat(this._parent.coordinateSystemMode, ")"));
  7557. }
  7558. }
  7559. this._parent.onMeshLoadedObservable.notifyObservers(this._rootBabylonMesh);
  7560. return rootNode;
  7561. };
  7562. /**
  7563. * Loads a glTF scene.
  7564. * @param context The context when loading the asset
  7565. * @param scene The glTF scene property
  7566. * @returns A promise that resolves when the load is complete
  7567. */
  7568. GLTFLoader.prototype.loadSceneAsync = function (context, scene) {
  7569. var _this = this;
  7570. var extensionPromise = this._extensionsLoadSceneAsync(context, scene);
  7571. if (extensionPromise) {
  7572. return extensionPromise;
  7573. }
  7574. var promises = new Array();
  7575. this.logOpen("".concat(context, " ").concat(scene.name || ""));
  7576. if (scene.nodes) {
  7577. for (var _i = 0, _a = scene.nodes; _i < _a.length; _i++) {
  7578. var index = _a[_i];
  7579. var node = ArrayItem.Get("".concat(context, "/nodes/").concat(index), this._gltf.nodes, index);
  7580. promises.push(this.loadNodeAsync("/nodes/".concat(node.index), node, function (babylonMesh) {
  7581. babylonMesh.parent = _this._rootBabylonMesh;
  7582. }));
  7583. }
  7584. }
  7585. for (var _b = 0, _c = this._postSceneLoadActions; _b < _c.length; _b++) {
  7586. var action = _c[_b];
  7587. action();
  7588. }
  7589. promises.push(this._loadAnimationsAsync());
  7590. this.logClose();
  7591. return Promise.all(promises).then(function () { });
  7592. };
  7593. GLTFLoader.prototype._forEachPrimitive = function (node, callback) {
  7594. if (node._primitiveBabylonMeshes) {
  7595. for (var _i = 0, _a = node._primitiveBabylonMeshes; _i < _a.length; _i++) {
  7596. var babylonMesh = _a[_i];
  7597. callback(babylonMesh);
  7598. }
  7599. }
  7600. };
  7601. GLTFLoader.prototype._getGeometries = function () {
  7602. var geometries = new Array();
  7603. var nodes = this._gltf.nodes;
  7604. if (nodes) {
  7605. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  7606. var node = nodes_1[_i];
  7607. this._forEachPrimitive(node, function (babylonMesh) {
  7608. var geometry = babylonMesh.geometry;
  7609. if (geometry && geometries.indexOf(geometry) === -1) {
  7610. geometries.push(geometry);
  7611. }
  7612. });
  7613. }
  7614. }
  7615. return geometries;
  7616. };
  7617. GLTFLoader.prototype._getMeshes = function () {
  7618. var meshes = new Array();
  7619. // Root mesh is always first, if available.
  7620. if (this._rootBabylonMesh) {
  7621. meshes.push(this._rootBabylonMesh);
  7622. }
  7623. var nodes = this._gltf.nodes;
  7624. if (nodes) {
  7625. for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) {
  7626. var node = nodes_2[_i];
  7627. this._forEachPrimitive(node, function (babylonMesh) {
  7628. meshes.push(babylonMesh);
  7629. });
  7630. }
  7631. }
  7632. return meshes;
  7633. };
  7634. GLTFLoader.prototype._getTransformNodes = function () {
  7635. var transformNodes = new Array();
  7636. var nodes = this._gltf.nodes;
  7637. if (nodes) {
  7638. for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) {
  7639. var node = nodes_3[_i];
  7640. if (node._babylonTransformNode && node._babylonTransformNode.getClassName() === "TransformNode") {
  7641. transformNodes.push(node._babylonTransformNode);
  7642. }
  7643. if (node._babylonTransformNodeForSkin) {
  7644. transformNodes.push(node._babylonTransformNodeForSkin);
  7645. }
  7646. }
  7647. }
  7648. return transformNodes;
  7649. };
  7650. GLTFLoader.prototype._getSkeletons = function () {
  7651. var skeletons = new Array();
  7652. var skins = this._gltf.skins;
  7653. if (skins) {
  7654. for (var _i = 0, skins_1 = skins; _i < skins_1.length; _i++) {
  7655. var skin = skins_1[_i];
  7656. if (skin._data) {
  7657. skeletons.push(skin._data.babylonSkeleton);
  7658. }
  7659. }
  7660. }
  7661. return skeletons;
  7662. };
  7663. GLTFLoader.prototype._getAnimationGroups = function () {
  7664. var animationGroups = new Array();
  7665. var animations = this._gltf.animations;
  7666. if (animations) {
  7667. for (var _i = 0, animations_1 = animations; _i < animations_1.length; _i++) {
  7668. var animation = animations_1[_i];
  7669. if (animation._babylonAnimationGroup) {
  7670. animationGroups.push(animation._babylonAnimationGroup);
  7671. }
  7672. }
  7673. }
  7674. return animationGroups;
  7675. };
  7676. GLTFLoader.prototype._startAnimations = function () {
  7677. switch (this._parent.animationStartMode) {
  7678. case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderAnimationStartMode.NONE: {
  7679. // do nothing
  7680. break;
  7681. }
  7682. case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderAnimationStartMode.FIRST: {
  7683. var babylonAnimationGroups = this._getAnimationGroups();
  7684. if (babylonAnimationGroups.length !== 0) {
  7685. babylonAnimationGroups[0].start(true);
  7686. }
  7687. break;
  7688. }
  7689. case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderAnimationStartMode.ALL: {
  7690. var babylonAnimationGroups = this._getAnimationGroups();
  7691. for (var _i = 0, babylonAnimationGroups_1 = babylonAnimationGroups; _i < babylonAnimationGroups_1.length; _i++) {
  7692. var babylonAnimationGroup = babylonAnimationGroups_1[_i];
  7693. babylonAnimationGroup.start(true);
  7694. }
  7695. break;
  7696. }
  7697. default: {
  7698. core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Error("Invalid animation start mode (".concat(this._parent.animationStartMode, ")"));
  7699. return;
  7700. }
  7701. }
  7702. };
  7703. /**
  7704. * Loads a glTF node.
  7705. * @param context The context when loading the asset
  7706. * @param node The glTF node property
  7707. * @param assign A function called synchronously after parsing the glTF properties
  7708. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  7709. */
  7710. GLTFLoader.prototype.loadNodeAsync = function (context, node, assign) {
  7711. var _this = this;
  7712. if (assign === void 0) { assign = function () { }; }
  7713. var extensionPromise = this._extensionsLoadNodeAsync(context, node, assign);
  7714. if (extensionPromise) {
  7715. return extensionPromise;
  7716. }
  7717. if (node._babylonTransformNode) {
  7718. throw new Error("".concat(context, ": Invalid recursive node hierarchy"));
  7719. }
  7720. var promises = new Array();
  7721. this.logOpen("".concat(context, " ").concat(node.name || ""));
  7722. var loadNode = function (babylonTransformNode) {
  7723. GLTFLoader.AddPointerMetadata(babylonTransformNode, context);
  7724. GLTFLoader._LoadTransform(node, babylonTransformNode);
  7725. if (node.camera != undefined) {
  7726. var camera = ArrayItem.Get("".concat(context, "/camera"), _this._gltf.cameras, node.camera);
  7727. promises.push(_this.loadCameraAsync("/cameras/".concat(camera.index), camera, function (babylonCamera) {
  7728. babylonCamera.parent = babylonTransformNode;
  7729. }));
  7730. }
  7731. if (node.children) {
  7732. for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
  7733. var index = _a[_i];
  7734. var childNode = ArrayItem.Get("".concat(context, "/children/").concat(index), _this._gltf.nodes, index);
  7735. promises.push(_this.loadNodeAsync("/nodes/".concat(childNode.index), childNode, function (childBabylonMesh) {
  7736. childBabylonMesh.parent = babylonTransformNode;
  7737. }));
  7738. }
  7739. }
  7740. assign(babylonTransformNode);
  7741. };
  7742. if (node.mesh == undefined || node.skin != undefined) {
  7743. var nodeName = node.name || "node".concat(node.index);
  7744. this._babylonScene._blockEntityCollection = !!this._assetContainer;
  7745. var transformNode = new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.TransformNode(nodeName, this._babylonScene);
  7746. transformNode._parentContainer = this._assetContainer;
  7747. this._babylonScene._blockEntityCollection = false;
  7748. if (node.mesh == undefined) {
  7749. node._babylonTransformNode = transformNode;
  7750. }
  7751. else {
  7752. node._babylonTransformNodeForSkin = transformNode;
  7753. }
  7754. loadNode(transformNode);
  7755. }
  7756. if (node.mesh != undefined) {
  7757. if (node.skin == undefined) {
  7758. var mesh = ArrayItem.Get("".concat(context, "/mesh"), this._gltf.meshes, node.mesh);
  7759. promises.push(this._loadMeshAsync("/meshes/".concat(mesh.index), node, mesh, loadNode));
  7760. }
  7761. else {
  7762. // See https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins (second implementation note)
  7763. // This code path will place the skinned mesh as a sibling of the skeleton root node without loading the
  7764. // transform, which effectively ignores the transform of the skinned mesh, as per spec.
  7765. var mesh = ArrayItem.Get("".concat(context, "/mesh"), this._gltf.meshes, node.mesh);
  7766. promises.push(this._loadMeshAsync("/meshes/".concat(mesh.index), node, mesh, function (babylonTransformNode) {
  7767. // Duplicate the metadata from the skin node to the skinned mesh in case any loader extension added metadata.
  7768. babylonTransformNode.metadata = node._babylonTransformNodeForSkin.metadata;
  7769. var skin = ArrayItem.Get("".concat(context, "/skin"), _this._gltf.skins, node.skin);
  7770. promises.push(_this._loadSkinAsync("/skins/".concat(skin.index), node, skin, function (babylonSkeleton) {
  7771. _this._forEachPrimitive(node, function (babylonMesh) {
  7772. babylonMesh.skeleton = babylonSkeleton;
  7773. });
  7774. // Wait until the scene is loaded to ensure the skeleton root node has been loaded.
  7775. _this._postSceneLoadActions.push(function () {
  7776. if (skin.skeleton != undefined) {
  7777. // Place the skinned mesh node as a sibling of the skeleton root node.
  7778. var skeletonRootNode = ArrayItem.Get("/skins/".concat(skin.index, "/skeleton"), _this._gltf.nodes, skin.skeleton);
  7779. babylonTransformNode.parent = skeletonRootNode.parent._babylonTransformNode;
  7780. }
  7781. else {
  7782. babylonTransformNode.parent = _this._rootBabylonMesh;
  7783. }
  7784. });
  7785. }));
  7786. }));
  7787. }
  7788. }
  7789. this.logClose();
  7790. return Promise.all(promises).then(function () {
  7791. _this._forEachPrimitive(node, function (babylonMesh) {
  7792. if (babylonMesh.geometry && babylonMesh.geometry.useBoundingInfoFromGeometry) {
  7793. // simply apply the world matrices to the bounding info - the extends are already ok
  7794. babylonMesh._updateBoundingInfo();
  7795. }
  7796. else {
  7797. babylonMesh.refreshBoundingInfo(true);
  7798. }
  7799. });
  7800. return node._babylonTransformNode;
  7801. });
  7802. };
  7803. GLTFLoader.prototype._loadMeshAsync = function (context, node, mesh, assign) {
  7804. var primitives = mesh.primitives;
  7805. if (!primitives || !primitives.length) {
  7806. throw new Error("".concat(context, ": Primitives are missing"));
  7807. }
  7808. if (primitives[0].index == undefined) {
  7809. ArrayItem.Assign(primitives);
  7810. }
  7811. var promises = new Array();
  7812. this.logOpen("".concat(context, " ").concat(mesh.name || ""));
  7813. var name = node.name || "node".concat(node.index);
  7814. if (primitives.length === 1) {
  7815. var primitive = mesh.primitives[0];
  7816. promises.push(this._loadMeshPrimitiveAsync("".concat(context, "/primitives/").concat(primitive.index), name, node, mesh, primitive, function (babylonMesh) {
  7817. node._babylonTransformNode = babylonMesh;
  7818. node._primitiveBabylonMeshes = [babylonMesh];
  7819. }));
  7820. }
  7821. else {
  7822. this._babylonScene._blockEntityCollection = !!this._assetContainer;
  7823. node._babylonTransformNode = new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.TransformNode(name, this._babylonScene);
  7824. node._babylonTransformNode._parentContainer = this._assetContainer;
  7825. this._babylonScene._blockEntityCollection = false;
  7826. node._primitiveBabylonMeshes = [];
  7827. for (var _i = 0, primitives_1 = primitives; _i < primitives_1.length; _i++) {
  7828. var primitive = primitives_1[_i];
  7829. promises.push(this._loadMeshPrimitiveAsync("".concat(context, "/primitives/").concat(primitive.index), "".concat(name, "_primitive").concat(primitive.index), node, mesh, primitive, function (babylonMesh) {
  7830. babylonMesh.parent = node._babylonTransformNode;
  7831. node._primitiveBabylonMeshes.push(babylonMesh);
  7832. }));
  7833. }
  7834. }
  7835. assign(node._babylonTransformNode);
  7836. this.logClose();
  7837. return Promise.all(promises).then(function () {
  7838. return node._babylonTransformNode;
  7839. });
  7840. };
  7841. /**
  7842. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  7843. * @param context The context when loading the asset
  7844. * @param name The mesh name when loading the asset
  7845. * @param node The glTF node when loading the asset
  7846. * @param mesh The glTF mesh when loading the asset
  7847. * @param primitive The glTF mesh primitive property
  7848. * @param assign A function called synchronously after parsing the glTF properties
  7849. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  7850. */
  7851. GLTFLoader.prototype._loadMeshPrimitiveAsync = function (context, name, node, mesh, primitive, assign) {
  7852. var _this = this;
  7853. var extensionPromise = this._extensionsLoadMeshPrimitiveAsync(context, name, node, mesh, primitive, assign);
  7854. if (extensionPromise) {
  7855. return extensionPromise;
  7856. }
  7857. this.logOpen("".concat(context));
  7858. var shouldInstance = this._disableInstancedMesh === 0 && this._parent.createInstances && node.skin == undefined && !mesh.primitives[0].targets;
  7859. var babylonAbstractMesh;
  7860. var promise;
  7861. if (shouldInstance && primitive._instanceData) {
  7862. this._babylonScene._blockEntityCollection = !!this._assetContainer;
  7863. babylonAbstractMesh = primitive._instanceData.babylonSourceMesh.createInstance(name);
  7864. babylonAbstractMesh._parentContainer = this._assetContainer;
  7865. this._babylonScene._blockEntityCollection = false;
  7866. promise = primitive._instanceData.promise;
  7867. }
  7868. else {
  7869. var promises = new Array();
  7870. this._babylonScene._blockEntityCollection = !!this._assetContainer;
  7871. var babylonMesh_1 = new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Mesh(name, this._babylonScene);
  7872. babylonMesh_1._parentContainer = this._assetContainer;
  7873. this._babylonScene._blockEntityCollection = false;
  7874. babylonMesh_1.overrideMaterialSideOrientation = this._babylonScene.useRightHandedSystem ? core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.CounterClockWiseSideOrientation : core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.ClockWiseSideOrientation;
  7875. this._createMorphTargets(context, node, mesh, primitive, babylonMesh_1);
  7876. promises.push(this._loadVertexDataAsync(context, primitive, babylonMesh_1).then(function (babylonGeometry) {
  7877. return _this._loadMorphTargetsAsync(context, primitive, babylonMesh_1, babylonGeometry).then(function () {
  7878. _this._babylonScene._blockEntityCollection = !!_this._assetContainer;
  7879. babylonGeometry.applyToMesh(babylonMesh_1);
  7880. babylonGeometry._parentContainer = _this._assetContainer;
  7881. _this._babylonScene._blockEntityCollection = false;
  7882. });
  7883. }));
  7884. var babylonDrawMode = GLTFLoader._GetDrawMode(context, primitive.mode);
  7885. if (primitive.material == undefined) {
  7886. var babylonMaterial = this._defaultBabylonMaterialData[babylonDrawMode];
  7887. if (!babylonMaterial) {
  7888. babylonMaterial = this._createDefaultMaterial("__GLTFLoader._default", babylonDrawMode);
  7889. this._parent.onMaterialLoadedObservable.notifyObservers(babylonMaterial);
  7890. this._defaultBabylonMaterialData[babylonDrawMode] = babylonMaterial;
  7891. }
  7892. babylonMesh_1.material = babylonMaterial;
  7893. }
  7894. else if (!this.parent.skipMaterials) {
  7895. var material = ArrayItem.Get("".concat(context, "/material"), this._gltf.materials, primitive.material);
  7896. promises.push(this._loadMaterialAsync("/materials/".concat(material.index), material, babylonMesh_1, babylonDrawMode, function (babylonMaterial) {
  7897. babylonMesh_1.material = babylonMaterial;
  7898. }));
  7899. }
  7900. promise = Promise.all(promises);
  7901. if (shouldInstance) {
  7902. primitive._instanceData = {
  7903. babylonSourceMesh: babylonMesh_1,
  7904. promise: promise,
  7905. };
  7906. }
  7907. babylonAbstractMesh = babylonMesh_1;
  7908. }
  7909. GLTFLoader.AddPointerMetadata(babylonAbstractMesh, context);
  7910. this._parent.onMeshLoadedObservable.notifyObservers(babylonAbstractMesh);
  7911. assign(babylonAbstractMesh);
  7912. this.logClose();
  7913. return promise.then(function () {
  7914. return babylonAbstractMesh;
  7915. });
  7916. };
  7917. GLTFLoader.prototype._loadVertexDataAsync = function (context, primitive, babylonMesh) {
  7918. var _this = this;
  7919. var extensionPromise = this._extensionsLoadVertexDataAsync(context, primitive, babylonMesh);
  7920. if (extensionPromise) {
  7921. return extensionPromise;
  7922. }
  7923. var attributes = primitive.attributes;
  7924. if (!attributes) {
  7925. throw new Error("".concat(context, ": Attributes are missing"));
  7926. }
  7927. var promises = new Array();
  7928. var babylonGeometry = new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Geometry(babylonMesh.name, this._babylonScene);
  7929. if (primitive.indices == undefined) {
  7930. babylonMesh.isUnIndexed = true;
  7931. }
  7932. else {
  7933. var accessor = ArrayItem.Get("".concat(context, "/indices"), this._gltf.accessors, primitive.indices);
  7934. promises.push(this._loadIndicesAccessorAsync("/accessors/".concat(accessor.index), accessor).then(function (data) {
  7935. babylonGeometry.setIndices(data);
  7936. }));
  7937. }
  7938. var loadAttribute = function (attribute, kind, callback) {
  7939. if (attributes[attribute] == undefined) {
  7940. return;
  7941. }
  7942. babylonMesh._delayInfo = babylonMesh._delayInfo || [];
  7943. if (babylonMesh._delayInfo.indexOf(kind) === -1) {
  7944. babylonMesh._delayInfo.push(kind);
  7945. }
  7946. var accessor = ArrayItem.Get("".concat(context, "/attributes/").concat(attribute), _this._gltf.accessors, attributes[attribute]);
  7947. promises.push(_this._loadVertexAccessorAsync("/accessors/".concat(accessor.index), accessor, kind).then(function (babylonVertexBuffer) {
  7948. if (babylonVertexBuffer.getKind() === core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind && !_this.parent.alwaysComputeBoundingBox && !babylonMesh.skeleton) {
  7949. var mmin = accessor.min, mmax = accessor.max;
  7950. if (mmin !== undefined && mmax !== undefined) {
  7951. if (accessor.normalized && accessor.componentType !== 5126 /* FLOAT */) {
  7952. var divider = 1;
  7953. switch (accessor.componentType) {
  7954. case 5120 /* BYTE */:
  7955. divider = 127.0;
  7956. break;
  7957. case 5121 /* UNSIGNED_BYTE */:
  7958. divider = 255.0;
  7959. break;
  7960. case 5122 /* SHORT */:
  7961. divider = 32767.0;
  7962. break;
  7963. case 5123 /* UNSIGNED_SHORT */:
  7964. divider = 65535.0;
  7965. break;
  7966. }
  7967. for (var i = 0; i < 3; ++i) {
  7968. mmin[i] = Math.max(mmin[i] / divider, -1.0);
  7969. mmax[i] = Math.max(mmax[i] / divider, -1.0);
  7970. }
  7971. }
  7972. var min = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0], max = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[1];
  7973. min.copyFromFloats.apply(min, mmin);
  7974. max.copyFromFloats.apply(max, mmax);
  7975. babylonGeometry._boundingInfo = new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.BoundingInfo(min, max);
  7976. babylonGeometry.useBoundingInfoFromGeometry = true;
  7977. }
  7978. }
  7979. babylonGeometry.setVerticesBuffer(babylonVertexBuffer, accessor.count);
  7980. }));
  7981. if (kind == core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesExtraKind) {
  7982. babylonMesh.numBoneInfluencers = 8;
  7983. }
  7984. if (callback) {
  7985. callback(accessor);
  7986. }
  7987. };
  7988. loadAttribute("POSITION", core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind);
  7989. loadAttribute("NORMAL", core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind);
  7990. loadAttribute("TANGENT", core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind);
  7991. loadAttribute("TEXCOORD_0", core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UVKind);
  7992. loadAttribute("TEXCOORD_1", core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV2Kind);
  7993. loadAttribute("TEXCOORD_2", core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV3Kind);
  7994. loadAttribute("TEXCOORD_3", core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV4Kind);
  7995. loadAttribute("TEXCOORD_4", core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV5Kind);
  7996. loadAttribute("TEXCOORD_5", core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV6Kind);
  7997. loadAttribute("JOINTS_0", core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesKind);
  7998. loadAttribute("WEIGHTS_0", core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsKind);
  7999. loadAttribute("JOINTS_1", core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesExtraKind);
  8000. loadAttribute("WEIGHTS_1", core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsExtraKind);
  8001. loadAttribute("COLOR_0", core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ColorKind, function (accessor) {
  8002. if (accessor.type === "VEC4" /* VEC4 */) {
  8003. babylonMesh.hasVertexAlpha = true;
  8004. }
  8005. });
  8006. return Promise.all(promises).then(function () {
  8007. return babylonGeometry;
  8008. });
  8009. };
  8010. GLTFLoader.prototype._createMorphTargets = function (context, node, mesh, primitive, babylonMesh) {
  8011. if (!primitive.targets) {
  8012. return;
  8013. }
  8014. if (node._numMorphTargets == undefined) {
  8015. node._numMorphTargets = primitive.targets.length;
  8016. }
  8017. else if (primitive.targets.length !== node._numMorphTargets) {
  8018. throw new Error("".concat(context, ": Primitives do not have the same number of targets"));
  8019. }
  8020. var targetNames = mesh.extras ? mesh.extras.targetNames : null;
  8021. babylonMesh.morphTargetManager = new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.MorphTargetManager(babylonMesh.getScene());
  8022. babylonMesh.morphTargetManager.areUpdatesFrozen = true;
  8023. for (var index = 0; index < primitive.targets.length; index++) {
  8024. var weight = node.weights ? node.weights[index] : mesh.weights ? mesh.weights[index] : 0;
  8025. var name_3 = targetNames ? targetNames[index] : "morphTarget".concat(index);
  8026. babylonMesh.morphTargetManager.addTarget(new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.MorphTarget(name_3, weight, babylonMesh.getScene()));
  8027. // TODO: tell the target whether it has positions, normals, tangents
  8028. }
  8029. };
  8030. GLTFLoader.prototype._loadMorphTargetsAsync = function (context, primitive, babylonMesh, babylonGeometry) {
  8031. if (!primitive.targets) {
  8032. return Promise.resolve();
  8033. }
  8034. var promises = new Array();
  8035. var morphTargetManager = babylonMesh.morphTargetManager;
  8036. for (var index = 0; index < morphTargetManager.numTargets; index++) {
  8037. var babylonMorphTarget = morphTargetManager.getTarget(index);
  8038. promises.push(this._loadMorphTargetVertexDataAsync("".concat(context, "/targets/").concat(index), babylonGeometry, primitive.targets[index], babylonMorphTarget));
  8039. }
  8040. return Promise.all(promises).then(function () {
  8041. morphTargetManager.areUpdatesFrozen = false;
  8042. });
  8043. };
  8044. GLTFLoader.prototype._loadMorphTargetVertexDataAsync = function (context, babylonGeometry, attributes, babylonMorphTarget) {
  8045. var _this = this;
  8046. var promises = new Array();
  8047. var loadAttribute = function (attribute, kind, setData) {
  8048. if (attributes[attribute] == undefined) {
  8049. return;
  8050. }
  8051. var babylonVertexBuffer = babylonGeometry.getVertexBuffer(kind);
  8052. if (!babylonVertexBuffer) {
  8053. return;
  8054. }
  8055. var accessor = ArrayItem.Get("".concat(context, "/").concat(attribute), _this._gltf.accessors, attributes[attribute]);
  8056. promises.push(_this._loadFloatAccessorAsync("/accessors/".concat(accessor.index), accessor).then(function (data) {
  8057. setData(babylonVertexBuffer, data);
  8058. }));
  8059. };
  8060. loadAttribute("POSITION", core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind, function (babylonVertexBuffer, data) {
  8061. var positions = new Float32Array(data.length);
  8062. babylonVertexBuffer.forEach(data.length, function (value, index) {
  8063. positions[index] = data[index] + value;
  8064. });
  8065. babylonMorphTarget.setPositions(positions);
  8066. });
  8067. loadAttribute("NORMAL", core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind, function (babylonVertexBuffer, data) {
  8068. var normals = new Float32Array(data.length);
  8069. babylonVertexBuffer.forEach(normals.length, function (value, index) {
  8070. normals[index] = data[index] + value;
  8071. });
  8072. babylonMorphTarget.setNormals(normals);
  8073. });
  8074. loadAttribute("TANGENT", core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind, function (babylonVertexBuffer, data) {
  8075. var tangents = new Float32Array((data.length / 3) * 4);
  8076. var dataIndex = 0;
  8077. babylonVertexBuffer.forEach((data.length / 3) * 4, function (value, index) {
  8078. // Tangent data for morph targets is stored as xyz delta.
  8079. // The vertexData.tangent is stored as xyzw.
  8080. // So we need to skip every fourth vertexData.tangent.
  8081. if ((index + 1) % 4 !== 0) {
  8082. tangents[dataIndex] = data[dataIndex] + value;
  8083. dataIndex++;
  8084. }
  8085. });
  8086. babylonMorphTarget.setTangents(tangents);
  8087. });
  8088. return Promise.all(promises).then(function () { });
  8089. };
  8090. GLTFLoader._LoadTransform = function (node, babylonNode) {
  8091. // Ignore the TRS of skinned nodes.
  8092. // See https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins (second implementation note)
  8093. if (node.skin != undefined) {
  8094. return;
  8095. }
  8096. var position = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero();
  8097. var rotation = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Quaternion.Identity();
  8098. var scaling = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.One();
  8099. if (node.matrix) {
  8100. var matrix = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.FromArray(node.matrix);
  8101. matrix.decompose(scaling, rotation, position);
  8102. }
  8103. else {
  8104. if (node.translation) {
  8105. position = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(node.translation);
  8106. }
  8107. if (node.rotation) {
  8108. rotation = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray(node.rotation);
  8109. }
  8110. if (node.scale) {
  8111. scaling = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(node.scale);
  8112. }
  8113. }
  8114. babylonNode.position = position;
  8115. babylonNode.rotationQuaternion = rotation;
  8116. babylonNode.scaling = scaling;
  8117. };
  8118. GLTFLoader.prototype._loadSkinAsync = function (context, node, skin, assign) {
  8119. var _this = this;
  8120. var extensionPromise = this._extensionsLoadSkinAsync(context, node, skin);
  8121. if (extensionPromise) {
  8122. return extensionPromise;
  8123. }
  8124. if (skin._data) {
  8125. assign(skin._data.babylonSkeleton);
  8126. return skin._data.promise;
  8127. }
  8128. var skeletonId = "skeleton".concat(skin.index);
  8129. this._babylonScene._blockEntityCollection = !!this._assetContainer;
  8130. var babylonSkeleton = new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Skeleton(skin.name || skeletonId, skeletonId, this._babylonScene);
  8131. babylonSkeleton._parentContainer = this._assetContainer;
  8132. this._babylonScene._blockEntityCollection = false;
  8133. this._loadBones(context, skin, babylonSkeleton);
  8134. var promise = this._loadSkinInverseBindMatricesDataAsync(context, skin).then(function (inverseBindMatricesData) {
  8135. _this._updateBoneMatrices(babylonSkeleton, inverseBindMatricesData);
  8136. });
  8137. skin._data = {
  8138. babylonSkeleton: babylonSkeleton,
  8139. promise: promise,
  8140. };
  8141. assign(babylonSkeleton);
  8142. return promise;
  8143. };
  8144. GLTFLoader.prototype._loadBones = function (context, skin, babylonSkeleton) {
  8145. if (skin.skeleton == undefined || this._parent.alwaysComputeSkeletonRootNode) {
  8146. var rootNode = this._findSkeletonRootNode("".concat(context, "/joints"), skin.joints);
  8147. if (rootNode) {
  8148. if (skin.skeleton === undefined) {
  8149. skin.skeleton = rootNode.index;
  8150. }
  8151. else {
  8152. var isParent = function (a, b) {
  8153. for (; b.parent; b = b.parent) {
  8154. if (b.parent === a) {
  8155. return true;
  8156. }
  8157. }
  8158. return false;
  8159. };
  8160. var skeletonNode = ArrayItem.Get("".concat(context, "/skeleton"), this._gltf.nodes, skin.skeleton);
  8161. if (skeletonNode !== rootNode && !isParent(skeletonNode, rootNode)) {
  8162. core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, "/skeleton: Overriding with nearest common ancestor as skeleton node is not a common root"));
  8163. skin.skeleton = rootNode.index;
  8164. }
  8165. }
  8166. }
  8167. else {
  8168. core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, ": Failed to find common root"));
  8169. }
  8170. }
  8171. var babylonBones = {};
  8172. for (var _i = 0, _a = skin.joints; _i < _a.length; _i++) {
  8173. var index = _a[_i];
  8174. var node = ArrayItem.Get("".concat(context, "/joints/").concat(index), this._gltf.nodes, index);
  8175. this._loadBone(node, skin, babylonSkeleton, babylonBones);
  8176. }
  8177. };
  8178. GLTFLoader.prototype._findSkeletonRootNode = function (context, joints) {
  8179. if (joints.length === 0) {
  8180. return null;
  8181. }
  8182. var paths = {};
  8183. for (var _i = 0, joints_1 = joints; _i < joints_1.length; _i++) {
  8184. var index = joints_1[_i];
  8185. var path = new Array();
  8186. var node = ArrayItem.Get("".concat(context, "/").concat(index), this._gltf.nodes, index);
  8187. while (node.index !== -1) {
  8188. path.unshift(node);
  8189. node = node.parent;
  8190. }
  8191. paths[index] = path;
  8192. }
  8193. var rootNode = null;
  8194. for (var i = 0;; ++i) {
  8195. var path = paths[joints[0]];
  8196. if (i >= path.length) {
  8197. return rootNode;
  8198. }
  8199. var node = path[i];
  8200. for (var j = 1; j < joints.length; ++j) {
  8201. path = paths[joints[j]];
  8202. if (i >= path.length || node !== path[i]) {
  8203. return rootNode;
  8204. }
  8205. }
  8206. rootNode = node;
  8207. }
  8208. };
  8209. GLTFLoader.prototype._loadBone = function (node, skin, babylonSkeleton, babylonBones) {
  8210. var babylonBone = babylonBones[node.index];
  8211. if (babylonBone) {
  8212. return babylonBone;
  8213. }
  8214. var parentBabylonBone = null;
  8215. if (node.index !== skin.skeleton) {
  8216. if (node.parent && node.parent.index !== -1) {
  8217. parentBabylonBone = this._loadBone(node.parent, skin, babylonSkeleton, babylonBones);
  8218. }
  8219. else if (skin.skeleton !== undefined) {
  8220. core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("/skins/".concat(skin.index, "/skeleton: Skeleton node is not a common root"));
  8221. }
  8222. }
  8223. var boneIndex = skin.joints.indexOf(node.index);
  8224. babylonBone = new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Bone(node.name || "joint".concat(node.index), babylonSkeleton, parentBabylonBone, this._getNodeMatrix(node), null, null, boneIndex);
  8225. babylonBones[node.index] = babylonBone;
  8226. // Wait until the scene is loaded to ensure the transform nodes are loaded.
  8227. this._postSceneLoadActions.push(function () {
  8228. // Link the Babylon bone with the corresponding Babylon transform node.
  8229. // A glTF joint is a pointer to a glTF node in the glTF node hierarchy similar to Unity3D.
  8230. babylonBone.linkTransformNode(node._babylonTransformNode);
  8231. });
  8232. return babylonBone;
  8233. };
  8234. GLTFLoader.prototype._loadSkinInverseBindMatricesDataAsync = function (context, skin) {
  8235. if (skin.inverseBindMatrices == undefined) {
  8236. return Promise.resolve(null);
  8237. }
  8238. var accessor = ArrayItem.Get("".concat(context, "/inverseBindMatrices"), this._gltf.accessors, skin.inverseBindMatrices);
  8239. return this._loadFloatAccessorAsync("/accessors/".concat(accessor.index), accessor);
  8240. };
  8241. GLTFLoader.prototype._updateBoneMatrices = function (babylonSkeleton, inverseBindMatricesData) {
  8242. for (var _i = 0, _a = babylonSkeleton.bones; _i < _a.length; _i++) {
  8243. var babylonBone = _a[_i];
  8244. var baseMatrix = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.Identity();
  8245. var boneIndex = babylonBone._index;
  8246. if (inverseBindMatricesData && boneIndex !== -1) {
  8247. core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.FromArrayToRef(inverseBindMatricesData, boneIndex * 16, baseMatrix);
  8248. baseMatrix.invertToRef(baseMatrix);
  8249. }
  8250. var babylonParentBone = babylonBone.getParent();
  8251. if (babylonParentBone) {
  8252. baseMatrix.multiplyToRef(babylonParentBone.getInvertedAbsoluteTransform(), baseMatrix);
  8253. }
  8254. babylonBone.updateMatrix(baseMatrix, false, false);
  8255. babylonBone._updateDifferenceMatrix(undefined, false);
  8256. }
  8257. };
  8258. GLTFLoader.prototype._getNodeMatrix = function (node) {
  8259. return node.matrix
  8260. ? core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.FromArray(node.matrix)
  8261. : core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.Compose(node.scale ? core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(node.scale) : core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.One(), node.rotation ? core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray(node.rotation) : core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Quaternion.Identity(), node.translation ? core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(node.translation) : core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero());
  8262. };
  8263. /**
  8264. * Loads a glTF camera.
  8265. * @param context The context when loading the asset
  8266. * @param camera The glTF camera property
  8267. * @param assign A function called synchronously after parsing the glTF properties
  8268. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  8269. */
  8270. GLTFLoader.prototype.loadCameraAsync = function (context, camera, assign) {
  8271. if (assign === void 0) { assign = function () { }; }
  8272. var extensionPromise = this._extensionsLoadCameraAsync(context, camera, assign);
  8273. if (extensionPromise) {
  8274. return extensionPromise;
  8275. }
  8276. var promises = new Array();
  8277. this.logOpen("".concat(context, " ").concat(camera.name || ""));
  8278. this._babylonScene._blockEntityCollection = !!this._assetContainer;
  8279. var babylonCamera = new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.FreeCamera(camera.name || "camera".concat(camera.index), core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(), this._babylonScene, false);
  8280. babylonCamera._parentContainer = this._assetContainer;
  8281. this._babylonScene._blockEntityCollection = false;
  8282. babylonCamera.ignoreParentScaling = true;
  8283. babylonCamera.rotation = new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3(0, Math.PI, 0);
  8284. switch (camera.type) {
  8285. case "perspective" /* PERSPECTIVE */: {
  8286. var perspective = camera.perspective;
  8287. if (!perspective) {
  8288. throw new Error("".concat(context, ": Camera perspective properties are missing"));
  8289. }
  8290. babylonCamera.fov = perspective.yfov;
  8291. babylonCamera.minZ = perspective.znear;
  8292. babylonCamera.maxZ = perspective.zfar || 0;
  8293. break;
  8294. }
  8295. case "orthographic" /* ORTHOGRAPHIC */: {
  8296. if (!camera.orthographic) {
  8297. throw new Error("".concat(context, ": Camera orthographic properties are missing"));
  8298. }
  8299. babylonCamera.mode = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Camera.ORTHOGRAPHIC_CAMERA;
  8300. babylonCamera.orthoLeft = -camera.orthographic.xmag;
  8301. babylonCamera.orthoRight = camera.orthographic.xmag;
  8302. babylonCamera.orthoBottom = -camera.orthographic.ymag;
  8303. babylonCamera.orthoTop = camera.orthographic.ymag;
  8304. babylonCamera.minZ = camera.orthographic.znear;
  8305. babylonCamera.maxZ = camera.orthographic.zfar;
  8306. break;
  8307. }
  8308. default: {
  8309. throw new Error("".concat(context, ": Invalid camera type (").concat(camera.type, ")"));
  8310. }
  8311. }
  8312. GLTFLoader.AddPointerMetadata(babylonCamera, context);
  8313. this._parent.onCameraLoadedObservable.notifyObservers(babylonCamera);
  8314. assign(babylonCamera);
  8315. this.logClose();
  8316. return Promise.all(promises).then(function () {
  8317. return babylonCamera;
  8318. });
  8319. };
  8320. GLTFLoader.prototype._loadAnimationsAsync = function () {
  8321. var animations = this._gltf.animations;
  8322. if (!animations) {
  8323. return Promise.resolve();
  8324. }
  8325. var promises = new Array();
  8326. for (var index = 0; index < animations.length; index++) {
  8327. var animation = animations[index];
  8328. promises.push(this.loadAnimationAsync("/animations/".concat(animation.index), animation).then(function (animationGroup) {
  8329. // Delete the animation group if it ended up not having any animations in it.
  8330. if (animationGroup.targetedAnimations.length === 0) {
  8331. animationGroup.dispose();
  8332. }
  8333. }));
  8334. }
  8335. return Promise.all(promises).then(function () { });
  8336. };
  8337. /**
  8338. * Loads a glTF animation.
  8339. * @param context The context when loading the asset
  8340. * @param animation The glTF animation property
  8341. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  8342. */
  8343. GLTFLoader.prototype.loadAnimationAsync = function (context, animation) {
  8344. var promise = this._extensionsLoadAnimationAsync(context, animation);
  8345. if (promise) {
  8346. return promise;
  8347. }
  8348. this._babylonScene._blockEntityCollection = !!this._assetContainer;
  8349. var babylonAnimationGroup = new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.AnimationGroup(animation.name || "animation".concat(animation.index), this._babylonScene);
  8350. babylonAnimationGroup._parentContainer = this._assetContainer;
  8351. this._babylonScene._blockEntityCollection = false;
  8352. animation._babylonAnimationGroup = babylonAnimationGroup;
  8353. var promises = new Array();
  8354. ArrayItem.Assign(animation.channels);
  8355. ArrayItem.Assign(animation.samplers);
  8356. for (var _i = 0, _a = animation.channels; _i < _a.length; _i++) {
  8357. var channel = _a[_i];
  8358. promises.push(this._loadAnimationChannelAsync("".concat(context, "/channels/").concat(channel.index), context, animation, channel, babylonAnimationGroup));
  8359. }
  8360. return Promise.all(promises).then(function () {
  8361. babylonAnimationGroup.normalize(0);
  8362. return babylonAnimationGroup;
  8363. });
  8364. };
  8365. /**
  8366. * @hidden Loads a glTF animation channel.
  8367. * @param context The context when loading the asset
  8368. * @param animationContext The context of the animation when loading the asset
  8369. * @param animation The glTF animation property
  8370. * @param channel The glTF animation channel property
  8371. * @param babylonAnimationGroup The babylon animation group property
  8372. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  8373. * @returns A void promise when the channel load is complete
  8374. */
  8375. GLTFLoader.prototype._loadAnimationChannelAsync = function (context, animationContext, animation, channel, babylonAnimationGroup, animationTargetOverride) {
  8376. var _this = this;
  8377. if (animationTargetOverride === void 0) { animationTargetOverride = null; }
  8378. if (channel.target.node == undefined) {
  8379. return Promise.resolve();
  8380. }
  8381. var targetNode = ArrayItem.Get("".concat(context, "/target/node"), this._gltf.nodes, channel.target.node);
  8382. // Ignore animations that have no animation targets.
  8383. if ((channel.target.path === "weights" /* WEIGHTS */ && !targetNode._numMorphTargets) ||
  8384. (channel.target.path !== "weights" /* WEIGHTS */ && !targetNode._babylonTransformNode)) {
  8385. return Promise.resolve();
  8386. }
  8387. var sampler = ArrayItem.Get("".concat(context, "/sampler"), animation.samplers, channel.sampler);
  8388. return this._loadAnimationSamplerAsync("".concat(animationContext, "/samplers/").concat(channel.sampler), sampler).then(function (data) {
  8389. var targetPath;
  8390. var animationType;
  8391. switch (channel.target.path) {
  8392. case "translation" /* TRANSLATION */: {
  8393. targetPath = "position";
  8394. animationType = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_VECTOR3;
  8395. break;
  8396. }
  8397. case "rotation" /* ROTATION */: {
  8398. targetPath = "rotationQuaternion";
  8399. animationType = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_QUATERNION;
  8400. break;
  8401. }
  8402. case "scale" /* SCALE */: {
  8403. targetPath = "scaling";
  8404. animationType = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_VECTOR3;
  8405. break;
  8406. }
  8407. case "weights" /* WEIGHTS */: {
  8408. targetPath = "influence";
  8409. animationType = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT;
  8410. break;
  8411. }
  8412. default: {
  8413. throw new Error("".concat(context, "/target/path: Invalid value (").concat(channel.target.path, ")"));
  8414. }
  8415. }
  8416. var outputBufferOffset = 0;
  8417. var getNextOutputValue;
  8418. switch (targetPath) {
  8419. case "position": {
  8420. getNextOutputValue = function (scale) {
  8421. var value = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(data.output, outputBufferOffset).scaleInPlace(scale);
  8422. outputBufferOffset += 3;
  8423. return value;
  8424. };
  8425. break;
  8426. }
  8427. case "rotationQuaternion": {
  8428. getNextOutputValue = function (scale) {
  8429. var value = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray(data.output, outputBufferOffset).scaleInPlace(scale);
  8430. outputBufferOffset += 4;
  8431. return value;
  8432. };
  8433. break;
  8434. }
  8435. case "scaling": {
  8436. getNextOutputValue = function (scale) {
  8437. var value = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(data.output, outputBufferOffset).scaleInPlace(scale);
  8438. outputBufferOffset += 3;
  8439. return value;
  8440. };
  8441. break;
  8442. }
  8443. case "influence": {
  8444. getNextOutputValue = function (scale) {
  8445. var value = new Array(targetNode._numMorphTargets);
  8446. for (var i = 0; i < targetNode._numMorphTargets; i++) {
  8447. value[i] = data.output[outputBufferOffset++] * scale;
  8448. }
  8449. return value;
  8450. };
  8451. break;
  8452. }
  8453. }
  8454. var getNextKey;
  8455. switch (data.interpolation) {
  8456. case "STEP" /* STEP */: {
  8457. getNextKey = function (frameIndex) { return ({
  8458. frame: data.input[frameIndex] * _this.parent.targetFps,
  8459. value: getNextOutputValue(1),
  8460. interpolation: core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.AnimationKeyInterpolation.STEP,
  8461. }); };
  8462. break;
  8463. }
  8464. case "LINEAR" /* LINEAR */: {
  8465. getNextKey = function (frameIndex) { return ({
  8466. frame: data.input[frameIndex] * _this.parent.targetFps,
  8467. value: getNextOutputValue(1),
  8468. }); };
  8469. break;
  8470. }
  8471. case "CUBICSPLINE" /* CUBICSPLINE */: {
  8472. var invTargetFps_1 = 1 / _this.parent.targetFps;
  8473. getNextKey = function (frameIndex) { return ({
  8474. frame: data.input[frameIndex] * _this.parent.targetFps,
  8475. inTangent: getNextOutputValue(invTargetFps_1),
  8476. value: getNextOutputValue(1),
  8477. outTangent: getNextOutputValue(invTargetFps_1),
  8478. }); };
  8479. break;
  8480. }
  8481. }
  8482. var keys = new Array(data.input.length);
  8483. for (var frameIndex = 0; frameIndex < data.input.length; frameIndex++) {
  8484. keys[frameIndex] = getNextKey(frameIndex);
  8485. }
  8486. if (targetPath === "influence") {
  8487. var _loop_2 = function (targetIndex) {
  8488. var animationName = "".concat(babylonAnimationGroup.name, "_channel").concat(babylonAnimationGroup.targetedAnimations.length);
  8489. var babylonAnimation = new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Animation(animationName, targetPath, _this.parent.targetFps, animationType);
  8490. babylonAnimation.setKeys(keys.map(function (key) { return ({
  8491. frame: key.frame,
  8492. inTangent: key.inTangent ? key.inTangent[targetIndex] : undefined,
  8493. value: key.value[targetIndex],
  8494. outTangent: key.outTangent ? key.outTangent[targetIndex] : undefined,
  8495. }); }));
  8496. _this._forEachPrimitive(targetNode, function (babylonAbstractMesh) {
  8497. var babylonMesh = babylonAbstractMesh;
  8498. var morphTarget = babylonMesh.morphTargetManager.getTarget(targetIndex);
  8499. var babylonAnimationClone = babylonAnimation.clone();
  8500. morphTarget.animations.push(babylonAnimationClone);
  8501. babylonAnimationGroup.addTargetedAnimation(babylonAnimationClone, morphTarget);
  8502. });
  8503. };
  8504. for (var targetIndex = 0; targetIndex < targetNode._numMorphTargets; targetIndex++) {
  8505. _loop_2(targetIndex);
  8506. }
  8507. }
  8508. else {
  8509. var animationName = "".concat(babylonAnimationGroup.name, "_channel").concat(babylonAnimationGroup.targetedAnimations.length);
  8510. var babylonAnimation = new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Animation(animationName, targetPath, _this.parent.targetFps, animationType);
  8511. babylonAnimation.setKeys(keys);
  8512. if (animationTargetOverride != null && animationTargetOverride.animations != null) {
  8513. animationTargetOverride.animations.push(babylonAnimation);
  8514. babylonAnimationGroup.addTargetedAnimation(babylonAnimation, animationTargetOverride);
  8515. }
  8516. else {
  8517. targetNode._babylonTransformNode.animations.push(babylonAnimation);
  8518. babylonAnimationGroup.addTargetedAnimation(babylonAnimation, targetNode._babylonTransformNode);
  8519. }
  8520. }
  8521. });
  8522. };
  8523. GLTFLoader.prototype._loadAnimationSamplerAsync = function (context, sampler) {
  8524. if (sampler._data) {
  8525. return sampler._data;
  8526. }
  8527. var interpolation = sampler.interpolation || "LINEAR" /* LINEAR */;
  8528. switch (interpolation) {
  8529. case "STEP" /* STEP */:
  8530. case "LINEAR" /* LINEAR */:
  8531. case "CUBICSPLINE" /* CUBICSPLINE */: {
  8532. break;
  8533. }
  8534. default: {
  8535. throw new Error("".concat(context, "/interpolation: Invalid value (").concat(sampler.interpolation, ")"));
  8536. }
  8537. }
  8538. var inputAccessor = ArrayItem.Get("".concat(context, "/input"), this._gltf.accessors, sampler.input);
  8539. var outputAccessor = ArrayItem.Get("".concat(context, "/output"), this._gltf.accessors, sampler.output);
  8540. sampler._data = Promise.all([
  8541. this._loadFloatAccessorAsync("/accessors/".concat(inputAccessor.index), inputAccessor),
  8542. this._loadFloatAccessorAsync("/accessors/".concat(outputAccessor.index), outputAccessor),
  8543. ]).then(function (_a) {
  8544. var inputData = _a[0], outputData = _a[1];
  8545. return {
  8546. input: inputData,
  8547. interpolation: interpolation,
  8548. output: outputData,
  8549. };
  8550. });
  8551. return sampler._data;
  8552. };
  8553. /**
  8554. * Loads a glTF buffer.
  8555. * @param context The context when loading the asset
  8556. * @param buffer The glTF buffer property
  8557. * @param byteOffset The byte offset to use
  8558. * @param byteLength The byte length to use
  8559. * @returns A promise that resolves with the loaded data when the load is complete
  8560. */
  8561. GLTFLoader.prototype.loadBufferAsync = function (context, buffer, byteOffset, byteLength) {
  8562. var extensionPromise = this._extensionsLoadBufferAsync(context, buffer, byteOffset, byteLength);
  8563. if (extensionPromise) {
  8564. return extensionPromise;
  8565. }
  8566. if (!buffer._data) {
  8567. if (buffer.uri) {
  8568. buffer._data = this.loadUriAsync("".concat(context, "/uri"), buffer, buffer.uri);
  8569. }
  8570. else {
  8571. if (!this._bin) {
  8572. throw new Error("".concat(context, ": Uri is missing or the binary glTF is missing its binary chunk"));
  8573. }
  8574. buffer._data = this._bin.readAsync(0, buffer.byteLength);
  8575. }
  8576. }
  8577. return buffer._data.then(function (data) {
  8578. try {
  8579. return new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength);
  8580. }
  8581. catch (e) {
  8582. throw new Error("".concat(context, ": ").concat(e.message));
  8583. }
  8584. });
  8585. };
  8586. /**
  8587. * Loads a glTF buffer view.
  8588. * @param context The context when loading the asset
  8589. * @param bufferView The glTF buffer view property
  8590. * @returns A promise that resolves with the loaded data when the load is complete
  8591. */
  8592. GLTFLoader.prototype.loadBufferViewAsync = function (context, bufferView) {
  8593. var extensionPromise = this._extensionsLoadBufferViewAsync(context, bufferView);
  8594. if (extensionPromise) {
  8595. return extensionPromise;
  8596. }
  8597. if (bufferView._data) {
  8598. return bufferView._data;
  8599. }
  8600. var buffer = ArrayItem.Get("".concat(context, "/buffer"), this._gltf.buffers, bufferView.buffer);
  8601. bufferView._data = this.loadBufferAsync("/buffers/".concat(buffer.index), buffer, bufferView.byteOffset || 0, bufferView.byteLength);
  8602. return bufferView._data;
  8603. };
  8604. GLTFLoader.prototype._loadAccessorAsync = function (context, accessor, constructor) {
  8605. var _this = this;
  8606. if (accessor._data) {
  8607. return accessor._data;
  8608. }
  8609. var numComponents = GLTFLoader._GetNumComponents(context, accessor.type);
  8610. var byteStride = numComponents * core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.GetTypeByteLength(accessor.componentType);
  8611. var length = numComponents * accessor.count;
  8612. if (accessor.bufferView == undefined) {
  8613. accessor._data = Promise.resolve(new constructor(length));
  8614. }
  8615. else {
  8616. var bufferView_1 = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, accessor.bufferView);
  8617. accessor._data = this.loadBufferViewAsync("/bufferViews/".concat(bufferView_1.index), bufferView_1).then(function (data) {
  8618. if (accessor.componentType === 5126 /* FLOAT */ && !accessor.normalized && (!bufferView_1.byteStride || bufferView_1.byteStride === byteStride)) {
  8619. return GLTFLoader._GetTypedArray(context, accessor.componentType, data, accessor.byteOffset, length);
  8620. }
  8621. else {
  8622. var typedArray_1 = new constructor(length);
  8623. core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ForEach(data, accessor.byteOffset || 0, bufferView_1.byteStride || byteStride, numComponents, accessor.componentType, typedArray_1.length, accessor.normalized || false, function (value, index) {
  8624. typedArray_1[index] = value;
  8625. });
  8626. return typedArray_1;
  8627. }
  8628. });
  8629. }
  8630. if (accessor.sparse) {
  8631. var sparse_1 = accessor.sparse;
  8632. accessor._data = accessor._data.then(function (data) {
  8633. var typedArray = data;
  8634. var indicesBufferView = ArrayItem.Get("".concat(context, "/sparse/indices/bufferView"), _this._gltf.bufferViews, sparse_1.indices.bufferView);
  8635. var valuesBufferView = ArrayItem.Get("".concat(context, "/sparse/values/bufferView"), _this._gltf.bufferViews, sparse_1.values.bufferView);
  8636. return Promise.all([
  8637. _this.loadBufferViewAsync("/bufferViews/".concat(indicesBufferView.index), indicesBufferView),
  8638. _this.loadBufferViewAsync("/bufferViews/".concat(valuesBufferView.index), valuesBufferView),
  8639. ]).then(function (_a) {
  8640. var indicesData = _a[0], valuesData = _a[1];
  8641. var indices = GLTFLoader._GetTypedArray("".concat(context, "/sparse/indices"), sparse_1.indices.componentType, indicesData, sparse_1.indices.byteOffset, sparse_1.count);
  8642. var sparseLength = numComponents * sparse_1.count;
  8643. var values;
  8644. if (accessor.componentType === 5126 /* FLOAT */ && !accessor.normalized) {
  8645. values = GLTFLoader._GetTypedArray("".concat(context, "/sparse/values"), accessor.componentType, valuesData, sparse_1.values.byteOffset, sparseLength);
  8646. }
  8647. else {
  8648. var sparseData = GLTFLoader._GetTypedArray("".concat(context, "/sparse/values"), accessor.componentType, valuesData, sparse_1.values.byteOffset, sparseLength);
  8649. values = new constructor(sparseLength);
  8650. core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ForEach(sparseData, 0, byteStride, numComponents, accessor.componentType, values.length, accessor.normalized || false, function (value, index) {
  8651. values[index] = value;
  8652. });
  8653. }
  8654. var valuesIndex = 0;
  8655. for (var indicesIndex = 0; indicesIndex < indices.length; indicesIndex++) {
  8656. var dataIndex = indices[indicesIndex] * numComponents;
  8657. for (var componentIndex = 0; componentIndex < numComponents; componentIndex++) {
  8658. typedArray[dataIndex++] = values[valuesIndex++];
  8659. }
  8660. }
  8661. return typedArray;
  8662. });
  8663. });
  8664. }
  8665. return accessor._data;
  8666. };
  8667. /**
  8668. * @param context
  8669. * @param accessor
  8670. * @hidden
  8671. */
  8672. GLTFLoader.prototype._loadFloatAccessorAsync = function (context, accessor) {
  8673. return this._loadAccessorAsync(context, accessor, Float32Array);
  8674. };
  8675. GLTFLoader.prototype._loadIndicesAccessorAsync = function (context, accessor) {
  8676. if (accessor.type !== "SCALAR" /* SCALAR */) {
  8677. throw new Error("".concat(context, "/type: Invalid value ").concat(accessor.type));
  8678. }
  8679. if (accessor.componentType !== 5121 /* UNSIGNED_BYTE */ &&
  8680. accessor.componentType !== 5123 /* UNSIGNED_SHORT */ &&
  8681. accessor.componentType !== 5125 /* UNSIGNED_INT */) {
  8682. throw new Error("".concat(context, "/componentType: Invalid value ").concat(accessor.componentType));
  8683. }
  8684. if (accessor._data) {
  8685. return accessor._data;
  8686. }
  8687. if (accessor.sparse) {
  8688. var constructor = GLTFLoader._GetTypedArrayConstructor("".concat(context, "/componentType"), accessor.componentType);
  8689. accessor._data = this._loadAccessorAsync(context, accessor, constructor);
  8690. }
  8691. else {
  8692. var bufferView = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, accessor.bufferView);
  8693. accessor._data = this.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) {
  8694. return GLTFLoader._GetTypedArray(context, accessor.componentType, data, accessor.byteOffset, accessor.count);
  8695. });
  8696. }
  8697. return accessor._data;
  8698. };
  8699. GLTFLoader.prototype._loadVertexBufferViewAsync = function (bufferView, kind) {
  8700. var _this = this;
  8701. if (bufferView._babylonBuffer) {
  8702. return bufferView._babylonBuffer;
  8703. }
  8704. bufferView._babylonBuffer = this.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) {
  8705. return new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Buffer(_this._babylonScene.getEngine(), data, false);
  8706. });
  8707. return bufferView._babylonBuffer;
  8708. };
  8709. GLTFLoader.prototype._loadVertexAccessorAsync = function (context, accessor, kind) {
  8710. var _this = this;
  8711. var _a;
  8712. if ((_a = accessor._babylonVertexBuffer) === null || _a === void 0 ? void 0 : _a[kind]) {
  8713. return accessor._babylonVertexBuffer[kind];
  8714. }
  8715. if (!accessor._babylonVertexBuffer) {
  8716. accessor._babylonVertexBuffer = {};
  8717. }
  8718. if (accessor.sparse) {
  8719. accessor._babylonVertexBuffer[kind] = this._loadFloatAccessorAsync(context, accessor).then(function (data) {
  8720. return new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer(_this._babylonScene.getEngine(), data, kind, false);
  8721. });
  8722. }
  8723. // Load joint indices as a float array since the shaders expect float data but glTF uses unsigned byte/short.
  8724. // This prevents certain platforms (e.g. D3D) from having to convert the data to float on the fly.
  8725. else if (kind === core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesKind || kind === core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesExtraKind) {
  8726. accessor._babylonVertexBuffer[kind] = this._loadFloatAccessorAsync(context, accessor).then(function (data) {
  8727. return new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer(_this._babylonScene.getEngine(), data, kind, false);
  8728. });
  8729. }
  8730. else {
  8731. var bufferView_2 = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, accessor.bufferView);
  8732. accessor._babylonVertexBuffer[kind] = this._loadVertexBufferViewAsync(bufferView_2, kind).then(function (babylonBuffer) {
  8733. var size = GLTFLoader._GetNumComponents(context, accessor.type);
  8734. return new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer(_this._babylonScene.getEngine(), babylonBuffer, kind, false, false, bufferView_2.byteStride, false, accessor.byteOffset, size, accessor.componentType, accessor.normalized, true, 1, true);
  8735. });
  8736. }
  8737. return accessor._babylonVertexBuffer[kind];
  8738. };
  8739. GLTFLoader.prototype._loadMaterialMetallicRoughnessPropertiesAsync = function (context, properties, babylonMaterial) {
  8740. if (!(babylonMaterial instanceof core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) {
  8741. throw new Error("".concat(context, ": Material type not supported"));
  8742. }
  8743. var promises = new Array();
  8744. if (properties) {
  8745. if (properties.baseColorFactor) {
  8746. babylonMaterial.albedoColor = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.baseColorFactor);
  8747. babylonMaterial.alpha = properties.baseColorFactor[3];
  8748. }
  8749. else {
  8750. babylonMaterial.albedoColor = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Color3.White();
  8751. }
  8752. babylonMaterial.metallic = properties.metallicFactor == undefined ? 1 : properties.metallicFactor;
  8753. babylonMaterial.roughness = properties.roughnessFactor == undefined ? 1 : properties.roughnessFactor;
  8754. if (properties.baseColorTexture) {
  8755. promises.push(this.loadTextureInfoAsync("".concat(context, "/baseColorTexture"), properties.baseColorTexture, function (texture) {
  8756. texture.name = "".concat(babylonMaterial.name, " (Base Color)");
  8757. babylonMaterial.albedoTexture = texture;
  8758. }));
  8759. }
  8760. if (properties.metallicRoughnessTexture) {
  8761. properties.metallicRoughnessTexture.nonColorData = true;
  8762. promises.push(this.loadTextureInfoAsync("".concat(context, "/metallicRoughnessTexture"), properties.metallicRoughnessTexture, function (texture) {
  8763. texture.name = "".concat(babylonMaterial.name, " (Metallic Roughness)");
  8764. babylonMaterial.metallicTexture = texture;
  8765. }));
  8766. babylonMaterial.useMetallnessFromMetallicTextureBlue = true;
  8767. babylonMaterial.useRoughnessFromMetallicTextureGreen = true;
  8768. babylonMaterial.useRoughnessFromMetallicTextureAlpha = false;
  8769. }
  8770. }
  8771. return Promise.all(promises).then(function () { });
  8772. };
  8773. /**
  8774. * @param context
  8775. * @param material
  8776. * @param babylonMesh
  8777. * @param babylonDrawMode
  8778. * @param assign
  8779. * @hidden
  8780. */
  8781. GLTFLoader.prototype._loadMaterialAsync = function (context, material, babylonMesh, babylonDrawMode, assign) {
  8782. if (assign === void 0) { assign = function () { }; }
  8783. var extensionPromise = this._extensionsLoadMaterialAsync(context, material, babylonMesh, babylonDrawMode, assign);
  8784. if (extensionPromise) {
  8785. return extensionPromise;
  8786. }
  8787. material._data = material._data || {};
  8788. var babylonData = material._data[babylonDrawMode];
  8789. if (!babylonData) {
  8790. this.logOpen("".concat(context, " ").concat(material.name || ""));
  8791. var babylonMaterial = this.createMaterial(context, material, babylonDrawMode);
  8792. babylonData = {
  8793. babylonMaterial: babylonMaterial,
  8794. babylonMeshes: [],
  8795. promise: this.loadMaterialPropertiesAsync(context, material, babylonMaterial),
  8796. };
  8797. material._data[babylonDrawMode] = babylonData;
  8798. GLTFLoader.AddPointerMetadata(babylonMaterial, context);
  8799. this._parent.onMaterialLoadedObservable.notifyObservers(babylonMaterial);
  8800. this.logClose();
  8801. }
  8802. if (babylonMesh) {
  8803. babylonData.babylonMeshes.push(babylonMesh);
  8804. babylonMesh.onDisposeObservable.addOnce(function () {
  8805. var index = babylonData.babylonMeshes.indexOf(babylonMesh);
  8806. if (index !== -1) {
  8807. babylonData.babylonMeshes.splice(index, 1);
  8808. }
  8809. });
  8810. }
  8811. assign(babylonData.babylonMaterial);
  8812. return babylonData.promise.then(function () {
  8813. return babylonData.babylonMaterial;
  8814. });
  8815. };
  8816. GLTFLoader.prototype._createDefaultMaterial = function (name, babylonDrawMode) {
  8817. this._babylonScene._blockEntityCollection = !!this._assetContainer;
  8818. var babylonMaterial = new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial(name, this._babylonScene);
  8819. babylonMaterial._parentContainer = this._assetContainer;
  8820. this._babylonScene._blockEntityCollection = false;
  8821. // Moved to mesh so user can change materials on gltf meshes: babylonMaterial.sideOrientation = this._babylonScene.useRightHandedSystem ? Material.CounterClockWiseSideOrientation : Material.ClockWiseSideOrientation;
  8822. babylonMaterial.fillMode = babylonDrawMode;
  8823. babylonMaterial.enableSpecularAntiAliasing = true;
  8824. babylonMaterial.useRadianceOverAlpha = !this._parent.transparencyAsCoverage;
  8825. babylonMaterial.useSpecularOverAlpha = !this._parent.transparencyAsCoverage;
  8826. babylonMaterial.transparencyMode = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial.PBRMATERIAL_OPAQUE;
  8827. babylonMaterial.metallic = 1;
  8828. babylonMaterial.roughness = 1;
  8829. return babylonMaterial;
  8830. };
  8831. /**
  8832. * Creates a Babylon material from a glTF material.
  8833. * @param context The context when loading the asset
  8834. * @param material The glTF material property
  8835. * @param babylonDrawMode The draw mode for the Babylon material
  8836. * @returns The Babylon material
  8837. */
  8838. GLTFLoader.prototype.createMaterial = function (context, material, babylonDrawMode) {
  8839. var extensionPromise = this._extensionsCreateMaterial(context, material, babylonDrawMode);
  8840. if (extensionPromise) {
  8841. return extensionPromise;
  8842. }
  8843. var name = material.name || "material".concat(material.index);
  8844. var babylonMaterial = this._createDefaultMaterial(name, babylonDrawMode);
  8845. return babylonMaterial;
  8846. };
  8847. /**
  8848. * Loads properties from a glTF material into a Babylon material.
  8849. * @param context The context when loading the asset
  8850. * @param material The glTF material property
  8851. * @param babylonMaterial The Babylon material
  8852. * @returns A promise that resolves when the load is complete
  8853. */
  8854. GLTFLoader.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
  8855. var extensionPromise = this._extensionsLoadMaterialPropertiesAsync(context, material, babylonMaterial);
  8856. if (extensionPromise) {
  8857. return extensionPromise;
  8858. }
  8859. var promises = new Array();
  8860. promises.push(this.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));
  8861. if (material.pbrMetallicRoughness) {
  8862. promises.push(this._loadMaterialMetallicRoughnessPropertiesAsync("".concat(context, "/pbrMetallicRoughness"), material.pbrMetallicRoughness, babylonMaterial));
  8863. }
  8864. this.loadMaterialAlphaProperties(context, material, babylonMaterial);
  8865. return Promise.all(promises).then(function () { });
  8866. };
  8867. /**
  8868. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  8869. * @param context The context when loading the asset
  8870. * @param material The glTF material property
  8871. * @param babylonMaterial The Babylon material
  8872. * @returns A promise that resolves when the load is complete
  8873. */
  8874. GLTFLoader.prototype.loadMaterialBasePropertiesAsync = function (context, material, babylonMaterial) {
  8875. if (!(babylonMaterial instanceof core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) {
  8876. throw new Error("".concat(context, ": Material type not supported"));
  8877. }
  8878. var promises = new Array();
  8879. babylonMaterial.emissiveColor = material.emissiveFactor ? core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(material.emissiveFactor) : new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Color3(0, 0, 0);
  8880. if (material.doubleSided) {
  8881. babylonMaterial.backFaceCulling = false;
  8882. babylonMaterial.twoSidedLighting = true;
  8883. }
  8884. if (material.normalTexture) {
  8885. material.normalTexture.nonColorData = true;
  8886. promises.push(this.loadTextureInfoAsync("".concat(context, "/normalTexture"), material.normalTexture, function (texture) {
  8887. texture.name = "".concat(babylonMaterial.name, " (Normal)");
  8888. babylonMaterial.bumpTexture = texture;
  8889. }));
  8890. babylonMaterial.invertNormalMapX = !this._babylonScene.useRightHandedSystem;
  8891. babylonMaterial.invertNormalMapY = this._babylonScene.useRightHandedSystem;
  8892. if (material.normalTexture.scale != undefined) {
  8893. babylonMaterial.bumpTexture.level = material.normalTexture.scale;
  8894. }
  8895. babylonMaterial.forceIrradianceInFragment = true;
  8896. }
  8897. if (material.occlusionTexture) {
  8898. material.occlusionTexture.nonColorData = true;
  8899. promises.push(this.loadTextureInfoAsync("".concat(context, "/occlusionTexture"), material.occlusionTexture, function (texture) {
  8900. texture.name = "".concat(babylonMaterial.name, " (Occlusion)");
  8901. babylonMaterial.ambientTexture = texture;
  8902. }));
  8903. babylonMaterial.useAmbientInGrayScale = true;
  8904. if (material.occlusionTexture.strength != undefined) {
  8905. babylonMaterial.ambientTextureStrength = material.occlusionTexture.strength;
  8906. }
  8907. }
  8908. if (material.emissiveTexture) {
  8909. promises.push(this.loadTextureInfoAsync("".concat(context, "/emissiveTexture"), material.emissiveTexture, function (texture) {
  8910. texture.name = "".concat(babylonMaterial.name, " (Emissive)");
  8911. babylonMaterial.emissiveTexture = texture;
  8912. }));
  8913. }
  8914. return Promise.all(promises).then(function () { });
  8915. };
  8916. /**
  8917. * Loads the alpha properties from a glTF material into a Babylon material.
  8918. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  8919. * @param context The context when loading the asset
  8920. * @param material The glTF material property
  8921. * @param babylonMaterial The Babylon material
  8922. */
  8923. GLTFLoader.prototype.loadMaterialAlphaProperties = function (context, material, babylonMaterial) {
  8924. if (!(babylonMaterial instanceof core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) {
  8925. throw new Error("".concat(context, ": Material type not supported"));
  8926. }
  8927. var alphaMode = material.alphaMode || "OPAQUE" /* OPAQUE */;
  8928. switch (alphaMode) {
  8929. case "OPAQUE" /* OPAQUE */: {
  8930. babylonMaterial.transparencyMode = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial.PBRMATERIAL_OPAQUE;
  8931. break;
  8932. }
  8933. case "MASK" /* MASK */: {
  8934. babylonMaterial.transparencyMode = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial.PBRMATERIAL_ALPHATEST;
  8935. babylonMaterial.alphaCutOff = material.alphaCutoff == undefined ? 0.5 : material.alphaCutoff;
  8936. if (babylonMaterial.albedoTexture) {
  8937. babylonMaterial.albedoTexture.hasAlpha = true;
  8938. }
  8939. break;
  8940. }
  8941. case "BLEND" /* BLEND */: {
  8942. babylonMaterial.transparencyMode = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial.PBRMATERIAL_ALPHABLEND;
  8943. if (babylonMaterial.albedoTexture) {
  8944. babylonMaterial.albedoTexture.hasAlpha = true;
  8945. babylonMaterial.useAlphaFromAlbedoTexture = true;
  8946. }
  8947. break;
  8948. }
  8949. default: {
  8950. throw new Error("".concat(context, "/alphaMode: Invalid value (").concat(material.alphaMode, ")"));
  8951. }
  8952. }
  8953. };
  8954. /**
  8955. * Loads a glTF texture info.
  8956. * @param context The context when loading the asset
  8957. * @param textureInfo The glTF texture info property
  8958. * @param assign A function called synchronously after parsing the glTF properties
  8959. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  8960. */
  8961. GLTFLoader.prototype.loadTextureInfoAsync = function (context, textureInfo, assign) {
  8962. var _this = this;
  8963. if (assign === void 0) { assign = function () { }; }
  8964. var extensionPromise = this._extensionsLoadTextureInfoAsync(context, textureInfo, assign);
  8965. if (extensionPromise) {
  8966. return extensionPromise;
  8967. }
  8968. this.logOpen("".concat(context));
  8969. if (textureInfo.texCoord >= 6) {
  8970. throw new Error("".concat(context, "/texCoord: Invalid value (").concat(textureInfo.texCoord, ")"));
  8971. }
  8972. var texture = ArrayItem.Get("".concat(context, "/index"), this._gltf.textures, textureInfo.index);
  8973. texture._textureInfo = textureInfo;
  8974. var promise = this._loadTextureAsync("/textures/".concat(textureInfo.index), texture, function (babylonTexture) {
  8975. babylonTexture.coordinatesIndex = textureInfo.texCoord || 0;
  8976. GLTFLoader.AddPointerMetadata(babylonTexture, context);
  8977. _this._parent.onTextureLoadedObservable.notifyObservers(babylonTexture);
  8978. assign(babylonTexture);
  8979. });
  8980. this.logClose();
  8981. return promise;
  8982. };
  8983. /**
  8984. * @param context
  8985. * @param texture
  8986. * @param assign
  8987. * @hidden
  8988. */
  8989. GLTFLoader.prototype._loadTextureAsync = function (context, texture, assign) {
  8990. if (assign === void 0) { assign = function () { }; }
  8991. var extensionPromise = this._extensionsLoadTextureAsync(context, texture, assign);
  8992. if (extensionPromise) {
  8993. return extensionPromise;
  8994. }
  8995. this.logOpen("".concat(context, " ").concat(texture.name || ""));
  8996. var sampler = texture.sampler == undefined ? GLTFLoader.DefaultSampler : ArrayItem.Get("".concat(context, "/sampler"), this._gltf.samplers, texture.sampler);
  8997. var image = ArrayItem.Get("".concat(context, "/source"), this._gltf.images, texture.source);
  8998. var promise = this._createTextureAsync(context, sampler, image, assign, undefined, !texture._textureInfo.nonColorData);
  8999. this.logClose();
  9000. return promise;
  9001. };
  9002. /**
  9003. * @param context
  9004. * @param sampler
  9005. * @param image
  9006. * @param assign
  9007. * @param textureLoaderOptions
  9008. * @param useSRGBBuffer
  9009. * @hidden
  9010. */
  9011. GLTFLoader.prototype._createTextureAsync = function (context, sampler, image, assign, textureLoaderOptions, useSRGBBuffer) {
  9012. var _this = this;
  9013. if (assign === void 0) { assign = function () { }; }
  9014. var samplerData = this._loadSampler("/samplers/".concat(sampler.index), sampler);
  9015. var promises = new Array();
  9016. var deferred = new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Deferred();
  9017. this._babylonScene._blockEntityCollection = !!this._assetContainer;
  9018. var textureCreationOptions = {
  9019. noMipmap: samplerData.noMipMaps,
  9020. invertY: false,
  9021. samplingMode: samplerData.samplingMode,
  9022. onLoad: function () {
  9023. if (!_this._disposed) {
  9024. deferred.resolve();
  9025. }
  9026. },
  9027. onError: function (message, exception) {
  9028. if (!_this._disposed) {
  9029. deferred.reject(new Error("".concat(context, ": ").concat(exception && exception.message ? exception.message : message || "Failed to load texture")));
  9030. }
  9031. },
  9032. mimeType: image.mimeType,
  9033. loaderOptions: textureLoaderOptions,
  9034. useSRGBBuffer: !!useSRGBBuffer && this._parent.useSRGBBuffers,
  9035. };
  9036. var babylonTexture = new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture(null, this._babylonScene, textureCreationOptions);
  9037. babylonTexture._parentContainer = this._assetContainer;
  9038. this._babylonScene._blockEntityCollection = false;
  9039. promises.push(deferred.promise);
  9040. promises.push(this.loadImageAsync("/images/".concat(image.index), image).then(function (data) {
  9041. var name = image.uri || "".concat(_this._fileName, "#image").concat(image.index);
  9042. var dataUrl = "data:".concat(_this._uniqueRootUrl).concat(name);
  9043. babylonTexture.updateURL(dataUrl, data);
  9044. }));
  9045. babylonTexture.wrapU = samplerData.wrapU;
  9046. babylonTexture.wrapV = samplerData.wrapV;
  9047. assign(babylonTexture);
  9048. return Promise.all(promises).then(function () {
  9049. return babylonTexture;
  9050. });
  9051. };
  9052. GLTFLoader.prototype._loadSampler = function (context, sampler) {
  9053. if (!sampler._data) {
  9054. sampler._data = {
  9055. noMipMaps: sampler.minFilter === 9728 /* NEAREST */ || sampler.minFilter === 9729 /* LINEAR */,
  9056. samplingMode: GLTFLoader._GetTextureSamplingMode(context, sampler),
  9057. wrapU: GLTFLoader._GetTextureWrapMode("".concat(context, "/wrapS"), sampler.wrapS),
  9058. wrapV: GLTFLoader._GetTextureWrapMode("".concat(context, "/wrapT"), sampler.wrapT),
  9059. };
  9060. }
  9061. return sampler._data;
  9062. };
  9063. /**
  9064. * Loads a glTF image.
  9065. * @param context The context when loading the asset
  9066. * @param image The glTF image property
  9067. * @returns A promise that resolves with the loaded data when the load is complete
  9068. */
  9069. GLTFLoader.prototype.loadImageAsync = function (context, image) {
  9070. if (!image._data) {
  9071. this.logOpen("".concat(context, " ").concat(image.name || ""));
  9072. if (image.uri) {
  9073. image._data = this.loadUriAsync("".concat(context, "/uri"), image, image.uri);
  9074. }
  9075. else {
  9076. var bufferView = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, image.bufferView);
  9077. image._data = this.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView);
  9078. }
  9079. this.logClose();
  9080. }
  9081. return image._data;
  9082. };
  9083. /**
  9084. * Loads a glTF uri.
  9085. * @param context The context when loading the asset
  9086. * @param property The glTF property associated with the uri
  9087. * @param uri The base64 or relative uri
  9088. * @returns A promise that resolves with the loaded data when the load is complete
  9089. */
  9090. GLTFLoader.prototype.loadUriAsync = function (context, property, uri) {
  9091. var _this = this;
  9092. var extensionPromise = this._extensionsLoadUriAsync(context, property, uri);
  9093. if (extensionPromise) {
  9094. return extensionPromise;
  9095. }
  9096. if (!GLTFLoader._ValidateUri(uri)) {
  9097. throw new Error("".concat(context, ": '").concat(uri, "' is invalid"));
  9098. }
  9099. if ((0,core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.IsBase64DataUrl)(uri)) {
  9100. var data = new Uint8Array((0,core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.DecodeBase64UrlToBinary)(uri));
  9101. this.log("".concat(context, ": Decoded ").concat(uri.substr(0, 64), "... (").concat(data.length, " bytes)"));
  9102. return Promise.resolve(data);
  9103. }
  9104. this.log("".concat(context, ": Loading ").concat(uri));
  9105. return this._parent.preprocessUrlAsync(this._rootUrl + uri).then(function (url) {
  9106. return new Promise(function (resolve, reject) {
  9107. _this._parent._loadFile(_this._babylonScene, url, function (data) {
  9108. if (!_this._disposed) {
  9109. _this.log("".concat(context, ": Loaded ").concat(uri, " (").concat(data.byteLength, " bytes)"));
  9110. resolve(new Uint8Array(data));
  9111. }
  9112. }, true, function (request) {
  9113. reject(new core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.LoadFileError("".concat(context, ": Failed to load '").concat(uri, "'").concat(request ? ": " + request.status + " " + request.statusText : ""), request));
  9114. });
  9115. });
  9116. });
  9117. };
  9118. /**
  9119. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  9120. * @param babylonObject the Babylon object with metadata
  9121. * @param babylonObject.metadata
  9122. * @param pointer the JSON pointer
  9123. */
  9124. GLTFLoader.AddPointerMetadata = function (babylonObject, pointer) {
  9125. var metadata = (babylonObject.metadata = babylonObject.metadata || {});
  9126. var gltf = (metadata.gltf = metadata.gltf || {});
  9127. var pointers = (gltf.pointers = gltf.pointers || []);
  9128. pointers.push(pointer);
  9129. };
  9130. GLTFLoader._GetTextureWrapMode = function (context, mode) {
  9131. // Set defaults if undefined
  9132. mode = mode == undefined ? 10497 /* REPEAT */ : mode;
  9133. switch (mode) {
  9134. case 33071 /* CLAMP_TO_EDGE */:
  9135. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.CLAMP_ADDRESSMODE;
  9136. case 33648 /* MIRRORED_REPEAT */:
  9137. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.MIRROR_ADDRESSMODE;
  9138. case 10497 /* REPEAT */:
  9139. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.WRAP_ADDRESSMODE;
  9140. default:
  9141. core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, ": Invalid value (").concat(mode, ")"));
  9142. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.WRAP_ADDRESSMODE;
  9143. }
  9144. };
  9145. GLTFLoader._GetTextureSamplingMode = function (context, sampler) {
  9146. // Set defaults if undefined
  9147. var magFilter = sampler.magFilter == undefined ? 9729 /* LINEAR */ : sampler.magFilter;
  9148. var minFilter = sampler.minFilter == undefined ? 9987 /* LINEAR_MIPMAP_LINEAR */ : sampler.minFilter;
  9149. if (magFilter === 9729 /* LINEAR */) {
  9150. switch (minFilter) {
  9151. case 9728 /* NEAREST */:
  9152. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_NEAREST;
  9153. case 9729 /* LINEAR */:
  9154. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR;
  9155. case 9984 /* NEAREST_MIPMAP_NEAREST */:
  9156. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_NEAREST_MIPNEAREST;
  9157. case 9985 /* LINEAR_MIPMAP_NEAREST */:
  9158. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR_MIPNEAREST;
  9159. case 9986 /* NEAREST_MIPMAP_LINEAR */:
  9160. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_NEAREST_MIPLINEAR;
  9161. case 9987 /* LINEAR_MIPMAP_LINEAR */:
  9162. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR_MIPLINEAR;
  9163. default:
  9164. core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, "/minFilter: Invalid value (").concat(minFilter, ")"));
  9165. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR_MIPLINEAR;
  9166. }
  9167. }
  9168. else {
  9169. if (magFilter !== 9728 /* NEAREST */) {
  9170. core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, "/magFilter: Invalid value (").concat(magFilter, ")"));
  9171. }
  9172. switch (minFilter) {
  9173. case 9728 /* NEAREST */:
  9174. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST;
  9175. case 9729 /* LINEAR */:
  9176. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_LINEAR;
  9177. case 9984 /* NEAREST_MIPMAP_NEAREST */:
  9178. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST_MIPNEAREST;
  9179. case 9985 /* LINEAR_MIPMAP_NEAREST */:
  9180. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_LINEAR_MIPNEAREST;
  9181. case 9986 /* NEAREST_MIPMAP_LINEAR */:
  9182. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST_MIPLINEAR;
  9183. case 9987 /* LINEAR_MIPMAP_LINEAR */:
  9184. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_LINEAR_MIPLINEAR;
  9185. default:
  9186. core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, "/minFilter: Invalid value (").concat(minFilter, ")"));
  9187. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST_MIPNEAREST;
  9188. }
  9189. }
  9190. };
  9191. GLTFLoader._GetTypedArrayConstructor = function (context, componentType) {
  9192. switch (componentType) {
  9193. case 5120 /* BYTE */:
  9194. return Int8Array;
  9195. case 5121 /* UNSIGNED_BYTE */:
  9196. return Uint8Array;
  9197. case 5122 /* SHORT */:
  9198. return Int16Array;
  9199. case 5123 /* UNSIGNED_SHORT */:
  9200. return Uint16Array;
  9201. case 5125 /* UNSIGNED_INT */:
  9202. return Uint32Array;
  9203. case 5126 /* FLOAT */:
  9204. return Float32Array;
  9205. default:
  9206. throw new Error("".concat(context, ": Invalid component type ").concat(componentType));
  9207. }
  9208. };
  9209. GLTFLoader._GetTypedArray = function (context, componentType, bufferView, byteOffset, length) {
  9210. var buffer = bufferView.buffer;
  9211. byteOffset = bufferView.byteOffset + (byteOffset || 0);
  9212. var constructor = GLTFLoader._GetTypedArrayConstructor("".concat(context, "/componentType"), componentType);
  9213. var componentTypeLength = core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.GetTypeByteLength(componentType);
  9214. if (byteOffset % componentTypeLength !== 0) {
  9215. // HACK: Copy the buffer if byte offset is not a multiple of component type byte length.
  9216. core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, ": Copying buffer as byte offset (").concat(byteOffset, ") is not a multiple of component type byte length (").concat(componentTypeLength, ")"));
  9217. return new constructor(buffer.slice(byteOffset, byteOffset + length * componentTypeLength), 0);
  9218. }
  9219. return new constructor(buffer, byteOffset, length);
  9220. };
  9221. GLTFLoader._GetNumComponents = function (context, type) {
  9222. switch (type) {
  9223. case "SCALAR":
  9224. return 1;
  9225. case "VEC2":
  9226. return 2;
  9227. case "VEC3":
  9228. return 3;
  9229. case "VEC4":
  9230. return 4;
  9231. case "MAT2":
  9232. return 4;
  9233. case "MAT3":
  9234. return 9;
  9235. case "MAT4":
  9236. return 16;
  9237. }
  9238. throw new Error("".concat(context, ": Invalid type (").concat(type, ")"));
  9239. };
  9240. GLTFLoader._ValidateUri = function (uri) {
  9241. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Tools.IsBase64(uri) || uri.indexOf("..") === -1;
  9242. };
  9243. /**
  9244. * @param context
  9245. * @param mode
  9246. * @hidden
  9247. */
  9248. GLTFLoader._GetDrawMode = function (context, mode) {
  9249. if (mode == undefined) {
  9250. mode = 4 /* TRIANGLES */;
  9251. }
  9252. switch (mode) {
  9253. case 0 /* POINTS */:
  9254. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.PointListDrawMode;
  9255. case 1 /* LINES */:
  9256. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.LineListDrawMode;
  9257. case 2 /* LINE_LOOP */:
  9258. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.LineLoopDrawMode;
  9259. case 3 /* LINE_STRIP */:
  9260. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.LineStripDrawMode;
  9261. case 4 /* TRIANGLES */:
  9262. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFillMode;
  9263. case 5 /* TRIANGLE_STRIP */:
  9264. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleStripDrawMode;
  9265. case 6 /* TRIANGLE_FAN */:
  9266. return core_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFanDrawMode;
  9267. }
  9268. throw new Error("".concat(context, ": Invalid mesh primitive mode (").concat(mode, ")"));
  9269. };
  9270. GLTFLoader.prototype._compileMaterialsAsync = function () {
  9271. var _this = this;
  9272. this._parent._startPerformanceCounter("Compile materials");
  9273. var promises = new Array();
  9274. if (this._gltf.materials) {
  9275. for (var _i = 0, _a = this._gltf.materials; _i < _a.length; _i++) {
  9276. var material = _a[_i];
  9277. if (material._data) {
  9278. for (var babylonDrawMode in material._data) {
  9279. var babylonData = material._data[babylonDrawMode];
  9280. for (var _b = 0, _c = babylonData.babylonMeshes; _b < _c.length; _b++) {
  9281. var babylonMesh = _c[_b];
  9282. // Ensure nonUniformScaling is set if necessary.
  9283. babylonMesh.computeWorldMatrix(true);
  9284. var babylonMaterial = babylonData.babylonMaterial;
  9285. promises.push(babylonMaterial.forceCompilationAsync(babylonMesh));
  9286. promises.push(babylonMaterial.forceCompilationAsync(babylonMesh, { useInstances: true }));
  9287. if (this._parent.useClipPlane) {
  9288. promises.push(babylonMaterial.forceCompilationAsync(babylonMesh, { clipPlane: true }));
  9289. promises.push(babylonMaterial.forceCompilationAsync(babylonMesh, { clipPlane: true, useInstances: true }));
  9290. }
  9291. }
  9292. }
  9293. }
  9294. }
  9295. }
  9296. return Promise.all(promises).then(function () {
  9297. _this._parent._endPerformanceCounter("Compile materials");
  9298. });
  9299. };
  9300. GLTFLoader.prototype._compileShadowGeneratorsAsync = function () {
  9301. var _this = this;
  9302. this._parent._startPerformanceCounter("Compile shadow generators");
  9303. var promises = new Array();
  9304. var lights = this._babylonScene.lights;
  9305. for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) {
  9306. var light = lights_1[_i];
  9307. var generator = light.getShadowGenerator();
  9308. if (generator) {
  9309. promises.push(generator.forceCompilationAsync());
  9310. }
  9311. }
  9312. return Promise.all(promises).then(function () {
  9313. _this._parent._endPerformanceCounter("Compile shadow generators");
  9314. });
  9315. };
  9316. GLTFLoader.prototype._forEachExtensions = function (action) {
  9317. for (var _i = 0, _a = this._extensions; _i < _a.length; _i++) {
  9318. var extension = _a[_i];
  9319. if (extension.enabled) {
  9320. action(extension);
  9321. }
  9322. }
  9323. };
  9324. GLTFLoader.prototype._applyExtensions = function (property, functionName, actionAsync) {
  9325. for (var _i = 0, _a = this._extensions; _i < _a.length; _i++) {
  9326. var extension = _a[_i];
  9327. if (extension.enabled) {
  9328. var id = "".concat(extension.name, ".").concat(functionName);
  9329. var loaderProperty = property;
  9330. loaderProperty._activeLoaderExtensionFunctions = loaderProperty._activeLoaderExtensionFunctions || {};
  9331. var activeLoaderExtensionFunctions = loaderProperty._activeLoaderExtensionFunctions;
  9332. if (!activeLoaderExtensionFunctions[id]) {
  9333. activeLoaderExtensionFunctions[id] = true;
  9334. try {
  9335. var result = actionAsync(extension);
  9336. if (result) {
  9337. return result;
  9338. }
  9339. }
  9340. finally {
  9341. delete activeLoaderExtensionFunctions[id];
  9342. }
  9343. }
  9344. }
  9345. }
  9346. return null;
  9347. };
  9348. GLTFLoader.prototype._extensionsOnLoading = function () {
  9349. this._forEachExtensions(function (extension) { return extension.onLoading && extension.onLoading(); });
  9350. };
  9351. GLTFLoader.prototype._extensionsOnReady = function () {
  9352. this._forEachExtensions(function (extension) { return extension.onReady && extension.onReady(); });
  9353. };
  9354. GLTFLoader.prototype._extensionsLoadSceneAsync = function (context, scene) {
  9355. return this._applyExtensions(scene, "loadScene", function (extension) { return extension.loadSceneAsync && extension.loadSceneAsync(context, scene); });
  9356. };
  9357. GLTFLoader.prototype._extensionsLoadNodeAsync = function (context, node, assign) {
  9358. return this._applyExtensions(node, "loadNode", function (extension) { return extension.loadNodeAsync && extension.loadNodeAsync(context, node, assign); });
  9359. };
  9360. GLTFLoader.prototype._extensionsLoadCameraAsync = function (context, camera, assign) {
  9361. return this._applyExtensions(camera, "loadCamera", function (extension) { return extension.loadCameraAsync && extension.loadCameraAsync(context, camera, assign); });
  9362. };
  9363. GLTFLoader.prototype._extensionsLoadVertexDataAsync = function (context, primitive, babylonMesh) {
  9364. return this._applyExtensions(primitive, "loadVertexData", function (extension) { return extension._loadVertexDataAsync && extension._loadVertexDataAsync(context, primitive, babylonMesh); });
  9365. };
  9366. GLTFLoader.prototype._extensionsLoadMeshPrimitiveAsync = function (context, name, node, mesh, primitive, assign) {
  9367. return this._applyExtensions(primitive, "loadMeshPrimitive", function (extension) { return extension._loadMeshPrimitiveAsync && extension._loadMeshPrimitiveAsync(context, name, node, mesh, primitive, assign); });
  9368. };
  9369. GLTFLoader.prototype._extensionsLoadMaterialAsync = function (context, material, babylonMesh, babylonDrawMode, assign) {
  9370. return this._applyExtensions(material, "loadMaterial", function (extension) { return extension._loadMaterialAsync && extension._loadMaterialAsync(context, material, babylonMesh, babylonDrawMode, assign); });
  9371. };
  9372. GLTFLoader.prototype._extensionsCreateMaterial = function (context, material, babylonDrawMode) {
  9373. return this._applyExtensions(material, "createMaterial", function (extension) { return extension.createMaterial && extension.createMaterial(context, material, babylonDrawMode); });
  9374. };
  9375. GLTFLoader.prototype._extensionsLoadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
  9376. return this._applyExtensions(material, "loadMaterialProperties", function (extension) { return extension.loadMaterialPropertiesAsync && extension.loadMaterialPropertiesAsync(context, material, babylonMaterial); });
  9377. };
  9378. GLTFLoader.prototype._extensionsLoadTextureInfoAsync = function (context, textureInfo, assign) {
  9379. return this._applyExtensions(textureInfo, "loadTextureInfo", function (extension) { return extension.loadTextureInfoAsync && extension.loadTextureInfoAsync(context, textureInfo, assign); });
  9380. };
  9381. GLTFLoader.prototype._extensionsLoadTextureAsync = function (context, texture, assign) {
  9382. return this._applyExtensions(texture, "loadTexture", function (extension) { return extension._loadTextureAsync && extension._loadTextureAsync(context, texture, assign); });
  9383. };
  9384. GLTFLoader.prototype._extensionsLoadAnimationAsync = function (context, animation) {
  9385. return this._applyExtensions(animation, "loadAnimation", function (extension) { return extension.loadAnimationAsync && extension.loadAnimationAsync(context, animation); });
  9386. };
  9387. GLTFLoader.prototype._extensionsLoadSkinAsync = function (context, node, skin) {
  9388. return this._applyExtensions(skin, "loadSkin", function (extension) { return extension._loadSkinAsync && extension._loadSkinAsync(context, node, skin); });
  9389. };
  9390. GLTFLoader.prototype._extensionsLoadUriAsync = function (context, property, uri) {
  9391. return this._applyExtensions(property, "loadUri", function (extension) { return extension._loadUriAsync && extension._loadUriAsync(context, property, uri); });
  9392. };
  9393. GLTFLoader.prototype._extensionsLoadBufferViewAsync = function (context, bufferView) {
  9394. return this._applyExtensions(bufferView, "loadBufferView", function (extension) { return extension.loadBufferViewAsync && extension.loadBufferViewAsync(context, bufferView); });
  9395. };
  9396. GLTFLoader.prototype._extensionsLoadBufferAsync = function (context, buffer, byteOffset, byteLength) {
  9397. return this._applyExtensions(buffer, "loadBuffer", function (extension) { return extension.loadBufferAsync && extension.loadBufferAsync(context, buffer, byteOffset, byteLength); });
  9398. };
  9399. /**
  9400. * Helper method called by a loader extension to load an glTF extension.
  9401. * @param context The context when loading the asset
  9402. * @param property The glTF property to load the extension from
  9403. * @param extensionName The name of the extension to load
  9404. * @param actionAsync The action to run
  9405. * @returns The promise returned by actionAsync or null if the extension does not exist
  9406. */
  9407. GLTFLoader.LoadExtensionAsync = function (context, property, extensionName, actionAsync) {
  9408. if (!property.extensions) {
  9409. return null;
  9410. }
  9411. var extensions = property.extensions;
  9412. var extension = extensions[extensionName];
  9413. if (!extension) {
  9414. return null;
  9415. }
  9416. return actionAsync("".concat(context, "/extensions/").concat(extensionName), extension);
  9417. };
  9418. /**
  9419. * Helper method called by a loader extension to load a glTF extra.
  9420. * @param context The context when loading the asset
  9421. * @param property The glTF property to load the extra from
  9422. * @param extensionName The name of the extension to load
  9423. * @param actionAsync The action to run
  9424. * @returns The promise returned by actionAsync or null if the extra does not exist
  9425. */
  9426. GLTFLoader.LoadExtraAsync = function (context, property, extensionName, actionAsync) {
  9427. if (!property.extras) {
  9428. return null;
  9429. }
  9430. var extras = property.extras;
  9431. var extra = extras[extensionName];
  9432. if (!extra) {
  9433. return null;
  9434. }
  9435. return actionAsync("".concat(context, "/extras/").concat(extensionName), extra);
  9436. };
  9437. /**
  9438. * Checks for presence of an extension.
  9439. * @param name The name of the extension to check
  9440. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  9441. */
  9442. GLTFLoader.prototype.isExtensionUsed = function (name) {
  9443. return !!this._gltf.extensionsUsed && this._gltf.extensionsUsed.indexOf(name) !== -1;
  9444. };
  9445. /**
  9446. * Increments the indentation level and logs a message.
  9447. * @param message The message to log
  9448. */
  9449. GLTFLoader.prototype.logOpen = function (message) {
  9450. this._parent._logOpen(message);
  9451. };
  9452. /**
  9453. * Decrements the indentation level.
  9454. */
  9455. GLTFLoader.prototype.logClose = function () {
  9456. this._parent._logClose();
  9457. };
  9458. /**
  9459. * Logs a message
  9460. * @param message The message to log
  9461. */
  9462. GLTFLoader.prototype.log = function (message) {
  9463. this._parent._log(message);
  9464. };
  9465. /**
  9466. * Starts a performance counter.
  9467. * @param counterName The name of the performance counter
  9468. */
  9469. GLTFLoader.prototype.startPerformanceCounter = function (counterName) {
  9470. this._parent._startPerformanceCounter(counterName);
  9471. };
  9472. /**
  9473. * Ends a performance counter.
  9474. * @param counterName The name of the performance counter
  9475. */
  9476. GLTFLoader.prototype.endPerformanceCounter = function (counterName) {
  9477. this._parent._endPerformanceCounter(counterName);
  9478. };
  9479. GLTFLoader._RegisteredExtensions = {};
  9480. /**
  9481. * The default glTF sampler.
  9482. */
  9483. GLTFLoader.DefaultSampler = { index: -1 };
  9484. return GLTFLoader;
  9485. }());
  9486. _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFFileLoader._CreateGLTF2Loader = function (parent) { return new GLTFLoader(parent); };
  9487. /***/ }),
  9488. /***/ "../../../lts/loaders/dist/glTF/2.0/glTFLoaderExtension.js":
  9489. /*!*****************************************************************!*\
  9490. !*** ../../../lts/loaders/dist/glTF/2.0/glTFLoaderExtension.js ***!
  9491. \*****************************************************************/
  9492. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  9493. __webpack_require__.r(__webpack_exports__);
  9494. /***/ }),
  9495. /***/ "../../../lts/loaders/dist/glTF/2.0/glTFLoaderInterfaces.js":
  9496. /*!******************************************************************!*\
  9497. !*** ../../../lts/loaders/dist/glTF/2.0/glTFLoaderInterfaces.js ***!
  9498. \******************************************************************/
  9499. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  9500. __webpack_require__.r(__webpack_exports__);
  9501. /***/ }),
  9502. /***/ "../../../lts/loaders/dist/glTF/2.0/index.js":
  9503. /*!***************************************************!*\
  9504. !*** ../../../lts/loaders/dist/glTF/2.0/index.js ***!
  9505. \***************************************************/
  9506. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  9507. __webpack_require__.r(__webpack_exports__);
  9508. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  9509. /* harmony export */ "ArrayItem": () => (/* reexport safe */ _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem),
  9510. /* harmony export */ "EXT_lights_image_based": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.EXT_lights_image_based),
  9511. /* harmony export */ "EXT_mesh_gpu_instancing": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.EXT_mesh_gpu_instancing),
  9512. /* harmony export */ "EXT_meshopt_compression": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.EXT_meshopt_compression),
  9513. /* harmony export */ "EXT_texture_webp": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.EXT_texture_webp),
  9514. /* harmony export */ "ExtrasAsMetadata": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.ExtrasAsMetadata),
  9515. /* harmony export */ "GLTFLoader": () => (/* reexport safe */ _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader),
  9516. /* harmony export */ "KHR_draco_mesh_compression": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_draco_mesh_compression),
  9517. /* harmony export */ "KHR_lights": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_lights),
  9518. /* harmony export */ "KHR_materials_clearcoat": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_clearcoat),
  9519. /* harmony export */ "KHR_materials_emissive_strength": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_emissive_strength),
  9520. /* harmony export */ "KHR_materials_ior": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_ior),
  9521. /* harmony export */ "KHR_materials_pbrSpecularGlossiness": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_pbrSpecularGlossiness),
  9522. /* harmony export */ "KHR_materials_sheen": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_sheen),
  9523. /* harmony export */ "KHR_materials_specular": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_specular),
  9524. /* harmony export */ "KHR_materials_translucency": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_translucency),
  9525. /* harmony export */ "KHR_materials_transmission": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_transmission),
  9526. /* harmony export */ "KHR_materials_unlit": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_unlit),
  9527. /* harmony export */ "KHR_materials_variants": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_variants),
  9528. /* harmony export */ "KHR_materials_volume": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_volume),
  9529. /* harmony export */ "KHR_mesh_quantization": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_mesh_quantization),
  9530. /* harmony export */ "KHR_texture_basisu": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_texture_basisu),
  9531. /* harmony export */ "KHR_texture_transform": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_texture_transform),
  9532. /* harmony export */ "KHR_xmp_json_ld": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_xmp_json_ld),
  9533. /* harmony export */ "MSFT_audio_emitter": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.MSFT_audio_emitter),
  9534. /* harmony export */ "MSFT_lod": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.MSFT_lod),
  9535. /* harmony export */ "MSFT_minecraftMesh": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.MSFT_minecraftMesh),
  9536. /* harmony export */ "MSFT_sRGBFactors": () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.MSFT_sRGBFactors)
  9537. /* harmony export */ });
  9538. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFLoader */ "../../../lts/loaders/dist/glTF/2.0/glTFLoader.js");
  9539. /* harmony import */ var _glTFLoaderExtension__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFLoaderExtension */ "../../../lts/loaders/dist/glTF/2.0/glTFLoaderExtension.js");
  9540. /* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "../../../lts/loaders/dist/glTF/2.0/glTFLoaderInterfaces.js");
  9541. /* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Extensions/index */ "../../../lts/loaders/dist/glTF/2.0/Extensions/index.js");
  9542. /***/ }),
  9543. /***/ "../../../lts/loaders/dist/glTF/glTFFileLoader.js":
  9544. /*!********************************************************!*\
  9545. !*** ../../../lts/loaders/dist/glTF/glTFFileLoader.js ***!
  9546. \********************************************************/
  9547. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  9548. __webpack_require__.r(__webpack_exports__);
  9549. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  9550. /* harmony export */ "GLTFFileLoader": () => (/* binding */ GLTFFileLoader),
  9551. /* harmony export */ "GLTFLoaderAnimationStartMode": () => (/* binding */ GLTFLoaderAnimationStartMode),
  9552. /* harmony export */ "GLTFLoaderCoordinateSystemMode": () => (/* binding */ GLTFLoaderCoordinateSystemMode),
  9553. /* harmony export */ "GLTFLoaderState": () => (/* binding */ GLTFLoaderState)
  9554. /* harmony export */ });
  9555. /* harmony import */ var core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Misc/error */ "core/Misc/observable");
  9556. /* harmony import */ var core_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  9557. /* harmony import */ var _glTFValidation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFValidation */ "../../../lts/loaders/dist/glTF/glTFValidation.js");
  9558. function readAsync(arrayBuffer, byteOffset, byteLength) {
  9559. try {
  9560. return Promise.resolve(new Uint8Array(arrayBuffer, byteOffset, byteLength));
  9561. }
  9562. catch (e) {
  9563. return Promise.reject(e);
  9564. }
  9565. }
  9566. /**
  9567. * Mode that determines the coordinate system to use.
  9568. */
  9569. var GLTFLoaderCoordinateSystemMode;
  9570. (function (GLTFLoaderCoordinateSystemMode) {
  9571. /**
  9572. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  9573. */
  9574. GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["AUTO"] = 0] = "AUTO";
  9575. /**
  9576. * Sets the useRightHandedSystem flag on the scene.
  9577. */
  9578. GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["FORCE_RIGHT_HANDED"] = 1] = "FORCE_RIGHT_HANDED";
  9579. })(GLTFLoaderCoordinateSystemMode || (GLTFLoaderCoordinateSystemMode = {}));
  9580. /**
  9581. * Mode that determines what animations will start.
  9582. */
  9583. var GLTFLoaderAnimationStartMode;
  9584. (function (GLTFLoaderAnimationStartMode) {
  9585. /**
  9586. * No animation will start.
  9587. */
  9588. GLTFLoaderAnimationStartMode[GLTFLoaderAnimationStartMode["NONE"] = 0] = "NONE";
  9589. /**
  9590. * The first animation will start.
  9591. */
  9592. GLTFLoaderAnimationStartMode[GLTFLoaderAnimationStartMode["FIRST"] = 1] = "FIRST";
  9593. /**
  9594. * All animations will start.
  9595. */
  9596. GLTFLoaderAnimationStartMode[GLTFLoaderAnimationStartMode["ALL"] = 2] = "ALL";
  9597. })(GLTFLoaderAnimationStartMode || (GLTFLoaderAnimationStartMode = {}));
  9598. /**
  9599. * Loader state.
  9600. */
  9601. var GLTFLoaderState;
  9602. (function (GLTFLoaderState) {
  9603. /**
  9604. * The asset is loading.
  9605. */
  9606. GLTFLoaderState[GLTFLoaderState["LOADING"] = 0] = "LOADING";
  9607. /**
  9608. * The asset is ready for rendering.
  9609. */
  9610. GLTFLoaderState[GLTFLoaderState["READY"] = 1] = "READY";
  9611. /**
  9612. * The asset is completely loaded.
  9613. */
  9614. GLTFLoaderState[GLTFLoaderState["COMPLETE"] = 2] = "COMPLETE";
  9615. })(GLTFLoaderState || (GLTFLoaderState = {}));
  9616. /**
  9617. * File loader for loading glTF files into a scene.
  9618. */
  9619. var GLTFFileLoader = /** @class */ (function () {
  9620. function GLTFFileLoader() {
  9621. // --------------
  9622. // Common options
  9623. // --------------
  9624. /**
  9625. * Raised when the asset has been parsed
  9626. */
  9627. this.onParsedObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
  9628. // ----------
  9629. // V2 options
  9630. // ----------
  9631. /**
  9632. * The coordinate system mode. Defaults to AUTO.
  9633. */
  9634. this.coordinateSystemMode = GLTFLoaderCoordinateSystemMode.AUTO;
  9635. /**
  9636. * The animation start mode. Defaults to FIRST.
  9637. */
  9638. this.animationStartMode = GLTFLoaderAnimationStartMode.FIRST;
  9639. /**
  9640. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  9641. */
  9642. this.compileMaterials = false;
  9643. /**
  9644. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  9645. */
  9646. this.useClipPlane = false;
  9647. /**
  9648. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  9649. */
  9650. this.compileShadowGenerators = false;
  9651. /**
  9652. * Defines if the Alpha blended materials are only applied as coverage.
  9653. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  9654. * If true, no extra effects are applied to transparent pixels.
  9655. */
  9656. this.transparencyAsCoverage = false;
  9657. /**
  9658. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  9659. * Enabling will disable offline support and glTF validator.
  9660. * Defaults to false.
  9661. */
  9662. this.useRangeRequests = false;
  9663. /**
  9664. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  9665. */
  9666. this.createInstances = true;
  9667. /**
  9668. * Defines if the loader should always compute the bounding boxes of meshes and not use the min/max values from the position accessor. Defaults to false.
  9669. */
  9670. this.alwaysComputeBoundingBox = false;
  9671. /**
  9672. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  9673. */
  9674. this.loadAllMaterials = false;
  9675. /**
  9676. * If true, load only the materials defined in the file. Defaults to false.
  9677. */
  9678. this.loadOnlyMaterials = false;
  9679. /**
  9680. * If true, do not load any materials defined in the file. Defaults to false.
  9681. */
  9682. this.skipMaterials = false;
  9683. /**
  9684. * If true, load the color (gamma encoded) textures into sRGB buffers (if supported by the GPU), which will yield more accurate results when sampling the texture. Defaults to true.
  9685. */
  9686. this.useSRGBBuffers = true;
  9687. /**
  9688. * When loading glTF animations, which are defined in seconds, target them to this FPS. Defaults to 60.
  9689. */
  9690. this.targetFps = 60;
  9691. /**
  9692. * Defines if the loader should always compute the nearest common ancestor of the skeleton joints instead of using `skin.skeleton`. Defaults to false.
  9693. * Set this to true if loading assets with invalid `skin.skeleton` values.
  9694. */
  9695. this.alwaysComputeSkeletonRootNode = false;
  9696. /**
  9697. * Function called before loading a url referenced by the asset.
  9698. * @param url
  9699. */
  9700. this.preprocessUrlAsync = function (url) { return Promise.resolve(url); };
  9701. /**
  9702. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  9703. * Note that the observable is raised as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
  9704. */
  9705. this.onMeshLoadedObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
  9706. /**
  9707. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  9708. */
  9709. this.onTextureLoadedObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
  9710. /**
  9711. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  9712. */
  9713. this.onMaterialLoadedObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
  9714. /**
  9715. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  9716. */
  9717. this.onCameraLoadedObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
  9718. /**
  9719. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  9720. * For assets with LODs, raised when all of the LODs are complete.
  9721. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  9722. */
  9723. this.onCompleteObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
  9724. /**
  9725. * Observable raised when an error occurs.
  9726. */
  9727. this.onErrorObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
  9728. /**
  9729. * Observable raised after the loader is disposed.
  9730. */
  9731. this.onDisposeObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
  9732. /**
  9733. * Observable raised after a loader extension is created.
  9734. * Set additional options for a loader extension in this event.
  9735. */
  9736. this.onExtensionLoadedObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
  9737. /**
  9738. * Defines if the loader should validate the asset.
  9739. */
  9740. this.validate = false;
  9741. /**
  9742. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  9743. */
  9744. this.onValidatedObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
  9745. this._loader = null;
  9746. this._state = null;
  9747. this._requests = new Array();
  9748. /**
  9749. * Name of the loader ("gltf")
  9750. */
  9751. this.name = "gltf";
  9752. /** @hidden */
  9753. this.extensions = {
  9754. ".gltf": { isBinary: false },
  9755. ".glb": { isBinary: true },
  9756. };
  9757. /**
  9758. * Observable raised when the loader state changes.
  9759. */
  9760. this.onLoaderStateChangedObservable = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable();
  9761. this._logIndentLevel = 0;
  9762. this._loggingEnabled = false;
  9763. /** @hidden */
  9764. this._log = this._logDisabled;
  9765. this._capturePerformanceCounters = false;
  9766. /** @hidden */
  9767. this._startPerformanceCounter = this._startPerformanceCounterDisabled;
  9768. /** @hidden */
  9769. this._endPerformanceCounter = this._endPerformanceCounterDisabled;
  9770. }
  9771. Object.defineProperty(GLTFFileLoader.prototype, "onParsed", {
  9772. /**
  9773. * Raised when the asset has been parsed
  9774. */
  9775. set: function (callback) {
  9776. if (this._onParsedObserver) {
  9777. this.onParsedObservable.remove(this._onParsedObserver);
  9778. }
  9779. this._onParsedObserver = this.onParsedObservable.add(callback);
  9780. },
  9781. enumerable: false,
  9782. configurable: true
  9783. });
  9784. Object.defineProperty(GLTFFileLoader.prototype, "onMeshLoaded", {
  9785. /**
  9786. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  9787. * Note that the callback is called as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
  9788. */
  9789. set: function (callback) {
  9790. if (this._onMeshLoadedObserver) {
  9791. this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver);
  9792. }
  9793. this._onMeshLoadedObserver = this.onMeshLoadedObservable.add(callback);
  9794. },
  9795. enumerable: false,
  9796. configurable: true
  9797. });
  9798. Object.defineProperty(GLTFFileLoader.prototype, "onTextureLoaded", {
  9799. /**
  9800. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  9801. */
  9802. set: function (callback) {
  9803. if (this._onTextureLoadedObserver) {
  9804. this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver);
  9805. }
  9806. this._onTextureLoadedObserver = this.onTextureLoadedObservable.add(callback);
  9807. },
  9808. enumerable: false,
  9809. configurable: true
  9810. });
  9811. Object.defineProperty(GLTFFileLoader.prototype, "onMaterialLoaded", {
  9812. /**
  9813. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  9814. */
  9815. set: function (callback) {
  9816. if (this._onMaterialLoadedObserver) {
  9817. this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver);
  9818. }
  9819. this._onMaterialLoadedObserver = this.onMaterialLoadedObservable.add(callback);
  9820. },
  9821. enumerable: false,
  9822. configurable: true
  9823. });
  9824. Object.defineProperty(GLTFFileLoader.prototype, "onCameraLoaded", {
  9825. /**
  9826. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  9827. */
  9828. set: function (callback) {
  9829. if (this._onCameraLoadedObserver) {
  9830. this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver);
  9831. }
  9832. this._onCameraLoadedObserver = this.onCameraLoadedObservable.add(callback);
  9833. },
  9834. enumerable: false,
  9835. configurable: true
  9836. });
  9837. Object.defineProperty(GLTFFileLoader.prototype, "onComplete", {
  9838. /**
  9839. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  9840. * For assets with LODs, raised when all of the LODs are complete.
  9841. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  9842. */
  9843. set: function (callback) {
  9844. if (this._onCompleteObserver) {
  9845. this.onCompleteObservable.remove(this._onCompleteObserver);
  9846. }
  9847. this._onCompleteObserver = this.onCompleteObservable.add(callback);
  9848. },
  9849. enumerable: false,
  9850. configurable: true
  9851. });
  9852. Object.defineProperty(GLTFFileLoader.prototype, "onError", {
  9853. /**
  9854. * Callback raised when an error occurs.
  9855. */
  9856. set: function (callback) {
  9857. if (this._onErrorObserver) {
  9858. this.onErrorObservable.remove(this._onErrorObserver);
  9859. }
  9860. this._onErrorObserver = this.onErrorObservable.add(callback);
  9861. },
  9862. enumerable: false,
  9863. configurable: true
  9864. });
  9865. Object.defineProperty(GLTFFileLoader.prototype, "onDispose", {
  9866. /**
  9867. * Callback raised after the loader is disposed.
  9868. */
  9869. set: function (callback) {
  9870. if (this._onDisposeObserver) {
  9871. this.onDisposeObservable.remove(this._onDisposeObserver);
  9872. }
  9873. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  9874. },
  9875. enumerable: false,
  9876. configurable: true
  9877. });
  9878. Object.defineProperty(GLTFFileLoader.prototype, "onExtensionLoaded", {
  9879. /**
  9880. * Callback raised after a loader extension is created.
  9881. */
  9882. set: function (callback) {
  9883. if (this._onExtensionLoadedObserver) {
  9884. this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver);
  9885. }
  9886. this._onExtensionLoadedObserver = this.onExtensionLoadedObservable.add(callback);
  9887. },
  9888. enumerable: false,
  9889. configurable: true
  9890. });
  9891. Object.defineProperty(GLTFFileLoader.prototype, "loggingEnabled", {
  9892. /**
  9893. * Defines if the loader logging is enabled.
  9894. */
  9895. get: function () {
  9896. return this._loggingEnabled;
  9897. },
  9898. set: function (value) {
  9899. if (this._loggingEnabled === value) {
  9900. return;
  9901. }
  9902. this._loggingEnabled = value;
  9903. if (this._loggingEnabled) {
  9904. this._log = this._logEnabled;
  9905. }
  9906. else {
  9907. this._log = this._logDisabled;
  9908. }
  9909. },
  9910. enumerable: false,
  9911. configurable: true
  9912. });
  9913. Object.defineProperty(GLTFFileLoader.prototype, "capturePerformanceCounters", {
  9914. /**
  9915. * Defines if the loader should capture performance counters.
  9916. */
  9917. get: function () {
  9918. return this._capturePerformanceCounters;
  9919. },
  9920. set: function (value) {
  9921. if (this._capturePerformanceCounters === value) {
  9922. return;
  9923. }
  9924. this._capturePerformanceCounters = value;
  9925. if (this._capturePerformanceCounters) {
  9926. this._startPerformanceCounter = this._startPerformanceCounterEnabled;
  9927. this._endPerformanceCounter = this._endPerformanceCounterEnabled;
  9928. }
  9929. else {
  9930. this._startPerformanceCounter = this._startPerformanceCounterDisabled;
  9931. this._endPerformanceCounter = this._endPerformanceCounterDisabled;
  9932. }
  9933. },
  9934. enumerable: false,
  9935. configurable: true
  9936. });
  9937. Object.defineProperty(GLTFFileLoader.prototype, "onValidated", {
  9938. /**
  9939. * Callback raised after a loader extension is created.
  9940. */
  9941. set: function (callback) {
  9942. if (this._onValidatedObserver) {
  9943. this.onValidatedObservable.remove(this._onValidatedObserver);
  9944. }
  9945. this._onValidatedObserver = this.onValidatedObservable.add(callback);
  9946. },
  9947. enumerable: false,
  9948. configurable: true
  9949. });
  9950. /**
  9951. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  9952. */
  9953. GLTFFileLoader.prototype.dispose = function () {
  9954. if (this._loader) {
  9955. this._loader.dispose();
  9956. this._loader = null;
  9957. }
  9958. for (var _i = 0, _a = this._requests; _i < _a.length; _i++) {
  9959. var request = _a[_i];
  9960. request.abort();
  9961. }
  9962. this._requests.length = 0;
  9963. delete this._progressCallback;
  9964. this.preprocessUrlAsync = function (url) { return Promise.resolve(url); };
  9965. this.onMeshLoadedObservable.clear();
  9966. this.onTextureLoadedObservable.clear();
  9967. this.onMaterialLoadedObservable.clear();
  9968. this.onCameraLoadedObservable.clear();
  9969. this.onCompleteObservable.clear();
  9970. this.onExtensionLoadedObservable.clear();
  9971. this.onDisposeObservable.notifyObservers(undefined);
  9972. this.onDisposeObservable.clear();
  9973. };
  9974. /**
  9975. * @param scene
  9976. * @param fileOrUrl
  9977. * @param onSuccess
  9978. * @param onProgress
  9979. * @param useArrayBuffer
  9980. * @param onError
  9981. * @hidden
  9982. */
  9983. GLTFFileLoader.prototype.loadFile = function (scene, fileOrUrl, onSuccess, onProgress, useArrayBuffer, onError) {
  9984. var _this = this;
  9985. this._progressCallback = onProgress;
  9986. var rootUrl = fileOrUrl.name ? "file:" : core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.GetFolderPath(fileOrUrl);
  9987. var fileName = fileOrUrl.name || core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.GetFilename(fileOrUrl);
  9988. if (useArrayBuffer) {
  9989. if (this.useRangeRequests) {
  9990. if (this.validate) {
  9991. core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("glTF validation is not supported when range requests are enabled");
  9992. }
  9993. var fileRequest_1 = {
  9994. abort: function () { },
  9995. onCompleteObservable: new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(),
  9996. };
  9997. var dataBuffer = {
  9998. readAsync: function (byteOffset, byteLength) {
  9999. return new Promise(function (resolve, reject) {
  10000. _this._loadFile(scene, fileOrUrl, function (data) {
  10001. resolve(new Uint8Array(data));
  10002. }, true, function (error) {
  10003. reject(error);
  10004. }, function (webRequest) {
  10005. webRequest.setRequestHeader("Range", "bytes=".concat(byteOffset, "-").concat(byteOffset + byteLength - 1));
  10006. });
  10007. });
  10008. },
  10009. byteLength: 0,
  10010. };
  10011. this._unpackBinaryAsync(new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DataReader(dataBuffer)).then(function (loaderData) {
  10012. fileRequest_1.onCompleteObservable.notifyObservers(fileRequest_1);
  10013. onSuccess(loaderData);
  10014. }, onError ? function (error) { return onError(undefined, error); } : undefined);
  10015. return fileRequest_1;
  10016. }
  10017. return this._loadFile(scene, fileOrUrl, function (data) {
  10018. _this._validate(scene, data, rootUrl, fileName);
  10019. _this._unpackBinaryAsync(new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DataReader({
  10020. readAsync: function (byteOffset, byteLength) { return readAsync(data, byteOffset, byteLength); },
  10021. byteLength: data.byteLength,
  10022. })).then(function (loaderData) {
  10023. onSuccess(loaderData);
  10024. }, onError ? function (error) { return onError(undefined, error); } : undefined);
  10025. }, true, onError);
  10026. }
  10027. return this._loadFile(scene, fileOrUrl, function (data) {
  10028. _this._validate(scene, data, rootUrl, fileName);
  10029. onSuccess({ json: _this._parseJson(data) });
  10030. }, useArrayBuffer, onError);
  10031. };
  10032. /**
  10033. * @param meshesNames
  10034. * @param scene
  10035. * @param data
  10036. * @param rootUrl
  10037. * @param onProgress
  10038. * @param fileName
  10039. * @hidden
  10040. */
  10041. GLTFFileLoader.prototype.importMeshAsync = function (meshesNames, scene, data, rootUrl, onProgress, fileName) {
  10042. var _this = this;
  10043. return Promise.resolve().then(function () {
  10044. _this.onParsedObservable.notifyObservers(data);
  10045. _this.onParsedObservable.clear();
  10046. _this._log("Loading ".concat(fileName || ""));
  10047. _this._loader = _this._getLoader(data);
  10048. return _this._loader.importMeshAsync(meshesNames, scene, null, data, rootUrl, onProgress, fileName);
  10049. });
  10050. };
  10051. /**
  10052. * @param scene
  10053. * @param data
  10054. * @param rootUrl
  10055. * @param onProgress
  10056. * @param fileName
  10057. * @hidden
  10058. */
  10059. GLTFFileLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fileName) {
  10060. var _this = this;
  10061. return Promise.resolve().then(function () {
  10062. _this.onParsedObservable.notifyObservers(data);
  10063. _this.onParsedObservable.clear();
  10064. _this._log("Loading ".concat(fileName || ""));
  10065. _this._loader = _this._getLoader(data);
  10066. return _this._loader.loadAsync(scene, data, rootUrl, onProgress, fileName);
  10067. });
  10068. };
  10069. /**
  10070. * @param scene
  10071. * @param data
  10072. * @param rootUrl
  10073. * @param onProgress
  10074. * @param fileName
  10075. * @hidden
  10076. */
  10077. GLTFFileLoader.prototype.loadAssetContainerAsync = function (scene, data, rootUrl, onProgress, fileName) {
  10078. var _this = this;
  10079. return Promise.resolve().then(function () {
  10080. _this.onParsedObservable.notifyObservers(data);
  10081. _this.onParsedObservable.clear();
  10082. _this._log("Loading ".concat(fileName || ""));
  10083. _this._loader = _this._getLoader(data);
  10084. // Prepare the asset container.
  10085. var container = new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.AssetContainer(scene);
  10086. // Get materials/textures when loading to add to container
  10087. var materials = [];
  10088. _this.onMaterialLoadedObservable.add(function (material) {
  10089. materials.push(material);
  10090. });
  10091. var textures = [];
  10092. _this.onTextureLoadedObservable.add(function (texture) {
  10093. textures.push(texture);
  10094. });
  10095. var cameras = [];
  10096. _this.onCameraLoadedObservable.add(function (camera) {
  10097. cameras.push(camera);
  10098. });
  10099. return _this._loader.importMeshAsync(null, scene, container, data, rootUrl, onProgress, fileName).then(function (result) {
  10100. Array.prototype.push.apply(container.geometries, result.geometries);
  10101. Array.prototype.push.apply(container.meshes, result.meshes);
  10102. Array.prototype.push.apply(container.particleSystems, result.particleSystems);
  10103. Array.prototype.push.apply(container.skeletons, result.skeletons);
  10104. Array.prototype.push.apply(container.animationGroups, result.animationGroups);
  10105. Array.prototype.push.apply(container.materials, materials);
  10106. Array.prototype.push.apply(container.textures, textures);
  10107. Array.prototype.push.apply(container.lights, result.lights);
  10108. Array.prototype.push.apply(container.transformNodes, result.transformNodes);
  10109. Array.prototype.push.apply(container.cameras, cameras);
  10110. return container;
  10111. });
  10112. });
  10113. };
  10114. /**
  10115. * @param data
  10116. * @hidden
  10117. */
  10118. GLTFFileLoader.prototype.canDirectLoad = function (data) {
  10119. return ((data.indexOf("asset") !== -1 && data.indexOf("version") !== -1) ||
  10120. core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.StringTools.StartsWith(data, "data:base64," + GLTFFileLoader.magicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat.
  10121. core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.StringTools.StartsWith(data, "data:;base64," + GLTFFileLoader.magicBase64Encoded) ||
  10122. core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.StringTools.StartsWith(data, "data:application/octet-stream;base64," + GLTFFileLoader.magicBase64Encoded) ||
  10123. core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.StringTools.StartsWith(data, "data:model/gltf-binary;base64," + GLTFFileLoader.magicBase64Encoded));
  10124. };
  10125. /**
  10126. * @param scene
  10127. * @param data
  10128. * @hidden
  10129. */
  10130. GLTFFileLoader.prototype.directLoad = function (scene, data) {
  10131. if (core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.StringTools.StartsWith(data, "base64," + GLTFFileLoader.magicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat.
  10132. core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.StringTools.StartsWith(data, ";base64," + GLTFFileLoader.magicBase64Encoded) ||
  10133. core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.StringTools.StartsWith(data, "application/octet-stream;base64," + GLTFFileLoader.magicBase64Encoded) ||
  10134. core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.StringTools.StartsWith(data, "model/gltf-binary;base64," + GLTFFileLoader.magicBase64Encoded)) {
  10135. var arrayBuffer_1 = (0,core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DecodeBase64UrlToBinary)(data);
  10136. this._validate(scene, arrayBuffer_1);
  10137. return this._unpackBinaryAsync(new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DataReader({
  10138. readAsync: function (byteOffset, byteLength) { return readAsync(arrayBuffer_1, byteOffset, byteLength); },
  10139. byteLength: arrayBuffer_1.byteLength,
  10140. }));
  10141. }
  10142. this._validate(scene, data);
  10143. return Promise.resolve({ json: this._parseJson(data) });
  10144. };
  10145. /** @hidden */
  10146. GLTFFileLoader.prototype.createPlugin = function () {
  10147. return new GLTFFileLoader();
  10148. };
  10149. Object.defineProperty(GLTFFileLoader.prototype, "loaderState", {
  10150. /**
  10151. * The loader state or null if the loader is not active.
  10152. */
  10153. get: function () {
  10154. return this._state;
  10155. },
  10156. enumerable: false,
  10157. configurable: true
  10158. });
  10159. /**
  10160. * Returns a promise that resolves when the asset is completely loaded.
  10161. * @returns a promise that resolves when the asset is completely loaded.
  10162. */
  10163. GLTFFileLoader.prototype.whenCompleteAsync = function () {
  10164. var _this = this;
  10165. return new Promise(function (resolve, reject) {
  10166. _this.onCompleteObservable.addOnce(function () {
  10167. resolve();
  10168. });
  10169. _this.onErrorObservable.addOnce(function (reason) {
  10170. reject(reason);
  10171. });
  10172. });
  10173. };
  10174. /**
  10175. * @param state
  10176. * @hidden
  10177. */
  10178. GLTFFileLoader.prototype._setState = function (state) {
  10179. if (this._state === state) {
  10180. return;
  10181. }
  10182. this._state = state;
  10183. this.onLoaderStateChangedObservable.notifyObservers(this._state);
  10184. this._log(GLTFLoaderState[this._state]);
  10185. };
  10186. /**
  10187. * @param scene
  10188. * @param fileOrUrl
  10189. * @param onSuccess
  10190. * @param useArrayBuffer
  10191. * @param onError
  10192. * @param onOpened
  10193. * @hidden
  10194. */
  10195. GLTFFileLoader.prototype._loadFile = function (scene, fileOrUrl, onSuccess, useArrayBuffer, onError, onOpened) {
  10196. var _this = this;
  10197. var request = scene._loadFile(fileOrUrl, onSuccess, function (event) {
  10198. _this._onProgress(event, request);
  10199. }, true, useArrayBuffer, onError, onOpened);
  10200. request.onCompleteObservable.add(function (request) {
  10201. _this._requests.splice(_this._requests.indexOf(request), 1);
  10202. });
  10203. this._requests.push(request);
  10204. return request;
  10205. };
  10206. GLTFFileLoader.prototype._onProgress = function (event, request) {
  10207. if (!this._progressCallback) {
  10208. return;
  10209. }
  10210. request._lengthComputable = event.lengthComputable;
  10211. request._loaded = event.loaded;
  10212. request._total = event.total;
  10213. var lengthComputable = true;
  10214. var loaded = 0;
  10215. var total = 0;
  10216. for (var _i = 0, _a = this._requests; _i < _a.length; _i++) {
  10217. var request_1 = _a[_i];
  10218. if (request_1._lengthComputable === undefined || request_1._loaded === undefined || request_1._total === undefined) {
  10219. return;
  10220. }
  10221. lengthComputable = lengthComputable && request_1._lengthComputable;
  10222. loaded += request_1._loaded;
  10223. total += request_1._total;
  10224. }
  10225. this._progressCallback({
  10226. lengthComputable: lengthComputable,
  10227. loaded: loaded,
  10228. total: lengthComputable ? total : 0,
  10229. });
  10230. };
  10231. GLTFFileLoader.prototype._validate = function (scene, data, rootUrl, fileName) {
  10232. var _this = this;
  10233. if (rootUrl === void 0) { rootUrl = ""; }
  10234. if (fileName === void 0) { fileName = ""; }
  10235. if (!this.validate) {
  10236. return;
  10237. }
  10238. this._startPerformanceCounter("Validate JSON");
  10239. _glTFValidation__WEBPACK_IMPORTED_MODULE_1__.GLTFValidation.ValidateAsync(data, rootUrl, fileName, function (uri) {
  10240. return _this.preprocessUrlAsync(rootUrl + uri).then(function (url) { return scene._loadFileAsync(url, undefined, true, true); });
  10241. }).then(function (result) {
  10242. _this._endPerformanceCounter("Validate JSON");
  10243. _this.onValidatedObservable.notifyObservers(result);
  10244. _this.onValidatedObservable.clear();
  10245. }, function (reason) {
  10246. _this._endPerformanceCounter("Validate JSON");
  10247. core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Failed to validate: ".concat(reason.message));
  10248. _this.onValidatedObservable.clear();
  10249. });
  10250. };
  10251. GLTFFileLoader.prototype._getLoader = function (loaderData) {
  10252. var asset = loaderData.json.asset || {};
  10253. this._log("Asset version: ".concat(asset.version));
  10254. asset.minVersion && this._log("Asset minimum version: ".concat(asset.minVersion));
  10255. asset.generator && this._log("Asset generator: ".concat(asset.generator));
  10256. var version = GLTFFileLoader._parseVersion(asset.version);
  10257. if (!version) {
  10258. throw new Error("Invalid version: " + asset.version);
  10259. }
  10260. if (asset.minVersion !== undefined) {
  10261. var minVersion = GLTFFileLoader._parseVersion(asset.minVersion);
  10262. if (!minVersion) {
  10263. throw new Error("Invalid minimum version: " + asset.minVersion);
  10264. }
  10265. if (GLTFFileLoader._compareVersion(minVersion, { major: 2, minor: 0 }) > 0) {
  10266. throw new Error("Incompatible minimum version: " + asset.minVersion);
  10267. }
  10268. }
  10269. var createLoaders = {
  10270. 1: GLTFFileLoader._CreateGLTF1Loader,
  10271. 2: GLTFFileLoader._CreateGLTF2Loader,
  10272. };
  10273. var createLoader = createLoaders[version.major];
  10274. if (!createLoader) {
  10275. throw new Error("Unsupported version: " + asset.version);
  10276. }
  10277. return createLoader(this);
  10278. };
  10279. GLTFFileLoader.prototype._parseJson = function (json) {
  10280. this._startPerformanceCounter("Parse JSON");
  10281. this._log("JSON length: ".concat(json.length));
  10282. var parsed = JSON.parse(json);
  10283. this._endPerformanceCounter("Parse JSON");
  10284. return parsed;
  10285. };
  10286. GLTFFileLoader.prototype._unpackBinaryAsync = function (dataReader) {
  10287. var _this = this;
  10288. this._startPerformanceCounter("Unpack Binary");
  10289. // Read magic + version + length + json length + json format
  10290. return dataReader.loadAsync(20).then(function () {
  10291. var Binary = {
  10292. Magic: 0x46546c67,
  10293. };
  10294. var magic = dataReader.readUint32();
  10295. if (magic !== Binary.Magic) {
  10296. throw new core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.RuntimeError("Unexpected magic: " + magic, core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.ErrorCodes.GLTFLoaderUnexpectedMagicError);
  10297. }
  10298. var version = dataReader.readUint32();
  10299. if (_this.loggingEnabled) {
  10300. _this._log("Binary version: ".concat(version));
  10301. }
  10302. var length = dataReader.readUint32();
  10303. if (dataReader.buffer.byteLength !== 0 && length !== dataReader.buffer.byteLength) {
  10304. throw new Error("Length in header does not match actual data length: ".concat(length, " != ").concat(dataReader.buffer.byteLength));
  10305. }
  10306. var unpacked;
  10307. switch (version) {
  10308. case 1: {
  10309. unpacked = _this._unpackBinaryV1Async(dataReader, length);
  10310. break;
  10311. }
  10312. case 2: {
  10313. unpacked = _this._unpackBinaryV2Async(dataReader, length);
  10314. break;
  10315. }
  10316. default: {
  10317. throw new Error("Unsupported version: " + version);
  10318. }
  10319. }
  10320. _this._endPerformanceCounter("Unpack Binary");
  10321. return unpacked;
  10322. });
  10323. };
  10324. GLTFFileLoader.prototype._unpackBinaryV1Async = function (dataReader, length) {
  10325. var ContentFormat = {
  10326. JSON: 0,
  10327. };
  10328. var contentLength = dataReader.readUint32();
  10329. var contentFormat = dataReader.readUint32();
  10330. if (contentFormat !== ContentFormat.JSON) {
  10331. throw new Error("Unexpected content format: ".concat(contentFormat));
  10332. }
  10333. var bodyLength = length - dataReader.byteOffset;
  10334. var data = { json: this._parseJson(dataReader.readString(contentLength)), bin: null };
  10335. if (bodyLength !== 0) {
  10336. var startByteOffset_1 = dataReader.byteOffset;
  10337. data.bin = {
  10338. readAsync: function (byteOffset, byteLength) { return dataReader.buffer.readAsync(startByteOffset_1 + byteOffset, byteLength); },
  10339. byteLength: bodyLength,
  10340. };
  10341. }
  10342. return Promise.resolve(data);
  10343. };
  10344. GLTFFileLoader.prototype._unpackBinaryV2Async = function (dataReader, length) {
  10345. var _this = this;
  10346. var ChunkFormat = {
  10347. JSON: 0x4e4f534a,
  10348. BIN: 0x004e4942,
  10349. };
  10350. // Read the JSON chunk header.
  10351. var chunkLength = dataReader.readUint32();
  10352. var chunkFormat = dataReader.readUint32();
  10353. if (chunkFormat !== ChunkFormat.JSON) {
  10354. throw new Error("First chunk format is not JSON");
  10355. }
  10356. // Bail if there are no other chunks.
  10357. if (dataReader.byteOffset + chunkLength === length) {
  10358. return dataReader.loadAsync(chunkLength).then(function () {
  10359. return { json: _this._parseJson(dataReader.readString(chunkLength)), bin: null };
  10360. });
  10361. }
  10362. // Read the JSON chunk and the length and type of the next chunk.
  10363. return dataReader.loadAsync(chunkLength + 8).then(function () {
  10364. var data = { json: _this._parseJson(dataReader.readString(chunkLength)), bin: null };
  10365. var readAsync = function () {
  10366. var chunkLength = dataReader.readUint32();
  10367. var chunkFormat = dataReader.readUint32();
  10368. switch (chunkFormat) {
  10369. case ChunkFormat.JSON: {
  10370. throw new Error("Unexpected JSON chunk");
  10371. }
  10372. case ChunkFormat.BIN: {
  10373. var startByteOffset_2 = dataReader.byteOffset;
  10374. data.bin = {
  10375. readAsync: function (byteOffset, byteLength) { return dataReader.buffer.readAsync(startByteOffset_2 + byteOffset, byteLength); },
  10376. byteLength: chunkLength,
  10377. };
  10378. dataReader.skipBytes(chunkLength);
  10379. break;
  10380. }
  10381. default: {
  10382. // ignore unrecognized chunkFormat
  10383. dataReader.skipBytes(chunkLength);
  10384. break;
  10385. }
  10386. }
  10387. if (dataReader.byteOffset !== length) {
  10388. return dataReader.loadAsync(8).then(readAsync);
  10389. }
  10390. return Promise.resolve(data);
  10391. };
  10392. return readAsync();
  10393. });
  10394. };
  10395. GLTFFileLoader._parseVersion = function (version) {
  10396. if (version === "1.0" || version === "1.0.1") {
  10397. return {
  10398. major: 1,
  10399. minor: 0,
  10400. };
  10401. }
  10402. var match = (version + "").match(/^(\d+)\.(\d+)/);
  10403. if (!match) {
  10404. return null;
  10405. }
  10406. return {
  10407. major: parseInt(match[1]),
  10408. minor: parseInt(match[2]),
  10409. };
  10410. };
  10411. GLTFFileLoader._compareVersion = function (a, b) {
  10412. if (a.major > b.major) {
  10413. return 1;
  10414. }
  10415. if (a.major < b.major) {
  10416. return -1;
  10417. }
  10418. if (a.minor > b.minor) {
  10419. return 1;
  10420. }
  10421. if (a.minor < b.minor) {
  10422. return -1;
  10423. }
  10424. return 0;
  10425. };
  10426. /**
  10427. * @param message
  10428. * @hidden
  10429. */
  10430. GLTFFileLoader.prototype._logOpen = function (message) {
  10431. this._log(message);
  10432. this._logIndentLevel++;
  10433. };
  10434. /** @hidden */
  10435. GLTFFileLoader.prototype._logClose = function () {
  10436. --this._logIndentLevel;
  10437. };
  10438. GLTFFileLoader.prototype._logEnabled = function (message) {
  10439. var spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2);
  10440. core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Logger.Log("".concat(spaces).concat(message));
  10441. };
  10442. GLTFFileLoader.prototype._logDisabled = function (message) { };
  10443. GLTFFileLoader.prototype._startPerformanceCounterEnabled = function (counterName) {
  10444. core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.StartPerformanceCounter(counterName);
  10445. };
  10446. GLTFFileLoader.prototype._startPerformanceCounterDisabled = function (counterName) { };
  10447. GLTFFileLoader.prototype._endPerformanceCounterEnabled = function (counterName) {
  10448. core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.EndPerformanceCounter(counterName);
  10449. };
  10450. GLTFFileLoader.prototype._endPerformanceCounterDisabled = function (counterName) { };
  10451. // ----------
  10452. // V1 options
  10453. // ----------
  10454. /**
  10455. * Set this property to false to disable incremental loading which delays the loader from calling the success callback until after loading the meshes and shaders.
  10456. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  10457. * Defaults to true.
  10458. * @hidden
  10459. */
  10460. GLTFFileLoader.IncrementalLoading = true;
  10461. /**
  10462. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  10463. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  10464. * @hidden
  10465. */
  10466. GLTFFileLoader.HomogeneousCoordinates = false;
  10467. GLTFFileLoader.magicBase64Encoded = "Z2xURg"; // "glTF" base64 encoded (without the quotes!)
  10468. GLTFFileLoader._logSpaces = " ";
  10469. return GLTFFileLoader;
  10470. }());
  10471. if (core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.SceneLoader) {
  10472. core_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.SceneLoader.RegisterPlugin(new GLTFFileLoader());
  10473. }
  10474. /***/ }),
  10475. /***/ "../../../lts/loaders/dist/glTF/glTFValidation.js":
  10476. /*!********************************************************!*\
  10477. !*** ../../../lts/loaders/dist/glTF/glTFValidation.js ***!
  10478. \********************************************************/
  10479. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  10480. __webpack_require__.r(__webpack_exports__);
  10481. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  10482. /* harmony export */ "GLTFValidation": () => (/* binding */ GLTFValidation)
  10483. /* harmony export */ });
  10484. /* harmony import */ var core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core/Misc/tools */ "core/Misc/observable");
  10485. /* harmony import */ var core_Misc_tools__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__);
  10486. function validateAsync(data, rootUrl, fileName, getExternalResource) {
  10487. var options = {
  10488. externalResourceFunction: function (uri) { return getExternalResource(uri).then(function (value) { return new Uint8Array(value); }); },
  10489. };
  10490. if (fileName) {
  10491. options.uri = rootUrl === "file:" ? fileName : rootUrl + fileName;
  10492. }
  10493. return data instanceof ArrayBuffer ? GLTFValidator.validateBytes(new Uint8Array(data), options) : GLTFValidator.validateString(data, options);
  10494. }
  10495. /**
  10496. * The worker function that gets converted to a blob url to pass into a worker.
  10497. */
  10498. function workerFunc() {
  10499. var pendingExternalResources = [];
  10500. onmessage = function (message) {
  10501. var data = message.data;
  10502. switch (data.id) {
  10503. case "init": {
  10504. importScripts(data.url);
  10505. break;
  10506. }
  10507. case "validate": {
  10508. validateAsync(data.data, data.rootUrl, data.fileName, function (uri) {
  10509. return new Promise(function (resolve, reject) {
  10510. var index = pendingExternalResources.length;
  10511. pendingExternalResources.push({ resolve: resolve, reject: reject });
  10512. postMessage({ id: "getExternalResource", index: index, uri: uri });
  10513. });
  10514. }).then(function (value) {
  10515. postMessage({ id: "validate.resolve", value: value });
  10516. }, function (reason) {
  10517. postMessage({ id: "validate.reject", reason: reason });
  10518. });
  10519. break;
  10520. }
  10521. case "getExternalResource.resolve": {
  10522. pendingExternalResources[data.index].resolve(data.value);
  10523. break;
  10524. }
  10525. case "getExternalResource.reject": {
  10526. pendingExternalResources[data.index].reject(data.reason);
  10527. break;
  10528. }
  10529. }
  10530. };
  10531. }
  10532. /**
  10533. * glTF validation
  10534. */
  10535. var GLTFValidation = /** @class */ (function () {
  10536. function GLTFValidation() {
  10537. }
  10538. /**
  10539. * Validate a glTF asset using the glTF-Validator.
  10540. * @param data The JSON of a glTF or the array buffer of a binary glTF
  10541. * @param rootUrl The root url for the glTF
  10542. * @param fileName The file name for the glTF
  10543. * @param getExternalResource The callback to get external resources for the glTF validator
  10544. * @returns A promise that resolves with the glTF validation results once complete
  10545. */
  10546. GLTFValidation.ValidateAsync = function (data, rootUrl, fileName, getExternalResource) {
  10547. var _this = this;
  10548. if (typeof Worker === "function") {
  10549. return new Promise(function (resolve, reject) {
  10550. var workerContent = "".concat(validateAsync, "(").concat(workerFunc, ")()");
  10551. var workerBlobUrl = URL.createObjectURL(new Blob([workerContent], { type: "application/javascript" }));
  10552. var worker = new Worker(workerBlobUrl);
  10553. var onError = function (error) {
  10554. worker.removeEventListener("error", onError);
  10555. worker.removeEventListener("message", onMessage);
  10556. reject(error);
  10557. };
  10558. var onMessage = function (message) {
  10559. var data = message.data;
  10560. switch (data.id) {
  10561. case "getExternalResource": {
  10562. getExternalResource(data.uri).then(function (value) {
  10563. worker.postMessage({ id: "getExternalResource.resolve", index: data.index, value: value }, [value]);
  10564. }, function (reason) {
  10565. worker.postMessage({ id: "getExternalResource.reject", index: data.index, reason: reason });
  10566. });
  10567. break;
  10568. }
  10569. case "validate.resolve": {
  10570. worker.removeEventListener("error", onError);
  10571. worker.removeEventListener("message", onMessage);
  10572. resolve(data.value);
  10573. worker.terminate();
  10574. break;
  10575. }
  10576. case "validate.reject": {
  10577. worker.removeEventListener("error", onError);
  10578. worker.removeEventListener("message", onMessage);
  10579. reject(data.reason);
  10580. worker.terminate();
  10581. }
  10582. }
  10583. };
  10584. worker.addEventListener("error", onError);
  10585. worker.addEventListener("message", onMessage);
  10586. worker.postMessage({ id: "init", url: _this.Configuration.url });
  10587. worker.postMessage({ id: "validate", data: data, rootUrl: rootUrl, fileName: fileName });
  10588. });
  10589. }
  10590. else {
  10591. if (!this._LoadScriptPromise) {
  10592. this._LoadScriptPromise = core_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.Tools.LoadScriptAsync(this.Configuration.url);
  10593. }
  10594. return this._LoadScriptPromise.then(function () {
  10595. return validateAsync(data, rootUrl, fileName, getExternalResource);
  10596. });
  10597. }
  10598. };
  10599. /**
  10600. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  10601. */
  10602. GLTFValidation.Configuration = {
  10603. url: "https://preview.babylonjs.com/gltf_validator.js",
  10604. };
  10605. return GLTFValidation;
  10606. }());
  10607. /***/ }),
  10608. /***/ "../../../lts/loaders/dist/glTF/index.js":
  10609. /*!***********************************************!*\
  10610. !*** ../../../lts/loaders/dist/glTF/index.js ***!
  10611. \***********************************************/
  10612. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  10613. __webpack_require__.r(__webpack_exports__);
  10614. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  10615. /* harmony export */ "GLTF1": () => (/* reexport module object */ _1_0_index__WEBPACK_IMPORTED_MODULE_2__),
  10616. /* harmony export */ "GLTF2": () => (/* reexport module object */ _2_0_index__WEBPACK_IMPORTED_MODULE_3__),
  10617. /* harmony export */ "GLTFFileLoader": () => (/* reexport safe */ _glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFFileLoader),
  10618. /* harmony export */ "GLTFLoaderAnimationStartMode": () => (/* reexport safe */ _glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderAnimationStartMode),
  10619. /* harmony export */ "GLTFLoaderCoordinateSystemMode": () => (/* reexport safe */ _glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderCoordinateSystemMode),
  10620. /* harmony export */ "GLTFLoaderState": () => (/* reexport safe */ _glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderState),
  10621. /* harmony export */ "GLTFValidation": () => (/* reexport safe */ _glTFValidation__WEBPACK_IMPORTED_MODULE_1__.GLTFValidation)
  10622. /* harmony export */ });
  10623. /* harmony import */ var _glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFFileLoader */ "../../../lts/loaders/dist/glTF/glTFFileLoader.js");
  10624. /* harmony import */ var _glTFValidation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFValidation */ "../../../lts/loaders/dist/glTF/glTFValidation.js");
  10625. /* harmony import */ var _1_0_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./1.0/index */ "../../../lts/loaders/dist/glTF/1.0/index.js");
  10626. /* harmony import */ var _2_0_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./2.0/index */ "../../../lts/loaders/dist/glTF/2.0/index.js");
  10627. /***/ }),
  10628. /***/ "../../../lts/loaders/dist/index.js":
  10629. /*!******************************************!*\
  10630. !*** ../../../lts/loaders/dist/index.js ***!
  10631. \******************************************/
  10632. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  10633. __webpack_require__.r(__webpack_exports__);
  10634. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  10635. /* harmony export */ "GLTF1": () => (/* reexport safe */ _glTF_index__WEBPACK_IMPORTED_MODULE_0__.GLTF1),
  10636. /* harmony export */ "GLTF2": () => (/* reexport safe */ _glTF_index__WEBPACK_IMPORTED_MODULE_0__.GLTF2),
  10637. /* harmony export */ "GLTFFileLoader": () => (/* reexport safe */ _glTF_index__WEBPACK_IMPORTED_MODULE_0__.GLTFFileLoader),
  10638. /* harmony export */ "GLTFLoaderAnimationStartMode": () => (/* reexport safe */ _glTF_index__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderAnimationStartMode),
  10639. /* harmony export */ "GLTFLoaderCoordinateSystemMode": () => (/* reexport safe */ _glTF_index__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderCoordinateSystemMode),
  10640. /* harmony export */ "GLTFLoaderState": () => (/* reexport safe */ _glTF_index__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderState),
  10641. /* harmony export */ "GLTFValidation": () => (/* reexport safe */ _glTF_index__WEBPACK_IMPORTED_MODULE_0__.GLTFValidation),
  10642. /* harmony export */ "MTLFileLoader": () => (/* reexport safe */ _OBJ_index__WEBPACK_IMPORTED_MODULE_1__.MTLFileLoader),
  10643. /* harmony export */ "OBJFileLoader": () => (/* reexport safe */ _OBJ_index__WEBPACK_IMPORTED_MODULE_1__.OBJFileLoader),
  10644. /* harmony export */ "STLFileLoader": () => (/* reexport safe */ _STL_index__WEBPACK_IMPORTED_MODULE_2__.STLFileLoader),
  10645. /* harmony export */ "SolidParser": () => (/* reexport safe */ _OBJ_index__WEBPACK_IMPORTED_MODULE_1__.SolidParser)
  10646. /* harmony export */ });
  10647. /* harmony import */ var _glTF_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTF/index */ "../../../lts/loaders/dist/glTF/index.js");
  10648. /* harmony import */ var _OBJ_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./OBJ/index */ "../../../lts/loaders/dist/OBJ/index.js");
  10649. /* harmony import */ var _STL_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./STL/index */ "../../../lts/loaders/dist/STL/index.js");
  10650. /***/ }),
  10651. /***/ "../../../lts/loaders/dist/legacy/legacy-glTF.js":
  10652. /*!*******************************************************!*\
  10653. !*** ../../../lts/loaders/dist/legacy/legacy-glTF.js ***!
  10654. \*******************************************************/
  10655. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  10656. __webpack_require__.r(__webpack_exports__);
  10657. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  10658. /* harmony export */ "GLTFFileLoader": () => (/* reexport safe */ loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFFileLoader),
  10659. /* harmony export */ "GLTFLoaderAnimationStartMode": () => (/* reexport safe */ loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderAnimationStartMode),
  10660. /* harmony export */ "GLTFLoaderCoordinateSystemMode": () => (/* reexport safe */ loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderCoordinateSystemMode),
  10661. /* harmony export */ "GLTFLoaderState": () => (/* reexport safe */ loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderState),
  10662. /* harmony export */ "GLTFValidation": () => (/* reexport safe */ loaders_glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__.GLTFValidation)
  10663. /* harmony export */ });
  10664. /* harmony import */ var loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! loaders/glTF/glTFFileLoader */ "../../../lts/loaders/dist/glTF/glTFFileLoader.js");
  10665. /* harmony import */ var loaders_glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! loaders/glTF/glTFValidation */ "../../../lts/loaders/dist/glTF/glTFValidation.js");
  10666. /**
  10667. * This is the entry point for the UMD module.
  10668. * The entry point for a future ESM package should be index.ts
  10669. */
  10670. var globalObject = typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : undefined;
  10671. if (typeof globalObject !== "undefined") {
  10672. globalObject.BABYLON = globalObject.BABYLON || {};
  10673. for (var key in loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__) {
  10674. globalObject.BABYLON[key] = loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__[key];
  10675. }
  10676. for (var key in loaders_glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__) {
  10677. globalObject.BABYLON[key] = loaders_glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__[key];
  10678. }
  10679. }
  10680. /***/ }),
  10681. /***/ "../../../lts/loaders/dist/legacy/legacy-glTF1.js":
  10682. /*!********************************************************!*\
  10683. !*** ../../../lts/loaders/dist/legacy/legacy-glTF1.js ***!
  10684. \********************************************************/
  10685. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  10686. __webpack_require__.r(__webpack_exports__);
  10687. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  10688. /* harmony export */ "GLTF1": () => (/* reexport module object */ loaders_glTF_1_0_index__WEBPACK_IMPORTED_MODULE_0__)
  10689. /* harmony export */ });
  10690. /* harmony import */ var loaders_glTF_1_0_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! loaders/glTF/1.0/index */ "../../../lts/loaders/dist/glTF/1.0/index.js");
  10691. /**
  10692. * This is the entry point for the UMD module.
  10693. * The entry point for a future ESM package should be index.ts
  10694. */
  10695. var globalObject = typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : undefined;
  10696. if (typeof globalObject !== "undefined") {
  10697. globalObject.BABYLON = globalObject.BABYLON || {};
  10698. globalObject.BABYLON.GLTF1 = globalObject.BABYLON.GLTF1 || {};
  10699. for (var key in loaders_glTF_1_0_index__WEBPACK_IMPORTED_MODULE_0__) {
  10700. globalObject.BABYLON.GLTF1[key] = loaders_glTF_1_0_index__WEBPACK_IMPORTED_MODULE_0__[key];
  10701. }
  10702. }
  10703. /***/ }),
  10704. /***/ "../../../lts/loaders/dist/legacy/legacy-glTF2.js":
  10705. /*!********************************************************!*\
  10706. !*** ../../../lts/loaders/dist/legacy/legacy-glTF2.js ***!
  10707. \********************************************************/
  10708. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  10709. __webpack_require__.r(__webpack_exports__);
  10710. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  10711. /* harmony export */ "GLTF2": () => (/* reexport module object */ loaders_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_2__)
  10712. /* harmony export */ });
  10713. /* harmony import */ var loaders_glTF_2_0_Extensions_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! loaders/glTF/2.0/Extensions/index */ "../../../lts/loaders/dist/glTF/2.0/Extensions/index.js");
  10714. /* harmony import */ var loaders_glTF_2_0_glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! loaders/glTF/2.0/glTFLoaderInterfaces */ "../../../lts/loaders/dist/glTF/2.0/glTFLoaderInterfaces.js");
  10715. /* harmony import */ var loaders_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! loaders/glTF/2.0/index */ "../../../lts/loaders/dist/glTF/2.0/index.js");
  10716. /**
  10717. * This is the entry point for the UMD module.
  10718. * The entry point for a future ESM package should be index.ts
  10719. */
  10720. var globalObject = typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : undefined;
  10721. if (typeof globalObject !== "undefined") {
  10722. globalObject.BABYLON = globalObject.BABYLON || {};
  10723. var BABYLON_1 = globalObject.BABYLON;
  10724. BABYLON_1.GLTF2 = BABYLON_1.GLTF2 || {};
  10725. BABYLON_1.GLTF2.Loader = BABYLON_1.GLTF2.Loader || {};
  10726. BABYLON_1.GLTF2.Loader.Extensions = BABYLON_1.GLTF2.Loader.Extensions || {};
  10727. var keys = [];
  10728. for (var key in loaders_glTF_2_0_Extensions_index__WEBPACK_IMPORTED_MODULE_0__) {
  10729. BABYLON_1.GLTF2.Loader.Extensions[key] = loaders_glTF_2_0_Extensions_index__WEBPACK_IMPORTED_MODULE_0__[key];
  10730. keys.push(key);
  10731. }
  10732. for (var key in loaders_glTF_2_0_glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_1__) {
  10733. BABYLON_1.GLTF2.Loader[key] = loaders_glTF_2_0_glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_1__[key];
  10734. keys.push(key);
  10735. }
  10736. for (var key in loaders_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_2__) {
  10737. // Prevent Reassignment.
  10738. if (keys.indexOf(key) > -1) {
  10739. continue;
  10740. }
  10741. BABYLON_1.GLTF2[key] = loaders_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_2__[key];
  10742. }
  10743. }
  10744. /***/ }),
  10745. /***/ "../../../lts/loaders/dist/legacy/legacy-objFileLoader.js":
  10746. /*!****************************************************************!*\
  10747. !*** ../../../lts/loaders/dist/legacy/legacy-objFileLoader.js ***!
  10748. \****************************************************************/
  10749. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  10750. __webpack_require__.r(__webpack_exports__);
  10751. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  10752. /* harmony export */ "MTLFileLoader": () => (/* reexport safe */ loaders_OBJ_index__WEBPACK_IMPORTED_MODULE_0__.MTLFileLoader),
  10753. /* harmony export */ "OBJFileLoader": () => (/* reexport safe */ loaders_OBJ_index__WEBPACK_IMPORTED_MODULE_0__.OBJFileLoader),
  10754. /* harmony export */ "SolidParser": () => (/* reexport safe */ loaders_OBJ_index__WEBPACK_IMPORTED_MODULE_0__.SolidParser)
  10755. /* harmony export */ });
  10756. /* harmony import */ var loaders_OBJ_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! loaders/OBJ/index */ "../../../lts/loaders/dist/OBJ/index.js");
  10757. /**
  10758. * This is the entry point for the UMD module.
  10759. * The entry point for a future ESM package should be index.ts
  10760. */
  10761. var globalObject = typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : undefined;
  10762. if (typeof globalObject !== "undefined") {
  10763. for (var key in loaders_OBJ_index__WEBPACK_IMPORTED_MODULE_0__) {
  10764. globalObject.BABYLON[key] = loaders_OBJ_index__WEBPACK_IMPORTED_MODULE_0__[key];
  10765. }
  10766. }
  10767. /***/ }),
  10768. /***/ "../../../lts/loaders/dist/legacy/legacy-stlFileLoader.js":
  10769. /*!****************************************************************!*\
  10770. !*** ../../../lts/loaders/dist/legacy/legacy-stlFileLoader.js ***!
  10771. \****************************************************************/
  10772. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  10773. __webpack_require__.r(__webpack_exports__);
  10774. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  10775. /* harmony export */ "STLFileLoader": () => (/* reexport safe */ loaders_STL_index__WEBPACK_IMPORTED_MODULE_0__.STLFileLoader)
  10776. /* harmony export */ });
  10777. /* harmony import */ var loaders_STL_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! loaders/STL/index */ "../../../lts/loaders/dist/STL/index.js");
  10778. /**
  10779. * This is the entry point for the UMD module.
  10780. * The entry point for a future ESM package should be index.ts
  10781. */
  10782. var globalObject = typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : undefined;
  10783. if (typeof globalObject !== "undefined") {
  10784. for (var key in loaders_STL_index__WEBPACK_IMPORTED_MODULE_0__) {
  10785. globalObject.BABYLON[key] = loaders_STL_index__WEBPACK_IMPORTED_MODULE_0__[key];
  10786. }
  10787. }
  10788. /***/ }),
  10789. /***/ "../../../lts/loaders/dist/legacy/legacy.js":
  10790. /*!**************************************************!*\
  10791. !*** ../../../lts/loaders/dist/legacy/legacy.js ***!
  10792. \**************************************************/
  10793. /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
  10794. __webpack_require__.r(__webpack_exports__);
  10795. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  10796. /* harmony export */ "GLTF1": () => (/* reexport safe */ loaders_index__WEBPACK_IMPORTED_MODULE_0__.GLTF1),
  10797. /* harmony export */ "GLTF2": () => (/* reexport safe */ loaders_index__WEBPACK_IMPORTED_MODULE_0__.GLTF2),
  10798. /* harmony export */ "GLTFFileLoader": () => (/* reexport safe */ loaders_index__WEBPACK_IMPORTED_MODULE_0__.GLTFFileLoader),
  10799. /* harmony export */ "GLTFLoaderAnimationStartMode": () => (/* reexport safe */ loaders_index__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderAnimationStartMode),
  10800. /* harmony export */ "GLTFLoaderCoordinateSystemMode": () => (/* reexport safe */ loaders_index__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderCoordinateSystemMode),
  10801. /* harmony export */ "GLTFLoaderState": () => (/* reexport safe */ loaders_index__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderState),
  10802. /* harmony export */ "GLTFValidation": () => (/* reexport safe */ loaders_index__WEBPACK_IMPORTED_MODULE_0__.GLTFValidation),
  10803. /* harmony export */ "MTLFileLoader": () => (/* reexport safe */ loaders_index__WEBPACK_IMPORTED_MODULE_0__.MTLFileLoader),
  10804. /* harmony export */ "OBJFileLoader": () => (/* reexport safe */ loaders_index__WEBPACK_IMPORTED_MODULE_0__.OBJFileLoader),
  10805. /* harmony export */ "STLFileLoader": () => (/* reexport safe */ loaders_index__WEBPACK_IMPORTED_MODULE_0__.STLFileLoader),
  10806. /* harmony export */ "SolidParser": () => (/* reexport safe */ loaders_index__WEBPACK_IMPORTED_MODULE_0__.SolidParser)
  10807. /* harmony export */ });
  10808. /* harmony import */ var loaders_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! loaders/index */ "../../../lts/loaders/dist/index.js");
  10809. /* harmony import */ var _legacy_glTF__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./legacy-glTF */ "../../../lts/loaders/dist/legacy/legacy-glTF.js");
  10810. /* harmony import */ var _legacy_glTF1__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./legacy-glTF1 */ "../../../lts/loaders/dist/legacy/legacy-glTF1.js");
  10811. /* harmony import */ var _legacy_glTF2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./legacy-glTF2 */ "../../../lts/loaders/dist/legacy/legacy-glTF2.js");
  10812. /* harmony import */ var _legacy_objFileLoader__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./legacy-objFileLoader */ "../../../lts/loaders/dist/legacy/legacy-objFileLoader.js");
  10813. /* harmony import */ var _legacy_stlFileLoader__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./legacy-stlFileLoader */ "../../../lts/loaders/dist/legacy/legacy-stlFileLoader.js");
  10814. /***/ }),
  10815. /***/ "core/Misc/observable":
  10816. /*!****************************************************************************************************!*\
  10817. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  10818. \****************************************************************************************************/
  10819. /***/ ((module) => {
  10820. module.exports = __WEBPACK_EXTERNAL_MODULE_core_Misc_observable__;
  10821. /***/ })
  10822. /******/ });
  10823. /************************************************************************/
  10824. /******/ // The module cache
  10825. /******/ var __webpack_module_cache__ = {};
  10826. /******/
  10827. /******/ // The require function
  10828. /******/ function __webpack_require__(moduleId) {
  10829. /******/ // Check if module is in cache
  10830. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  10831. /******/ if (cachedModule !== undefined) {
  10832. /******/ return cachedModule.exports;
  10833. /******/ }
  10834. /******/ // Create a new module (and put it into the cache)
  10835. /******/ var module = __webpack_module_cache__[moduleId] = {
  10836. /******/ // no module.id needed
  10837. /******/ // no module.loaded needed
  10838. /******/ exports: {}
  10839. /******/ };
  10840. /******/
  10841. /******/ // Execute the module function
  10842. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  10843. /******/
  10844. /******/ // Return the exports of the module
  10845. /******/ return module.exports;
  10846. /******/ }
  10847. /******/
  10848. /************************************************************************/
  10849. /******/ /* webpack/runtime/compat get default export */
  10850. /******/ (() => {
  10851. /******/ // getDefaultExport function for compatibility with non-harmony modules
  10852. /******/ __webpack_require__.n = (module) => {
  10853. /******/ var getter = module && module.__esModule ?
  10854. /******/ () => (module['default']) :
  10855. /******/ () => (module);
  10856. /******/ __webpack_require__.d(getter, { a: getter });
  10857. /******/ return getter;
  10858. /******/ };
  10859. /******/ })();
  10860. /******/
  10861. /******/ /* webpack/runtime/define property getters */
  10862. /******/ (() => {
  10863. /******/ // define getter functions for harmony exports
  10864. /******/ __webpack_require__.d = (exports, definition) => {
  10865. /******/ for(var key in definition) {
  10866. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  10867. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  10868. /******/ }
  10869. /******/ }
  10870. /******/ };
  10871. /******/ })();
  10872. /******/
  10873. /******/ /* webpack/runtime/global */
  10874. /******/ (() => {
  10875. /******/ __webpack_require__.g = (function() {
  10876. /******/ if (typeof globalThis === 'object') return globalThis;
  10877. /******/ try {
  10878. /******/ return this || new Function('return this')();
  10879. /******/ } catch (e) {
  10880. /******/ if (typeof window === 'object') return window;
  10881. /******/ }
  10882. /******/ })();
  10883. /******/ })();
  10884. /******/
  10885. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  10886. /******/ (() => {
  10887. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  10888. /******/ })();
  10889. /******/
  10890. /******/ /* webpack/runtime/make namespace object */
  10891. /******/ (() => {
  10892. /******/ // define __esModule on exports
  10893. /******/ __webpack_require__.r = (exports) => {
  10894. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  10895. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  10896. /******/ }
  10897. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  10898. /******/ };
  10899. /******/ })();
  10900. /******/
  10901. /************************************************************************/
  10902. var __webpack_exports__ = {};
  10903. // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
  10904. (() => {
  10905. /*!**********************!*\
  10906. !*** ./src/index.ts ***!
  10907. \**********************/
  10908. __webpack_require__.r(__webpack_exports__);
  10909. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  10910. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
  10911. /* harmony export */ "loaders": () => (/* reexport module object */ loaders_legacy_legacy__WEBPACK_IMPORTED_MODULE_0__)
  10912. /* harmony export */ });
  10913. /* harmony import */ var loaders_legacy_legacy__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! loaders/legacy/legacy */ "../../../lts/loaders/dist/legacy/legacy.js");
  10914. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (loaders_legacy_legacy__WEBPACK_IMPORTED_MODULE_0__);
  10915. })();
  10916. __webpack_exports__ = __webpack_exports__["default"];
  10917. /******/ return __webpack_exports__;
  10918. /******/ })()
  10919. ;
  10920. });
  10921. //# sourceMappingURL=babylonjs.loaders.js.map