babylon.glTF1FileLoader.js 185 KB

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