babylon.glTF1FileLoader.js 166 KB

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