babylon.glTF2FileLoader.js 260 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131
  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_babylonjs_Misc_tools__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy-glTF2FileLoader.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../../node_modules/webpack/buildin/global.js":
  99. /*!***********************************!*\
  100. !*** (webpack)/buildin/global.js ***!
  101. \***********************************/
  102. /*! no static exports found */
  103. /***/ (function(module, exports) {
  104. var g;
  105. // This works in non-strict mode
  106. g = (function() {
  107. return this;
  108. })();
  109. try {
  110. // This works if eval is allowed (see CSP)
  111. g = g || new Function("return this")();
  112. } catch (e) {
  113. // This works if the window reference is available
  114. if (typeof window === "object") g = window;
  115. }
  116. // g can still be undefined, but nothing to do about it...
  117. // We return undefined, instead of nothing here, so it's
  118. // easier to handle this case. if(!global) { ...}
  119. module.exports = g;
  120. /***/ }),
  121. /***/ "./glTF/2.0/Extensions/EXT_lights_image_based.ts":
  122. /*!*******************************************************!*\
  123. !*** ./glTF/2.0/Extensions/EXT_lights_image_based.ts ***!
  124. \*******************************************************/
  125. /*! exports provided: EXT_lights_image_based */
  126. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127. "use strict";
  128. __webpack_require__.r(__webpack_exports__);
  129. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EXT_lights_image_based", function() { return EXT_lights_image_based; });
  130. /* harmony import */ var babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.scalar */ "babylonjs/Misc/tools");
  131. /* harmony import */ var babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__);
  132. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "./glTF/2.0/glTFLoader.ts");
  133. var NAME = "EXT_lights_image_based";
  134. /**
  135. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  136. */
  137. var EXT_lights_image_based = /** @class */ (function () {
  138. /** @hidden */
  139. function EXT_lights_image_based(loader) {
  140. /**
  141. * The name of this extension.
  142. */
  143. this.name = NAME;
  144. this._loader = loader;
  145. this.enabled = this._loader.isExtensionUsed(NAME);
  146. }
  147. /** @hidden */
  148. EXT_lights_image_based.prototype.dispose = function () {
  149. delete this._loader;
  150. delete this._lights;
  151. };
  152. /** @hidden */
  153. EXT_lights_image_based.prototype.onLoading = function () {
  154. var extensions = this._loader.gltf.extensions;
  155. if (extensions && extensions[this.name]) {
  156. var extension = extensions[this.name];
  157. this._lights = extension.lights;
  158. }
  159. };
  160. /** @hidden */
  161. EXT_lights_image_based.prototype.loadSceneAsync = function (context, scene) {
  162. var _this = this;
  163. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].LoadExtensionAsync(context, scene, this.name, function (extensionContext, extension) {
  164. var promises = new Array();
  165. promises.push(_this._loader.loadSceneAsync(context, scene));
  166. _this._loader.logOpen("" + extensionContext);
  167. var light = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["ArrayItem"].Get(extensionContext + "/light", _this._lights, extension.light);
  168. promises.push(_this._loadLightAsync("#/extensions/" + _this.name + "/lights/" + extension.light, light).then(function (texture) {
  169. _this._loader.babylonScene.environmentTexture = texture;
  170. }));
  171. _this._loader.logClose();
  172. return Promise.all(promises).then(function () { });
  173. });
  174. };
  175. EXT_lights_image_based.prototype._loadLightAsync = function (context, light) {
  176. var _this = this;
  177. if (!light._loaded) {
  178. var promises = new Array();
  179. this._loader.logOpen("" + context);
  180. var imageData_1 = new Array(light.specularImages.length);
  181. var _loop_1 = function (mipmap) {
  182. var faces = light.specularImages[mipmap];
  183. imageData_1[mipmap] = new Array(faces.length);
  184. var _loop_2 = function (face) {
  185. var specularImageContext = context + "/specularImages/" + mipmap + "/" + face;
  186. this_1._loader.logOpen("" + specularImageContext);
  187. var index = faces[face];
  188. var image = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["ArrayItem"].Get(specularImageContext, this_1._loader.gltf.images, index);
  189. promises.push(this_1._loader.loadImageAsync("#/images/" + index, image).then(function (data) {
  190. imageData_1[mipmap][face] = data;
  191. }));
  192. this_1._loader.logClose();
  193. };
  194. for (var face = 0; face < faces.length; face++) {
  195. _loop_2(face);
  196. }
  197. };
  198. var this_1 = this;
  199. for (var mipmap = 0; mipmap < light.specularImages.length; mipmap++) {
  200. _loop_1(mipmap);
  201. }
  202. this._loader.logClose();
  203. light._loaded = Promise.all(promises).then(function () {
  204. var babylonTexture = new babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["RawCubeTexture"](_this._loader.babylonScene, null, light.specularImageSize);
  205. light._babylonTexture = babylonTexture;
  206. if (light.intensity != undefined) {
  207. babylonTexture.level = light.intensity;
  208. }
  209. if (light.rotation) {
  210. var rotation = babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(light.rotation);
  211. // Invert the rotation so that positive rotation is counter-clockwise.
  212. if (!_this._loader.babylonScene.useRightHandedSystem) {
  213. rotation = babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Inverse(rotation);
  214. }
  215. babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromQuaternionToRef(rotation, babylonTexture.getReflectionTextureMatrix());
  216. }
  217. var sphericalHarmonics = babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["SphericalHarmonics"].FromArray(light.irradianceCoefficients);
  218. sphericalHarmonics.scaleInPlace(light.intensity);
  219. sphericalHarmonics.convertIrradianceToLambertianRadiance();
  220. var sphericalPolynomial = babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"].FromHarmonics(sphericalHarmonics);
  221. // Compute the lod generation scale to fit exactly to the number of levels available.
  222. var lodGenerationScale = (imageData_1.length - 1) / babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(light.specularImageSize);
  223. return babylonTexture.updateRGBDAsync(imageData_1, sphericalPolynomial, lodGenerationScale);
  224. });
  225. }
  226. return light._loaded.then(function () {
  227. return light._babylonTexture;
  228. });
  229. };
  230. return EXT_lights_image_based;
  231. }());
  232. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].RegisterExtension(NAME, function (loader) { return new EXT_lights_image_based(loader); });
  233. /***/ }),
  234. /***/ "./glTF/2.0/Extensions/ExtrasAsMetadata.ts":
  235. /*!*************************************************!*\
  236. !*** ./glTF/2.0/Extensions/ExtrasAsMetadata.ts ***!
  237. \*************************************************/
  238. /*! exports provided: ExtrasAsMetadata */
  239. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  240. "use strict";
  241. __webpack_require__.r(__webpack_exports__);
  242. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExtrasAsMetadata", function() { return ExtrasAsMetadata; });
  243. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "./glTF/2.0/glTFLoader.ts");
  244. var NAME = "ExtrasAsMetadata";
  245. /**
  246. * Store glTF extras (if present) in BJS objects' metadata
  247. */
  248. var ExtrasAsMetadata = /** @class */ (function () {
  249. /** @hidden */
  250. function ExtrasAsMetadata(loader) {
  251. /**
  252. * The name of this extension.
  253. */
  254. this.name = NAME;
  255. /**
  256. * Defines whether this extension is enabled.
  257. */
  258. this.enabled = true;
  259. this._loader = loader;
  260. }
  261. ExtrasAsMetadata.prototype._assignExtras = function (babylonObject, gltfProp) {
  262. if (gltfProp.extras && Object.keys(gltfProp.extras).length > 0) {
  263. var metadata = (babylonObject.metadata = babylonObject.metadata || {});
  264. var gltf = (metadata.gltf = metadata.gltf || {});
  265. gltf.extras = gltfProp.extras;
  266. }
  267. };
  268. /** @hidden */
  269. ExtrasAsMetadata.prototype.dispose = function () {
  270. delete this._loader;
  271. };
  272. /** @hidden */
  273. ExtrasAsMetadata.prototype.loadNodeAsync = function (context, node, assign) {
  274. var _this = this;
  275. return this._loader.loadNodeAsync(context, node, function (babylonTransformNode) {
  276. _this._assignExtras(babylonTransformNode, node);
  277. assign(babylonTransformNode);
  278. });
  279. };
  280. /** @hidden */
  281. ExtrasAsMetadata.prototype.loadCameraAsync = function (context, camera, assign) {
  282. var _this = this;
  283. return this._loader.loadCameraAsync(context, camera, function (babylonCamera) {
  284. _this._assignExtras(babylonCamera, camera);
  285. assign(babylonCamera);
  286. });
  287. };
  288. /** @hidden */
  289. ExtrasAsMetadata.prototype.createMaterial = function (context, material, babylonDrawMode) {
  290. var babylonMaterial = this._loader.createMaterial(context, material, babylonDrawMode);
  291. this._assignExtras(babylonMaterial, material);
  292. return babylonMaterial;
  293. };
  294. return ExtrasAsMetadata;
  295. }());
  296. _glTFLoader__WEBPACK_IMPORTED_MODULE_0__["GLTFLoader"].RegisterExtension(NAME, function (loader) { return new ExtrasAsMetadata(loader); });
  297. /***/ }),
  298. /***/ "./glTF/2.0/Extensions/KHR_draco_mesh_compression.ts":
  299. /*!***********************************************************!*\
  300. !*** ./glTF/2.0/Extensions/KHR_draco_mesh_compression.ts ***!
  301. \***********************************************************/
  302. /*! exports provided: KHR_draco_mesh_compression */
  303. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  304. "use strict";
  305. __webpack_require__.r(__webpack_exports__);
  306. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KHR_draco_mesh_compression", function() { return KHR_draco_mesh_compression; });
  307. /* harmony import */ var babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Meshes/Compression/dracoCompression */ "babylonjs/Misc/tools");
  308. /* harmony import */ var babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__);
  309. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "./glTF/2.0/glTFLoader.ts");
  310. var NAME = "KHR_draco_mesh_compression";
  311. /**
  312. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  313. */
  314. var KHR_draco_mesh_compression = /** @class */ (function () {
  315. /** @hidden */
  316. function KHR_draco_mesh_compression(loader) {
  317. /**
  318. * The name of this extension.
  319. */
  320. this.name = NAME;
  321. this._loader = loader;
  322. this.enabled = babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"].DecoderAvailable && this._loader.isExtensionUsed(NAME);
  323. }
  324. /** @hidden */
  325. KHR_draco_mesh_compression.prototype.dispose = function () {
  326. delete this.dracoCompression;
  327. delete this._loader;
  328. };
  329. /** @hidden */
  330. KHR_draco_mesh_compression.prototype._loadVertexDataAsync = function (context, primitive, babylonMesh) {
  331. var _this = this;
  332. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].LoadExtensionAsync(context, primitive, this.name, function (extensionContext, extension) {
  333. if (primitive.mode != undefined) {
  334. if (primitive.mode !== 5 /* TRIANGLE_STRIP */ &&
  335. primitive.mode !== 4 /* TRIANGLES */) {
  336. throw new Error(context + ": Unsupported mode " + primitive.mode);
  337. }
  338. // TODO: handle triangle strips
  339. if (primitive.mode === 5 /* TRIANGLE_STRIP */) {
  340. throw new Error(context + ": Mode " + primitive.mode + " is not currently supported");
  341. }
  342. }
  343. var attributes = {};
  344. var loadAttribute = function (name, kind) {
  345. var uniqueId = extension.attributes[name];
  346. if (uniqueId == undefined) {
  347. return;
  348. }
  349. babylonMesh._delayInfo = babylonMesh._delayInfo || [];
  350. if (babylonMesh._delayInfo.indexOf(kind) === -1) {
  351. babylonMesh._delayInfo.push(kind);
  352. }
  353. attributes[kind] = uniqueId;
  354. };
  355. loadAttribute("POSITION", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].PositionKind);
  356. loadAttribute("NORMAL", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].NormalKind);
  357. loadAttribute("TANGENT", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].TangentKind);
  358. loadAttribute("TEXCOORD_0", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind);
  359. loadAttribute("TEXCOORD_1", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind);
  360. loadAttribute("JOINTS_0", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesKind);
  361. loadAttribute("WEIGHTS_0", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsKind);
  362. loadAttribute("COLOR_0", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].ColorKind);
  363. var bufferView = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["ArrayItem"].Get(extensionContext, _this._loader.gltf.bufferViews, extension.bufferView);
  364. if (!bufferView._dracoBabylonGeometry) {
  365. bufferView._dracoBabylonGeometry = _this._loader.loadBufferViewAsync("#/bufferViews/" + bufferView.index, bufferView).then(function (data) {
  366. var dracoCompression = _this.dracoCompression || babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"].Default;
  367. return dracoCompression.decodeMeshAsync(data, attributes).then(function (babylonVertexData) {
  368. var babylonGeometry = new babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__["Geometry"](babylonMesh.name, _this._loader.babylonScene);
  369. babylonVertexData.applyToGeometry(babylonGeometry);
  370. return babylonGeometry;
  371. }).catch(function (error) {
  372. throw new Error(context + ": " + error.message);
  373. });
  374. });
  375. }
  376. return bufferView._dracoBabylonGeometry;
  377. });
  378. };
  379. return KHR_draco_mesh_compression;
  380. }());
  381. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].RegisterExtension(NAME, function (loader) { return new KHR_draco_mesh_compression(loader); });
  382. /***/ }),
  383. /***/ "./glTF/2.0/Extensions/KHR_lights_punctual.ts":
  384. /*!****************************************************!*\
  385. !*** ./glTF/2.0/Extensions/KHR_lights_punctual.ts ***!
  386. \****************************************************/
  387. /*! exports provided: KHR_lights */
  388. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  389. "use strict";
  390. __webpack_require__.r(__webpack_exports__);
  391. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KHR_lights", function() { return KHR_lights; });
  392. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/tools");
  393. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  394. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "./glTF/2.0/glTFLoader.ts");
  395. var NAME = "KHR_lights_punctual";
  396. var LightType;
  397. (function (LightType) {
  398. LightType["DIRECTIONAL"] = "directional";
  399. LightType["POINT"] = "point";
  400. LightType["SPOT"] = "spot";
  401. })(LightType || (LightType = {}));
  402. /**
  403. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  404. */
  405. var KHR_lights = /** @class */ (function () {
  406. /** @hidden */
  407. function KHR_lights(loader) {
  408. /**
  409. * The name of this extension.
  410. */
  411. this.name = NAME;
  412. this._loader = loader;
  413. this.enabled = this._loader.isExtensionUsed(NAME);
  414. }
  415. /** @hidden */
  416. KHR_lights.prototype.dispose = function () {
  417. delete this._loader;
  418. delete this._lights;
  419. };
  420. /** @hidden */
  421. KHR_lights.prototype.onLoading = function () {
  422. var extensions = this._loader.gltf.extensions;
  423. if (extensions && extensions[this.name]) {
  424. var extension = extensions[this.name];
  425. this._lights = extension.lights;
  426. }
  427. };
  428. /** @hidden */
  429. KHR_lights.prototype.loadNodeAsync = function (context, node, assign) {
  430. var _this = this;
  431. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) {
  432. return _this._loader.loadNodeAsync(context, node, function (babylonMesh) {
  433. var babylonLight;
  434. var light = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["ArrayItem"].Get(extensionContext, _this._lights, extension.light);
  435. var name = light.name || babylonMesh.name;
  436. _this._loader.babylonScene._blockEntityCollection = _this._loader._forAssetContainer;
  437. switch (light.type) {
  438. case LightType.DIRECTIONAL: {
  439. babylonLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["DirectionalLight"](name, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Backward(), _this._loader.babylonScene);
  440. break;
  441. }
  442. case LightType.POINT: {
  443. babylonLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["PointLight"](name, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _this._loader.babylonScene);
  444. break;
  445. }
  446. case LightType.SPOT: {
  447. var babylonSpotLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["SpotLight"](name, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Backward(), 0, 1, _this._loader.babylonScene);
  448. babylonSpotLight.angle = ((light.spot && light.spot.outerConeAngle) || Math.PI / 4) * 2;
  449. babylonSpotLight.innerAngle = ((light.spot && light.spot.innerConeAngle) || 0) * 2;
  450. babylonLight = babylonSpotLight;
  451. break;
  452. }
  453. default: {
  454. _this._loader.babylonScene._blockEntityCollection = false;
  455. throw new Error(extensionContext + ": Invalid light type (" + light.type + ")");
  456. }
  457. }
  458. _this._loader.babylonScene._blockEntityCollection = false;
  459. babylonLight.falloffType = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Light"].FALLOFF_GLTF;
  460. babylonLight.diffuse = light.color ? babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(light.color) : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
  461. babylonLight.intensity = light.intensity == undefined ? 1 : light.intensity;
  462. babylonLight.range = light.range == undefined ? Number.MAX_VALUE : light.range;
  463. babylonLight.parent = babylonMesh;
  464. _this._loader._babylonLights.push(babylonLight);
  465. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].AddPointerMetadata(babylonLight, extensionContext);
  466. assign(babylonMesh);
  467. });
  468. });
  469. };
  470. return KHR_lights;
  471. }());
  472. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].RegisterExtension(NAME, function (loader) { return new KHR_lights(loader); });
  473. /***/ }),
  474. /***/ "./glTF/2.0/Extensions/KHR_materials_clearcoat.ts":
  475. /*!********************************************************!*\
  476. !*** ./glTF/2.0/Extensions/KHR_materials_clearcoat.ts ***!
  477. \********************************************************/
  478. /*! exports provided: KHR_materials_clearcoat */
  479. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  480. "use strict";
  481. __webpack_require__.r(__webpack_exports__);
  482. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KHR_materials_clearcoat", function() { return KHR_materials_clearcoat; });
  483. /* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/tools");
  484. /* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__);
  485. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "./glTF/2.0/glTFLoader.ts");
  486. var NAME = "KHR_materials_clearcoat";
  487. /**
  488. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  489. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  490. * !!! Experimental Extension Subject to Changes !!!
  491. */
  492. var KHR_materials_clearcoat = /** @class */ (function () {
  493. /** @hidden */
  494. function KHR_materials_clearcoat(loader) {
  495. /**
  496. * The name of this extension.
  497. */
  498. this.name = NAME;
  499. /**
  500. * Defines a number that determines the order the extensions are applied.
  501. */
  502. this.order = 190;
  503. this._loader = loader;
  504. this.enabled = this._loader.isExtensionUsed(NAME);
  505. }
  506. /** @hidden */
  507. KHR_materials_clearcoat.prototype.dispose = function () {
  508. delete this._loader;
  509. };
  510. /** @hidden */
  511. KHR_materials_clearcoat.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
  512. var _this = this;
  513. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
  514. var promises = new Array();
  515. promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
  516. promises.push(_this._loadClearCoatPropertiesAsync(extensionContext, extension, babylonMaterial));
  517. return Promise.all(promises).then(function () { });
  518. });
  519. };
  520. KHR_materials_clearcoat.prototype._loadClearCoatPropertiesAsync = function (context, properties, babylonMaterial) {
  521. if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"])) {
  522. throw new Error(context + ": Material type not supported");
  523. }
  524. var promises = new Array();
  525. babylonMaterial.clearCoat.isEnabled = true;
  526. if (properties.clearcoatFactor != undefined) {
  527. babylonMaterial.clearCoat.intensity = properties.clearcoatFactor;
  528. }
  529. else {
  530. babylonMaterial.clearCoat.intensity = 0;
  531. }
  532. if (properties.clearcoatTexture) {
  533. promises.push(this._loader.loadTextureInfoAsync(context + "/clearcoatTexture", properties.clearcoatTexture, function (texture) {
  534. texture.name = babylonMaterial.name + " (ClearCoat Intensity)";
  535. babylonMaterial.clearCoat.texture = texture;
  536. }));
  537. }
  538. if (properties.clearcoatRoughnessFactor != undefined) {
  539. babylonMaterial.clearCoat.roughness = properties.clearcoatRoughnessFactor;
  540. }
  541. else {
  542. babylonMaterial.clearCoat.roughness = 0;
  543. }
  544. if (properties.clearcoatRoughnessTexture) {
  545. promises.push(this._loader.loadTextureInfoAsync(context + "/clearcoatRoughnessTexture", properties.clearcoatRoughnessTexture, function (texture) {
  546. texture.name = babylonMaterial.name + " (ClearCoat Roughness)";
  547. babylonMaterial.clearCoat.texture = texture;
  548. }));
  549. }
  550. if (properties.clearcoatNormalTexture) {
  551. promises.push(this._loader.loadTextureInfoAsync(context + "/clearcoatNormalTexture", properties.clearcoatNormalTexture, function (texture) {
  552. texture.name = babylonMaterial.name + " (ClearCoat Normal)";
  553. babylonMaterial.clearCoat.bumpTexture = texture;
  554. }));
  555. babylonMaterial.invertNormalMapX = !babylonMaterial.getScene().useRightHandedSystem;
  556. babylonMaterial.invertNormalMapY = babylonMaterial.getScene().useRightHandedSystem;
  557. if (properties.clearcoatNormalTexture.scale != undefined) {
  558. babylonMaterial.clearCoat.bumpTexture.level = properties.clearcoatNormalTexture.scale;
  559. }
  560. }
  561. return Promise.all(promises).then(function () { });
  562. };
  563. return KHR_materials_clearcoat;
  564. }());
  565. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].RegisterExtension(NAME, function (loader) { return new KHR_materials_clearcoat(loader); });
  566. /***/ }),
  567. /***/ "./glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.ts":
  568. /*!********************************************************************!*\
  569. !*** ./glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.ts ***!
  570. \********************************************************************/
  571. /*! exports provided: KHR_materials_pbrSpecularGlossiness */
  572. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  573. "use strict";
  574. __webpack_require__.r(__webpack_exports__);
  575. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KHR_materials_pbrSpecularGlossiness", function() { return KHR_materials_pbrSpecularGlossiness; });
  576. /* harmony import */ var babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.color */ "babylonjs/Misc/tools");
  577. /* harmony import */ var babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__);
  578. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "./glTF/2.0/glTFLoader.ts");
  579. var NAME = "KHR_materials_pbrSpecularGlossiness";
  580. /**
  581. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  582. */
  583. var KHR_materials_pbrSpecularGlossiness = /** @class */ (function () {
  584. /** @hidden */
  585. function KHR_materials_pbrSpecularGlossiness(loader) {
  586. /**
  587. * The name of this extension.
  588. */
  589. this.name = NAME;
  590. /**
  591. * Defines a number that determines the order the extensions are applied.
  592. */
  593. this.order = 200;
  594. this._loader = loader;
  595. this.enabled = this._loader.isExtensionUsed(NAME);
  596. }
  597. /** @hidden */
  598. KHR_materials_pbrSpecularGlossiness.prototype.dispose = function () {
  599. delete this._loader;
  600. };
  601. /** @hidden */
  602. KHR_materials_pbrSpecularGlossiness.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
  603. var _this = this;
  604. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
  605. var promises = new Array();
  606. promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));
  607. promises.push(_this._loadSpecularGlossinessPropertiesAsync(extensionContext, material, extension, babylonMaterial));
  608. _this._loader.loadMaterialAlphaProperties(context, material, babylonMaterial);
  609. return Promise.all(promises).then(function () { });
  610. });
  611. };
  612. KHR_materials_pbrSpecularGlossiness.prototype._loadSpecularGlossinessPropertiesAsync = function (context, material, properties, babylonMaterial) {
  613. if (!(babylonMaterial instanceof babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"])) {
  614. throw new Error(context + ": Material type not supported");
  615. }
  616. var promises = new Array();
  617. babylonMaterial.metallic = null;
  618. babylonMaterial.roughness = null;
  619. if (properties.diffuseFactor) {
  620. babylonMaterial.albedoColor = babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(properties.diffuseFactor);
  621. babylonMaterial.alpha = properties.diffuseFactor[3];
  622. }
  623. else {
  624. babylonMaterial.albedoColor = babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
  625. }
  626. babylonMaterial.reflectivityColor = properties.specularFactor ? babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(properties.specularFactor) : babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
  627. babylonMaterial.microSurface = properties.glossinessFactor == undefined ? 1 : properties.glossinessFactor;
  628. if (properties.diffuseTexture) {
  629. promises.push(this._loader.loadTextureInfoAsync(context + "/diffuseTexture", properties.diffuseTexture, function (texture) {
  630. texture.name = babylonMaterial.name + " (Diffuse)";
  631. babylonMaterial.albedoTexture = texture;
  632. }));
  633. }
  634. if (properties.specularGlossinessTexture) {
  635. promises.push(this._loader.loadTextureInfoAsync(context + "/specularGlossinessTexture", properties.specularGlossinessTexture, function (texture) {
  636. texture.name = babylonMaterial.name + " (Specular Glossiness)";
  637. babylonMaterial.reflectivityTexture = texture;
  638. }));
  639. babylonMaterial.reflectivityTexture.hasAlpha = true;
  640. babylonMaterial.useMicroSurfaceFromReflectivityMapAlpha = true;
  641. }
  642. return Promise.all(promises).then(function () { });
  643. };
  644. return KHR_materials_pbrSpecularGlossiness;
  645. }());
  646. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].RegisterExtension(NAME, function (loader) { return new KHR_materials_pbrSpecularGlossiness(loader); });
  647. /***/ }),
  648. /***/ "./glTF/2.0/Extensions/KHR_materials_sheen.ts":
  649. /*!****************************************************!*\
  650. !*** ./glTF/2.0/Extensions/KHR_materials_sheen.ts ***!
  651. \****************************************************/
  652. /*! exports provided: KHR_materials_sheen */
  653. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  654. "use strict";
  655. __webpack_require__.r(__webpack_exports__);
  656. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KHR_materials_sheen", function() { return KHR_materials_sheen; });
  657. /* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/tools");
  658. /* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__);
  659. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "./glTF/2.0/glTFLoader.ts");
  660. var NAME = "KHR_materials_sheen";
  661. /**
  662. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  663. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  664. * !!! Experimental Extension Subject to Changes !!!
  665. */
  666. var KHR_materials_sheen = /** @class */ (function () {
  667. /** @hidden */
  668. function KHR_materials_sheen(loader) {
  669. /**
  670. * The name of this extension.
  671. */
  672. this.name = NAME;
  673. /**
  674. * Defines a number that determines the order the extensions are applied.
  675. */
  676. this.order = 190;
  677. this._loader = loader;
  678. this.enabled = this._loader.isExtensionUsed(NAME);
  679. }
  680. /** @hidden */
  681. KHR_materials_sheen.prototype.dispose = function () {
  682. delete this._loader;
  683. };
  684. /** @hidden */
  685. KHR_materials_sheen.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
  686. var _this = this;
  687. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
  688. var promises = new Array();
  689. promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
  690. promises.push(_this._loadSheenPropertiesAsync(extensionContext, extension, babylonMaterial));
  691. return Promise.all(promises).then(function () { });
  692. });
  693. };
  694. KHR_materials_sheen.prototype._loadSheenPropertiesAsync = function (context, properties, babylonMaterial) {
  695. if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"])) {
  696. throw new Error(context + ": Material type not supported");
  697. }
  698. var promises = new Array();
  699. babylonMaterial.sheen.isEnabled = true;
  700. if (properties.intensityFactor != undefined) {
  701. babylonMaterial.sheen.intensity = properties.intensityFactor;
  702. }
  703. else {
  704. babylonMaterial.sheen.intensity = 0;
  705. }
  706. if (properties.colorFactor != undefined) {
  707. babylonMaterial.sheen.color = babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(properties.colorFactor);
  708. }
  709. if (properties.colorIntensityTexture) {
  710. promises.push(this._loader.loadTextureInfoAsync(context + "/sheenTexture", properties.colorIntensityTexture, function (texture) {
  711. texture.name = babylonMaterial.name + " (Sheen Intensity)";
  712. babylonMaterial.sheen.texture = texture;
  713. }));
  714. }
  715. return Promise.all(promises).then(function () { });
  716. };
  717. return KHR_materials_sheen;
  718. }());
  719. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].RegisterExtension(NAME, function (loader) { return new KHR_materials_sheen(loader); });
  720. /***/ }),
  721. /***/ "./glTF/2.0/Extensions/KHR_materials_specular.ts":
  722. /*!*******************************************************!*\
  723. !*** ./glTF/2.0/Extensions/KHR_materials_specular.ts ***!
  724. \*******************************************************/
  725. /*! exports provided: KHR_materials_specular */
  726. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  727. "use strict";
  728. __webpack_require__.r(__webpack_exports__);
  729. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KHR_materials_specular", function() { return KHR_materials_specular; });
  730. /* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/tools");
  731. /* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__);
  732. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "./glTF/2.0/glTFLoader.ts");
  733. var NAME = "KHR_materials_specular";
  734. /**
  735. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  736. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  737. * !!! Experimental Extension Subject to Changes !!!
  738. */
  739. var KHR_materials_specular = /** @class */ (function () {
  740. /** @hidden */
  741. function KHR_materials_specular(loader) {
  742. /**
  743. * The name of this extension.
  744. */
  745. this.name = NAME;
  746. /**
  747. * Defines a number that determines the order the extensions are applied.
  748. */
  749. this.order = 190;
  750. this._loader = loader;
  751. this.enabled = this._loader.isExtensionUsed(NAME);
  752. }
  753. /** @hidden */
  754. KHR_materials_specular.prototype.dispose = function () {
  755. delete this._loader;
  756. };
  757. /** @hidden */
  758. KHR_materials_specular.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
  759. var _this = this;
  760. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
  761. var promises = new Array();
  762. promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));
  763. promises.push(_this._loadSpecularPropertiesAsync(extensionContext, extension, babylonMaterial));
  764. return Promise.all(promises).then(function () { });
  765. });
  766. };
  767. KHR_materials_specular.prototype._loadSpecularPropertiesAsync = function (context, properties, babylonMaterial) {
  768. if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"])) {
  769. throw new Error(context + ": Material type not supported");
  770. }
  771. if (properties.specularFactor !== undefined) {
  772. babylonMaterial.metallicF0Factor = properties.specularFactor;
  773. }
  774. if (properties.specularTexture) {
  775. // This does not allow a separate sampler for it at the moment but is currently under discussion.
  776. babylonMaterial.useMetallicF0FactorFromMetallicTexture = true;
  777. }
  778. return Promise.resolve();
  779. };
  780. return KHR_materials_specular;
  781. }());
  782. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].RegisterExtension(NAME, function (loader) { return new KHR_materials_specular(loader); });
  783. /***/ }),
  784. /***/ "./glTF/2.0/Extensions/KHR_materials_unlit.ts":
  785. /*!****************************************************!*\
  786. !*** ./glTF/2.0/Extensions/KHR_materials_unlit.ts ***!
  787. \****************************************************/
  788. /*! exports provided: KHR_materials_unlit */
  789. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  790. "use strict";
  791. __webpack_require__.r(__webpack_exports__);
  792. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KHR_materials_unlit", function() { return KHR_materials_unlit; });
  793. /* harmony import */ var babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.color */ "babylonjs/Misc/tools");
  794. /* harmony import */ var babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__);
  795. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "./glTF/2.0/glTFLoader.ts");
  796. var NAME = "KHR_materials_unlit";
  797. /**
  798. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  799. */
  800. var KHR_materials_unlit = /** @class */ (function () {
  801. /** @hidden */
  802. function KHR_materials_unlit(loader) {
  803. /**
  804. * The name of this extension.
  805. */
  806. this.name = NAME;
  807. /**
  808. * Defines a number that determines the order the extensions are applied.
  809. */
  810. this.order = 210;
  811. this._loader = loader;
  812. this.enabled = this._loader.isExtensionUsed(NAME);
  813. }
  814. /** @hidden */
  815. KHR_materials_unlit.prototype.dispose = function () {
  816. delete this._loader;
  817. };
  818. /** @hidden */
  819. KHR_materials_unlit.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
  820. var _this = this;
  821. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].LoadExtensionAsync(context, material, this.name, function () {
  822. return _this._loadUnlitPropertiesAsync(context, material, babylonMaterial);
  823. });
  824. };
  825. KHR_materials_unlit.prototype._loadUnlitPropertiesAsync = function (context, material, babylonMaterial) {
  826. if (!(babylonMaterial instanceof babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"])) {
  827. throw new Error(context + ": Material type not supported");
  828. }
  829. var promises = new Array();
  830. babylonMaterial.unlit = true;
  831. var properties = material.pbrMetallicRoughness;
  832. if (properties) {
  833. if (properties.baseColorFactor) {
  834. babylonMaterial.albedoColor = babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(properties.baseColorFactor);
  835. babylonMaterial.alpha = properties.baseColorFactor[3];
  836. }
  837. else {
  838. babylonMaterial.albedoColor = babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
  839. }
  840. if (properties.baseColorTexture) {
  841. promises.push(this._loader.loadTextureInfoAsync(context + "/baseColorTexture", properties.baseColorTexture, function (texture) {
  842. texture.name = babylonMaterial.name + " (Base Color)";
  843. babylonMaterial.albedoTexture = texture;
  844. }));
  845. }
  846. }
  847. if (material.doubleSided) {
  848. babylonMaterial.backFaceCulling = false;
  849. babylonMaterial.twoSidedLighting = true;
  850. }
  851. this._loader.loadMaterialAlphaProperties(context, material, babylonMaterial);
  852. return Promise.all(promises).then(function () { });
  853. };
  854. return KHR_materials_unlit;
  855. }());
  856. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].RegisterExtension(NAME, function (loader) { return new KHR_materials_unlit(loader); });
  857. /***/ }),
  858. /***/ "./glTF/2.0/Extensions/KHR_mesh_quantization.ts":
  859. /*!******************************************************!*\
  860. !*** ./glTF/2.0/Extensions/KHR_mesh_quantization.ts ***!
  861. \******************************************************/
  862. /*! exports provided: KHR_mesh_quantization */
  863. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  864. "use strict";
  865. __webpack_require__.r(__webpack_exports__);
  866. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KHR_mesh_quantization", function() { return KHR_mesh_quantization; });
  867. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "./glTF/2.0/glTFLoader.ts");
  868. var NAME = "KHR_mesh_quantization";
  869. /**
  870. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  871. */
  872. var KHR_mesh_quantization = /** @class */ (function () {
  873. /** @hidden */
  874. function KHR_mesh_quantization(loader) {
  875. /**
  876. * The name of this extension.
  877. */
  878. this.name = NAME;
  879. this.enabled = loader.isExtensionUsed(NAME);
  880. }
  881. /** @hidden */
  882. KHR_mesh_quantization.prototype.dispose = function () {
  883. };
  884. return KHR_mesh_quantization;
  885. }());
  886. _glTFLoader__WEBPACK_IMPORTED_MODULE_0__["GLTFLoader"].RegisterExtension(NAME, function (loader) { return new KHR_mesh_quantization(loader); });
  887. /***/ }),
  888. /***/ "./glTF/2.0/Extensions/KHR_texture_basisu.ts":
  889. /*!***************************************************!*\
  890. !*** ./glTF/2.0/Extensions/KHR_texture_basisu.ts ***!
  891. \***************************************************/
  892. /*! exports provided: KHR_texture_basisu */
  893. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  894. "use strict";
  895. __webpack_require__.r(__webpack_exports__);
  896. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KHR_texture_basisu", function() { return KHR_texture_basisu; });
  897. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "./glTF/2.0/glTFLoader.ts");
  898. var NAME = "KHR_texture_basisu";
  899. /**
  900. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  901. * !!! Experimental Extension Subject to Changes !!!
  902. */
  903. var KHR_texture_basisu = /** @class */ (function () {
  904. /** @hidden */
  905. function KHR_texture_basisu(loader) {
  906. /** The name of this extension. */
  907. this.name = NAME;
  908. this._loader = loader;
  909. this.enabled = loader.isExtensionUsed(NAME);
  910. }
  911. /** @hidden */
  912. KHR_texture_basisu.prototype.dispose = function () {
  913. delete this._loader;
  914. };
  915. /** @hidden */
  916. KHR_texture_basisu.prototype._loadTextureAsync = function (context, texture, assign) {
  917. var _this = this;
  918. return _glTFLoader__WEBPACK_IMPORTED_MODULE_0__["GLTFLoader"].LoadExtensionAsync(context, texture, this.name, function (extensionContext, extension) {
  919. var sampler = (texture.sampler == undefined ? _glTFLoader__WEBPACK_IMPORTED_MODULE_0__["GLTFLoader"].DefaultSampler : _glTFLoader__WEBPACK_IMPORTED_MODULE_0__["ArrayItem"].Get(context + "/sampler", _this._loader.gltf.samplers, texture.sampler));
  920. var image = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__["ArrayItem"].Get(extensionContext + "/source", _this._loader.gltf.images, extension.source);
  921. return _this._loader._createTextureAsync(context, sampler, image, function (babylonTexture) {
  922. babylonTexture.gammaSpace = false;
  923. assign(babylonTexture);
  924. });
  925. });
  926. };
  927. return KHR_texture_basisu;
  928. }());
  929. _glTFLoader__WEBPACK_IMPORTED_MODULE_0__["GLTFLoader"].RegisterExtension(NAME, function (loader) { return new KHR_texture_basisu(loader); });
  930. /***/ }),
  931. /***/ "./glTF/2.0/Extensions/KHR_texture_transform.ts":
  932. /*!******************************************************!*\
  933. !*** ./glTF/2.0/Extensions/KHR_texture_transform.ts ***!
  934. \******************************************************/
  935. /*! exports provided: KHR_texture_transform */
  936. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  937. "use strict";
  938. __webpack_require__.r(__webpack_exports__);
  939. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KHR_texture_transform", function() { return KHR_texture_transform; });
  940. /* harmony import */ var babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/Textures/texture */ "babylonjs/Misc/tools");
  941. /* harmony import */ var babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__);
  942. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "./glTF/2.0/glTFLoader.ts");
  943. var NAME = "KHR_texture_transform";
  944. /**
  945. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  946. */
  947. var KHR_texture_transform = /** @class */ (function () {
  948. /** @hidden */
  949. function KHR_texture_transform(loader) {
  950. /**
  951. * The name of this extension.
  952. */
  953. this.name = NAME;
  954. this._loader = loader;
  955. this.enabled = this._loader.isExtensionUsed(NAME);
  956. }
  957. /** @hidden */
  958. KHR_texture_transform.prototype.dispose = function () {
  959. delete this._loader;
  960. };
  961. /** @hidden */
  962. KHR_texture_transform.prototype.loadTextureInfoAsync = function (context, textureInfo, assign) {
  963. var _this = this;
  964. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].LoadExtensionAsync(context, textureInfo, this.name, function (extensionContext, extension) {
  965. return _this._loader.loadTextureInfoAsync(context, textureInfo, function (babylonTexture) {
  966. if (!(babylonTexture instanceof babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"])) {
  967. throw new Error(extensionContext + ": Texture type not supported");
  968. }
  969. if (extension.offset) {
  970. babylonTexture.uOffset = extension.offset[0];
  971. babylonTexture.vOffset = extension.offset[1];
  972. }
  973. // Always rotate around the origin.
  974. babylonTexture.uRotationCenter = 0;
  975. babylonTexture.vRotationCenter = 0;
  976. if (extension.rotation) {
  977. babylonTexture.wAng = -extension.rotation;
  978. }
  979. if (extension.scale) {
  980. babylonTexture.uScale = extension.scale[0];
  981. babylonTexture.vScale = extension.scale[1];
  982. }
  983. if (extension.texCoord != undefined) {
  984. babylonTexture.coordinatesIndex = extension.texCoord;
  985. }
  986. assign(babylonTexture);
  987. });
  988. });
  989. };
  990. return KHR_texture_transform;
  991. }());
  992. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].RegisterExtension(NAME, function (loader) { return new KHR_texture_transform(loader); });
  993. /***/ }),
  994. /***/ "./glTF/2.0/Extensions/MSFT_audio_emitter.ts":
  995. /*!***************************************************!*\
  996. !*** ./glTF/2.0/Extensions/MSFT_audio_emitter.ts ***!
  997. \***************************************************/
  998. /*! exports provided: MSFT_audio_emitter */
  999. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1000. "use strict";
  1001. __webpack_require__.r(__webpack_exports__);
  1002. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MSFT_audio_emitter", function() { return MSFT_audio_emitter; });
  1003. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/tools");
  1004. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  1005. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "./glTF/2.0/glTFLoader.ts");
  1006. var NAME = "MSFT_audio_emitter";
  1007. /**
  1008. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  1009. */
  1010. var MSFT_audio_emitter = /** @class */ (function () {
  1011. /** @hidden */
  1012. function MSFT_audio_emitter(loader) {
  1013. /**
  1014. * The name of this extension.
  1015. */
  1016. this.name = NAME;
  1017. this._loader = loader;
  1018. this.enabled = this._loader.isExtensionUsed(NAME);
  1019. }
  1020. /** @hidden */
  1021. MSFT_audio_emitter.prototype.dispose = function () {
  1022. delete this._loader;
  1023. delete this._clips;
  1024. delete this._emitters;
  1025. };
  1026. /** @hidden */
  1027. MSFT_audio_emitter.prototype.onLoading = function () {
  1028. var extensions = this._loader.gltf.extensions;
  1029. if (extensions && extensions[this.name]) {
  1030. var extension = extensions[this.name];
  1031. this._clips = extension.clips;
  1032. this._emitters = extension.emitters;
  1033. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["ArrayItem"].Assign(this._clips);
  1034. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["ArrayItem"].Assign(this._emitters);
  1035. }
  1036. };
  1037. /** @hidden */
  1038. MSFT_audio_emitter.prototype.loadSceneAsync = function (context, scene) {
  1039. var _this = this;
  1040. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].LoadExtensionAsync(context, scene, this.name, function (extensionContext, extension) {
  1041. var promises = new Array();
  1042. promises.push(_this._loader.loadSceneAsync(context, scene));
  1043. for (var _i = 0, _a = extension.emitters; _i < _a.length; _i++) {
  1044. var emitterIndex = _a[_i];
  1045. var emitter = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["ArrayItem"].Get(extensionContext + "/emitters", _this._emitters, emitterIndex);
  1046. if (emitter.refDistance != undefined || emitter.maxDistance != undefined || emitter.rolloffFactor != undefined ||
  1047. emitter.distanceModel != undefined || emitter.innerAngle != undefined || emitter.outerAngle != undefined) {
  1048. throw new Error(extensionContext + ": Direction or Distance properties are not allowed on emitters attached to a scene");
  1049. }
  1050. promises.push(_this._loadEmitterAsync(extensionContext + "/emitters/" + emitter.index, emitter));
  1051. }
  1052. return Promise.all(promises).then(function () { });
  1053. });
  1054. };
  1055. /** @hidden */
  1056. MSFT_audio_emitter.prototype.loadNodeAsync = function (context, node, assign) {
  1057. var _this = this;
  1058. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) {
  1059. var promises = new Array();
  1060. return _this._loader.loadNodeAsync(extensionContext, node, function (babylonMesh) {
  1061. var _loop_1 = function (emitterIndex) {
  1062. var emitter = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["ArrayItem"].Get(extensionContext + "/emitters", _this._emitters, emitterIndex);
  1063. promises.push(_this._loadEmitterAsync(extensionContext + "/emitters/" + emitter.index, emitter).then(function () {
  1064. for (var _i = 0, _a = emitter._babylonSounds; _i < _a.length; _i++) {
  1065. var sound = _a[_i];
  1066. sound.attachToMesh(babylonMesh);
  1067. if (emitter.innerAngle != undefined || emitter.outerAngle != undefined) {
  1068. sound.setLocalDirectionToMesh(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Forward());
  1069. sound.setDirectionalCone(2 * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Tools"].ToDegrees(emitter.innerAngle == undefined ? Math.PI : emitter.innerAngle), 2 * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Tools"].ToDegrees(emitter.outerAngle == undefined ? Math.PI : emitter.outerAngle), 0);
  1070. }
  1071. }
  1072. }));
  1073. };
  1074. for (var _i = 0, _a = extension.emitters; _i < _a.length; _i++) {
  1075. var emitterIndex = _a[_i];
  1076. _loop_1(emitterIndex);
  1077. }
  1078. assign(babylonMesh);
  1079. }).then(function (babylonMesh) {
  1080. return Promise.all(promises).then(function () {
  1081. return babylonMesh;
  1082. });
  1083. });
  1084. });
  1085. };
  1086. /** @hidden */
  1087. MSFT_audio_emitter.prototype.loadAnimationAsync = function (context, animation) {
  1088. var _this = this;
  1089. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].LoadExtensionAsync(context, animation, this.name, function (extensionContext, extension) {
  1090. return _this._loader.loadAnimationAsync(context, animation).then(function (babylonAnimationGroup) {
  1091. var promises = new Array();
  1092. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["ArrayItem"].Assign(extension.events);
  1093. for (var _i = 0, _a = extension.events; _i < _a.length; _i++) {
  1094. var event_1 = _a[_i];
  1095. promises.push(_this._loadAnimationEventAsync(extensionContext + "/events/" + event_1.index, context, animation, event_1, babylonAnimationGroup));
  1096. }
  1097. return Promise.all(promises).then(function () {
  1098. return babylonAnimationGroup;
  1099. });
  1100. });
  1101. });
  1102. };
  1103. MSFT_audio_emitter.prototype._loadClipAsync = function (context, clip) {
  1104. if (clip._objectURL) {
  1105. return clip._objectURL;
  1106. }
  1107. var promise;
  1108. if (clip.uri) {
  1109. promise = this._loader.loadUriAsync(context, clip, clip.uri);
  1110. }
  1111. else {
  1112. var bufferView = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["ArrayItem"].Get(context + "/bufferView", this._loader.gltf.bufferViews, clip.bufferView);
  1113. promise = this._loader.loadBufferViewAsync("#/bufferViews/" + bufferView.index, bufferView);
  1114. }
  1115. clip._objectURL = promise.then(function (data) {
  1116. return URL.createObjectURL(new Blob([data], { type: clip.mimeType }));
  1117. });
  1118. return clip._objectURL;
  1119. };
  1120. MSFT_audio_emitter.prototype._loadEmitterAsync = function (context, emitter) {
  1121. var _this = this;
  1122. emitter._babylonSounds = emitter._babylonSounds || [];
  1123. if (!emitter._babylonData) {
  1124. var clipPromises = new Array();
  1125. var name_1 = emitter.name || "emitter" + emitter.index;
  1126. var options_1 = {
  1127. loop: false,
  1128. autoplay: false,
  1129. volume: emitter.volume == undefined ? 1 : emitter.volume,
  1130. };
  1131. var _loop_2 = function (i) {
  1132. var clipContext = "#/extensions/" + this_1.name + "/clips";
  1133. var clip = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["ArrayItem"].Get(clipContext, this_1._clips, emitter.clips[i].clip);
  1134. clipPromises.push(this_1._loadClipAsync(clipContext + "/" + emitter.clips[i].clip, clip).then(function (objectURL) {
  1135. var sound = emitter._babylonSounds[i] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Sound"](name_1, objectURL, _this._loader.babylonScene, null, options_1);
  1136. sound.refDistance = emitter.refDistance || 1;
  1137. sound.maxDistance = emitter.maxDistance || 256;
  1138. sound.rolloffFactor = emitter.rolloffFactor || 1;
  1139. sound.distanceModel = emitter.distanceModel || 'exponential';
  1140. sound._positionInEmitterSpace = true;
  1141. }));
  1142. };
  1143. var this_1 = this;
  1144. for (var i = 0; i < emitter.clips.length; i++) {
  1145. _loop_2(i);
  1146. }
  1147. var promise = Promise.all(clipPromises).then(function () {
  1148. var weights = emitter.clips.map(function (clip) { return clip.weight || 1; });
  1149. var weightedSound = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["WeightedSound"](emitter.loop || false, emitter._babylonSounds, weights);
  1150. if (emitter.innerAngle) {
  1151. weightedSound.directionalConeInnerAngle = 2 * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Tools"].ToDegrees(emitter.innerAngle);
  1152. }
  1153. if (emitter.outerAngle) {
  1154. weightedSound.directionalConeOuterAngle = 2 * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Tools"].ToDegrees(emitter.outerAngle);
  1155. }
  1156. if (emitter.volume) {
  1157. weightedSound.volume = emitter.volume;
  1158. }
  1159. emitter._babylonData.sound = weightedSound;
  1160. });
  1161. emitter._babylonData = {
  1162. loaded: promise
  1163. };
  1164. }
  1165. return emitter._babylonData.loaded;
  1166. };
  1167. MSFT_audio_emitter.prototype._getEventAction = function (context, sound, action, time, startOffset) {
  1168. switch (action) {
  1169. case "play" /* play */: {
  1170. return function (currentFrame) {
  1171. var frameOffset = (startOffset || 0) + (currentFrame - time);
  1172. sound.play(frameOffset);
  1173. };
  1174. }
  1175. case "stop" /* stop */: {
  1176. return function (currentFrame) {
  1177. sound.stop();
  1178. };
  1179. }
  1180. case "pause" /* pause */: {
  1181. return function (currentFrame) {
  1182. sound.pause();
  1183. };
  1184. }
  1185. default: {
  1186. throw new Error(context + ": Unsupported action " + action);
  1187. }
  1188. }
  1189. };
  1190. MSFT_audio_emitter.prototype._loadAnimationEventAsync = function (context, animationContext, animation, event, babylonAnimationGroup) {
  1191. var _this = this;
  1192. if (babylonAnimationGroup.targetedAnimations.length == 0) {
  1193. return Promise.resolve();
  1194. }
  1195. var babylonAnimation = babylonAnimationGroup.targetedAnimations[0];
  1196. var emitterIndex = event.emitter;
  1197. var emitter = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["ArrayItem"].Get("#/extensions/" + this.name + "/emitters", this._emitters, emitterIndex);
  1198. return this._loadEmitterAsync(context, emitter).then(function () {
  1199. var sound = emitter._babylonData.sound;
  1200. if (sound) {
  1201. var babylonAnimationEvent = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["AnimationEvent"](event.time, _this._getEventAction(context, sound, event.action, event.time, event.startOffset));
  1202. babylonAnimation.animation.addEvent(babylonAnimationEvent);
  1203. // Make sure all started audio stops when this animation is terminated.
  1204. babylonAnimationGroup.onAnimationGroupEndObservable.add(function () {
  1205. sound.stop();
  1206. });
  1207. babylonAnimationGroup.onAnimationGroupPauseObservable.add(function () {
  1208. sound.pause();
  1209. });
  1210. }
  1211. });
  1212. };
  1213. return MSFT_audio_emitter;
  1214. }());
  1215. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].RegisterExtension(NAME, function (loader) { return new MSFT_audio_emitter(loader); });
  1216. /***/ }),
  1217. /***/ "./glTF/2.0/Extensions/MSFT_lod.ts":
  1218. /*!*****************************************!*\
  1219. !*** ./glTF/2.0/Extensions/MSFT_lod.ts ***!
  1220. \*****************************************/
  1221. /*! exports provided: MSFT_lod */
  1222. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1223. "use strict";
  1224. __webpack_require__.r(__webpack_exports__);
  1225. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MSFT_lod", function() { return MSFT_lod; });
  1226. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  1227. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  1228. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "./glTF/2.0/glTFLoader.ts");
  1229. var NAME = "MSFT_lod";
  1230. /**
  1231. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  1232. */
  1233. var MSFT_lod = /** @class */ (function () {
  1234. /** @hidden */
  1235. function MSFT_lod(loader) {
  1236. /**
  1237. * The name of this extension.
  1238. */
  1239. this.name = NAME;
  1240. /**
  1241. * Defines a number that determines the order the extensions are applied.
  1242. */
  1243. this.order = 100;
  1244. /**
  1245. * Maximum number of LODs to load, starting from the lowest LOD.
  1246. */
  1247. this.maxLODsToLoad = 10;
  1248. /**
  1249. * Observable raised when all node LODs of one level are loaded.
  1250. * The event data is the index of the loaded LOD starting from zero.
  1251. * Dispose the loader to cancel the loading of the next level of LODs.
  1252. */
  1253. this.onNodeLODsLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  1254. /**
  1255. * Observable raised when all material LODs of one level are loaded.
  1256. * The event data is the index of the loaded LOD starting from zero.
  1257. * Dispose the loader to cancel the loading of the next level of LODs.
  1258. */
  1259. this.onMaterialLODsLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  1260. this._nodeIndexLOD = null;
  1261. this._nodeSignalLODs = new Array();
  1262. this._nodePromiseLODs = new Array();
  1263. this._materialIndexLOD = null;
  1264. this._materialSignalLODs = new Array();
  1265. this._materialPromiseLODs = new Array();
  1266. this._indexLOD = null;
  1267. this._bufferLODs = new Array();
  1268. this._loader = loader;
  1269. this.enabled = this._loader.isExtensionUsed(NAME);
  1270. }
  1271. /** @hidden */
  1272. MSFT_lod.prototype.dispose = function () {
  1273. delete this._loader;
  1274. this._nodeIndexLOD = null;
  1275. this._nodeSignalLODs.length = 0;
  1276. this._nodePromiseLODs.length = 0;
  1277. this._materialIndexLOD = null;
  1278. this._materialSignalLODs.length = 0;
  1279. this._materialPromiseLODs.length = 0;
  1280. this._indexLOD = null;
  1281. this._bufferLODs.length = 0;
  1282. this.onMaterialLODsLoadedObservable.clear();
  1283. this.onNodeLODsLoadedObservable.clear();
  1284. };
  1285. /** @hidden */
  1286. MSFT_lod.prototype.onReady = function () {
  1287. var _this = this;
  1288. var _loop_1 = function (indexLOD) {
  1289. var promise = Promise.all(this_1._nodePromiseLODs[indexLOD]).then(function () {
  1290. if (indexLOD !== 0) {
  1291. _this._loader.endPerformanceCounter("Node LOD " + indexLOD);
  1292. }
  1293. _this._loader.log("Loaded node LOD " + indexLOD);
  1294. _this.onNodeLODsLoadedObservable.notifyObservers(indexLOD);
  1295. if (indexLOD !== _this._nodePromiseLODs.length - 1) {
  1296. _this._loader.startPerformanceCounter("Node LOD " + (indexLOD + 1));
  1297. if (_this._nodeSignalLODs[indexLOD]) {
  1298. _this._nodeSignalLODs[indexLOD].resolve();
  1299. }
  1300. }
  1301. });
  1302. this_1._loader._completePromises.push(promise);
  1303. };
  1304. var this_1 = this;
  1305. for (var indexLOD = 0; indexLOD < this._nodePromiseLODs.length; indexLOD++) {
  1306. _loop_1(indexLOD);
  1307. }
  1308. var _loop_2 = function (indexLOD) {
  1309. var promise = Promise.all(this_2._materialPromiseLODs[indexLOD]).then(function () {
  1310. if (indexLOD !== 0) {
  1311. _this._loader.endPerformanceCounter("Material LOD " + indexLOD);
  1312. }
  1313. _this._loader.log("Loaded material LOD " + indexLOD);
  1314. _this.onMaterialLODsLoadedObservable.notifyObservers(indexLOD);
  1315. if (indexLOD !== _this._materialPromiseLODs.length - 1) {
  1316. _this._loader.startPerformanceCounter("Material LOD " + (indexLOD + 1));
  1317. if (_this._materialSignalLODs[indexLOD]) {
  1318. _this._materialSignalLODs[indexLOD].resolve();
  1319. }
  1320. }
  1321. });
  1322. this_2._loader._completePromises.push(promise);
  1323. };
  1324. var this_2 = this;
  1325. for (var indexLOD = 0; indexLOD < this._materialPromiseLODs.length; indexLOD++) {
  1326. _loop_2(indexLOD);
  1327. }
  1328. for (var indexLOD = 1; indexLOD < this._bufferLODs.length; indexLOD++) {
  1329. this._loadBufferLOD(indexLOD);
  1330. }
  1331. };
  1332. /** @hidden */
  1333. MSFT_lod.prototype.loadSceneAsync = function (context, scene) {
  1334. var promise = this._loader.loadSceneAsync(context, scene);
  1335. if (this._bufferLODs.length !== 0) {
  1336. this._loadBufferLOD(0);
  1337. }
  1338. return promise;
  1339. };
  1340. /** @hidden */
  1341. MSFT_lod.prototype.loadNodeAsync = function (context, node, assign) {
  1342. var _this = this;
  1343. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) {
  1344. var firstPromise;
  1345. var nodeLODs = _this._getLODs(extensionContext, node, _this._loader.gltf.nodes, extension.ids);
  1346. _this._loader.logOpen("" + extensionContext);
  1347. var _loop_3 = function (indexLOD) {
  1348. var nodeLOD = nodeLODs[indexLOD];
  1349. _this._indexLOD = indexLOD;
  1350. if (indexLOD !== 0) {
  1351. _this._nodeIndexLOD = indexLOD;
  1352. _this._nodeSignalLODs[indexLOD] = _this._nodeSignalLODs[indexLOD] || new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Deferred"]();
  1353. }
  1354. var assign_1 = function (babylonTransformNode) { babylonTransformNode.setEnabled(false); };
  1355. var promise = _this._loader.loadNodeAsync("#/nodes/" + nodeLOD.index, nodeLOD, assign_1).then(function (babylonMesh) {
  1356. if (indexLOD !== 0) {
  1357. // TODO: should not rely on _babylonTransformNode
  1358. var previousNodeLOD = nodeLODs[indexLOD - 1];
  1359. if (previousNodeLOD._babylonTransformNode) {
  1360. _this._disposeTransformNode(previousNodeLOD._babylonTransformNode);
  1361. delete previousNodeLOD._babylonTransformNode;
  1362. }
  1363. }
  1364. babylonMesh.setEnabled(true);
  1365. return babylonMesh;
  1366. });
  1367. if (indexLOD === 0) {
  1368. firstPromise = promise;
  1369. }
  1370. else {
  1371. _this._nodeIndexLOD = null;
  1372. }
  1373. _this._indexLOD = null;
  1374. _this._nodePromiseLODs[indexLOD] = _this._nodePromiseLODs[indexLOD] || [];
  1375. _this._nodePromiseLODs[indexLOD].push(promise);
  1376. };
  1377. for (var indexLOD = 0; indexLOD < nodeLODs.length; indexLOD++) {
  1378. _loop_3(indexLOD);
  1379. }
  1380. _this._loader.logClose();
  1381. return firstPromise;
  1382. });
  1383. };
  1384. /** @hidden */
  1385. MSFT_lod.prototype._loadMaterialAsync = function (context, material, babylonMesh, babylonDrawMode, assign) {
  1386. var _this = this;
  1387. // Don't load material LODs if already loading a node LOD.
  1388. if (this._indexLOD) {
  1389. return null;
  1390. }
  1391. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
  1392. var firstPromise;
  1393. var materialLODs = _this._getLODs(extensionContext, material, _this._loader.gltf.materials, extension.ids);
  1394. _this._loader.logOpen("" + extensionContext);
  1395. var _loop_4 = function (indexLOD) {
  1396. var materialLOD = materialLODs[indexLOD];
  1397. _this._indexLOD = indexLOD;
  1398. if (indexLOD !== 0) {
  1399. _this._materialIndexLOD = indexLOD;
  1400. }
  1401. var promise = _this._loader._loadMaterialAsync("#/materials/" + materialLOD.index, materialLOD, babylonMesh, babylonDrawMode, function (babylonMaterial) {
  1402. if (indexLOD === 0) {
  1403. assign(babylonMaterial);
  1404. }
  1405. }).then(function (babylonMaterial) {
  1406. if (indexLOD !== 0) {
  1407. assign(babylonMaterial);
  1408. // TODO: should not rely on _data
  1409. var previousDataLOD = materialLODs[indexLOD - 1]._data;
  1410. if (previousDataLOD[babylonDrawMode]) {
  1411. _this._disposeMaterials([previousDataLOD[babylonDrawMode].babylonMaterial]);
  1412. delete previousDataLOD[babylonDrawMode];
  1413. }
  1414. }
  1415. return babylonMaterial;
  1416. });
  1417. if (indexLOD === 0) {
  1418. firstPromise = promise;
  1419. }
  1420. else {
  1421. _this._materialIndexLOD = null;
  1422. }
  1423. _this._indexLOD = null;
  1424. _this._materialPromiseLODs[indexLOD] = _this._materialPromiseLODs[indexLOD] || [];
  1425. _this._materialPromiseLODs[indexLOD].push(promise);
  1426. };
  1427. for (var indexLOD = 0; indexLOD < materialLODs.length; indexLOD++) {
  1428. _loop_4(indexLOD);
  1429. }
  1430. _this._loader.logClose();
  1431. return firstPromise;
  1432. });
  1433. };
  1434. /** @hidden */
  1435. MSFT_lod.prototype._loadUriAsync = function (context, property, uri) {
  1436. var _this = this;
  1437. // Defer the loading of uris if loading a material or node LOD.
  1438. if (this._materialIndexLOD !== null) {
  1439. this._loader.log("deferred");
  1440. var previousIndexLOD = this._materialIndexLOD - 1;
  1441. this._materialSignalLODs[previousIndexLOD] = this._materialSignalLODs[previousIndexLOD] || new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Deferred"]();
  1442. return this._materialSignalLODs[previousIndexLOD].promise.then(function () {
  1443. return _this._loader.loadUriAsync(context, property, uri);
  1444. });
  1445. }
  1446. else if (this._nodeIndexLOD !== null) {
  1447. this._loader.log("deferred");
  1448. var previousIndexLOD = this._nodeIndexLOD - 1;
  1449. this._nodeSignalLODs[previousIndexLOD] = this._nodeSignalLODs[previousIndexLOD] || new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Deferred"]();
  1450. return this._nodeSignalLODs[this._nodeIndexLOD - 1].promise.then(function () {
  1451. return _this._loader.loadUriAsync(context, property, uri);
  1452. });
  1453. }
  1454. return null;
  1455. };
  1456. /** @hidden */
  1457. MSFT_lod.prototype.loadBufferAsync = function (context, buffer, byteOffset, byteLength) {
  1458. if (this._loader.parent.useRangeRequests && !buffer.uri) {
  1459. if (!this._loader.bin) {
  1460. throw new Error(context + ": Uri is missing or the binary glTF is missing its binary chunk");
  1461. }
  1462. // Non-LOD buffers will be bucketed into the first LOD.
  1463. var indexLOD = this._indexLOD || 0;
  1464. var start = byteOffset;
  1465. var end = start + byteLength - 1;
  1466. var bufferLOD_1 = this._bufferLODs[indexLOD];
  1467. if (bufferLOD_1) {
  1468. bufferLOD_1.start = Math.min(bufferLOD_1.start, start);
  1469. bufferLOD_1.end = Math.max(bufferLOD_1.end, end);
  1470. }
  1471. else {
  1472. bufferLOD_1 = { start: start, end: end, loaded: new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Deferred"]() };
  1473. this._bufferLODs[indexLOD] = bufferLOD_1;
  1474. }
  1475. return bufferLOD_1.loaded.promise.then(function (data) {
  1476. return new Uint8Array(data.buffer, data.byteOffset + byteOffset - bufferLOD_1.start, byteLength);
  1477. });
  1478. }
  1479. return null;
  1480. };
  1481. MSFT_lod.prototype._loadBufferLOD = function (indexLOD) {
  1482. var bufferLOD = this._bufferLODs[indexLOD];
  1483. this._loader.bin.readAsync(bufferLOD.start, bufferLOD.end - bufferLOD.start + 1).then(function (data) {
  1484. bufferLOD.loaded.resolve(data);
  1485. }, function (error) {
  1486. bufferLOD.loaded.reject(error);
  1487. });
  1488. };
  1489. /**
  1490. * Gets an array of LOD properties from lowest to highest.
  1491. */
  1492. MSFT_lod.prototype._getLODs = function (context, property, array, ids) {
  1493. if (this.maxLODsToLoad <= 0) {
  1494. throw new Error("maxLODsToLoad must be greater than zero");
  1495. }
  1496. var properties = new Array();
  1497. for (var i = ids.length - 1; i >= 0; i--) {
  1498. properties.push(_glTFLoader__WEBPACK_IMPORTED_MODULE_1__["ArrayItem"].Get(context + "/ids/" + ids[i], array, ids[i]));
  1499. if (properties.length === this.maxLODsToLoad) {
  1500. return properties;
  1501. }
  1502. }
  1503. properties.push(property);
  1504. return properties;
  1505. };
  1506. MSFT_lod.prototype._disposeTransformNode = function (babylonTransformNode) {
  1507. var _this = this;
  1508. var babylonMaterials = new Array();
  1509. var babylonMaterial = babylonTransformNode.material;
  1510. if (babylonMaterial) {
  1511. babylonMaterials.push(babylonMaterial);
  1512. }
  1513. for (var _i = 0, _a = babylonTransformNode.getChildMeshes(); _i < _a.length; _i++) {
  1514. var babylonMesh = _a[_i];
  1515. if (babylonMesh.material) {
  1516. babylonMaterials.push(babylonMesh.material);
  1517. }
  1518. }
  1519. babylonTransformNode.dispose();
  1520. var babylonMaterialsToDispose = babylonMaterials.filter(function (babylonMaterial) { return _this._loader.babylonScene.meshes.every(function (mesh) { return mesh.material != babylonMaterial; }); });
  1521. this._disposeMaterials(babylonMaterialsToDispose);
  1522. };
  1523. MSFT_lod.prototype._disposeMaterials = function (babylonMaterials) {
  1524. var babylonTextures = {};
  1525. for (var _i = 0, babylonMaterials_1 = babylonMaterials; _i < babylonMaterials_1.length; _i++) {
  1526. var babylonMaterial = babylonMaterials_1[_i];
  1527. for (var _a = 0, _b = babylonMaterial.getActiveTextures(); _a < _b.length; _a++) {
  1528. var babylonTexture = _b[_a];
  1529. babylonTextures[babylonTexture.uniqueId] = babylonTexture;
  1530. }
  1531. babylonMaterial.dispose();
  1532. }
  1533. for (var uniqueId in babylonTextures) {
  1534. for (var _c = 0, _d = this._loader.babylonScene.materials; _c < _d.length; _c++) {
  1535. var babylonMaterial = _d[_c];
  1536. if (babylonMaterial.hasTexture(babylonTextures[uniqueId])) {
  1537. delete babylonTextures[uniqueId];
  1538. }
  1539. }
  1540. }
  1541. for (var uniqueId in babylonTextures) {
  1542. babylonTextures[uniqueId].dispose();
  1543. }
  1544. };
  1545. return MSFT_lod;
  1546. }());
  1547. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].RegisterExtension(NAME, function (loader) { return new MSFT_lod(loader); });
  1548. /***/ }),
  1549. /***/ "./glTF/2.0/Extensions/MSFT_minecraftMesh.ts":
  1550. /*!***************************************************!*\
  1551. !*** ./glTF/2.0/Extensions/MSFT_minecraftMesh.ts ***!
  1552. \***************************************************/
  1553. /*! exports provided: MSFT_minecraftMesh */
  1554. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1555. "use strict";
  1556. __webpack_require__.r(__webpack_exports__);
  1557. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MSFT_minecraftMesh", function() { return MSFT_minecraftMesh; });
  1558. /* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/tools");
  1559. /* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__);
  1560. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "./glTF/2.0/glTFLoader.ts");
  1561. var NAME = "MSFT_minecraftMesh";
  1562. /** @hidden */
  1563. var MSFT_minecraftMesh = /** @class */ (function () {
  1564. function MSFT_minecraftMesh(loader) {
  1565. this.name = NAME;
  1566. this._loader = loader;
  1567. this.enabled = this._loader.isExtensionUsed(NAME);
  1568. }
  1569. MSFT_minecraftMesh.prototype.dispose = function () {
  1570. delete this._loader;
  1571. };
  1572. MSFT_minecraftMesh.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
  1573. var _this = this;
  1574. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].LoadExtraAsync(context, material, this.name, function (extraContext, extra) {
  1575. if (extra) {
  1576. if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"])) {
  1577. throw new Error(extraContext + ": Material type not supported");
  1578. }
  1579. var promise = _this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial);
  1580. if (babylonMaterial.needAlphaBlending()) {
  1581. babylonMaterial.forceDepthWrite = true;
  1582. babylonMaterial.separateCullingPass = true;
  1583. }
  1584. babylonMaterial.backFaceCulling = babylonMaterial.forceDepthWrite;
  1585. babylonMaterial.twoSidedLighting = true;
  1586. return promise;
  1587. }
  1588. return null;
  1589. });
  1590. };
  1591. return MSFT_minecraftMesh;
  1592. }());
  1593. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].RegisterExtension(NAME, function (loader) { return new MSFT_minecraftMesh(loader); });
  1594. /***/ }),
  1595. /***/ "./glTF/2.0/Extensions/MSFT_sRGBFactors.ts":
  1596. /*!*************************************************!*\
  1597. !*** ./glTF/2.0/Extensions/MSFT_sRGBFactors.ts ***!
  1598. \*************************************************/
  1599. /*! exports provided: MSFT_sRGBFactors */
  1600. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1601. "use strict";
  1602. __webpack_require__.r(__webpack_exports__);
  1603. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MSFT_sRGBFactors", function() { return MSFT_sRGBFactors; });
  1604. /* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/tools");
  1605. /* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__);
  1606. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "./glTF/2.0/glTFLoader.ts");
  1607. var NAME = "MSFT_sRGBFactors";
  1608. /** @hidden */
  1609. var MSFT_sRGBFactors = /** @class */ (function () {
  1610. function MSFT_sRGBFactors(loader) {
  1611. this.name = NAME;
  1612. this._loader = loader;
  1613. this.enabled = this._loader.isExtensionUsed(NAME);
  1614. }
  1615. MSFT_sRGBFactors.prototype.dispose = function () {
  1616. delete this._loader;
  1617. };
  1618. MSFT_sRGBFactors.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
  1619. var _this = this;
  1620. return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].LoadExtraAsync(context, material, this.name, function (extraContext, extra) {
  1621. if (extra) {
  1622. if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"])) {
  1623. throw new Error(extraContext + ": Material type not supported");
  1624. }
  1625. var promise = _this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial);
  1626. if (!babylonMaterial.albedoTexture) {
  1627. babylonMaterial.albedoColor.toLinearSpaceToRef(babylonMaterial.albedoColor);
  1628. }
  1629. if (!babylonMaterial.reflectivityTexture) {
  1630. babylonMaterial.reflectivityColor.toLinearSpaceToRef(babylonMaterial.reflectivityColor);
  1631. }
  1632. return promise;
  1633. }
  1634. return null;
  1635. });
  1636. };
  1637. return MSFT_sRGBFactors;
  1638. }());
  1639. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].RegisterExtension(NAME, function (loader) { return new MSFT_sRGBFactors(loader); });
  1640. /***/ }),
  1641. /***/ "./glTF/2.0/Extensions/index.ts":
  1642. /*!**************************************!*\
  1643. !*** ./glTF/2.0/Extensions/index.ts ***!
  1644. \**************************************/
  1645. /*! exports provided: EXT_lights_image_based, KHR_draco_mesh_compression, KHR_lights, KHR_materials_pbrSpecularGlossiness, KHR_materials_unlit, KHR_materials_clearcoat, KHR_materials_sheen, KHR_materials_specular, KHR_mesh_quantization, KHR_texture_basisu, KHR_texture_transform, MSFT_audio_emitter, MSFT_lod, MSFT_minecraftMesh, MSFT_sRGBFactors, ExtrasAsMetadata */
  1646. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1647. "use strict";
  1648. __webpack_require__.r(__webpack_exports__);
  1649. /* harmony import */ var _EXT_lights_image_based__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./EXT_lights_image_based */ "./glTF/2.0/Extensions/EXT_lights_image_based.ts");
  1650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EXT_lights_image_based", function() { return _EXT_lights_image_based__WEBPACK_IMPORTED_MODULE_0__["EXT_lights_image_based"]; });
  1651. /* harmony import */ var _KHR_draco_mesh_compression__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./KHR_draco_mesh_compression */ "./glTF/2.0/Extensions/KHR_draco_mesh_compression.ts");
  1652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KHR_draco_mesh_compression", function() { return _KHR_draco_mesh_compression__WEBPACK_IMPORTED_MODULE_1__["KHR_draco_mesh_compression"]; });
  1653. /* harmony import */ var _KHR_lights_punctual__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./KHR_lights_punctual */ "./glTF/2.0/Extensions/KHR_lights_punctual.ts");
  1654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KHR_lights", function() { return _KHR_lights_punctual__WEBPACK_IMPORTED_MODULE_2__["KHR_lights"]; });
  1655. /* harmony import */ var _KHR_materials_pbrSpecularGlossiness__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./KHR_materials_pbrSpecularGlossiness */ "./glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.ts");
  1656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KHR_materials_pbrSpecularGlossiness", function() { return _KHR_materials_pbrSpecularGlossiness__WEBPACK_IMPORTED_MODULE_3__["KHR_materials_pbrSpecularGlossiness"]; });
  1657. /* harmony import */ var _KHR_materials_unlit__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./KHR_materials_unlit */ "./glTF/2.0/Extensions/KHR_materials_unlit.ts");
  1658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KHR_materials_unlit", function() { return _KHR_materials_unlit__WEBPACK_IMPORTED_MODULE_4__["KHR_materials_unlit"]; });
  1659. /* harmony import */ var _KHR_materials_clearcoat__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./KHR_materials_clearcoat */ "./glTF/2.0/Extensions/KHR_materials_clearcoat.ts");
  1660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KHR_materials_clearcoat", function() { return _KHR_materials_clearcoat__WEBPACK_IMPORTED_MODULE_5__["KHR_materials_clearcoat"]; });
  1661. /* harmony import */ var _KHR_materials_sheen__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./KHR_materials_sheen */ "./glTF/2.0/Extensions/KHR_materials_sheen.ts");
  1662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KHR_materials_sheen", function() { return _KHR_materials_sheen__WEBPACK_IMPORTED_MODULE_6__["KHR_materials_sheen"]; });
  1663. /* harmony import */ var _KHR_materials_specular__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./KHR_materials_specular */ "./glTF/2.0/Extensions/KHR_materials_specular.ts");
  1664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KHR_materials_specular", function() { return _KHR_materials_specular__WEBPACK_IMPORTED_MODULE_7__["KHR_materials_specular"]; });
  1665. /* harmony import */ var _KHR_mesh_quantization__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./KHR_mesh_quantization */ "./glTF/2.0/Extensions/KHR_mesh_quantization.ts");
  1666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KHR_mesh_quantization", function() { return _KHR_mesh_quantization__WEBPACK_IMPORTED_MODULE_8__["KHR_mesh_quantization"]; });
  1667. /* harmony import */ var _KHR_texture_basisu__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./KHR_texture_basisu */ "./glTF/2.0/Extensions/KHR_texture_basisu.ts");
  1668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KHR_texture_basisu", function() { return _KHR_texture_basisu__WEBPACK_IMPORTED_MODULE_9__["KHR_texture_basisu"]; });
  1669. /* harmony import */ var _KHR_texture_transform__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./KHR_texture_transform */ "./glTF/2.0/Extensions/KHR_texture_transform.ts");
  1670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KHR_texture_transform", function() { return _KHR_texture_transform__WEBPACK_IMPORTED_MODULE_10__["KHR_texture_transform"]; });
  1671. /* harmony import */ var _MSFT_audio_emitter__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./MSFT_audio_emitter */ "./glTF/2.0/Extensions/MSFT_audio_emitter.ts");
  1672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MSFT_audio_emitter", function() { return _MSFT_audio_emitter__WEBPACK_IMPORTED_MODULE_11__["MSFT_audio_emitter"]; });
  1673. /* harmony import */ var _MSFT_lod__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./MSFT_lod */ "./glTF/2.0/Extensions/MSFT_lod.ts");
  1674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MSFT_lod", function() { return _MSFT_lod__WEBPACK_IMPORTED_MODULE_12__["MSFT_lod"]; });
  1675. /* harmony import */ var _MSFT_minecraftMesh__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./MSFT_minecraftMesh */ "./glTF/2.0/Extensions/MSFT_minecraftMesh.ts");
  1676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MSFT_minecraftMesh", function() { return _MSFT_minecraftMesh__WEBPACK_IMPORTED_MODULE_13__["MSFT_minecraftMesh"]; });
  1677. /* harmony import */ var _MSFT_sRGBFactors__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./MSFT_sRGBFactors */ "./glTF/2.0/Extensions/MSFT_sRGBFactors.ts");
  1678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MSFT_sRGBFactors", function() { return _MSFT_sRGBFactors__WEBPACK_IMPORTED_MODULE_14__["MSFT_sRGBFactors"]; });
  1679. /* harmony import */ var _ExtrasAsMetadata__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ExtrasAsMetadata */ "./glTF/2.0/Extensions/ExtrasAsMetadata.ts");
  1680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtrasAsMetadata", function() { return _ExtrasAsMetadata__WEBPACK_IMPORTED_MODULE_15__["ExtrasAsMetadata"]; });
  1681. /***/ }),
  1682. /***/ "./glTF/2.0/glTFLoader.ts":
  1683. /*!********************************!*\
  1684. !*** ./glTF/2.0/glTFLoader.ts ***!
  1685. \********************************/
  1686. /*! exports provided: ArrayItem, GLTFLoader */
  1687. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1688. "use strict";
  1689. __webpack_require__.r(__webpack_exports__);
  1690. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayItem", function() { return ArrayItem; });
  1691. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GLTFLoader", function() { return GLTFLoader; });
  1692. /* harmony import */ var babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/deferred */ "babylonjs/Misc/tools");
  1693. /* harmony import */ var babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__);
  1694. /* harmony import */ var _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFFileLoader */ "./glTF/glTFFileLoader.ts");
  1695. /**
  1696. * Helper class for working with arrays when loading the glTF asset
  1697. */
  1698. var ArrayItem = /** @class */ (function () {
  1699. function ArrayItem() {
  1700. }
  1701. /**
  1702. * Gets an item from the given array.
  1703. * @param context The context when loading the asset
  1704. * @param array The array to get the item from
  1705. * @param index The index to the array
  1706. * @returns The array item
  1707. */
  1708. ArrayItem.Get = function (context, array, index) {
  1709. if (!array || index == undefined || !array[index]) {
  1710. throw new Error(context + ": Failed to find index (" + index + ")");
  1711. }
  1712. return array[index];
  1713. };
  1714. /**
  1715. * Assign an `index` field to each item of the given array.
  1716. * @param array The array of items
  1717. */
  1718. ArrayItem.Assign = function (array) {
  1719. if (array) {
  1720. for (var index = 0; index < array.length; index++) {
  1721. array[index].index = index;
  1722. }
  1723. }
  1724. };
  1725. return ArrayItem;
  1726. }());
  1727. /**
  1728. * The glTF 2.0 loader
  1729. */
  1730. var GLTFLoader = /** @class */ (function () {
  1731. /** @hidden */
  1732. function GLTFLoader(parent) {
  1733. /** @hidden */
  1734. this._completePromises = new Array();
  1735. /** @hidden */
  1736. this._forAssetContainer = false;
  1737. /** Storage */
  1738. this._babylonLights = [];
  1739. this._disposed = false;
  1740. this._state = null;
  1741. this._extensions = new Array();
  1742. this._defaultBabylonMaterialData = {};
  1743. this._requests = new Array();
  1744. this._parent = parent;
  1745. }
  1746. /**
  1747. * Registers a loader extension.
  1748. * @param name The name of the loader extension.
  1749. * @param factory The factory function that creates the loader extension.
  1750. */
  1751. GLTFLoader.RegisterExtension = function (name, factory) {
  1752. if (GLTFLoader.UnregisterExtension(name)) {
  1753. babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Extension with the name '" + name + "' already exists");
  1754. }
  1755. GLTFLoader._RegisteredExtensions[name] = {
  1756. factory: factory
  1757. };
  1758. };
  1759. /**
  1760. * Unregisters a loader extension.
  1761. * @param name The name of the loader extension.
  1762. * @returns A boolean indicating whether the extension has been unregistered
  1763. */
  1764. GLTFLoader.UnregisterExtension = function (name) {
  1765. if (!GLTFLoader._RegisteredExtensions[name]) {
  1766. return false;
  1767. }
  1768. delete GLTFLoader._RegisteredExtensions[name];
  1769. return true;
  1770. };
  1771. Object.defineProperty(GLTFLoader.prototype, "state", {
  1772. /**
  1773. * The loader state.
  1774. */
  1775. get: function () {
  1776. return this._state;
  1777. },
  1778. enumerable: true,
  1779. configurable: true
  1780. });
  1781. Object.defineProperty(GLTFLoader.prototype, "gltf", {
  1782. /**
  1783. * The object that represents the glTF JSON.
  1784. */
  1785. get: function () {
  1786. return this._gltf;
  1787. },
  1788. enumerable: true,
  1789. configurable: true
  1790. });
  1791. Object.defineProperty(GLTFLoader.prototype, "bin", {
  1792. /**
  1793. * The BIN chunk of a binary glTF.
  1794. */
  1795. get: function () {
  1796. return this._bin;
  1797. },
  1798. enumerable: true,
  1799. configurable: true
  1800. });
  1801. Object.defineProperty(GLTFLoader.prototype, "parent", {
  1802. /**
  1803. * The parent file loader.
  1804. */
  1805. get: function () {
  1806. return this._parent;
  1807. },
  1808. enumerable: true,
  1809. configurable: true
  1810. });
  1811. Object.defineProperty(GLTFLoader.prototype, "babylonScene", {
  1812. /**
  1813. * The Babylon scene when loading the asset.
  1814. */
  1815. get: function () {
  1816. return this._babylonScene;
  1817. },
  1818. enumerable: true,
  1819. configurable: true
  1820. });
  1821. Object.defineProperty(GLTFLoader.prototype, "rootBabylonMesh", {
  1822. /**
  1823. * The root Babylon mesh when loading the asset.
  1824. */
  1825. get: function () {
  1826. return this._rootBabylonMesh;
  1827. },
  1828. enumerable: true,
  1829. configurable: true
  1830. });
  1831. /** @hidden */
  1832. GLTFLoader.prototype.dispose = function () {
  1833. if (this._disposed) {
  1834. return;
  1835. }
  1836. this._disposed = true;
  1837. for (var _i = 0, _a = this._requests; _i < _a.length; _i++) {
  1838. var request = _a[_i];
  1839. request.abort();
  1840. }
  1841. this._requests.length = 0;
  1842. this._completePromises.length = 0;
  1843. for (var name_1 in this._extensions) {
  1844. var extension = this._extensions[name_1];
  1845. extension.dispose && extension.dispose();
  1846. delete this._extensions[name_1];
  1847. }
  1848. delete this._gltf;
  1849. delete this._babylonScene;
  1850. delete this._rootBabylonMesh;
  1851. delete this._progressCallback;
  1852. this._parent._clear();
  1853. };
  1854. /** @hidden */
  1855. GLTFLoader.prototype.importMeshAsync = function (meshesNames, scene, forAssetContainer, data, rootUrl, onProgress, fileName) {
  1856. var _this = this;
  1857. return Promise.resolve().then(function () {
  1858. _this._babylonScene = scene;
  1859. _this._rootUrl = rootUrl;
  1860. _this._fileName = fileName || "scene";
  1861. _this._progressCallback = onProgress;
  1862. _this._forAssetContainer = forAssetContainer;
  1863. _this._loadData(data);
  1864. var nodes = null;
  1865. if (meshesNames) {
  1866. var nodeMap_1 = {};
  1867. if (_this._gltf.nodes) {
  1868. for (var _i = 0, _a = _this._gltf.nodes; _i < _a.length; _i++) {
  1869. var node = _a[_i];
  1870. if (node.name) {
  1871. nodeMap_1[node.name] = node.index;
  1872. }
  1873. }
  1874. }
  1875. var names = (meshesNames instanceof Array) ? meshesNames : [meshesNames];
  1876. nodes = names.map(function (name) {
  1877. var node = nodeMap_1[name];
  1878. if (node === undefined) {
  1879. throw new Error("Failed to find node '" + name + "'");
  1880. }
  1881. return node;
  1882. });
  1883. }
  1884. return _this._loadAsync(nodes, function () {
  1885. return {
  1886. meshes: _this._getMeshes(),
  1887. particleSystems: [],
  1888. skeletons: _this._getSkeletons(),
  1889. animationGroups: _this._getAnimationGroups(),
  1890. lights: _this._babylonLights,
  1891. transformNodes: _this._getTransformNodes()
  1892. };
  1893. });
  1894. });
  1895. };
  1896. /** @hidden */
  1897. GLTFLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fileName) {
  1898. var _this = this;
  1899. return Promise.resolve().then(function () {
  1900. _this._babylonScene = scene;
  1901. _this._rootUrl = rootUrl;
  1902. _this._fileName = fileName || "scene";
  1903. _this._progressCallback = onProgress;
  1904. _this._loadData(data);
  1905. return _this._loadAsync(null, function () { return undefined; });
  1906. });
  1907. };
  1908. GLTFLoader.prototype._loadAsync = function (nodes, resultFunc) {
  1909. var _this = this;
  1910. return Promise.resolve().then(function () {
  1911. _this._uniqueRootUrl = (_this._rootUrl.indexOf("file:") === -1 && _this._fileName) ? _this._rootUrl : "" + _this._rootUrl + Date.now() + "/";
  1912. _this._loadExtensions();
  1913. _this._checkExtensions();
  1914. var loadingToReadyCounterName = _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"][_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"].LOADING] + " => " + _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"][_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"].READY];
  1915. var loadingToCompleteCounterName = _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"][_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"].LOADING] + " => " + _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"][_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"].COMPLETE];
  1916. _this._parent._startPerformanceCounter(loadingToReadyCounterName);
  1917. _this._parent._startPerformanceCounter(loadingToCompleteCounterName);
  1918. _this._setState(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"].LOADING);
  1919. _this._extensionsOnLoading();
  1920. var promises = new Array();
  1921. // Block the marking of materials dirty until the scene is loaded.
  1922. var oldBlockMaterialDirtyMechanism = _this._babylonScene.blockMaterialDirtyMechanism;
  1923. _this._babylonScene.blockMaterialDirtyMechanism = true;
  1924. if (nodes) {
  1925. promises.push(_this.loadSceneAsync("/nodes", { nodes: nodes, index: -1 }));
  1926. }
  1927. else if (_this._gltf.scene != undefined || (_this._gltf.scenes && _this._gltf.scenes[0])) {
  1928. var scene = ArrayItem.Get("/scene", _this._gltf.scenes, _this._gltf.scene || 0);
  1929. promises.push(_this.loadSceneAsync("/scenes/" + scene.index, scene));
  1930. }
  1931. // Restore the blocking of material dirty.
  1932. _this._babylonScene.blockMaterialDirtyMechanism = oldBlockMaterialDirtyMechanism;
  1933. if (_this._parent.compileMaterials) {
  1934. promises.push(_this._compileMaterialsAsync());
  1935. }
  1936. if (_this._parent.compileShadowGenerators) {
  1937. promises.push(_this._compileShadowGeneratorsAsync());
  1938. }
  1939. var resultPromise = Promise.all(promises).then(function () {
  1940. if (_this._rootBabylonMesh) {
  1941. _this._rootBabylonMesh.setEnabled(true);
  1942. }
  1943. _this._setState(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"].READY);
  1944. _this._extensionsOnReady();
  1945. _this._startAnimations();
  1946. return resultFunc();
  1947. });
  1948. resultPromise.then(function () {
  1949. _this._parent._endPerformanceCounter(loadingToReadyCounterName);
  1950. babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  1951. if (!_this._disposed) {
  1952. Promise.all(_this._completePromises).then(function () {
  1953. _this._parent._endPerformanceCounter(loadingToCompleteCounterName);
  1954. _this._setState(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"].COMPLETE);
  1955. _this._parent.onCompleteObservable.notifyObservers(undefined);
  1956. _this._parent.onCompleteObservable.clear();
  1957. _this.dispose();
  1958. }, function (error) {
  1959. _this._parent.onErrorObservable.notifyObservers(error);
  1960. _this._parent.onErrorObservable.clear();
  1961. _this.dispose();
  1962. });
  1963. }
  1964. });
  1965. });
  1966. return resultPromise;
  1967. }, function (error) {
  1968. if (!_this._disposed) {
  1969. _this._parent.onErrorObservable.notifyObservers(error);
  1970. _this._parent.onErrorObservable.clear();
  1971. _this.dispose();
  1972. }
  1973. throw error;
  1974. });
  1975. };
  1976. GLTFLoader.prototype._loadData = function (data) {
  1977. this._gltf = data.json;
  1978. this._setupData();
  1979. if (data.bin) {
  1980. var buffers = this._gltf.buffers;
  1981. if (buffers && buffers[0] && !buffers[0].uri) {
  1982. var binaryBuffer = buffers[0];
  1983. if (binaryBuffer.byteLength < data.bin.byteLength - 3 || binaryBuffer.byteLength > data.bin.byteLength) {
  1984. babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Binary buffer length (" + binaryBuffer.byteLength + ") from JSON does not match chunk length (" + data.bin.byteLength + ")");
  1985. }
  1986. this._bin = data.bin;
  1987. }
  1988. else {
  1989. babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Unexpected BIN chunk");
  1990. }
  1991. }
  1992. };
  1993. GLTFLoader.prototype._setupData = function () {
  1994. ArrayItem.Assign(this._gltf.accessors);
  1995. ArrayItem.Assign(this._gltf.animations);
  1996. ArrayItem.Assign(this._gltf.buffers);
  1997. ArrayItem.Assign(this._gltf.bufferViews);
  1998. ArrayItem.Assign(this._gltf.cameras);
  1999. ArrayItem.Assign(this._gltf.images);
  2000. ArrayItem.Assign(this._gltf.materials);
  2001. ArrayItem.Assign(this._gltf.meshes);
  2002. ArrayItem.Assign(this._gltf.nodes);
  2003. ArrayItem.Assign(this._gltf.samplers);
  2004. ArrayItem.Assign(this._gltf.scenes);
  2005. ArrayItem.Assign(this._gltf.skins);
  2006. ArrayItem.Assign(this._gltf.textures);
  2007. if (this._gltf.nodes) {
  2008. var nodeParents = {};
  2009. for (var _i = 0, _a = this._gltf.nodes; _i < _a.length; _i++) {
  2010. var node = _a[_i];
  2011. if (node.children) {
  2012. for (var _b = 0, _c = node.children; _b < _c.length; _b++) {
  2013. var index = _c[_b];
  2014. nodeParents[index] = node.index;
  2015. }
  2016. }
  2017. }
  2018. var rootNode = this._createRootNode();
  2019. for (var _d = 0, _e = this._gltf.nodes; _d < _e.length; _d++) {
  2020. var node = _e[_d];
  2021. var parentIndex = nodeParents[node.index];
  2022. node.parent = parentIndex === undefined ? rootNode : this._gltf.nodes[parentIndex];
  2023. }
  2024. }
  2025. };
  2026. GLTFLoader.prototype._loadExtensions = function () {
  2027. for (var name_2 in GLTFLoader._RegisteredExtensions) {
  2028. var extension = GLTFLoader._RegisteredExtensions[name_2].factory(this);
  2029. if (extension.name !== name_2) {
  2030. babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("The name of the glTF loader extension instance does not match the registered name: " + extension.name + " !== " + name_2);
  2031. }
  2032. this._extensions.push(extension);
  2033. this._parent.onExtensionLoadedObservable.notifyObservers(extension);
  2034. }
  2035. this._extensions.sort(function (a, b) { return (a.order || Number.MAX_VALUE) - (b.order || Number.MAX_VALUE); });
  2036. this._parent.onExtensionLoadedObservable.clear();
  2037. };
  2038. GLTFLoader.prototype._checkExtensions = function () {
  2039. if (this._gltf.extensionsRequired) {
  2040. var _loop_1 = function (name_3) {
  2041. var available = this_1._extensions.some(function (extension) { return extension.name === name_3 && extension.enabled; });
  2042. if (!available) {
  2043. throw new Error("Require extension " + name_3 + " is not available");
  2044. }
  2045. };
  2046. var this_1 = this;
  2047. for (var _i = 0, _a = this._gltf.extensionsRequired; _i < _a.length; _i++) {
  2048. var name_3 = _a[_i];
  2049. _loop_1(name_3);
  2050. }
  2051. }
  2052. };
  2053. GLTFLoader.prototype._setState = function (state) {
  2054. this._state = state;
  2055. this.log(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"][this._state]);
  2056. };
  2057. GLTFLoader.prototype._createRootNode = function () {
  2058. this._babylonScene._blockEntityCollection = this._forAssetContainer;
  2059. this._rootBabylonMesh = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Mesh"]("__root__", this._babylonScene);
  2060. this._babylonScene._blockEntityCollection = false;
  2061. this._rootBabylonMesh.setEnabled(false);
  2062. var rootNode = {
  2063. _babylonTransformNode: this._rootBabylonMesh,
  2064. index: -1
  2065. };
  2066. switch (this._parent.coordinateSystemMode) {
  2067. case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderCoordinateSystemMode"].AUTO: {
  2068. if (!this._babylonScene.useRightHandedSystem) {
  2069. rootNode.rotation = [0, 1, 0, 0];
  2070. rootNode.scale = [1, 1, -1];
  2071. GLTFLoader._LoadTransform(rootNode, this._rootBabylonMesh);
  2072. }
  2073. break;
  2074. }
  2075. case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderCoordinateSystemMode"].FORCE_RIGHT_HANDED: {
  2076. this._babylonScene.useRightHandedSystem = true;
  2077. break;
  2078. }
  2079. default: {
  2080. throw new Error("Invalid coordinate system mode (" + this._parent.coordinateSystemMode + ")");
  2081. }
  2082. }
  2083. this._parent.onMeshLoadedObservable.notifyObservers(this._rootBabylonMesh);
  2084. return rootNode;
  2085. };
  2086. /**
  2087. * Loads a glTF scene.
  2088. * @param context The context when loading the asset
  2089. * @param scene The glTF scene property
  2090. * @returns A promise that resolves when the load is complete
  2091. */
  2092. GLTFLoader.prototype.loadSceneAsync = function (context, scene) {
  2093. var _this = this;
  2094. var extensionPromise = this._extensionsLoadSceneAsync(context, scene);
  2095. if (extensionPromise) {
  2096. return extensionPromise;
  2097. }
  2098. var promises = new Array();
  2099. this.logOpen(context + " " + (scene.name || ""));
  2100. if (scene.nodes) {
  2101. for (var _i = 0, _a = scene.nodes; _i < _a.length; _i++) {
  2102. var index = _a[_i];
  2103. var node = ArrayItem.Get(context + "/nodes/" + index, this._gltf.nodes, index);
  2104. promises.push(this.loadNodeAsync("/nodes/" + node.index, node, function (babylonMesh) {
  2105. babylonMesh.parent = _this._rootBabylonMesh;
  2106. }));
  2107. }
  2108. }
  2109. // Link all Babylon bones for each glTF node with the corresponding Babylon transform node.
  2110. // A glTF joint is a pointer to a glTF node in the glTF node hierarchy similar to Unity3D.
  2111. if (this._gltf.nodes) {
  2112. for (var _b = 0, _c = this._gltf.nodes; _b < _c.length; _b++) {
  2113. var node = _c[_b];
  2114. if (node._babylonTransformNode && node._babylonBones) {
  2115. for (var _d = 0, _e = node._babylonBones; _d < _e.length; _d++) {
  2116. var babylonBone = _e[_d];
  2117. babylonBone.linkTransformNode(node._babylonTransformNode);
  2118. }
  2119. }
  2120. }
  2121. }
  2122. promises.push(this._loadAnimationsAsync());
  2123. this.logClose();
  2124. return Promise.all(promises).then(function () { });
  2125. };
  2126. GLTFLoader.prototype._forEachPrimitive = function (node, callback) {
  2127. if (node._primitiveBabylonMeshes) {
  2128. for (var _i = 0, _a = node._primitiveBabylonMeshes; _i < _a.length; _i++) {
  2129. var babylonMesh = _a[_i];
  2130. callback(babylonMesh);
  2131. }
  2132. }
  2133. };
  2134. GLTFLoader.prototype._getMeshes = function () {
  2135. var meshes = new Array();
  2136. // Root mesh is always first.
  2137. meshes.push(this._rootBabylonMesh);
  2138. var nodes = this._gltf.nodes;
  2139. if (nodes) {
  2140. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  2141. var node = nodes_1[_i];
  2142. this._forEachPrimitive(node, function (babylonMesh) {
  2143. meshes.push(babylonMesh);
  2144. });
  2145. }
  2146. }
  2147. return meshes;
  2148. };
  2149. GLTFLoader.prototype._getTransformNodes = function () {
  2150. var transformNodes = new Array();
  2151. var nodes = this._gltf.nodes;
  2152. if (nodes) {
  2153. for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) {
  2154. var node = nodes_2[_i];
  2155. if (node._babylonTransformNode && node._babylonTransformNode.getClassName() === "TransformNode") {
  2156. transformNodes.push(node._babylonTransformNode);
  2157. }
  2158. }
  2159. }
  2160. return transformNodes;
  2161. };
  2162. GLTFLoader.prototype._getSkeletons = function () {
  2163. var skeletons = new Array();
  2164. var skins = this._gltf.skins;
  2165. if (skins) {
  2166. for (var _i = 0, skins_1 = skins; _i < skins_1.length; _i++) {
  2167. var skin = skins_1[_i];
  2168. if (skin._data) {
  2169. skeletons.push(skin._data.babylonSkeleton);
  2170. }
  2171. }
  2172. }
  2173. return skeletons;
  2174. };
  2175. GLTFLoader.prototype._getAnimationGroups = function () {
  2176. var animationGroups = new Array();
  2177. var animations = this._gltf.animations;
  2178. if (animations) {
  2179. for (var _i = 0, animations_1 = animations; _i < animations_1.length; _i++) {
  2180. var animation = animations_1[_i];
  2181. if (animation._babylonAnimationGroup) {
  2182. animationGroups.push(animation._babylonAnimationGroup);
  2183. }
  2184. }
  2185. }
  2186. return animationGroups;
  2187. };
  2188. GLTFLoader.prototype._startAnimations = function () {
  2189. switch (this._parent.animationStartMode) {
  2190. case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderAnimationStartMode"].NONE: {
  2191. // do nothing
  2192. break;
  2193. }
  2194. case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderAnimationStartMode"].FIRST: {
  2195. var babylonAnimationGroups = this._getAnimationGroups();
  2196. if (babylonAnimationGroups.length !== 0) {
  2197. babylonAnimationGroups[0].start(true);
  2198. }
  2199. break;
  2200. }
  2201. case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderAnimationStartMode"].ALL: {
  2202. var babylonAnimationGroups = this._getAnimationGroups();
  2203. for (var _i = 0, babylonAnimationGroups_1 = babylonAnimationGroups; _i < babylonAnimationGroups_1.length; _i++) {
  2204. var babylonAnimationGroup = babylonAnimationGroups_1[_i];
  2205. babylonAnimationGroup.start(true);
  2206. }
  2207. break;
  2208. }
  2209. default: {
  2210. babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Invalid animation start mode (" + this._parent.animationStartMode + ")");
  2211. return;
  2212. }
  2213. }
  2214. };
  2215. /**
  2216. * Loads a glTF node.
  2217. * @param context The context when loading the asset
  2218. * @param node The glTF node property
  2219. * @param assign A function called synchronously after parsing the glTF properties
  2220. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  2221. */
  2222. GLTFLoader.prototype.loadNodeAsync = function (context, node, assign) {
  2223. var _this = this;
  2224. if (assign === void 0) { assign = function () { }; }
  2225. var extensionPromise = this._extensionsLoadNodeAsync(context, node, assign);
  2226. if (extensionPromise) {
  2227. return extensionPromise;
  2228. }
  2229. if (node._babylonTransformNode) {
  2230. throw new Error(context + ": Invalid recursive node hierarchy");
  2231. }
  2232. var promises = new Array();
  2233. this.logOpen(context + " " + (node.name || ""));
  2234. var loadNode = function (babylonTransformNode) {
  2235. GLTFLoader.AddPointerMetadata(babylonTransformNode, context);
  2236. GLTFLoader._LoadTransform(node, babylonTransformNode);
  2237. if (node.camera != undefined) {
  2238. var camera = ArrayItem.Get(context + "/camera", _this._gltf.cameras, node.camera);
  2239. promises.push(_this.loadCameraAsync("/cameras/" + camera.index, camera, function (babylonCamera) {
  2240. babylonCamera.parent = babylonTransformNode;
  2241. }));
  2242. }
  2243. if (node.children) {
  2244. for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
  2245. var index = _a[_i];
  2246. var childNode = ArrayItem.Get(context + "/children/" + index, _this._gltf.nodes, index);
  2247. promises.push(_this.loadNodeAsync("/nodes/" + childNode.index, childNode, function (childBabylonMesh) {
  2248. childBabylonMesh.parent = babylonTransformNode;
  2249. }));
  2250. }
  2251. }
  2252. assign(babylonTransformNode);
  2253. };
  2254. if (node.mesh == undefined) {
  2255. var nodeName = node.name || "node" + node.index;
  2256. this._babylonScene._blockEntityCollection = this._forAssetContainer;
  2257. node._babylonTransformNode = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["TransformNode"](nodeName, this._babylonScene);
  2258. this._babylonScene._blockEntityCollection = false;
  2259. loadNode(node._babylonTransformNode);
  2260. }
  2261. else {
  2262. var mesh = ArrayItem.Get(context + "/mesh", this._gltf.meshes, node.mesh);
  2263. promises.push(this._loadMeshAsync("/meshes/" + mesh.index, node, mesh, loadNode));
  2264. }
  2265. this.logClose();
  2266. return Promise.all(promises).then(function () {
  2267. _this._forEachPrimitive(node, function (babylonMesh) {
  2268. babylonMesh.refreshBoundingInfo(true);
  2269. });
  2270. return node._babylonTransformNode;
  2271. });
  2272. };
  2273. GLTFLoader.prototype._loadMeshAsync = function (context, node, mesh, assign) {
  2274. var primitives = mesh.primitives;
  2275. if (!primitives || !primitives.length) {
  2276. throw new Error(context + ": Primitives are missing");
  2277. }
  2278. if (primitives[0].index == undefined) {
  2279. ArrayItem.Assign(primitives);
  2280. }
  2281. var promises = new Array();
  2282. this.logOpen(context + " " + (mesh.name || ""));
  2283. var name = node.name || "node" + node.index;
  2284. if (primitives.length === 1) {
  2285. var primitive = mesh.primitives[0];
  2286. promises.push(this._loadMeshPrimitiveAsync(context + "/primitives/" + primitive.index, name, node, mesh, primitive, function (babylonMesh) {
  2287. node._babylonTransformNode = babylonMesh;
  2288. node._primitiveBabylonMeshes = [babylonMesh];
  2289. }));
  2290. }
  2291. else {
  2292. node._babylonTransformNode = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["TransformNode"](name, this._babylonScene);
  2293. node._primitiveBabylonMeshes = [];
  2294. for (var _i = 0, primitives_1 = primitives; _i < primitives_1.length; _i++) {
  2295. var primitive = primitives_1[_i];
  2296. promises.push(this._loadMeshPrimitiveAsync(context + "/primitives/" + primitive.index, name + "_primitive" + primitive.index, node, mesh, primitive, function (babylonMesh) {
  2297. babylonMesh.parent = node._babylonTransformNode;
  2298. node._primitiveBabylonMeshes.push(babylonMesh);
  2299. }));
  2300. }
  2301. }
  2302. if (node.skin != undefined) {
  2303. var skin = ArrayItem.Get(context + "/skin", this._gltf.skins, node.skin);
  2304. promises.push(this._loadSkinAsync("/skins/" + skin.index, node, skin));
  2305. }
  2306. assign(node._babylonTransformNode);
  2307. this.logClose();
  2308. return Promise.all(promises).then(function () {
  2309. return node._babylonTransformNode;
  2310. });
  2311. };
  2312. /**
  2313. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  2314. * @param context The context when loading the asset
  2315. * @param name The mesh name when loading the asset
  2316. * @param node The glTF node when loading the asset
  2317. * @param mesh The glTF mesh when loading the asset
  2318. * @param primitive The glTF mesh primitive property
  2319. * @param assign A function called synchronously after parsing the glTF properties
  2320. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  2321. */
  2322. GLTFLoader.prototype._loadMeshPrimitiveAsync = function (context, name, node, mesh, primitive, assign) {
  2323. var _this = this;
  2324. var extensionPromise = this._extensionsLoadMeshPrimitiveAsync(context, name, node, mesh, primitive, assign);
  2325. if (extensionPromise) {
  2326. return extensionPromise;
  2327. }
  2328. this.logOpen("" + context);
  2329. var shouldInstance = this._parent.createInstances && (node.skin == undefined && !mesh.primitives[0].targets);
  2330. var babylonAbstractMesh;
  2331. var promise;
  2332. if (shouldInstance && primitive._instanceData) {
  2333. babylonAbstractMesh = primitive._instanceData.babylonSourceMesh.createInstance(name);
  2334. promise = primitive._instanceData.promise;
  2335. }
  2336. else {
  2337. var promises = new Array();
  2338. this._babylonScene._blockEntityCollection = this._forAssetContainer;
  2339. var babylonMesh_1 = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, this._babylonScene);
  2340. this._babylonScene._blockEntityCollection = false;
  2341. babylonMesh_1.overrideMaterialSideOrientation = this._babylonScene.useRightHandedSystem ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Material"].CounterClockWiseSideOrientation : babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Material"].ClockWiseSideOrientation;
  2342. this._createMorphTargets(context, node, mesh, primitive, babylonMesh_1);
  2343. promises.push(this._loadVertexDataAsync(context, primitive, babylonMesh_1).then(function (babylonGeometry) {
  2344. return _this._loadMorphTargetsAsync(context, primitive, babylonMesh_1, babylonGeometry).then(function () {
  2345. babylonGeometry.applyToMesh(babylonMesh_1);
  2346. });
  2347. }));
  2348. var babylonDrawMode = GLTFLoader._GetDrawMode(context, primitive.mode);
  2349. if (primitive.material == undefined) {
  2350. var babylonMaterial = this._defaultBabylonMaterialData[babylonDrawMode];
  2351. if (!babylonMaterial) {
  2352. babylonMaterial = this._createDefaultMaterial("__GLTFLoader._default", babylonDrawMode);
  2353. this._parent.onMaterialLoadedObservable.notifyObservers(babylonMaterial);
  2354. this._defaultBabylonMaterialData[babylonDrawMode] = babylonMaterial;
  2355. }
  2356. babylonMesh_1.material = babylonMaterial;
  2357. }
  2358. else {
  2359. var material = ArrayItem.Get(context + "/material", this._gltf.materials, primitive.material);
  2360. promises.push(this._loadMaterialAsync("/materials/" + material.index, material, babylonMesh_1, babylonDrawMode, function (babylonMaterial) {
  2361. babylonMesh_1.material = babylonMaterial;
  2362. }));
  2363. }
  2364. promise = Promise.all(promises);
  2365. if (shouldInstance) {
  2366. primitive._instanceData = {
  2367. babylonSourceMesh: babylonMesh_1,
  2368. promise: promise
  2369. };
  2370. }
  2371. babylonAbstractMesh = babylonMesh_1;
  2372. }
  2373. GLTFLoader.AddPointerMetadata(babylonAbstractMesh, context);
  2374. this._parent.onMeshLoadedObservable.notifyObservers(babylonAbstractMesh);
  2375. assign(babylonAbstractMesh);
  2376. this.logClose();
  2377. return promise.then(function () {
  2378. return babylonAbstractMesh;
  2379. });
  2380. };
  2381. GLTFLoader.prototype._loadVertexDataAsync = function (context, primitive, babylonMesh) {
  2382. var _this = this;
  2383. var extensionPromise = this._extensionsLoadVertexDataAsync(context, primitive, babylonMesh);
  2384. if (extensionPromise) {
  2385. return extensionPromise;
  2386. }
  2387. var attributes = primitive.attributes;
  2388. if (!attributes) {
  2389. throw new Error(context + ": Attributes are missing");
  2390. }
  2391. var promises = new Array();
  2392. var babylonGeometry = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Geometry"](babylonMesh.name, this._babylonScene);
  2393. if (primitive.indices == undefined) {
  2394. babylonMesh.isUnIndexed = true;
  2395. }
  2396. else {
  2397. var accessor = ArrayItem.Get(context + "/indices", this._gltf.accessors, primitive.indices);
  2398. promises.push(this._loadIndicesAccessorAsync("/accessors/" + accessor.index, accessor).then(function (data) {
  2399. babylonGeometry.setIndices(data);
  2400. }));
  2401. }
  2402. var loadAttribute = function (attribute, kind, callback) {
  2403. if (attributes[attribute] == undefined) {
  2404. return;
  2405. }
  2406. babylonMesh._delayInfo = babylonMesh._delayInfo || [];
  2407. if (babylonMesh._delayInfo.indexOf(kind) === -1) {
  2408. babylonMesh._delayInfo.push(kind);
  2409. }
  2410. var accessor = ArrayItem.Get(context + "/attributes/" + attribute, _this._gltf.accessors, attributes[attribute]);
  2411. promises.push(_this._loadVertexAccessorAsync("/accessors/" + accessor.index, accessor, kind).then(function (babylonVertexBuffer) {
  2412. babylonGeometry.setVerticesBuffer(babylonVertexBuffer, accessor.count);
  2413. }));
  2414. if (kind == babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesExtraKind) {
  2415. babylonMesh.numBoneInfluencers = 8;
  2416. }
  2417. if (callback) {
  2418. callback(accessor);
  2419. }
  2420. };
  2421. loadAttribute("POSITION", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].PositionKind);
  2422. loadAttribute("NORMAL", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].NormalKind);
  2423. loadAttribute("TANGENT", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].TangentKind);
  2424. loadAttribute("TEXCOORD_0", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind);
  2425. loadAttribute("TEXCOORD_1", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind);
  2426. loadAttribute("JOINTS_0", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesKind);
  2427. loadAttribute("WEIGHTS_0", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsKind);
  2428. loadAttribute("JOINTS_1", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesExtraKind);
  2429. loadAttribute("WEIGHTS_1", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsExtraKind);
  2430. loadAttribute("COLOR_0", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].ColorKind, function (accessor) {
  2431. if (accessor.type === "VEC4" /* VEC4 */) {
  2432. babylonMesh.hasVertexAlpha = true;
  2433. }
  2434. });
  2435. return Promise.all(promises).then(function () {
  2436. return babylonGeometry;
  2437. });
  2438. };
  2439. GLTFLoader.prototype._createMorphTargets = function (context, node, mesh, primitive, babylonMesh) {
  2440. if (!primitive.targets) {
  2441. return;
  2442. }
  2443. if (node._numMorphTargets == undefined) {
  2444. node._numMorphTargets = primitive.targets.length;
  2445. }
  2446. else if (primitive.targets.length !== node._numMorphTargets) {
  2447. throw new Error(context + ": Primitives do not have the same number of targets");
  2448. }
  2449. var targetNames = mesh.extras ? mesh.extras.targetNames : null;
  2450. babylonMesh.morphTargetManager = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["MorphTargetManager"](babylonMesh.getScene());
  2451. for (var index = 0; index < primitive.targets.length; index++) {
  2452. var weight = node.weights ? node.weights[index] : mesh.weights ? mesh.weights[index] : 0;
  2453. var name_4 = targetNames ? targetNames[index] : "morphTarget" + index;
  2454. babylonMesh.morphTargetManager.addTarget(new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"](name_4, weight, babylonMesh.getScene()));
  2455. // TODO: tell the target whether it has positions, normals, tangents
  2456. }
  2457. };
  2458. GLTFLoader.prototype._loadMorphTargetsAsync = function (context, primitive, babylonMesh, babylonGeometry) {
  2459. if (!primitive.targets) {
  2460. return Promise.resolve();
  2461. }
  2462. var promises = new Array();
  2463. var morphTargetManager = babylonMesh.morphTargetManager;
  2464. for (var index = 0; index < morphTargetManager.numTargets; index++) {
  2465. var babylonMorphTarget = morphTargetManager.getTarget(index);
  2466. promises.push(this._loadMorphTargetVertexDataAsync(context + "/targets/" + index, babylonGeometry, primitive.targets[index], babylonMorphTarget));
  2467. }
  2468. return Promise.all(promises).then(function () { });
  2469. };
  2470. GLTFLoader.prototype._loadMorphTargetVertexDataAsync = function (context, babylonGeometry, attributes, babylonMorphTarget) {
  2471. var _this = this;
  2472. var promises = new Array();
  2473. var loadAttribute = function (attribute, kind, setData) {
  2474. if (attributes[attribute] == undefined) {
  2475. return;
  2476. }
  2477. var babylonVertexBuffer = babylonGeometry.getVertexBuffer(kind);
  2478. if (!babylonVertexBuffer) {
  2479. return;
  2480. }
  2481. var accessor = ArrayItem.Get(context + "/" + attribute, _this._gltf.accessors, attributes[attribute]);
  2482. promises.push(_this._loadFloatAccessorAsync("/accessors/" + accessor.index, accessor).then(function (data) {
  2483. setData(babylonVertexBuffer, data);
  2484. }));
  2485. };
  2486. loadAttribute("POSITION", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].PositionKind, function (babylonVertexBuffer, data) {
  2487. var positions = new Float32Array(data.length);
  2488. babylonVertexBuffer.forEach(data.length, function (value, index) {
  2489. positions[index] = data[index] + value;
  2490. });
  2491. babylonMorphTarget.setPositions(positions);
  2492. });
  2493. loadAttribute("NORMAL", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].NormalKind, function (babylonVertexBuffer, data) {
  2494. var normals = new Float32Array(data.length);
  2495. babylonVertexBuffer.forEach(normals.length, function (value, index) {
  2496. normals[index] = data[index] + value;
  2497. });
  2498. babylonMorphTarget.setNormals(normals);
  2499. });
  2500. loadAttribute("TANGENT", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].TangentKind, function (babylonVertexBuffer, data) {
  2501. var tangents = new Float32Array(data.length / 3 * 4);
  2502. var dataIndex = 0;
  2503. babylonVertexBuffer.forEach(data.length / 3 * 4, function (value, index) {
  2504. // Tangent data for morph targets is stored as xyz delta.
  2505. // The vertexData.tangent is stored as xyzw.
  2506. // So we need to skip every fourth vertexData.tangent.
  2507. if (((index + 1) % 4) !== 0) {
  2508. tangents[dataIndex] = data[dataIndex] + value;
  2509. dataIndex++;
  2510. }
  2511. });
  2512. babylonMorphTarget.setTangents(tangents);
  2513. });
  2514. return Promise.all(promises).then(function () { });
  2515. };
  2516. GLTFLoader._LoadTransform = function (node, babylonNode) {
  2517. // Ignore the TRS of skinned nodes.
  2518. // See https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins (second implementation note)
  2519. if (node.skin != undefined) {
  2520. return;
  2521. }
  2522. var position = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  2523. var rotation = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  2524. var scaling = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  2525. if (node.matrix) {
  2526. var matrix = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromArray(node.matrix);
  2527. matrix.decompose(scaling, rotation, position);
  2528. }
  2529. else {
  2530. if (node.translation) {
  2531. position = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(node.translation);
  2532. }
  2533. if (node.rotation) {
  2534. rotation = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(node.rotation);
  2535. }
  2536. if (node.scale) {
  2537. scaling = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(node.scale);
  2538. }
  2539. }
  2540. babylonNode.position = position;
  2541. babylonNode.rotationQuaternion = rotation;
  2542. babylonNode.scaling = scaling;
  2543. };
  2544. GLTFLoader.prototype._loadSkinAsync = function (context, node, skin) {
  2545. var _this = this;
  2546. var extensionPromise = this._extensionsLoadSkinAsync(context, node, skin);
  2547. if (extensionPromise) {
  2548. return extensionPromise;
  2549. }
  2550. var assignSkeleton = function (skeleton) {
  2551. _this._forEachPrimitive(node, function (babylonMesh) {
  2552. babylonMesh.skeleton = skeleton;
  2553. });
  2554. };
  2555. if (skin._data) {
  2556. assignSkeleton(skin._data.babylonSkeleton);
  2557. return skin._data.promise;
  2558. }
  2559. var skeletonId = "skeleton" + skin.index;
  2560. this._babylonScene._blockEntityCollection = this._forAssetContainer;
  2561. var babylonSkeleton = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Skeleton"](skin.name || skeletonId, skeletonId, this._babylonScene);
  2562. this._babylonScene._blockEntityCollection = false;
  2563. // See https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins (second implementation note)
  2564. babylonSkeleton.overrideMesh = this._rootBabylonMesh;
  2565. this._loadBones(context, skin, babylonSkeleton);
  2566. assignSkeleton(babylonSkeleton);
  2567. var promise = this._loadSkinInverseBindMatricesDataAsync(context, skin).then(function (inverseBindMatricesData) {
  2568. _this._updateBoneMatrices(babylonSkeleton, inverseBindMatricesData);
  2569. });
  2570. skin._data = {
  2571. babylonSkeleton: babylonSkeleton,
  2572. promise: promise
  2573. };
  2574. return promise;
  2575. };
  2576. GLTFLoader.prototype._loadBones = function (context, skin, babylonSkeleton) {
  2577. var babylonBones = {};
  2578. for (var _i = 0, _a = skin.joints; _i < _a.length; _i++) {
  2579. var index = _a[_i];
  2580. var node = ArrayItem.Get(context + "/joints/" + index, this._gltf.nodes, index);
  2581. this._loadBone(node, skin, babylonSkeleton, babylonBones);
  2582. }
  2583. };
  2584. GLTFLoader.prototype._loadBone = function (node, skin, babylonSkeleton, babylonBones) {
  2585. var babylonBone = babylonBones[node.index];
  2586. if (babylonBone) {
  2587. return babylonBone;
  2588. }
  2589. var babylonParentBone = null;
  2590. if (node.parent && node.parent._babylonTransformNode !== this._rootBabylonMesh) {
  2591. babylonParentBone = this._loadBone(node.parent, skin, babylonSkeleton, babylonBones);
  2592. }
  2593. var boneIndex = skin.joints.indexOf(node.index);
  2594. babylonBone = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Bone"](node.name || "joint" + node.index, babylonSkeleton, babylonParentBone, this._getNodeMatrix(node), null, null, boneIndex);
  2595. babylonBones[node.index] = babylonBone;
  2596. node._babylonBones = node._babylonBones || [];
  2597. node._babylonBones.push(babylonBone);
  2598. return babylonBone;
  2599. };
  2600. GLTFLoader.prototype._loadSkinInverseBindMatricesDataAsync = function (context, skin) {
  2601. if (skin.inverseBindMatrices == undefined) {
  2602. return Promise.resolve(null);
  2603. }
  2604. var accessor = ArrayItem.Get(context + "/inverseBindMatrices", this._gltf.accessors, skin.inverseBindMatrices);
  2605. return this._loadFloatAccessorAsync("/accessors/" + accessor.index, accessor);
  2606. };
  2607. GLTFLoader.prototype._updateBoneMatrices = function (babylonSkeleton, inverseBindMatricesData) {
  2608. for (var _i = 0, _a = babylonSkeleton.bones; _i < _a.length; _i++) {
  2609. var babylonBone = _a[_i];
  2610. var baseMatrix = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  2611. var boneIndex = babylonBone._index;
  2612. if (inverseBindMatricesData && boneIndex !== -1) {
  2613. babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromArrayToRef(inverseBindMatricesData, boneIndex * 16, baseMatrix);
  2614. baseMatrix.invertToRef(baseMatrix);
  2615. }
  2616. var babylonParentBone = babylonBone.getParent();
  2617. if (babylonParentBone) {
  2618. baseMatrix.multiplyToRef(babylonParentBone.getInvertedAbsoluteTransform(), baseMatrix);
  2619. }
  2620. babylonBone.updateMatrix(baseMatrix, false, false);
  2621. babylonBone._updateDifferenceMatrix(undefined, false);
  2622. }
  2623. };
  2624. GLTFLoader.prototype._getNodeMatrix = function (node) {
  2625. return node.matrix ?
  2626. babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromArray(node.matrix) :
  2627. babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Compose(node.scale ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(node.scale) : babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One(), node.rotation ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(node.rotation) : babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity(), node.translation ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(node.translation) : babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero());
  2628. };
  2629. /**
  2630. * Loads a glTF camera.
  2631. * @param context The context when loading the asset
  2632. * @param camera The glTF camera property
  2633. * @param assign A function called synchronously after parsing the glTF properties
  2634. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  2635. */
  2636. GLTFLoader.prototype.loadCameraAsync = function (context, camera, assign) {
  2637. if (assign === void 0) { assign = function () { }; }
  2638. var extensionPromise = this._extensionsLoadCameraAsync(context, camera, assign);
  2639. if (extensionPromise) {
  2640. return extensionPromise;
  2641. }
  2642. var promises = new Array();
  2643. this.logOpen(context + " " + (camera.name || ""));
  2644. this._babylonScene._blockEntityCollection = this._forAssetContainer;
  2645. var babylonCamera = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["FreeCamera"](camera.name || "camera" + camera.index, babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), this._babylonScene, false);
  2646. this._babylonScene._blockEntityCollection = false;
  2647. babylonCamera.rotation = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, Math.PI, 0);
  2648. switch (camera.type) {
  2649. case "perspective" /* PERSPECTIVE */: {
  2650. var perspective = camera.perspective;
  2651. if (!perspective) {
  2652. throw new Error(context + ": Camera perspective properties are missing");
  2653. }
  2654. babylonCamera.fov = perspective.yfov;
  2655. babylonCamera.minZ = perspective.znear;
  2656. babylonCamera.maxZ = perspective.zfar || Number.MAX_VALUE;
  2657. break;
  2658. }
  2659. case "orthographic" /* ORTHOGRAPHIC */: {
  2660. if (!camera.orthographic) {
  2661. throw new Error(context + ": Camera orthographic properties are missing");
  2662. }
  2663. babylonCamera.mode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Camera"].ORTHOGRAPHIC_CAMERA;
  2664. babylonCamera.orthoLeft = -camera.orthographic.xmag;
  2665. babylonCamera.orthoRight = camera.orthographic.xmag;
  2666. babylonCamera.orthoBottom = -camera.orthographic.ymag;
  2667. babylonCamera.orthoTop = camera.orthographic.ymag;
  2668. babylonCamera.minZ = camera.orthographic.znear;
  2669. babylonCamera.maxZ = camera.orthographic.zfar;
  2670. break;
  2671. }
  2672. default: {
  2673. throw new Error(context + ": Invalid camera type (" + camera.type + ")");
  2674. }
  2675. }
  2676. GLTFLoader.AddPointerMetadata(babylonCamera, context);
  2677. this._parent.onCameraLoadedObservable.notifyObservers(babylonCamera);
  2678. assign(babylonCamera);
  2679. return Promise.all(promises).then(function () {
  2680. return babylonCamera;
  2681. });
  2682. };
  2683. GLTFLoader.prototype._loadAnimationsAsync = function () {
  2684. var animations = this._gltf.animations;
  2685. if (!animations) {
  2686. return Promise.resolve();
  2687. }
  2688. var promises = new Array();
  2689. for (var index = 0; index < animations.length; index++) {
  2690. var animation = animations[index];
  2691. promises.push(this.loadAnimationAsync("/animations/" + animation.index, animation));
  2692. }
  2693. return Promise.all(promises).then(function () { });
  2694. };
  2695. /**
  2696. * Loads a glTF animation.
  2697. * @param context The context when loading the asset
  2698. * @param animation The glTF animation property
  2699. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  2700. */
  2701. GLTFLoader.prototype.loadAnimationAsync = function (context, animation) {
  2702. var promise = this._extensionsLoadAnimationAsync(context, animation);
  2703. if (promise) {
  2704. return promise;
  2705. }
  2706. this._babylonScene._blockEntityCollection = this._forAssetContainer;
  2707. var babylonAnimationGroup = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["AnimationGroup"](animation.name || "animation" + animation.index, this._babylonScene);
  2708. this._babylonScene._blockEntityCollection = false;
  2709. animation._babylonAnimationGroup = babylonAnimationGroup;
  2710. var promises = new Array();
  2711. ArrayItem.Assign(animation.channels);
  2712. ArrayItem.Assign(animation.samplers);
  2713. for (var _i = 0, _a = animation.channels; _i < _a.length; _i++) {
  2714. var channel = _a[_i];
  2715. promises.push(this._loadAnimationChannelAsync(context + "/channels/" + channel.index, context, animation, channel, babylonAnimationGroup));
  2716. }
  2717. return Promise.all(promises).then(function () {
  2718. babylonAnimationGroup.normalize(0);
  2719. return babylonAnimationGroup;
  2720. });
  2721. };
  2722. /**
  2723. * @hidden Loads a glTF animation channel.
  2724. * @param context The context when loading the asset
  2725. * @param animationContext The context of the animation when loading the asset
  2726. * @param animation The glTF animation property
  2727. * @param channel The glTF animation channel property
  2728. * @param babylonAnimationGroup The babylon animation group property
  2729. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  2730. * @returns A void promise when the channel load is complete
  2731. */
  2732. GLTFLoader.prototype._loadAnimationChannelAsync = function (context, animationContext, animation, channel, babylonAnimationGroup, animationTargetOverride) {
  2733. var _this = this;
  2734. if (animationTargetOverride === void 0) { animationTargetOverride = null; }
  2735. if (channel.target.node == undefined) {
  2736. return Promise.resolve();
  2737. }
  2738. var targetNode = ArrayItem.Get(context + "/target/node", this._gltf.nodes, channel.target.node);
  2739. // Ignore animations that have no animation targets.
  2740. if ((channel.target.path === "weights" /* WEIGHTS */ && !targetNode._numMorphTargets) ||
  2741. (channel.target.path !== "weights" /* WEIGHTS */ && !targetNode._babylonTransformNode)) {
  2742. return Promise.resolve();
  2743. }
  2744. var sampler = ArrayItem.Get(context + "/sampler", animation.samplers, channel.sampler);
  2745. return this._loadAnimationSamplerAsync(animationContext + "/samplers/" + channel.sampler, sampler).then(function (data) {
  2746. var targetPath;
  2747. var animationType;
  2748. switch (channel.target.path) {
  2749. case "translation" /* TRANSLATION */: {
  2750. targetPath = "position";
  2751. animationType = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONTYPE_VECTOR3;
  2752. break;
  2753. }
  2754. case "rotation" /* ROTATION */: {
  2755. targetPath = "rotationQuaternion";
  2756. animationType = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONTYPE_QUATERNION;
  2757. break;
  2758. }
  2759. case "scale" /* SCALE */: {
  2760. targetPath = "scaling";
  2761. animationType = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONTYPE_VECTOR3;
  2762. break;
  2763. }
  2764. case "weights" /* WEIGHTS */: {
  2765. targetPath = "influence";
  2766. animationType = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONTYPE_FLOAT;
  2767. break;
  2768. }
  2769. default: {
  2770. throw new Error(context + "/target/path: Invalid value (" + channel.target.path + ")");
  2771. }
  2772. }
  2773. var outputBufferOffset = 0;
  2774. var getNextOutputValue;
  2775. switch (targetPath) {
  2776. case "position": {
  2777. getNextOutputValue = function () {
  2778. var value = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(data.output, outputBufferOffset);
  2779. outputBufferOffset += 3;
  2780. return value;
  2781. };
  2782. break;
  2783. }
  2784. case "rotationQuaternion": {
  2785. getNextOutputValue = function () {
  2786. var value = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(data.output, outputBufferOffset);
  2787. outputBufferOffset += 4;
  2788. return value;
  2789. };
  2790. break;
  2791. }
  2792. case "scaling": {
  2793. getNextOutputValue = function () {
  2794. var value = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(data.output, outputBufferOffset);
  2795. outputBufferOffset += 3;
  2796. return value;
  2797. };
  2798. break;
  2799. }
  2800. case "influence": {
  2801. getNextOutputValue = function () {
  2802. var value = new Array(targetNode._numMorphTargets);
  2803. for (var i = 0; i < targetNode._numMorphTargets; i++) {
  2804. value[i] = data.output[outputBufferOffset++];
  2805. }
  2806. return value;
  2807. };
  2808. break;
  2809. }
  2810. }
  2811. var getNextKey;
  2812. switch (data.interpolation) {
  2813. case "STEP" /* STEP */: {
  2814. getNextKey = function (frameIndex) { return ({
  2815. frame: data.input[frameIndex],
  2816. value: getNextOutputValue(),
  2817. interpolation: babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["AnimationKeyInterpolation"].STEP
  2818. }); };
  2819. break;
  2820. }
  2821. case "LINEAR" /* LINEAR */: {
  2822. getNextKey = function (frameIndex) { return ({
  2823. frame: data.input[frameIndex],
  2824. value: getNextOutputValue()
  2825. }); };
  2826. break;
  2827. }
  2828. case "CUBICSPLINE" /* CUBICSPLINE */: {
  2829. getNextKey = function (frameIndex) { return ({
  2830. frame: data.input[frameIndex],
  2831. inTangent: getNextOutputValue(),
  2832. value: getNextOutputValue(),
  2833. outTangent: getNextOutputValue()
  2834. }); };
  2835. break;
  2836. }
  2837. }
  2838. var keys = new Array(data.input.length);
  2839. for (var frameIndex = 0; frameIndex < data.input.length; frameIndex++) {
  2840. keys[frameIndex] = getNextKey(frameIndex);
  2841. }
  2842. if (targetPath === "influence") {
  2843. var _loop_2 = function (targetIndex) {
  2844. var animationName = babylonAnimationGroup.name + "_channel" + babylonAnimationGroup.targetedAnimations.length;
  2845. var babylonAnimation = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Animation"](animationName, targetPath, 1, animationType);
  2846. babylonAnimation.setKeys(keys.map(function (key) { return ({
  2847. frame: key.frame,
  2848. inTangent: key.inTangent ? key.inTangent[targetIndex] : undefined,
  2849. value: key.value[targetIndex],
  2850. outTangent: key.outTangent ? key.outTangent[targetIndex] : undefined
  2851. }); }));
  2852. _this._forEachPrimitive(targetNode, function (babylonAbstractMesh) {
  2853. var babylonMesh = babylonAbstractMesh;
  2854. var morphTarget = babylonMesh.morphTargetManager.getTarget(targetIndex);
  2855. var babylonAnimationClone = babylonAnimation.clone();
  2856. morphTarget.animations.push(babylonAnimationClone);
  2857. babylonAnimationGroup.addTargetedAnimation(babylonAnimationClone, morphTarget);
  2858. });
  2859. };
  2860. for (var targetIndex = 0; targetIndex < targetNode._numMorphTargets; targetIndex++) {
  2861. _loop_2(targetIndex);
  2862. }
  2863. }
  2864. else {
  2865. var animationName = babylonAnimationGroup.name + "_channel" + babylonAnimationGroup.targetedAnimations.length;
  2866. var babylonAnimation = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Animation"](animationName, targetPath, 1, animationType);
  2867. babylonAnimation.setKeys(keys);
  2868. if (animationTargetOverride != null && animationTargetOverride.animations != null) {
  2869. animationTargetOverride.animations.push(babylonAnimation);
  2870. babylonAnimationGroup.addTargetedAnimation(babylonAnimation, animationTargetOverride);
  2871. }
  2872. else {
  2873. targetNode._babylonTransformNode.animations.push(babylonAnimation);
  2874. babylonAnimationGroup.addTargetedAnimation(babylonAnimation, targetNode._babylonTransformNode);
  2875. }
  2876. }
  2877. });
  2878. };
  2879. GLTFLoader.prototype._loadAnimationSamplerAsync = function (context, sampler) {
  2880. if (sampler._data) {
  2881. return sampler._data;
  2882. }
  2883. var interpolation = sampler.interpolation || "LINEAR" /* LINEAR */;
  2884. switch (interpolation) {
  2885. case "STEP" /* STEP */:
  2886. case "LINEAR" /* LINEAR */:
  2887. case "CUBICSPLINE" /* CUBICSPLINE */: {
  2888. break;
  2889. }
  2890. default: {
  2891. throw new Error(context + "/interpolation: Invalid value (" + sampler.interpolation + ")");
  2892. }
  2893. }
  2894. var inputAccessor = ArrayItem.Get(context + "/input", this._gltf.accessors, sampler.input);
  2895. var outputAccessor = ArrayItem.Get(context + "/output", this._gltf.accessors, sampler.output);
  2896. sampler._data = Promise.all([
  2897. this._loadFloatAccessorAsync("/accessors/" + inputAccessor.index, inputAccessor),
  2898. this._loadFloatAccessorAsync("/accessors/" + outputAccessor.index, outputAccessor)
  2899. ]).then(function (_a) {
  2900. var inputData = _a[0], outputData = _a[1];
  2901. return {
  2902. input: inputData,
  2903. interpolation: interpolation,
  2904. output: outputData,
  2905. };
  2906. });
  2907. return sampler._data;
  2908. };
  2909. GLTFLoader.prototype._loadBufferAsync = function (context, buffer, byteOffset, byteLength) {
  2910. var extensionPromise = this._extensionsLoadBufferAsync(context, buffer, byteOffset, byteLength);
  2911. if (extensionPromise) {
  2912. return extensionPromise;
  2913. }
  2914. if (!buffer._data) {
  2915. if (buffer.uri) {
  2916. buffer._data = this.loadUriAsync(context + "/uri", buffer, buffer.uri);
  2917. }
  2918. else {
  2919. if (!this._bin) {
  2920. throw new Error(context + ": Uri is missing or the binary glTF is missing its binary chunk");
  2921. }
  2922. buffer._data = this._bin.readAsync(0, buffer.byteLength);
  2923. }
  2924. }
  2925. return buffer._data.then(function (data) {
  2926. try {
  2927. return new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength);
  2928. }
  2929. catch (e) {
  2930. throw new Error(context + ": " + e.message);
  2931. }
  2932. });
  2933. };
  2934. /**
  2935. * Loads a glTF buffer view.
  2936. * @param context The context when loading the asset
  2937. * @param bufferView The glTF buffer view property
  2938. * @returns A promise that resolves with the loaded data when the load is complete
  2939. */
  2940. GLTFLoader.prototype.loadBufferViewAsync = function (context, bufferView) {
  2941. var extensionPromise = this._extensionsLoadBufferViewAsync(context, bufferView);
  2942. if (extensionPromise) {
  2943. return extensionPromise;
  2944. }
  2945. if (bufferView._data) {
  2946. return bufferView._data;
  2947. }
  2948. var buffer = ArrayItem.Get(context + "/buffer", this._gltf.buffers, bufferView.buffer);
  2949. bufferView._data = this._loadBufferAsync("/buffers/" + buffer.index, buffer, (bufferView.byteOffset || 0), bufferView.byteLength);
  2950. return bufferView._data;
  2951. };
  2952. GLTFLoader.prototype._loadAccessorAsync = function (context, accessor, constructor) {
  2953. var _this = this;
  2954. if (accessor._data) {
  2955. return accessor._data;
  2956. }
  2957. var numComponents = GLTFLoader._GetNumComponents(context, accessor.type);
  2958. var byteStride = numComponents * babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].GetTypeByteLength(accessor.componentType);
  2959. var length = numComponents * accessor.count;
  2960. if (accessor.bufferView == undefined) {
  2961. accessor._data = Promise.resolve(new constructor(length));
  2962. }
  2963. else {
  2964. var bufferView_1 = ArrayItem.Get(context + "/bufferView", this._gltf.bufferViews, accessor.bufferView);
  2965. accessor._data = this.loadBufferViewAsync("/bufferViews/" + bufferView_1.index, bufferView_1).then(function (data) {
  2966. if (accessor.componentType === 5126 /* FLOAT */ && !accessor.normalized) {
  2967. return GLTFLoader._GetTypedArray(context, accessor.componentType, data, accessor.byteOffset, length);
  2968. }
  2969. else {
  2970. var typedArray_1 = new constructor(length);
  2971. babylonjs_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) {
  2972. typedArray_1[index] = value;
  2973. });
  2974. return typedArray_1;
  2975. }
  2976. });
  2977. }
  2978. if (accessor.sparse) {
  2979. var sparse_1 = accessor.sparse;
  2980. accessor._data = accessor._data.then(function (data) {
  2981. var typedArray = data;
  2982. var indicesBufferView = ArrayItem.Get(context + "/sparse/indices/bufferView", _this._gltf.bufferViews, sparse_1.indices.bufferView);
  2983. var valuesBufferView = ArrayItem.Get(context + "/sparse/values/bufferView", _this._gltf.bufferViews, sparse_1.values.bufferView);
  2984. return Promise.all([
  2985. _this.loadBufferViewAsync("/bufferViews/" + indicesBufferView.index, indicesBufferView),
  2986. _this.loadBufferViewAsync("/bufferViews/" + valuesBufferView.index, valuesBufferView)
  2987. ]).then(function (_a) {
  2988. var indicesData = _a[0], valuesData = _a[1];
  2989. var indices = GLTFLoader._GetTypedArray(context + "/sparse/indices", sparse_1.indices.componentType, indicesData, sparse_1.indices.byteOffset, sparse_1.count);
  2990. var sparseLength = numComponents * sparse_1.count;
  2991. var values;
  2992. if (accessor.componentType === 5126 /* FLOAT */ && !accessor.normalized) {
  2993. values = GLTFLoader._GetTypedArray(context + "/sparse/values", accessor.componentType, valuesData, sparse_1.values.byteOffset, sparseLength);
  2994. }
  2995. else {
  2996. var sparseData = GLTFLoader._GetTypedArray(context + "/sparse/values", accessor.componentType, valuesData, sparse_1.values.byteOffset, sparseLength);
  2997. values = new constructor(sparseLength);
  2998. babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].ForEach(sparseData, 0, byteStride, numComponents, accessor.componentType, values.length, accessor.normalized || false, function (value, index) {
  2999. values[index] = value;
  3000. });
  3001. }
  3002. var valuesIndex = 0;
  3003. for (var indicesIndex = 0; indicesIndex < indices.length; indicesIndex++) {
  3004. var dataIndex = indices[indicesIndex] * numComponents;
  3005. for (var componentIndex = 0; componentIndex < numComponents; componentIndex++) {
  3006. typedArray[dataIndex++] = values[valuesIndex++];
  3007. }
  3008. }
  3009. return typedArray;
  3010. });
  3011. });
  3012. }
  3013. return accessor._data;
  3014. };
  3015. GLTFLoader.prototype._loadFloatAccessorAsync = function (context, accessor) {
  3016. return this._loadAccessorAsync(context, accessor, Float32Array);
  3017. };
  3018. GLTFLoader.prototype._loadIndicesAccessorAsync = function (context, accessor) {
  3019. if (accessor.type !== "SCALAR" /* SCALAR */) {
  3020. throw new Error(context + "/type: Invalid value " + accessor.type);
  3021. }
  3022. if (accessor.componentType !== 5121 /* UNSIGNED_BYTE */ &&
  3023. accessor.componentType !== 5123 /* UNSIGNED_SHORT */ &&
  3024. accessor.componentType !== 5125 /* UNSIGNED_INT */) {
  3025. throw new Error(context + "/componentType: Invalid value " + accessor.componentType);
  3026. }
  3027. if (accessor._data) {
  3028. return accessor._data;
  3029. }
  3030. if (accessor.sparse) {
  3031. var constructor = GLTFLoader._GetTypedArrayConstructor(context + "/componentType", accessor.componentType);
  3032. accessor._data = this._loadAccessorAsync(context, accessor, constructor);
  3033. }
  3034. else {
  3035. var bufferView = ArrayItem.Get(context + "/bufferView", this._gltf.bufferViews, accessor.bufferView);
  3036. accessor._data = this.loadBufferViewAsync("/bufferViews/" + bufferView.index, bufferView).then(function (data) {
  3037. return GLTFLoader._GetTypedArray(context, accessor.componentType, data, accessor.byteOffset, accessor.count);
  3038. });
  3039. }
  3040. return accessor._data;
  3041. };
  3042. GLTFLoader.prototype._loadVertexBufferViewAsync = function (bufferView, kind) {
  3043. var _this = this;
  3044. if (bufferView._babylonBuffer) {
  3045. return bufferView._babylonBuffer;
  3046. }
  3047. bufferView._babylonBuffer = this.loadBufferViewAsync("/bufferViews/" + bufferView.index, bufferView).then(function (data) {
  3048. return new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Buffer"](_this._babylonScene.getEngine(), data, false);
  3049. });
  3050. return bufferView._babylonBuffer;
  3051. };
  3052. GLTFLoader.prototype._loadVertexAccessorAsync = function (context, accessor, kind) {
  3053. var _this = this;
  3054. if (accessor._babylonVertexBuffer) {
  3055. return accessor._babylonVertexBuffer;
  3056. }
  3057. if (accessor.sparse) {
  3058. accessor._babylonVertexBuffer = this._loadFloatAccessorAsync("/accessors/" + accessor.index, accessor).then(function (data) {
  3059. return new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"](_this._babylonScene.getEngine(), data, kind, false);
  3060. });
  3061. }
  3062. // HACK: If byte offset is not a multiple of component type byte length then load as a float array instead of using Babylon buffers.
  3063. else if (accessor.byteOffset && accessor.byteOffset % babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].GetTypeByteLength(accessor.componentType) !== 0) {
  3064. babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Accessor byte offset is not a multiple of component type byte length");
  3065. accessor._babylonVertexBuffer = this._loadFloatAccessorAsync("/accessors/" + accessor.index, accessor).then(function (data) {
  3066. return new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"](_this._babylonScene.getEngine(), data, kind, false);
  3067. });
  3068. }
  3069. // Load joint indices as a float array since the shaders expect float data but glTF uses unsigned byte/short.
  3070. // This prevents certain platforms (e.g. D3D) from having to convert the data to float on the fly.
  3071. else if (kind === babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesKind || kind === babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesExtraKind) {
  3072. accessor._babylonVertexBuffer = this._loadFloatAccessorAsync("/accessors/" + accessor.index, accessor).then(function (data) {
  3073. return new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"](_this._babylonScene.getEngine(), data, kind, false);
  3074. });
  3075. }
  3076. else {
  3077. var bufferView_2 = ArrayItem.Get(context + "/bufferView", this._gltf.bufferViews, accessor.bufferView);
  3078. accessor._babylonVertexBuffer = this._loadVertexBufferViewAsync(bufferView_2, kind).then(function (babylonBuffer) {
  3079. var size = GLTFLoader._GetNumComponents(context, accessor.type);
  3080. return new babylonjs_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);
  3081. });
  3082. }
  3083. return accessor._babylonVertexBuffer;
  3084. };
  3085. GLTFLoader.prototype._loadMaterialMetallicRoughnessPropertiesAsync = function (context, properties, babylonMaterial) {
  3086. if (!(babylonMaterial instanceof babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"])) {
  3087. throw new Error(context + ": Material type not supported");
  3088. }
  3089. var promises = new Array();
  3090. if (properties) {
  3091. if (properties.baseColorFactor) {
  3092. babylonMaterial.albedoColor = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(properties.baseColorFactor);
  3093. babylonMaterial.alpha = properties.baseColorFactor[3];
  3094. }
  3095. else {
  3096. babylonMaterial.albedoColor = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
  3097. }
  3098. babylonMaterial.metallic = properties.metallicFactor == undefined ? 1 : properties.metallicFactor;
  3099. babylonMaterial.roughness = properties.roughnessFactor == undefined ? 1 : properties.roughnessFactor;
  3100. if (properties.baseColorTexture) {
  3101. promises.push(this.loadTextureInfoAsync(context + "/baseColorTexture", properties.baseColorTexture, function (texture) {
  3102. texture.name = babylonMaterial.name + " (Base Color)";
  3103. babylonMaterial.albedoTexture = texture;
  3104. }));
  3105. }
  3106. if (properties.metallicRoughnessTexture) {
  3107. promises.push(this.loadTextureInfoAsync(context + "/metallicRoughnessTexture", properties.metallicRoughnessTexture, function (texture) {
  3108. texture.name = babylonMaterial.name + " (Metallic Roughness)";
  3109. babylonMaterial.metallicTexture = texture;
  3110. }));
  3111. babylonMaterial.useMetallnessFromMetallicTextureBlue = true;
  3112. babylonMaterial.useRoughnessFromMetallicTextureGreen = true;
  3113. babylonMaterial.useRoughnessFromMetallicTextureAlpha = false;
  3114. }
  3115. }
  3116. return Promise.all(promises).then(function () { });
  3117. };
  3118. /** @hidden */
  3119. GLTFLoader.prototype._loadMaterialAsync = function (context, material, babylonMesh, babylonDrawMode, assign) {
  3120. if (assign === void 0) { assign = function () { }; }
  3121. var extensionPromise = this._extensionsLoadMaterialAsync(context, material, babylonMesh, babylonDrawMode, assign);
  3122. if (extensionPromise) {
  3123. return extensionPromise;
  3124. }
  3125. material._data = material._data || {};
  3126. var babylonData = material._data[babylonDrawMode];
  3127. if (!babylonData) {
  3128. this.logOpen(context + " " + (material.name || ""));
  3129. var babylonMaterial = this.createMaterial(context, material, babylonDrawMode);
  3130. babylonData = {
  3131. babylonMaterial: babylonMaterial,
  3132. babylonMeshes: [],
  3133. promise: this.loadMaterialPropertiesAsync(context, material, babylonMaterial)
  3134. };
  3135. material._data[babylonDrawMode] = babylonData;
  3136. GLTFLoader.AddPointerMetadata(babylonMaterial, context);
  3137. this._parent.onMaterialLoadedObservable.notifyObservers(babylonMaterial);
  3138. this.logClose();
  3139. }
  3140. babylonData.babylonMeshes.push(babylonMesh);
  3141. babylonMesh.onDisposeObservable.addOnce(function () {
  3142. var index = babylonData.babylonMeshes.indexOf(babylonMesh);
  3143. if (index !== -1) {
  3144. babylonData.babylonMeshes.splice(index, 1);
  3145. }
  3146. });
  3147. assign(babylonData.babylonMaterial);
  3148. return babylonData.promise.then(function () {
  3149. return babylonData.babylonMaterial;
  3150. });
  3151. };
  3152. GLTFLoader.prototype._createDefaultMaterial = function (name, babylonDrawMode) {
  3153. this._babylonScene._blockEntityCollection = this._forAssetContainer;
  3154. var babylonMaterial = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"](name, this._babylonScene);
  3155. this._babylonScene._blockEntityCollection = false;
  3156. // Moved to mesh so user can change materials on gltf meshes: babylonMaterial.sideOrientation = this._babylonScene.useRightHandedSystem ? Material.CounterClockWiseSideOrientation : Material.ClockWiseSideOrientation;
  3157. babylonMaterial.fillMode = babylonDrawMode;
  3158. babylonMaterial.enableSpecularAntiAliasing = true;
  3159. babylonMaterial.useRadianceOverAlpha = !this._parent.transparencyAsCoverage;
  3160. babylonMaterial.useSpecularOverAlpha = !this._parent.transparencyAsCoverage;
  3161. babylonMaterial.transparencyMode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"].PBRMATERIAL_OPAQUE;
  3162. babylonMaterial.metallic = 1;
  3163. babylonMaterial.roughness = 1;
  3164. return babylonMaterial;
  3165. };
  3166. /**
  3167. * Creates a Babylon material from a glTF material.
  3168. * @param context The context when loading the asset
  3169. * @param material The glTF material property
  3170. * @param babylonDrawMode The draw mode for the Babylon material
  3171. * @returns The Babylon material
  3172. */
  3173. GLTFLoader.prototype.createMaterial = function (context, material, babylonDrawMode) {
  3174. var extensionPromise = this._extensionsCreateMaterial(context, material, babylonDrawMode);
  3175. if (extensionPromise) {
  3176. return extensionPromise;
  3177. }
  3178. var name = material.name || "material" + material.index;
  3179. var babylonMaterial = this._createDefaultMaterial(name, babylonDrawMode);
  3180. return babylonMaterial;
  3181. };
  3182. /**
  3183. * Loads properties from a glTF material into a Babylon material.
  3184. * @param context The context when loading the asset
  3185. * @param material The glTF material property
  3186. * @param babylonMaterial The Babylon material
  3187. * @returns A promise that resolves when the load is complete
  3188. */
  3189. GLTFLoader.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
  3190. var extensionPromise = this._extensionsLoadMaterialPropertiesAsync(context, material, babylonMaterial);
  3191. if (extensionPromise) {
  3192. return extensionPromise;
  3193. }
  3194. var promises = new Array();
  3195. promises.push(this.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));
  3196. if (material.pbrMetallicRoughness) {
  3197. promises.push(this._loadMaterialMetallicRoughnessPropertiesAsync(context + "/pbrMetallicRoughness", material.pbrMetallicRoughness, babylonMaterial));
  3198. }
  3199. this.loadMaterialAlphaProperties(context, material, babylonMaterial);
  3200. return Promise.all(promises).then(function () { });
  3201. };
  3202. /**
  3203. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  3204. * @param context The context when loading the asset
  3205. * @param material The glTF material property
  3206. * @param babylonMaterial The Babylon material
  3207. * @returns A promise that resolves when the load is complete
  3208. */
  3209. GLTFLoader.prototype.loadMaterialBasePropertiesAsync = function (context, material, babylonMaterial) {
  3210. if (!(babylonMaterial instanceof babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"])) {
  3211. throw new Error(context + ": Material type not supported");
  3212. }
  3213. var promises = new Array();
  3214. babylonMaterial.emissiveColor = material.emissiveFactor ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(material.emissiveFactor) : new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Color3"](0, 0, 0);
  3215. if (material.doubleSided) {
  3216. babylonMaterial.backFaceCulling = false;
  3217. babylonMaterial.twoSidedLighting = true;
  3218. }
  3219. if (material.normalTexture) {
  3220. promises.push(this.loadTextureInfoAsync(context + "/normalTexture", material.normalTexture, function (texture) {
  3221. texture.name = babylonMaterial.name + " (Normal)";
  3222. babylonMaterial.bumpTexture = texture;
  3223. }));
  3224. babylonMaterial.invertNormalMapX = !this._babylonScene.useRightHandedSystem;
  3225. babylonMaterial.invertNormalMapY = this._babylonScene.useRightHandedSystem;
  3226. if (material.normalTexture.scale != undefined) {
  3227. babylonMaterial.bumpTexture.level = material.normalTexture.scale;
  3228. }
  3229. babylonMaterial.forceIrradianceInFragment = true;
  3230. }
  3231. if (material.occlusionTexture) {
  3232. promises.push(this.loadTextureInfoAsync(context + "/occlusionTexture", material.occlusionTexture, function (texture) {
  3233. texture.name = babylonMaterial.name + " (Occlusion)";
  3234. babylonMaterial.ambientTexture = texture;
  3235. }));
  3236. babylonMaterial.useAmbientInGrayScale = true;
  3237. if (material.occlusionTexture.strength != undefined) {
  3238. babylonMaterial.ambientTextureStrength = material.occlusionTexture.strength;
  3239. }
  3240. }
  3241. if (material.emissiveTexture) {
  3242. promises.push(this.loadTextureInfoAsync(context + "/emissiveTexture", material.emissiveTexture, function (texture) {
  3243. texture.name = babylonMaterial.name + " (Emissive)";
  3244. babylonMaterial.emissiveTexture = texture;
  3245. }));
  3246. }
  3247. return Promise.all(promises).then(function () { });
  3248. };
  3249. /**
  3250. * Loads the alpha properties from a glTF material into a Babylon material.
  3251. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  3252. * @param context The context when loading the asset
  3253. * @param material The glTF material property
  3254. * @param babylonMaterial The Babylon material
  3255. */
  3256. GLTFLoader.prototype.loadMaterialAlphaProperties = function (context, material, babylonMaterial) {
  3257. if (!(babylonMaterial instanceof babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"])) {
  3258. throw new Error(context + ": Material type not supported");
  3259. }
  3260. var alphaMode = material.alphaMode || "OPAQUE" /* OPAQUE */;
  3261. switch (alphaMode) {
  3262. case "OPAQUE" /* OPAQUE */: {
  3263. babylonMaterial.transparencyMode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"].PBRMATERIAL_OPAQUE;
  3264. break;
  3265. }
  3266. case "MASK" /* MASK */: {
  3267. babylonMaterial.transparencyMode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"].PBRMATERIAL_ALPHATEST;
  3268. babylonMaterial.alphaCutOff = (material.alphaCutoff == undefined ? 0.5 : material.alphaCutoff);
  3269. if (babylonMaterial.albedoTexture) {
  3270. babylonMaterial.albedoTexture.hasAlpha = true;
  3271. }
  3272. break;
  3273. }
  3274. case "BLEND" /* BLEND */: {
  3275. babylonMaterial.transparencyMode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"].PBRMATERIAL_ALPHABLEND;
  3276. if (babylonMaterial.albedoTexture) {
  3277. babylonMaterial.albedoTexture.hasAlpha = true;
  3278. babylonMaterial.useAlphaFromAlbedoTexture = true;
  3279. }
  3280. break;
  3281. }
  3282. default: {
  3283. throw new Error(context + "/alphaMode: Invalid value (" + material.alphaMode + ")");
  3284. }
  3285. }
  3286. };
  3287. /**
  3288. * Loads a glTF texture info.
  3289. * @param context The context when loading the asset
  3290. * @param textureInfo The glTF texture info property
  3291. * @param assign A function called synchronously after parsing the glTF properties
  3292. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  3293. */
  3294. GLTFLoader.prototype.loadTextureInfoAsync = function (context, textureInfo, assign) {
  3295. var _this = this;
  3296. if (assign === void 0) { assign = function () { }; }
  3297. var extensionPromise = this._extensionsLoadTextureInfoAsync(context, textureInfo, assign);
  3298. if (extensionPromise) {
  3299. return extensionPromise;
  3300. }
  3301. this.logOpen("" + context);
  3302. if (textureInfo.texCoord >= 2) {
  3303. throw new Error(context + "/texCoord: Invalid value (" + textureInfo.texCoord + ")");
  3304. }
  3305. var texture = ArrayItem.Get(context + "/index", this._gltf.textures, textureInfo.index);
  3306. var promise = this._loadTextureAsync("/textures/" + textureInfo.index, texture, function (babylonTexture) {
  3307. babylonTexture.coordinatesIndex = textureInfo.texCoord || 0;
  3308. GLTFLoader.AddPointerMetadata(babylonTexture, context);
  3309. _this._parent.onTextureLoadedObservable.notifyObservers(babylonTexture);
  3310. assign(babylonTexture);
  3311. });
  3312. this.logClose();
  3313. return promise;
  3314. };
  3315. /** @hidden */
  3316. GLTFLoader.prototype._loadTextureAsync = function (context, texture, assign) {
  3317. if (assign === void 0) { assign = function () { }; }
  3318. var extensionPromise = this._extensionsLoadTextureAsync(context, texture, assign);
  3319. if (extensionPromise) {
  3320. return extensionPromise;
  3321. }
  3322. this.logOpen(context + " " + (texture.name || ""));
  3323. var sampler = (texture.sampler == undefined ? GLTFLoader.DefaultSampler : ArrayItem.Get(context + "/sampler", this._gltf.samplers, texture.sampler));
  3324. var image = ArrayItem.Get(context + "/source", this._gltf.images, texture.source);
  3325. var promise = this._createTextureAsync(context, sampler, image, assign);
  3326. this.logClose();
  3327. return promise;
  3328. };
  3329. /** @hidden */
  3330. GLTFLoader.prototype._createTextureAsync = function (context, sampler, image, assign) {
  3331. var _this = this;
  3332. if (assign === void 0) { assign = function () { }; }
  3333. var samplerData = this._loadSampler("/samplers/" + sampler.index, sampler);
  3334. var promises = new Array();
  3335. var deferred = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Deferred"]();
  3336. this._babylonScene._blockEntityCollection = this._forAssetContainer;
  3337. var babylonTexture = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Texture"](null, this._babylonScene, samplerData.noMipMaps, false, samplerData.samplingMode, function () {
  3338. if (!_this._disposed) {
  3339. deferred.resolve();
  3340. }
  3341. }, function (message, exception) {
  3342. if (!_this._disposed) {
  3343. deferred.reject(new Error(context + ": " + ((exception && exception.message) ? exception.message : message || "Failed to load texture")));
  3344. }
  3345. }, undefined, undefined, undefined, image.mimeType);
  3346. this._babylonScene._blockEntityCollection = false;
  3347. promises.push(deferred.promise);
  3348. promises.push(this.loadImageAsync("/images/" + image.index, image).then(function (data) {
  3349. var name = image.uri || _this._fileName + "#image" + image.index;
  3350. var dataUrl = "data:" + _this._uniqueRootUrl + name;
  3351. babylonTexture.updateURL(dataUrl, data);
  3352. }));
  3353. babylonTexture.wrapU = samplerData.wrapU;
  3354. babylonTexture.wrapV = samplerData.wrapV;
  3355. assign(babylonTexture);
  3356. return Promise.all(promises).then(function () {
  3357. return babylonTexture;
  3358. });
  3359. };
  3360. GLTFLoader.prototype._loadSampler = function (context, sampler) {
  3361. if (!sampler._data) {
  3362. sampler._data = {
  3363. noMipMaps: (sampler.minFilter === 9728 /* NEAREST */ || sampler.minFilter === 9729 /* LINEAR */),
  3364. samplingMode: GLTFLoader._GetTextureSamplingMode(context, sampler),
  3365. wrapU: GLTFLoader._GetTextureWrapMode(context + "/wrapS", sampler.wrapS),
  3366. wrapV: GLTFLoader._GetTextureWrapMode(context + "/wrapT", sampler.wrapT)
  3367. };
  3368. }
  3369. return sampler._data;
  3370. };
  3371. /**
  3372. * Loads a glTF image.
  3373. * @param context The context when loading the asset
  3374. * @param image The glTF image property
  3375. * @returns A promise that resolves with the loaded data when the load is complete
  3376. */
  3377. GLTFLoader.prototype.loadImageAsync = function (context, image) {
  3378. if (!image._data) {
  3379. this.logOpen(context + " " + (image.name || ""));
  3380. if (image.uri) {
  3381. image._data = this.loadUriAsync(context + "/uri", image, image.uri);
  3382. }
  3383. else {
  3384. var bufferView = ArrayItem.Get(context + "/bufferView", this._gltf.bufferViews, image.bufferView);
  3385. image._data = this.loadBufferViewAsync("/bufferViews/" + bufferView.index, bufferView);
  3386. }
  3387. this.logClose();
  3388. }
  3389. return image._data;
  3390. };
  3391. /**
  3392. * Loads a glTF uri.
  3393. * @param context The context when loading the asset
  3394. * @param property The glTF property associated with the uri
  3395. * @param uri The base64 or relative uri
  3396. * @returns A promise that resolves with the loaded data when the load is complete
  3397. */
  3398. GLTFLoader.prototype.loadUriAsync = function (context, property, uri) {
  3399. var _this = this;
  3400. var extensionPromise = this._extensionsLoadUriAsync(context, property, uri);
  3401. if (extensionPromise) {
  3402. return extensionPromise;
  3403. }
  3404. if (!GLTFLoader._ValidateUri(uri)) {
  3405. throw new Error(context + ": '" + uri + "' is invalid");
  3406. }
  3407. if (babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsBase64(uri)) {
  3408. var data = new Uint8Array(babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Tools"].DecodeBase64(uri));
  3409. this.log("Decoded " + uri.substr(0, 64) + "... (" + data.length + " bytes)");
  3410. return Promise.resolve(data);
  3411. }
  3412. this.log("Loading " + uri);
  3413. return this._parent.preprocessUrlAsync(this._rootUrl + uri).then(function (url) {
  3414. return new Promise(function (resolve, reject) {
  3415. if (!_this._disposed) {
  3416. var request_1 = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(url, function (fileData) {
  3417. if (!_this._disposed) {
  3418. var data = new Uint8Array(fileData);
  3419. _this.log("Loaded " + uri + " (" + data.length + " bytes)");
  3420. resolve(data);
  3421. }
  3422. }, function (event) {
  3423. if (!_this._disposed) {
  3424. if (request_1) {
  3425. request_1._lengthComputable = event.lengthComputable;
  3426. request_1._loaded = event.loaded;
  3427. request_1._total = event.total;
  3428. }
  3429. if (_this._state === _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderState"].LOADING) {
  3430. try {
  3431. _this._onProgress();
  3432. }
  3433. catch (e) {
  3434. reject(e);
  3435. }
  3436. }
  3437. }
  3438. }, _this._babylonScene.offlineProvider, true, function (request, exception) {
  3439. if (!_this._disposed) {
  3440. reject(new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["LoadFileError"](context + ": Failed to load '" + uri + "'" + (request ? ": " + request.status + " " + request.statusText : ""), request));
  3441. }
  3442. });
  3443. _this._requests.push(request_1);
  3444. }
  3445. });
  3446. });
  3447. };
  3448. GLTFLoader.prototype._onProgress = function () {
  3449. if (!this._progressCallback) {
  3450. return;
  3451. }
  3452. var lengthComputable = true;
  3453. var loaded = 0;
  3454. var total = 0;
  3455. for (var _i = 0, _a = this._requests; _i < _a.length; _i++) {
  3456. var request = _a[_i];
  3457. if (request._lengthComputable === undefined || request._loaded === undefined || request._total === undefined) {
  3458. return;
  3459. }
  3460. lengthComputable = lengthComputable && request._lengthComputable;
  3461. loaded += request._loaded;
  3462. total += request._total;
  3463. }
  3464. this._progressCallback(new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderProgressEvent"](lengthComputable, loaded, lengthComputable ? total : 0));
  3465. };
  3466. /**
  3467. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  3468. * @param babylonObject the Babylon object with metadata
  3469. * @param pointer the JSON pointer
  3470. */
  3471. GLTFLoader.AddPointerMetadata = function (babylonObject, pointer) {
  3472. var metadata = (babylonObject.metadata = babylonObject.metadata || {});
  3473. var gltf = (metadata.gltf = metadata.gltf || {});
  3474. var pointers = (gltf.pointers = gltf.pointers || []);
  3475. pointers.push(pointer);
  3476. };
  3477. GLTFLoader._GetTextureWrapMode = function (context, mode) {
  3478. // Set defaults if undefined
  3479. mode = mode == undefined ? 10497 /* REPEAT */ : mode;
  3480. switch (mode) {
  3481. case 33071 /* CLAMP_TO_EDGE */: return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  3482. case 33648 /* MIRRORED_REPEAT */: return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Texture"].MIRROR_ADDRESSMODE;
  3483. case 10497 /* REPEAT */: return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Texture"].WRAP_ADDRESSMODE;
  3484. default:
  3485. babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn(context + ": Invalid value (" + mode + ")");
  3486. return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Texture"].WRAP_ADDRESSMODE;
  3487. }
  3488. };
  3489. GLTFLoader._GetTextureSamplingMode = function (context, sampler) {
  3490. // Set defaults if undefined
  3491. var magFilter = sampler.magFilter == undefined ? 9729 /* LINEAR */ : sampler.magFilter;
  3492. var minFilter = sampler.minFilter == undefined ? 9987 /* LINEAR_MIPMAP_LINEAR */ : sampler.minFilter;
  3493. if (magFilter === 9729 /* LINEAR */) {
  3494. switch (minFilter) {
  3495. case 9728 /* NEAREST */: return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Texture"].LINEAR_NEAREST;
  3496. case 9729 /* LINEAR */: return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Texture"].LINEAR_LINEAR;
  3497. case 9984 /* NEAREST_MIPMAP_NEAREST */: return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Texture"].LINEAR_NEAREST_MIPNEAREST;
  3498. case 9985 /* LINEAR_MIPMAP_NEAREST */: return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Texture"].LINEAR_LINEAR_MIPNEAREST;
  3499. case 9986 /* NEAREST_MIPMAP_LINEAR */: return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Texture"].LINEAR_NEAREST_MIPLINEAR;
  3500. case 9987 /* LINEAR_MIPMAP_LINEAR */: return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Texture"].LINEAR_LINEAR_MIPLINEAR;
  3501. default:
  3502. babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn(context + "/minFilter: Invalid value (" + minFilter + ")");
  3503. return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Texture"].LINEAR_LINEAR_MIPLINEAR;
  3504. }
  3505. }
  3506. else {
  3507. if (magFilter !== 9728 /* NEAREST */) {
  3508. babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn(context + "/magFilter: Invalid value (" + magFilter + ")");
  3509. }
  3510. switch (minFilter) {
  3511. case 9728 /* NEAREST */: return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Texture"].NEAREST_NEAREST;
  3512. case 9729 /* LINEAR */: return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Texture"].NEAREST_LINEAR;
  3513. case 9984 /* NEAREST_MIPMAP_NEAREST */: return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Texture"].NEAREST_NEAREST_MIPNEAREST;
  3514. case 9985 /* LINEAR_MIPMAP_NEAREST */: return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Texture"].NEAREST_LINEAR_MIPNEAREST;
  3515. case 9986 /* NEAREST_MIPMAP_LINEAR */: return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Texture"].NEAREST_NEAREST_MIPLINEAR;
  3516. case 9987 /* LINEAR_MIPMAP_LINEAR */: return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Texture"].NEAREST_LINEAR_MIPLINEAR;
  3517. default:
  3518. babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn(context + "/minFilter: Invalid value (" + minFilter + ")");
  3519. return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Texture"].NEAREST_NEAREST_MIPNEAREST;
  3520. }
  3521. }
  3522. };
  3523. GLTFLoader._GetTypedArrayConstructor = function (context, componentType) {
  3524. switch (componentType) {
  3525. case 5120 /* BYTE */: return Int8Array;
  3526. case 5121 /* UNSIGNED_BYTE */: return Uint8Array;
  3527. case 5122 /* SHORT */: return Int16Array;
  3528. case 5123 /* UNSIGNED_SHORT */: return Uint16Array;
  3529. case 5125 /* UNSIGNED_INT */: return Uint32Array;
  3530. case 5126 /* FLOAT */: return Float32Array;
  3531. default: throw new Error(context + ": Invalid component type " + componentType);
  3532. }
  3533. };
  3534. GLTFLoader._GetTypedArray = function (context, componentType, bufferView, byteOffset, length) {
  3535. var buffer = bufferView.buffer;
  3536. byteOffset = bufferView.byteOffset + (byteOffset || 0);
  3537. var constructor = GLTFLoader._GetTypedArrayConstructor(context + "/componentType", componentType);
  3538. try {
  3539. return new constructor(buffer, byteOffset, length);
  3540. }
  3541. catch (e) {
  3542. throw new Error(context + ": " + e);
  3543. }
  3544. };
  3545. GLTFLoader._GetNumComponents = function (context, type) {
  3546. switch (type) {
  3547. case "SCALAR": return 1;
  3548. case "VEC2": return 2;
  3549. case "VEC3": return 3;
  3550. case "VEC4": return 4;
  3551. case "MAT2": return 4;
  3552. case "MAT3": return 9;
  3553. case "MAT4": return 16;
  3554. }
  3555. throw new Error(context + ": Invalid type (" + type + ")");
  3556. };
  3557. GLTFLoader._ValidateUri = function (uri) {
  3558. return (babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsBase64(uri) || uri.indexOf("..") === -1);
  3559. };
  3560. GLTFLoader._GetDrawMode = function (context, mode) {
  3561. if (mode == undefined) {
  3562. mode = 4 /* TRIANGLES */;
  3563. }
  3564. switch (mode) {
  3565. case 0 /* POINTS */: return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Material"].PointListDrawMode;
  3566. case 1 /* LINES */: return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Material"].LineListDrawMode;
  3567. case 2 /* LINE_LOOP */: return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Material"].LineLoopDrawMode;
  3568. case 3 /* LINE_STRIP */: return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Material"].LineStripDrawMode;
  3569. case 4 /* TRIANGLES */: return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode;
  3570. case 5 /* TRIANGLE_STRIP */: return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleStripDrawMode;
  3571. case 6 /* TRIANGLE_FAN */: return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFanDrawMode;
  3572. }
  3573. throw new Error(context + ": Invalid mesh primitive mode (" + mode + ")");
  3574. };
  3575. GLTFLoader.prototype._compileMaterialsAsync = function () {
  3576. var _this = this;
  3577. this._parent._startPerformanceCounter("Compile materials");
  3578. var promises = new Array();
  3579. if (this._gltf.materials) {
  3580. for (var _i = 0, _a = this._gltf.materials; _i < _a.length; _i++) {
  3581. var material = _a[_i];
  3582. if (material._data) {
  3583. for (var babylonDrawMode in material._data) {
  3584. var babylonData = material._data[babylonDrawMode];
  3585. for (var _b = 0, _c = babylonData.babylonMeshes; _b < _c.length; _b++) {
  3586. var babylonMesh = _c[_b];
  3587. // Ensure nonUniformScaling is set if necessary.
  3588. babylonMesh.computeWorldMatrix(true);
  3589. var babylonMaterial = babylonData.babylonMaterial;
  3590. promises.push(babylonMaterial.forceCompilationAsync(babylonMesh));
  3591. promises.push(babylonMaterial.forceCompilationAsync(babylonMesh, { useInstances: true }));
  3592. if (this._parent.useClipPlane) {
  3593. promises.push(babylonMaterial.forceCompilationAsync(babylonMesh, { clipPlane: true }));
  3594. promises.push(babylonMaterial.forceCompilationAsync(babylonMesh, { clipPlane: true, useInstances: true }));
  3595. }
  3596. }
  3597. }
  3598. }
  3599. }
  3600. }
  3601. return Promise.all(promises).then(function () {
  3602. _this._parent._endPerformanceCounter("Compile materials");
  3603. });
  3604. };
  3605. GLTFLoader.prototype._compileShadowGeneratorsAsync = function () {
  3606. var _this = this;
  3607. this._parent._startPerformanceCounter("Compile shadow generators");
  3608. var promises = new Array();
  3609. var lights = this._babylonScene.lights;
  3610. for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) {
  3611. var light = lights_1[_i];
  3612. var generator = light.getShadowGenerator();
  3613. if (generator) {
  3614. promises.push(generator.forceCompilationAsync());
  3615. }
  3616. }
  3617. return Promise.all(promises).then(function () {
  3618. _this._parent._endPerformanceCounter("Compile shadow generators");
  3619. });
  3620. };
  3621. GLTFLoader.prototype._forEachExtensions = function (action) {
  3622. for (var _i = 0, _a = this._extensions; _i < _a.length; _i++) {
  3623. var extension = _a[_i];
  3624. if (extension.enabled) {
  3625. action(extension);
  3626. }
  3627. }
  3628. };
  3629. GLTFLoader.prototype._applyExtensions = function (property, functionName, actionAsync) {
  3630. for (var _i = 0, _a = this._extensions; _i < _a.length; _i++) {
  3631. var extension = _a[_i];
  3632. if (extension.enabled) {
  3633. var id = extension.name + "." + functionName;
  3634. var loaderProperty = property;
  3635. loaderProperty._activeLoaderExtensionFunctions = loaderProperty._activeLoaderExtensionFunctions || {};
  3636. var activeLoaderExtensionFunctions = loaderProperty._activeLoaderExtensionFunctions;
  3637. if (!activeLoaderExtensionFunctions[id]) {
  3638. activeLoaderExtensionFunctions[id] = true;
  3639. try {
  3640. var result = actionAsync(extension);
  3641. if (result) {
  3642. return result;
  3643. }
  3644. }
  3645. finally {
  3646. delete activeLoaderExtensionFunctions[id];
  3647. }
  3648. }
  3649. }
  3650. }
  3651. return null;
  3652. };
  3653. GLTFLoader.prototype._extensionsOnLoading = function () {
  3654. this._forEachExtensions(function (extension) { return extension.onLoading && extension.onLoading(); });
  3655. };
  3656. GLTFLoader.prototype._extensionsOnReady = function () {
  3657. this._forEachExtensions(function (extension) { return extension.onReady && extension.onReady(); });
  3658. };
  3659. GLTFLoader.prototype._extensionsLoadSceneAsync = function (context, scene) {
  3660. return this._applyExtensions(scene, "loadScene", function (extension) { return extension.loadSceneAsync && extension.loadSceneAsync(context, scene); });
  3661. };
  3662. GLTFLoader.prototype._extensionsLoadNodeAsync = function (context, node, assign) {
  3663. return this._applyExtensions(node, "loadNode", function (extension) { return extension.loadNodeAsync && extension.loadNodeAsync(context, node, assign); });
  3664. };
  3665. GLTFLoader.prototype._extensionsLoadCameraAsync = function (context, camera, assign) {
  3666. return this._applyExtensions(camera, "loadCamera", function (extension) { return extension.loadCameraAsync && extension.loadCameraAsync(context, camera, assign); });
  3667. };
  3668. GLTFLoader.prototype._extensionsLoadVertexDataAsync = function (context, primitive, babylonMesh) {
  3669. return this._applyExtensions(primitive, "loadVertexData", function (extension) { return extension._loadVertexDataAsync && extension._loadVertexDataAsync(context, primitive, babylonMesh); });
  3670. };
  3671. GLTFLoader.prototype._extensionsLoadMeshPrimitiveAsync = function (context, name, node, mesh, primitive, assign) {
  3672. return this._applyExtensions(primitive, "loadMeshPrimitive", function (extension) { return extension._loadMeshPrimitiveAsync && extension._loadMeshPrimitiveAsync(context, name, node, mesh, primitive, assign); });
  3673. };
  3674. GLTFLoader.prototype._extensionsLoadMaterialAsync = function (context, material, babylonMesh, babylonDrawMode, assign) {
  3675. return this._applyExtensions(material, "loadMaterial", function (extension) { return extension._loadMaterialAsync && extension._loadMaterialAsync(context, material, babylonMesh, babylonDrawMode, assign); });
  3676. };
  3677. GLTFLoader.prototype._extensionsCreateMaterial = function (context, material, babylonDrawMode) {
  3678. return this._applyExtensions(material, "createMaterial", function (extension) { return extension.createMaterial && extension.createMaterial(context, material, babylonDrawMode); });
  3679. };
  3680. GLTFLoader.prototype._extensionsLoadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
  3681. return this._applyExtensions(material, "loadMaterialProperties", function (extension) { return extension.loadMaterialPropertiesAsync && extension.loadMaterialPropertiesAsync(context, material, babylonMaterial); });
  3682. };
  3683. GLTFLoader.prototype._extensionsLoadTextureInfoAsync = function (context, textureInfo, assign) {
  3684. return this._applyExtensions(textureInfo, "loadTextureInfo", function (extension) { return extension.loadTextureInfoAsync && extension.loadTextureInfoAsync(context, textureInfo, assign); });
  3685. };
  3686. GLTFLoader.prototype._extensionsLoadTextureAsync = function (context, texture, assign) {
  3687. return this._applyExtensions(texture, "loadTexture", function (extension) { return extension._loadTextureAsync && extension._loadTextureAsync(context, texture, assign); });
  3688. };
  3689. GLTFLoader.prototype._extensionsLoadAnimationAsync = function (context, animation) {
  3690. return this._applyExtensions(animation, "loadAnimation", function (extension) { return extension.loadAnimationAsync && extension.loadAnimationAsync(context, animation); });
  3691. };
  3692. GLTFLoader.prototype._extensionsLoadSkinAsync = function (context, node, skin) {
  3693. return this._applyExtensions(skin, "loadSkin", function (extension) { return extension._loadSkinAsync && extension._loadSkinAsync(context, node, skin); });
  3694. };
  3695. GLTFLoader.prototype._extensionsLoadUriAsync = function (context, property, uri) {
  3696. return this._applyExtensions(property, "loadUri", function (extension) { return extension._loadUriAsync && extension._loadUriAsync(context, property, uri); });
  3697. };
  3698. GLTFLoader.prototype._extensionsLoadBufferViewAsync = function (context, bufferView) {
  3699. return this._applyExtensions(bufferView, "loadBufferView", function (extension) { return extension.loadBufferViewAsync && extension.loadBufferViewAsync(context, bufferView); });
  3700. };
  3701. GLTFLoader.prototype._extensionsLoadBufferAsync = function (context, buffer, byteOffset, byteLength) {
  3702. return this._applyExtensions(buffer, "loadBuffer", function (extension) { return extension.loadBufferAsync && extension.loadBufferAsync(context, buffer, byteOffset, byteLength); });
  3703. };
  3704. /**
  3705. * Helper method called by a loader extension to load an glTF extension.
  3706. * @param context The context when loading the asset
  3707. * @param property The glTF property to load the extension from
  3708. * @param extensionName The name of the extension to load
  3709. * @param actionAsync The action to run
  3710. * @returns The promise returned by actionAsync or null if the extension does not exist
  3711. */
  3712. GLTFLoader.LoadExtensionAsync = function (context, property, extensionName, actionAsync) {
  3713. if (!property.extensions) {
  3714. return null;
  3715. }
  3716. var extensions = property.extensions;
  3717. var extension = extensions[extensionName];
  3718. if (!extension) {
  3719. return null;
  3720. }
  3721. return actionAsync(context + "/extensions/" + extensionName, extension);
  3722. };
  3723. /**
  3724. * Helper method called by a loader extension to load a glTF extra.
  3725. * @param context The context when loading the asset
  3726. * @param property The glTF property to load the extra from
  3727. * @param extensionName The name of the extension to load
  3728. * @param actionAsync The action to run
  3729. * @returns The promise returned by actionAsync or null if the extra does not exist
  3730. */
  3731. GLTFLoader.LoadExtraAsync = function (context, property, extensionName, actionAsync) {
  3732. if (!property.extras) {
  3733. return null;
  3734. }
  3735. var extras = property.extras;
  3736. var extra = extras[extensionName];
  3737. if (!extra) {
  3738. return null;
  3739. }
  3740. return actionAsync(context + "/extras/" + extensionName, extra);
  3741. };
  3742. /**
  3743. * Checks for presence of an extension.
  3744. * @param name The name of the extension to check
  3745. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  3746. */
  3747. GLTFLoader.prototype.isExtensionUsed = function (name) {
  3748. return !!this._gltf.extensionsUsed && this._gltf.extensionsUsed.indexOf(name) !== -1;
  3749. };
  3750. /**
  3751. * Increments the indentation level and logs a message.
  3752. * @param message The message to log
  3753. */
  3754. GLTFLoader.prototype.logOpen = function (message) {
  3755. this._parent._logOpen(message);
  3756. };
  3757. /**
  3758. * Decrements the indentation level.
  3759. */
  3760. GLTFLoader.prototype.logClose = function () {
  3761. this._parent._logClose();
  3762. };
  3763. /**
  3764. * Logs a message
  3765. * @param message The message to log
  3766. */
  3767. GLTFLoader.prototype.log = function (message) {
  3768. this._parent._log(message);
  3769. };
  3770. /**
  3771. * Starts a performance counter.
  3772. * @param counterName The name of the performance counter
  3773. */
  3774. GLTFLoader.prototype.startPerformanceCounter = function (counterName) {
  3775. this._parent._startPerformanceCounter(counterName);
  3776. };
  3777. /**
  3778. * Ends a performance counter.
  3779. * @param counterName The name of the performance counter
  3780. */
  3781. GLTFLoader.prototype.endPerformanceCounter = function (counterName) {
  3782. this._parent._endPerformanceCounter(counterName);
  3783. };
  3784. GLTFLoader._RegisteredExtensions = {};
  3785. /**
  3786. * The default glTF sampler.
  3787. */
  3788. GLTFLoader.DefaultSampler = { index: -1 };
  3789. return GLTFLoader;
  3790. }());
  3791. _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFFileLoader"]._CreateGLTF2Loader = function (parent) { return new GLTFLoader(parent); };
  3792. /***/ }),
  3793. /***/ "./glTF/2.0/glTFLoaderInterfaces.ts":
  3794. /*!******************************************!*\
  3795. !*** ./glTF/2.0/glTFLoaderInterfaces.ts ***!
  3796. \******************************************/
  3797. /*! no static exports found */
  3798. /***/ (function(module, exports) {
  3799. /***/ }),
  3800. /***/ "./glTF/2.0/index.ts":
  3801. /*!***************************!*\
  3802. !*** ./glTF/2.0/index.ts ***!
  3803. \***************************/
  3804. /*! exports provided: ArrayItem, GLTFLoader, EXT_lights_image_based, KHR_draco_mesh_compression, KHR_lights, KHR_materials_pbrSpecularGlossiness, KHR_materials_unlit, KHR_materials_clearcoat, KHR_materials_sheen, KHR_materials_specular, KHR_mesh_quantization, KHR_texture_basisu, KHR_texture_transform, MSFT_audio_emitter, MSFT_lod, MSFT_minecraftMesh, MSFT_sRGBFactors, ExtrasAsMetadata */
  3805. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3806. "use strict";
  3807. __webpack_require__.r(__webpack_exports__);
  3808. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFLoader */ "./glTF/2.0/glTFLoader.ts");
  3809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArrayItem", function() { return _glTFLoader__WEBPACK_IMPORTED_MODULE_0__["ArrayItem"]; });
  3810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFLoader", function() { return _glTFLoader__WEBPACK_IMPORTED_MODULE_0__["GLTFLoader"]; });
  3811. /* harmony import */ var _Extensions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Extensions */ "./glTF/2.0/Extensions/index.ts");
  3812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EXT_lights_image_based", function() { return _Extensions__WEBPACK_IMPORTED_MODULE_1__["EXT_lights_image_based"]; });
  3813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KHR_draco_mesh_compression", function() { return _Extensions__WEBPACK_IMPORTED_MODULE_1__["KHR_draco_mesh_compression"]; });
  3814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KHR_lights", function() { return _Extensions__WEBPACK_IMPORTED_MODULE_1__["KHR_lights"]; });
  3815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KHR_materials_pbrSpecularGlossiness", function() { return _Extensions__WEBPACK_IMPORTED_MODULE_1__["KHR_materials_pbrSpecularGlossiness"]; });
  3816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KHR_materials_unlit", function() { return _Extensions__WEBPACK_IMPORTED_MODULE_1__["KHR_materials_unlit"]; });
  3817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KHR_materials_clearcoat", function() { return _Extensions__WEBPACK_IMPORTED_MODULE_1__["KHR_materials_clearcoat"]; });
  3818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KHR_materials_sheen", function() { return _Extensions__WEBPACK_IMPORTED_MODULE_1__["KHR_materials_sheen"]; });
  3819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KHR_materials_specular", function() { return _Extensions__WEBPACK_IMPORTED_MODULE_1__["KHR_materials_specular"]; });
  3820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KHR_mesh_quantization", function() { return _Extensions__WEBPACK_IMPORTED_MODULE_1__["KHR_mesh_quantization"]; });
  3821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KHR_texture_basisu", function() { return _Extensions__WEBPACK_IMPORTED_MODULE_1__["KHR_texture_basisu"]; });
  3822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KHR_texture_transform", function() { return _Extensions__WEBPACK_IMPORTED_MODULE_1__["KHR_texture_transform"]; });
  3823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MSFT_audio_emitter", function() { return _Extensions__WEBPACK_IMPORTED_MODULE_1__["MSFT_audio_emitter"]; });
  3824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MSFT_lod", function() { return _Extensions__WEBPACK_IMPORTED_MODULE_1__["MSFT_lod"]; });
  3825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MSFT_minecraftMesh", function() { return _Extensions__WEBPACK_IMPORTED_MODULE_1__["MSFT_minecraftMesh"]; });
  3826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MSFT_sRGBFactors", function() { return _Extensions__WEBPACK_IMPORTED_MODULE_1__["MSFT_sRGBFactors"]; });
  3827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtrasAsMetadata", function() { return _Extensions__WEBPACK_IMPORTED_MODULE_1__["ExtrasAsMetadata"]; });
  3828. /***/ }),
  3829. /***/ "./glTF/glTFFileLoader.ts":
  3830. /*!********************************!*\
  3831. !*** ./glTF/glTFFileLoader.ts ***!
  3832. \********************************/
  3833. /*! exports provided: GLTFLoaderCoordinateSystemMode, GLTFLoaderAnimationStartMode, GLTFLoaderState, GLTFFileLoader */
  3834. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3835. "use strict";
  3836. __webpack_require__.r(__webpack_exports__);
  3837. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GLTFLoaderCoordinateSystemMode", function() { return GLTFLoaderCoordinateSystemMode; });
  3838. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GLTFLoaderAnimationStartMode", function() { return GLTFLoaderAnimationStartMode; });
  3839. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GLTFLoaderState", function() { return GLTFLoaderState; });
  3840. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GLTFFileLoader", function() { return GLTFFileLoader; });
  3841. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  3842. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3843. /* harmony import */ var _glTFValidation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFValidation */ "./glTF/glTFValidation.ts");
  3844. /**
  3845. * Mode that determines the coordinate system to use.
  3846. */
  3847. var GLTFLoaderCoordinateSystemMode;
  3848. (function (GLTFLoaderCoordinateSystemMode) {
  3849. /**
  3850. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  3851. */
  3852. GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["AUTO"] = 0] = "AUTO";
  3853. /**
  3854. * Sets the useRightHandedSystem flag on the scene.
  3855. */
  3856. GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["FORCE_RIGHT_HANDED"] = 1] = "FORCE_RIGHT_HANDED";
  3857. })(GLTFLoaderCoordinateSystemMode || (GLTFLoaderCoordinateSystemMode = {}));
  3858. /**
  3859. * Mode that determines what animations will start.
  3860. */
  3861. var GLTFLoaderAnimationStartMode;
  3862. (function (GLTFLoaderAnimationStartMode) {
  3863. /**
  3864. * No animation will start.
  3865. */
  3866. GLTFLoaderAnimationStartMode[GLTFLoaderAnimationStartMode["NONE"] = 0] = "NONE";
  3867. /**
  3868. * The first animation will start.
  3869. */
  3870. GLTFLoaderAnimationStartMode[GLTFLoaderAnimationStartMode["FIRST"] = 1] = "FIRST";
  3871. /**
  3872. * All animations will start.
  3873. */
  3874. GLTFLoaderAnimationStartMode[GLTFLoaderAnimationStartMode["ALL"] = 2] = "ALL";
  3875. })(GLTFLoaderAnimationStartMode || (GLTFLoaderAnimationStartMode = {}));
  3876. /**
  3877. * Loader state.
  3878. */
  3879. var GLTFLoaderState;
  3880. (function (GLTFLoaderState) {
  3881. /**
  3882. * The asset is loading.
  3883. */
  3884. GLTFLoaderState[GLTFLoaderState["LOADING"] = 0] = "LOADING";
  3885. /**
  3886. * The asset is ready for rendering.
  3887. */
  3888. GLTFLoaderState[GLTFLoaderState["READY"] = 1] = "READY";
  3889. /**
  3890. * The asset is completely loaded.
  3891. */
  3892. GLTFLoaderState[GLTFLoaderState["COMPLETE"] = 2] = "COMPLETE";
  3893. })(GLTFLoaderState || (GLTFLoaderState = {}));
  3894. /**
  3895. * File loader for loading glTF files into a scene.
  3896. */
  3897. var GLTFFileLoader = /** @class */ (function () {
  3898. function GLTFFileLoader() {
  3899. // --------------
  3900. // Common options
  3901. // --------------
  3902. /**
  3903. * Raised when the asset has been parsed
  3904. */
  3905. this.onParsedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3906. // ----------
  3907. // V2 options
  3908. // ----------
  3909. /**
  3910. * The coordinate system mode. Defaults to AUTO.
  3911. */
  3912. this.coordinateSystemMode = GLTFLoaderCoordinateSystemMode.AUTO;
  3913. /**
  3914. * The animation start mode. Defaults to FIRST.
  3915. */
  3916. this.animationStartMode = GLTFLoaderAnimationStartMode.FIRST;
  3917. /**
  3918. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  3919. */
  3920. this.compileMaterials = false;
  3921. /**
  3922. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  3923. */
  3924. this.useClipPlane = false;
  3925. /**
  3926. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  3927. */
  3928. this.compileShadowGenerators = false;
  3929. /**
  3930. * Defines if the Alpha blended materials are only applied as coverage.
  3931. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  3932. * If true, no extra effects are applied to transparent pixels.
  3933. */
  3934. this.transparencyAsCoverage = false;
  3935. /**
  3936. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  3937. * Enabling will disable offline support and glTF validator.
  3938. * Defaults to false.
  3939. */
  3940. this.useRangeRequests = false;
  3941. /**
  3942. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  3943. */
  3944. this.createInstances = true;
  3945. /**
  3946. * Function called before loading a url referenced by the asset.
  3947. */
  3948. this.preprocessUrlAsync = function (url) { return Promise.resolve(url); };
  3949. /**
  3950. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  3951. */
  3952. this.onMeshLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3953. /**
  3954. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  3955. */
  3956. this.onTextureLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3957. /**
  3958. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  3959. */
  3960. this.onMaterialLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3961. /**
  3962. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  3963. */
  3964. this.onCameraLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3965. /**
  3966. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  3967. * For assets with LODs, raised when all of the LODs are complete.
  3968. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  3969. */
  3970. this.onCompleteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3971. /**
  3972. * Observable raised when an error occurs.
  3973. */
  3974. this.onErrorObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3975. /**
  3976. * Observable raised after the loader is disposed.
  3977. */
  3978. this.onDisposeObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3979. /**
  3980. * Observable raised after a loader extension is created.
  3981. * Set additional options for a loader extension in this event.
  3982. */
  3983. this.onExtensionLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3984. /**
  3985. * Defines if the loader should validate the asset.
  3986. */
  3987. this.validate = false;
  3988. /**
  3989. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  3990. */
  3991. this.onValidatedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3992. this._loader = null;
  3993. /**
  3994. * Name of the loader ("gltf")
  3995. */
  3996. this.name = "gltf";
  3997. /** @hidden */
  3998. this.extensions = {
  3999. ".gltf": { isBinary: false },
  4000. ".glb": { isBinary: true }
  4001. };
  4002. this._logIndentLevel = 0;
  4003. this._loggingEnabled = false;
  4004. /** @hidden */
  4005. this._log = this._logDisabled;
  4006. this._capturePerformanceCounters = false;
  4007. /** @hidden */
  4008. this._startPerformanceCounter = this._startPerformanceCounterDisabled;
  4009. /** @hidden */
  4010. this._endPerformanceCounter = this._endPerformanceCounterDisabled;
  4011. }
  4012. Object.defineProperty(GLTFFileLoader.prototype, "onParsed", {
  4013. /**
  4014. * Raised when the asset has been parsed
  4015. */
  4016. set: function (callback) {
  4017. if (this._onParsedObserver) {
  4018. this.onParsedObservable.remove(this._onParsedObserver);
  4019. }
  4020. this._onParsedObserver = this.onParsedObservable.add(callback);
  4021. },
  4022. enumerable: true,
  4023. configurable: true
  4024. });
  4025. Object.defineProperty(GLTFFileLoader.prototype, "onMeshLoaded", {
  4026. /**
  4027. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  4028. */
  4029. set: function (callback) {
  4030. if (this._onMeshLoadedObserver) {
  4031. this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver);
  4032. }
  4033. this._onMeshLoadedObserver = this.onMeshLoadedObservable.add(callback);
  4034. },
  4035. enumerable: true,
  4036. configurable: true
  4037. });
  4038. Object.defineProperty(GLTFFileLoader.prototype, "onTextureLoaded", {
  4039. /**
  4040. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  4041. */
  4042. set: function (callback) {
  4043. if (this._onTextureLoadedObserver) {
  4044. this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver);
  4045. }
  4046. this._onTextureLoadedObserver = this.onTextureLoadedObservable.add(callback);
  4047. },
  4048. enumerable: true,
  4049. configurable: true
  4050. });
  4051. Object.defineProperty(GLTFFileLoader.prototype, "onMaterialLoaded", {
  4052. /**
  4053. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  4054. */
  4055. set: function (callback) {
  4056. if (this._onMaterialLoadedObserver) {
  4057. this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver);
  4058. }
  4059. this._onMaterialLoadedObserver = this.onMaterialLoadedObservable.add(callback);
  4060. },
  4061. enumerable: true,
  4062. configurable: true
  4063. });
  4064. Object.defineProperty(GLTFFileLoader.prototype, "onCameraLoaded", {
  4065. /**
  4066. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  4067. */
  4068. set: function (callback) {
  4069. if (this._onCameraLoadedObserver) {
  4070. this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver);
  4071. }
  4072. this._onCameraLoadedObserver = this.onCameraLoadedObservable.add(callback);
  4073. },
  4074. enumerable: true,
  4075. configurable: true
  4076. });
  4077. Object.defineProperty(GLTFFileLoader.prototype, "onComplete", {
  4078. /**
  4079. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  4080. * For assets with LODs, raised when all of the LODs are complete.
  4081. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  4082. */
  4083. set: function (callback) {
  4084. if (this._onCompleteObserver) {
  4085. this.onCompleteObservable.remove(this._onCompleteObserver);
  4086. }
  4087. this._onCompleteObserver = this.onCompleteObservable.add(callback);
  4088. },
  4089. enumerable: true,
  4090. configurable: true
  4091. });
  4092. Object.defineProperty(GLTFFileLoader.prototype, "onError", {
  4093. /**
  4094. * Callback raised when an error occurs.
  4095. */
  4096. set: function (callback) {
  4097. if (this._onErrorObserver) {
  4098. this.onErrorObservable.remove(this._onErrorObserver);
  4099. }
  4100. this._onErrorObserver = this.onErrorObservable.add(callback);
  4101. },
  4102. enumerable: true,
  4103. configurable: true
  4104. });
  4105. Object.defineProperty(GLTFFileLoader.prototype, "onDispose", {
  4106. /**
  4107. * Callback raised after the loader is disposed.
  4108. */
  4109. set: function (callback) {
  4110. if (this._onDisposeObserver) {
  4111. this.onDisposeObservable.remove(this._onDisposeObserver);
  4112. }
  4113. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  4114. },
  4115. enumerable: true,
  4116. configurable: true
  4117. });
  4118. Object.defineProperty(GLTFFileLoader.prototype, "onExtensionLoaded", {
  4119. /**
  4120. * Callback raised after a loader extension is created.
  4121. */
  4122. set: function (callback) {
  4123. if (this._onExtensionLoadedObserver) {
  4124. this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver);
  4125. }
  4126. this._onExtensionLoadedObserver = this.onExtensionLoadedObservable.add(callback);
  4127. },
  4128. enumerable: true,
  4129. configurable: true
  4130. });
  4131. Object.defineProperty(GLTFFileLoader.prototype, "loggingEnabled", {
  4132. /**
  4133. * Defines if the loader logging is enabled.
  4134. */
  4135. get: function () {
  4136. return this._loggingEnabled;
  4137. },
  4138. set: function (value) {
  4139. if (this._loggingEnabled === value) {
  4140. return;
  4141. }
  4142. this._loggingEnabled = value;
  4143. if (this._loggingEnabled) {
  4144. this._log = this._logEnabled;
  4145. }
  4146. else {
  4147. this._log = this._logDisabled;
  4148. }
  4149. },
  4150. enumerable: true,
  4151. configurable: true
  4152. });
  4153. Object.defineProperty(GLTFFileLoader.prototype, "capturePerformanceCounters", {
  4154. /**
  4155. * Defines if the loader should capture performance counters.
  4156. */
  4157. get: function () {
  4158. return this._capturePerformanceCounters;
  4159. },
  4160. set: function (value) {
  4161. if (this._capturePerformanceCounters === value) {
  4162. return;
  4163. }
  4164. this._capturePerformanceCounters = value;
  4165. if (this._capturePerformanceCounters) {
  4166. this._startPerformanceCounter = this._startPerformanceCounterEnabled;
  4167. this._endPerformanceCounter = this._endPerformanceCounterEnabled;
  4168. }
  4169. else {
  4170. this._startPerformanceCounter = this._startPerformanceCounterDisabled;
  4171. this._endPerformanceCounter = this._endPerformanceCounterDisabled;
  4172. }
  4173. },
  4174. enumerable: true,
  4175. configurable: true
  4176. });
  4177. Object.defineProperty(GLTFFileLoader.prototype, "onValidated", {
  4178. /**
  4179. * Callback raised after a loader extension is created.
  4180. */
  4181. set: function (callback) {
  4182. if (this._onValidatedObserver) {
  4183. this.onValidatedObservable.remove(this._onValidatedObserver);
  4184. }
  4185. this._onValidatedObserver = this.onValidatedObservable.add(callback);
  4186. },
  4187. enumerable: true,
  4188. configurable: true
  4189. });
  4190. /**
  4191. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  4192. */
  4193. GLTFFileLoader.prototype.dispose = function () {
  4194. if (this._loader) {
  4195. this._loader.dispose();
  4196. this._loader = null;
  4197. }
  4198. this._clear();
  4199. this.onDisposeObservable.notifyObservers(undefined);
  4200. this.onDisposeObservable.clear();
  4201. };
  4202. /** @hidden */
  4203. GLTFFileLoader.prototype._clear = function () {
  4204. this.preprocessUrlAsync = function (url) { return Promise.resolve(url); };
  4205. this.onMeshLoadedObservable.clear();
  4206. this.onTextureLoadedObservable.clear();
  4207. this.onMaterialLoadedObservable.clear();
  4208. this.onCameraLoadedObservable.clear();
  4209. this.onCompleteObservable.clear();
  4210. this.onExtensionLoadedObservable.clear();
  4211. };
  4212. /** @hidden */
  4213. GLTFFileLoader.prototype.requestFile = function (scene, url, onSuccess, onProgress, useArrayBuffer, onError) {
  4214. var _this = this;
  4215. if (useArrayBuffer) {
  4216. if (this.useRangeRequests) {
  4217. if (this.validate) {
  4218. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("glTF validation is not supported when range requests are enabled");
  4219. }
  4220. var fileRequests_1 = new Array();
  4221. var aggregatedFileRequest_1 = {
  4222. abort: function () { return fileRequests_1.forEach(function (fileRequest) { return fileRequest.abort(); }); },
  4223. onCompleteObservable: new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]()
  4224. };
  4225. var dataBuffer_1 = {
  4226. readAsync: function (byteOffset, byteLength) {
  4227. return new Promise(function (resolve, reject) {
  4228. fileRequests_1.push(scene._requestFile(url, function (data, webRequest) {
  4229. var contentRange = webRequest.getResponseHeader("Content-Range");
  4230. if (contentRange) {
  4231. dataBuffer_1.byteLength = Number(contentRange.split("/")[1]);
  4232. }
  4233. resolve(new Uint8Array(data));
  4234. }, onProgress, true, true, function (error) {
  4235. reject(error);
  4236. }, function (webRequest) {
  4237. webRequest.setRequestHeader("Range", "bytes=" + byteOffset + "-" + (byteOffset + byteLength - 1));
  4238. }));
  4239. });
  4240. },
  4241. byteLength: 0
  4242. };
  4243. this._unpackBinaryAsync(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["DataReader"](dataBuffer_1)).then(function (loaderData) {
  4244. aggregatedFileRequest_1.onCompleteObservable.notifyObservers(aggregatedFileRequest_1);
  4245. onSuccess(loaderData);
  4246. }, onError);
  4247. return aggregatedFileRequest_1;
  4248. }
  4249. return scene._requestFile(url, function (data, request) {
  4250. var arrayBuffer = data;
  4251. _this._unpackBinaryAsync(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["DataReader"]({
  4252. readAsync: function (byteOffset, byteLength) { return Promise.resolve(new Uint8Array(arrayBuffer, byteOffset, byteLength)); },
  4253. byteLength: arrayBuffer.byteLength
  4254. })).then(function (loaderData) {
  4255. onSuccess(loaderData, request);
  4256. }, onError);
  4257. }, onProgress, true, true, onError);
  4258. }
  4259. return scene._requestFile(url, function (data, response) {
  4260. _this._validate(scene, data, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFolderPath(url), babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(url));
  4261. onSuccess({ json: _this._parseJson(data) }, response);
  4262. }, onProgress, true, false, onError);
  4263. };
  4264. /** @hidden */
  4265. GLTFFileLoader.prototype.readFile = function (scene, file, onSuccess, onProgress, useArrayBuffer, onError) {
  4266. var _this = this;
  4267. return scene._readFile(file, function (data) {
  4268. _this._validate(scene, data, "file:", file.name);
  4269. if (useArrayBuffer) {
  4270. var arrayBuffer_1 = data;
  4271. _this._unpackBinaryAsync(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["DataReader"]({
  4272. readAsync: function (byteOffset, byteLength) { return Promise.resolve(new Uint8Array(arrayBuffer_1, byteOffset, byteLength)); },
  4273. byteLength: arrayBuffer_1.byteLength
  4274. })).then(onSuccess, onError);
  4275. }
  4276. else {
  4277. onSuccess({ json: _this._parseJson(data) });
  4278. }
  4279. }, onProgress, useArrayBuffer, onError);
  4280. };
  4281. /** @hidden */
  4282. GLTFFileLoader.prototype.importMeshAsync = function (meshesNames, scene, data, rootUrl, onProgress, fileName) {
  4283. var _this = this;
  4284. return Promise.resolve().then(function () {
  4285. _this.onParsedObservable.notifyObservers(data);
  4286. _this.onParsedObservable.clear();
  4287. _this._log("Loading " + (fileName || ""));
  4288. _this._loader = _this._getLoader(data);
  4289. return _this._loader.importMeshAsync(meshesNames, scene, false, data, rootUrl, onProgress, fileName);
  4290. });
  4291. };
  4292. /** @hidden */
  4293. GLTFFileLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fileName) {
  4294. var _this = this;
  4295. return Promise.resolve().then(function () {
  4296. _this.onParsedObservable.notifyObservers(data);
  4297. _this.onParsedObservable.clear();
  4298. _this._log("Loading " + (fileName || ""));
  4299. _this._loader = _this._getLoader(data);
  4300. return _this._loader.loadAsync(scene, data, rootUrl, onProgress, fileName);
  4301. });
  4302. };
  4303. /** @hidden */
  4304. GLTFFileLoader.prototype.loadAssetContainerAsync = function (scene, data, rootUrl, onProgress, fileName) {
  4305. var _this = this;
  4306. return Promise.resolve().then(function () {
  4307. _this.onParsedObservable.notifyObservers(data);
  4308. _this.onParsedObservable.clear();
  4309. _this._log("Loading " + (fileName || ""));
  4310. _this._loader = _this._getLoader(data);
  4311. // Get materials/textures when loading to add to container
  4312. var materials = [];
  4313. _this.onMaterialLoadedObservable.add(function (material) {
  4314. materials.push(material);
  4315. });
  4316. var textures = [];
  4317. _this.onTextureLoadedObservable.add(function (texture) {
  4318. textures.push(texture);
  4319. });
  4320. return _this._loader.importMeshAsync(null, scene, true, data, rootUrl, onProgress, fileName).then(function (result) {
  4321. var container = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AssetContainer"](scene);
  4322. Array.prototype.push.apply(container.meshes, result.meshes);
  4323. Array.prototype.push.apply(container.particleSystems, result.particleSystems);
  4324. Array.prototype.push.apply(container.skeletons, result.skeletons);
  4325. Array.prototype.push.apply(container.animationGroups, result.animationGroups);
  4326. Array.prototype.push.apply(container.materials, materials);
  4327. Array.prototype.push.apply(container.textures, textures);
  4328. Array.prototype.push.apply(container.lights, result.lights);
  4329. Array.prototype.push.apply(container.transformNodes, result.transformNodes);
  4330. return container;
  4331. });
  4332. });
  4333. };
  4334. /** @hidden */
  4335. GLTFFileLoader.prototype.canDirectLoad = function (data) {
  4336. return data.indexOf("asset") !== -1 && data.indexOf("version") !== -1;
  4337. };
  4338. /** @hidden */
  4339. GLTFFileLoader.prototype.directLoad = function (scene, data) {
  4340. this._validate(scene, data);
  4341. return { json: this._parseJson(data) };
  4342. };
  4343. /** @hidden */
  4344. GLTFFileLoader.prototype.createPlugin = function () {
  4345. return new GLTFFileLoader();
  4346. };
  4347. Object.defineProperty(GLTFFileLoader.prototype, "loaderState", {
  4348. /**
  4349. * The loader state or null if the loader is not active.
  4350. */
  4351. get: function () {
  4352. return this._loader ? this._loader.state : null;
  4353. },
  4354. enumerable: true,
  4355. configurable: true
  4356. });
  4357. /**
  4358. * Returns a promise that resolves when the asset is completely loaded.
  4359. * @returns a promise that resolves when the asset is completely loaded.
  4360. */
  4361. GLTFFileLoader.prototype.whenCompleteAsync = function () {
  4362. var _this = this;
  4363. return new Promise(function (resolve, reject) {
  4364. _this.onCompleteObservable.addOnce(function () {
  4365. resolve();
  4366. });
  4367. _this.onErrorObservable.addOnce(function (reason) {
  4368. reject(reason);
  4369. });
  4370. });
  4371. };
  4372. GLTFFileLoader.prototype._validate = function (scene, data, rootUrl, fileName) {
  4373. var _this = this;
  4374. if (rootUrl === void 0) { rootUrl = ""; }
  4375. if (fileName === void 0) { fileName = ""; }
  4376. if (!this.validate) {
  4377. return;
  4378. }
  4379. this._startPerformanceCounter("Validate JSON");
  4380. _glTFValidation__WEBPACK_IMPORTED_MODULE_1__["GLTFValidation"].ValidateAsync(data, rootUrl, fileName, function (uri) {
  4381. return _this.preprocessUrlAsync(rootUrl + uri).then(function (url) { return scene._loadFileAsync(url, undefined, true, true); });
  4382. }).then(function (result) {
  4383. _this._endPerformanceCounter("Validate JSON");
  4384. _this.onValidatedObservable.notifyObservers(result);
  4385. _this.onValidatedObservable.clear();
  4386. }, function (reason) {
  4387. _this._endPerformanceCounter("Validate JSON");
  4388. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Warn("Failed to validate: " + reason.message);
  4389. _this.onValidatedObservable.clear();
  4390. });
  4391. };
  4392. GLTFFileLoader.prototype._getLoader = function (loaderData) {
  4393. var asset = loaderData.json.asset || {};
  4394. this._log("Asset version: " + asset.version);
  4395. asset.minVersion && this._log("Asset minimum version: " + asset.minVersion);
  4396. asset.generator && this._log("Asset generator: " + asset.generator);
  4397. var version = GLTFFileLoader._parseVersion(asset.version);
  4398. if (!version) {
  4399. throw new Error("Invalid version: " + asset.version);
  4400. }
  4401. if (asset.minVersion !== undefined) {
  4402. var minVersion = GLTFFileLoader._parseVersion(asset.minVersion);
  4403. if (!minVersion) {
  4404. throw new Error("Invalid minimum version: " + asset.minVersion);
  4405. }
  4406. if (GLTFFileLoader._compareVersion(minVersion, { major: 2, minor: 0 }) > 0) {
  4407. throw new Error("Incompatible minimum version: " + asset.minVersion);
  4408. }
  4409. }
  4410. var createLoaders = {
  4411. 1: GLTFFileLoader._CreateGLTF1Loader,
  4412. 2: GLTFFileLoader._CreateGLTF2Loader
  4413. };
  4414. var createLoader = createLoaders[version.major];
  4415. if (!createLoader) {
  4416. throw new Error("Unsupported version: " + asset.version);
  4417. }
  4418. return createLoader(this);
  4419. };
  4420. GLTFFileLoader.prototype._parseJson = function (json) {
  4421. this._startPerformanceCounter("Parse JSON");
  4422. this._log("JSON length: " + json.length);
  4423. var parsed = JSON.parse(json);
  4424. this._endPerformanceCounter("Parse JSON");
  4425. return parsed;
  4426. };
  4427. GLTFFileLoader.prototype._unpackBinaryAsync = function (dataReader) {
  4428. var _this = this;
  4429. this._startPerformanceCounter("Unpack Binary");
  4430. // Read magic + version + length + json length + json format
  4431. return dataReader.loadAsync(20).then(function () {
  4432. var Binary = {
  4433. Magic: 0x46546C67
  4434. };
  4435. var magic = dataReader.readUint32();
  4436. if (magic !== Binary.Magic) {
  4437. throw new Error("Unexpected magic: " + magic);
  4438. }
  4439. var version = dataReader.readUint32();
  4440. if (_this.loggingEnabled) {
  4441. _this._log("Binary version: " + version);
  4442. }
  4443. var length = dataReader.readUint32();
  4444. if (dataReader.buffer.byteLength != 0 && length !== dataReader.buffer.byteLength) {
  4445. throw new Error("Length in header does not match actual data length: " + length + " != " + dataReader.buffer.byteLength);
  4446. }
  4447. var unpacked;
  4448. switch (version) {
  4449. case 1: {
  4450. unpacked = _this._unpackBinaryV1Async(dataReader, length);
  4451. break;
  4452. }
  4453. case 2: {
  4454. unpacked = _this._unpackBinaryV2Async(dataReader, length);
  4455. break;
  4456. }
  4457. default: {
  4458. throw new Error("Unsupported version: " + version);
  4459. }
  4460. }
  4461. _this._endPerformanceCounter("Unpack Binary");
  4462. return unpacked;
  4463. });
  4464. };
  4465. GLTFFileLoader.prototype._unpackBinaryV1Async = function (dataReader, length) {
  4466. var ContentFormat = {
  4467. JSON: 0
  4468. };
  4469. var contentLength = dataReader.readUint32();
  4470. var contentFormat = dataReader.readUint32();
  4471. if (contentFormat !== ContentFormat.JSON) {
  4472. throw new Error("Unexpected content format: " + contentFormat);
  4473. }
  4474. var bodyLength = length - dataReader.byteOffset;
  4475. var data = { json: this._parseJson(dataReader.readString(contentLength)), bin: null };
  4476. if (bodyLength !== 0) {
  4477. var startByteOffset_1 = dataReader.byteOffset;
  4478. data.bin = {
  4479. readAsync: function (byteOffset, byteLength) { return dataReader.buffer.readAsync(startByteOffset_1 + byteOffset, byteLength); },
  4480. byteLength: bodyLength
  4481. };
  4482. }
  4483. return Promise.resolve(data);
  4484. };
  4485. GLTFFileLoader.prototype._unpackBinaryV2Async = function (dataReader, length) {
  4486. var _this = this;
  4487. var ChunkFormat = {
  4488. JSON: 0x4E4F534A,
  4489. BIN: 0x004E4942
  4490. };
  4491. // Read the JSON chunk header.
  4492. var chunkLength = dataReader.readUint32();
  4493. var chunkFormat = dataReader.readUint32();
  4494. if (chunkFormat !== ChunkFormat.JSON) {
  4495. throw new Error("First chunk format is not JSON");
  4496. }
  4497. // Bail if there are no other chunks.
  4498. if (dataReader.byteOffset + chunkLength === length) {
  4499. return dataReader.loadAsync(chunkLength).then(function () {
  4500. return { json: _this._parseJson(dataReader.readString(chunkLength)), bin: null };
  4501. });
  4502. }
  4503. // Read the JSON chunk and the length and type of the next chunk.
  4504. return dataReader.loadAsync(chunkLength + 8).then(function () {
  4505. var data = { json: _this._parseJson(dataReader.readString(chunkLength)), bin: null };
  4506. var readAsync = function () {
  4507. var chunkLength = dataReader.readUint32();
  4508. var chunkFormat = dataReader.readUint32();
  4509. switch (chunkFormat) {
  4510. case ChunkFormat.JSON: {
  4511. throw new Error("Unexpected JSON chunk");
  4512. }
  4513. case ChunkFormat.BIN: {
  4514. var startByteOffset_2 = dataReader.byteOffset;
  4515. data.bin = {
  4516. readAsync: function (byteOffset, byteLength) { return dataReader.buffer.readAsync(startByteOffset_2 + byteOffset, byteLength); },
  4517. byteLength: chunkLength
  4518. };
  4519. dataReader.skipBytes(chunkLength);
  4520. break;
  4521. }
  4522. default: {
  4523. // ignore unrecognized chunkFormat
  4524. dataReader.skipBytes(chunkLength);
  4525. break;
  4526. }
  4527. }
  4528. if (dataReader.byteOffset !== length) {
  4529. return dataReader.loadAsync(8).then(readAsync);
  4530. }
  4531. return Promise.resolve(data);
  4532. };
  4533. return readAsync();
  4534. });
  4535. };
  4536. GLTFFileLoader._parseVersion = function (version) {
  4537. if (version === "1.0" || version === "1.0.1") {
  4538. return {
  4539. major: 1,
  4540. minor: 0
  4541. };
  4542. }
  4543. var match = (version + "").match(/^(\d+)\.(\d+)/);
  4544. if (!match) {
  4545. return null;
  4546. }
  4547. return {
  4548. major: parseInt(match[1]),
  4549. minor: parseInt(match[2])
  4550. };
  4551. };
  4552. GLTFFileLoader._compareVersion = function (a, b) {
  4553. if (a.major > b.major) {
  4554. return 1;
  4555. }
  4556. if (a.major < b.major) {
  4557. return -1;
  4558. }
  4559. if (a.minor > b.minor) {
  4560. return 1;
  4561. }
  4562. if (a.minor < b.minor) {
  4563. return -1;
  4564. }
  4565. return 0;
  4566. };
  4567. /** @hidden */
  4568. GLTFFileLoader.prototype._logOpen = function (message) {
  4569. this._log(message);
  4570. this._logIndentLevel++;
  4571. };
  4572. /** @hidden */
  4573. GLTFFileLoader.prototype._logClose = function () {
  4574. --this._logIndentLevel;
  4575. };
  4576. GLTFFileLoader.prototype._logEnabled = function (message) {
  4577. var spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2);
  4578. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log("" + spaces + message);
  4579. };
  4580. GLTFFileLoader.prototype._logDisabled = function (message) {
  4581. };
  4582. GLTFFileLoader.prototype._startPerformanceCounterEnabled = function (counterName) {
  4583. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter(counterName);
  4584. };
  4585. GLTFFileLoader.prototype._startPerformanceCounterDisabled = function (counterName) {
  4586. };
  4587. GLTFFileLoader.prototype._endPerformanceCounterEnabled = function (counterName) {
  4588. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter(counterName);
  4589. };
  4590. GLTFFileLoader.prototype._endPerformanceCounterDisabled = function (counterName) {
  4591. };
  4592. // ----------
  4593. // V1 options
  4594. // ----------
  4595. /**
  4596. * 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.
  4597. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  4598. * Defaults to true.
  4599. * @hidden
  4600. */
  4601. GLTFFileLoader.IncrementalLoading = true;
  4602. /**
  4603. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  4604. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  4605. * @hidden
  4606. */
  4607. GLTFFileLoader.HomogeneousCoordinates = false;
  4608. GLTFFileLoader._logSpaces = " ";
  4609. return GLTFFileLoader;
  4610. }());
  4611. if (babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"]) {
  4612. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].RegisterPlugin(new GLTFFileLoader());
  4613. }
  4614. /***/ }),
  4615. /***/ "./glTF/glTFValidation.ts":
  4616. /*!********************************!*\
  4617. !*** ./glTF/glTFValidation.ts ***!
  4618. \********************************/
  4619. /*! exports provided: GLTFValidation */
  4620. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4621. "use strict";
  4622. __webpack_require__.r(__webpack_exports__);
  4623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GLTFValidation", function() { return GLTFValidation; });
  4624. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  4625. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__);
  4626. function validateAsync(data, rootUrl, fileName, getExternalResource) {
  4627. var options = {
  4628. externalResourceFunction: function (uri) { return getExternalResource(uri).then(function (value) { return new Uint8Array(value); }); }
  4629. };
  4630. if (fileName) {
  4631. options.uri = (rootUrl === "file:" ? fileName : rootUrl + fileName);
  4632. }
  4633. return (data instanceof ArrayBuffer)
  4634. ? GLTFValidator.validateBytes(new Uint8Array(data), options)
  4635. : GLTFValidator.validateString(data, options);
  4636. }
  4637. /**
  4638. * The worker function that gets converted to a blob url to pass into a worker.
  4639. */
  4640. function workerFunc() {
  4641. var pendingExternalResources = [];
  4642. onmessage = function (message) {
  4643. var data = message.data;
  4644. switch (data.id) {
  4645. case "init": {
  4646. importScripts(data.url);
  4647. break;
  4648. }
  4649. case "validate": {
  4650. validateAsync(data.data, data.rootUrl, data.fileName, function (uri) { return new Promise(function (resolve, reject) {
  4651. var index = pendingExternalResources.length;
  4652. pendingExternalResources.push({ resolve: resolve, reject: reject });
  4653. postMessage({ id: "getExternalResource", index: index, uri: uri });
  4654. }); }).then(function (value) {
  4655. postMessage({ id: "validate.resolve", value: value });
  4656. }, function (reason) {
  4657. postMessage({ id: "validate.reject", reason: reason });
  4658. });
  4659. break;
  4660. }
  4661. case "getExternalResource.resolve": {
  4662. pendingExternalResources[data.index].resolve(data.value);
  4663. break;
  4664. }
  4665. case "getExternalResource.reject": {
  4666. pendingExternalResources[data.index].reject(data.reason);
  4667. break;
  4668. }
  4669. }
  4670. };
  4671. }
  4672. /**
  4673. * glTF validation
  4674. */
  4675. var GLTFValidation = /** @class */ (function () {
  4676. function GLTFValidation() {
  4677. }
  4678. /**
  4679. * Validate a glTF asset using the glTF-Validator.
  4680. * @param data The JSON of a glTF or the array buffer of a binary glTF
  4681. * @param rootUrl The root url for the glTF
  4682. * @param fileName The file name for the glTF
  4683. * @param getExternalResource The callback to get external resources for the glTF validator
  4684. * @returns A promise that resolves with the glTF validation results once complete
  4685. */
  4686. GLTFValidation.ValidateAsync = function (data, rootUrl, fileName, getExternalResource) {
  4687. var _this = this;
  4688. if (typeof Worker === "function") {
  4689. return new Promise(function (resolve, reject) {
  4690. var workerContent = validateAsync + "(" + workerFunc + ")()";
  4691. var workerBlobUrl = URL.createObjectURL(new Blob([workerContent], { type: "application/javascript" }));
  4692. var worker = new Worker(workerBlobUrl);
  4693. var onError = function (error) {
  4694. worker.removeEventListener("error", onError);
  4695. worker.removeEventListener("message", onMessage);
  4696. reject(error);
  4697. };
  4698. var onMessage = function (message) {
  4699. var data = message.data;
  4700. switch (data.id) {
  4701. case "getExternalResource": {
  4702. getExternalResource(data.uri).then(function (value) {
  4703. worker.postMessage({ id: "getExternalResource.resolve", index: data.index, value: value }, [value]);
  4704. }, function (reason) {
  4705. worker.postMessage({ id: "getExternalResource.reject", index: data.index, reason: reason });
  4706. });
  4707. break;
  4708. }
  4709. case "validate.resolve": {
  4710. worker.removeEventListener("error", onError);
  4711. worker.removeEventListener("message", onMessage);
  4712. resolve(data.value);
  4713. break;
  4714. }
  4715. case "validate.reject": {
  4716. worker.removeEventListener("error", onError);
  4717. worker.removeEventListener("message", onMessage);
  4718. reject(data.reason);
  4719. }
  4720. }
  4721. };
  4722. worker.addEventListener("error", onError);
  4723. worker.addEventListener("message", onMessage);
  4724. worker.postMessage({ id: "init", url: babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetAbsoluteUrl(_this.Configuration.url) });
  4725. worker.postMessage({ id: "validate", data: data, rootUrl: rootUrl, fileName: fileName });
  4726. });
  4727. }
  4728. else {
  4729. if (!this._LoadScriptPromise) {
  4730. this._LoadScriptPromise = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadScriptAsync(this.Configuration.url);
  4731. }
  4732. return this._LoadScriptPromise.then(function () {
  4733. return validateAsync(data, rootUrl, fileName, getExternalResource);
  4734. });
  4735. }
  4736. };
  4737. /**
  4738. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  4739. */
  4740. GLTFValidation.Configuration = {
  4741. url: "https://preview.babylonjs.com/gltf_validator.js"
  4742. };
  4743. return GLTFValidation;
  4744. }());
  4745. /***/ }),
  4746. /***/ "./legacy/legacy-glTF.ts":
  4747. /*!*******************************!*\
  4748. !*** ./legacy/legacy-glTF.ts ***!
  4749. \*******************************/
  4750. /*! exports provided: GLTFLoaderCoordinateSystemMode, GLTFLoaderAnimationStartMode, GLTFLoaderState, GLTFFileLoader, GLTFValidation */
  4751. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4752. "use strict";
  4753. __webpack_require__.r(__webpack_exports__);
  4754. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTF/glTFFileLoader */ "./glTF/glTFFileLoader.ts");
  4755. /* harmony import */ var _glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTF/glTFValidation */ "./glTF/glTFValidation.ts");
  4756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFLoaderCoordinateSystemMode", function() { return _glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__["GLTFLoaderCoordinateSystemMode"]; });
  4757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFLoaderAnimationStartMode", function() { return _glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__["GLTFLoaderAnimationStartMode"]; });
  4758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFLoaderState", function() { return _glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__["GLTFLoaderState"]; });
  4759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFFileLoader", function() { return _glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__["GLTFFileLoader"]; });
  4760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFValidation", function() { return _glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__["GLTFValidation"]; });
  4761. /**
  4762. * This is the entry point for the UMD module.
  4763. * The entry point for a future ESM package should be index.ts
  4764. */
  4765. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  4766. if (typeof globalObject !== "undefined") {
  4767. globalObject.BABYLON = globalObject.BABYLON || {};
  4768. for (var key in _glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__) {
  4769. globalObject.BABYLON[key] = _glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__[key];
  4770. }
  4771. for (var key in _glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__) {
  4772. globalObject.BABYLON[key] = _glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__[key];
  4773. }
  4774. }
  4775. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  4776. /***/ }),
  4777. /***/ "./legacy/legacy-glTF2.ts":
  4778. /*!********************************!*\
  4779. !*** ./legacy/legacy-glTF2.ts ***!
  4780. \********************************/
  4781. /*! exports provided: GLTF2 */
  4782. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4783. "use strict";
  4784. __webpack_require__.r(__webpack_exports__);
  4785. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _glTF_2_0_Extensions__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTF/2.0/Extensions */ "./glTF/2.0/Extensions/index.ts");
  4786. /* harmony import */ var _glTF_2_0_glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTF/2.0/glTFLoaderInterfaces */ "./glTF/2.0/glTFLoaderInterfaces.ts");
  4787. /* harmony import */ var _glTF_2_0_glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_glTF_2_0_glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_1__);
  4788. /* harmony import */ var _glTF_2_0__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../glTF/2.0 */ "./glTF/2.0/index.ts");
  4789. /* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "GLTF2", function() { return _glTF_2_0__WEBPACK_IMPORTED_MODULE_2__; });
  4790. /**
  4791. * This is the entry point for the UMD module.
  4792. * The entry point for a future ESM package should be index.ts
  4793. */
  4794. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  4795. if (typeof globalObject !== "undefined") {
  4796. globalObject.BABYLON = globalObject.BABYLON || {};
  4797. var BABYLON = globalObject.BABYLON;
  4798. BABYLON.GLTF2 = BABYLON.GLTF2 || {};
  4799. BABYLON.GLTF2.Loader = BABYLON.GLTF2.Loader || {};
  4800. BABYLON.GLTF2.Loader.Extensions = BABYLON.GLTF2.Loader.Extensions || {};
  4801. var keys = [];
  4802. for (var key in _glTF_2_0_Extensions__WEBPACK_IMPORTED_MODULE_0__) {
  4803. BABYLON.GLTF2.Loader.Extensions[key] = _glTF_2_0_Extensions__WEBPACK_IMPORTED_MODULE_0__[key];
  4804. keys.push(key);
  4805. }
  4806. for (var key in _glTF_2_0_glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_1__) {
  4807. BABYLON.GLTF2.Loader[key] = _glTF_2_0_glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_1__[key];
  4808. keys.push(key);
  4809. }
  4810. for (var key in _glTF_2_0__WEBPACK_IMPORTED_MODULE_2__) {
  4811. // Prevent Reassignment.
  4812. if (keys.indexOf(key) > -1) {
  4813. continue;
  4814. }
  4815. BABYLON.GLTF2[key] = _glTF_2_0__WEBPACK_IMPORTED_MODULE_2__[key];
  4816. }
  4817. }
  4818. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  4819. /***/ }),
  4820. /***/ "./legacy/legacy-glTF2FileLoader.ts":
  4821. /*!******************************************!*\
  4822. !*** ./legacy/legacy-glTF2FileLoader.ts ***!
  4823. \******************************************/
  4824. /*! exports provided: GLTF2, GLTFLoaderCoordinateSystemMode, GLTFLoaderAnimationStartMode, GLTFLoaderState, GLTFFileLoader, GLTFValidation */
  4825. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4826. "use strict";
  4827. __webpack_require__.r(__webpack_exports__);
  4828. /* harmony import */ var _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./legacy-glTF */ "./legacy/legacy-glTF.ts");
  4829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFLoaderCoordinateSystemMode", function() { return _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__["GLTFLoaderCoordinateSystemMode"]; });
  4830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFLoaderAnimationStartMode", function() { return _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__["GLTFLoaderAnimationStartMode"]; });
  4831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFLoaderState", function() { return _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__["GLTFLoaderState"]; });
  4832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFFileLoader", function() { return _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__["GLTFFileLoader"]; });
  4833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFValidation", function() { return _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__["GLTFValidation"]; });
  4834. /* harmony import */ var _legacy_glTF2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./legacy-glTF2 */ "./legacy/legacy-glTF2.ts");
  4835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTF2", function() { return _legacy_glTF2__WEBPACK_IMPORTED_MODULE_1__["GLTF2"]; });
  4836. /***/ }),
  4837. /***/ "babylonjs/Misc/tools":
  4838. /*!****************************************************************************************************!*\
  4839. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  4840. \****************************************************************************************************/
  4841. /*! no static exports found */
  4842. /***/ (function(module, exports) {
  4843. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_tools__;
  4844. /***/ })
  4845. /******/ });
  4846. });
  4847. //# sourceMappingURL=babylon.glTF2FileLoader.js.map