babylon.glTF1FileLoader.js 166 KB

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