babylon.glTF2FileLoader.js 213 KB

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