babylon.glTF1FileLoader.js 185 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888
  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-glTF1FileLoader.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../../node_modules/tslib/tslib.es6.js":
  99. /*!***********************************************************!*\
  100. !*** D:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  101. \***********************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __createBinding, __exportStar, __values, __read, __spread, __spreadArrays, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault, __classPrivateFieldGet, __classPrivateFieldSet */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__createBinding", function() { return __createBinding; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldGet", function() { return __classPrivateFieldGet; });
  128. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldSet", function() { return __classPrivateFieldSet; });
  129. /*! *****************************************************************************
  130. Copyright (c) Microsoft Corporation.
  131. Permission to use, copy, modify, and/or distribute this software for any
  132. purpose with or without fee is hereby granted.
  133. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  134. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  135. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  136. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  137. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  138. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  139. PERFORMANCE OF THIS SOFTWARE.
  140. ***************************************************************************** */
  141. /* global Reflect, Promise */
  142. var extendStatics = function(d, b) {
  143. extendStatics = Object.setPrototypeOf ||
  144. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  145. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  146. return extendStatics(d, b);
  147. };
  148. function __extends(d, b) {
  149. extendStatics(d, b);
  150. function __() { this.constructor = d; }
  151. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  152. }
  153. var __assign = function() {
  154. __assign = Object.assign || function __assign(t) {
  155. for (var s, i = 1, n = arguments.length; i < n; i++) {
  156. s = arguments[i];
  157. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  158. }
  159. return t;
  160. }
  161. return __assign.apply(this, arguments);
  162. }
  163. function __rest(s, e) {
  164. var t = {};
  165. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  166. t[p] = s[p];
  167. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  168. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  169. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  170. t[p[i]] = s[p[i]];
  171. }
  172. return t;
  173. }
  174. function __decorate(decorators, target, key, desc) {
  175. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  176. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  177. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  178. return c > 3 && r && Object.defineProperty(target, key, r), r;
  179. }
  180. function __param(paramIndex, decorator) {
  181. return function (target, key) { decorator(target, key, paramIndex); }
  182. }
  183. function __metadata(metadataKey, metadataValue) {
  184. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  185. }
  186. function __awaiter(thisArg, _arguments, P, generator) {
  187. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  188. return new (P || (P = Promise))(function (resolve, reject) {
  189. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  190. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  191. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  192. step((generator = generator.apply(thisArg, _arguments || [])).next());
  193. });
  194. }
  195. function __generator(thisArg, body) {
  196. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  197. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  198. function verb(n) { return function (v) { return step([n, v]); }; }
  199. function step(op) {
  200. if (f) throw new TypeError("Generator is already executing.");
  201. while (_) try {
  202. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  203. if (y = 0, t) op = [op[0] & 2, t.value];
  204. switch (op[0]) {
  205. case 0: case 1: t = op; break;
  206. case 4: _.label++; return { value: op[1], done: false };
  207. case 5: _.label++; y = op[1]; op = [0]; continue;
  208. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  209. default:
  210. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  211. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  212. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  213. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  214. if (t[2]) _.ops.pop();
  215. _.trys.pop(); continue;
  216. }
  217. op = body.call(thisArg, _);
  218. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  219. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  220. }
  221. }
  222. var __createBinding = Object.create ? (function(o, m, k, k2) {
  223. if (k2 === undefined) k2 = k;
  224. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  225. }) : (function(o, m, k, k2) {
  226. if (k2 === undefined) k2 = k;
  227. o[k2] = m[k];
  228. });
  229. function __exportStar(m, exports) {
  230. for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
  231. }
  232. function __values(o) {
  233. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  234. if (m) return m.call(o);
  235. if (o && typeof o.length === "number") return {
  236. next: function () {
  237. if (o && i >= o.length) o = void 0;
  238. return { value: o && o[i++], done: !o };
  239. }
  240. };
  241. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  242. }
  243. function __read(o, n) {
  244. var m = typeof Symbol === "function" && o[Symbol.iterator];
  245. if (!m) return o;
  246. var i = m.call(o), r, ar = [], e;
  247. try {
  248. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  249. }
  250. catch (error) { e = { error: error }; }
  251. finally {
  252. try {
  253. if (r && !r.done && (m = i["return"])) m.call(i);
  254. }
  255. finally { if (e) throw e.error; }
  256. }
  257. return ar;
  258. }
  259. function __spread() {
  260. for (var ar = [], i = 0; i < arguments.length; i++)
  261. ar = ar.concat(__read(arguments[i]));
  262. return ar;
  263. }
  264. function __spreadArrays() {
  265. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  266. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  267. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  268. r[k] = a[j];
  269. return r;
  270. };
  271. function __await(v) {
  272. return this instanceof __await ? (this.v = v, this) : new __await(v);
  273. }
  274. function __asyncGenerator(thisArg, _arguments, generator) {
  275. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  276. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  277. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  278. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  279. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  280. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  281. function fulfill(value) { resume("next", value); }
  282. function reject(value) { resume("throw", value); }
  283. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  284. }
  285. function __asyncDelegator(o) {
  286. var i, p;
  287. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  288. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  289. }
  290. function __asyncValues(o) {
  291. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  292. var m = o[Symbol.asyncIterator], i;
  293. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  294. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  295. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  296. }
  297. function __makeTemplateObject(cooked, raw) {
  298. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  299. return cooked;
  300. };
  301. var __setModuleDefault = Object.create ? (function(o, v) {
  302. Object.defineProperty(o, "default", { enumerable: true, value: v });
  303. }) : function(o, v) {
  304. o["default"] = v;
  305. };
  306. function __importStar(mod) {
  307. if (mod && mod.__esModule) return mod;
  308. var result = {};
  309. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  310. __setModuleDefault(result, mod);
  311. return result;
  312. }
  313. function __importDefault(mod) {
  314. return (mod && mod.__esModule) ? mod : { default: mod };
  315. }
  316. function __classPrivateFieldGet(receiver, privateMap) {
  317. if (!privateMap.has(receiver)) {
  318. throw new TypeError("attempted to get private field on non-instance");
  319. }
  320. return privateMap.get(receiver);
  321. }
  322. function __classPrivateFieldSet(receiver, privateMap, value) {
  323. if (!privateMap.has(receiver)) {
  324. throw new TypeError("attempted to set private field on non-instance");
  325. }
  326. privateMap.set(receiver, value);
  327. return value;
  328. }
  329. /***/ }),
  330. /***/ "../../node_modules/webpack/buildin/global.js":
  331. /*!***********************************!*\
  332. !*** (webpack)/buildin/global.js ***!
  333. \***********************************/
  334. /*! no static exports found */
  335. /***/ (function(module, exports) {
  336. var g;
  337. // This works in non-strict mode
  338. g = (function() {
  339. return this;
  340. })();
  341. try {
  342. // This works if eval is allowed (see CSP)
  343. g = g || new Function("return this")();
  344. } catch (e) {
  345. // This works if the window reference is available
  346. if (typeof window === "object") g = window;
  347. }
  348. // g can still be undefined, but nothing to do about it...
  349. // We return undefined, instead of nothing here, so it's
  350. // easier to handle this case. if(!global) { ...}
  351. module.exports = g;
  352. /***/ }),
  353. /***/ "./glTF/1.0/glTFBinaryExtension.ts":
  354. /*!*****************************************!*\
  355. !*** ./glTF/1.0/glTFBinaryExtension.ts ***!
  356. \*****************************************/
  357. /*! exports provided: GLTFBinaryExtension */
  358. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  359. "use strict";
  360. __webpack_require__.r(__webpack_exports__);
  361. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GLTFBinaryExtension", function() { return GLTFBinaryExtension; });
  362. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  363. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFLoader */ "./glTF/1.0/glTFLoader.ts");
  364. /* harmony import */ var _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFLoaderUtils */ "./glTF/1.0/glTFLoaderUtils.ts");
  365. /* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "./glTF/1.0/glTFLoaderInterfaces.ts");
  366. var BinaryExtensionBufferName = "binary_glTF";
  367. /** @hidden */
  368. var GLTFBinaryExtension = /** @class */ (function (_super) {
  369. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(GLTFBinaryExtension, _super);
  370. function GLTFBinaryExtension() {
  371. return _super.call(this, "KHR_binary_glTF") || this;
  372. }
  373. GLTFBinaryExtension.prototype.loadRuntimeAsync = function (scene, data, rootUrl, onSuccess, onError) {
  374. var extensionsUsed = data.json.extensionsUsed;
  375. if (!extensionsUsed || extensionsUsed.indexOf(this.name) === -1 || !data.bin) {
  376. return false;
  377. }
  378. this._bin = data.bin;
  379. onSuccess(_glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderBase"].CreateRuntime(data.json, scene, rootUrl));
  380. return true;
  381. };
  382. GLTFBinaryExtension.prototype.loadBufferAsync = function (gltfRuntime, id, onSuccess, onError) {
  383. if (gltfRuntime.extensionsUsed.indexOf(this.name) === -1) {
  384. return false;
  385. }
  386. if (id !== BinaryExtensionBufferName) {
  387. return false;
  388. }
  389. this._bin.readAsync(0, this._bin.byteLength).then(onSuccess, function (error) { return onError(error.message); });
  390. return true;
  391. };
  392. GLTFBinaryExtension.prototype.loadTextureBufferAsync = function (gltfRuntime, id, onSuccess, onError) {
  393. var texture = gltfRuntime.textures[id];
  394. var source = gltfRuntime.images[texture.source];
  395. if (!source.extensions || !(this.name in source.extensions)) {
  396. return false;
  397. }
  398. var sourceExt = source.extensions[this.name];
  399. var bufferView = gltfRuntime.bufferViews[sourceExt.bufferView];
  400. var buffer = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__["GLTFUtils"].GetBufferFromBufferView(gltfRuntime, bufferView, 0, bufferView.byteLength, _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_3__["EComponentType"].UNSIGNED_BYTE);
  401. onSuccess(buffer);
  402. return true;
  403. };
  404. GLTFBinaryExtension.prototype.loadShaderStringAsync = function (gltfRuntime, id, onSuccess, onError) {
  405. var shader = gltfRuntime.shaders[id];
  406. if (!shader.extensions || !(this.name in shader.extensions)) {
  407. return false;
  408. }
  409. var binaryExtensionShader = shader.extensions[this.name];
  410. var bufferView = gltfRuntime.bufferViews[binaryExtensionShader.bufferView];
  411. var shaderBytes = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__["GLTFUtils"].GetBufferFromBufferView(gltfRuntime, bufferView, 0, bufferView.byteLength, _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_3__["EComponentType"].UNSIGNED_BYTE);
  412. setTimeout(function () {
  413. var shaderString = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__["GLTFUtils"].DecodeBufferToText(shaderBytes);
  414. onSuccess(shaderString);
  415. });
  416. return true;
  417. };
  418. return GLTFBinaryExtension;
  419. }(_glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderExtension"]));
  420. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].RegisterExtension(new GLTFBinaryExtension());
  421. /***/ }),
  422. /***/ "./glTF/1.0/glTFLoader.ts":
  423. /*!********************************!*\
  424. !*** ./glTF/1.0/glTFLoader.ts ***!
  425. \********************************/
  426. /*! exports provided: GLTFLoaderBase, GLTFLoader, GLTFLoaderExtension */
  427. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  428. "use strict";
  429. __webpack_require__.r(__webpack_exports__);
  430. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GLTFLoaderBase", function() { return GLTFLoaderBase; });
  431. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GLTFLoader", function() { return GLTFLoader; });
  432. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GLTFLoaderExtension", function() { return GLTFLoaderExtension; });
  433. /* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "./glTF/1.0/glTFLoaderInterfaces.ts");
  434. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/tools");
  435. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  436. /* harmony import */ var _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFLoaderUtils */ "./glTF/1.0/glTFLoaderUtils.ts");
  437. /* harmony import */ var _glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../glTFFileLoader */ "./glTF/glTFFileLoader.ts");
  438. /**
  439. * Tokenizer. Used for shaders compatibility
  440. * Automatically map world, view, projection, worldViewProjection, attributes and so on
  441. */
  442. var ETokenType;
  443. (function (ETokenType) {
  444. ETokenType[ETokenType["IDENTIFIER"] = 1] = "IDENTIFIER";
  445. ETokenType[ETokenType["UNKNOWN"] = 2] = "UNKNOWN";
  446. ETokenType[ETokenType["END_OF_INPUT"] = 3] = "END_OF_INPUT";
  447. })(ETokenType || (ETokenType = {}));
  448. var Tokenizer = /** @class */ (function () {
  449. function Tokenizer(toParse) {
  450. this._pos = 0;
  451. this.currentToken = ETokenType.UNKNOWN;
  452. this.currentIdentifier = "";
  453. this.currentString = "";
  454. this.isLetterOrDigitPattern = /^[a-zA-Z0-9]+$/;
  455. this._toParse = toParse;
  456. this._maxPos = toParse.length;
  457. }
  458. Tokenizer.prototype.getNextToken = function () {
  459. if (this.isEnd()) {
  460. return ETokenType.END_OF_INPUT;
  461. }
  462. this.currentString = this.read();
  463. this.currentToken = ETokenType.UNKNOWN;
  464. if (this.currentString === "_" || this.isLetterOrDigitPattern.test(this.currentString)) {
  465. this.currentToken = ETokenType.IDENTIFIER;
  466. this.currentIdentifier = this.currentString;
  467. while (!this.isEnd() && (this.isLetterOrDigitPattern.test(this.currentString = this.peek()) || this.currentString === "_")) {
  468. this.currentIdentifier += this.currentString;
  469. this.forward();
  470. }
  471. }
  472. return this.currentToken;
  473. };
  474. Tokenizer.prototype.peek = function () {
  475. return this._toParse[this._pos];
  476. };
  477. Tokenizer.prototype.read = function () {
  478. return this._toParse[this._pos++];
  479. };
  480. Tokenizer.prototype.forward = function () {
  481. this._pos++;
  482. };
  483. Tokenizer.prototype.isEnd = function () {
  484. return this._pos >= this._maxPos;
  485. };
  486. return Tokenizer;
  487. }());
  488. /**
  489. * Values
  490. */
  491. var glTFTransforms = ["MODEL", "VIEW", "PROJECTION", "MODELVIEW", "MODELVIEWPROJECTION", "JOINTMATRIX"];
  492. var babylonTransforms = ["world", "view", "projection", "worldView", "worldViewProjection", "mBones"];
  493. var glTFAnimationPaths = ["translation", "rotation", "scale"];
  494. var babylonAnimationPaths = ["position", "rotationQuaternion", "scaling"];
  495. /**
  496. * Parse
  497. */
  498. var parseBuffers = function (parsedBuffers, gltfRuntime) {
  499. for (var buf in parsedBuffers) {
  500. var parsedBuffer = parsedBuffers[buf];
  501. gltfRuntime.buffers[buf] = parsedBuffer;
  502. gltfRuntime.buffersCount++;
  503. }
  504. };
  505. var parseShaders = function (parsedShaders, gltfRuntime) {
  506. for (var sha in parsedShaders) {
  507. var parsedShader = parsedShaders[sha];
  508. gltfRuntime.shaders[sha] = parsedShader;
  509. gltfRuntime.shaderscount++;
  510. }
  511. };
  512. var parseObject = function (parsedObjects, runtimeProperty, gltfRuntime) {
  513. for (var object in parsedObjects) {
  514. var parsedObject = parsedObjects[object];
  515. gltfRuntime[runtimeProperty][object] = parsedObject;
  516. }
  517. };
  518. /**
  519. * Utils
  520. */
  521. var normalizeUVs = function (buffer) {
  522. if (!buffer) {
  523. return;
  524. }
  525. for (var i = 0; i < buffer.length / 2; i++) {
  526. buffer[i * 2 + 1] = 1.0 - buffer[i * 2 + 1];
  527. }
  528. };
  529. var getAttribute = function (attributeParameter) {
  530. if (attributeParameter.semantic === "NORMAL") {
  531. return "normal";
  532. }
  533. else if (attributeParameter.semantic === "POSITION") {
  534. return "position";
  535. }
  536. else if (attributeParameter.semantic === "JOINT") {
  537. return "matricesIndices";
  538. }
  539. else if (attributeParameter.semantic === "WEIGHT") {
  540. return "matricesWeights";
  541. }
  542. else if (attributeParameter.semantic === "COLOR") {
  543. return "color";
  544. }
  545. else if (attributeParameter.semantic && attributeParameter.semantic.indexOf("TEXCOORD_") !== -1) {
  546. var channel = Number(attributeParameter.semantic.split("_")[1]);
  547. return "uv" + (channel === 0 ? "" : channel + 1);
  548. }
  549. return null;
  550. };
  551. /**
  552. * Loads and creates animations
  553. */
  554. var loadAnimations = function (gltfRuntime) {
  555. for (var anim in gltfRuntime.animations) {
  556. var animation = gltfRuntime.animations[anim];
  557. if (!animation.channels || !animation.samplers) {
  558. continue;
  559. }
  560. var lastAnimation = null;
  561. for (var i = 0; i < animation.channels.length; i++) {
  562. // Get parameters and load buffers
  563. var channel = animation.channels[i];
  564. var sampler = animation.samplers[channel.sampler];
  565. if (!sampler) {
  566. continue;
  567. }
  568. var inputData = null;
  569. var outputData = null;
  570. if (animation.parameters) {
  571. inputData = animation.parameters[sampler.input];
  572. outputData = animation.parameters[sampler.output];
  573. }
  574. else {
  575. inputData = sampler.input;
  576. outputData = sampler.output;
  577. }
  578. var bufferInput = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__["GLTFUtils"].GetBufferFromAccessor(gltfRuntime, gltfRuntime.accessors[inputData]);
  579. var bufferOutput = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__["GLTFUtils"].GetBufferFromAccessor(gltfRuntime, gltfRuntime.accessors[outputData]);
  580. var targetID = channel.target.id;
  581. var targetNode = gltfRuntime.scene.getNodeByID(targetID);
  582. if (targetNode === null) {
  583. targetNode = gltfRuntime.scene.getNodeByName(targetID);
  584. }
  585. if (targetNode === null) {
  586. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Tools"].Warn("Creating animation named " + anim + ". But cannot find node named " + targetID + " to attach to");
  587. continue;
  588. }
  589. var isBone = targetNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Bone"];
  590. // Get target path (position, rotation or scaling)
  591. var targetPath = channel.target.path;
  592. var targetPathIndex = glTFAnimationPaths.indexOf(targetPath);
  593. if (targetPathIndex !== -1) {
  594. targetPath = babylonAnimationPaths[targetPathIndex];
  595. }
  596. // Determine animation type
  597. var animationType = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_MATRIX;
  598. if (!isBone) {
  599. if (targetPath === "rotationQuaternion") {
  600. animationType = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION;
  601. targetNode.rotationQuaternion = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  602. }
  603. else {
  604. animationType = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3;
  605. }
  606. }
  607. // Create animation and key frames
  608. var babylonAnimation = null;
  609. var keys = [];
  610. var arrayOffset = 0;
  611. var modifyKey = false;
  612. if (isBone && lastAnimation && lastAnimation.getKeys().length === bufferInput.length) {
  613. babylonAnimation = lastAnimation;
  614. modifyKey = true;
  615. }
  616. if (!modifyKey) {
  617. gltfRuntime.scene._blockEntityCollection = gltfRuntime.forAssetContainer;
  618. babylonAnimation = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Animation"](anim, isBone ? "_matrix" : targetPath, 1, animationType, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  619. gltfRuntime.scene._blockEntityCollection = false;
  620. }
  621. // For each frame
  622. for (var j = 0; j < bufferInput.length; j++) {
  623. var value = null;
  624. if (targetPath === "rotationQuaternion") { // VEC4
  625. value = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromArray([bufferOutput[arrayOffset], bufferOutput[arrayOffset + 1], bufferOutput[arrayOffset + 2], bufferOutput[arrayOffset + 3]]);
  626. arrayOffset += 4;
  627. }
  628. else { // Position and scaling are VEC3
  629. value = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray([bufferOutput[arrayOffset], bufferOutput[arrayOffset + 1], bufferOutput[arrayOffset + 2]]);
  630. arrayOffset += 3;
  631. }
  632. if (isBone) {
  633. var bone = targetNode;
  634. var translation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  635. var rotationQuaternion = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  636. var scaling = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  637. // Warning on decompose
  638. var mat = bone.getBaseMatrix();
  639. if (modifyKey && lastAnimation) {
  640. mat = lastAnimation.getKeys()[j].value;
  641. }
  642. mat.decompose(scaling, rotationQuaternion, translation);
  643. if (targetPath === "position") {
  644. translation = value;
  645. }
  646. else if (targetPath === "rotationQuaternion") {
  647. rotationQuaternion = value;
  648. }
  649. else {
  650. scaling = value;
  651. }
  652. value = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Compose(scaling, rotationQuaternion, translation);
  653. }
  654. if (!modifyKey) {
  655. keys.push({
  656. frame: bufferInput[j],
  657. value: value
  658. });
  659. }
  660. else if (lastAnimation) {
  661. lastAnimation.getKeys()[j].value = value;
  662. }
  663. }
  664. // Finish
  665. if (!modifyKey && babylonAnimation) {
  666. babylonAnimation.setKeys(keys);
  667. targetNode.animations.push(babylonAnimation);
  668. }
  669. lastAnimation = babylonAnimation;
  670. gltfRuntime.scene.stopAnimation(targetNode);
  671. gltfRuntime.scene.beginAnimation(targetNode, 0, bufferInput[bufferInput.length - 1], true, 1.0);
  672. }
  673. }
  674. };
  675. /**
  676. * Returns the bones transformation matrix
  677. */
  678. var configureBoneTransformation = function (node) {
  679. var mat = null;
  680. if (node.translation || node.rotation || node.scale) {
  681. var scale = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(node.scale || [1, 1, 1]);
  682. var rotation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromArray(node.rotation || [0, 0, 0, 1]);
  683. var position = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(node.translation || [0, 0, 0]);
  684. mat = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Compose(scale, rotation, position);
  685. }
  686. else {
  687. mat = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromArray(node.matrix);
  688. }
  689. return mat;
  690. };
  691. /**
  692. * Returns the parent bone
  693. */
  694. var getParentBone = function (gltfRuntime, skins, jointName, newSkeleton) {
  695. // Try to find
  696. for (var i = 0; i < newSkeleton.bones.length; i++) {
  697. if (newSkeleton.bones[i].name === jointName) {
  698. return newSkeleton.bones[i];
  699. }
  700. }
  701. // Not found, search in gltf nodes
  702. var nodes = gltfRuntime.nodes;
  703. for (var nde in nodes) {
  704. var node = nodes[nde];
  705. if (!node.jointName) {
  706. continue;
  707. }
  708. var children = node.children;
  709. for (var i = 0; i < children.length; i++) {
  710. var child = gltfRuntime.nodes[children[i]];
  711. if (!child.jointName) {
  712. continue;
  713. }
  714. if (child.jointName === jointName) {
  715. var mat = configureBoneTransformation(node);
  716. var bone = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Bone"](node.name || "", newSkeleton, getParentBone(gltfRuntime, skins, node.jointName, newSkeleton), mat);
  717. bone.id = nde;
  718. return bone;
  719. }
  720. }
  721. }
  722. return null;
  723. };
  724. /**
  725. * Returns the appropriate root node
  726. */
  727. var getNodeToRoot = function (nodesToRoot, id) {
  728. for (var i = 0; i < nodesToRoot.length; i++) {
  729. var nodeToRoot = nodesToRoot[i];
  730. for (var j = 0; j < nodeToRoot.node.children.length; j++) {
  731. var child = nodeToRoot.node.children[j];
  732. if (child === id) {
  733. return nodeToRoot.bone;
  734. }
  735. }
  736. }
  737. return null;
  738. };
  739. /**
  740. * Returns the node with the joint name
  741. */
  742. var getJointNode = function (gltfRuntime, jointName) {
  743. var nodes = gltfRuntime.nodes;
  744. var node = nodes[jointName];
  745. if (node) {
  746. return {
  747. node: node,
  748. id: jointName
  749. };
  750. }
  751. for (var nde in nodes) {
  752. node = nodes[nde];
  753. if (node.jointName === jointName) {
  754. return {
  755. node: node,
  756. id: nde
  757. };
  758. }
  759. }
  760. return null;
  761. };
  762. /**
  763. * Checks if a nodes is in joints
  764. */
  765. var nodeIsInJoints = function (skins, id) {
  766. for (var i = 0; i < skins.jointNames.length; i++) {
  767. if (skins.jointNames[i] === id) {
  768. return true;
  769. }
  770. }
  771. return false;
  772. };
  773. /**
  774. * Fills the nodes to root for bones and builds hierarchy
  775. */
  776. var getNodesToRoot = function (gltfRuntime, newSkeleton, skins, nodesToRoot) {
  777. // Creates nodes for root
  778. for (var nde in gltfRuntime.nodes) {
  779. var node = gltfRuntime.nodes[nde];
  780. var id = nde;
  781. if (!node.jointName || nodeIsInJoints(skins, node.jointName)) {
  782. continue;
  783. }
  784. // Create node to root bone
  785. var mat = configureBoneTransformation(node);
  786. var bone = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Bone"](node.name || "", newSkeleton, null, mat);
  787. bone.id = id;
  788. nodesToRoot.push({ bone: bone, node: node, id: id });
  789. }
  790. // Parenting
  791. for (var i = 0; i < nodesToRoot.length; i++) {
  792. var nodeToRoot = nodesToRoot[i];
  793. var children = nodeToRoot.node.children;
  794. for (var j = 0; j < children.length; j++) {
  795. var child = null;
  796. for (var k = 0; k < nodesToRoot.length; k++) {
  797. if (nodesToRoot[k].id === children[j]) {
  798. child = nodesToRoot[k];
  799. break;
  800. }
  801. }
  802. if (child) {
  803. child.bone._parent = nodeToRoot.bone;
  804. nodeToRoot.bone.children.push(child.bone);
  805. }
  806. }
  807. }
  808. };
  809. /**
  810. * Imports a skeleton
  811. */
  812. var importSkeleton = function (gltfRuntime, skins, mesh, newSkeleton, id) {
  813. if (!newSkeleton) {
  814. newSkeleton = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Skeleton"](skins.name || "", "", gltfRuntime.scene);
  815. }
  816. if (!skins.babylonSkeleton) {
  817. return newSkeleton;
  818. }
  819. // Find the root bones
  820. var nodesToRoot = [];
  821. var nodesToRootToAdd = [];
  822. getNodesToRoot(gltfRuntime, newSkeleton, skins, nodesToRoot);
  823. newSkeleton.bones = [];
  824. // Joints
  825. for (var i = 0; i < skins.jointNames.length; i++) {
  826. var jointNode = getJointNode(gltfRuntime, skins.jointNames[i]);
  827. if (!jointNode) {
  828. continue;
  829. }
  830. var node = jointNode.node;
  831. if (!node) {
  832. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Tools"].Warn("Joint named " + skins.jointNames[i] + " does not exist");
  833. continue;
  834. }
  835. var id = jointNode.id;
  836. // Optimize, if the bone already exists...
  837. var existingBone = gltfRuntime.scene.getBoneByID(id);
  838. if (existingBone) {
  839. newSkeleton.bones.push(existingBone);
  840. continue;
  841. }
  842. // Search for parent bone
  843. var foundBone = false;
  844. var parentBone = null;
  845. for (var j = 0; j < i; j++) {
  846. var jointNode_1 = getJointNode(gltfRuntime, skins.jointNames[j]);
  847. if (!jointNode_1) {
  848. continue;
  849. }
  850. var joint = jointNode_1.node;
  851. if (!joint) {
  852. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Tools"].Warn("Joint named " + skins.jointNames[j] + " does not exist when looking for parent");
  853. continue;
  854. }
  855. var children = joint.children;
  856. if (!children) {
  857. continue;
  858. }
  859. foundBone = false;
  860. for (var k = 0; k < children.length; k++) {
  861. if (children[k] === id) {
  862. parentBone = getParentBone(gltfRuntime, skins, skins.jointNames[j], newSkeleton);
  863. foundBone = true;
  864. break;
  865. }
  866. }
  867. if (foundBone) {
  868. break;
  869. }
  870. }
  871. // Create bone
  872. var mat = configureBoneTransformation(node);
  873. if (!parentBone && nodesToRoot.length > 0) {
  874. parentBone = getNodeToRoot(nodesToRoot, id);
  875. if (parentBone) {
  876. if (nodesToRootToAdd.indexOf(parentBone) === -1) {
  877. nodesToRootToAdd.push(parentBone);
  878. }
  879. }
  880. }
  881. var bone = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Bone"](node.jointName || "", newSkeleton, parentBone, mat);
  882. bone.id = id;
  883. }
  884. // Polish
  885. var bones = newSkeleton.bones;
  886. newSkeleton.bones = [];
  887. for (var i = 0; i < skins.jointNames.length; i++) {
  888. var jointNode = getJointNode(gltfRuntime, skins.jointNames[i]);
  889. if (!jointNode) {
  890. continue;
  891. }
  892. for (var j = 0; j < bones.length; j++) {
  893. if (bones[j].id === jointNode.id) {
  894. newSkeleton.bones.push(bones[j]);
  895. break;
  896. }
  897. }
  898. }
  899. newSkeleton.prepare();
  900. // Finish
  901. for (var i = 0; i < nodesToRootToAdd.length; i++) {
  902. newSkeleton.bones.push(nodesToRootToAdd[i]);
  903. }
  904. return newSkeleton;
  905. };
  906. /**
  907. * Imports a mesh and its geometries
  908. */
  909. var importMesh = function (gltfRuntime, node, meshes, id, newMesh) {
  910. if (!newMesh) {
  911. gltfRuntime.scene._blockEntityCollection = gltfRuntime.forAssetContainer;
  912. newMesh = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Mesh"](node.name || "", gltfRuntime.scene);
  913. gltfRuntime.scene._blockEntityCollection = false;
  914. newMesh.id = id;
  915. }
  916. if (!node.babylonNode) {
  917. return newMesh;
  918. }
  919. var subMaterials = [];
  920. var vertexData = null;
  921. var verticesStarts = new Array();
  922. var verticesCounts = new Array();
  923. var indexStarts = new Array();
  924. var indexCounts = new Array();
  925. for (var meshIndex = 0; meshIndex < meshes.length; meshIndex++) {
  926. var meshID = meshes[meshIndex];
  927. var mesh = gltfRuntime.meshes[meshID];
  928. if (!mesh) {
  929. continue;
  930. }
  931. // Positions, normals and UVs
  932. for (var i = 0; i < mesh.primitives.length; i++) {
  933. // Temporary vertex data
  934. var tempVertexData = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  935. var primitive = mesh.primitives[i];
  936. if (primitive.mode !== 4) {
  937. // continue;
  938. }
  939. var attributes = primitive.attributes;
  940. var accessor = null;
  941. var buffer = null;
  942. // Set positions, normal and uvs
  943. for (var semantic in attributes) {
  944. // Link accessor and buffer view
  945. accessor = gltfRuntime.accessors[attributes[semantic]];
  946. buffer = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__["GLTFUtils"].GetBufferFromAccessor(gltfRuntime, accessor);
  947. if (semantic === "NORMAL") {
  948. tempVertexData.normals = new Float32Array(buffer.length);
  949. tempVertexData.normals.set(buffer);
  950. }
  951. else if (semantic === "POSITION") {
  952. if (_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__["GLTFFileLoader"].HomogeneousCoordinates) {
  953. tempVertexData.positions = new Float32Array(buffer.length - buffer.length / 4);
  954. for (var j = 0; j < buffer.length; j += 4) {
  955. tempVertexData.positions[j] = buffer[j];
  956. tempVertexData.positions[j + 1] = buffer[j + 1];
  957. tempVertexData.positions[j + 2] = buffer[j + 2];
  958. }
  959. }
  960. else {
  961. tempVertexData.positions = new Float32Array(buffer.length);
  962. tempVertexData.positions.set(buffer);
  963. }
  964. verticesCounts.push(tempVertexData.positions.length);
  965. }
  966. else if (semantic.indexOf("TEXCOORD_") !== -1) {
  967. var channel = Number(semantic.split("_")[1]);
  968. var uvKind = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind + (channel === 0 ? "" : (channel + 1));
  969. var uvs = new Float32Array(buffer.length);
  970. uvs.set(buffer);
  971. normalizeUVs(uvs);
  972. tempVertexData.set(uvs, uvKind);
  973. }
  974. else if (semantic === "JOINT") {
  975. tempVertexData.matricesIndices = new Float32Array(buffer.length);
  976. tempVertexData.matricesIndices.set(buffer);
  977. }
  978. else if (semantic === "WEIGHT") {
  979. tempVertexData.matricesWeights = new Float32Array(buffer.length);
  980. tempVertexData.matricesWeights.set(buffer);
  981. }
  982. else if (semantic === "COLOR") {
  983. tempVertexData.colors = new Float32Array(buffer.length);
  984. tempVertexData.colors.set(buffer);
  985. }
  986. }
  987. // Indices
  988. accessor = gltfRuntime.accessors[primitive.indices];
  989. if (accessor) {
  990. buffer = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__["GLTFUtils"].GetBufferFromAccessor(gltfRuntime, accessor);
  991. tempVertexData.indices = new Int32Array(buffer.length);
  992. tempVertexData.indices.set(buffer);
  993. indexCounts.push(tempVertexData.indices.length);
  994. }
  995. else {
  996. // Set indices on the fly
  997. var indices = [];
  998. for (var j = 0; j < tempVertexData.positions.length / 3; j++) {
  999. indices.push(j);
  1000. }
  1001. tempVertexData.indices = new Int32Array(indices);
  1002. indexCounts.push(tempVertexData.indices.length);
  1003. }
  1004. if (!vertexData) {
  1005. vertexData = tempVertexData;
  1006. }
  1007. else {
  1008. vertexData.merge(tempVertexData);
  1009. }
  1010. // Sub material
  1011. var material_1 = gltfRuntime.scene.getMaterialByID(primitive.material);
  1012. subMaterials.push(material_1 === null ? _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__["GLTFUtils"].GetDefaultMaterial(gltfRuntime.scene) : material_1);
  1013. // Update vertices start and index start
  1014. verticesStarts.push(verticesStarts.length === 0 ? 0 : verticesStarts[verticesStarts.length - 1] + verticesCounts[verticesCounts.length - 2]);
  1015. indexStarts.push(indexStarts.length === 0 ? 0 : indexStarts[indexStarts.length - 1] + indexCounts[indexCounts.length - 2]);
  1016. }
  1017. }
  1018. var material;
  1019. gltfRuntime.scene._blockEntityCollection = gltfRuntime.forAssetContainer;
  1020. if (subMaterials.length > 1) {
  1021. material = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["MultiMaterial"]("multimat" + id, gltfRuntime.scene);
  1022. material.subMaterials = subMaterials;
  1023. }
  1024. else {
  1025. material = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("multimat" + id, gltfRuntime.scene);
  1026. }
  1027. if (subMaterials.length === 1) {
  1028. material = subMaterials[0];
  1029. }
  1030. if (!newMesh.material) {
  1031. newMesh.material = material;
  1032. }
  1033. // Apply geometry
  1034. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Geometry"](id, gltfRuntime.scene, vertexData, false, newMesh);
  1035. newMesh.computeWorldMatrix(true);
  1036. gltfRuntime.scene._blockEntityCollection = false;
  1037. // Apply submeshes
  1038. newMesh.subMeshes = [];
  1039. var index = 0;
  1040. for (var meshIndex = 0; meshIndex < meshes.length; meshIndex++) {
  1041. var meshID = meshes[meshIndex];
  1042. var mesh = gltfRuntime.meshes[meshID];
  1043. if (!mesh) {
  1044. continue;
  1045. }
  1046. for (var i = 0; i < mesh.primitives.length; i++) {
  1047. if (mesh.primitives[i].mode !== 4) {
  1048. //continue;
  1049. }
  1050. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["SubMesh"].AddToMesh(index, verticesStarts[index], verticesCounts[index], indexStarts[index], indexCounts[index], newMesh, newMesh, true);
  1051. index++;
  1052. }
  1053. }
  1054. // Finish
  1055. return newMesh;
  1056. };
  1057. /**
  1058. * Configure node transformation from position, rotation and scaling
  1059. */
  1060. var configureNode = function (newNode, position, rotation, scaling) {
  1061. if (newNode.position) {
  1062. newNode.position = position;
  1063. }
  1064. if (newNode.rotationQuaternion || newNode.rotation) {
  1065. newNode.rotationQuaternion = rotation;
  1066. }
  1067. if (newNode.scaling) {
  1068. newNode.scaling = scaling;
  1069. }
  1070. };
  1071. /**
  1072. * Configures node from transformation matrix
  1073. */
  1074. var configureNodeFromMatrix = function (newNode, node, parent) {
  1075. if (node.matrix) {
  1076. var position = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  1077. var rotation = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  1078. var scaling = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  1079. var mat = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromArray(node.matrix);
  1080. mat.decompose(scaling, rotation, position);
  1081. configureNode(newNode, position, rotation, scaling);
  1082. }
  1083. else if (node.translation && node.rotation && node.scale) {
  1084. configureNode(newNode, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(node.translation), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromArray(node.rotation), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(node.scale));
  1085. }
  1086. newNode.computeWorldMatrix(true);
  1087. };
  1088. /**
  1089. * Imports a node
  1090. */
  1091. var importNode = function (gltfRuntime, node, id, parent) {
  1092. var lastNode = null;
  1093. if (gltfRuntime.importOnlyMeshes && (node.skin || node.meshes)) {
  1094. if (gltfRuntime.importMeshesNames && gltfRuntime.importMeshesNames.length > 0 && gltfRuntime.importMeshesNames.indexOf(node.name || "") === -1) {
  1095. return null;
  1096. }
  1097. }
  1098. // Meshes
  1099. if (node.skin) {
  1100. if (node.meshes) {
  1101. var skin = gltfRuntime.skins[node.skin];
  1102. var newMesh = importMesh(gltfRuntime, node, node.meshes, id, node.babylonNode);
  1103. newMesh.skeleton = gltfRuntime.scene.getLastSkeletonByID(node.skin);
  1104. if (newMesh.skeleton === null) {
  1105. newMesh.skeleton = importSkeleton(gltfRuntime, skin, newMesh, skin.babylonSkeleton, node.skin);
  1106. if (!skin.babylonSkeleton) {
  1107. skin.babylonSkeleton = newMesh.skeleton;
  1108. }
  1109. }
  1110. lastNode = newMesh;
  1111. }
  1112. }
  1113. else if (node.meshes) {
  1114. /**
  1115. * Improve meshes property
  1116. */
  1117. var newMesh = importMesh(gltfRuntime, node, node.mesh ? [node.mesh] : node.meshes, id, node.babylonNode);
  1118. lastNode = newMesh;
  1119. }
  1120. // Lights
  1121. else if (node.light && !node.babylonNode && !gltfRuntime.importOnlyMeshes) {
  1122. var light = gltfRuntime.lights[node.light];
  1123. if (light) {
  1124. if (light.type === "ambient") {
  1125. var ambienLight = light[light.type];
  1126. var hemiLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["HemisphericLight"](node.light, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), gltfRuntime.scene);
  1127. hemiLight.name = node.name || "";
  1128. if (ambienLight.color) {
  1129. hemiLight.diffuse = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(ambienLight.color);
  1130. }
  1131. lastNode = hemiLight;
  1132. }
  1133. else if (light.type === "directional") {
  1134. var directionalLight = light[light.type];
  1135. var dirLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["DirectionalLight"](node.light, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), gltfRuntime.scene);
  1136. dirLight.name = node.name || "";
  1137. if (directionalLight.color) {
  1138. dirLight.diffuse = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(directionalLight.color);
  1139. }
  1140. lastNode = dirLight;
  1141. }
  1142. else if (light.type === "point") {
  1143. var pointLight = light[light.type];
  1144. var ptLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["PointLight"](node.light, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), gltfRuntime.scene);
  1145. ptLight.name = node.name || "";
  1146. if (pointLight.color) {
  1147. ptLight.diffuse = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(pointLight.color);
  1148. }
  1149. lastNode = ptLight;
  1150. }
  1151. else if (light.type === "spot") {
  1152. var spotLight = light[light.type];
  1153. var spLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["SpotLight"](node.light, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), 0, 0, gltfRuntime.scene);
  1154. spLight.name = node.name || "";
  1155. if (spotLight.color) {
  1156. spLight.diffuse = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(spotLight.color);
  1157. }
  1158. if (spotLight.fallOfAngle) {
  1159. spLight.angle = spotLight.fallOfAngle;
  1160. }
  1161. if (spotLight.fallOffExponent) {
  1162. spLight.exponent = spotLight.fallOffExponent;
  1163. }
  1164. lastNode = spLight;
  1165. }
  1166. }
  1167. }
  1168. // Cameras
  1169. else if (node.camera && !node.babylonNode && !gltfRuntime.importOnlyMeshes) {
  1170. var camera = gltfRuntime.cameras[node.camera];
  1171. if (camera) {
  1172. gltfRuntime.scene._blockEntityCollection = gltfRuntime.forAssetContainer;
  1173. if (camera.type === "orthographic") {
  1174. var orthoCamera = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"](node.camera, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), gltfRuntime.scene, false);
  1175. orthoCamera.name = node.name || "";
  1176. orthoCamera.mode = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Camera"].ORTHOGRAPHIC_CAMERA;
  1177. orthoCamera.attachControl(gltfRuntime.scene.getEngine().getInputElement());
  1178. lastNode = orthoCamera;
  1179. }
  1180. else if (camera.type === "perspective") {
  1181. var perspectiveCamera = camera[camera.type];
  1182. var persCamera = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"](node.camera, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), gltfRuntime.scene, false);
  1183. persCamera.name = node.name || "";
  1184. persCamera.attachControl(gltfRuntime.scene.getEngine().getInputElement());
  1185. if (!perspectiveCamera.aspectRatio) {
  1186. perspectiveCamera.aspectRatio = gltfRuntime.scene.getEngine().getRenderWidth() / gltfRuntime.scene.getEngine().getRenderHeight();
  1187. }
  1188. if (perspectiveCamera.znear && perspectiveCamera.zfar) {
  1189. persCamera.maxZ = perspectiveCamera.zfar;
  1190. persCamera.minZ = perspectiveCamera.znear;
  1191. }
  1192. lastNode = persCamera;
  1193. }
  1194. gltfRuntime.scene._blockEntityCollection = false;
  1195. }
  1196. }
  1197. // Empty node
  1198. if (!node.jointName) {
  1199. if (node.babylonNode) {
  1200. return node.babylonNode;
  1201. }
  1202. else if (lastNode === null) {
  1203. gltfRuntime.scene._blockEntityCollection = gltfRuntime.forAssetContainer;
  1204. var dummy = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Mesh"](node.name || "", gltfRuntime.scene);
  1205. gltfRuntime.scene._blockEntityCollection = false;
  1206. node.babylonNode = dummy;
  1207. lastNode = dummy;
  1208. }
  1209. }
  1210. if (lastNode !== null) {
  1211. if (node.matrix && lastNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Mesh"]) {
  1212. configureNodeFromMatrix(lastNode, node, parent);
  1213. }
  1214. else {
  1215. var translation = node.translation || [0, 0, 0];
  1216. var rotation = node.rotation || [0, 0, 0, 1];
  1217. var scale = node.scale || [1, 1, 1];
  1218. configureNode(lastNode, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(translation), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromArray(rotation), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(scale));
  1219. }
  1220. lastNode.updateCache(true);
  1221. node.babylonNode = lastNode;
  1222. }
  1223. return lastNode;
  1224. };
  1225. /**
  1226. * Traverses nodes and creates them
  1227. */
  1228. var traverseNodes = function (gltfRuntime, id, parent, meshIncluded) {
  1229. if (meshIncluded === void 0) { meshIncluded = false; }
  1230. var node = gltfRuntime.nodes[id];
  1231. var newNode = null;
  1232. if (gltfRuntime.importOnlyMeshes && !meshIncluded && gltfRuntime.importMeshesNames) {
  1233. if (gltfRuntime.importMeshesNames.indexOf(node.name || "") !== -1 || gltfRuntime.importMeshesNames.length === 0) {
  1234. meshIncluded = true;
  1235. }
  1236. else {
  1237. meshIncluded = false;
  1238. }
  1239. }
  1240. else {
  1241. meshIncluded = true;
  1242. }
  1243. if (!node.jointName && meshIncluded) {
  1244. newNode = importNode(gltfRuntime, node, id, parent);
  1245. if (newNode !== null) {
  1246. newNode.id = id;
  1247. newNode.parent = parent;
  1248. }
  1249. }
  1250. if (node.children) {
  1251. for (var i = 0; i < node.children.length; i++) {
  1252. traverseNodes(gltfRuntime, node.children[i], newNode, meshIncluded);
  1253. }
  1254. }
  1255. };
  1256. /**
  1257. * do stuff after buffers, shaders are loaded (e.g. hook up materials, load animations, etc.)
  1258. */
  1259. var postLoad = function (gltfRuntime) {
  1260. // Nodes
  1261. var currentScene = gltfRuntime.currentScene;
  1262. if (currentScene) {
  1263. for (var i = 0; i < currentScene.nodes.length; i++) {
  1264. traverseNodes(gltfRuntime, currentScene.nodes[i], null);
  1265. }
  1266. }
  1267. else {
  1268. for (var thing in gltfRuntime.scenes) {
  1269. currentScene = gltfRuntime.scenes[thing];
  1270. for (var i = 0; i < currentScene.nodes.length; i++) {
  1271. traverseNodes(gltfRuntime, currentScene.nodes[i], null);
  1272. }
  1273. }
  1274. }
  1275. // Set animations
  1276. loadAnimations(gltfRuntime);
  1277. for (var i = 0; i < gltfRuntime.scene.skeletons.length; i++) {
  1278. var skeleton = gltfRuntime.scene.skeletons[i];
  1279. gltfRuntime.scene.beginAnimation(skeleton, 0, Number.MAX_VALUE, true, 1.0);
  1280. }
  1281. };
  1282. /**
  1283. * onBind shaderrs callback to set uniforms and matrices
  1284. */
  1285. var onBindShaderMaterial = function (mesh, gltfRuntime, unTreatedUniforms, shaderMaterial, technique, material, onSuccess) {
  1286. var materialValues = material.values || technique.parameters;
  1287. for (var unif in unTreatedUniforms) {
  1288. var uniform = unTreatedUniforms[unif];
  1289. var type = uniform.type;
  1290. if (type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EParameterType"].FLOAT_MAT2 || type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EParameterType"].FLOAT_MAT3 || type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EParameterType"].FLOAT_MAT4) {
  1291. if (uniform.semantic && !uniform.source && !uniform.node) {
  1292. _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__["GLTFUtils"].SetMatrix(gltfRuntime.scene, mesh, uniform, unif, shaderMaterial.getEffect());
  1293. }
  1294. else if (uniform.semantic && (uniform.source || uniform.node)) {
  1295. var source = gltfRuntime.scene.getNodeByName(uniform.source || uniform.node || "");
  1296. if (source === null) {
  1297. source = gltfRuntime.scene.getNodeByID(uniform.source || uniform.node || "");
  1298. }
  1299. if (source === null) {
  1300. continue;
  1301. }
  1302. _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__["GLTFUtils"].SetMatrix(gltfRuntime.scene, source, uniform, unif, shaderMaterial.getEffect());
  1303. }
  1304. }
  1305. else {
  1306. var value = materialValues[technique.uniforms[unif]];
  1307. if (!value) {
  1308. continue;
  1309. }
  1310. if (type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EParameterType"].SAMPLER_2D) {
  1311. var texture = gltfRuntime.textures[material.values ? value : uniform.value].babylonTexture;
  1312. if (texture === null || texture === undefined) {
  1313. continue;
  1314. }
  1315. shaderMaterial.getEffect().setTexture(unif, texture);
  1316. }
  1317. else {
  1318. _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__["GLTFUtils"].SetUniform((shaderMaterial.getEffect()), unif, value, type);
  1319. }
  1320. }
  1321. }
  1322. onSuccess(shaderMaterial);
  1323. };
  1324. /**
  1325. * Prepare uniforms to send the only one time
  1326. * Loads the appropriate textures
  1327. */
  1328. var prepareShaderMaterialUniforms = function (gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms) {
  1329. var materialValues = material.values || technique.parameters;
  1330. var techniqueUniforms = technique.uniforms;
  1331. /**
  1332. * Prepare values here (not matrices)
  1333. */
  1334. for (var unif in unTreatedUniforms) {
  1335. var uniform = unTreatedUniforms[unif];
  1336. var type = uniform.type;
  1337. var value = materialValues[techniqueUniforms[unif]];
  1338. if (value === undefined) {
  1339. // In case the value is the same for all materials
  1340. value = uniform.value;
  1341. }
  1342. if (!value) {
  1343. continue;
  1344. }
  1345. var onLoadTexture = function (uniformName) {
  1346. return function (texture) {
  1347. if (uniform.value && uniformName) {
  1348. // Static uniform
  1349. shaderMaterial.setTexture(uniformName, texture);
  1350. delete unTreatedUniforms[uniformName];
  1351. }
  1352. };
  1353. };
  1354. // Texture (sampler2D)
  1355. if (type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EParameterType"].SAMPLER_2D) {
  1356. GLTFLoaderExtension.LoadTextureAsync(gltfRuntime, material.values ? value : uniform.value, onLoadTexture(unif), function () { return onLoadTexture(null); });
  1357. }
  1358. // Others
  1359. else {
  1360. if (uniform.value && _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__["GLTFUtils"].SetUniform(shaderMaterial, unif, material.values ? value : uniform.value, type)) {
  1361. // Static uniform
  1362. delete unTreatedUniforms[unif];
  1363. }
  1364. }
  1365. }
  1366. };
  1367. /**
  1368. * Shader compilation failed
  1369. */
  1370. var onShaderCompileError = function (program, shaderMaterial, onError) {
  1371. return function (effect, error) {
  1372. shaderMaterial.dispose(true);
  1373. onError("Cannot compile program named " + program.name + ". Error: " + error + ". Default material will be applied");
  1374. };
  1375. };
  1376. /**
  1377. * Shader compilation success
  1378. */
  1379. var onShaderCompileSuccess = function (gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms, onSuccess) {
  1380. return function (_) {
  1381. prepareShaderMaterialUniforms(gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms);
  1382. shaderMaterial.onBind = function (mesh) {
  1383. onBindShaderMaterial(mesh, gltfRuntime, unTreatedUniforms, shaderMaterial, technique, material, onSuccess);
  1384. };
  1385. };
  1386. };
  1387. /**
  1388. * Returns the appropriate uniform if already handled by babylon
  1389. */
  1390. var parseShaderUniforms = function (tokenizer, technique, unTreatedUniforms) {
  1391. for (var unif in technique.uniforms) {
  1392. var uniform = technique.uniforms[unif];
  1393. var uniformParameter = technique.parameters[uniform];
  1394. if (tokenizer.currentIdentifier === unif) {
  1395. if (uniformParameter.semantic && !uniformParameter.source && !uniformParameter.node) {
  1396. var transformIndex = glTFTransforms.indexOf(uniformParameter.semantic);
  1397. if (transformIndex !== -1) {
  1398. delete unTreatedUniforms[unif];
  1399. return babylonTransforms[transformIndex];
  1400. }
  1401. }
  1402. }
  1403. }
  1404. return tokenizer.currentIdentifier;
  1405. };
  1406. /**
  1407. * All shaders loaded. Create materials one by one
  1408. */
  1409. var importMaterials = function (gltfRuntime) {
  1410. // Create materials
  1411. for (var mat in gltfRuntime.materials) {
  1412. GLTFLoaderExtension.LoadMaterialAsync(gltfRuntime, mat, function (material) { }, function () { });
  1413. }
  1414. };
  1415. /**
  1416. * Implementation of the base glTF spec
  1417. * @hidden
  1418. */
  1419. var GLTFLoaderBase = /** @class */ (function () {
  1420. function GLTFLoaderBase() {
  1421. }
  1422. GLTFLoaderBase.CreateRuntime = function (parsedData, scene, rootUrl) {
  1423. var gltfRuntime = {
  1424. extensions: {},
  1425. accessors: {},
  1426. buffers: {},
  1427. bufferViews: {},
  1428. meshes: {},
  1429. lights: {},
  1430. cameras: {},
  1431. nodes: {},
  1432. images: {},
  1433. textures: {},
  1434. shaders: {},
  1435. programs: {},
  1436. samplers: {},
  1437. techniques: {},
  1438. materials: {},
  1439. animations: {},
  1440. skins: {},
  1441. extensionsUsed: [],
  1442. scenes: {},
  1443. buffersCount: 0,
  1444. shaderscount: 0,
  1445. scene: scene,
  1446. rootUrl: rootUrl,
  1447. loadedBufferCount: 0,
  1448. loadedBufferViews: {},
  1449. loadedShaderCount: 0,
  1450. importOnlyMeshes: false,
  1451. dummyNodes: [],
  1452. forAssetContainer: false
  1453. };
  1454. // Parse
  1455. if (parsedData.extensions) {
  1456. parseObject(parsedData.extensions, "extensions", gltfRuntime);
  1457. }
  1458. if (parsedData.extensionsUsed) {
  1459. parseObject(parsedData.extensionsUsed, "extensionsUsed", gltfRuntime);
  1460. }
  1461. if (parsedData.buffers) {
  1462. parseBuffers(parsedData.buffers, gltfRuntime);
  1463. }
  1464. if (parsedData.bufferViews) {
  1465. parseObject(parsedData.bufferViews, "bufferViews", gltfRuntime);
  1466. }
  1467. if (parsedData.accessors) {
  1468. parseObject(parsedData.accessors, "accessors", gltfRuntime);
  1469. }
  1470. if (parsedData.meshes) {
  1471. parseObject(parsedData.meshes, "meshes", gltfRuntime);
  1472. }
  1473. if (parsedData.lights) {
  1474. parseObject(parsedData.lights, "lights", gltfRuntime);
  1475. }
  1476. if (parsedData.cameras) {
  1477. parseObject(parsedData.cameras, "cameras", gltfRuntime);
  1478. }
  1479. if (parsedData.nodes) {
  1480. parseObject(parsedData.nodes, "nodes", gltfRuntime);
  1481. }
  1482. if (parsedData.images) {
  1483. parseObject(parsedData.images, "images", gltfRuntime);
  1484. }
  1485. if (parsedData.textures) {
  1486. parseObject(parsedData.textures, "textures", gltfRuntime);
  1487. }
  1488. if (parsedData.shaders) {
  1489. parseShaders(parsedData.shaders, gltfRuntime);
  1490. }
  1491. if (parsedData.programs) {
  1492. parseObject(parsedData.programs, "programs", gltfRuntime);
  1493. }
  1494. if (parsedData.samplers) {
  1495. parseObject(parsedData.samplers, "samplers", gltfRuntime);
  1496. }
  1497. if (parsedData.techniques) {
  1498. parseObject(parsedData.techniques, "techniques", gltfRuntime);
  1499. }
  1500. if (parsedData.materials) {
  1501. parseObject(parsedData.materials, "materials", gltfRuntime);
  1502. }
  1503. if (parsedData.animations) {
  1504. parseObject(parsedData.animations, "animations", gltfRuntime);
  1505. }
  1506. if (parsedData.skins) {
  1507. parseObject(parsedData.skins, "skins", gltfRuntime);
  1508. }
  1509. if (parsedData.scenes) {
  1510. gltfRuntime.scenes = parsedData.scenes;
  1511. }
  1512. if (parsedData.scene && parsedData.scenes) {
  1513. gltfRuntime.currentScene = parsedData.scenes[parsedData.scene];
  1514. }
  1515. return gltfRuntime;
  1516. };
  1517. GLTFLoaderBase.LoadBufferAsync = function (gltfRuntime, id, onSuccess, onError, onProgress) {
  1518. var buffer = gltfRuntime.buffers[id];
  1519. if (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Tools"].IsBase64(buffer.uri)) {
  1520. setTimeout(function () { return onSuccess(new Uint8Array(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Tools"].DecodeBase64(buffer.uri))); });
  1521. }
  1522. else {
  1523. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadFile(gltfRuntime.rootUrl + buffer.uri, function (data) { return onSuccess(new Uint8Array(data)); }, onProgress, undefined, true, function (request) {
  1524. if (request) {
  1525. onError(request.status + " " + request.statusText);
  1526. }
  1527. });
  1528. }
  1529. };
  1530. GLTFLoaderBase.LoadTextureBufferAsync = function (gltfRuntime, id, onSuccess, onError) {
  1531. var texture = gltfRuntime.textures[id];
  1532. if (!texture || !texture.source) {
  1533. onError("");
  1534. return;
  1535. }
  1536. if (texture.babylonTexture) {
  1537. onSuccess(null);
  1538. return;
  1539. }
  1540. var source = gltfRuntime.images[texture.source];
  1541. if (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Tools"].IsBase64(source.uri)) {
  1542. setTimeout(function () { return onSuccess(new Uint8Array(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Tools"].DecodeBase64(source.uri))); });
  1543. }
  1544. else {
  1545. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadFile(gltfRuntime.rootUrl + source.uri, function (data) { return onSuccess(new Uint8Array(data)); }, undefined, undefined, true, function (request) {
  1546. if (request) {
  1547. onError(request.status + " " + request.statusText);
  1548. }
  1549. });
  1550. }
  1551. };
  1552. GLTFLoaderBase.CreateTextureAsync = function (gltfRuntime, id, buffer, onSuccess, onError) {
  1553. var texture = gltfRuntime.textures[id];
  1554. if (texture.babylonTexture) {
  1555. onSuccess(texture.babylonTexture);
  1556. return;
  1557. }
  1558. var sampler = gltfRuntime.samplers[texture.sampler];
  1559. var createMipMaps = (sampler.minFilter === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["ETextureFilterType"].NEAREST_MIPMAP_NEAREST) ||
  1560. (sampler.minFilter === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["ETextureFilterType"].NEAREST_MIPMAP_LINEAR) ||
  1561. (sampler.minFilter === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["ETextureFilterType"].LINEAR_MIPMAP_NEAREST) ||
  1562. (sampler.minFilter === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["ETextureFilterType"].LINEAR_MIPMAP_LINEAR);
  1563. var samplingMode = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE;
  1564. var blob = buffer == null ? new Blob() : new Blob([buffer]);
  1565. var blobURL = URL.createObjectURL(blob);
  1566. var revokeBlobURL = function () { return URL.revokeObjectURL(blobURL); };
  1567. var newTexture = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Texture"](blobURL, gltfRuntime.scene, !createMipMaps, true, samplingMode, revokeBlobURL, revokeBlobURL);
  1568. if (sampler.wrapS !== undefined) {
  1569. newTexture.wrapU = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__["GLTFUtils"].GetWrapMode(sampler.wrapS);
  1570. }
  1571. if (sampler.wrapT !== undefined) {
  1572. newTexture.wrapV = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__["GLTFUtils"].GetWrapMode(sampler.wrapT);
  1573. }
  1574. newTexture.name = id;
  1575. texture.babylonTexture = newTexture;
  1576. onSuccess(newTexture);
  1577. };
  1578. GLTFLoaderBase.LoadShaderStringAsync = function (gltfRuntime, id, onSuccess, onError) {
  1579. var shader = gltfRuntime.shaders[id];
  1580. if (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Tools"].IsBase64(shader.uri)) {
  1581. var shaderString = atob(shader.uri.split(",")[1]);
  1582. if (onSuccess) {
  1583. onSuccess(shaderString);
  1584. }
  1585. }
  1586. else {
  1587. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadFile(gltfRuntime.rootUrl + shader.uri, onSuccess, undefined, undefined, false, function (request) {
  1588. if (request && onError) {
  1589. onError(request.status + " " + request.statusText);
  1590. }
  1591. });
  1592. }
  1593. };
  1594. GLTFLoaderBase.LoadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) {
  1595. var material = gltfRuntime.materials[id];
  1596. if (!material.technique) {
  1597. if (onError) {
  1598. onError("No technique found.");
  1599. }
  1600. return;
  1601. }
  1602. var technique = gltfRuntime.techniques[material.technique];
  1603. if (!technique) {
  1604. gltfRuntime.scene._blockEntityCollection = gltfRuntime.forAssetContainer;
  1605. var defaultMaterial = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](id, gltfRuntime.scene);
  1606. gltfRuntime.scene._blockEntityCollection = false;
  1607. defaultMaterial.diffuseColor = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.5, 0.5, 0.5);
  1608. defaultMaterial.sideOrientation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Material"].CounterClockWiseSideOrientation;
  1609. onSuccess(defaultMaterial);
  1610. return;
  1611. }
  1612. var program = gltfRuntime.programs[technique.program];
  1613. var states = technique.states;
  1614. var vertexShader = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore[program.vertexShader + "VertexShader"];
  1615. var pixelShader = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore[program.fragmentShader + "PixelShader"];
  1616. var newVertexShader = "";
  1617. var newPixelShader = "";
  1618. var vertexTokenizer = new Tokenizer(vertexShader);
  1619. var pixelTokenizer = new Tokenizer(pixelShader);
  1620. var unTreatedUniforms = {};
  1621. var uniforms = [];
  1622. var attributes = [];
  1623. var samplers = [];
  1624. // Fill uniform, sampler2D and attributes
  1625. for (var unif in technique.uniforms) {
  1626. var uniform = technique.uniforms[unif];
  1627. var uniformParameter = technique.parameters[uniform];
  1628. unTreatedUniforms[unif] = uniformParameter;
  1629. if (uniformParameter.semantic && !uniformParameter.node && !uniformParameter.source) {
  1630. var transformIndex = glTFTransforms.indexOf(uniformParameter.semantic);
  1631. if (transformIndex !== -1) {
  1632. uniforms.push(babylonTransforms[transformIndex]);
  1633. delete unTreatedUniforms[unif];
  1634. }
  1635. else {
  1636. uniforms.push(unif);
  1637. }
  1638. }
  1639. else if (uniformParameter.type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EParameterType"].SAMPLER_2D) {
  1640. samplers.push(unif);
  1641. }
  1642. else {
  1643. uniforms.push(unif);
  1644. }
  1645. }
  1646. for (var attr in technique.attributes) {
  1647. var attribute = technique.attributes[attr];
  1648. var attributeParameter = technique.parameters[attribute];
  1649. if (attributeParameter.semantic) {
  1650. var name_1 = getAttribute(attributeParameter);
  1651. if (name_1) {
  1652. attributes.push(name_1);
  1653. }
  1654. }
  1655. }
  1656. // Configure vertex shader
  1657. while (!vertexTokenizer.isEnd() && vertexTokenizer.getNextToken()) {
  1658. var tokenType = vertexTokenizer.currentToken;
  1659. if (tokenType !== ETokenType.IDENTIFIER) {
  1660. newVertexShader += vertexTokenizer.currentString;
  1661. continue;
  1662. }
  1663. var foundAttribute = false;
  1664. for (var attr in technique.attributes) {
  1665. var attribute = technique.attributes[attr];
  1666. var attributeParameter = technique.parameters[attribute];
  1667. if (vertexTokenizer.currentIdentifier === attr && attributeParameter.semantic) {
  1668. newVertexShader += getAttribute(attributeParameter);
  1669. foundAttribute = true;
  1670. break;
  1671. }
  1672. }
  1673. if (foundAttribute) {
  1674. continue;
  1675. }
  1676. newVertexShader += parseShaderUniforms(vertexTokenizer, technique, unTreatedUniforms);
  1677. }
  1678. // Configure pixel shader
  1679. while (!pixelTokenizer.isEnd() && pixelTokenizer.getNextToken()) {
  1680. var tokenType = pixelTokenizer.currentToken;
  1681. if (tokenType !== ETokenType.IDENTIFIER) {
  1682. newPixelShader += pixelTokenizer.currentString;
  1683. continue;
  1684. }
  1685. newPixelShader += parseShaderUniforms(pixelTokenizer, technique, unTreatedUniforms);
  1686. }
  1687. // Create shader material
  1688. var shaderPath = {
  1689. vertex: program.vertexShader + id,
  1690. fragment: program.fragmentShader + id
  1691. };
  1692. var options = {
  1693. attributes: attributes,
  1694. uniforms: uniforms,
  1695. samplers: samplers,
  1696. needAlphaBlending: states && states.enable && states.enable.indexOf(3042) !== -1
  1697. };
  1698. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore[program.vertexShader + id + "VertexShader"] = newVertexShader;
  1699. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore[program.fragmentShader + id + "PixelShader"] = newPixelShader;
  1700. var shaderMaterial = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["ShaderMaterial"](id, gltfRuntime.scene, shaderPath, options);
  1701. shaderMaterial.onError = onShaderCompileError(program, shaderMaterial, onError);
  1702. shaderMaterial.onCompiled = onShaderCompileSuccess(gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms, onSuccess);
  1703. shaderMaterial.sideOrientation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Material"].CounterClockWiseSideOrientation;
  1704. if (states && states.functions) {
  1705. var functions = states.functions;
  1706. if (functions.cullFace && functions.cullFace[0] !== _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["ECullingType"].BACK) {
  1707. shaderMaterial.backFaceCulling = false;
  1708. }
  1709. var blendFunc = functions.blendFuncSeparate;
  1710. if (blendFunc) {
  1711. if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EBlendingFunction"].SRC_ALPHA && blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EBlendingFunction"].ONE_MINUS_SRC_ALPHA && blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EBlendingFunction"].ONE && blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EBlendingFunction"].ONE) {
  1712. shaderMaterial.alphaMode = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Constants"].ALPHA_COMBINE;
  1713. }
  1714. else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EBlendingFunction"].ONE && blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EBlendingFunction"].ONE && blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EBlendingFunction"].ZERO && blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EBlendingFunction"].ONE) {
  1715. shaderMaterial.alphaMode = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Constants"].ALPHA_ONEONE;
  1716. }
  1717. else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EBlendingFunction"].SRC_ALPHA && blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EBlendingFunction"].ONE && blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EBlendingFunction"].ZERO && blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EBlendingFunction"].ONE) {
  1718. shaderMaterial.alphaMode = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Constants"].ALPHA_ADD;
  1719. }
  1720. else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EBlendingFunction"].ZERO && blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EBlendingFunction"].ONE_MINUS_SRC_COLOR && blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EBlendingFunction"].ONE && blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EBlendingFunction"].ONE) {
  1721. shaderMaterial.alphaMode = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Constants"].ALPHA_SUBTRACT;
  1722. }
  1723. else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EBlendingFunction"].DST_COLOR && blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EBlendingFunction"].ZERO && blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EBlendingFunction"].ONE && blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EBlendingFunction"].ONE) {
  1724. shaderMaterial.alphaMode = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Constants"].ALPHA_MULTIPLY;
  1725. }
  1726. else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EBlendingFunction"].SRC_ALPHA && blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EBlendingFunction"].ONE_MINUS_SRC_COLOR && blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EBlendingFunction"].ONE && blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EBlendingFunction"].ONE) {
  1727. shaderMaterial.alphaMode = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Constants"].ALPHA_MAXIMIZED;
  1728. }
  1729. }
  1730. }
  1731. };
  1732. return GLTFLoaderBase;
  1733. }());
  1734. /**
  1735. * glTF V1 Loader
  1736. * @hidden
  1737. */
  1738. var GLTFLoader = /** @class */ (function () {
  1739. function GLTFLoader() {
  1740. this.state = null;
  1741. }
  1742. GLTFLoader.RegisterExtension = function (extension) {
  1743. if (GLTFLoader.Extensions[extension.name]) {
  1744. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Tool with the same name \"" + extension.name + "\" already exists");
  1745. return;
  1746. }
  1747. GLTFLoader.Extensions[extension.name] = extension;
  1748. };
  1749. GLTFLoader.prototype.dispose = function () {
  1750. // do nothing
  1751. };
  1752. GLTFLoader.prototype._importMeshAsync = function (meshesNames, scene, data, rootUrl, forAssetContainer, onSuccess, onProgress, onError) {
  1753. var _this = this;
  1754. scene.useRightHandedSystem = true;
  1755. GLTFLoaderExtension.LoadRuntimeAsync(scene, data, rootUrl, function (gltfRuntime) {
  1756. gltfRuntime.forAssetContainer = forAssetContainer;
  1757. gltfRuntime.importOnlyMeshes = true;
  1758. if (meshesNames === "") {
  1759. gltfRuntime.importMeshesNames = [];
  1760. }
  1761. else if (typeof meshesNames === "string") {
  1762. gltfRuntime.importMeshesNames = [meshesNames];
  1763. }
  1764. else if (meshesNames && !(meshesNames instanceof Array)) {
  1765. gltfRuntime.importMeshesNames = [meshesNames];
  1766. }
  1767. else {
  1768. gltfRuntime.importMeshesNames = [];
  1769. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Tools"].Warn("Argument meshesNames must be of type string or string[]");
  1770. }
  1771. // Create nodes
  1772. _this._createNodes(gltfRuntime);
  1773. var meshes = new Array();
  1774. var skeletons = new Array();
  1775. // Fill arrays of meshes and skeletons
  1776. for (var nde in gltfRuntime.nodes) {
  1777. var node = gltfRuntime.nodes[nde];
  1778. if (node.babylonNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  1779. meshes.push(node.babylonNode);
  1780. }
  1781. }
  1782. for (var skl in gltfRuntime.skins) {
  1783. var skin = gltfRuntime.skins[skl];
  1784. if (skin.babylonSkeleton instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Skeleton"]) {
  1785. skeletons.push(skin.babylonSkeleton);
  1786. }
  1787. }
  1788. // Load buffers, shaders, materials, etc.
  1789. _this._loadBuffersAsync(gltfRuntime, function () {
  1790. _this._loadShadersAsync(gltfRuntime, function () {
  1791. importMaterials(gltfRuntime);
  1792. postLoad(gltfRuntime);
  1793. if (!_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__["GLTFFileLoader"].IncrementalLoading && onSuccess) {
  1794. onSuccess(meshes, skeletons);
  1795. }
  1796. });
  1797. }, onProgress);
  1798. if (_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__["GLTFFileLoader"].IncrementalLoading && onSuccess) {
  1799. onSuccess(meshes, skeletons);
  1800. }
  1801. }, onError);
  1802. return true;
  1803. };
  1804. /**
  1805. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  1806. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  1807. * @param scene the scene the meshes should be added to
  1808. * @param forAssetContainer defines if the entities must be stored in the scene
  1809. * @param data gltf data containing information of the meshes in a loaded file
  1810. * @param rootUrl root url to load from
  1811. * @param onProgress event that fires when loading progress has occured
  1812. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  1813. */
  1814. GLTFLoader.prototype.importMeshAsync = function (meshesNames, scene, forAssetContainer, data, rootUrl, onProgress) {
  1815. var _this = this;
  1816. return new Promise(function (resolve, reject) {
  1817. _this._importMeshAsync(meshesNames, scene, data, rootUrl, forAssetContainer, function (meshes, skeletons) {
  1818. resolve({
  1819. meshes: meshes,
  1820. particleSystems: [],
  1821. skeletons: skeletons,
  1822. animationGroups: [],
  1823. lights: [],
  1824. transformNodes: []
  1825. });
  1826. }, onProgress, function (message) {
  1827. reject(new Error(message));
  1828. });
  1829. });
  1830. };
  1831. GLTFLoader.prototype._loadAsync = function (scene, data, rootUrl, forAssetContainer, onSuccess, onProgress, onError) {
  1832. var _this = this;
  1833. scene.useRightHandedSystem = true;
  1834. GLTFLoaderExtension.LoadRuntimeAsync(scene, data, rootUrl, function (gltfRuntime) {
  1835. // Load runtime extensios
  1836. GLTFLoaderExtension.LoadRuntimeExtensionsAsync(gltfRuntime, function () {
  1837. // Create nodes
  1838. _this._createNodes(gltfRuntime);
  1839. // Load buffers, shaders, materials, etc.
  1840. _this._loadBuffersAsync(gltfRuntime, function () {
  1841. _this._loadShadersAsync(gltfRuntime, function () {
  1842. importMaterials(gltfRuntime);
  1843. postLoad(gltfRuntime);
  1844. if (!_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__["GLTFFileLoader"].IncrementalLoading) {
  1845. onSuccess();
  1846. }
  1847. });
  1848. });
  1849. if (_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__["GLTFFileLoader"].IncrementalLoading) {
  1850. onSuccess();
  1851. }
  1852. }, onError);
  1853. }, onError);
  1854. };
  1855. /**
  1856. * Imports all objects from a loaded gltf file and adds them to the scene
  1857. * @param scene the scene the objects should be added to
  1858. * @param data gltf data containing information of the meshes in a loaded file
  1859. * @param rootUrl root url to load from
  1860. * @param onProgress event that fires when loading progress has occured
  1861. * @returns a promise which completes when objects have been loaded to the scene
  1862. */
  1863. GLTFLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress) {
  1864. var _this = this;
  1865. return new Promise(function (resolve, reject) {
  1866. _this._loadAsync(scene, data, rootUrl, false, function () {
  1867. resolve();
  1868. }, onProgress, function (message) {
  1869. reject(new Error(message));
  1870. });
  1871. });
  1872. };
  1873. GLTFLoader.prototype._loadShadersAsync = function (gltfRuntime, onload) {
  1874. var hasShaders = false;
  1875. var processShader = function (sha, shader) {
  1876. GLTFLoaderExtension.LoadShaderStringAsync(gltfRuntime, sha, function (shaderString) {
  1877. if (shaderString instanceof ArrayBuffer) {
  1878. return;
  1879. }
  1880. gltfRuntime.loadedShaderCount++;
  1881. if (shaderString) {
  1882. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore[sha + (shader.type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EShaderType"].VERTEX ? "VertexShader" : "PixelShader")] = shaderString;
  1883. }
  1884. if (gltfRuntime.loadedShaderCount === gltfRuntime.shaderscount) {
  1885. onload();
  1886. }
  1887. }, function () {
  1888. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Error when loading shader program named " + sha + " located at " + shader.uri);
  1889. });
  1890. };
  1891. for (var sha in gltfRuntime.shaders) {
  1892. hasShaders = true;
  1893. var shader = gltfRuntime.shaders[sha];
  1894. if (shader) {
  1895. processShader.bind(this, sha, shader)();
  1896. }
  1897. else {
  1898. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("No shader named: " + sha);
  1899. }
  1900. }
  1901. if (!hasShaders) {
  1902. onload();
  1903. }
  1904. };
  1905. GLTFLoader.prototype._loadBuffersAsync = function (gltfRuntime, onLoad, onProgress) {
  1906. var hasBuffers = false;
  1907. var processBuffer = function (buf, buffer) {
  1908. GLTFLoaderExtension.LoadBufferAsync(gltfRuntime, buf, function (bufferView) {
  1909. gltfRuntime.loadedBufferCount++;
  1910. if (bufferView) {
  1911. if (bufferView.byteLength != gltfRuntime.buffers[buf].byteLength) {
  1912. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Buffer named " + buf + " is length " + bufferView.byteLength + ". Expected: " + buffer.byteLength); // Improve error message
  1913. }
  1914. gltfRuntime.loadedBufferViews[buf] = bufferView;
  1915. }
  1916. if (gltfRuntime.loadedBufferCount === gltfRuntime.buffersCount) {
  1917. onLoad();
  1918. }
  1919. }, function () {
  1920. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Error when loading buffer named " + buf + " located at " + buffer.uri);
  1921. });
  1922. };
  1923. for (var buf in gltfRuntime.buffers) {
  1924. hasBuffers = true;
  1925. var buffer = gltfRuntime.buffers[buf];
  1926. if (buffer) {
  1927. processBuffer.bind(this, buf, buffer)();
  1928. }
  1929. else {
  1930. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("No buffer named: " + buf);
  1931. }
  1932. }
  1933. if (!hasBuffers) {
  1934. onLoad();
  1935. }
  1936. };
  1937. GLTFLoader.prototype._createNodes = function (gltfRuntime) {
  1938. var currentScene = gltfRuntime.currentScene;
  1939. if (currentScene) {
  1940. // Only one scene even if multiple scenes are defined
  1941. for (var i = 0; i < currentScene.nodes.length; i++) {
  1942. traverseNodes(gltfRuntime, currentScene.nodes[i], null);
  1943. }
  1944. }
  1945. else {
  1946. // Load all scenes
  1947. for (var thing in gltfRuntime.scenes) {
  1948. currentScene = gltfRuntime.scenes[thing];
  1949. for (var i = 0; i < currentScene.nodes.length; i++) {
  1950. traverseNodes(gltfRuntime, currentScene.nodes[i], null);
  1951. }
  1952. }
  1953. }
  1954. };
  1955. GLTFLoader.Extensions = {};
  1956. return GLTFLoader;
  1957. }());
  1958. /** @hidden */
  1959. var GLTFLoaderExtension = /** @class */ (function () {
  1960. function GLTFLoaderExtension(name) {
  1961. this._name = name;
  1962. }
  1963. Object.defineProperty(GLTFLoaderExtension.prototype, "name", {
  1964. get: function () {
  1965. return this._name;
  1966. },
  1967. enumerable: false,
  1968. configurable: true
  1969. });
  1970. /**
  1971. * Defines an override for loading the runtime
  1972. * Return true to stop further extensions from loading the runtime
  1973. */
  1974. GLTFLoaderExtension.prototype.loadRuntimeAsync = function (scene, data, rootUrl, onSuccess, onError) {
  1975. return false;
  1976. };
  1977. /**
  1978. * Defines an onverride for creating gltf runtime
  1979. * Return true to stop further extensions from creating the runtime
  1980. */
  1981. GLTFLoaderExtension.prototype.loadRuntimeExtensionsAsync = function (gltfRuntime, onSuccess, onError) {
  1982. return false;
  1983. };
  1984. /**
  1985. * Defines an override for loading buffers
  1986. * Return true to stop further extensions from loading this buffer
  1987. */
  1988. GLTFLoaderExtension.prototype.loadBufferAsync = function (gltfRuntime, id, onSuccess, onError, onProgress) {
  1989. return false;
  1990. };
  1991. /**
  1992. * Defines an override for loading texture buffers
  1993. * Return true to stop further extensions from loading this texture data
  1994. */
  1995. GLTFLoaderExtension.prototype.loadTextureBufferAsync = function (gltfRuntime, id, onSuccess, onError) {
  1996. return false;
  1997. };
  1998. /**
  1999. * Defines an override for creating textures
  2000. * Return true to stop further extensions from loading this texture
  2001. */
  2002. GLTFLoaderExtension.prototype.createTextureAsync = function (gltfRuntime, id, buffer, onSuccess, onError) {
  2003. return false;
  2004. };
  2005. /**
  2006. * Defines an override for loading shader strings
  2007. * Return true to stop further extensions from loading this shader data
  2008. */
  2009. GLTFLoaderExtension.prototype.loadShaderStringAsync = function (gltfRuntime, id, onSuccess, onError) {
  2010. return false;
  2011. };
  2012. /**
  2013. * Defines an override for loading materials
  2014. * Return true to stop further extensions from loading this material
  2015. */
  2016. GLTFLoaderExtension.prototype.loadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) {
  2017. return false;
  2018. };
  2019. // ---------
  2020. // Utilities
  2021. // ---------
  2022. GLTFLoaderExtension.LoadRuntimeAsync = function (scene, data, rootUrl, onSuccess, onError) {
  2023. GLTFLoaderExtension.ApplyExtensions(function (loaderExtension) {
  2024. return loaderExtension.loadRuntimeAsync(scene, data, rootUrl, onSuccess, onError);
  2025. }, function () {
  2026. setTimeout(function () {
  2027. if (!onSuccess) {
  2028. return;
  2029. }
  2030. onSuccess(GLTFLoaderBase.CreateRuntime(data.json, scene, rootUrl));
  2031. });
  2032. });
  2033. };
  2034. GLTFLoaderExtension.LoadRuntimeExtensionsAsync = function (gltfRuntime, onSuccess, onError) {
  2035. GLTFLoaderExtension.ApplyExtensions(function (loaderExtension) {
  2036. return loaderExtension.loadRuntimeExtensionsAsync(gltfRuntime, onSuccess, onError);
  2037. }, function () {
  2038. setTimeout(function () {
  2039. onSuccess();
  2040. });
  2041. });
  2042. };
  2043. GLTFLoaderExtension.LoadBufferAsync = function (gltfRuntime, id, onSuccess, onError, onProgress) {
  2044. GLTFLoaderExtension.ApplyExtensions(function (loaderExtension) {
  2045. return loaderExtension.loadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress);
  2046. }, function () {
  2047. GLTFLoaderBase.LoadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress);
  2048. });
  2049. };
  2050. GLTFLoaderExtension.LoadTextureAsync = function (gltfRuntime, id, onSuccess, onError) {
  2051. GLTFLoaderExtension.LoadTextureBufferAsync(gltfRuntime, id, function (buffer) {
  2052. if (buffer) {
  2053. GLTFLoaderExtension.CreateTextureAsync(gltfRuntime, id, buffer, onSuccess, onError);
  2054. }
  2055. }, onError);
  2056. };
  2057. GLTFLoaderExtension.LoadShaderStringAsync = function (gltfRuntime, id, onSuccess, onError) {
  2058. GLTFLoaderExtension.ApplyExtensions(function (loaderExtension) {
  2059. return loaderExtension.loadShaderStringAsync(gltfRuntime, id, onSuccess, onError);
  2060. }, function () {
  2061. GLTFLoaderBase.LoadShaderStringAsync(gltfRuntime, id, onSuccess, onError);
  2062. });
  2063. };
  2064. GLTFLoaderExtension.LoadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) {
  2065. GLTFLoaderExtension.ApplyExtensions(function (loaderExtension) {
  2066. return loaderExtension.loadMaterialAsync(gltfRuntime, id, onSuccess, onError);
  2067. }, function () {
  2068. GLTFLoaderBase.LoadMaterialAsync(gltfRuntime, id, onSuccess, onError);
  2069. });
  2070. };
  2071. GLTFLoaderExtension.LoadTextureBufferAsync = function (gltfRuntime, id, onSuccess, onError) {
  2072. GLTFLoaderExtension.ApplyExtensions(function (loaderExtension) {
  2073. return loaderExtension.loadTextureBufferAsync(gltfRuntime, id, onSuccess, onError);
  2074. }, function () {
  2075. GLTFLoaderBase.LoadTextureBufferAsync(gltfRuntime, id, onSuccess, onError);
  2076. });
  2077. };
  2078. GLTFLoaderExtension.CreateTextureAsync = function (gltfRuntime, id, buffer, onSuccess, onError) {
  2079. GLTFLoaderExtension.ApplyExtensions(function (loaderExtension) {
  2080. return loaderExtension.createTextureAsync(gltfRuntime, id, buffer, onSuccess, onError);
  2081. }, function () {
  2082. GLTFLoaderBase.CreateTextureAsync(gltfRuntime, id, buffer, onSuccess, onError);
  2083. });
  2084. };
  2085. GLTFLoaderExtension.ApplyExtensions = function (func, defaultFunc) {
  2086. for (var extensionName in GLTFLoader.Extensions) {
  2087. var loaderExtension = GLTFLoader.Extensions[extensionName];
  2088. if (func(loaderExtension)) {
  2089. return;
  2090. }
  2091. }
  2092. defaultFunc();
  2093. };
  2094. return GLTFLoaderExtension;
  2095. }());
  2096. _glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__["GLTFFileLoader"]._CreateGLTF1Loader = function () { return new GLTFLoader(); };
  2097. /***/ }),
  2098. /***/ "./glTF/1.0/glTFLoaderInterfaces.ts":
  2099. /*!******************************************!*\
  2100. !*** ./glTF/1.0/glTFLoaderInterfaces.ts ***!
  2101. \******************************************/
  2102. /*! exports provided: EComponentType, EShaderType, EParameterType, ETextureWrapMode, ETextureFilterType, ETextureFormat, ECullingType, EBlendingFunction */
  2103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2104. "use strict";
  2105. __webpack_require__.r(__webpack_exports__);
  2106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EComponentType", function() { return EComponentType; });
  2107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EShaderType", function() { return EShaderType; });
  2108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EParameterType", function() { return EParameterType; });
  2109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ETextureWrapMode", function() { return ETextureWrapMode; });
  2110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ETextureFilterType", function() { return ETextureFilterType; });
  2111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ETextureFormat", function() { return ETextureFormat; });
  2112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ECullingType", function() { return ECullingType; });
  2113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EBlendingFunction", function() { return EBlendingFunction; });
  2114. /**
  2115. * Enums
  2116. * @hidden
  2117. */
  2118. var EComponentType;
  2119. (function (EComponentType) {
  2120. EComponentType[EComponentType["BYTE"] = 5120] = "BYTE";
  2121. EComponentType[EComponentType["UNSIGNED_BYTE"] = 5121] = "UNSIGNED_BYTE";
  2122. EComponentType[EComponentType["SHORT"] = 5122] = "SHORT";
  2123. EComponentType[EComponentType["UNSIGNED_SHORT"] = 5123] = "UNSIGNED_SHORT";
  2124. EComponentType[EComponentType["FLOAT"] = 5126] = "FLOAT";
  2125. })(EComponentType || (EComponentType = {}));
  2126. /** @hidden */
  2127. var EShaderType;
  2128. (function (EShaderType) {
  2129. EShaderType[EShaderType["FRAGMENT"] = 35632] = "FRAGMENT";
  2130. EShaderType[EShaderType["VERTEX"] = 35633] = "VERTEX";
  2131. })(EShaderType || (EShaderType = {}));
  2132. /** @hidden */
  2133. var EParameterType;
  2134. (function (EParameterType) {
  2135. EParameterType[EParameterType["BYTE"] = 5120] = "BYTE";
  2136. EParameterType[EParameterType["UNSIGNED_BYTE"] = 5121] = "UNSIGNED_BYTE";
  2137. EParameterType[EParameterType["SHORT"] = 5122] = "SHORT";
  2138. EParameterType[EParameterType["UNSIGNED_SHORT"] = 5123] = "UNSIGNED_SHORT";
  2139. EParameterType[EParameterType["INT"] = 5124] = "INT";
  2140. EParameterType[EParameterType["UNSIGNED_INT"] = 5125] = "UNSIGNED_INT";
  2141. EParameterType[EParameterType["FLOAT"] = 5126] = "FLOAT";
  2142. EParameterType[EParameterType["FLOAT_VEC2"] = 35664] = "FLOAT_VEC2";
  2143. EParameterType[EParameterType["FLOAT_VEC3"] = 35665] = "FLOAT_VEC3";
  2144. EParameterType[EParameterType["FLOAT_VEC4"] = 35666] = "FLOAT_VEC4";
  2145. EParameterType[EParameterType["INT_VEC2"] = 35667] = "INT_VEC2";
  2146. EParameterType[EParameterType["INT_VEC3"] = 35668] = "INT_VEC3";
  2147. EParameterType[EParameterType["INT_VEC4"] = 35669] = "INT_VEC4";
  2148. EParameterType[EParameterType["BOOL"] = 35670] = "BOOL";
  2149. EParameterType[EParameterType["BOOL_VEC2"] = 35671] = "BOOL_VEC2";
  2150. EParameterType[EParameterType["BOOL_VEC3"] = 35672] = "BOOL_VEC3";
  2151. EParameterType[EParameterType["BOOL_VEC4"] = 35673] = "BOOL_VEC4";
  2152. EParameterType[EParameterType["FLOAT_MAT2"] = 35674] = "FLOAT_MAT2";
  2153. EParameterType[EParameterType["FLOAT_MAT3"] = 35675] = "FLOAT_MAT3";
  2154. EParameterType[EParameterType["FLOAT_MAT4"] = 35676] = "FLOAT_MAT4";
  2155. EParameterType[EParameterType["SAMPLER_2D"] = 35678] = "SAMPLER_2D";
  2156. })(EParameterType || (EParameterType = {}));
  2157. /** @hidden */
  2158. var ETextureWrapMode;
  2159. (function (ETextureWrapMode) {
  2160. ETextureWrapMode[ETextureWrapMode["CLAMP_TO_EDGE"] = 33071] = "CLAMP_TO_EDGE";
  2161. ETextureWrapMode[ETextureWrapMode["MIRRORED_REPEAT"] = 33648] = "MIRRORED_REPEAT";
  2162. ETextureWrapMode[ETextureWrapMode["REPEAT"] = 10497] = "REPEAT";
  2163. })(ETextureWrapMode || (ETextureWrapMode = {}));
  2164. /** @hidden */
  2165. var ETextureFilterType;
  2166. (function (ETextureFilterType) {
  2167. ETextureFilterType[ETextureFilterType["NEAREST"] = 9728] = "NEAREST";
  2168. ETextureFilterType[ETextureFilterType["LINEAR"] = 9728] = "LINEAR";
  2169. ETextureFilterType[ETextureFilterType["NEAREST_MIPMAP_NEAREST"] = 9984] = "NEAREST_MIPMAP_NEAREST";
  2170. ETextureFilterType[ETextureFilterType["LINEAR_MIPMAP_NEAREST"] = 9985] = "LINEAR_MIPMAP_NEAREST";
  2171. ETextureFilterType[ETextureFilterType["NEAREST_MIPMAP_LINEAR"] = 9986] = "NEAREST_MIPMAP_LINEAR";
  2172. ETextureFilterType[ETextureFilterType["LINEAR_MIPMAP_LINEAR"] = 9987] = "LINEAR_MIPMAP_LINEAR";
  2173. })(ETextureFilterType || (ETextureFilterType = {}));
  2174. /** @hidden */
  2175. var ETextureFormat;
  2176. (function (ETextureFormat) {
  2177. ETextureFormat[ETextureFormat["ALPHA"] = 6406] = "ALPHA";
  2178. ETextureFormat[ETextureFormat["RGB"] = 6407] = "RGB";
  2179. ETextureFormat[ETextureFormat["RGBA"] = 6408] = "RGBA";
  2180. ETextureFormat[ETextureFormat["LUMINANCE"] = 6409] = "LUMINANCE";
  2181. ETextureFormat[ETextureFormat["LUMINANCE_ALPHA"] = 6410] = "LUMINANCE_ALPHA";
  2182. })(ETextureFormat || (ETextureFormat = {}));
  2183. /** @hidden */
  2184. var ECullingType;
  2185. (function (ECullingType) {
  2186. ECullingType[ECullingType["FRONT"] = 1028] = "FRONT";
  2187. ECullingType[ECullingType["BACK"] = 1029] = "BACK";
  2188. ECullingType[ECullingType["FRONT_AND_BACK"] = 1032] = "FRONT_AND_BACK";
  2189. })(ECullingType || (ECullingType = {}));
  2190. /** @hidden */
  2191. var EBlendingFunction;
  2192. (function (EBlendingFunction) {
  2193. EBlendingFunction[EBlendingFunction["ZERO"] = 0] = "ZERO";
  2194. EBlendingFunction[EBlendingFunction["ONE"] = 1] = "ONE";
  2195. EBlendingFunction[EBlendingFunction["SRC_COLOR"] = 768] = "SRC_COLOR";
  2196. EBlendingFunction[EBlendingFunction["ONE_MINUS_SRC_COLOR"] = 769] = "ONE_MINUS_SRC_COLOR";
  2197. EBlendingFunction[EBlendingFunction["DST_COLOR"] = 774] = "DST_COLOR";
  2198. EBlendingFunction[EBlendingFunction["ONE_MINUS_DST_COLOR"] = 775] = "ONE_MINUS_DST_COLOR";
  2199. EBlendingFunction[EBlendingFunction["SRC_ALPHA"] = 770] = "SRC_ALPHA";
  2200. EBlendingFunction[EBlendingFunction["ONE_MINUS_SRC_ALPHA"] = 771] = "ONE_MINUS_SRC_ALPHA";
  2201. EBlendingFunction[EBlendingFunction["DST_ALPHA"] = 772] = "DST_ALPHA";
  2202. EBlendingFunction[EBlendingFunction["ONE_MINUS_DST_ALPHA"] = 773] = "ONE_MINUS_DST_ALPHA";
  2203. EBlendingFunction[EBlendingFunction["CONSTANT_COLOR"] = 32769] = "CONSTANT_COLOR";
  2204. EBlendingFunction[EBlendingFunction["ONE_MINUS_CONSTANT_COLOR"] = 32770] = "ONE_MINUS_CONSTANT_COLOR";
  2205. EBlendingFunction[EBlendingFunction["CONSTANT_ALPHA"] = 32771] = "CONSTANT_ALPHA";
  2206. EBlendingFunction[EBlendingFunction["ONE_MINUS_CONSTANT_ALPHA"] = 32772] = "ONE_MINUS_CONSTANT_ALPHA";
  2207. EBlendingFunction[EBlendingFunction["SRC_ALPHA_SATURATE"] = 776] = "SRC_ALPHA_SATURATE";
  2208. })(EBlendingFunction || (EBlendingFunction = {}));
  2209. /***/ }),
  2210. /***/ "./glTF/1.0/glTFLoaderUtils.ts":
  2211. /*!*************************************!*\
  2212. !*** ./glTF/1.0/glTFLoaderUtils.ts ***!
  2213. \*************************************/
  2214. /*! exports provided: GLTFUtils */
  2215. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2216. "use strict";
  2217. __webpack_require__.r(__webpack_exports__);
  2218. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GLTFUtils", function() { return GLTFUtils; });
  2219. /* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "./glTF/1.0/glTFLoaderInterfaces.ts");
  2220. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/tools");
  2221. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  2222. /**
  2223. * Utils functions for GLTF
  2224. * @hidden
  2225. */
  2226. var GLTFUtils = /** @class */ (function () {
  2227. function GLTFUtils() {
  2228. }
  2229. /**
  2230. * Sets the given "parameter" matrix
  2231. * @param scene: the Scene object
  2232. * @param source: the source node where to pick the matrix
  2233. * @param parameter: the GLTF technique parameter
  2234. * @param uniformName: the name of the shader's uniform
  2235. * @param shaderMaterial: the shader material
  2236. */
  2237. GLTFUtils.SetMatrix = function (scene, source, parameter, uniformName, shaderMaterial) {
  2238. var mat = null;
  2239. if (parameter.semantic === "MODEL") {
  2240. mat = source.getWorldMatrix();
  2241. }
  2242. else if (parameter.semantic === "PROJECTION") {
  2243. mat = scene.getProjectionMatrix();
  2244. }
  2245. else if (parameter.semantic === "VIEW") {
  2246. mat = scene.getViewMatrix();
  2247. }
  2248. else if (parameter.semantic === "MODELVIEWINVERSETRANSPOSE") {
  2249. mat = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Transpose(source.getWorldMatrix().multiply(scene.getViewMatrix()).invert());
  2250. }
  2251. else if (parameter.semantic === "MODELVIEW") {
  2252. mat = source.getWorldMatrix().multiply(scene.getViewMatrix());
  2253. }
  2254. else if (parameter.semantic === "MODELVIEWPROJECTION") {
  2255. mat = source.getWorldMatrix().multiply(scene.getTransformMatrix());
  2256. }
  2257. else if (parameter.semantic === "MODELINVERSE") {
  2258. mat = source.getWorldMatrix().invert();
  2259. }
  2260. else if (parameter.semantic === "VIEWINVERSE") {
  2261. mat = scene.getViewMatrix().invert();
  2262. }
  2263. else if (parameter.semantic === "PROJECTIONINVERSE") {
  2264. mat = scene.getProjectionMatrix().invert();
  2265. }
  2266. else if (parameter.semantic === "MODELVIEWINVERSE") {
  2267. mat = source.getWorldMatrix().multiply(scene.getViewMatrix()).invert();
  2268. }
  2269. else if (parameter.semantic === "MODELVIEWPROJECTIONINVERSE") {
  2270. mat = source.getWorldMatrix().multiply(scene.getTransformMatrix()).invert();
  2271. }
  2272. else if (parameter.semantic === "MODELINVERSETRANSPOSE") {
  2273. mat = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Transpose(source.getWorldMatrix().invert());
  2274. }
  2275. else {
  2276. debugger;
  2277. }
  2278. if (mat) {
  2279. switch (parameter.type) {
  2280. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EParameterType"].FLOAT_MAT2:
  2281. shaderMaterial.setMatrix2x2(uniformName, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].GetAsMatrix2x2(mat));
  2282. break;
  2283. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EParameterType"].FLOAT_MAT3:
  2284. shaderMaterial.setMatrix3x3(uniformName, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].GetAsMatrix3x3(mat));
  2285. break;
  2286. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EParameterType"].FLOAT_MAT4:
  2287. shaderMaterial.setMatrix(uniformName, mat);
  2288. break;
  2289. default: break;
  2290. }
  2291. }
  2292. };
  2293. /**
  2294. * Sets the given "parameter" matrix
  2295. * @param shaderMaterial: the shader material
  2296. * @param uniform: the name of the shader's uniform
  2297. * @param value: the value of the uniform
  2298. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  2299. */
  2300. GLTFUtils.SetUniform = function (shaderMaterial, uniform, value, type) {
  2301. switch (type) {
  2302. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EParameterType"].FLOAT:
  2303. shaderMaterial.setFloat(uniform, value);
  2304. return true;
  2305. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EParameterType"].FLOAT_VEC2:
  2306. shaderMaterial.setVector2(uniform, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"].FromArray(value));
  2307. return true;
  2308. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EParameterType"].FLOAT_VEC3:
  2309. shaderMaterial.setVector3(uniform, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(value));
  2310. return true;
  2311. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EParameterType"].FLOAT_VEC4:
  2312. shaderMaterial.setVector4(uniform, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"].FromArray(value));
  2313. return true;
  2314. default: return false;
  2315. }
  2316. };
  2317. /**
  2318. * Returns the wrap mode of the texture
  2319. * @param mode: the mode value
  2320. */
  2321. GLTFUtils.GetWrapMode = function (mode) {
  2322. switch (mode) {
  2323. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["ETextureWrapMode"].CLAMP_TO_EDGE: return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  2324. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["ETextureWrapMode"].MIRRORED_REPEAT: return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Texture"].MIRROR_ADDRESSMODE;
  2325. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["ETextureWrapMode"].REPEAT: return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  2326. default: return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  2327. }
  2328. };
  2329. /**
  2330. * Returns the byte stride giving an accessor
  2331. * @param accessor: the GLTF accessor objet
  2332. */
  2333. GLTFUtils.GetByteStrideFromType = function (accessor) {
  2334. // Needs this function since "byteStride" isn't requiered in glTF format
  2335. var type = accessor.type;
  2336. switch (type) {
  2337. case "VEC2": return 2;
  2338. case "VEC3": return 3;
  2339. case "VEC4": return 4;
  2340. case "MAT2": return 4;
  2341. case "MAT3": return 9;
  2342. case "MAT4": return 16;
  2343. default: return 1;
  2344. }
  2345. };
  2346. /**
  2347. * Returns the texture filter mode giving a mode value
  2348. * @param mode: the filter mode value
  2349. */
  2350. GLTFUtils.GetTextureFilterMode = function (mode) {
  2351. switch (mode) {
  2352. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["ETextureFilterType"].LINEAR:
  2353. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["ETextureFilterType"].LINEAR_MIPMAP_NEAREST:
  2354. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["ETextureFilterType"].LINEAR_MIPMAP_LINEAR: return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE;
  2355. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["ETextureFilterType"].NEAREST:
  2356. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["ETextureFilterType"].NEAREST_MIPMAP_NEAREST: return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE;
  2357. default: return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE;
  2358. }
  2359. };
  2360. GLTFUtils.GetBufferFromBufferView = function (gltfRuntime, bufferView, byteOffset, byteLength, componentType) {
  2361. var byteOffset = bufferView.byteOffset + byteOffset;
  2362. var loadedBufferView = gltfRuntime.loadedBufferViews[bufferView.buffer];
  2363. if (byteOffset + byteLength > loadedBufferView.byteLength) {
  2364. throw new Error("Buffer access is out of range");
  2365. }
  2366. var buffer = loadedBufferView.buffer;
  2367. byteOffset += loadedBufferView.byteOffset;
  2368. switch (componentType) {
  2369. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EComponentType"].BYTE: return new Int8Array(buffer, byteOffset, byteLength);
  2370. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EComponentType"].UNSIGNED_BYTE: return new Uint8Array(buffer, byteOffset, byteLength);
  2371. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EComponentType"].SHORT: return new Int16Array(buffer, byteOffset, byteLength);
  2372. case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__["EComponentType"].UNSIGNED_SHORT: return new Uint16Array(buffer, byteOffset, byteLength);
  2373. default: return new Float32Array(buffer, byteOffset, byteLength);
  2374. }
  2375. };
  2376. /**
  2377. * Returns a buffer from its accessor
  2378. * @param gltfRuntime: the GLTF runtime
  2379. * @param accessor: the GLTF accessor
  2380. */
  2381. GLTFUtils.GetBufferFromAccessor = function (gltfRuntime, accessor) {
  2382. var bufferView = gltfRuntime.bufferViews[accessor.bufferView];
  2383. var byteLength = accessor.count * GLTFUtils.GetByteStrideFromType(accessor);
  2384. return GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, accessor.byteOffset, byteLength, accessor.componentType);
  2385. };
  2386. /**
  2387. * Decodes a buffer view into a string
  2388. * @param view: the buffer view
  2389. */
  2390. GLTFUtils.DecodeBufferToText = function (view) {
  2391. var result = "";
  2392. var length = view.byteLength;
  2393. for (var i = 0; i < length; ++i) {
  2394. result += String.fromCharCode(view[i]);
  2395. }
  2396. return result;
  2397. };
  2398. /**
  2399. * Returns the default material of gltf. Related to
  2400. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  2401. * @param scene: the Babylon.js scene
  2402. */
  2403. GLTFUtils.GetDefaultMaterial = function (scene) {
  2404. if (!GLTFUtils._DefaultMaterial) {
  2405. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore["GLTFDefaultMaterialVertexShader"] = [
  2406. "precision highp float;",
  2407. "",
  2408. "uniform mat4 worldView;",
  2409. "uniform mat4 projection;",
  2410. "",
  2411. "attribute vec3 position;",
  2412. "",
  2413. "void main(void)",
  2414. "{",
  2415. " gl_Position = projection * worldView * vec4(position, 1.0);",
  2416. "}"
  2417. ].join("\n");
  2418. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Effect"].ShadersStore["GLTFDefaultMaterialPixelShader"] = [
  2419. "precision highp float;",
  2420. "",
  2421. "uniform vec4 u_emission;",
  2422. "",
  2423. "void main(void)",
  2424. "{",
  2425. " gl_FragColor = u_emission;",
  2426. "}"
  2427. ].join("\n");
  2428. var shaderPath = {
  2429. vertex: "GLTFDefaultMaterial",
  2430. fragment: "GLTFDefaultMaterial"
  2431. };
  2432. var options = {
  2433. attributes: ["position"],
  2434. uniforms: ["worldView", "projection", "u_emission"],
  2435. samplers: new Array(),
  2436. needAlphaBlending: false
  2437. };
  2438. GLTFUtils._DefaultMaterial = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["ShaderMaterial"]("GLTFDefaultMaterial", scene, shaderPath, options);
  2439. GLTFUtils._DefaultMaterial.setColor4("u_emission", new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.5, 0.5, 0.5, 1.0));
  2440. }
  2441. return GLTFUtils._DefaultMaterial;
  2442. };
  2443. // The GLTF default material
  2444. GLTFUtils._DefaultMaterial = null;
  2445. return GLTFUtils;
  2446. }());
  2447. /***/ }),
  2448. /***/ "./glTF/1.0/glTFMaterialsCommonExtension.ts":
  2449. /*!**************************************************!*\
  2450. !*** ./glTF/1.0/glTFMaterialsCommonExtension.ts ***!
  2451. \**************************************************/
  2452. /*! exports provided: GLTFMaterialsCommonExtension */
  2453. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2454. "use strict";
  2455. __webpack_require__.r(__webpack_exports__);
  2456. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GLTFMaterialsCommonExtension", function() { return GLTFMaterialsCommonExtension; });
  2457. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  2458. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFLoader */ "./glTF/1.0/glTFLoader.ts");
  2459. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/tools");
  2460. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__);
  2461. /** @hidden */
  2462. var GLTFMaterialsCommonExtension = /** @class */ (function (_super) {
  2463. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(GLTFMaterialsCommonExtension, _super);
  2464. function GLTFMaterialsCommonExtension() {
  2465. return _super.call(this, "KHR_materials_common") || this;
  2466. }
  2467. GLTFMaterialsCommonExtension.prototype.loadRuntimeExtensionsAsync = function (gltfRuntime, onSuccess, onError) {
  2468. if (!gltfRuntime.extensions) {
  2469. return false;
  2470. }
  2471. var extension = gltfRuntime.extensions[this.name];
  2472. if (!extension) {
  2473. return false;
  2474. }
  2475. // Create lights
  2476. var lights = extension.lights;
  2477. if (lights) {
  2478. for (var thing in lights) {
  2479. var light = lights[thing];
  2480. switch (light.type) {
  2481. case "ambient":
  2482. var ambientLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["HemisphericLight"](light.name, new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1, 0), gltfRuntime.scene);
  2483. var ambient = light.ambient;
  2484. if (ambient) {
  2485. ambientLight.diffuse = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(ambient.color || [1, 1, 1]);
  2486. }
  2487. break;
  2488. case "point":
  2489. var pointLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["PointLight"](light.name, new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](10, 10, 10), gltfRuntime.scene);
  2490. var point = light.point;
  2491. if (point) {
  2492. pointLight.diffuse = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(point.color || [1, 1, 1]);
  2493. }
  2494. break;
  2495. case "directional":
  2496. var dirLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["DirectionalLight"](light.name, new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, -1, 0), gltfRuntime.scene);
  2497. var directional = light.directional;
  2498. if (directional) {
  2499. dirLight.diffuse = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(directional.color || [1, 1, 1]);
  2500. }
  2501. break;
  2502. case "spot":
  2503. var spot = light.spot;
  2504. if (spot) {
  2505. var spotLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["SpotLight"](light.name, new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 10, 0), new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, -1, 0), spot.fallOffAngle || Math.PI, spot.fallOffExponent || 0.0, gltfRuntime.scene);
  2506. spotLight.diffuse = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(spot.color || [1, 1, 1]);
  2507. }
  2508. break;
  2509. default:
  2510. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Tools"].Warn("GLTF Material Common extension: light type \"" + light.type + "\” not supported");
  2511. break;
  2512. }
  2513. }
  2514. }
  2515. return false;
  2516. };
  2517. GLTFMaterialsCommonExtension.prototype.loadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) {
  2518. var material = gltfRuntime.materials[id];
  2519. if (!material || !material.extensions) {
  2520. return false;
  2521. }
  2522. var extension = material.extensions[this.name];
  2523. if (!extension) {
  2524. return false;
  2525. }
  2526. var standardMaterial = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](id, gltfRuntime.scene);
  2527. standardMaterial.sideOrientation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Material"].CounterClockWiseSideOrientation;
  2528. if (extension.technique === "CONSTANT") {
  2529. standardMaterial.disableLighting = true;
  2530. }
  2531. standardMaterial.backFaceCulling = extension.doubleSided === undefined ? false : !extension.doubleSided;
  2532. standardMaterial.alpha = extension.values.transparency === undefined ? 1.0 : extension.values.transparency;
  2533. standardMaterial.specularPower = extension.values.shininess === undefined ? 0.0 : extension.values.shininess;
  2534. // Ambient
  2535. if (typeof extension.values.ambient === "string") {
  2536. this._loadTexture(gltfRuntime, extension.values.ambient, standardMaterial, "ambientTexture", onError);
  2537. }
  2538. else {
  2539. standardMaterial.ambientColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(extension.values.ambient || [0, 0, 0]);
  2540. }
  2541. // Diffuse
  2542. if (typeof extension.values.diffuse === "string") {
  2543. this._loadTexture(gltfRuntime, extension.values.diffuse, standardMaterial, "diffuseTexture", onError);
  2544. }
  2545. else {
  2546. standardMaterial.diffuseColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(extension.values.diffuse || [0, 0, 0]);
  2547. }
  2548. // Emission
  2549. if (typeof extension.values.emission === "string") {
  2550. this._loadTexture(gltfRuntime, extension.values.emission, standardMaterial, "emissiveTexture", onError);
  2551. }
  2552. else {
  2553. standardMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(extension.values.emission || [0, 0, 0]);
  2554. }
  2555. // Specular
  2556. if (typeof extension.values.specular === "string") {
  2557. this._loadTexture(gltfRuntime, extension.values.specular, standardMaterial, "specularTexture", onError);
  2558. }
  2559. else {
  2560. standardMaterial.specularColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(extension.values.specular || [0, 0, 0]);
  2561. }
  2562. return true;
  2563. };
  2564. GLTFMaterialsCommonExtension.prototype._loadTexture = function (gltfRuntime, id, material, propertyPath, onError) {
  2565. // Create buffer from texture url
  2566. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderBase"].LoadTextureBufferAsync(gltfRuntime, id, function (buffer) {
  2567. // Create texture from buffer
  2568. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderBase"].CreateTextureAsync(gltfRuntime, id, buffer, function (texture) { return material[propertyPath] = texture; }, onError);
  2569. }, onError);
  2570. };
  2571. return GLTFMaterialsCommonExtension;
  2572. }(_glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderExtension"]));
  2573. _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"].RegisterExtension(new GLTFMaterialsCommonExtension());
  2574. /***/ }),
  2575. /***/ "./glTF/1.0/index.ts":
  2576. /*!***************************!*\
  2577. !*** ./glTF/1.0/index.ts ***!
  2578. \***************************/
  2579. /*! exports provided: GLTFBinaryExtension, GLTFLoaderBase, GLTFLoader, GLTFLoaderExtension, EComponentType, EShaderType, EParameterType, ETextureWrapMode, ETextureFilterType, ETextureFormat, ECullingType, EBlendingFunction, GLTFUtils, GLTFMaterialsCommonExtension */
  2580. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2581. "use strict";
  2582. __webpack_require__.r(__webpack_exports__);
  2583. /* harmony import */ var _glTFBinaryExtension__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFBinaryExtension */ "./glTF/1.0/glTFBinaryExtension.ts");
  2584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFBinaryExtension", function() { return _glTFBinaryExtension__WEBPACK_IMPORTED_MODULE_0__["GLTFBinaryExtension"]; });
  2585. /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFLoader */ "./glTF/1.0/glTFLoader.ts");
  2586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFLoaderBase", function() { return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderBase"]; });
  2587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFLoader", function() { return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoader"]; });
  2588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFLoaderExtension", function() { return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__["GLTFLoaderExtension"]; });
  2589. /* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "./glTF/1.0/glTFLoaderInterfaces.ts");
  2590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EComponentType", function() { return _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__["EComponentType"]; });
  2591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EShaderType", function() { return _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__["EShaderType"]; });
  2592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EParameterType", function() { return _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__["EParameterType"]; });
  2593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ETextureWrapMode", function() { return _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__["ETextureWrapMode"]; });
  2594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ETextureFilterType", function() { return _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__["ETextureFilterType"]; });
  2595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ETextureFormat", function() { return _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__["ETextureFormat"]; });
  2596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ECullingType", function() { return _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__["ECullingType"]; });
  2597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EBlendingFunction", function() { return _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__["EBlendingFunction"]; });
  2598. /* harmony import */ var _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./glTFLoaderUtils */ "./glTF/1.0/glTFLoaderUtils.ts");
  2599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFUtils", function() { return _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_3__["GLTFUtils"]; });
  2600. /* harmony import */ var _glTFMaterialsCommonExtension__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./glTFMaterialsCommonExtension */ "./glTF/1.0/glTFMaterialsCommonExtension.ts");
  2601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFMaterialsCommonExtension", function() { return _glTFMaterialsCommonExtension__WEBPACK_IMPORTED_MODULE_4__["GLTFMaterialsCommonExtension"]; });
  2602. /***/ }),
  2603. /***/ "./glTF/glTFFileLoader.ts":
  2604. /*!********************************!*\
  2605. !*** ./glTF/glTFFileLoader.ts ***!
  2606. \********************************/
  2607. /*! exports provided: GLTFLoaderCoordinateSystemMode, GLTFLoaderAnimationStartMode, GLTFLoaderState, GLTFFileLoader */
  2608. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2609. "use strict";
  2610. __webpack_require__.r(__webpack_exports__);
  2611. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GLTFLoaderCoordinateSystemMode", function() { return GLTFLoaderCoordinateSystemMode; });
  2612. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GLTFLoaderAnimationStartMode", function() { return GLTFLoaderAnimationStartMode; });
  2613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GLTFLoaderState", function() { return GLTFLoaderState; });
  2614. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GLTFFileLoader", function() { return GLTFFileLoader; });
  2615. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/tools");
  2616. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  2617. /* harmony import */ var _glTFValidation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFValidation */ "./glTF/glTFValidation.ts");
  2618. /**
  2619. * Mode that determines the coordinate system to use.
  2620. */
  2621. var GLTFLoaderCoordinateSystemMode;
  2622. (function (GLTFLoaderCoordinateSystemMode) {
  2623. /**
  2624. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  2625. */
  2626. GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["AUTO"] = 0] = "AUTO";
  2627. /**
  2628. * Sets the useRightHandedSystem flag on the scene.
  2629. */
  2630. GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["FORCE_RIGHT_HANDED"] = 1] = "FORCE_RIGHT_HANDED";
  2631. })(GLTFLoaderCoordinateSystemMode || (GLTFLoaderCoordinateSystemMode = {}));
  2632. /**
  2633. * Mode that determines what animations will start.
  2634. */
  2635. var GLTFLoaderAnimationStartMode;
  2636. (function (GLTFLoaderAnimationStartMode) {
  2637. /**
  2638. * No animation will start.
  2639. */
  2640. GLTFLoaderAnimationStartMode[GLTFLoaderAnimationStartMode["NONE"] = 0] = "NONE";
  2641. /**
  2642. * The first animation will start.
  2643. */
  2644. GLTFLoaderAnimationStartMode[GLTFLoaderAnimationStartMode["FIRST"] = 1] = "FIRST";
  2645. /**
  2646. * All animations will start.
  2647. */
  2648. GLTFLoaderAnimationStartMode[GLTFLoaderAnimationStartMode["ALL"] = 2] = "ALL";
  2649. })(GLTFLoaderAnimationStartMode || (GLTFLoaderAnimationStartMode = {}));
  2650. /**
  2651. * Loader state.
  2652. */
  2653. var GLTFLoaderState;
  2654. (function (GLTFLoaderState) {
  2655. /**
  2656. * The asset is loading.
  2657. */
  2658. GLTFLoaderState[GLTFLoaderState["LOADING"] = 0] = "LOADING";
  2659. /**
  2660. * The asset is ready for rendering.
  2661. */
  2662. GLTFLoaderState[GLTFLoaderState["READY"] = 1] = "READY";
  2663. /**
  2664. * The asset is completely loaded.
  2665. */
  2666. GLTFLoaderState[GLTFLoaderState["COMPLETE"] = 2] = "COMPLETE";
  2667. })(GLTFLoaderState || (GLTFLoaderState = {}));
  2668. /**
  2669. * File loader for loading glTF files into a scene.
  2670. */
  2671. var GLTFFileLoader = /** @class */ (function () {
  2672. function GLTFFileLoader() {
  2673. // --------------
  2674. // Common options
  2675. // --------------
  2676. /**
  2677. * Raised when the asset has been parsed
  2678. */
  2679. this.onParsedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  2680. // ----------
  2681. // V2 options
  2682. // ----------
  2683. /**
  2684. * The coordinate system mode. Defaults to AUTO.
  2685. */
  2686. this.coordinateSystemMode = GLTFLoaderCoordinateSystemMode.AUTO;
  2687. /**
  2688. * The animation start mode. Defaults to FIRST.
  2689. */
  2690. this.animationStartMode = GLTFLoaderAnimationStartMode.FIRST;
  2691. /**
  2692. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  2693. */
  2694. this.compileMaterials = false;
  2695. /**
  2696. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  2697. */
  2698. this.useClipPlane = false;
  2699. /**
  2700. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  2701. */
  2702. this.compileShadowGenerators = false;
  2703. /**
  2704. * Defines if the Alpha blended materials are only applied as coverage.
  2705. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  2706. * If true, no extra effects are applied to transparent pixels.
  2707. */
  2708. this.transparencyAsCoverage = false;
  2709. /**
  2710. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  2711. * Enabling will disable offline support and glTF validator.
  2712. * Defaults to false.
  2713. */
  2714. this.useRangeRequests = false;
  2715. /**
  2716. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  2717. */
  2718. this.createInstances = true;
  2719. /**
  2720. * Defines if the loader should always compute the bounding boxes of meshes and not use the min/max values from the position accessor. Defaults to false.
  2721. */
  2722. this.alwaysComputeBoundingBox = false;
  2723. /**
  2724. * Function called before loading a url referenced by the asset.
  2725. */
  2726. this.preprocessUrlAsync = function (url) { return Promise.resolve(url); };
  2727. /**
  2728. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  2729. */
  2730. this.onMeshLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  2731. /**
  2732. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  2733. */
  2734. this.onTextureLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  2735. /**
  2736. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  2737. */
  2738. this.onMaterialLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  2739. /**
  2740. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  2741. */
  2742. this.onCameraLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  2743. /**
  2744. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  2745. * For assets with LODs, raised when all of the LODs are complete.
  2746. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  2747. */
  2748. this.onCompleteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  2749. /**
  2750. * Observable raised when an error occurs.
  2751. */
  2752. this.onErrorObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  2753. /**
  2754. * Observable raised after the loader is disposed.
  2755. */
  2756. this.onDisposeObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  2757. /**
  2758. * Observable raised after a loader extension is created.
  2759. * Set additional options for a loader extension in this event.
  2760. */
  2761. this.onExtensionLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  2762. /**
  2763. * Defines if the loader should validate the asset.
  2764. */
  2765. this.validate = false;
  2766. /**
  2767. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  2768. */
  2769. this.onValidatedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  2770. this._loader = null;
  2771. this._requests = new Array();
  2772. /**
  2773. * Name of the loader ("gltf")
  2774. */
  2775. this.name = "gltf";
  2776. /** @hidden */
  2777. this.extensions = {
  2778. ".gltf": { isBinary: false },
  2779. ".glb": { isBinary: true }
  2780. };
  2781. this._logIndentLevel = 0;
  2782. this._loggingEnabled = false;
  2783. /** @hidden */
  2784. this._log = this._logDisabled;
  2785. this._capturePerformanceCounters = false;
  2786. /** @hidden */
  2787. this._startPerformanceCounter = this._startPerformanceCounterDisabled;
  2788. /** @hidden */
  2789. this._endPerformanceCounter = this._endPerformanceCounterDisabled;
  2790. }
  2791. Object.defineProperty(GLTFFileLoader.prototype, "onParsed", {
  2792. /**
  2793. * Raised when the asset has been parsed
  2794. */
  2795. set: function (callback) {
  2796. if (this._onParsedObserver) {
  2797. this.onParsedObservable.remove(this._onParsedObserver);
  2798. }
  2799. this._onParsedObserver = this.onParsedObservable.add(callback);
  2800. },
  2801. enumerable: false,
  2802. configurable: true
  2803. });
  2804. Object.defineProperty(GLTFFileLoader.prototype, "onMeshLoaded", {
  2805. /**
  2806. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  2807. */
  2808. set: function (callback) {
  2809. if (this._onMeshLoadedObserver) {
  2810. this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver);
  2811. }
  2812. this._onMeshLoadedObserver = this.onMeshLoadedObservable.add(callback);
  2813. },
  2814. enumerable: false,
  2815. configurable: true
  2816. });
  2817. Object.defineProperty(GLTFFileLoader.prototype, "onTextureLoaded", {
  2818. /**
  2819. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  2820. */
  2821. set: function (callback) {
  2822. if (this._onTextureLoadedObserver) {
  2823. this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver);
  2824. }
  2825. this._onTextureLoadedObserver = this.onTextureLoadedObservable.add(callback);
  2826. },
  2827. enumerable: false,
  2828. configurable: true
  2829. });
  2830. Object.defineProperty(GLTFFileLoader.prototype, "onMaterialLoaded", {
  2831. /**
  2832. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  2833. */
  2834. set: function (callback) {
  2835. if (this._onMaterialLoadedObserver) {
  2836. this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver);
  2837. }
  2838. this._onMaterialLoadedObserver = this.onMaterialLoadedObservable.add(callback);
  2839. },
  2840. enumerable: false,
  2841. configurable: true
  2842. });
  2843. Object.defineProperty(GLTFFileLoader.prototype, "onCameraLoaded", {
  2844. /**
  2845. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  2846. */
  2847. set: function (callback) {
  2848. if (this._onCameraLoadedObserver) {
  2849. this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver);
  2850. }
  2851. this._onCameraLoadedObserver = this.onCameraLoadedObservable.add(callback);
  2852. },
  2853. enumerable: false,
  2854. configurable: true
  2855. });
  2856. Object.defineProperty(GLTFFileLoader.prototype, "onComplete", {
  2857. /**
  2858. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  2859. * For assets with LODs, raised when all of the LODs are complete.
  2860. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  2861. */
  2862. set: function (callback) {
  2863. if (this._onCompleteObserver) {
  2864. this.onCompleteObservable.remove(this._onCompleteObserver);
  2865. }
  2866. this._onCompleteObserver = this.onCompleteObservable.add(callback);
  2867. },
  2868. enumerable: false,
  2869. configurable: true
  2870. });
  2871. Object.defineProperty(GLTFFileLoader.prototype, "onError", {
  2872. /**
  2873. * Callback raised when an error occurs.
  2874. */
  2875. set: function (callback) {
  2876. if (this._onErrorObserver) {
  2877. this.onErrorObservable.remove(this._onErrorObserver);
  2878. }
  2879. this._onErrorObserver = this.onErrorObservable.add(callback);
  2880. },
  2881. enumerable: false,
  2882. configurable: true
  2883. });
  2884. Object.defineProperty(GLTFFileLoader.prototype, "onDispose", {
  2885. /**
  2886. * Callback raised after the loader is disposed.
  2887. */
  2888. set: function (callback) {
  2889. if (this._onDisposeObserver) {
  2890. this.onDisposeObservable.remove(this._onDisposeObserver);
  2891. }
  2892. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  2893. },
  2894. enumerable: false,
  2895. configurable: true
  2896. });
  2897. Object.defineProperty(GLTFFileLoader.prototype, "onExtensionLoaded", {
  2898. /**
  2899. * Callback raised after a loader extension is created.
  2900. */
  2901. set: function (callback) {
  2902. if (this._onExtensionLoadedObserver) {
  2903. this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver);
  2904. }
  2905. this._onExtensionLoadedObserver = this.onExtensionLoadedObservable.add(callback);
  2906. },
  2907. enumerable: false,
  2908. configurable: true
  2909. });
  2910. Object.defineProperty(GLTFFileLoader.prototype, "loggingEnabled", {
  2911. /**
  2912. * Defines if the loader logging is enabled.
  2913. */
  2914. get: function () {
  2915. return this._loggingEnabled;
  2916. },
  2917. set: function (value) {
  2918. if (this._loggingEnabled === value) {
  2919. return;
  2920. }
  2921. this._loggingEnabled = value;
  2922. if (this._loggingEnabled) {
  2923. this._log = this._logEnabled;
  2924. }
  2925. else {
  2926. this._log = this._logDisabled;
  2927. }
  2928. },
  2929. enumerable: false,
  2930. configurable: true
  2931. });
  2932. Object.defineProperty(GLTFFileLoader.prototype, "capturePerformanceCounters", {
  2933. /**
  2934. * Defines if the loader should capture performance counters.
  2935. */
  2936. get: function () {
  2937. return this._capturePerformanceCounters;
  2938. },
  2939. set: function (value) {
  2940. if (this._capturePerformanceCounters === value) {
  2941. return;
  2942. }
  2943. this._capturePerformanceCounters = value;
  2944. if (this._capturePerformanceCounters) {
  2945. this._startPerformanceCounter = this._startPerformanceCounterEnabled;
  2946. this._endPerformanceCounter = this._endPerformanceCounterEnabled;
  2947. }
  2948. else {
  2949. this._startPerformanceCounter = this._startPerformanceCounterDisabled;
  2950. this._endPerformanceCounter = this._endPerformanceCounterDisabled;
  2951. }
  2952. },
  2953. enumerable: false,
  2954. configurable: true
  2955. });
  2956. Object.defineProperty(GLTFFileLoader.prototype, "onValidated", {
  2957. /**
  2958. * Callback raised after a loader extension is created.
  2959. */
  2960. set: function (callback) {
  2961. if (this._onValidatedObserver) {
  2962. this.onValidatedObservable.remove(this._onValidatedObserver);
  2963. }
  2964. this._onValidatedObserver = this.onValidatedObservable.add(callback);
  2965. },
  2966. enumerable: false,
  2967. configurable: true
  2968. });
  2969. /**
  2970. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  2971. */
  2972. GLTFFileLoader.prototype.dispose = function () {
  2973. if (this._loader) {
  2974. this._loader.dispose();
  2975. this._loader = null;
  2976. }
  2977. for (var _i = 0, _a = this._requests; _i < _a.length; _i++) {
  2978. var request = _a[_i];
  2979. request.abort();
  2980. }
  2981. this._requests.length = 0;
  2982. delete this._progressCallback;
  2983. this.preprocessUrlAsync = function (url) { return Promise.resolve(url); };
  2984. this.onMeshLoadedObservable.clear();
  2985. this.onTextureLoadedObservable.clear();
  2986. this.onMaterialLoadedObservable.clear();
  2987. this.onCameraLoadedObservable.clear();
  2988. this.onCompleteObservable.clear();
  2989. this.onExtensionLoadedObservable.clear();
  2990. this.onDisposeObservable.notifyObservers(undefined);
  2991. this.onDisposeObservable.clear();
  2992. };
  2993. /** @hidden */
  2994. GLTFFileLoader.prototype.requestFile = function (scene, url, onSuccess, onProgress, useArrayBuffer, onError) {
  2995. var _this = this;
  2996. this._progressCallback = onProgress;
  2997. if (useArrayBuffer) {
  2998. if (this.useRangeRequests) {
  2999. if (this.validate) {
  3000. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("glTF validation is not supported when range requests are enabled");
  3001. }
  3002. var fileRequest_1 = {
  3003. abort: function () { },
  3004. onCompleteObservable: new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]()
  3005. };
  3006. var dataBuffer = {
  3007. readAsync: function (byteOffset, byteLength) {
  3008. return new Promise(function (resolve, reject) {
  3009. _this._requestFile(url, scene, function (data) {
  3010. resolve(new Uint8Array(data));
  3011. }, true, function (error) {
  3012. reject(error);
  3013. }, function (webRequest) {
  3014. webRequest.setRequestHeader("Range", "bytes=" + byteOffset + "-" + (byteOffset + byteLength - 1));
  3015. });
  3016. });
  3017. },
  3018. byteLength: 0
  3019. };
  3020. this._unpackBinaryAsync(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["DataReader"](dataBuffer)).then(function (loaderData) {
  3021. fileRequest_1.onCompleteObservable.notifyObservers(fileRequest_1);
  3022. onSuccess(loaderData);
  3023. }, onError);
  3024. return fileRequest_1;
  3025. }
  3026. return this._requestFile(url, scene, function (data, request) {
  3027. var arrayBuffer = data;
  3028. _this._unpackBinaryAsync(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["DataReader"]({
  3029. readAsync: function (byteOffset, byteLength) { return Promise.resolve(new Uint8Array(arrayBuffer, byteOffset, byteLength)); },
  3030. byteLength: arrayBuffer.byteLength
  3031. })).then(function (loaderData) {
  3032. onSuccess(loaderData, request);
  3033. }, onError);
  3034. }, true, onError);
  3035. }
  3036. return this._requestFile(url, scene, function (data, request) {
  3037. _this._validate(scene, data, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFolderPath(url), babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(url));
  3038. onSuccess({ json: _this._parseJson(data) }, request);
  3039. }, useArrayBuffer, onError);
  3040. };
  3041. /** @hidden */
  3042. GLTFFileLoader.prototype.readFile = function (scene, file, onSuccess, onProgress, useArrayBuffer, onError) {
  3043. var _this = this;
  3044. return scene._readFile(file, function (data) {
  3045. _this._validate(scene, data, "file:", file.name);
  3046. if (useArrayBuffer) {
  3047. var arrayBuffer_1 = data;
  3048. _this._unpackBinaryAsync(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["DataReader"]({
  3049. readAsync: function (byteOffset, byteLength) { return Promise.resolve(new Uint8Array(arrayBuffer_1, byteOffset, byteLength)); },
  3050. byteLength: arrayBuffer_1.byteLength
  3051. })).then(onSuccess, onError);
  3052. }
  3053. else {
  3054. onSuccess({ json: _this._parseJson(data) });
  3055. }
  3056. }, onProgress, useArrayBuffer, onError);
  3057. };
  3058. /** @hidden */
  3059. GLTFFileLoader.prototype.importMeshAsync = function (meshesNames, scene, data, rootUrl, onProgress, fileName) {
  3060. var _this = this;
  3061. return Promise.resolve().then(function () {
  3062. _this.onParsedObservable.notifyObservers(data);
  3063. _this.onParsedObservable.clear();
  3064. _this._log("Loading " + (fileName || ""));
  3065. _this._loader = _this._getLoader(data);
  3066. return _this._loader.importMeshAsync(meshesNames, scene, false, data, rootUrl, onProgress, fileName);
  3067. });
  3068. };
  3069. /** @hidden */
  3070. GLTFFileLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fileName) {
  3071. var _this = this;
  3072. return Promise.resolve().then(function () {
  3073. _this.onParsedObservable.notifyObservers(data);
  3074. _this.onParsedObservable.clear();
  3075. _this._log("Loading " + (fileName || ""));
  3076. _this._loader = _this._getLoader(data);
  3077. return _this._loader.loadAsync(scene, data, rootUrl, onProgress, fileName);
  3078. });
  3079. };
  3080. /** @hidden */
  3081. GLTFFileLoader.prototype.loadAssetContainerAsync = function (scene, data, rootUrl, onProgress, fileName) {
  3082. var _this = this;
  3083. return Promise.resolve().then(function () {
  3084. _this.onParsedObservable.notifyObservers(data);
  3085. _this.onParsedObservable.clear();
  3086. _this._log("Loading " + (fileName || ""));
  3087. _this._loader = _this._getLoader(data);
  3088. // Prepare the asset container.
  3089. var container = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AssetContainer"](scene);
  3090. // Get materials/textures when loading to add to container
  3091. var materials = [];
  3092. _this.onMaterialLoadedObservable.add(function (material) {
  3093. materials.push(material);
  3094. material.onDisposeObservable.addOnce(function () {
  3095. var index = container.materials.indexOf(material);
  3096. if (index > -1) {
  3097. container.materials.splice(index, 1);
  3098. }
  3099. index = materials.indexOf(material);
  3100. if (index > -1) {
  3101. materials.splice(index, 1);
  3102. }
  3103. });
  3104. });
  3105. var textures = [];
  3106. _this.onTextureLoadedObservable.add(function (texture) {
  3107. textures.push(texture);
  3108. texture.onDisposeObservable.addOnce(function () {
  3109. var index = container.textures.indexOf(texture);
  3110. if (index > -1) {
  3111. container.textures.splice(index, 1);
  3112. }
  3113. index = textures.indexOf(texture);
  3114. if (index > -1) {
  3115. textures.splice(index, 1);
  3116. }
  3117. });
  3118. });
  3119. var cameras = [];
  3120. _this.onCameraLoadedObservable.add(function (camera) {
  3121. cameras.push(camera);
  3122. });
  3123. return _this._loader.importMeshAsync(null, scene, true, data, rootUrl, onProgress, fileName).then(function (result) {
  3124. Array.prototype.push.apply(container.meshes, result.meshes);
  3125. Array.prototype.push.apply(container.particleSystems, result.particleSystems);
  3126. Array.prototype.push.apply(container.skeletons, result.skeletons);
  3127. Array.prototype.push.apply(container.animationGroups, result.animationGroups);
  3128. Array.prototype.push.apply(container.materials, materials);
  3129. Array.prototype.push.apply(container.textures, textures);
  3130. Array.prototype.push.apply(container.lights, result.lights);
  3131. Array.prototype.push.apply(container.transformNodes, result.transformNodes);
  3132. Array.prototype.push.apply(container.cameras, cameras);
  3133. return container;
  3134. });
  3135. });
  3136. };
  3137. /** @hidden */
  3138. GLTFFileLoader.prototype.canDirectLoad = function (data) {
  3139. return (data.indexOf("asset") !== -1 && data.indexOf("version") !== -1)
  3140. || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["StringTools"].StartsWith(data, "data:base64," + GLTFFileLoader.magicBase64Encoded)
  3141. || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["StringTools"].StartsWith(data, "data:application/octet-stream;base64," + GLTFFileLoader.magicBase64Encoded)
  3142. || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["StringTools"].StartsWith(data, "data:model/gltf-binary;base64," + GLTFFileLoader.magicBase64Encoded);
  3143. };
  3144. /** @hidden */
  3145. GLTFFileLoader.prototype.directLoad = function (scene, data) {
  3146. if (babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["StringTools"].StartsWith(data, "base64," + GLTFFileLoader.magicBase64Encoded) ||
  3147. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["StringTools"].StartsWith(data, "application/octet-stream;base64," + GLTFFileLoader.magicBase64Encoded) ||
  3148. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["StringTools"].StartsWith(data, "model/gltf-binary;base64," + GLTFFileLoader.magicBase64Encoded)) {
  3149. var arrayBuffer_2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].DecodeBase64(data);
  3150. this._validate(scene, arrayBuffer_2);
  3151. return this._unpackBinaryAsync(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["DataReader"]({
  3152. readAsync: function (byteOffset, byteLength) { return Promise.resolve(new Uint8Array(arrayBuffer_2, byteOffset, byteLength)); },
  3153. byteLength: arrayBuffer_2.byteLength
  3154. }));
  3155. }
  3156. this._validate(scene, data);
  3157. return Promise.resolve({ json: this._parseJson(data) });
  3158. };
  3159. /** @hidden */
  3160. GLTFFileLoader.prototype.createPlugin = function () {
  3161. return new GLTFFileLoader();
  3162. };
  3163. Object.defineProperty(GLTFFileLoader.prototype, "loaderState", {
  3164. /**
  3165. * The loader state or null if the loader is not active.
  3166. */
  3167. get: function () {
  3168. return this._loader ? this._loader.state : null;
  3169. },
  3170. enumerable: false,
  3171. configurable: true
  3172. });
  3173. /**
  3174. * Returns a promise that resolves when the asset is completely loaded.
  3175. * @returns a promise that resolves when the asset is completely loaded.
  3176. */
  3177. GLTFFileLoader.prototype.whenCompleteAsync = function () {
  3178. var _this = this;
  3179. return new Promise(function (resolve, reject) {
  3180. _this.onCompleteObservable.addOnce(function () {
  3181. resolve();
  3182. });
  3183. _this.onErrorObservable.addOnce(function (reason) {
  3184. reject(reason);
  3185. });
  3186. });
  3187. };
  3188. /** @hidden */
  3189. GLTFFileLoader.prototype._loadFile = function (url, scene, onSuccess, useArrayBuffer, onError) {
  3190. var _this = this;
  3191. var request = scene._loadFile(url, onSuccess, function (event) {
  3192. _this._onProgress(event, request);
  3193. }, undefined, useArrayBuffer, onError);
  3194. request.onCompleteObservable.add(function (request) {
  3195. _this._requests.splice(_this._requests.indexOf(request), 1);
  3196. });
  3197. this._requests.push(request);
  3198. return request;
  3199. };
  3200. /** @hidden */
  3201. GLTFFileLoader.prototype._requestFile = function (url, scene, onSuccess, useArrayBuffer, onError, onOpened) {
  3202. var _this = this;
  3203. var request = scene._requestFile(url, onSuccess, function (event) {
  3204. _this._onProgress(event, request);
  3205. }, undefined, useArrayBuffer, onError, onOpened);
  3206. request.onCompleteObservable.add(function (request) {
  3207. _this._requests.splice(_this._requests.indexOf(request), 1);
  3208. });
  3209. this._requests.push(request);
  3210. return request;
  3211. };
  3212. GLTFFileLoader.prototype._onProgress = function (event, request) {
  3213. if (!this._progressCallback) {
  3214. return;
  3215. }
  3216. request._lengthComputable = event.lengthComputable;
  3217. request._loaded = event.loaded;
  3218. request._total = event.total;
  3219. var lengthComputable = true;
  3220. var loaded = 0;
  3221. var total = 0;
  3222. for (var _i = 0, _a = this._requests; _i < _a.length; _i++) {
  3223. var request_1 = _a[_i];
  3224. if (request_1._lengthComputable === undefined || request_1._loaded === undefined || request_1._total === undefined) {
  3225. return;
  3226. }
  3227. lengthComputable = lengthComputable && request_1._lengthComputable;
  3228. loaded += request_1._loaded;
  3229. total += request_1._total;
  3230. }
  3231. this._progressCallback({
  3232. lengthComputable: lengthComputable,
  3233. loaded: loaded,
  3234. total: lengthComputable ? total : 0
  3235. });
  3236. };
  3237. GLTFFileLoader.prototype._validate = function (scene, data, rootUrl, fileName) {
  3238. var _this = this;
  3239. if (rootUrl === void 0) { rootUrl = ""; }
  3240. if (fileName === void 0) { fileName = ""; }
  3241. if (!this.validate) {
  3242. return;
  3243. }
  3244. this._startPerformanceCounter("Validate JSON");
  3245. _glTFValidation__WEBPACK_IMPORTED_MODULE_1__["GLTFValidation"].ValidateAsync(data, rootUrl, fileName, function (uri) {
  3246. return _this.preprocessUrlAsync(rootUrl + uri).then(function (url) { return scene._loadFileAsync(url, undefined, true, true); });
  3247. }).then(function (result) {
  3248. _this._endPerformanceCounter("Validate JSON");
  3249. _this.onValidatedObservable.notifyObservers(result);
  3250. _this.onValidatedObservable.clear();
  3251. }, function (reason) {
  3252. _this._endPerformanceCounter("Validate JSON");
  3253. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Warn("Failed to validate: " + reason.message);
  3254. _this.onValidatedObservable.clear();
  3255. });
  3256. };
  3257. GLTFFileLoader.prototype._getLoader = function (loaderData) {
  3258. var asset = loaderData.json.asset || {};
  3259. this._log("Asset version: " + asset.version);
  3260. asset.minVersion && this._log("Asset minimum version: " + asset.minVersion);
  3261. asset.generator && this._log("Asset generator: " + asset.generator);
  3262. var version = GLTFFileLoader._parseVersion(asset.version);
  3263. if (!version) {
  3264. throw new Error("Invalid version: " + asset.version);
  3265. }
  3266. if (asset.minVersion !== undefined) {
  3267. var minVersion = GLTFFileLoader._parseVersion(asset.minVersion);
  3268. if (!minVersion) {
  3269. throw new Error("Invalid minimum version: " + asset.minVersion);
  3270. }
  3271. if (GLTFFileLoader._compareVersion(minVersion, { major: 2, minor: 0 }) > 0) {
  3272. throw new Error("Incompatible minimum version: " + asset.minVersion);
  3273. }
  3274. }
  3275. var createLoaders = {
  3276. 1: GLTFFileLoader._CreateGLTF1Loader,
  3277. 2: GLTFFileLoader._CreateGLTF2Loader
  3278. };
  3279. var createLoader = createLoaders[version.major];
  3280. if (!createLoader) {
  3281. throw new Error("Unsupported version: " + asset.version);
  3282. }
  3283. return createLoader(this);
  3284. };
  3285. GLTFFileLoader.prototype._parseJson = function (json) {
  3286. this._startPerformanceCounter("Parse JSON");
  3287. this._log("JSON length: " + json.length);
  3288. var parsed = JSON.parse(json);
  3289. this._endPerformanceCounter("Parse JSON");
  3290. return parsed;
  3291. };
  3292. GLTFFileLoader.prototype._unpackBinaryAsync = function (dataReader) {
  3293. var _this = this;
  3294. this._startPerformanceCounter("Unpack Binary");
  3295. // Read magic + version + length + json length + json format
  3296. return dataReader.loadAsync(20).then(function () {
  3297. var Binary = {
  3298. Magic: 0x46546C67
  3299. };
  3300. var magic = dataReader.readUint32();
  3301. if (magic !== Binary.Magic) {
  3302. throw new Error("Unexpected magic: " + magic);
  3303. }
  3304. var version = dataReader.readUint32();
  3305. if (_this.loggingEnabled) {
  3306. _this._log("Binary version: " + version);
  3307. }
  3308. var length = dataReader.readUint32();
  3309. if (dataReader.buffer.byteLength !== 0 && length !== dataReader.buffer.byteLength) {
  3310. throw new Error("Length in header does not match actual data length: " + length + " != " + dataReader.buffer.byteLength);
  3311. }
  3312. var unpacked;
  3313. switch (version) {
  3314. case 1: {
  3315. unpacked = _this._unpackBinaryV1Async(dataReader, length);
  3316. break;
  3317. }
  3318. case 2: {
  3319. unpacked = _this._unpackBinaryV2Async(dataReader, length);
  3320. break;
  3321. }
  3322. default: {
  3323. throw new Error("Unsupported version: " + version);
  3324. }
  3325. }
  3326. _this._endPerformanceCounter("Unpack Binary");
  3327. return unpacked;
  3328. });
  3329. };
  3330. GLTFFileLoader.prototype._unpackBinaryV1Async = function (dataReader, length) {
  3331. var ContentFormat = {
  3332. JSON: 0
  3333. };
  3334. var contentLength = dataReader.readUint32();
  3335. var contentFormat = dataReader.readUint32();
  3336. if (contentFormat !== ContentFormat.JSON) {
  3337. throw new Error("Unexpected content format: " + contentFormat);
  3338. }
  3339. var bodyLength = length - dataReader.byteOffset;
  3340. var data = { json: this._parseJson(dataReader.readString(contentLength)), bin: null };
  3341. if (bodyLength !== 0) {
  3342. var startByteOffset_1 = dataReader.byteOffset;
  3343. data.bin = {
  3344. readAsync: function (byteOffset, byteLength) { return dataReader.buffer.readAsync(startByteOffset_1 + byteOffset, byteLength); },
  3345. byteLength: bodyLength
  3346. };
  3347. }
  3348. return Promise.resolve(data);
  3349. };
  3350. GLTFFileLoader.prototype._unpackBinaryV2Async = function (dataReader, length) {
  3351. var _this = this;
  3352. var ChunkFormat = {
  3353. JSON: 0x4E4F534A,
  3354. BIN: 0x004E4942
  3355. };
  3356. // Read the JSON chunk header.
  3357. var chunkLength = dataReader.readUint32();
  3358. var chunkFormat = dataReader.readUint32();
  3359. if (chunkFormat !== ChunkFormat.JSON) {
  3360. throw new Error("First chunk format is not JSON");
  3361. }
  3362. // Bail if there are no other chunks.
  3363. if (dataReader.byteOffset + chunkLength === length) {
  3364. return dataReader.loadAsync(chunkLength).then(function () {
  3365. return { json: _this._parseJson(dataReader.readString(chunkLength)), bin: null };
  3366. });
  3367. }
  3368. // Read the JSON chunk and the length and type of the next chunk.
  3369. return dataReader.loadAsync(chunkLength + 8).then(function () {
  3370. var data = { json: _this._parseJson(dataReader.readString(chunkLength)), bin: null };
  3371. var readAsync = function () {
  3372. var chunkLength = dataReader.readUint32();
  3373. var chunkFormat = dataReader.readUint32();
  3374. switch (chunkFormat) {
  3375. case ChunkFormat.JSON: {
  3376. throw new Error("Unexpected JSON chunk");
  3377. }
  3378. case ChunkFormat.BIN: {
  3379. var startByteOffset_2 = dataReader.byteOffset;
  3380. data.bin = {
  3381. readAsync: function (byteOffset, byteLength) { return dataReader.buffer.readAsync(startByteOffset_2 + byteOffset, byteLength); },
  3382. byteLength: chunkLength
  3383. };
  3384. dataReader.skipBytes(chunkLength);
  3385. break;
  3386. }
  3387. default: {
  3388. // ignore unrecognized chunkFormat
  3389. dataReader.skipBytes(chunkLength);
  3390. break;
  3391. }
  3392. }
  3393. if (dataReader.byteOffset !== length) {
  3394. return dataReader.loadAsync(8).then(readAsync);
  3395. }
  3396. return Promise.resolve(data);
  3397. };
  3398. return readAsync();
  3399. });
  3400. };
  3401. GLTFFileLoader._parseVersion = function (version) {
  3402. if (version === "1.0" || version === "1.0.1") {
  3403. return {
  3404. major: 1,
  3405. minor: 0
  3406. };
  3407. }
  3408. var match = (version + "").match(/^(\d+)\.(\d+)/);
  3409. if (!match) {
  3410. return null;
  3411. }
  3412. return {
  3413. major: parseInt(match[1]),
  3414. minor: parseInt(match[2])
  3415. };
  3416. };
  3417. GLTFFileLoader._compareVersion = function (a, b) {
  3418. if (a.major > b.major) {
  3419. return 1;
  3420. }
  3421. if (a.major < b.major) {
  3422. return -1;
  3423. }
  3424. if (a.minor > b.minor) {
  3425. return 1;
  3426. }
  3427. if (a.minor < b.minor) {
  3428. return -1;
  3429. }
  3430. return 0;
  3431. };
  3432. /** @hidden */
  3433. GLTFFileLoader.prototype._logOpen = function (message) {
  3434. this._log(message);
  3435. this._logIndentLevel++;
  3436. };
  3437. /** @hidden */
  3438. GLTFFileLoader.prototype._logClose = function () {
  3439. --this._logIndentLevel;
  3440. };
  3441. GLTFFileLoader.prototype._logEnabled = function (message) {
  3442. var spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2);
  3443. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log("" + spaces + message);
  3444. };
  3445. GLTFFileLoader.prototype._logDisabled = function (message) {
  3446. };
  3447. GLTFFileLoader.prototype._startPerformanceCounterEnabled = function (counterName) {
  3448. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter(counterName);
  3449. };
  3450. GLTFFileLoader.prototype._startPerformanceCounterDisabled = function (counterName) {
  3451. };
  3452. GLTFFileLoader.prototype._endPerformanceCounterEnabled = function (counterName) {
  3453. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter(counterName);
  3454. };
  3455. GLTFFileLoader.prototype._endPerformanceCounterDisabled = function (counterName) {
  3456. };
  3457. // ----------
  3458. // V1 options
  3459. // ----------
  3460. /**
  3461. * 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.
  3462. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  3463. * Defaults to true.
  3464. * @hidden
  3465. */
  3466. GLTFFileLoader.IncrementalLoading = true;
  3467. /**
  3468. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  3469. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  3470. * @hidden
  3471. */
  3472. GLTFFileLoader.HomogeneousCoordinates = false;
  3473. GLTFFileLoader.magicBase64Encoded = "Z2xURg"; // "glTF" base64 encoded (without the quotes!)
  3474. GLTFFileLoader._logSpaces = " ";
  3475. return GLTFFileLoader;
  3476. }());
  3477. if (babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"]) {
  3478. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].RegisterPlugin(new GLTFFileLoader());
  3479. }
  3480. /***/ }),
  3481. /***/ "./glTF/glTFValidation.ts":
  3482. /*!********************************!*\
  3483. !*** ./glTF/glTFValidation.ts ***!
  3484. \********************************/
  3485. /*! exports provided: GLTFValidation */
  3486. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3487. "use strict";
  3488. __webpack_require__.r(__webpack_exports__);
  3489. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GLTFValidation", function() { return GLTFValidation; });
  3490. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/tools");
  3491. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__);
  3492. function validateAsync(data, rootUrl, fileName, getExternalResource) {
  3493. var options = {
  3494. externalResourceFunction: function (uri) { return getExternalResource(uri).then(function (value) { return new Uint8Array(value); }); }
  3495. };
  3496. if (fileName) {
  3497. options.uri = (rootUrl === "file:" ? fileName : rootUrl + fileName);
  3498. }
  3499. return (data instanceof ArrayBuffer)
  3500. ? GLTFValidator.validateBytes(new Uint8Array(data), options)
  3501. : GLTFValidator.validateString(data, options);
  3502. }
  3503. /**
  3504. * The worker function that gets converted to a blob url to pass into a worker.
  3505. */
  3506. function workerFunc() {
  3507. var pendingExternalResources = [];
  3508. onmessage = function (message) {
  3509. var data = message.data;
  3510. switch (data.id) {
  3511. case "init": {
  3512. importScripts(data.url);
  3513. break;
  3514. }
  3515. case "validate": {
  3516. validateAsync(data.data, data.rootUrl, data.fileName, function (uri) { return new Promise(function (resolve, reject) {
  3517. var index = pendingExternalResources.length;
  3518. pendingExternalResources.push({ resolve: resolve, reject: reject });
  3519. postMessage({ id: "getExternalResource", index: index, uri: uri });
  3520. }); }).then(function (value) {
  3521. postMessage({ id: "validate.resolve", value: value });
  3522. }, function (reason) {
  3523. postMessage({ id: "validate.reject", reason: reason });
  3524. });
  3525. break;
  3526. }
  3527. case "getExternalResource.resolve": {
  3528. pendingExternalResources[data.index].resolve(data.value);
  3529. break;
  3530. }
  3531. case "getExternalResource.reject": {
  3532. pendingExternalResources[data.index].reject(data.reason);
  3533. break;
  3534. }
  3535. }
  3536. };
  3537. }
  3538. /**
  3539. * glTF validation
  3540. */
  3541. var GLTFValidation = /** @class */ (function () {
  3542. function GLTFValidation() {
  3543. }
  3544. /**
  3545. * Validate a glTF asset using the glTF-Validator.
  3546. * @param data The JSON of a glTF or the array buffer of a binary glTF
  3547. * @param rootUrl The root url for the glTF
  3548. * @param fileName The file name for the glTF
  3549. * @param getExternalResource The callback to get external resources for the glTF validator
  3550. * @returns A promise that resolves with the glTF validation results once complete
  3551. */
  3552. GLTFValidation.ValidateAsync = function (data, rootUrl, fileName, getExternalResource) {
  3553. var _this = this;
  3554. if (typeof Worker === "function") {
  3555. return new Promise(function (resolve, reject) {
  3556. var workerContent = validateAsync + "(" + workerFunc + ")()";
  3557. var workerBlobUrl = URL.createObjectURL(new Blob([workerContent], { type: "application/javascript" }));
  3558. var worker = new Worker(workerBlobUrl);
  3559. var onError = function (error) {
  3560. worker.removeEventListener("error", onError);
  3561. worker.removeEventListener("message", onMessage);
  3562. reject(error);
  3563. };
  3564. var onMessage = function (message) {
  3565. var data = message.data;
  3566. switch (data.id) {
  3567. case "getExternalResource": {
  3568. getExternalResource(data.uri).then(function (value) {
  3569. worker.postMessage({ id: "getExternalResource.resolve", index: data.index, value: value }, [value]);
  3570. }, function (reason) {
  3571. worker.postMessage({ id: "getExternalResource.reject", index: data.index, reason: reason });
  3572. });
  3573. break;
  3574. }
  3575. case "validate.resolve": {
  3576. worker.removeEventListener("error", onError);
  3577. worker.removeEventListener("message", onMessage);
  3578. resolve(data.value);
  3579. break;
  3580. }
  3581. case "validate.reject": {
  3582. worker.removeEventListener("error", onError);
  3583. worker.removeEventListener("message", onMessage);
  3584. reject(data.reason);
  3585. }
  3586. }
  3587. };
  3588. worker.addEventListener("error", onError);
  3589. worker.addEventListener("message", onMessage);
  3590. worker.postMessage({ id: "init", url: babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetAbsoluteUrl(_this.Configuration.url) });
  3591. worker.postMessage({ id: "validate", data: data, rootUrl: rootUrl, fileName: fileName });
  3592. });
  3593. }
  3594. else {
  3595. if (!this._LoadScriptPromise) {
  3596. this._LoadScriptPromise = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadScriptAsync(this.Configuration.url);
  3597. }
  3598. return this._LoadScriptPromise.then(function () {
  3599. return validateAsync(data, rootUrl, fileName, getExternalResource);
  3600. });
  3601. }
  3602. };
  3603. /**
  3604. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  3605. */
  3606. GLTFValidation.Configuration = {
  3607. url: "https://preview.babylonjs.com/gltf_validator.js"
  3608. };
  3609. return GLTFValidation;
  3610. }());
  3611. /***/ }),
  3612. /***/ "./legacy/legacy-glTF.ts":
  3613. /*!*******************************!*\
  3614. !*** ./legacy/legacy-glTF.ts ***!
  3615. \*******************************/
  3616. /*! exports provided: GLTFLoaderCoordinateSystemMode, GLTFLoaderAnimationStartMode, GLTFLoaderState, GLTFFileLoader, GLTFValidation */
  3617. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3618. "use strict";
  3619. __webpack_require__.r(__webpack_exports__);
  3620. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTF/glTFFileLoader */ "./glTF/glTFFileLoader.ts");
  3621. /* harmony import */ var _glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTF/glTFValidation */ "./glTF/glTFValidation.ts");
  3622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFLoaderCoordinateSystemMode", function() { return _glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__["GLTFLoaderCoordinateSystemMode"]; });
  3623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFLoaderAnimationStartMode", function() { return _glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__["GLTFLoaderAnimationStartMode"]; });
  3624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFLoaderState", function() { return _glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__["GLTFLoaderState"]; });
  3625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFFileLoader", function() { return _glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__["GLTFFileLoader"]; });
  3626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFValidation", function() { return _glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__["GLTFValidation"]; });
  3627. /**
  3628. * This is the entry point for the UMD module.
  3629. * The entry point for a future ESM package should be index.ts
  3630. */
  3631. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  3632. if (typeof globalObject !== "undefined") {
  3633. globalObject.BABYLON = globalObject.BABYLON || {};
  3634. for (var key in _glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__) {
  3635. globalObject.BABYLON[key] = _glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__[key];
  3636. }
  3637. for (var key in _glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__) {
  3638. globalObject.BABYLON[key] = _glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__[key];
  3639. }
  3640. }
  3641. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  3642. /***/ }),
  3643. /***/ "./legacy/legacy-glTF1.ts":
  3644. /*!********************************!*\
  3645. !*** ./legacy/legacy-glTF1.ts ***!
  3646. \********************************/
  3647. /*! exports provided: GLTF1 */
  3648. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3649. "use strict";
  3650. __webpack_require__.r(__webpack_exports__);
  3651. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _glTF_1_0__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTF/1.0 */ "./glTF/1.0/index.ts");
  3652. /* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "GLTF1", function() { return _glTF_1_0__WEBPACK_IMPORTED_MODULE_0__; });
  3653. /**
  3654. * This is the entry point for the UMD module.
  3655. * The entry point for a future ESM package should be index.ts
  3656. */
  3657. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  3658. if (typeof globalObject !== "undefined") {
  3659. globalObject.BABYLON = globalObject.BABYLON || {};
  3660. globalObject.BABYLON.GLTF1 = globalObject.BABYLON.GLTF1 || {};
  3661. for (var key in _glTF_1_0__WEBPACK_IMPORTED_MODULE_0__) {
  3662. globalObject.BABYLON.GLTF1[key] = _glTF_1_0__WEBPACK_IMPORTED_MODULE_0__[key];
  3663. }
  3664. }
  3665. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  3666. /***/ }),
  3667. /***/ "./legacy/legacy-glTF1FileLoader.ts":
  3668. /*!******************************************!*\
  3669. !*** ./legacy/legacy-glTF1FileLoader.ts ***!
  3670. \******************************************/
  3671. /*! exports provided: GLTFLoaderCoordinateSystemMode, GLTFLoaderAnimationStartMode, GLTFLoaderState, GLTFFileLoader, GLTFValidation, GLTF1 */
  3672. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3673. "use strict";
  3674. __webpack_require__.r(__webpack_exports__);
  3675. /* harmony import */ var _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./legacy-glTF */ "./legacy/legacy-glTF.ts");
  3676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFLoaderCoordinateSystemMode", function() { return _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__["GLTFLoaderCoordinateSystemMode"]; });
  3677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFLoaderAnimationStartMode", function() { return _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__["GLTFLoaderAnimationStartMode"]; });
  3678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFLoaderState", function() { return _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__["GLTFLoaderState"]; });
  3679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFFileLoader", function() { return _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__["GLTFFileLoader"]; });
  3680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTFValidation", function() { return _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__["GLTFValidation"]; });
  3681. /* harmony import */ var _legacy_glTF1__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./legacy-glTF1 */ "./legacy/legacy-glTF1.ts");
  3682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GLTF1", function() { return _legacy_glTF1__WEBPACK_IMPORTED_MODULE_1__["GLTF1"]; });
  3683. /***/ }),
  3684. /***/ "babylonjs/Misc/tools":
  3685. /*!****************************************************************************************************!*\
  3686. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  3687. \****************************************************************************************************/
  3688. /*! no static exports found */
  3689. /***/ (function(module, exports) {
  3690. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_tools__;
  3691. /***/ })
  3692. /******/ });
  3693. });
  3694. //# sourceMappingURL=babylon.glTF1FileLoader.js.map