babylonjs-loaders
Version:
Babylon.js Loaders module =====================
1 lines • 149 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-loaders",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-loaders"]=t(require("babylonjs")):e.LOADERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(e=>(()=>{"use strict";var t,n,r={597:t=>{t.exports=e}},o={};function a(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return r[e](n,n.exports,a),n.exports}n=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,a.t=function(e,r){if(1&r&&(e=this(e)),8&r)return e;if("object"==typeof e&&e){if(4&r&&e.__esModule)return e;if(16&r&&"function"==typeof e.then)return e}var o=Object.create(null);a.r(o);var i={};t=t||[null,n({}),n([]),n(n)];for(var s=2&r&&e;"object"==typeof s&&!~t.indexOf(s);s=n(s))Object.getOwnPropertyNames(s).forEach((t=>i[t]=()=>e[t]));return i.default=()=>e,a.d(o,i),o},a.d=(e,t)=>{for(var n in t)a.o(t,n)&&!a.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};a.d(i,{default:()=>Ot});var s={};a.r(s),a.d(s,{GLTFValidation:()=>w});var l={};a.r(l),a.d(l,{GLTFFileLoader:()=>E,GLTFLoaderAnimationStartMode:()=>T,GLTFLoaderCoordinateSystemMode:()=>A,GLTFLoaderState:()=>x});var c={};a.r(c),a.d(c,{EXT_lights_image_based:()=>q,EXT_mesh_gpu_instancing:()=>W,EXT_meshopt_compression:()=>z,EXT_texture_avif:()=>$,EXT_texture_webp:()=>Q,ExtrasAsMetadata:()=>gt,KHR_animation_pointer:()=>nt,KHR_draco_mesh_compression:()=>te,KHR_interactivity:()=>vt,KHR_lights:()=>re,KHR_materials_anisotropy:()=>fe,KHR_materials_clearcoat:()=>ce,KHR_materials_diffuse_transmission:()=>Le,KHR_materials_dispersion:()=>Re,KHR_materials_emissive_strength:()=>_e,KHR_materials_ior:()=>Ae,KHR_materials_iridescence:()=>de,KHR_materials_pbrSpecularGlossiness:()=>ae,KHR_materials_sheen:()=>ye,KHR_materials_specular:()=>be,KHR_materials_transmission:()=>Ce,KHR_materials_unlit:()=>se,KHR_materials_variants:()=>xe,KHR_materials_volume:()=>Se,KHR_mesh_quantization:()=>Ne,KHR_texture_basisu:()=>Be,KHR_texture_transform:()=>Ge,KHR_xmp_json_ld:()=>Ve,MSFT_audio_emitter:()=>ot,MSFT_lod:()=>it,MSFT_minecraftMesh:()=>lt,MSFT_sRGBFactors:()=>ut});var u={};a.r(u);var d={};a.r(d),a.d(d,{ArrayItem:()=>K,EXT_lights_image_based:()=>q,EXT_mesh_gpu_instancing:()=>W,EXT_meshopt_compression:()=>z,EXT_texture_avif:()=>$,EXT_texture_webp:()=>Q,ExtrasAsMetadata:()=>gt,GLTFFileLoader:()=>E,GLTFLoader:()=>H,KHR_animation_pointer:()=>nt,KHR_draco_mesh_compression:()=>te,KHR_interactivity:()=>vt,KHR_lights:()=>re,KHR_materials_anisotropy:()=>fe,KHR_materials_clearcoat:()=>ce,KHR_materials_diffuse_transmission:()=>Le,KHR_materials_dispersion:()=>Re,KHR_materials_emissive_strength:()=>_e,KHR_materials_ior:()=>Ae,KHR_materials_iridescence:()=>de,KHR_materials_pbrSpecularGlossiness:()=>ae,KHR_materials_sheen:()=>ye,KHR_materials_specular:()=>be,KHR_materials_transmission:()=>Ce,KHR_materials_unlit:()=>se,KHR_materials_variants:()=>xe,KHR_materials_volume:()=>Se,KHR_mesh_quantization:()=>Ne,KHR_texture_basisu:()=>Be,KHR_texture_transform:()=>Ge,KHR_xmp_json_ld:()=>Ve,MSFT_audio_emitter:()=>ot,MSFT_lod:()=>it,MSFT_minecraftMesh:()=>lt,MSFT_sRGBFactors:()=>ut,registerGLTFExtension:()=>D,registeredGLTFExtensions:()=>G,unregisterGLTFExtension:()=>V});var h={};a.r(h),a.d(h,{GLTF2:()=>d,GLTFFileLoader:()=>E,GLTFLoaderAnimationStartMode:()=>T,GLTFLoaderCoordinateSystemMode:()=>A,GLTFLoaderState:()=>x,GLTFValidation:()=>w});var f=function(e,t){return f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},f(e,t)};function p(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}f(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var _=function(){return _=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},_.apply(this,arguments)};function m(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{l(r.next(e))}catch(e){a(e)}}function s(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,s)}l((r=r.apply(e,t||[])).next())}))}function y(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var v=a(597);function b(e,t,n,r){var o={externalResourceFunction:r};return n&&(o.uri="file:"===t?n:t+n),ArrayBuffer.isView(e)?GLTFValidator.validateBytes(e,o):GLTFValidator.validateString(e,o)}function g(){var e=[];onmessage=function(t){var n=t.data;switch(n.id){case"init":importScripts(n.url);break;case"validate":b(n.data,n.rootUrl,n.fileName,(function(t){return new Promise((function(n,r){var o=e.length;e.push({resolve:n,reject:r}),postMessage({id:"getExternalResource",index:o,uri:t})}))})).then((function(e){postMessage({id:"validate.resolve",value:e})}),(function(e){postMessage({id:"validate.reject",reason:e})}));break;case"getExternalResource.resolve":e[n.index].resolve(n.value);break;case"getExternalResource.reject":e[n.index].reject(n.reason)}}}var A,T,x,w=function(){function e(){}return e.ValidateAsync=function(e,t,n,r){var o=this;return"function"==typeof Worker?new Promise((function(a,i){var s="".concat(b,"(").concat(g,")()"),l=URL.createObjectURL(new Blob([s],{type:"application/javascript"})),c=new Worker(l),u=function(e){c.removeEventListener("error",u),c.removeEventListener("message",d),i(e)},d=function(e){var t=e.data;switch(t.id){case"getExternalResource":r(t.uri).then((function(e){c.postMessage({id:"getExternalResource.resolve",index:t.index,value:e},[e.buffer])}),(function(e){c.postMessage({id:"getExternalResource.reject",index:t.index,reason:e})}));break;case"validate.resolve":c.removeEventListener("error",u),c.removeEventListener("message",d),a(t.value),c.terminate();break;case"validate.reject":c.removeEventListener("error",u),c.removeEventListener("message",d),i(t.reason),c.terminate()}};if(c.addEventListener("error",u),c.addEventListener("message",d),c.postMessage({id:"init",url:v.Tools.GetBabylonScriptURL(o.Configuration.url)}),ArrayBuffer.isView(e)){var h=e.slice();c.postMessage({id:"validate",data:h,rootUrl:t,fileName:n},[h.buffer])}else c.postMessage({id:"validate",data:e,rootUrl:t,fileName:n})})):(this._LoadScriptPromise||(this._LoadScriptPromise=v.Tools.LoadBabylonScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then((function(){return b(e,t,n,r)})))},e.Configuration={url:"".concat(v.Tools._DefaultCdnUrl,"/gltf_validator.js")},e}(),O="Z2xURg",C="gltf",M={".gltf":{isBinary:!1},".glb":{isBinary:!0}};function L(e,t,n){try{return Promise.resolve(new Uint8Array(e,t,n))}catch(e){return Promise.reject(e)}}!function(e){e[e.AUTO=0]="AUTO",e[e.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED"}(A||(A={})),function(e){e[e.NONE=0]="NONE",e[e.FIRST=1]="FIRST",e[e.ALL=2]="ALL"}(T||(T={})),function(e){e[e.LOADING=0]="LOADING",e[e.READY=1]="READY",e[e.COMPLETE=2]="COMPLETE"}(x||(x={}));var E=function(e){function t(t){var n=e.call(this)||this;return n.onParsedObservable=new v.Observable,n.onMeshLoadedObservable=new v.Observable,n.onSkinLoadedObservable=new v.Observable,n.onTextureLoadedObservable=new v.Observable,n.onMaterialLoadedObservable=new v.Observable,n.onCameraLoadedObservable=new v.Observable,n.onCompleteObservable=new v.Observable,n.onErrorObservable=new v.Observable,n.onDisposeObservable=new v.Observable,n.onExtensionLoadedObservable=new v.Observable,n.validate=!1,n.onValidatedObservable=new v.Observable,n._loader=null,n._state=null,n._requests=new Array,n.name=C,n.extensions=M,n.onLoaderStateChangedObservable=new v.Observable,n._logIndentLevel=0,n._loggingEnabled=!1,n._log=n._logDisabled,n._capturePerformanceCounters=!1,n._startPerformanceCounter=n._startPerformanceCounterDisabled,n._endPerformanceCounter=n._endPerformanceCounterDisabled,n.copyFrom(t),n}return p(t,e),Object.defineProperty(t.prototype,"onParsed",{set:function(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),e&&(this._onParsedObserver=this.onParsedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onMeshLoaded",{set:function(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),e&&(this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onSkinLoaded",{set:function(e){this._onSkinLoadedObserver&&this.onSkinLoadedObservable.remove(this._onSkinLoadedObserver),e&&(this._onSkinLoadedObserver=this.onSkinLoadedObservable.add((function(t){return e(t.node,t.skinnedNode)})))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onTextureLoaded",{set:function(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),e&&(this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onMaterialLoaded",{set:function(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),e&&(this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onCameraLoaded",{set:function(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),e&&(this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onComplete",{set:function(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onError",{set:function(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onExtensionLoaded",{set:function(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"loggingEnabled",{get:function(){return this._loggingEnabled},set:function(e){this._loggingEnabled!==e&&(this._loggingEnabled=e,this._loggingEnabled?this._log=this._logEnabled:this._log=this._logDisabled)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"capturePerformanceCounters",{get:function(){return this._capturePerformanceCounters},set:function(e){this._capturePerformanceCounters!==e&&(this._capturePerformanceCounters=e,this._capturePerformanceCounters?(this._startPerformanceCounter=this._startPerformanceCounterEnabled,this._endPerformanceCounter=this._endPerformanceCounterEnabled):(this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onValidated",{set:function(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this._loader&&(this._loader.dispose(),this._loader=null);for(var e=0,t=this._requests;e<t.length;e++)t[e].abort();this._requests.length=0,delete this._progressCallback,this.preprocessUrlAsync=function(e){return Promise.resolve(e)},this.onMeshLoadedObservable.clear(),this.onSkinLoadedObservable.clear(),this.onTextureLoadedObservable.clear(),this.onMaterialLoadedObservable.clear(),this.onCameraLoadedObservable.clear(),this.onCompleteObservable.clear(),this.onExtensionLoadedObservable.clear(),this.onDisposeObservable.notifyObservers(void 0),this.onDisposeObservable.clear()},t.prototype.loadFile=function(e,t,n,r,o,a,i,s){var l=this;if(ArrayBuffer.isView(t))return this._loadBinary(e,t,n,r,i,s),null;this._progressCallback=o;var c=t.name||v.Tools.GetFilename(t);if(a){if(this.useRangeRequests){this.validate&&v.Logger.Warn("glTF validation is not supported when range requests are enabled");var u={abort:function(){},onCompleteObservable:new v.Observable},d={readAsync:function(n,r){return new Promise((function(o,a){l._loadFile(e,t,(function(e){o(new Uint8Array(e))}),!0,(function(e){a(e)}),(function(e){e.setRequestHeader("Range","bytes=".concat(n,"-").concat(n+r-1))}))}))},byteLength:0};return this._unpackBinaryAsync(new v.DataReader(d)).then((function(e){u.onCompleteObservable.notifyObservers(u),r(e)}),i?function(e){return i(void 0,e)}:void 0),u}return this._loadFile(e,t,(function(t){l._validate(e,new Uint8Array(t,0,t.byteLength),n,c),l._unpackBinaryAsync(new v.DataReader({readAsync:function(e,n){return L(t,e,n)},byteLength:t.byteLength})).then((function(e){r(e)}),i?function(e){return i(void 0,e)}:void 0)}),!0,i)}return this._loadFile(e,t,(function(t){try{l._validate(e,t,n,c),r({json:l._parseJson(t)})}catch(e){i&&i()}}),!1,i)},t.prototype._loadBinary=function(e,t,n,r,o,a){this._validate(e,new Uint8Array(t.buffer,t.byteOffset,t.byteLength),n,a),this._unpackBinaryAsync(new v.DataReader({readAsync:function(e,n){return function(e,t,n){try{if(t<0||t>=e.byteLength)throw new RangeError("Offset is out of range.");if(t+n>e.byteLength)throw new RangeError("Length is out of range.");return Promise.resolve(new Uint8Array(e.buffer,e.byteOffset+t,n))}catch(e){return Promise.reject(e)}}(t,e,n)},byteLength:t.byteLength})).then((function(e){r(e)}),o?function(e){return o(void 0,e)}:void 0)},t.prototype.importMeshAsync=function(e,t,n,r,o,a){var i=this;return Promise.resolve().then((function(){return i.onParsedObservable.notifyObservers(n),i.onParsedObservable.clear(),i._log("Loading ".concat(a||"")),i._loader=i._getLoader(n),i._loader.importMeshAsync(e,t,null,n,r,o,a)}))},t.prototype.loadAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then((function(){return a.onParsedObservable.notifyObservers(t),a.onParsedObservable.clear(),a._log("Loading ".concat(o||"")),a._loader=a._getLoader(t),a._loader.loadAsync(e,t,n,r,o)}))},t.prototype.loadAssetContainerAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then((function(){a.onParsedObservable.notifyObservers(t),a.onParsedObservable.clear(),a._log("Loading ".concat(o||"")),a._loader=a._getLoader(t);var i=new v.AssetContainer(e),s=[];a.onMaterialLoadedObservable.add((function(e){s.push(e)}));var l=[];a.onTextureLoadedObservable.add((function(e){l.push(e)}));var c=[];a.onCameraLoadedObservable.add((function(e){c.push(e)}));var u=[];return a.onMeshLoadedObservable.add((function(e){e.morphTargetManager&&u.push(e.morphTargetManager)})),a._loader.importMeshAsync(null,e,i,t,n,r,o).then((function(e){return Array.prototype.push.apply(i.geometries,e.geometries),Array.prototype.push.apply(i.meshes,e.meshes),Array.prototype.push.apply(i.particleSystems,e.particleSystems),Array.prototype.push.apply(i.skeletons,e.skeletons),Array.prototype.push.apply(i.animationGroups,e.animationGroups),Array.prototype.push.apply(i.materials,s),Array.prototype.push.apply(i.textures,l),Array.prototype.push.apply(i.lights,e.lights),Array.prototype.push.apply(i.transformNodes,e.transformNodes),Array.prototype.push.apply(i.cameras,c),Array.prototype.push.apply(i.morphTargetManagers,u),i}))}))},t.prototype.canDirectLoad=function(e){return function(e){return-1!==e.indexOf("asset")&&-1!==e.indexOf("version")||e.startsWith("data:base64,"+O)||e.startsWith("data:;base64,"+O)||e.startsWith("data:application/octet-stream;base64,"+O)||e.startsWith("data:model/gltf-binary;base64,"+O)}(e)},t.prototype.directLoad=function(e,t){if(t.startsWith("base64,"+O)||t.startsWith(";base64,"+O)||t.startsWith("application/octet-stream;base64,"+O)||t.startsWith("model/gltf-binary;base64,"+O)){var n=(0,v.DecodeBase64UrlToBinary)(t);return this._validate(e,new Uint8Array(n,0,n.byteLength)),this._unpackBinaryAsync(new v.DataReader({readAsync:function(e,t){return L(n,e,t)},byteLength:n.byteLength}))}return this._validate(e,t),Promise.resolve({json:this._parseJson(t)})},t.prototype.createPlugin=function(e){return new t(e[C])},Object.defineProperty(t.prototype,"loaderState",{get:function(){return this._state},enumerable:!1,configurable:!0}),t.prototype.whenCompleteAsync=function(){var e=this;return new Promise((function(t,n){e.onCompleteObservable.addOnce((function(){t()})),e.onErrorObservable.addOnce((function(e){n(e)}))}))},t.prototype._setState=function(e){this._state!==e&&(this._state=e,this.onLoaderStateChangedObservable.notifyObservers(this._state),this._log(x[this._state]))},t.prototype._loadFile=function(e,t,n,r,o,a){var i=this,s=e._loadFile(t,n,(function(e){i._onProgress(e,s)}),!0,r,o,a);return s.onCompleteObservable.add((function(){s._lengthComputable=!0,s._total=s._loaded})),this._requests.push(s),s},t.prototype._onProgress=function(e,t){if(this._progressCallback){t._lengthComputable=e.lengthComputable,t._loaded=e.loaded,t._total=e.total;for(var n=!0,r=0,o=0,a=0,i=this._requests;a<i.length;a++){var s=i[a];if(void 0===s._lengthComputable||void 0===s._loaded||void 0===s._total)return;n=n&&s._lengthComputable,r+=s._loaded,o+=s._total}this._progressCallback({lengthComputable:n,loaded:r,total:n?o:0})}},t.prototype._validate=function(e,t,n,r){var o=this;void 0===n&&(n=""),void 0===r&&(r=""),this.validate&&(this._startPerformanceCounter("Validate JSON"),w.ValidateAsync(t,n,r,(function(t){return o.preprocessUrlAsync(n+t).then((function(t){return e._loadFileAsync(t,void 0,!0,!0).then((function(e){return new Uint8Array(e,0,e.byteLength)}))}))})).then((function(e){o._endPerformanceCounter("Validate JSON"),o.onValidatedObservable.notifyObservers(e),o.onValidatedObservable.clear()}),(function(e){o._endPerformanceCounter("Validate JSON"),v.Tools.Warn("Failed to validate: ".concat(e.message)),o.onValidatedObservable.clear()})))},t.prototype._getLoader=function(e){var n=e.json.asset||{};this._log("Asset version: ".concat(n.version)),n.minVersion&&this._log("Asset minimum version: ".concat(n.minVersion)),n.generator&&this._log("Asset generator: ".concat(n.generator));var r=t._parseVersion(n.version);if(!r)throw new Error("Invalid version: "+n.version);if(void 0!==n.minVersion){var o=t._parseVersion(n.minVersion);if(!o)throw new Error("Invalid minimum version: "+n.minVersion);if(t._compareVersion(o,{major:2,minor:0})>0)throw new Error("Incompatible minimum version: "+n.minVersion)}var a={1:t._CreateGLTF1Loader,2:t._CreateGLTF2Loader}[r.major];if(!a)throw new Error("Unsupported version: "+n.version);return a(this)},t.prototype._parseJson=function(e){this._startPerformanceCounter("Parse JSON"),this._log("JSON length: ".concat(e.length));var t=JSON.parse(e);return this._endPerformanceCounter("Parse JSON"),t},t.prototype._unpackBinaryAsync=function(e){var t=this;return this._startPerformanceCounter("Unpack Binary"),e.loadAsync(20).then((function(){var n=e.readUint32();if(1179937895!==n)throw new v.RuntimeError("Unexpected magic: "+n,v.ErrorCodes.GLTFLoaderUnexpectedMagicError);var r=e.readUint32();t.loggingEnabled&&t._log("Binary version: ".concat(r));var o,a=e.readUint32();switch(t.useRangeRequests||a===e.buffer.byteLength||v.Logger.Warn("Length in header does not match actual data length: ".concat(a," != ").concat(e.buffer.byteLength)),r){case 1:o=t._unpackBinaryV1Async(e,a);break;case 2:o=t._unpackBinaryV2Async(e,a);break;default:throw new Error("Unsupported version: "+r)}return t._endPerformanceCounter("Unpack Binary"),o}))},t.prototype._unpackBinaryV1Async=function(e,t){var n=e.readUint32(),r=e.readUint32();if(0!==r)throw new Error("Unexpected content format: ".concat(r));var o=t-e.byteOffset,a={json:this._parseJson(e.readString(n)),bin:null};if(0!==o){var i=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(i+t,n)},byteLength:o}}return Promise.resolve(a)},t.prototype._unpackBinaryV2Async=function(e,t){var n=this,r=1313821514,o=e.readUint32();if(e.readUint32()!==r)throw new Error("First chunk format is not JSON");return e.byteOffset+o===t?e.loadAsync(o).then((function(){return{json:n._parseJson(e.readString(o)),bin:null}})):e.loadAsync(o+8).then((function(){var a={json:n._parseJson(e.readString(o)),bin:null},i=function(){var n=e.readUint32();switch(e.readUint32()){case r:throw new Error("Unexpected JSON chunk");case 5130562:var o=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(o+t,n)},byteLength:n},e.skipBytes(n);break;default:e.skipBytes(n)}return e.byteOffset!==t?e.loadAsync(8).then(i):Promise.resolve(a)};return i()}))},t._parseVersion=function(e){if("1.0"===e||"1.0.1"===e)return{major:1,minor:0};var t=(e+"").match(/^(\d+)\.(\d+)/);return t?{major:parseInt(t[1]),minor:parseInt(t[2])}:null},t._compareVersion=function(e,t){return e.major>t.major?1:e.major<t.major?-1:e.minor>t.minor?1:e.minor<t.minor?-1:0},t.prototype._logOpen=function(e){this._log(e),this._logIndentLevel++},t.prototype._logClose=function(){--this._logIndentLevel},t.prototype._logEnabled=function(e){var n=t._logSpaces.substring(0,2*this._logIndentLevel);v.Logger.Log("".concat(n).concat(e))},t.prototype._logDisabled=function(e){},t.prototype._startPerformanceCounterEnabled=function(e){v.Tools.StartPerformanceCounter(e)},t.prototype._startPerformanceCounterDisabled=function(e){},t.prototype._endPerformanceCounterEnabled=function(e){v.Tools.EndPerformanceCounter(e)},t.prototype._endPerformanceCounterDisabled=function(e){},t.IncrementalLoading=!0,t.HomogeneousCoordinates=!1,t._logSpaces=" ",t}(function(){function e(){this.coordinateSystemMode=A.AUTO,this.animationStartMode=T.FIRST,this.loadNodeAnimations=!0,this.loadSkins=!0,this.loadMorphTargets=!0,this.compileMaterials=!1,this.useClipPlane=!1,this.compileShadowGenerators=!1,this.transparencyAsCoverage=!1,this.useRangeRequests=!1,this.createInstances=!0,this.alwaysComputeBoundingBox=!1,this.loadAllMaterials=!1,this.loadOnlyMaterials=!1,this.skipMaterials=!1,this.useSRGBBuffers=!0,this.targetFps=60,this.alwaysComputeSkeletonRootNode=!1,this.preprocessUrlAsync=function(e){return Promise.resolve(e)},this.extensionOptions={}}return e.prototype.copyFrom=function(e){var t,n,r,o,a,i,s,l,c,u,d,h,f,p,_,m,y,v,b,g;e&&(this.onParsed=e.onParsed,this.coordinateSystemMode=null!==(t=e.coordinateSystemMode)&&void 0!==t?t:this.coordinateSystemMode,this.animationStartMode=null!==(n=e.animationStartMode)&&void 0!==n?n:this.animationStartMode,this.loadNodeAnimations=null!==(r=e.loadNodeAnimations)&&void 0!==r?r:this.loadNodeAnimations,this.loadSkins=null!==(o=e.loadSkins)&&void 0!==o?o:this.loadSkins,this.loadMorphTargets=null!==(a=e.loadMorphTargets)&&void 0!==a?a:this.loadMorphTargets,this.compileMaterials=null!==(i=e.compileMaterials)&&void 0!==i?i:this.compileMaterials,this.useClipPlane=null!==(s=e.useClipPlane)&&void 0!==s?s:this.useClipPlane,this.compileShadowGenerators=null!==(l=e.compileShadowGenerators)&&void 0!==l?l:this.compileShadowGenerators,this.transparencyAsCoverage=null!==(c=e.transparencyAsCoverage)&&void 0!==c?c:this.transparencyAsCoverage,this.useRangeRequests=null!==(u=e.useRangeRequests)&&void 0!==u?u:this.useRangeRequests,this.createInstances=null!==(d=e.createInstances)&&void 0!==d?d:this.createInstances,this.alwaysComputeBoundingBox=null!==(h=e.alwaysComputeBoundingBox)&&void 0!==h?h:this.alwaysComputeBoundingBox,this.loadAllMaterials=null!==(f=e.loadAllMaterials)&&void 0!==f?f:this.loadAllMaterials,this.loadOnlyMaterials=null!==(p=e.loadOnlyMaterials)&&void 0!==p?p:this.loadOnlyMaterials,this.skipMaterials=null!==(_=e.skipMaterials)&&void 0!==_?_:this.skipMaterials,this.useSRGBBuffers=null!==(m=e.useSRGBBuffers)&&void 0!==m?m:this.useSRGBBuffers,this.targetFps=null!==(y=e.targetFps)&&void 0!==y?y:this.targetFps,this.alwaysComputeSkeletonRootNode=null!==(v=e.alwaysComputeSkeletonRootNode)&&void 0!==v?v:this.alwaysComputeSkeletonRootNode,this.preprocessUrlAsync=null!==(b=e.preprocessUrlAsync)&&void 0!==b?b:this.preprocessUrlAsync,this.customRootNode=e.customRootNode,this.onMeshLoaded=e.onMeshLoaded,this.onSkinLoaded=e.onSkinLoaded,this.onTextureLoaded=e.onTextureLoaded,this.onMaterialLoaded=e.onMaterialLoaded,this.onCameraLoaded=e.onCameraLoaded,this.extensionOptions=null!==(g=e.extensionOptions)&&void 0!==g?g:this.extensionOptions)},e}());(0,v.registerSceneLoaderPlugin)(new E);var S=void 0!==a.g?a.g:"undefined"!=typeof window?window:void 0;if(void 0!==S){for(var P in S.BABYLON=S.BABYLON||{},l)S.BABYLON[P]=l[P];for(var P in s)S.BABYLON[P]=s[P]}function R(e,t,n,r){return v.Vector3.FromArray(t,n).scaleInPlace(r)}var I=function(){function e(e,t,n,r){this.type=e,this.name=t,this.getValue=n,this.getStride=r}return e.prototype._buildAnimation=function(e,t,n){var r=new v.Animation(e,this.name,t,this.type);return r.setKeys(n),r},e}(),N=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return p(t,e),t.prototype.buildAnimations=function(e,t,n,r,o){o(e._babylonTransformNode,this._buildAnimation(t,n,r))},t}(I),F=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return p(t,e),t.prototype.buildAnimations=function(e,t,n,r,o){if(e._numMorphTargets)for(var a=function(a){var s=new v.Animation("".concat(t,"_").concat(a),i.name,n,i.type);if(s.setKeys(r.map((function(e){return{frame:e.frame,inTangent:e.inTangent?e.inTangent[a]:void 0,value:e.value[a],outTangent:e.outTangent?e.outTangent[a]:void 0,interpolation:e.interpolation}}))),e._primitiveBabylonMeshes)for(var l=0,c=e._primitiveBabylonMeshes;l<c.length;l++){var u=c[l];if(u.morphTargetManager){var d=u.morphTargetManager.getTarget(a),h=s.clone();d.animations.push(h),o(d,h)}}},i=this,s=0;s<e._numMorphTargets;s++)a(s)},t}(I),B={translation:[new N(v.Animation.ANIMATIONTYPE_VECTOR3,"position",R,(function(){return 3}))],rotation:[new N(v.Animation.ANIMATIONTYPE_QUATERNION,"rotationQuaternion",(function(e,t,n,r){return v.Quaternion.FromArray(t,n).scaleInPlace(r)}),(function(){return 4}))],scale:[new N(v.Animation.ANIMATIONTYPE_VECTOR3,"scaling",R,(function(){return 3}))],weights:[new F(v.Animation.ANIMATIONTYPE_FLOAT,"influence",(function(e,t,n,r){for(var o=new Array(e._numMorphTargets),a=0;a<o.length;a++)o[a]=t[n++]*r;return o}),(function(e){return e._numMorphTargets}))]},k=new Map,G=k;function D(e,t,n){V(e)&&v.Logger.Warn("Extension with the name '".concat(e,"' already exists")),k.set(e,{isGLTFExtension:t,factory:n})}function V(e){return k.delete(e)}function U(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=function(e){return e&&"object"==typeof e};return e.reduce((function(e,t){return Object.keys(t).forEach((function(r){var o=e[r],a=t[r];Array.isArray(o)&&Array.isArray(a)?e[r]=o.concat.apply(o,a):n(o)&&n(a)?e[r]=U(o,a):e[r]=a})),e}),{})}var K=function(){function e(){}return e.Get=function(e,t,n){if(!t||null==n||!t[n])throw new Error("".concat(e,": Failed to find index (").concat(n,")"));return t[n]},e.TryGet=function(e,t){return e&&null!=t&&e[t]?e[t]:null},e.Assign=function(e){if(e)for(var t=0;t<e.length;t++)e[t].index=t},e}(),H=function(){function e(e){this._completePromises=new Array,this._assetContainer=null,this._babylonLights=[],this._disableInstancedMesh=0,this._allMaterialsDirtyRequired=!1,this._extensions=new Array,this._disposed=!1,this._rootUrl=null,this._fileName=null,this._uniqueRootUrl=null,this._bin=null,this._rootBabylonMesh=null,this._defaultBabylonMaterialData={},this._postSceneLoadActions=new Array,this._parent=e}return e.RegisterExtension=function(e,t){D(e,!1,t)},e.UnregisterExtension=function(e){return V(e)},Object.defineProperty(e.prototype,"gltf",{get:function(){if(!this._gltf)throw new Error("glTF JSON is not available");return this._gltf},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bin",{get:function(){return this._bin},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"babylonScene",{get:function(){if(!this._babylonScene)throw new Error("Scene is not available");return this._babylonScene},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rootBabylonMesh",{get:function(){return this._rootBabylonMesh},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rootUrl",{get:function(){return this._rootUrl},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this._disposed||(this._disposed=!0,this._completePromises.length=0,this._extensions.forEach((function(e){return e.dispose&&e.dispose()})),this._extensions.length=0,this._gltf=null,this._bin=null,this._babylonScene=null,this._rootBabylonMesh=null,this._defaultBabylonMaterialData={},this._postSceneLoadActions.length=0,this._parent.dispose())},e.prototype.importMeshAsync=function(e,t,n,r,o,a,i){var s=this;return void 0===i&&(i=""),Promise.resolve().then((function(){s._babylonScene=t,s._assetContainer=n,s._loadData(r);var a=null;if(e){var l={};if(s._gltf.nodes)for(var c=0,u=s._gltf.nodes;c<u.length;c++){var d=u[c];d.name&&(l[d.name]=d.index)}a=(e instanceof Array?e:[e]).map((function(e){var t=l[e];if(void 0===t)throw new Error("Failed to find node '".concat(e,"'"));return t}))}return s._loadAsync(o,i,a,(function(){return{meshes:s._getMeshes(),particleSystems:[],skeletons:s._getSkeletons(),animationGroups:s._getAnimationGroups(),lights:s._babylonLights,transformNodes:s._getTransformNodes(),geometries:s._getGeometries(),spriteManagers:[]}}))}))},e.prototype.loadAsync=function(e,t,n,r,o){var a=this;return void 0===o&&(o=""),Promise.resolve().then((function(){return a._babylonScene=e,a._loadData(t),a._loadAsync(n,o,null,(function(){}))}))},e.prototype._loadAsync=function(e,t,n,r){var o=this;return Promise.resolve().then((function(){return m(o,void 0,void 0,(function(){var o,a,i,s,l,c,u,d,h,f=this;return y(this,(function(p){switch(p.label){case 0:return this._rootUrl=e,this._uniqueRootUrl=!e.startsWith("file:")&&t?e:"".concat(e).concat(Date.now(),"/"),this._fileName=t,this._allMaterialsDirtyRequired=!1,[4,this._loadExtensionsAsync()];case 1:if(p.sent(),o="".concat(x[x.LOADING]," => ").concat(x[x.READY]),a="".concat(x[x.LOADING]," => ").concat(x[x.COMPLETE]),this._parent._startPerformanceCounter(o),this._parent._startPerformanceCounter(a),this._parent._setState(x.LOADING),this._extensionsOnLoading(),i=new Array,s=this._babylonScene.blockMaterialDirtyMechanism,this._babylonScene.blockMaterialDirtyMechanism=!0,this.parent.loadOnlyMaterials||(n?i.push(this.loadSceneAsync("/nodes",{nodes:n,index:-1})):(null!=this._gltf.scene||this._gltf.scenes&&this._gltf.scenes[0])&&(l=K.Get("/scene",this._gltf.scenes,this._gltf.scene||0),i.push(this.loadSceneAsync("/scenes/".concat(l.index),l)))),!this.parent.skipMaterials&&this.parent.loadAllMaterials&&this._gltf.materials)for(c=0;c<this._gltf.materials.length;++c)u=this._gltf.materials[c],d="/materials/"+c,h=v.Material.TriangleFillMode,i.push(this._loadMaterialAsync(d,u,null,h,(function(){})));return this._allMaterialsDirtyRequired?this._babylonScene.blockMaterialDirtyMechanism=s:this._babylonScene._forceBlockMaterialDirtyMechanism(s),this._parent.compileMaterials&&i.push(this._compileMaterialsAsync()),this._parent.compileShadowGenerators&&i.push(this._compileShadowGeneratorsAsync()),[2,Promise.all(i).then((function(){return f._rootBabylonMesh&&f._rootBabylonMesh!==f._parent.customRootNode&&f._rootBabylonMesh.setEnabled(!0),f._extensionsOnReady(),f._parent._setState(x.READY),f._startAnimations(),r()})).then((function(e){return f._parent._endPerformanceCounter(o),v.Tools.SetImmediate((function(){f._disposed||Promise.all(f._completePromises).then((function(){f._parent._endPerformanceCounter(a),f._parent._setState(x.COMPLETE),f._parent.onCompleteObservable.notifyObservers(void 0),f._parent.onCompleteObservable.clear(),f.dispose()}),(function(e){f._parent.onErrorObservable.notifyObservers(e),f._parent.onErrorObservable.clear(),f.dispose()}))})),e}))]}}))}))})).catch((function(e){throw o._disposed||(o._parent.onErrorObservable.notifyObservers(e),o._parent.onErrorObservable.clear(),o.dispose()),e}))},e.prototype._loadData=function(e){if(this._gltf=e.json,this._setupData(),e.bin){var t=this._gltf.buffers;if(t&&t[0]&&!t[0].uri){var n=t[0];(n.byteLength<e.bin.byteLength-3||n.byteLength>e.bin.byteLength)&&v.Logger.Warn("Binary buffer length (".concat(n.byteLength,") from JSON does not match chunk length (").concat(e.bin.byteLength,")")),this._bin=e.bin}else v.Logger.Warn("Unexpected BIN chunk")}},e.prototype._setupData=function(){if(K.Assign(this._gltf.accessors),K.Assign(this._gltf.animations),K.Assign(this._gltf.buffers),K.Assign(this._gltf.bufferViews),K.Assign(this._gltf.cameras),K.Assign(this._gltf.images),K.Assign(this._gltf.materials),K.Assign(this._gltf.meshes),K.Assign(this._gltf.nodes),K.Assign(this._gltf.samplers),K.Assign(this._gltf.scenes),K.Assign(this._gltf.skins),K.Assign(this._gltf.textures),this._gltf.nodes){for(var e={},t=0,n=this._gltf.nodes;t<n.length;t++)if((l=n[t]).children)for(var r=0,o=l.children;r<o.length;r++)e[o[r]]=l.index;for(var a=this._createRootNode(),i=0,s=this._gltf.nodes;i<s.length;i++){var l,c=e[(l=s[i]).index];l.parent=void 0===c?a:this._gltf.nodes[c]}}},e.prototype._loadExtensionsAsync=function(){var e;return m(this,void 0,void 0,(function(){var t,n,r,o,a,i,s,l,c,u,d=this;return y(this,(function(h){switch(h.label){case 0:return t=[],G.forEach((function(e,n){var r;!1===(null===(r=d.parent.extensionOptions[n])||void 0===r?void 0:r.enabled)?e.isGLTFExtension&&d.isExtensionUsed(n)&&v.Logger.Warn("Extension ".concat(n," is used but has been explicitly disabled.")):e.isGLTFExtension&&!d.isExtensionUsed(n)||t.push(m(d,void 0,void 0,(function(){var t;return y(this,(function(r){switch(r.label){case 0:return[4,e.factory(this)];case 1:return(t=r.sent()).name!==n&&v.Logger.Warn("The name of the glTF loader extension instance does not match the registered name: ".concat(t.name," !== ").concat(n)),this._parent.onExtensionLoadedObservable.notifyObservers(t),[2,t]}}))})))})),r=(n=(u=this._extensions).push).apply,o=[u],[4,Promise.all(t)];case 1:if(r.apply(n,o.concat([h.sent()])),this._extensions.sort((function(e,t){return(e.order||Number.MAX_VALUE)-(t.order||Number.MAX_VALUE)})),this._parent.onExtensionLoadedObservable.clear(),this._gltf.extensionsRequired)for(a=function(t){if(!i._extensions.some((function(e){return e.name===t&&e.enabled}))){if(!1===(null===(e=i.parent.extensionOptions[t])||void 0===e?void 0:e.enabled))throw new Error("Required extension ".concat(t," is disabled"));throw new Error("Required extension ".concat(t," is not available"))}},i=this,s=0,l=this._gltf.extensionsRequired;s<l.length;s++)c=l[s],a(c);return[2]}}))}))},e.prototype._createRootNode=function(){if(void 0!==this._parent.customRootNode)return this._rootBabylonMesh=this._parent.customRootNode,{_babylonTransformNode:null===this._rootBabylonMesh?void 0:this._rootBabylonMesh,index:-1};this._babylonScene._blockEntityCollection=!!this._assetContainer;var t=new v.Mesh("__root__",this._babylonScene);this._rootBabylonMesh=t,this._rootBabylonMesh._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._rootBabylonMesh.setEnabled(!1);var n={_babylonTransformNode:this._rootBabylonMesh,index:-1};switch(this._parent.coordinateSystemMode){case A.AUTO:this._babylonScene.useRightHandedSystem||(n.rotation=[0,1,0,0],n.scale=[1,1,-1],e._LoadTransform(n,this._rootBabylonMesh));break;case A.FORCE_RIGHT_HANDED:this._babylonScene.useRightHandedSystem=!0;break;default:throw new Error("Invalid coordinate system mode (".concat(this._parent.coordinateSystemMode,")"))}return this._parent.onMeshLoadedObservable.notifyObservers(t),n},e.prototype.loadSceneAsync=function(e,t){var n=this,r=this._extensionsLoadSceneAsync(e,t);if(r)return r;var o=new Array;if(this.logOpen("".concat(e," ").concat(t.name||"")),t.nodes)for(var a=0,i=t.nodes;a<i.length;a++){var s=i[a],l=K.Get("".concat(e,"/nodes/").concat(s),this._gltf.nodes,s);o.push(this.loadNodeAsync("/nodes/".concat(l.index),l,(function(e){e.parent=n._rootBabylonMesh})))}for(var c=0,u=this._postSceneLoadActions;c<u.length;c++)(0,u[c])();return o.push(this._loadAnimationsAsync()),this.logClose(),Promise.all(o).then((function(){}))},e.prototype._forEachPrimitive=function(e,t){if(e._primitiveBabylonMeshes)for(var n=0,r=e._primitiveBabylonMeshes;n<r.length;n++)t(r[n])},e.prototype._getGeometries=function(){var e=[],t=this._gltf.nodes;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];this._forEachPrimitive(o,(function(t){var n=t.geometry;n&&-1===e.indexOf(n)&&e.push(n)}))}return e},e.prototype._getMeshes=function(){var e=[];this._rootBabylonMesh instanceof v.AbstractMesh&&e.push(this._rootBabylonMesh);var t=this._gltf.nodes;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];this._forEachPrimitive(o,(function(t){e.push(t)}))}return e},e.prototype._getTransformNodes=function(){var e=[],t=this._gltf.nodes;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];o._babylonTransformNode&&"TransformNode"===o._babylonTransformNode.getClassName()&&e.push(o._babylonTransformNode),o._babylonTransformNodeForSkin&&e.push(o._babylonTransformNodeForSkin)}return e},e.prototype._getSkeletons=function(){var e=[],t=this._gltf.skins;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];o._data&&e.push(o._data.babylonSkeleton)}return e},e.prototype._getAnimationGroups=function(){var e=[],t=this._gltf.animations;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];o._babylonAnimationGroup&&e.push(o._babylonAnimationGroup)}return e},e.prototype._startAnimations=function(){switch(this._parent.animationStartMode){case T.NONE:break;case T.FIRST:0!==(e=this._getAnimationGroups()).length&&e[0].start(!0);break;case T.ALL:for(var e,t=0,n=e=this._getAnimationGroups();t<n.length;t++)n[t].start(!0);break;default:return void v.Logger.Error("Invalid animation start mode (".concat(this._parent.animationStartMode,")"))}},e.prototype.loadNodeAsync=function(t,n,r){var o=this;void 0===r&&(r=function(){});var a=this._extensionsLoadNodeAsync(t,n,r);if(a)return a;if(n._babylonTransformNode)throw new Error("".concat(t,": Invalid recursive node hierarchy"));var i=new Array;this.logOpen("".concat(t," ").concat(n.name||""));var s=function(a){if(e.AddPointerMetadata(a,t),e._LoadTransform(n,a),null!=n.camera){var s=K.Get("".concat(t,"/camera"),o._gltf.cameras,n.camera);i.push(o.loadCameraAsync("/cameras/".concat(s.index),s,(function(e){e.parent=a})))}if(n.children)for(var l=0,c=n.children;l<c.length;l++){var u=c[l],d=K.Get("".concat(t,"/children/").concat(u),o._gltf.nodes,u);i.push(o.loadNodeAsync("/nodes/".concat(d.index),d,(function(e){e.parent=a})))}r(a)},l=null!=n.mesh,c=this._parent.loadSkins&&null!=n.skin;if(!l||c){var u=n.name||"node".concat(n.index);this._babylonScene._blockEntityCollection=!!this._assetContainer;var d=new v.TransformNode(u,this._babylonScene);d._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,null==n.mesh?n._babylonTransformNode=d:n._babylonTransformNodeForSkin=d,s(d)}if(l)if(c){var h=K.Get("".concat(t,"/mesh"),this._gltf.meshes,n.mesh);i.push(this._loadMeshAsync("/meshes/".concat(h.index),n,h,(function(e){var r=n._babylonTransformNodeForSkin;e.metadata=U(r.metadata,e.metadata||{});var a=K.Get("".concat(t,"/skin"),o._gltf.skins,n.skin);i.push(o._loadSkinAsync("/skins/".concat(a.index),n,a,(function(t){o._forEachPrimitive(n,(function(e){e.skeleton=t})),o._postSceneLoadActions.push((function(){if(null!=a.skeleton){var t=K.Get("/skins/".concat(a.index,"/skeleton"),o._gltf.nodes,a.skeleton).parent;n.index===t.index?e.parent=r.parent:e.parent=t._babylonTransformNode}else e.parent=o._rootBabylonMesh;o._parent.onSkinLoadedObservable.notifyObservers({node:r,skinnedNode:e})}))})))})))}else h=K.Get("".concat(t,"/mesh"),this._gltf.meshes,n.mesh),i.push(this._loadMeshAsync("/meshes/".concat(h.index),n,h,s));return this.logClose(),Promise.all(i).then((function(){return o._forEachPrimitive(n,(function(e){e.geometry&&e.geometry.useBoundingInfoFromGeometry?e._updateBoundingInfo():e.refreshBoundingInfo(!0,!0)})),n._babylonTransformNode}))},e.prototype._loadMeshAsync=function(e,t,n,r){var o=n.primitives;if(!o||!o.length)throw new Error("".concat(e,": Primitives are missing"));null==o[0].index&&K.Assign(o);var a=new Array;this.logOpen("".concat(e," ").concat(n.name||""));var i=t.name||"node".concat(t.index);if(1===o.length){var s=n.primitives[0];a.push(this._loadMeshPrimitiveAsync("".concat(e,"/primitives/").concat(s.index),i,t,n,s,(function(e){t._babylonTransformNode=e,t._primitiveBabylonMeshes=[e]})))}else{this._babylonScene._blockEntityCollection=!!this._assetContainer,t._babylonTransformNode=new v.TransformNode(i,this._babylonScene),t._babylonTransformNode._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,t._primitiveBabylonMeshes=[];for(var l=0,c=o;l<c.length;l++)s=c[l],a.push(this._loadMeshPrimitiveAsync("".concat(e,"/primitives/").concat(s.index),"".concat(i,"_primitive").concat(s.index),t,n,s,(function(e){e.parent=t._babylonTransformNode,t._primitiveBabylonMeshes.push(e)})))}return r(t._babylonTransformNode),this.logClose(),Promise.all(a).then((function(){return t._babylonTransformNode}))},e.prototype._loadMeshPrimitiveAsync=function(t,n,r,o,a,i){var s=this,l=this._extensionsLoadMeshPrimitiveAsync(t,n,r,o,a,i);if(l)return l;this.logOpen("".concat(t));var c,u,d=0===this._disableInstancedMesh&&this._parent.createInstances&&null==r.skin&&!o.primitives[0].targets;if(d&&a._instanceData)this._babylonScene._blockEntityCollection=!!this._assetContainer,(c=a._instanceData.babylonSourceMesh.createInstance(n))._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,u=a._instanceData.promise;else{var h=new Array;this._babylonScene._blockEntityCollection=!!this._assetContainer;var f=new v.Mesh(n,this._babylonScene);f._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,f.sideOrientation=this._babylonScene.useRightHandedSystem?v.Material.CounterClockWiseSideOrientation:v.Material.ClockWiseSideOrientation,this._createMorphTargets(t,r,o,a,f),h.push(this._loadVertexDataAsync(t,a,f).then((function(e){return s._loadMorphTargetsAsync(t,a,f,e).then((function(){s._disposed||(s._babylonScene._blockEntityCollection=!!s._assetContainer,e.applyToMesh(f),e._parentContainer=s._assetContainer,s._babylonScene._blockEntityCollection=!1)}))})));var p=e._GetDrawMode(t,a.mode);if(null==a.material){var _=this._defaultBabylonMaterialData[p];_||(_=this._createDefaultMaterial("__GLTFLoader._default",p),this._parent.onMaterialLoadedObservable.notifyObservers(_),this._defaultBabylonMaterialData[p]=_),f.material=_}else if(!this.parent.skipMaterials){var m=K.Get("".concat(t,"/material"),this._gltf.materials,a.material);h.push(this._loadMaterialAsync("/materials/".concat(m.index),m,f,p,(function(e){f.material=e})))}u=Promise.all(h),d&&(a._instanceData={babylonSourceMesh:f,promise:u}),c=f}return e.AddPointerMetadata(c,t),this._parent.onMeshLoadedObservable.notifyObservers(c),i(c),this.logClose(),u.then((function(){return c}))},e.prototype._loadVertexDataAsync=function(e,t,n){var r=this,o=this._extensionsLoadVertexDataAsync(e,t,n);if(o)return o;var a=t.attributes;if(!a)throw new Error("".concat(e,": Attributes are missing"));var i=new Array,s=new v.Geometry(n.name,this._babylonScene);if(null==t.indices)n.isUnIndexed=!0;else{var l=K.Get("".concat(e,"/indices"),this._gltf.accessors,t.indices);i.push(this._loadIndicesAccessorAsync("/accessors/".concat(l.index),l).then((function(e){s.setIndices(e)})))}var c=function(t,o,l){if(null!=a[t]){n._delayInfo=n._delayInfo||[],-1===n._delayInfo.indexOf(o)&&n._delayInfo.push(o);var c=K.Get("".concat(e,"/attributes/").concat(t),r._gltf.accessors,a[t]);i.push(r._loadVertexAccessorAsync("/accessors/".concat(c.index),c,o).then((function(e){var t,o;if(e.getKind()===v.VertexBuffer.PositionKind&&!r.parent.alwaysComputeBoundingBox&&!n.skeleton&&c.min&&c.max){var a=(t=v.TmpVectors.Vector3[0]).copyFromFloats.apply(t,c.min),i=(o=v.TmpVectors.Vector3[1]).copyFromFloats.apply(o,c.max);if(c.normalized&&5126!==c.componentType){var l=1;switch(c.componentType){case 5120:l=127;break;case 5121:l=255;break;case 5122:l=32767;break;case 5123:l=65535}var u=1/l;a.scaleInPlace(u),i.scaleInPlace(u)}s._boundingInfo=new v.BoundingInfo(a,i),s.useBoundingInfoFromGeometry=!0}s.setVerticesBuffer(e,c.count)}))),o==v.VertexBuffer.MatricesIndicesExtraKind&&(n.numBoneInfluencers=8),l&&l(c)}};return c("POSITION",v.VertexBuffer.PositionKind),c("NORMAL",v.VertexBuffer.NormalKind),c("TANGENT",v.VertexBuffer.TangentKind),c("TEXCOORD_0",v.VertexBuffer.UVKind),c("TEXCOORD_1",v.VertexBuffer.UV2Kind),c("TEXCOORD_2",v.VertexBuffer.UV3Kind),c("TEXCOORD_3",v.VertexBuffer.UV4Kind),c("TEXCOORD_4",v.VertexBuffer.UV5Kind),c("TEXCOORD_5",v.VertexBuffer.UV6Kind),c("JOINTS_0",v.VertexBuffer.MatricesIndicesKind),c("WEIGHTS_0",v.VertexBuffer.MatricesWeightsKind),c("JOINTS_1",v.VertexBuffer.MatricesIndicesExtraKind),c("WEIGHTS_1",v.VertexBuffer.MatricesWeightsExtraKind),c("COLOR_0",v.VertexBuffer.ColorKind,(function(e){"VEC4"===e.type&&(n.hasVertexAlpha=!0)})),Promise.all(i).then((function(){return s}))},e.prototype._createMorphTargets=function(e,t,n,r,o){if(r.targets&&this._parent.loadMorphTargets){if(null==t._numMorphTargets)t._numMorphTargets=r.targets.length;else if(r.targets.length!==t._numMorphTargets)throw new Error("".concat(e,": Primitives do not have the same number of targets"));var a=n.extras?n.extras.targetNames:null;this._babylonScene._blockEntityCollection=!!this._assetContainer,o.morphTargetManager=new v.MorphTargetManager(this._babylonScene),o.morphTargetManager._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,o.morphTargetManager.areUpdatesFrozen=!0;for(var i=0;i<r.targets.length;i++){var s=t.weights?t.weights[i]:n.weights?n.weights[i]:0,l=a?a[i]:"morphTarget".concat(i);o.morphTargetManager.addTarget(new v.MorphTarget(l,s,o.getScene()))}}},e.prototype._loadMorphTargetsAsync=function(e,t,n,r){if(!t.targets||!this._parent.loadMorphTargets)return Promise.resolve();for(var o=new Array,a=n.morphTargetManager,i=0;i<a.numTargets;i++){var s=a.getTarget(i);o.push(this._loadMorphTargetVertexDataAsync("".concat(e,"/targets/").concat(i),r,t.targets[i],s))}return Promise.all(o).then((function(){a.areUpdatesFrozen=!1}))},e.prototype._loadMorphTargetVertexDataAsync=function(e,t,n,r){var o=this,a=new Array,i=function(r,i,s){if(null!=n[r]){var l=t.getVertexBuffer(i);if(l){var c=K.Get("".concat(e,"/").concat(r),o._gltf.accessors,n[r]);a.push(o._loadFloatAccessorAsync("/accessors/".concat(c.index),c).then((function(e){s(l,e)})))}}};return i("POSITION",v.VertexBuffer.PositionKind,(function(e,t){var n=new Float32Array(t.length);e.forEach(t.length,(function(e,r){n[r]=t[r]+e})),r.setPositions(n)})),i("NORMAL",v.VertexBuffer.NormalKind,(function(e,t){var n=new Float32Array(t.length);e.forEach(n.length,(function(e,r){n[r]=t[r]+e})),r.setNormals(n)})),i("TANGENT",v.VertexBuffer.TangentKind,(function(e,t){var n=new Float32Array(t.length/3*4),o=0;e.forEach(t.length/3*4,(function(e,r){(r+1)%4!=0&&(n[o]=t[o]+e,o++)})),r.setTangents(n)})),Promise.all(a).then((function(){}))},e._LoadTransform=function(e,t){if(null==e.skin){var n=v.Vector3.Zero(),r=v.Quaternion.Identity(),o=v.Vector3.One();e.matrix?v.Matrix.FromArray(e.matrix).decompose(o,r,n):(e.translation&&(n=v.Vector3.FromArray(e.translation)),e.rotation&&(r=v.Quaternion.FromArray(e.rotation)),e.scale&&(o=v.Vector3.FromArray(e.scale))),t.position=n,t.rotationQuaternion=r,t.scaling=o}},e.prototype._loadSkinAsync=function(e,t,n,r){var o=this;if(!this._parent.loadSkins)return Promise.resolve();var a=this._extensionsLoadSkinAsync(e,t,n);if(a)return a;if(n._data)return r(n._data.babylonSkeleton),n._data.promise;var i="skeleton".concat(n.index);this._babylonScene._blockEntityCollection=!!this._assetContainer;var s=new v.Skeleton(n.name