text: !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,(function(e){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=19)}([function(t,n){t.exports=e},function(e,t,n){"use strict";n.d(t,"a",(function(){return a})),n.d(t,"b",(function(){return i}));var r=n(0),o=n(2),a=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.Assign=function(e){if(e)for(var t=0;t<e.length;t++)e[t].index=t},e}(),i=function(){function e(e){this._completePromises=new Array,this._assetContainer=null,this._babylonLights=[],this._disableInstancedMesh=0,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(t,n){e.UnregisterExtension(t)&&r.Logger.Warn("Extension with the name '".concat(t,"' already exists")),e._RegisteredExtensions[t]={factory:n}},e.UnregisterExtension=function(t){return!!e._RegisteredExtensions[t]&&(delete e._RegisteredExtensions[t],!0)},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}),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()}}))}))},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,i){var s=this;return Promise.resolve().then((function(){s._rootUrl=e,s._uniqueRootUrl=!r.StringTools.StartsWith(e,"file:")&&t?e:"".concat(e).concat(Date.now(),"/"),s._fileName=t,s._loadExtensions(),s._checkExtensions();var l="".concat(o.GLTFLoaderState[o.GLTFLoaderState.LOADING]," => ").concat(o.GLTFLoaderState[o.GLTFLoaderState.READY]),c="".concat(o.GLTFLoaderState[o.GLTFLoaderState.LOADING]," => ").concat(o.GLTFLoaderState[o.GLTFLoaderState.COMPLETE]);s._parent._startPerformanceCounter(l),s._parent._startPerformanceCounter(c),s._parent._setState(o.GLTFLoaderState.LOADING),s._extensionsOnLoading();var u=new Array,d=s._babylonScene.blockMaterialDirtyMechanism;if(s._babylonScene.blockMaterialDirtyMechanism=!0,n)u.push(s.loadSceneAsync("/nodes",{nodes:n,index:-1}));else if(null!=s._gltf.scene||s._gltf.scenes&&s._gltf.scenes[0]){var f=a.Get("/scene",s._gltf.scenes,s._gltf.scene||0);u.push(s.loadSceneAsync("/scenes/".concat(f.index),f))}if(s.parent.loadAllMaterials&&s._gltf.materials)for(var h=0;h<s._gltf.materials.length;++h){var p=s._gltf.materials[h],_="/materials/"+h,m=r.Material.TriangleFillMode;u.push(s._loadMaterialAsync(_,p,null,m,(function(e){})))}return s._babylonScene.blockMaterialDirtyMechanism=d,s._parent.compileMaterials&&u.push(s._compileMaterialsAsync()),s._parent.compileShadowGenerators&&u.push(s._compileShadowGeneratorsAsync()),Promise.all(u).then((function(){return s._rootBabylonMesh&&s._rootBabylonMesh.setEnabled(!0),s._extensionsOnReady(),s._parent._setState(o.GLTFLoaderState.READY),s._startAnimations(),i()})).then((function(e){return s._parent._endPerformanceCounter(l),r.Tools.SetImmediate((function(){s._disposed||Promise.all(s._completePromises).then((function(){s._parent._endPerformanceCounter(c),s._parent._setState(o.GLTFLoaderState.COMPLETE),s._parent.onCompleteObservable.notifyObservers(void 0),s._parent.onCompleteObservable.clear(),s.dispose()}),(function(e){s._parent.onErrorObservable.notifyObservers(e),s._parent.onErrorObservable.clear(),s.dispose()}))})),e}))})).catch((function(e){throw s._disposed||(s._parent.onErrorObservable.notifyObservers(e),s._parent.onErrorObservable.clear(),s.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)&&r.Logger.Warn("Binary buffer length (".concat(n.byteLength,") from JSON does not match chunk length (").concat(e.bin.byteLength,")")),this._bin=e.bin}else r.Logger.Warn("Unexpected BIN chunk")}},e.prototype._setupData=function(){if(a.Assign(this._gltf.accessors),a.Assign(this._gltf.animations),a.Assign(this._gltf.buffers),a.Assign(this._gltf.bufferViews),a.Assign(this._gltf.cameras),a.Assign(this._gltf.images),a.Assign(this._gltf.materials),a.Assign(this._gltf.meshes),a.Assign(this._gltf.nodes),a.Assign(this._gltf.samplers),a.Assign(this._gltf.scenes),a.Assign(this._gltf.skins),a.Assign(this._gltf.textures),this._gltf.nodes){for(var e={},t=0,n=this._gltf.nodes;t<n.length;t++){if((c=n[t]).children)for(var r=0,o=c.children;r<o.length;r++){e[o[r]]=c.index}}for(var i=this._createRootNode(),s=0,l=this._gltf.nodes;s<l.length;s++){var c,u=e[(c=l[s]).index];c.parent=void 0===u?i:this._gltf.nodes[u]}}},e.prototype._loadExtensions=function(){for(var t in e._RegisteredExtensions){var n=e._RegisteredExtensions[t].factory(this);n.name!==t&&r.Logger.Warn("The name of the glTF loader extension instance does not match the registered name: ".concat(n.name," !== ").concat(t)),this._extensions.push(n),this._parent.onExtensionLoadedObservable.notifyObservers(n)}this._extensions.sort((function(e,t){return(e.order||Number.MAX_VALUE)-(t.order||Number.MAX_VALUE)})),this._parent.onExtensionLoadedObservable.clear()},e.prototype._checkExtensions=function(){if(this._gltf.extensionsRequired)for(var e=function(e){if(!t._extensions.some((function(t){return t.name===e&&t.enabled})))throw new Error("Require extension ".concat(e," is not available"))},t=this,n=0,r=this._gltf.extensionsRequired;n<r.length;n++){e(r[n])}},e.prototype._createRootNode=function(){this._babylonScene._blockEntityCollection=!!this._assetContainer,this._rootBabylonMesh=new r.Mesh("__root__",this._babylonScene),this._rootBabylonMesh._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._rootBabylonMesh.setEnabled(!1);var t={_babylonTransformNode:this._rootBabylonMesh,index:-1};switch(this._parent.coordinateSystemMode){case o.GLTFLoaderCoordinateSystemMode.AUTO:this._babylonScene.useRightHandedSystem||(t.rotation=[0,1,0,0],t.scale=[1,1,-1],e._LoadTransform(t,this._rootBabylonMesh));break;case o.GLTFLoaderCoordinateSystemMode.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(this._rootBabylonMesh),t},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 i=0,s=t.nodes;i<s.length;i++){var l=s[i],c=a.Get("".concat(e,"/nodes/").concat(l),this._gltf.nodes,l);o.push(this.loadNodeAsync("/nodes/".concat(c.index),c,(function(e){e.parent=n._rootBabylonMesh})))}for(var u=0,d=this._postSceneLoadActions;u<d.length;u++){(0,d[u])()}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=new Array,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=new Array;this._rootBabylonMesh&&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=new Array,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)}return e},e.prototype._getSkeletons=function(){var e=new Array,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=new Array,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 o.GLTFLoaderAnimationStartMode.NONE:break;case o.GLTFLoaderAnimationStartMode.FIRST:0!==(e=this._getAnimationGroups()).length&&e[0].start(!0);break;case o.GLTFLoaderAnimationStartMode.ALL:for(var e,t=0,n=e=this._getAnimationGroups();t<n.length;t++){n[t].start(!0)}break;default:return void r.Logger.Error("Invalid animation start mode (".concat(this._parent.animationStartMode,")"))}},e.prototype.loadNodeAsync=function(t,n,o){var i=this;void 0===o&&(o=function(){});var s=this._extensionsLoadNodeAsync(t,n,o);if(s)return s;if(n._babylonTransformNode)throw new Error("".concat(t,": Invalid recursive node hierarchy"));var l=new Array;this.logOpen("".concat(t," ").concat(n.name||""));var c=function(r){if(e.AddPointerMetadata(r,t),e._LoadTransform(n,r),null!=n.camera){var s=a.Get("".concat(t,"/camera"),i._gltf.cameras,n.camera);l.push(i.loadCameraAsync("/cameras/".concat(s.index),s,(function(e){e.parent=r})))}if(n.children)for(var c=0,u=n.children;c<u.length;c++){var d=u[c],f=a.Get("".concat(t,"/children/").concat(d),i._gltf.nodes,d);l.push(i.loadNodeAsync("/nodes/".concat(f.index),f,(function(e){e.parent=r})))}o(r)};if(null==n.mesh||null!=n.skin){var u=n.name||"node".concat(n.index);this._babylonScene._blockEntityCollection=!!this._assetContainer,n._babylonTransformNode=new r.TransformNode(u,this._babylonScene),n._babylonTransformNode._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,c(n._babylonTransformNode)}if(null!=n.mesh)if(null==n.skin){var d=a.Get("".concat(t,"/mesh"),this._gltf.meshes,n.mesh);l.push(this._loadMeshAsync("/meshes/".concat(d.index),n,d,c))}else{d=a.Get("".concat(t,"/mesh"),this._gltf.meshes,n.mesh);l.push(this._loadMeshAsync("/meshes/".concat(d.index),n,d,(function(r){e.AddPointerMetadata(r,t);var o=a.Get("".concat(t,"/skin"),i._gltf.skins,n.skin);l.push(i._loadSkinAsync("/skins/".concat(o.index),n,o,(function(e){i._forEachPrimitive(n,(function(t){t.skeleton=e})),i._postSceneLoadActions.push((function(){if(null!=o.skeleton){var e=a.Get("/skins/".concat(o.index,"/skeleton"),i._gltf.nodes,o.skeleton);r.parent=e.parent._babylonTransformNode}else r.parent=i._rootBabylonMesh}))})))})))}return this.logClose(),Promise.all(l).then((function(){return i._forEachPrimitive(n,(function(e){e.geometry&&e.geometry.useBoundingInfoFromGeometry?e._updateBoundingInfo():e.refreshBoundingInfo(!0)})),n._babylonTransformNode}))},e.prototype._loadMeshAsync=function(e,t,n,o){var i=n.primitives;if(!i||!i.length)throw new Error("".concat(e,": Primitives are missing"));null==i[0].index&&a.Assign(i);var s=new Array;this.logOpen("".concat(e," ").concat(n.name||""));var l=t.name||"node".concat(t.index);if(1===i.length){var c=n.primitives[0];s.push(this._loadMeshPrimitiveAsync("".concat(e,"/primitives/").concat(c.index),l,t,n,c,(function(e){t._babylonTransformNode=e,t._primitiveBabylonMeshes=[e]})))}else{this._babylonScene._blockEntityCollection=!!this._assetContainer,t._babylonTransformNode=new r.TransformNode(l,this._babylonScene),t._babylonTransformNode._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,t._primitiveBabylonMeshes=[];for(var u=0,d=i;u<d.length;u++){c=d[u];s.push(this._loadMeshPrimitiveAsync("".concat(e,"/primitives/").concat(c.index),"".concat(l,"_primitive").concat(c.index),t,n,c,(function(e){e.parent=t._babylonTransformNode,t._primitiveBabylonMeshes.push(e)})))}}return o(t._babylonTransformNode),this.logClose(),Promise.all(s).then((function(){return t._babylonTransformNode}))},e.prototype._loadMeshPrimitiveAsync=function(t,n,o,i,s,l){var c=this,u=this._extensionsLoadMeshPrimitiveAsync(t,n,o,i,s,l);if(u)return u;this.logOpen("".concat(t));var d,f,h=0===this._disableInstancedMesh&&this._parent.createInstances&&null==o.skin&&!i.primitives[0].targets;if(h&&s._instanceData)this._babylonScene._blockEntityCollection=!!this._assetContainer,(d=s._instanceData.babylonSourceMesh.createInstance(n))._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,f=s._instanceData.promise;else{var p=new Array;this._babylonScene._blockEntityCollection=!!this._assetContainer;var _=new r.Mesh(n,this._babylonScene);_._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,_.overrideMaterialSideOrientation=this._babylonScene.useRightHandedSystem?r.Material.CounterClockWiseSideOrientation:r.Material.ClockWiseSideOrientation,this._createMorphTargets(t,o,i,s,_),p.push(this._loadVertexDataAsync(t,s,_).then((function(e){return c._loadMorphTargetsAsync(t,s,_,e).then((function(){c._babylonScene._blockEntityCollection=!!c._assetContainer,e.applyToMesh(_),e._parentContainer=c._assetContainer,c._babylonScene._blockEntityCollection=!1}))})));var m=e._GetDrawMode(t,s.mode);if(null==s.material){var y=this._defaultBabylonMaterialData[m];y||(y=this._createDefaultMaterial("__GLTFLoader._default",m),this._parent.onMaterialLoadedObservable.notifyObservers(y),this._defaultBabylonMaterialData[m]=y),_.material=y}else{var b=a.Get("".concat(t,"/material"),this._gltf.materials,s.material);p.push(this._loadMaterialAsync("/materials/".concat(b.index),b,_,m,(function(e){_.material=e})))}f=Promise.all(p),h&&(s._instanceData={babylonSourceMesh:_,promise:f}),d=_}return e.AddPointerMetadata(d,t),this._parent.onMeshLoadedObservable.notifyObservers(d),l(d),this.logClose(),f.then((function(){return d}))},e.prototype._loadVertexDataAsync=function(e,t,n){var o=this,i=this._extensionsLoadVertexDataAsync(e,t,n);if(i)return i;var s=t.attributes;if(!s)throw new Error("".concat(e,": Attributes are missing"));var l=new Array,c=new r.Geometry(n.name,this._babylonScene);if(null==t.indices)n.isUnIndexed=!0;else{var u=a.Get("".concat(e,"/indices"),this._gltf.accessors,t.indices);l.push(this._loadIndicesAccessorAsync("/accessors/".concat(u.index),u).then((function(e){c.setIndices(e)})))}var d=function(t,i,u){if(null!=s[t]){n._delayInfo=n._delayInfo||[],-1===n._delayInfo.indexOf(i)&&n._delayInfo.push(i);var d=a.Get("".concat(e,"/attributes/").concat(t),o._gltf.accessors,s[t]);l.push(o._loadVertexAccessorAsync("/accessors/".concat(d.index),d,i).then((function(e){if(e.getKind()===r.VertexBuffer.PositionKind&&!o.parent.alwaysComputeBoundingBox&&!n.skeleton){var t=d.min,a=d.max;if(void 0!==t&&void 0!==a){if(d.normalized&&5126!==d.componentType){var i=1;switch(d.componentType){case 5120:i=127;break;case 5121:i=255;break;case 5122:i=32767;break;case 5123:i=65535}for(var s=0;s<3;++s)t[s]=Math.max(t[s]/i,-1),a[s]=Math.max(a[s]/i,-1)}var l=r.TmpVectors.Vector3[0],u=r.TmpVectors.Vector3[1];l.copyFromFloats.apply(l,t),u.copyFromFloats.apply(u,a),c._boundingInfo=new r.BoundingInfo(l,u),c.useBoundingInfoFromGeometry=!0}}c.setVerticesBuffer(e,d.count)}))),i==r.VertexBuffer.MatricesIndicesExtraKind&&(n.numBoneInfluencers=8),u&&u(d)}};return d("POSITION",r.VertexBuffer.PositionKind),d("NORMAL",r.VertexBuffer.NormalKind),d("TANGENT",r.VertexBuffer.TangentKind),d("TEXCOORD_0",r.VertexBuffer.UVKind),d("TEXCOORD_1",r.VertexBuffer.UV2Kind),d("TEXCOORD_2",r.VertexBuffer.UV3Kind),d("TEXCOORD_3",r.VertexBuffer.UV4Kind),d("TEXCOORD_4",r.VertexBuffer.UV5Kind),d("TEXCOORD_5",r.VertexBuffer.UV6Kind),d("JOINTS_0",r.VertexBuffer.MatricesIndicesKind),d("WEIGHTS_0",r.VertexBuffer.MatricesWeightsKind),d("JOINTS_1",r.VertexBuffer.MatricesIndicesExtraKind),d("WEIGHTS_1",r.VertexBuffer.MatricesWeightsExtraKind),d("COLOR_0",r.VertexBuffer.ColorKind,(function(e){"VEC4"===e.type&&(n.hasVertexAlpha=!0)})),Promise.all(l).then((function(){return c}))},e.prototype._createMorphTargets=function(e,t,n,o,a){if(o.targets){if(null==t._numMorphTargets)t._numMorphTargets=o.targets.length;else if(o.targets.length!==t._numMorphTargets)throw new Error("".concat(e,": Primitives do not have the same number of targets"));var i=n.extras?n.extras.targetNames:null;a.morphTargetManager=new r.MorphTargetManager(a.getScene()),a.morphTargetManager.areUpdatesFrozen=!0;for(var s=0;s<o.targets.length;s++){var l=t.weights?t.weights[s]:n.weights?n.weights[s]:0,c=i?i[s]:"morphTarget".concat(s);a.morphTargetManager.addTarget(new r.MorphTarget(c,l,a.getScene()))}}},e.prototype._loadMorphTargetsAsync=function(e,t,n,r){if(!t.targets)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,o){var i=this,s=new Array,l=function(r,o,l){if(null!=n[r]){var c=t.getVertexBuffer(o);if(c){var u=a.Get("".concat(e,"/").concat(r),i._gltf.accessors,n[r]);s.push(i._loadFloatAccessorAsync("/accessors/".concat(u.index),u).then((function(e){l(c,e)})))}}};return l("POSITION",r.VertexBuffer.PositionKind,(function(e,t){var n=new Float32Array(t.length);e.forEach(t.length,(function(e,r){n[r]=t[r]+e})),o.setPositions(n)})),l("NORMAL",r.VertexBuffer.NormalKind,(function(e,t){var n=new Float32Array(t.length);e.forEach(n.length,(function(e,r){n[r]=t[r]+e})),o.setNormals(n)})),l("TANGENT",r.VertexBuffer.TangentKind,(function(e,t){var n=new Float32Array(t.length/3*4),r=0;e.forEach(t.length/3*4,(function(e,o){(o+1)%4!=0&&(n[r]=t[r]+e,r++)})),o.setTangents(n)})),Promise.all(s).then((function(){}))},e._LoadTransform=function(e,t){if(null==e.skin){var n=r.Vector3.Zero(),o=r.Quaternion.Identity(),a=r.Vector3.One();if(e.matrix)r.Matrix.FromArray(e.matrix).decompose(a,o,n);else e.translation&&(n=r.Vector3.FromArray(e.translation)),e.rotation&&(o=r.Quaternion.FromArray(e.rotation)),e.scale&&(a=r.Vector3.FromArray(e.scale));t.position=n,t.rotationQuaternion=o,t.scaling=a}},e.prototype._loadSkinAsync=function(e,t,n,o){var a=this,i=this._extensionsLoadSkinAsync(e,t,n);if(i)return i;if(n._data)return o(n._data.babylonSkeleton),n._data.promise;var s="skeleton".concat(n.index);this._babylonScene._blockEntityCollection=!!this._assetContainer;var l=new r.Skeleton(n.name||s,s,this._babylonScene);l._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._loadBones(e,n,l);var c=this._loadSkinInverseBindMatricesDataAsync(e,n).then((function(e){a._updateBoneMatrices(l,e)}));return n._data={babylonSkeleton:l,promise:c},o(l),c},e.prototype._loadBones=function(e,t,n){if(null==t.skeleton){var o=this._findSkeletonRootNode("".concat(e,"/joints"),t.joints);o?t.skeleton=o.index:r.Logger.Warn("".concat(e,": Failed to find common root"))}for(var i={},s=0,l=t.joints;s<l.length;s++){var c=l[s],u=a.Get("".concat(e,"/joints/").concat(c),this._gltf.nodes,c);this._loadBone(u,t,n,i)}},e.prototype._findSkeletonRootNode=function(e,t){for(var n={},r=0,o=t;r<o.length;r++){for(var i=o[r],s=new Array,l=a.Get("".concat(e,"/").concat(i),this._gltf.nodes,i);-1!==l.index;)s.unshift(l),l=l.parent;n[i]=s}for(var c=null,u=0;;++u){if(u>=(s=n[t[0]]).length)return c;l=s[u];for(var d=1;d<t.length;++d)if(u>=(s=n[t[d]]).length||l!==s[u])return c;c=l}},e.prototype._loadBone=function(e,t,n,o){var a=o[e.index];if(a)return a;var i=null;e.index!==t.skeleton&&(e.parent&&-1!==e.parent.index?i=this._loadBone(e.parent,t,n,o):void 0!==t.skeleton&&r.Logger.Warn("/skins/".concat(t.index,"/skeleton: Skeleton node is not a common root")));var s=t.joints.indexOf(e.index);return a=new r.Bone(e.name||"joint".concat(e.index),n,i,this._getNodeMatrix(e),null,null,s),o[e.index]=a,this._postSceneLoadActions.push((function(){a.linkTransformNode(e._babylonTransformNode)})),a},e.prototype._loadSkinInverseBindMatricesDataAsync=function(e,t){if(null==t.inverseBindMatrices)return Promise.resolve(null);var n=a.Get("".concat(e,"/inverseBindMatrices"),this._gltf.accessors,t.inverseBindMatrices);return this._loadFloatAccessorAsync("/accessors/".concat(n.index),n)},e.prototype._updateBoneMatrices=function(e,t){for(var n=0,o=e.bones;n<o.length;n++){var a=o[n],i=r.Matrix.Identity(),s=a._index;t&&-1!==s&&(r.Matrix.FromArrayToRef(t,16*s,i),i.invertToRef(i));var l=a.getParent();l&&i.multiplyToRef(l.getInvertedAbsoluteTransform(),i),a.updateMatrix(i,!1,!1),a._updateDifferenceMatrix(void 0,!1)}},e.prototype._getNodeMatrix=function(e){return e.matrix?r.Matrix.FromArray(e.matrix):r.Matrix.Compose(e.scale?r.Vector3.FromArray(e.scale):r.Vector3.One(),e.rotation?r.Quaternion.FromArray(e.rotation):r.Quaternion.Identity(),e.translation?r.Vector3.FromArray(e.translation):r.Vector3.Zero())},e.prototype.loadCameraAsync=function(t,n,o){void 0===o&&(o=function(){});var a=this._extensionsLoadCameraAsync(t,n,o);if(a)return a;var i=new Array;this.logOpen("".concat(t," ").concat(n.name||"")),this._babylonScene._blockEntityCollection=!!this._assetContainer;var s=new r.FreeCamera(n.name||"camera".concat(n.index),r.Vector3.Zero(),this._babylonScene,!1);switch(s._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,s.ignoreParentScaling=!0,s.rotation=new r.Vector3(0,Math.PI,0),n.type){case"perspective":var l=n.perspective;if(!l)throw new Error("".concat(t,": Camera perspective properties are missing"));s.fov=l.yfov,s.minZ=l.znear,s.maxZ=l.zfar||0;break;case"orthographic":if(!n.orthographic)throw new Error("".concat(t,": Camera orthographic properties are missing"));s.mode=r.Camera.ORTHOGRAPHIC_CAMERA,s.orthoLeft=-n.orthographic.xmag,s.orthoRight=n.orthographic.xmag,s.orthoBottom=-n.orthographic.ymag,s.orthoTop=n.orthographic.ymag,s.minZ=n.orthographic.znear,s.maxZ=n.orthographic.zfar;break;default:throw new Error("".concat(t,": Invalid camera type (").concat(n.type,")"))}return e.AddPointerMetadata(s,t),this._parent.onCameraLoadedObservable.notifyObservers(s),o(s),this.logClose(),Promise.all(i).then((function(){return s}))},e.prototype._loadAnimationsAsync=function(){var e=this._gltf.animations;if(!e)return Promise.resolve();for(var t=new Array,n=0;n<e.length;n++){var r=e[n];t.push(this.loadAnimationAsync("/animations/".concat(r.index),r).then((function(e){0===e.targetedAnimations.length&&e.dispose()})))}return Promise.all(t).then((function(){}))},e.prototype.loadAnimationAsync=function(e,t){var n=this._extensionsLoadAnimationAsync(e,t);if(n)return n;this._babylonScene._blockEntityCollection=!!this._assetContainer;var o=new r.AnimationGroup(t.name||"animation".concat(t.index),this._babylonScene);o._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,t._babylonAnimationGroup=o;var i=new Array;a.Assign(t.channels),a.Assign(t.samplers);for(var s=0,l=t.channels;s<l.length;s++){var c=l[s];i.push(this._loadAnimationChannelAsync("".concat(e,"/channels/").concat(c.index),e,t,c,o))}return Promise.all(i).then((function(){return o.normalize(0),o}))},e.prototype._loadAnimationChannelAsync=function(e,t,n,o,i,s){var l=this;if(void 0===s&&(s=null),null==o.target.node)return Promise.resolve();var c=a.Get("".concat(e,"/target/node"),this._gltf.nodes,o.target.node);if("weights"===o.target.path&&!c._numMorphTargets||"weights"!==o.target.path&&!c._babylonTransformNode)return Promise.resolve();var u=a.Get("".concat(e,"/sampler"),n.samplers,o.sampler);return this._loadAnimationSamplerAsync("".concat(t,"/samplers/").concat(o.sampler),u).then((function(t){var n,a;switch(o.target.path){case"translation":n="position",a=r.Animation.ANIMATIONTYPE_VECTOR3;break;case"rotation":n="rotationQuaternion",a=r.Animation.ANIMATIONTYPE_QUATERNION;break;case"scale":n="scaling",a=r.Animation.ANIMATIONTYPE_VECTOR3;break;case"weights":n="influence",a=r.Animation.ANIMATIONTYPE_FLOAT;break;default:throw new Error("".concat(e,"/target/path: Invalid value (").concat(o.target.path,")"))}var u,d,f=0;switch(n){case"position":u=function(){var e=r.Vector3.FromArray(t.output,f);return f+=3,e};break;case"rotationQuaternion":u=function(){var e=r.Quaternion.FromArray(t.output,f);return f+=4,e};break;case"scaling":u=function(){var e=r.Vector3.FromArray(t.output,f);return f+=3,e};break;case"influence":u=function(){for(var e=new Array(c._numMorphTargets),n=0;n<c._numMorphTargets;n++)e[n]=t.output[f++];return e}}switch(t.interpolation){case"STEP":d=function(e){return{frame:t.input[e]*l.parent.targetFps,value:u(),interpolation:r.AnimationKeyInterpolation.STEP}};break;case"LINEAR":d=function(e){return{frame:t.input[e]*l.parent.targetFps,value:u()}};break;case"CUBICSPLINE":d=function(e){return{frame:t.input[e]*l.parent.targetFps,inTangent:u(),value:u(),outTangent:u()}}}for(var h=new Array(t.input.length),p=0;p<t.input.length;p++)h[p]=d(p);if("influence"===n)for(var _=function(e){var t="".concat(i.name,"_channel").concat(i.targetedAnimations.length),o=new r.Animation(t,n,l.parent.targetFps,a);o.setKeys(h.map((function(t){return{frame:t.frame,inTangent:t.inTangent?t.inTangent[e]:void 0,value:t.value[e],outTangent:t.outTangent?t.outTangent[e]:void 0}}))),l._forEachPrimitive(c,(function(t){var n=t.morphTargetManager.getTarget(e),r=o.clone();n.animations.push(r),i.addTargetedAnimation(r,n)}))},m=0;m<c._numMorphTargets;m++)_(m);else{var y="".concat(i.name,"_channel").concat(i.targetedAnimations.length),b=new r.Animation(y,n,l.parent.targetFps,a);b.setKeys(h),null!=s&&null!=s.animations?(s.animations.push(b),i.addTargetedAnimation(b,s)):(c._babylonTransformNode.animations.push(b),i.addTargetedAnimation(b,c._babylonTransformNode))}}))},e.prototype._loadAnimationSamplerAsync=function(e,t){if(t._data)return t._data;var n=t.interpolation||"LINEAR";switch(n){case"STEP":case"LINEAR":case"CUBICSPLINE":break;default:throw new Error("".concat(e,"/interpolation: Invalid value (").concat(t.interpolation,")"))}var r=a.Get("".concat(e,"/input"),this._gltf.accessors,t.input),o=a.Get("".concat(e,"/output"),this._gltf.accessors,t.output);return t._data=Promise.all([this._loadFloatAccessorAsync("/accessors/".concat(r.index),r),this._loadFloatAccessorAsync("/accessors/".concat(o.index),o)]).then((function(e){var t=e[0],r=e[1];return{input:t,interpolation:n,output:r}})),t._data},e.prototype.loadBufferAsync=function(e,t,n,r){var o=this._extensionsLoadBufferAsync(e,t,n,r);if(o)return o;if(!t._data)if(t.uri)t._data=this.loadUriAsync("".concat(e,"/uri"),t,t.uri);else{if(!this._bin)throw new Error("".concat(e,": Uri is missing or the binary glTF is missing its binary chunk"));t._data=this._bin.readAsync(0,t.byteLength)}return t._data.then((function(t){try{return new Uint8Array(t.buffer,t.byteOffset+n,r)}catch(t){throw new Error("".concat(e,": ").concat(t.message))}}))},e.prototype.loadBufferViewAsync=function(e,t){var n=this._extensionsLoadBufferViewAsync(e,t);if(n)return n;if(t._data)return t._data;var r=a.Get("".concat(e,"/buffer"),this._gltf.buffers,t.buffer);return t._data=this.loadBufferAsync("/buffers/".concat(r.index),r,t.byteOffset||0,t.byteLength),t._data},e.prototype._loadAccessorAsync=function(t,n,o){var i=this;if(n._data)return n._data;var s=e._GetNumComponents(t,n.type),l=s*r.VertexBuffer.GetTypeByteLength(n.componentType),c=s*n.count;if(null==n.bufferView)n._data=Promise.resolve(new o(c));else{var u=a.Get("".concat(t,"/bufferView"),this._gltf.bufferViews,n.bufferView);n._data=this.loadBufferViewAsync("/bufferViews/".concat(u.index),u).then((function(a){if(5126!==n.componentType||n.normalized||u.byteStride&&u.byteStride!==l){var i=new o(c);return r.VertexBuffer.ForEach(a,n.byteOffset||0,u.byteStride||l,s,n.componentType,i.length,n.normalized||!1,(function(e,t){i[t]=e})),i}return e._GetTypedArray(t,n.componentType,a,n.byteOffset,c)}))}if(n.sparse){var d=n.sparse;n._data=n._data.then((function(c){var u=c,f=a.Get("".concat(t,"/sparse/indices/bufferView"),i._gltf.bufferViews,d.indices.bufferView),h=a.Get("".concat(t,"/sparse/values/bufferView"),i._gltf.bufferViews,d.values.bufferView);return Promise.all([i.loadBufferViewAsync("/bufferViews/".concat(f.index),f),i.loadBufferViewAsync("/bufferViews/".concat(h.index),h)]).then((function(a){var i,c=a[0],f=a[1],h=e._GetTypedArray("".concat(t,"/sparse/indices"),d.indices.componentType,c,d.indices.byteOffset,d.count),p=s*d.count;if(5126!==n.componentType||n.normalized){var _=e._GetTypedArray("".concat(t,"/sparse/values"),n.componentType,f,d.values.byteOffset,p);i=new o(p),r.VertexBuffer.ForEach(_,0,l,s,n.componentType,i.length,n.normalized||!1,(function(e,t){i[t]=e}))}else i=e._GetTypedArray("".concat(t,"/sparse/values"),n.componentType,f,d.values.byteOffset,p);for(var m=0,y=0;y<h.length;y++)for(var b=h[y]*s,v=0;v<s;v++)u[b++]=i[m++];return u}))}))}return n._data},e.prototype._loadFloatAccessorAsync=function(e,t){return this._loadAccessorAsync(e,t,Float32Array)},e.prototype._loadIndicesAccessorAsync=function(t,n){if("SCALAR"!==n.type)throw new Error("".concat(t,"/type: Invalid value ").concat(n.type));if(5121!==n.componentType&&5123!==n.componentType&&5125!==n.componentType)throw new Error("".concat(t,"/componentType: Invalid value ").concat(n.componentType));if(n._data)return n._data;if(n.sparse){var r=e._GetTypedArrayConstructor("".concat(t,"/componentType"),n.componentType);n._data=this._loadAccessorAsync(t,n,r)}else{var o=a.Get("".concat(t,"/bufferView"),this._gltf.bufferViews,n.bufferView);n._data=this.loadBufferViewAsync("/bufferViews/".concat(o.index),o).then((function(r){return e._GetTypedArray(t,n.componentType,r,n.byteOffset,n.count)}))}return n._data},e.prototype._loadVertexBufferViewAsync=function(e,t){var n=this;return e._babylonBuffer||(e._babylonBuffer=this.loadBufferViewAsync("/bufferViews/".concat(e.index),e).then((function(e){return new r.Buffer(n._babylonScene.getEngine(),e,!1)}))),e._babylonBuffer},e.prototype._loadVertexAccessorAsync=function(t,n,o){var i,s=this;if(null===(i=n._babylonVertexBuffer)||void 0===i?void 0:i[o])return n._babylonVertexBuffer[o];if(n._babylonVertexBuffer||(n._babylonVertexBuffer={}),n.sparse)n._babylonVertexBuffer[o]=this._loadFloatAccessorAsync(t,n).then((function(e){return new r.VertexBuffer(s._babylonScene.getEngine(),e,o,!1)}));else if(o===r.VertexBuffer.MatricesIndicesKind||o===r.VertexBuffer.MatricesIndicesExtraKind)n._babylonVertexBuffer[o]=this._loadFloatAccessorAsync(t,n).then((function(e){return new r.VertexBuffer(s._babylonScene.getEngine(),e,o,!1)}));else{var l=a.Get("".concat(t,"/bufferView"),this._gltf.bufferViews,n.bufferView);n._babylonVertexBuffer[o]=this._loadVertexBufferViewAsync(l,o).then((function(a){var i=e._GetNumComponents(t,n.type);return new r.VertexBuffer(s._babylonScene.getEngine(),a,o,!1,!1,l.byteStride,!1,n.byteOffset,i,n.componentType,n.normalized,!0,1,!0)}))}return n._babylonVertexBuffer[o]},e.prototype._loadMaterialMetallicRoughnessPropertiesAsync=function(e,t,n){if(!(n instanceof r.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));var o=new Array;return t&&(t.baseColorFactor?(n.albedoColor=r.Color3.FromArray(t.baseColorFactor),n.alpha=t.baseColorFactor[3]):n.albedoColor=r.Color3.White(),n.metallic=null==t.metallicFactor?1:t.metallicFactor,n.roughness=null==t.roughnessFactor?1:t.roughnessFactor,t.baseColorTexture&&o.push(this.loadTextureInfoAsync("".concat(e,"/baseColorTexture"),t.baseColorTexture,(function(e){e.name="".concat(n.name," (Base Color)"),n.albedoTexture=e}))),t.metallicRoughnessTexture&&(t.metallicRoughnessTexture.nonColorData=!0,o.push(this.loadTextureInfoAsync("".concat(e,"/metallicRoughnessTexture"),t.metallicRoughnessTexture,(function(e){e.name="".concat(n.name," (Metallic Roughness)"),n.metallicTexture=e}))),n.useMetallnessFromMetallicTextureBlue=!0,n.useRoughnessFromMetallicTextureGreen=!0,n.useRoughnessFromMetallicTextureAlpha=!1)),Promise.all(o).then((function(){}))},e.prototype._loadMaterialAsync=function(t,n,r,o,a){void 0===a&&(a=function(){});var i=this._extensionsLoadMaterialAsync(t,n,r,o,a);if(i)return i;n._data=n._data||{};var s=n._data[o];if(!s){this.logOpen("".concat(t," ").concat(n.name||""));var l=this.createMaterial(t,n,o);s={babylonMaterial:l,babylonMeshes:[],promise:this.loadMaterialPropertiesAsync(t,n,l)},n._data[o]=s,e.AddPointerMetadata(l,t),this._parent.onMaterialLoadedObservable.notifyObservers(l),this.logClose()}return r&&(s.babylonMeshes.push(r),r.onDisposeObservable.addOnce((function(){var e=s.babylonMeshes.indexOf(r);-1!==e&&s.babylonMeshes.splice(e,1)}))),a(s.babylonMaterial),s.promise.then((function(){return s.babylonMaterial}))},e.prototype._createDefaultMaterial=function(e,t){this._babylonScene._blockEntityCollection=!!this._assetContainer;var n=new r.PBRMaterial(e,this._babylonScene);return n._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,n.fillMode=t,n.enableSpecularAntiAliasing=!0,n.useRadianceOverAlpha=!this._parent.transparencyAsCoverage,n.useSpecularOverAlpha=!this._parent.transparencyAsCoverage,n.transparencyMode=r.PBRMaterial.PBRMATERIAL_OPAQUE,n.metallic=1,n.roughness=1,n},e.prototype.createMaterial=function(e,t,n){var r=this._extensionsCreateMaterial(e,t,n);if(r)return r;var o=t.name||"material".concat(t.index);return this._createDefaultMaterial(o,n)},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this._extensionsLoadMaterialPropertiesAsync(e,t,n);if(r)return r;var o=new Array;return o.push(this.loadMaterialBasePropertiesAsync(e,t,n)),t.pbrMetallicRoughness&&o.push(this._loadMaterialMetallicRoughnessPropertiesAsync("".concat(e,"/pbrMetallicRoughness"),t.pbrMetallicRoughness,n)),this.loadMaterialAlphaProperties(e,t,n),Promise.all(o).then((function(){}))},e.prototype.loadMaterialBasePropertiesAsync=function(e,t,n){if(!(n instanceof r.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));var o=new Array;return n.emissiveColor=t.emissiveFactor?r.Color3.FromArray(t.emissiveFactor):new r.Color3(0,0,0),t.doubleSided&&(n.backFaceCulling=!1,n.twoSidedLighting=!0),t.normalTexture&&(t.normalTexture.nonColorData=!0,o.push(this.loadTextureInfoAsync("".concat(e,"/normalTexture"),t.normalTexture,(function(e){e.name="".concat(n.name," (Normal)"),n.bumpTexture=e}))),n.invertNormalMapX=!this._babylonScene.useRightHandedSystem,n.invertNormalMapY=this._babylonScene.useRightHandedSystem,null!=t.normalTexture.scale&&(n.bumpTexture.level=t.normalTexture.scale),n.forceIrradianceInFragment=!0),t.occlusionTexture&&(t.occlusionTexture.nonColorData=!0,o.push(this.loadTextureInfoAsync("".concat(e,"/occlusionTexture"),t.occlusionTexture,(function(e){e.name="".concat(n.name," (Occlusion)"),n.ambientTexture=e}))),n.useAmbientInGrayScale=!0,null!=t.occlusionTexture.strength&&(n.ambientTextureStrength=t.occlusionTexture.strength)),t.emissiveTexture&&o.push(this.loadTextureInfoAsync("".concat(e,"/emissiveTexture"),t.emissiveTexture,(function(e){e.name="".concat(n.name," (Emissive)"),n.emissiveTexture=e}))),Promise.all(o).then((function(){}))},e.prototype.loadMaterialAlphaProperties=function(e,t,n){if(!(n instanceof r.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));switch(t.alphaMode||"OPAQUE"){case"OPAQUE":n.transparencyMode=r.PBRMaterial.PBRMATERIAL_OPAQUE;break;case"MASK":n.transparencyMode=r.PBRMaterial.PBRMATERIAL_ALPHATEST,n.alphaCutOff=null==t.alphaCutoff?.5:t.alphaCutoff,n.albedoTexture&&(n.albedoTexture.hasAlpha=!0);break;case"BLEND":n.transparencyMode=r.PBRMaterial.PBRMATERIAL_ALPHABLEND,n.albedoTexture&&(n.albedoTexture.hasAlpha=!0,n.useAlphaFromAlbedoTexture=!0);break;default:throw new Error("".concat(e,"/alphaMode: Invalid value (").concat(t.alphaMode,")"))}},e.prototype.loadTextureInfoAsync=function(t,n,r){var o=this;void 0===r&&(r=function(){});var i=this._extensionsLoadTextureInfoAsync(t,n,r);if(i)return i;if(this.logOpen("".concat(t)),n.texCoord>=6)throw new Error("".concat(t,"/texCoord: Invalid value (").concat(n.texCoord,")"));var s=a.Get("".concat(t,"/index"),this._gltf.textures,n.index);s._textureInfo=n;var l=this._loadTextureAsync("/textures/".concat(n.index),s,(function(a){a.coordinatesIndex=n.texCoord||0,e.AddPointerMetadata(a,t),o._parent.onTextureLoadedObservable.notifyObservers(a),r(a)}));return this.logClose(),l},e.prototype._loadTextureAsync=function(t,n,r){void 0===r&&(r=function(){});var o=this._extensionsLoadTextureAsync(t,n,r);if(o)return o;this.logOpen("".concat(t," ").concat(n.name||""));var i=null==n.sampler?e.DefaultSampler:a.Get("".concat(t,"/sampler"),this._gltf.samplers,n.sampler),s=a.Get("".concat(t,"/source"),this._gltf.images,n.source),l=this._createTextureAsync(t,i,s,r,void 0,!n._textureInfo.nonColorData);return this.logClose(),l},e.prototype._createTextureAsync=function(e,t,n,o,a,i){var s=this;void 0===o&&(o=function(){});var l=this._loadSampler("/samplers/".concat(t.index),t),c=new Array,u=new r.Deferred;this._babylonScene._blockEntityCollection=!!this._assetContainer;var d={noMipmap:l.noMipMaps,invertY:!1,samplingMode:l.samplingMode,onLoad:function(){s._disposed||u.resolve()},onError:function(t,n){s._disposed||u.reject(new Error("".concat(e,": ").concat(n&&n.message?n.message:t||"Failed to load texture")))},mimeType:n.mimeType,loaderOptions:a,useSRGBBuffer:!!i&&this._parent.useSRGBBuffers},f=new r.Texture(null,this._babylonScene,d);return f._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,c.push(u.promise),c.push(this.loadImageAsync("/images/".concat(n.index),n).then((function(e){var t=n.uri||"".concat(s._fileName,"#image").concat(n.index),r="data:".concat(s._uniqueRootUrl).concat(t);f.updateURL(r,e)}))),f.wrapU=l.wrapU,f.wrapV=l.wrapV,o(f),Promise.all(c).then((function(){return f}))},e.prototype._loadSampler=function(t,n){return n._data||(n._data={noMipMaps:9728===n.minFilter||9729===n.minFilter,samplingMode:e._GetTextureSamplingMode(t,n),wrapU:e._GetTextureWrapMode("".concat(t,"/wrapS"),n.wrapS),wrapV:e._GetTextureWrapMode("".concat(t,"/wrapT"),n.wrapT)}),n._data},e.prototype.loadImageAsync=function(e,t){if(!t._data){if(this.logOpen("".concat(e," ").concat(t.name||"")),t.uri)t._data=this.loadUriAsync("".concat(e,"/uri"),t,t.uri);else{var n=a.Get("".concat(e,"/bufferView"),this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync("/bufferViews/".concat(n.index),n)}this.logClose()}return t._data},e.prototype.loadUriAsync=function(t,n,o){var a=this,i=this._extensionsLoadUriAsync(t,n,o);if(i)return i;if(!e._ValidateUri(o))throw new Error("".concat(t,": '").concat(o,"' is invalid"));if(Object(r.IsBase64DataUrl)(o)){var s=new Uint8Array(Object(r.DecodeBase64UrlToBinary)(o));return this.log("".concat(t,": Decoded ").concat(o.substr(0,64),"... (").concat(s.length," bytes)")),Promise.resolve(s)}return this.log("".concat(t,": Loading ").concat(o)),this._parent.preprocessUrlAsync(this._rootUrl+o).then((function(e){return new Promise((function(n,i){a._parent._loadFile(a._babylonScene,e,(function(e){a._disposed||(a.log("".concat(t,": Loaded ").concat(o," (").concat(e.byteLength," bytes)")),n(new Uint8Array(e)))}),!0,(function(e){i(new r.LoadFileError("".concat(t,": Failed to load '").concat(o,"'").concat(e?": "+e.status+" "+e.statusText:""),e))}))}))}))},e.AddPointerMetadata=function(e,t){var n=e.metadata=e.metadata||{},r=n.gltf=n.gltf||{};(r.pointers=r.pointers||[]).push(t)},e._GetTextureWrapMode=function(e,t){switch(t=null==t?10497:t){case 33071:return r.Texture.CLAMP_ADDRESSMODE;case 33648:return r.Texture.MIRROR_ADDRESSMODE;case 10497:return r.Texture.WRAP_ADDRESSMODE;default:return r.Logger.Warn("".concat(e,": Invalid value (").concat(t,")")),r.Texture.WRAP_ADDRESSMODE}},e._GetTextureSamplingMode=function(e,t){var n=null==t.magFilter?9729:t.magFilter,o=null==t.minFilter?9987:t.minFilter;if(9729===n)switch(o){case 9728:return r.Texture.LINEAR_NEAREST;case 9729:return r.Texture.LINEAR_LINEAR;case 9984:return r.Texture.LINEAR_NEAREST_MIPNEAREST;case 9985:return r.Texture.LINEAR_LINEAR_MIPNEAREST;case 9986:return r.Texture.LINEAR_NEAREST_MIPLINEAR;case 9987:return r.Texture.LINEAR_LINEAR_MIPLINEAR;default:return r.Logger.Warn("".concat(e,"/minFilter: Invalid value (").concat(o,")")),r.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(9728!==n&&r.Logger.Warn("".concat(e,"/magFilter: Invalid value (").concat(n,")")),o){case 9728:return r.Texture.NEAREST_NEAREST;case 9729:return r.Texture.NEAREST_LINEAR;case 9984:return r.Texture.NEAREST_NEAREST_MIPNEAREST;case 9985:return r.Texture.NEAREST_LINEAR_MIPNEAREST;case 9986:return r.Texture.NEAREST_NEAREST_MIPLINEAR;case 9987:return r.Texture.NEAREST_LINEAR_MIPLINEAR;default:return r.Logger.Warn("".concat(e,"/minFilter: Invalid value (").concat(o,")")),r.Texture.NEAREST_NEAREST_MIPNEAREST}},e._GetTypedArrayConstructor=function(e,t){switch(t){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5125:return Uint32Array;case 5126:return Float32Array;default:throw new Error("".concat(e,": Invalid component type ").concat(t))}},e._GetTypedArray=function(t,n,o,a,i){var s=o.buffer;a=o.byteOffset+(a||0);var l=e._GetTypedArrayConstructor("".concat(t,"/componentType"),n),c=r.VertexBuffer.GetTypeByteLength(n);return a%c!=0?(r.Logger.Warn("".concat(t,": Copying buffer as byte offset (").concat(a,") is not a multiple of component type byte length (").concat(c,")")),new l(s.slice(a,a+i*c),0)):new l(s,a,i)},e._GetNumComponents=function(e,t){switch(t){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16}throw new Error("".concat(e,": Invalid type (").concat(t,")"))},e._ValidateUri=function(e){return r.Tools.IsBase64(e)||-1===e.indexOf("..")},e._GetDrawMode=function(e,t){switch(null==t&&(t=4),t){case 0:return r.Material.PointListDrawMode;case 1:return r.Material.LineListDrawMode;case 2:return r.Material.LineLoopDrawMode;case 3:return r.Material.LineStripDrawMode;case 4:return r.Material.TriangleFillMode;case 5:return r.Material.TriangleStripDrawMode;case 6:return r.Material.TriangleFanDrawMode}throw new Error("".concat(e,": Invalid mesh primitive mode (").concat(t,")"))},e.prototype._compileMaterialsAsync=function(){var e=this;this._parent._startPerformanceCounter("Compile materials");var t=new Array;if(this._gltf.materials)for(var n=0,r=this._gltf.materials;n<r.length;n++){var o=r[n];if(o._data)for(var a in o._data)for(var i=o._data[a],s=0,l=i.babylonMeshes;s<l.length;s++){var c=l[s];c.computeWorldMatrix(!0);var u=i.babylonMaterial;t.push(u.forceCompilationAsync(c)),t.push(u.forceCompilationAsync(c,{useInstances:!0})),this._parent.useClipPlane&&(t.push(u.forceCompilationAsync(c,{clipPlane:!0})),t.push(u.forceCompilationAsync(c,{clipPlane:!0,useInstances:!0})))}}return Promise.all(t).then((function(){e._parent._endPerformanceCounter("Compile materials")}))},e.prototype._compileShadowGeneratorsAsync=function(){var e=this;this._parent._startPerformanceCounter("Compile shadow generators");for(var t=new Array,n=0,r=this._babylonScene.lights;n<r.length;n++){var o=r[n].getShadowGenerator();o&&t.push(o.forceCompilationAsync())}return Promise.all(t).then((function(){e._parent._endPerformanceCounter("Compile shadow generators")}))},e.prototype._forEachExtensions=function(e){for(var t=0,n=this._extensions;t<n.length;t++){var r=n[t];r.enabled&&e(r)}},e.prototype._applyExtensions=function(e,t,n){for(var r=0,o=this._extensions;r<o.length;r++){var a=o[r];if(a.enabled){var i="".concat(a.name,".").concat(t),s=e;s._activeLoaderExtensionFunctions=s._activeLoaderExtensionFunctions||{};var l=s._activeLoaderExtensionFunctions;if(!l[i]){l[i]=!0;try{var c=n(a);if(c)return c}finally{delete l[i]}}}}return null},e.prototype._extensionsOnLoading=function(){this._forEachExtensions((function(e){return e.onLoading&&e.onLoading()}))},e.prototype._extensionsOnReady=function(){this._forEachExtensions((function(e){return e.onReady&&e.onReady()}))},e.prototype._extensionsLoadSceneAsync=function(e,t){return this._applyExtensions(t,"loadScene",(function(n){return n.loadSceneAsync&&n.loadSceneAsync(e,t)}))},e.prototype._extensionsLoadNodeAsync=function(e,t,n){return this._applyExtensions(t,"loadNode",(function(r){return r.loadNodeAsync&&r.loadNodeAsync(e,t,n)}))},e.prototype._extensionsLoadCameraAsync=function(e,t,n){return this._applyExtensions(t,"loadCamera",(function(r){return r.loadCameraAsync&&r.loadCameraAsync(e,t,n)}))},e.prototype._extensionsLoadVertexDataAsync=function(e,t,n){return this._applyExtensions(t,"loadVertexData",(function(r){return r._loadVertexDataAsync&&r._loadVertexDataAsync(e,t,n)}))},e.prototype._extensionsLoadMeshPrimitiveAsync=function(e,t,n,r,o,a){return this._applyExtensions(o,"loadMeshPrimitive",(function(i){return i._loadMeshPrimitiveAsync&&i._loadMeshPrimitiveAsync(e,t,n,r,o,a)}))},e.prototype._extensionsLoadMaterialAsync=function(e,t,n,r,o){return this._applyExtensions(t,"loadMaterial",(function(a){return a._loadMaterialAsync&&a._loadMaterialAsync(e,t,n,r,o)}))},e.prototype._extensionsCreateMaterial=function(e,t,n){return this._applyExtensions(t,"createMaterial",(function(r){return r.createMaterial&&r.createMaterial(e,t,n)}))},e.prototype._extensionsLoadMaterialPropertiesAsync=function(e,t,n){return this._applyExtensions(t,"loadMaterialProperties",(function(r){return r.loadMaterialPropertiesAsync&&r.loadMaterialPropertiesAsync(e,t,n)}))},e.prototype._extensionsLoadTextureInfoAsync=function(e,t,n){return this._applyExtensions(t,"loadTextureInfo",(function(r){return r.loadTextureInfoAsync&&r.loadTextureInfoAsync(e,t,n)}))},e.prototype._extensionsLoadTextureAsync=function(e,t,n){return this._applyExtensions(t,"loadTexture",(function(r){return r._loadTextureAsync&&r._loadTextureAsync(e,t,n)}))},e.prototype._extensionsLoadAnimationAsync=function(e,t){return this._applyExtensions(t,"loadAnimation",(function(n){return n.loadAnimationAsync&&n.loadAnimationAsync(e,t)}))},e.prototype._extensionsLoadSkinAsync=function(e,t,n){return this._applyExtensions(n,"loadSkin",(function(r){return r._loadSkinAsync&&r._loadSkinAsync(e,t,n)}))},e.prototype._extensionsLoadUriAsync=function(e,t,n){return this._applyExtensions(t,"loadUri",(function(r){return r._loadUriAsync&&r._loadUriAsync(e,t,n)}))},e.prototype._extensionsLoadBufferViewAsync=function(e,t){return this._applyExtensions(t,"loadBufferView",(function(n){return n.loadBufferViewAsync&&n.loadBufferViewAsync(e,t)}))},e.prototype._extensionsLoadBufferAsync=function(e,t,n,r){return this._applyExtensions(t,"loadBuffer",(function(o){return o.loadBufferAsync&&o.loadBufferAsync(e,t,n,r)}))},e.LoadExtensionAsync=function(e,t,n,r){if(!t.extensions)return null;var o=t.extensions[n];return o?r("".concat(e,"/extensions/").concat(n),o):null},e.LoadExtraAsync=function(e,t,n,r){if(!t.extras)return null;var o=t.extras[n];return o?r("".concat(e,"/extras/").concat(n),o):null},e.prototype.isExtensionUsed=function(e){return!!this._gltf.extensionsUsed&&-1!==this._gltf.extensionsUsed.indexOf(e)},e.prototype.logOpen=function(e){this._parent._logOpen(e)},e.prototype.logClose=function(){this._parent._logClose()},e.prototype.log=function(e){this._parent._log(e)},e.prototype.startPerformanceCounter=function(e){this._parent._startPerformanceCounter(e)},e.prototype.endPerformanceCounter=function(e){this._parent._endPerformanceCounter(e)},e._RegisteredExtensions={},e.DefaultSampler={index:-1},e}();o.GLTFFileLoader._CreateGLTF2Loader=function(e){return new i(e)}},function(e,t,n){"use strict";n.r(t),n.d(t,"GLTFLoaderCoordinateSystemMode",(function(){return r})),n.d(t,"GLTFLoaderAnimationStartMode",(function(){return o})),n.d(t,"GLTFLoaderState",(function(){return a})),n.d(t,"GLTFFileLoader",(function(){return c}));var r,o,a,i=n(0),s=n(3);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"}(r||(r={})),function(e){e[e.NONE=0]="NONE",e[e.FIRST=1]="FIRST",e[e.ALL=2]="ALL"}(o||(o={})),function(e){e[e.LOADING=0]="LOADING",e[e.READY=1]="READY",e[e.COMPLETE=2]="COMPLETE"}(a||(a={}));var c=function(){function e(){this.onParsedObservable=new i.Observable,this.coordinateSystemMode=r.AUTO,this.animationStartMode=o.FIRST,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.useSRGBBuffers=!0,this.targetFps=60,this.preprocessUrlAsync=function(e){return Promise.resolve(e)},this.onMeshLoadedObservable=new i.Observable,this.onTextureLoadedObservable=new i.Observable,this.onMaterialLoadedObservable=new i.Observable,this.onCameraLoadedObservable=new i.Observable,this.onCompleteObservable=new i.Observable,this.onErrorObservable=new i.Observable,this.onDisposeObservable=new i.Observable,this.onExtensionLoadedObservable=new i.Observable,this.validate=!1,this.onValidatedObservable=new i.Observable,this._loader=null,this._state=null,this._requests=new Array,this.name="gltf",this.extensions={".gltf":{isBinary:!1},".glb":{isBinary:!0}},this.onLoaderStateChangedObservable=new i.Observable,this._logIndentLevel=0,this._loggingEnabled=!1,this._log=this._logDisabled,this._capturePerformanceCounters=!1,this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled}return Object.defineProperty(e.prototype,"onParsed",{set:function(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),this._onParsedObserver=this.onParsedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMeshLoaded",{set:function(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onTextureLoaded",{set:function(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMaterialLoaded",{set:function(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onCameraLoaded",{set:function(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{set:function(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{set:function(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onExtensionLoaded",{set:function(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.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(e.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(e.prototype,"onValidated",{set:function(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)},enumerable:!1,configurable:!0}),e.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.onTextureLoadedObservable.clear(),this.onMaterialLoadedObservable.clear(),this.onCameraLoadedObservable.clear(),this.onCompleteObservable.clear(),this.onExtensionLoadedObservable.clear(),this.onDisposeObservable.notifyObservers(void 0),this.onDisposeObservable.clear()},e.prototype.loadFile=function(e,t,n,r,o,a){var s=this;if(this._progressCallback=r,o){if(this.useRangeRequests){this.validate&&i.Logger.Warn("glTF validation is not supported when range requests are enabled");var c={abort:function(){},onCompleteObservable:new i.Observable},u={readAsync:function(n,r){return new Promise((function(o,a){s._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 i.DataReader(u)).then((function(e){c.onCompleteObservable.notifyObservers(c),n(e)}),a?function(e){return a(void 0,e)}:void 0),c}return this._loadFile(e,t,(function(e){var t=e;s._unpackBinaryAsync(new i.DataReader({readAsync:function(e,n){return l(t,e,n)},byteLength:t.byteLength})).then((function(e){n(e)}),a?function(e){return a(void 0,e)}:void 0)}),!0,a)}return this._loadFile(e,t,(function(r){if(t.name)s._validate(e,r,"file:",t.name);else{var o=t;s._validate(e,r,i.Tools.GetFolderPath(o),i.Tools.GetFilename(o))}n({json:s._parseJson(r)})}),o,a)},e.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)}))},e.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)}))},e.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 s=new i.AssetContainer(e),l=[];a.onMaterialLoadedObservable.add((function(e){l.push(e)}));var c=[];a.onTextureLoadedObservable.add((function(e){c.push(e)}));var u=[];return a.onCameraLoadedObservable.add((function(e){u.push(e)})),a._loader.importMeshAsync(null,e,s,t,n,r,o).then((function(e){return Array.prototype.push.apply(s.geometries,e.geometries),Array.prototype.push.apply(s.meshes,e.meshes),Array.prototype.push.apply(s.particleSystems,e.particleSystems),Array.prototype.push.apply(s.skeletons,e.skeletons),Array.prototype.push.apply(s.animationGroups,e.animationGroups),Array.prototype.push.apply(s.materials,l),Array.prototype.push.apply(s.textures,c),Array.prototype.push.apply(s.lights,e.lights),Array.prototype.push.apply(s.transformNodes,e.transformNodes),Array.prototype.push.apply(s.cameras,u),s}))}))},e.prototype.canDirectLoad=function(t){return-1!==t.indexOf("asset")&&-1!==t.indexOf("version")||i.StringTools.StartsWith(t,"data:base64,"+e.magicBase64Encoded)||i.StringTools.StartsWith(t,"data:;base64,"+e.magicBase64Encoded)||i.StringTools.StartsWith(t,"data:application/octet-stream;base64,"+e.magicBase64Encoded)||i.StringTools.StartsWith(t,"data:model/gltf-binary;base64,"+e.magicBase64Encoded)},e.prototype.directLoad=function(t,n){if(i.StringTools.StartsWith(n,"base64,"+e.magicBase64Encoded)||i.StringTools.StartsWith(n,";base64,"+e.magicBase64Encoded)||i.StringTools.StartsWith(n,"application/octet-stream;base64,"+e.magicBase64Encoded)||i.StringTools.StartsWith(n,"model/gltf-binary;base64,"+e.magicBase64Encoded)){var r=Object(i.DecodeBase64UrlToBinary)(n);return this._validate(t,r),this._unpackBinaryAsync(new i.DataReader({readAsync:function(e,t){return l(r,e,t)},byteLength:r.byteLength}))}return this._validate(t,n),Promise.resolve({json:this._parseJson(n)})},e.prototype.createPlugin=function(){return new e},Object.defineProperty(e.prototype,"loaderState",{get:function(){return this._state},enumerable:!1,configurable:!0}),e.prototype.whenCompleteAsync=function(){var e=this;return new Promise((function(t,n){e.onCompleteObservable.addOnce((function(){t()})),e.onErrorObservable.addOnce((function(e){n(e)}))}))},e.prototype._setState=function(e){this._state!==e&&(this._state=e,this.onLoaderStateChangedObservable.notifyObservers(this._state),this._log(a[this._state]))},e.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(e){i._requests.splice(i._requests.indexOf(e),1)})),this._requests.push(s),s},e.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})}},e.prototype._validate=function(e,t,n,r){var o=this;void 0===n&&(n=""),void 0===r&&(r=""),this.validate&&(this._startPerformanceCounter("Validate JSON"),s.GLTFValidation.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){o._endPerformanceCounter("Validate JSON"),o.onValidatedObservable.notifyObservers(e),o.onValidatedObservable.clear()}),(function(e){o._endPerformanceCounter("Validate JSON"),i.Tools.Warn("Failed to validate: ".concat(e.message)),o.onValidatedObservable.clear()})))},e.prototype._getLoader=function(t){var n=t.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=e._parseVersion(n.version);if(!r)throw new Error("Invalid version: "+n.version);if(void 0!==n.minVersion){var o=e._parseVersion(n.minVersion);if(!o)throw new Error("Invalid minimum version: "+n.minVersion);if(e._compareVersion(o,{major:2,minor:0})>0)throw new Error("Incompatible minimum version: "+n.minVersion)}var a={1:e._CreateGLTF1Loader,2:e._CreateGLTF2Loader}[r.major];if(!a)throw new Error("Unsupported version: "+n.version);return a(this)},e.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},e.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 Error("Unexpected magic: "+n);var r=e.readUint32();t.loggingEnabled&&t._log("Binary version: ".concat(r));var o,a=e.readUint32();if(0!==e.buffer.byteLength&&a!==e.buffer.byteLength)throw new Error("Length in header does not match actual data length: ".concat(a," != ").concat(e.buffer.byteLength));switch(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}))},e.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)},e.prototype._unpackBinaryV2Async=function(e,t){var n=this,r=1313821514,o=5130562,a=e.readUint32();if(e.readUint32()!==r)throw new Error("First chunk format is not JSON");return e.byteOffset+a===t?e.loadAsync(a).then((function(){return{json:n._parseJson(e.readString(a)),bin:null}})):e.loadAsync(a+8).then((function(){var i={json:n._parseJson(e.readString(a)),bin:null},s=function(){var n=e.readUint32();switch(e.readUint32()){case r:throw new Error("Unexpected JSON chunk");case o:var a=e.byteOffset;i.bin={readAsync:function(t,n){return e.buffer.readAsync(a+t,n)},byteLength:n},e.skipBytes(n);break;default:e.skipBytes(n)}return e.byteOffset!==t?e.loadAsync(8).then(s):Promise.resolve(i)};return s()}))},e._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},e._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},e.prototype._logOpen=function(e){this._log(e),this._logIndentLevel++},e.prototype._logClose=function(){--this._logIndentLevel},e.prototype._logEnabled=function(t){var n=e._logSpaces.substr(0,2*this._logIndentLevel);i.Logger.Log("".concat(n).concat(t))},e.prototype._logDisabled=function(e){},e.prototype._startPerformanceCounterEnabled=function(e){i.Tools.StartPerformanceCounter(e)},e.prototype._startPerformanceCounterDisabled=function(e){},e.prototype._endPerformanceCounterEnabled=function(e){i.Tools.EndPerformanceCounter(e)},e.prototype._endPerformanceCounterDisabled=function(e){},e.IncrementalLoading=!0,e.HomogeneousCoordinates=!1,e.magicBase64Encoded="Z2xURg",e._logSpaces="                                ",e}();i.SceneLoader&&i.SceneLoader.RegisterPlugin(new c)},function(e,t,n){"use strict";n.r(t),n.d(t,"GLTFValidation",(function(){return i}));var r=n(0);function o(e,t,n,r){var o={externalResourceFunction:function(e){return r(e).then((function(e){return new Uint8Array(e)}))}};return n&&(o.uri="file:"===t?n:t+n),e instanceof ArrayBuffer?GLTFValidator.validateBytes(new Uint8Array(e),o):GLTFValidator.validateString(e,o)}function a(){var e=[];onmessage=function(t){var n=t.data;switch(n.id){case"init":importScripts(n.url);break;case"validate":o(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 i=function(){function e(){}return e.ValidateAsync=function(e,t,n,i){var s=this;return"function"==typeof Worker?new Promise((function(r,l){var c="".concat(o,"(").concat(a,")()"),u=URL.createObjectURL(new Blob([c],{type:"application/javascript"})),d=new Worker(u),f=function(e){d.removeEventListener("error",f),d.removeEventListener("message",h),l(e)},h=function(e){var t=e.data;switch(t.id){case"getExternalResource":i(t.uri).then((function(e){d.postMessage({id:"getExternalResource.resolve",index:t.index,value:e},[e])}),(function(e){d.postMessage({id:"getExternalResource.reject",index:t.index,reason:e})}));break;case"validate.resolve":d.removeEventListener("error",f),d.removeEventListener("message",h),r(t.value);break;case"validate.reject":d.removeEventListener("error",f),d.removeEventListener("message",h),l(t.reason)}};d.addEventListener("error",f),d.addEventListener("message",h),d.postMessage({id:"init",url:s.Configuration.url}),d.postMessage({id:"validate",data:e,rootUrl:t,fileName:n})})):(this._LoadScriptPromise||(this._LoadScriptPromise=r.Tools.LoadScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then((function(){return o(e,t,n,i)})))},e.Configuration={url:"https://preview.babylonjs.com/gltf_validator.js"},e}()},function(e,t,n){"use strict";n.d(t,"b",(function(){return o})),n.d(t,"a",(function(){return a}));
  /*! *****************************************************************************
  Copyright (c) Microsoft Corporation.
  
  Permission to use, copy, modify, and/or distribute this software for any
  purpose with or without fee is hereby granted.
  
  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  PERFORMANCE OF THIS SOFTWARE.
  ***************************************************************************** */
  var r=function(e,t){return(r=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])})(e,t)};function o(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}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var a=function(){return(a=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)};Object.create;Object.create},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";n.r(t)},function(e,t,n){"use strict";n.r(t),n.d(t,"EXT_lights_image_based",(function(){return i})),n.d(t,"EXT_mesh_gpu_instancing",(function(){return s})),n.d(t,"EXT_meshopt_compression",(function(){return l})),n.d(t,"EXT_texture_webp",(function(){return c})),n.d(t,"KHR_draco_mesh_compression",(function(){return u})),n.d(t,"KHR_lights",(function(){return d})),n.d(t,"KHR_materials_pbrSpecularGlossiness",(function(){return f})),n.d(t,"KHR_materials_unlit",(function(){return h})),n.d(t,"KHR_materials_clearcoat",(function(){return p})),n.d(t,"KHR_materials_emissive_strength",(function(){return _})),n.d(t,"KHR_materials_sheen",(function(){return m})),n.d(t,"KHR_materials_specular",(function(){return y})),n.d(t,"KHR_materials_ior",(function(){return b})),n.d(t,"KHR_materials_variants",(function(){return v})),n.d(t,"KHR_materials_transmission",(function(){return T})),n.d(t,"KHR_materials_translucency",(function(){return x})),n.d(t,"KHR_materials_volume",(function(){return E})),n.d(t,"KHR_mesh_quantization",(function(){return O})),n.d(t,"KHR_texture_basisu",(function(){return L})),n.d(t,"KHR_texture_transform",(function(){return M})),n.d(t,"KHR_xmp_json_ld",(function(){return S})),n.d(t,"MSFT_audio_emitter",(function(){return C})),n.d(t,"MSFT_lod",(function(){return R})),n.d(t,"MSFT_minecraftMesh",(function(){return w})),n.d(t,"MSFT_sRGBFactors",(function(){return P})),n.d(t,"ExtrasAsMetadata",(function(){return N}));var r=n(0),o=n(1),a="EXT_lights_image_based",i=function(){function e(e){this.name=a,this._loader=e,this.enabled=this._loader.isExtensionUsed(a)}return e.prototype.dispose=function(){this._loader=null,delete this._lights},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._lights=t.lights}},e.prototype.loadSceneAsync=function(e,t){var n=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(r,a){var i=new Array;i.push(n._loader.loadSceneAsync(e,t)),n._loader.logOpen("".concat(r));var s=o.a.Get("".concat(r,"/light"),n._lights,a.light);return i.push(n._loadLightAsync("/extensions/".concat(n.name,"/lights/").concat(a.light),s).then((function(e){n._loader.babylonScene.environmentTexture=e}))),n._loader.logClose(),Promise.all(i).then((function(){}))}))},e.prototype._loadLightAsync=function(e,t){var n=this;if(!t._loaded){var a=new Array;this._loader.logOpen("".concat(e));for(var i=new Array(t.specularImages.length),s=function(n){var r=t.specularImages[n];i[n]=new Array(r.length);for(var s=function(t){var s="".concat(e,"/specularImages/").concat(n,"/").concat(t);l._loader.logOpen("".concat(s));var c=r[t],u=o.a.Get(s,l._loader.gltf.images,c);a.push(l._loader.loadImageAsync("/images/".concat(c),u).then((function(e){i[n][t]=e}))),l._loader.logClose()},c=0;c<r.length;c++)s(c)},l=this,c=0;c<t.specularImages.length;c++)s(c);this._loader.logClose(),t._loaded=Promise.all(a).then((function(){var o=new r.RawCubeTexture(n._loader.babylonScene,null,t.specularImageSize);if(o.name=t.name||"environment",t._babylonTexture=o,null!=t.intensity&&(o.level=t.intensity),t.rotation){var a=r.Quaternion.FromArray(t.rotation);n._loader.babylonScene.useRightHandedSystem||(a=r.Quaternion.Inverse(a)),r.Matrix.FromQuaternionToRef(a,o.getReflectionTextureMatrix())}if(!t.irradianceCoefficients)throw new Error("".concat(e,": Irradiance coefficients are missing"));var s=r.SphericalHarmonics.FromArray(t.irradianceCoefficients);s.scaleInPlace(t.intensity),s.convertIrradianceToLambertianRadiance();var l=r.SphericalPolynomial.FromHarmonics(s),c=(i.length-1)/r.Scalar.Log2(t.specularImageSize);return o.updateRGBDAsync(i,l,c)}))}return t._loaded.then((function(){return t._babylonTexture}))},e}();o.b.RegisterExtension(a,(function(e){return new i(e)}));var s=function(){function e(e){this.name="EXT_mesh_gpu_instancing",this._loader=e,this.enabled=this._loader.isExtensionUsed("EXT_mesh_gpu_instancing")}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadNodeAsync=function(e,t,n){var a=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(e,i){a._loader._disableInstancedMesh++;var s=a._loader.loadNodeAsync("/nodes/".concat(t.index),t,n);if(a._loader._disableInstancedMesh--,!t._primitiveBabylonMeshes)return s;var l=new Array,c=0,u=function(t){if(null!=i.attributes[t]){var n=o.a.Get("".concat(e,"/attributes/").concat(t),a._loader.gltf.accessors,i.attributes[t]);if(l.push(a._loader._loadFloatAccessorAsync("/accessors/".concat(n.bufferView),n)),0===c)c=n.count;else if(c!==n.count)throw new Error("".concat(e,"/attributes: Instance buffer accessors do not have the same count."))}else l.push(Promise.resolve(null))};return u("TRANSLATION"),u("ROTATION"),u("SCALE"),s.then((function(e){return Promise.all(l).then((function(n){var o=n[0],a=n[1],i=n[2],s=new Float32Array(16*c);r.TmpVectors.Vector3[0].copyFromFloats(0,0,0),r.TmpVectors.Quaternion[0].copyFromFloats(0,0,0,1),r.TmpVectors.Vector3[1].copyFromFloats(1,1,1);for(var l=0;l<c;++l)o&&r.Vector3.FromArrayToRef(o,3*l,r.TmpVectors.Vector3[0]),a&&r.Quaternion.FromArrayToRef(a,4*l,r.TmpVectors.Quaternion[0]),i&&r.Vector3.FromArrayToRef(i,3*l,r.TmpVectors.Vector3[1]),r.Matrix.ComposeToRef(r.TmpVectors.Vector3[1],r.TmpVectors.Quaternion[0],r.TmpVectors.Vector3[0],r.TmpVectors.Matrix[0]),r.TmpVectors.Matrix[0].copyToArray(s,16*l);for(var u=0,d=t._primitiveBabylonMeshes;u<d.length;u++){d[u].thinInstanceSetBuffer("matrix",s,16,!0)}return e}))}))}))},e}();o.b.RegisterExtension("EXT_mesh_gpu_instancing",(function(e){return new s(e)}));var l=function(){function e(e){this.name="EXT_meshopt_compression",this.enabled=e.isExtensionUsed("EXT_meshopt_compression"),this._loader=e}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadBufferViewAsync=function(e,t){var n=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(a,i){var s=t;if(s._meshOptData)return s._meshOptData;var l=o.a.Get("".concat(e,"/buffer"),n._loader.gltf.buffers,i.buffer);return s._meshOptData=n._loader.loadBufferAsync("/buffers/".concat(l.index),l,i.byteOffset||0,i.byteLength).then((function(e){return r.MeshoptCompression.Default.decodeGltfBufferAsync(e,i.count,i.byteStride,i.mode,i.filter)})),s._meshOptData}))},e}();o.b.RegisterExtension("EXT_meshopt_compression",(function(e){return new l(e)}));var c=function(){function e(e){this.name="EXT_texture_webp",this._loader=e,this.enabled=e.isExtensionUsed("EXT_texture_webp")}return e.prototype.dispose=function(){this._loader=null},e.prototype._loadTextureAsync=function(e,t,n){var r=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(a,i){var s=null==t.sampler?o.b.DefaultSampler:o.a.Get("".concat(e,"/sampler"),r._loader.gltf.samplers,t.sampler),l=o.a.Get("".concat(a,"/source"),r._loader.gltf.images,i.source);return r._loader._createTextureAsync(e,s,l,(function(e){n(e)}),void 0,!t._textureInfo.nonColorData)}))},e}();o.b.RegisterExtension("EXT_texture_webp",(function(e){return new c(e)}));var u=function(){function e(e){this.name="KHR_draco_mesh_compression",this._loader=e,this.enabled=r.DracoCompression.DecoderAvailable&&this._loader.isExtensionUsed("KHR_draco_mesh_compression")}return e.prototype.dispose=function(){delete this.dracoCompression,this._loader=null},e.prototype._loadVertexDataAsync=function(e,t,n){var a=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(i,s){if(null!=t.mode){if(5!==t.mode&&4!==t.mode)throw new Error("".concat(e,": Unsupported mode ").concat(t.mode));if(5===t.mode)throw new Error("".concat(e,": Mode ").concat(t.mode," is not currently supported"))}var l={},c={},u=function(r,i){var u=s.attributes[r];if(void 0!==u&&void 0!==t.attributes[r]){l[i]=u;var d=o.a.Get("".concat(e,"/attributes/").concat(r),a._loader.gltf.accessors,t.attributes[r]);if(d.normalized&&5126!==d.componentType){var f=1;switch(d.componentType){case 5120:f=127;break;case 5121:f=255;break;case 5122:f=32767;break;case 5123:f=65535}c[i]=f}n._delayInfo=n._delayInfo||[],-1===n._delayInfo.indexOf(i)&&n._delayInfo.push(i)}};u("POSITION",r.VertexBuffer.PositionKind),u("NORMAL",r.VertexBuffer.NormalKind),u("TANGENT",r.VertexBuffer.TangentKind),u("TEXCOORD_0",r.VertexBuffer.UVKind),u("TEXCOORD_1",r.VertexBuffer.UV2Kind),u("TEXCOORD_2",r.VertexBuffer.UV3Kind),u("TEXCOORD_3",r.VertexBuffer.UV4Kind),u("TEXCOORD_4",r.VertexBuffer.UV5Kind),u("TEXCOORD_5",r.VertexBuffer.UV6Kind),u("JOINTS_0",r.VertexBuffer.MatricesIndicesKind),u("WEIGHTS_0",r.VertexBuffer.MatricesWeightsKind),u("COLOR_0",r.VertexBuffer.ColorKind);var d=o.a.Get(i,a._loader.gltf.bufferViews,s.bufferView);return d._dracoBabylonGeometry||(d._dracoBabylonGeometry=a._loader.loadBufferViewAsync("/bufferViews/".concat(d.index),d).then((function(t){return(a.dracoCompression||r.DracoCompression.Default).decodeMeshAsync(t,l,c).then((function(e){var t=new r.Geometry(n.name,a._loader.babylonScene);return e.applyToGeometry(t),t})).catch((function(t){throw new Error("".concat(e,": ").concat(t.message))}))}))),d._dracoBabylonGeometry}))},e}();o.b.RegisterExtension("KHR_draco_mesh_compression",(function(e){return new u(e)}));var d=function(){function e(e){this.name="KHR_lights_punctual",this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_lights_punctual")}return e.prototype.dispose=function(){this._loader=null,delete this._lights},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._lights=t.lights}},e.prototype.loadNodeAsync=function(e,t,n){var a=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(i,s){return a._loader.loadNodeAsync(e,t,(function(e){var t,l=o.a.Get(i,a._lights,s.light),c=l.name||e.name;switch(a._loader.babylonScene._blockEntityCollection=!!a._loader._assetContainer,l.type){case"directional":t=new r.DirectionalLight(c,r.Vector3.Backward(),a._loader.babylonScene);break;case"point":t=new r.PointLight(c,r.Vector3.Zero(),a._loader.babylonScene);break;case"spot":var u=new r.SpotLight(c,r.Vector3.Zero(),r.Vector3.Backward(),0,1,a._loader.babylonScene);u.angle=2*(l.spot&&l.spot.outerConeAngle||Math.PI/4),u.innerAngle=2*(l.spot&&l.spot.innerConeAngle||0),t=u;break;default:throw a._loader.babylonScene._blockEntityCollection=!1,new Error("".concat(i,": Invalid light type (").concat(l.type,")"))}t._parentContainer=a._loader._assetContainer,a._loader.babylonScene._blockEntityCollection=!1,t.falloffType=r.Light.FALLOFF_GLTF,t.diffuse=l.color?r.Color3.FromArray(l.color):r.Color3.White(),t.intensity=null==l.intensity?1:l.intensity,t.range=null==l.range?Number.MAX_VALUE:l.range,t.parent=e,a._loader._babylonLights.push(t),o.b.AddPointerMetadata(t,i),n(e)}))}))},e}();o.b.RegisterExtension("KHR_lights_punctual",(function(e){return new d(e)}));var f=function(){function e(e){this.name="KHR_materials_pbrSpecularGlossiness",this.order=200,this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_materials_pbrSpecularGlossiness")}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(o,a){var i=new Array;return i.push(r._loader.loadMaterialBasePropertiesAsync(e,t,n)),i.push(r._loadSpecularGlossinessPropertiesAsync(o,t,a,n)),r._loader.loadMaterialAlphaProperties(e,t,n),Promise.all(i).then((function(){}))}))},e.prototype._loadSpecularGlossinessPropertiesAsync=function(e,t,n,o){if(!(o instanceof r.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));var a=new Array;return o.metallic=null,o.roughness=null,n.diffuseFactor?(o.albedoColor=r.Color3.FromArray(n.diffuseFactor),o.alpha=n.diffuseFactor[3]):o.albedoColor=r.Color3.White(),o.reflectivityColor=n.specularFactor?r.Color3.FromArray(n.specularFactor):r.Color3.White(),o.microSurface=null==n.glossinessFactor?1:n.glossinessFactor,n.diffuseTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/diffuseTexture"),n.diffuseTexture,(function(e){e.name="".concat(o.name," (Diffuse)"),o.albedoTexture=e}))),n.specularGlossinessTexture&&(a.push(this._loader.loadTextureInfoAsync("".concat(e,"/specularGlossinessTexture"),n.specularGlossinessTexture,(function(e){e.name="".concat(o.name," (Specular Glossiness)"),o.reflectivityTexture=e}))),o.reflectivityTexture.hasAlpha=!0,o.useMicroSurfaceFromReflectivityMapAlpha=!0),Promise.all(a).then((function(){}))},e}();o.b.RegisterExtension("KHR_materials_pbrSpecularGlossiness",(function(e){return new f(e)}));var h=function(){function e(e){this.name="KHR_materials_unlit",this.order=210,this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_materials_unlit")}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(){return r._loadUnlitPropertiesAsync(e,t,n)}))},e.prototype._loadUnlitPropertiesAsync=function(e,t,n){if(!(n instanceof r.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));var o=new Array;n.unlit=!0;var a=t.pbrMetallicRoughness;return a&&(a.baseColorFactor?(n.albedoColor=r.Color3.FromArray(a.baseColorFactor),n.alpha=a.baseColorFactor[3]):n.albedoColor=r.Color3.White(),a.baseColorTexture&&o.push(this._loader.loadTextureInfoAsync("".concat(e,"/baseColorTexture"),a.baseColorTexture,(function(e){e.name="".concat(n.name," (Base Color)"),n.albedoTexture=e})))),t.doubleSided&&(n.backFaceCulling=!1,n.twoSidedLighting=!0),this._loader.loadMaterialAlphaProperties(e,t,n),Promise.all(o).then((function(){}))},e}();o.b.RegisterExtension("KHR_materials_unlit",(function(e){return new h(e)}));var p=function(){function e(e){this.name="KHR_materials_clearcoat",this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_materials_clearcoat")}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(o,a){var i=new Array;return i.push(r._loader.loadMaterialPropertiesAsync(e,t,n)),i.push(r._loadClearCoatPropertiesAsync(o,a,n)),Promise.all(i).then((function(){}))}))},e.prototype._loadClearCoatPropertiesAsync=function(e,t,n){if(!(n instanceof r.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));var o=new Array;return n.clearCoat.isEnabled=!0,n.clearCoat.useRoughnessFromMainTexture=!1,n.clearCoat.remapF0OnInterfaceChange=!1,null!=t.clearcoatFactor?n.clearCoat.intensity=t.clearcoatFactor:n.clearCoat.intensity=0,t.clearcoatTexture&&o.push(this._loader.loadTextureInfoAsync("".concat(e,"/clearcoatTexture"),t.clearcoatTexture,(function(e){e.name="".concat(n.name," (ClearCoat Intensity)"),n.clearCoat.texture=e}))),null!=t.clearcoatRoughnessFactor?n.clearCoat.roughness=t.clearcoatRoughnessFactor:n.clearCoat.roughness=0,t.clearcoatRoughnessTexture&&(t.clearcoatRoughnessTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync("".concat(e,"/clearcoatRoughnessTexture"),t.clearcoatRoughnessTexture,(function(e){e.name="".concat(n.name," (ClearCoat Roughness)"),n.clearCoat.textureRoughness=e})))),t.clearcoatNormalTexture&&(t.clearcoatNormalTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync("".concat(e,"/clearcoatNormalTexture"),t.clearcoatNormalTexture,(function(e){e.name="".concat(n.name," (ClearCoat Normal)"),n.clearCoat.bumpTexture=e}))),n.invertNormalMapX=!n.getScene().useRightHandedSystem,n.invertNormalMapY=n.getScene().useRightHandedSystem,null!=t.clearcoatNormalTexture.scale&&(n.clearCoat.bumpTexture.level=t.clearcoatNormalTexture.scale)),Promise.all(o).then((function(){}))},e}();o.b.RegisterExtension("KHR_materials_clearcoat",(function(e){return new p(e)}));var _=function(){function e(e){this.name="KHR_materials_emissive_strength",this.order=170,this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_materials_emissive_strength")}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(o,a){return r._loader.loadMaterialPropertiesAsync(e,t,n).then((function(){r._loadEmissiveProperties(o,a,n)}))}))},e.prototype._loadEmissiveProperties=function(e,t,n){if(!(n instanceof r.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));void 0!==t.emissiveStrength&&n.emissiveColor.scaleToRef(t.emissiveStrength,n.emissiveColor)},e}();o.b.RegisterExtension("KHR_materials_emissive_strength",(function(e){return new _(e)}));var m=function(){function e(e){this.name="KHR_materials_sheen",this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_materials_sheen")}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(o,a){var i=new Array;return i.push(r._loader.loadMaterialPropertiesAsync(e,t,n)),i.push(r._loadSheenPropertiesAsync(o,a,n)),Promise.all(i).then((function(){}))}))},e.prototype._loadSheenPropertiesAsync=function(e,t,n){if(!(n instanceof r.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));var o=new Array;return n.sheen.isEnabled=!0,n.sheen.intensity=1,null!=t.sheenColorFactor?n.sheen.color=r.Color3.FromArray(t.sheenColorFactor):n.sheen.color=r.Color3.Black(),t.sheenColorTexture&&o.push(this._loader.loadTextureInfoAsync("".concat(e,"/sheenColorTexture"),t.sheenColorTexture,(function(e){e.name="".concat(n.name," (Sheen Color)"),n.sheen.texture=e}))),void 0!==t.sheenRoughnessFactor?n.sheen.roughness=t.sheenRoughnessFactor:n.sheen.roughness=0,t.sheenRoughnessTexture&&(t.sheenRoughnessTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync("".concat(e,"/sheenRoughnessTexture"),t.sheenRoughnessTexture,(function(e){e.name="".concat(n.name," (Sheen Roughness)"),n.sheen.textureRoughness=e})))),n.sheen.albedoScaling=!0,n.sheen.useRoughnessFromMainTexture=!1,Promise.all(o).then((function(){}))},e}();o.b.RegisterExtension("KHR_materials_sheen",(function(e){return new m(e)}));var y=function(){function e(e){this.name="KHR_materials_specular",this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_materials_specular")}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(o,a){var i=new Array;return i.push(r._loader.loadMaterialPropertiesAsync(e,t,n)),i.push(r._loadSpecularPropertiesAsync(o,a,n)),Promise.all(i).then((function(){}))}))},e.prototype._loadSpecularPropertiesAsync=function(e,t,n){if(!(n instanceof r.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));var o=new Array;return void 0!==t.specularFactor&&(n.metallicF0Factor=t.specularFactor),void 0!==t.specularColorFactor&&(n.metallicReflectanceColor=r.Color3.FromArray(t.specularColorFactor)),t.specularTexture&&(t.specularTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync("".concat(e,"/specularTexture"),t.specularTexture,(function(e){e.name="".concat(n.name," (Specular F0 Strength)"),n.metallicReflectanceTexture=e,n.useOnlyMetallicFromMetallicReflectanceTexture=!0})))),t.specularColorTexture&&o.push(this._loader.loadTextureInfoAsync("".concat(e,"/specularColorTexture"),t.specularColorTexture,(function(e){e.name="".concat(n.name," (Specular F0 Color)"),n.reflectanceTexture=e}))),Promise.all(o).then((function(){}))},e}();o.b.RegisterExtension("KHR_materials_specular",(function(e){return new y(e)}));var b=function(){function e(e){this.name="KHR_materials_ior",this.order=180,this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_materials_ior")}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(o,a){var i=new Array;return i.push(r._loader.loadMaterialPropertiesAsync(e,t,n)),i.push(r._loadIorPropertiesAsync(o,a,n)),Promise.all(i).then((function(){}))}))},e.prototype._loadIorPropertiesAsync=function(t,n,o){if(!(o instanceof r.PBRMaterial))throw new Error("".concat(t,": Material type not supported"));return void 0!==n.ior?o.indexOfRefraction=n.ior:o.indexOfRefraction=e._DEFAULT_IOR,Promise.resolve()},e._DEFAULT_IOR=1.5,e}();o.b.RegisterExtension("KHR_materials_ior",(function(e){return new b(e)}));var v=function(){function e(e){this.name="KHR_materials_variants",this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_materials_variants")}return e.prototype.dispose=function(){this._loader=null},e.GetAvailableVariants=function(e){var t=this._GetExtensionMetadata(e);return t?Object.keys(t.variants):[]},e.prototype.getAvailableVariants=function(t){return e.GetAvailableVariants(t)},e.SelectVariant=function(e,t){var n=this._GetExtensionMetadata(e);if(!n)throw new Error("Cannot select variant on a glTF mesh that does not have the ".concat("KHR_materials_variants"," extension"));var r=function(e){var t=n.variants[e];if(t)for(var r=0,o=t;r<o.length;r++){var a=o[r];a.mesh.material=a.material}};if(t instanceof Array)for(var o=0,a=t;o<a.length;o++){r(a[o])}else r(t);n.lastSelected=t},e.prototype.selectVariant=function(t,n){return e.SelectVariant(t,n)},e.Reset=function(e){var t=this._GetExtensionMetadata(e);if(!t)throw new Error("Cannot reset on a glTF mesh that does not have the ".concat("KHR_materials_variants"," extension"));for(var n=0,r=t.original;n<r.length;n++){var o=r[n];o.mesh.material=o.material}t.lastSelected=null},e.prototype.reset=function(t){return e.Reset(t)},e.GetLastSelectedVariant=function(e){var t=this._GetExtensionMetadata(e);if(!t)throw new Error("Cannot get the last selected variant on a glTF mesh that does not have the ".concat("KHR_materials_variants"," extension"));return t.lastSelected},e.prototype.getLastSelectedVariant=function(t){return e.GetLastSelectedVariant(t)},e._GetExtensionMetadata=function(e){var t,n;return(null===(n=null===(t=null==e?void 0:e.metadata)||void 0===t?void 0:t.gltf)||void 0===n?void 0:n.KHR_materials_variants)||null},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._variants=t.variants}},e.prototype._loadMeshPrimitiveAsync=function(t,n,a,i,s,l){var c=this;return o.b.LoadExtensionAsync(t,s,this.name,(function(u,d){var f=new Array;return f.push(c._loader._loadMeshPrimitiveAsync(t,n,a,i,s,(function(n){if(l(n),n instanceof r.Mesh){var a=o.b._GetDrawMode(t,s.mode),i=c._loader.rootBabylonMesh,h=i?i.metadata=i.metadata||{}:{},p=h.gltf=h.gltf||{},_=p.KHR_materials_variants=p.KHR_materials_variants||{lastSelected:null,original:[],variants:{}};_.original.push({mesh:n,material:n.material});for(var m=function(t){var r=d.mappings[t],s=o.a.Get("".concat(u,"/mappings/").concat(t,"/material"),c._loader.gltf.materials,r.material);f.push(c._loader._loadMaterialAsync("#/materials/".concat(r.material),s,n,a,(function(t){for(var a=function(a){var s=r.variants[a],l=o.a.Get("/extensions/".concat("KHR_materials_variants","/variants/").concat(s),c._variants,s);_.variants[l.name]=_.variants[l.name]||[],_.variants[l.name].push({mesh:n,material:t}),n.onClonedObservable.add((function(t){var r=t,o=null,a=r;do{if(!(a=a.parent))return;o=e._GetExtensionMetadata(a)}while(null===o);if(i&&o===e._GetExtensionMetadata(i)){for(var s in a.metadata={},i.metadata)a.metadata[s]=i.metadata[s];for(var s in a.metadata.gltf=[],i.metadata.gltf)a.metadata.gltf[s]=i.metadata.gltf[s];a.metadata.gltf.KHR_materials_variants={lastSelected:null,original:[],variants:{}};for(var c=0,u=o.original;c<u.length;c++){var d=u[c];a.metadata.gltf.KHR_materials_variants.original.push({mesh:d.mesh,material:d.material})}for(var s in o.variants)if(o.variants.hasOwnProperty(s)){a.metadata.gltf.KHR_materials_variants.variants[s]=[];for(var f=0,h=o.variants[s];f<h.length;f++){var p=h[f];a.metadata.gltf.KHR_materials_variants.variants[s].push({mesh:p.mesh,material:p.material})}}o=a.metadata.gltf.KHR_materials_variants}for(var _=0,m=o.original;_<m.length;_++){(v=m[_]).mesh===n&&(v.mesh=r)}for(var y=0,b=o.variants[l.name];y<b.length;y++){var v;(v=b[y]).mesh===n&&(v.mesh=r)}}))},s=0;s<r.variants.length;++s)a(s)})))},y=0;y<d.mappings.length;++y)m(y)}}))),Promise.all(f).then((function(e){return e[0]}))}))},e}();o.b.RegisterExtension("KHR_materials_variants",(function(e){return new v(e)}));var g=n(4),A=function(){function e(t,n){var o=this;this._opaqueRenderTarget=null,this._opaqueMeshesCache=[],this._transparentMeshesCache=[],this._materialObservers={},this._options=Object(g.a)(Object(g.a)({},e._getDefaultOptions()),t),this._scene=n,this._scene._transmissionHelper=this,this.onErrorObservable=new r.Observable,this._scene.onDisposeObservable.addOnce((function(e){o.dispose()})),this._parseScene(),this._setupRenderTargets()}return e._getDefaultOptions=function(){return{renderSize:1024,samples:4,lodGenerationScale:1,lodGenerationOffset:-4,renderTargetTextureType:r.Constants.TEXTURETYPE_HALF_FLOAT,generateMipmaps:!0}},e.prototype.updateOptions=function(e){var t=this;if(Object.keys(e).filter((function(n){return t._options[n]!==e[n]})).length){var n=Object(g.a)(Object(g.a)({},this._options),e),r=this._options;this._options=n,n.renderSize===r.renderSize&&n.renderTargetTextureType===r.renderTargetTextureType&&n.generateMipmaps===r.generateMipmaps&&this._opaqueRenderTarget?(this._opaqueRenderTarget.samples=n.samples,this._opaqueRenderTarget.lodGenerationScale=n.lodGenerationScale,this._opaqueRenderTarget.lodGenerationOffset=n.lodGenerationOffset):this._setupRenderTargets()}},e.prototype.getOpaqueTarget=function(){return this._opaqueRenderTarget},e.prototype.shouldRenderAsTransmission=function(e){return!!e&&!!(e instanceof r.PBRMaterial&&e.subSurface.isRefractionEnabled)},e.prototype._addMesh=function(e){var t=this;this._materialObservers[e.uniqueId]=e.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this)),r.Tools.SetImmediate((function(){t.shouldRenderAsTransmission(e.material)?(e.material.refractionTexture=t._opaqueRenderTarget,t._transparentMeshesCache.push(e)):t._opaqueMeshesCache.push(e)}))},e.prototype._removeMesh=function(e){e.onMaterialChangedObservable.remove(this._materialObservers[e.uniqueId]),delete this._materialObservers[e.uniqueId];var t=this._transparentMeshesCache.indexOf(e);-1!==t&&this._transparentMeshesCache.splice(t,1),-1!==(t=this._opaqueMeshesCache.indexOf(e))&&this._opaqueMeshesCache.splice(t,1)},e.prototype._parseScene=function(){this._scene.meshes.forEach(this._addMesh.bind(this)),this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this)),this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this))},e.prototype._onMeshMaterialChanged=function(e){var t=this._transparentMeshesCache.indexOf(e),n=this._opaqueMeshesCache.indexOf(e);this.shouldRenderAsTransmission(e.material)?(e.material instanceof r.PBRMaterial&&(e.material.subSurface.refractionTexture=this._opaqueRenderTarget),-1!==n?(this._opaqueMeshesCache.splice(n,1),this._transparentMeshesCache.push(e)):-1===t&&this._transparentMeshesCache.push(e)):-1!==t?(this._transparentMeshesCache.splice(t,1),this._opaqueMeshesCache.push(e)):-1===n&&this._opaqueMeshesCache.push(e)},e.prototype._setupRenderTargets=function(){var e,t,n,o,a=this;this._opaqueRenderTarget&&this._opaqueRenderTarget.dispose(),this._opaqueRenderTarget=new r.RenderTargetTexture("opaqueSceneTexture",this._options.renderSize,this._scene,this._options.generateMipmaps,void 0,this._options.renderTargetTextureType),this._opaqueRenderTarget.ignoreCameraViewport=!0,this._opaqueRenderTarget.renderList=this._opaqueMeshesCache,this._opaqueRenderTarget.clearColor=null!==(t=null===(e=this._options.clearColor)||void 0===e?void 0:e.clone())&&void 0!==t?t:this._scene.clearColor.clone(),this._opaqueRenderTarget.gammaSpace=!1,this._opaqueRenderTarget.lodGenerationScale=this._options.lodGenerationScale,this._opaqueRenderTarget.lodGenerationOffset=this._options.lodGenerationOffset,this._opaqueRenderTarget.samples=this._options.samples,this._opaqueRenderTarget.onBeforeBindObservable.add((function(e){o=a._scene.environmentIntensity,a._scene.environmentIntensity=1,n=a._scene.imageProcessingConfiguration.applyByPostProcess,a._options.clearColor?e.clearColor.copyFrom(a._options.clearColor):a._scene.clearColor.toLinearSpaceToRef(e.clearColor),a._scene.imageProcessingConfiguration._applyByPostProcess=!0})),this._opaqueRenderTarget.onAfterUnbindObservable.add((function(){a._scene.environmentIntensity=o,a._scene.imageProcessingConfiguration._applyByPostProcess=n})),this._transparentMeshesCache.forEach((function(e){a.shouldRenderAsTransmission(e.material)&&(e.material.refractionTexture=a._opaqueRenderTarget)}))},e.prototype.dispose=function(){this._scene._transmissionHelper=void 0,this._opaqueRenderTarget&&(this._opaqueRenderTarget.dispose(),this._opaqueRenderTarget=null),this._transparentMeshesCache=[],this._opaqueMeshesCache=[]},e}(),T=function(){function e(e){this.name="KHR_materials_transmission",this.order=175,this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_materials_transmission"),this.enabled&&(e.parent.transparencyAsCoverage=!0)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(o,a){var i=new Array;return i.push(r._loader.loadMaterialBasePropertiesAsync(e,t,n)),i.push(r._loader.loadMaterialPropertiesAsync(e,t,n)),i.push(r._loadTransparentPropertiesAsync(o,t,n,a)),Promise.all(i).then((function(){}))}))},e.prototype._loadTransparentPropertiesAsync=function(e,t,n,o){if(!(n instanceof r.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));var a=n;if(a.subSurface.isRefractionEnabled=!0,a.subSurface.volumeIndexOfRefraction=1,a.subSurface.useAlbedoToTintRefraction=!0,void 0===o.transmissionFactor)return a.subSurface.refractionIntensity=0,a.subSurface.isRefractionEnabled=!1,Promise.resolve();a.subSurface.refractionIntensity=o.transmissionFactor;var i=a.getScene();return a.subSurface.refractionIntensity&&!i._transmissionHelper&&new A({},a.getScene()),a.subSurface.minimumThickness=0,a.subSurface.maximumThickness=0,o.transmissionTexture?(o.transmissionTexture.nonColorData=!0,this._loader.loadTextureInfoAsync("".concat(e,"/transmissionTexture"),o.transmissionTexture,void 0).then((function(e){a.subSurface.refractionIntensityTexture=e,a.subSurface.useGltfStyleTextures=!0}))):Promise.resolve()},e}();o.b.RegisterExtension("KHR_materials_transmission",(function(e){return new T(e)}));var x=function(){function e(e){this.name="KHR_materials_translucency",this.order=174,this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_materials_translucency"),this.enabled&&(e.parent.transparencyAsCoverage=!0)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(o,a){var i=new Array;return i.push(r._loader.loadMaterialBasePropertiesAsync(e,t,n)),i.push(r._loader.loadMaterialPropertiesAsync(e,t,n)),i.push(r._loadTranslucentPropertiesAsync(o,t,n,a)),Promise.all(i).then((function(){}))}))},e.prototype._loadTranslucentPropertiesAsync=function(e,t,n,o){if(!(n instanceof r.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));var a=n;return a.subSurface.isTranslucencyEnabled=!0,a.subSurface.volumeIndexOfRefraction=1,a.subSurface.minimumThickness=0,a.subSurface.maximumThickness=0,a.subSurface.useAlbedoToTintTranslucency=!0,void 0===o.translucencyFactor?(a.subSurface.translucencyIntensity=0,a.subSurface.isTranslucencyEnabled=!1,Promise.resolve()):(a.subSurface.translucencyIntensity=o.translucencyFactor,o.translucencyTexture?(o.translucencyTexture.nonColorData=!0,this._loader.loadTextureInfoAsync("".concat(e,"/translucencyTexture"),o.translucencyTexture).then((function(e){a.subSurface.translucencyIntensityTexture=e}))):Promise.resolve())},e}();o.b.RegisterExtension("KHR_materials_translucency",(function(e){return new x(e)}));var E=function(){function e(e){this.name="KHR_materials_volume",this.order=173,this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_materials_volume"),this.enabled&&this._loader._disableInstancedMesh++}return e.prototype.dispose=function(){this.enabled&&this._loader._disableInstancedMesh--,this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(o,a){var i=new Array;return i.push(r._loader.loadMaterialBasePropertiesAsync(e,t,n)),i.push(r._loader.loadMaterialPropertiesAsync(e,t,n)),i.push(r._loadVolumePropertiesAsync(o,t,n,a)),Promise.all(i).then((function(){}))}))},e.prototype._loadVolumePropertiesAsync=function(e,t,n,o){if(!(n instanceof r.PBRMaterial))throw new Error("".concat(e,": Material type not supported"));if(!n.subSurface.isRefractionEnabled&&!n.subSurface.isTranslucencyEnabled||!o.thicknessFactor)return Promise.resolve();n.subSurface.volumeIndexOfRefraction=n.indexOfRefraction;var a=void 0!==o.attenuationDistance?o.attenuationDistance:Number.MAX_VALUE;return n.subSurface.tintColorAtDistance=a,void 0!==o.attenuationColor&&3==o.attenuationColor.length&&n.subSurface.tintColor.copyFromFloats(o.attenuationColor[0],o.attenuationColor[1],o.attenuationColor[2]),n.subSurface.minimumThickness=0,n.subSurface.maximumThickness=o.thicknessFactor,n.subSurface.useThicknessAsDepth=!0,o.thicknessTexture?(o.thicknessTexture.nonColorData=!0,this._loader.loadTextureInfoAsync("".concat(e,"/thicknessTexture"),o.thicknessTexture).then((function(e){n.subSurface.thicknessTexture=e,n.subSurface.useGltfStyleTextures=!0}))):Promise.resolve()},e}();o.b.RegisterExtension("KHR_materials_volume",(function(e){return new E(e)}));var O=function(){function e(e){this.name="KHR_mesh_quantization",this.enabled=e.isExtensionUsed("KHR_mesh_quantization")}return e.prototype.dispose=function(){},e}();o.b.RegisterExtension("KHR_mesh_quantization",(function(e){return new O(e)}));var L=function(){function e(e){this.name="KHR_texture_basisu",this._loader=e,this.enabled=e.isExtensionUsed("KHR_texture_basisu")}return e.prototype.dispose=function(){this._loader=null},e.prototype._loadTextureAsync=function(e,t,n){var r=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(a,i){var s=null==t.sampler?o.b.DefaultSampler:o.a.Get("".concat(e,"/sampler"),r._loader.gltf.samplers,t.sampler),l=o.a.Get("".concat(a,"/source"),r._loader.gltf.images,i.source);return r._loader._createTextureAsync(e,s,l,(function(e){n(e)}),t._textureInfo.nonColorData?{useRGBAIfASTCBC7NotAvailableWhenUASTC:!0}:void 0,!t._textureInfo.nonColorData)}))},e}();o.b.RegisterExtension("KHR_texture_basisu",(function(e){return new L(e)}));var M=function(){function e(e){this.name="KHR_texture_transform",this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_texture_transform")}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadTextureInfoAsync=function(e,t,n){var a=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(o,i){return a._loader.loadTextureInfoAsync(e,t,(function(e){if(!(e instanceof r.Texture))throw new Error("".concat(o,": Texture type not supported"));i.offset&&(e.uOffset=i.offset[0],e.vOffset=i.offset[1]),e.uRotationCenter=0,e.vRotationCenter=0,i.rotation&&(e.wAng=-i.rotation),i.scale&&(e.uScale=i.scale[0],e.vScale=i.scale[1]),null!=i.texCoord&&(e.coordinatesIndex=i.texCoord),n(e)}))}))},e}();o.b.RegisterExtension("KHR_texture_transform",(function(e){return new M(e)}));var S=function(){function e(e){this.name="KHR_xmp_json_ld",this.order=100,this._loader=e,this.enabled=this._loader.isExtensionUsed("KHR_xmp_json_ld")}return e.prototype.dispose=function(){this._loader=null},e.prototype.onLoading=function(){var e,t,n;if(null!==this._loader.rootBabylonMesh){var r=null===(e=this._loader.gltf.extensions)||void 0===e?void 0:e.KHR_xmp_json_ld,o=null===(n=null===(t=this._loader.gltf.asset)||void 0===t?void 0:t.extensions)||void 0===n?void 0:n.KHR_xmp_json_ld;if(r&&o){var a=+o.packet;r.packets&&a<r.packets.length&&(this._loader.rootBabylonMesh.metadata=this._loader.rootBabylonMesh.metadata||{},this._loader.rootBabylonMesh.metadata.xmp=r.packets[a])}}},e}();o.b.RegisterExtension("KHR_xmp_json_ld",(function(e){return new S(e)}));var C=function(){function e(e){this.name="MSFT_audio_emitter",this._loader=e,this.enabled=this._loader.isExtensionUsed("MSFT_audio_emitter")}return e.prototype.dispose=function(){this._loader=null,this._clips=null,this._emitters=null},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._clips=t.clips,this._emitters=t.emitters,o.a.Assign(this._clips),o.a.Assign(this._emitters)}},e.prototype.loadSceneAsync=function(e,t){var n=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(r,a){var i=new Array;i.push(n._loader.loadSceneAsync(e,t));for(var s=0,l=a.emitters;s<l.length;s++){var c=l[s],u=o.a.Get("".concat(r,"/emitters"),n._emitters,c);if(null!=u.refDistance||null!=u.maxDistance||null!=u.rolloffFactor||null!=u.distanceModel||null!=u.innerAngle||null!=u.outerAngle)throw new Error("".concat(r,": Direction or Distance properties are not allowed on emitters attached to a scene"));i.push(n._loadEmitterAsync("".concat(r,"/emitters/").concat(u.index),u))}return Promise.all(i).then((function(){}))}))},e.prototype.loadNodeAsync=function(e,t,n){var a=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(e,i){var s=new Array;return a._loader.loadNodeAsync(e,t,(function(t){for(var l=function(n){var i=o.a.Get("".concat(e,"/emitters"),a._emitters,n);s.push(a._loadEmitterAsync("".concat(e,"/emitters/").concat(i.index),i).then((function(){for(var e=0,n=i._babylonSounds;e<n.length;e++){var o=n[e];o.attachToMesh(t),null==i.innerAngle&&null==i.outerAngle||(o.setLocalDirectionToMesh(r.Vector3.Forward()),o.setDirectionalCone(2*r.Tools.ToDegrees(null==i.innerAngle?Math.PI:i.innerAngle),2*r.Tools.ToDegrees(null==i.outerAngle?Math.PI:i.outerAngle),0))}})))},c=0,u=i.emitters;c<u.length;c++){l(u[c])}n(t)})).then((function(e){return Promise.all(s).then((function(){return e}))}))}))},e.prototype.loadAnimationAsync=function(e,t){var n=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(r,a){return n._loader.loadAnimationAsync(e,t).then((function(i){var s=new Array;o.a.Assign(a.events);for(var l=0,c=a.events;l<c.length;l++){var u=c[l];s.push(n._loadAnimationEventAsync("".concat(r,"/events/").concat(u.index),e,t,u,i))}return Promise.all(s).then((function(){return i}))}))}))},e.prototype._loadClipAsync=function(e,t){if(t._objectURL)return t._objectURL;var n;if(t.uri)n=this._loader.loadUriAsync(e,t,t.uri);else{var r=o.a.Get("".concat(e,"/bufferView"),this._loader.gltf.bufferViews,t.bufferView);n=this._loader.loadBufferViewAsync("/bufferViews/".concat(r.index),r)}return t._objectURL=n.then((function(e){return URL.createObjectURL(new Blob([e],{type:t.mimeType}))})),t._objectURL},e.prototype._loadEmitterAsync=function(e,t){var n=this;if(t._babylonSounds=t._babylonSounds||[],!t._babylonData){for(var a=new Array,i=t.name||"emitter".concat(t.index),s={loop:!1,autoplay:!1,volume:null==t.volume?1:t.volume},l=function(e){var l="/extensions/".concat(c.name,"/clips"),u=o.a.Get(l,c._clips,t.clips[e].clip);a.push(c._loadClipAsync("".concat(l,"/").concat(t.clips[e].clip),u).then((function(o){var a=t._babylonSounds[e]=new r.Sound(i,o,n._loader.babylonScene,null,s);a.refDistance=t.refDistance||1,a.maxDistance=t.maxDistance||256,a.rolloffFactor=t.rolloffFactor||1,a.distanceModel=t.distanceModel||"exponential"})))},c=this,u=0;u<t.clips.length;u++)l(u);var d=Promise.all(a).then((function(){var e=t.clips.map((function(e){return e.weight||1})),n=new r.WeightedSound(t.loop||!1,t._babylonSounds,e);t.innerAngle&&(n.directionalConeInnerAngle=2*r.Tools.ToDegrees(t.innerAngle)),t.outerAngle&&(n.directionalConeOuterAngle=2*r.Tools.ToDegrees(t.outerAngle)),t.volume&&(n.volume=t.volume),t._babylonData.sound=n}));t._babylonData={loaded:d}}return t._babylonData.loaded},e.prototype._getEventAction=function(e,t,n,r,o){switch(n){case"play":return function(e){var n=(o||0)+(e-r);t.play(n)};case"stop":return function(e){t.stop()};case"pause":return function(e){t.pause()};default:throw new Error("".concat(e,": Unsupported action ").concat(n))}},e.prototype._loadAnimationEventAsync=function(e,t,n,a,i){var s=this;if(0==i.targetedAnimations.length)return Promise.resolve();var l=i.targetedAnimations[0],c=a.emitter,u=o.a.Get("/extensions/".concat(this.name,"/emitters"),this._emitters,c);return this._loadEmitterAsync(e,u).then((function(){var t=u._babylonData.sound;if(t){var n=new r.AnimationEvent(a.time,s._getEventAction(e,t,a.action,a.time,a.startOffset));l.animation.addEvent(n),i.onAnimationGroupEndObservable.add((function(){t.stop()})),i.onAnimationGroupPauseObservable.add((function(){t.pause()}))}}))},e}();o.b.RegisterExtension("MSFT_audio_emitter",(function(e){return new C(e)}));var R=function(){function e(e){this.name="MSFT_lod",this.order=100,this.maxLODsToLoad=10,this.onNodeLODsLoadedObservable=new r.Observable,this.onMaterialLODsLoadedObservable=new r.Observable,this._bufferLODs=new Array,this._nodeIndexLOD=null,this._nodeSignalLODs=new Array,this._nodePromiseLODs=new Array,this._nodeBufferLODs=new Array,this._materialIndexLOD=null,this._materialSignalLODs=new Array,this._materialPromiseLODs=new Array,this._materialBufferLODs=new Array,this._loader=e,this.enabled=this._loader.isExtensionUsed("MSFT_lod")}return e.prototype.dispose=function(){this._loader=null,this._nodeIndexLOD=null,this._nodeSignalLODs.length=0,this._nodePromiseLODs.length=0,this._nodeBufferLODs.length=0,this._materialIndexLOD=null,this._materialSignalLODs.length=0,this._materialPromiseLODs.length=0,this._materialBufferLODs.length=0,this.onMaterialLODsLoadedObservable.clear(),this.onNodeLODsLoadedObservable.clear()},e.prototype.onReady=function(){for(var e=this,t=function(t){var r=Promise.all(n._nodePromiseLODs[t]).then((function(){0!==t&&(e._loader.endPerformanceCounter("Node LOD ".concat(t)),e._loader.log("Loaded node LOD ".concat(t))),e.onNodeLODsLoadedObservable.notifyObservers(t),t!==e._nodePromiseLODs.length-1&&(e._loader.startPerformanceCounter("Node LOD ".concat(t+1)),e._loadBufferLOD(e._nodeBufferLODs,t+1),e._nodeSignalLODs[t]&&e._nodeSignalLODs[t].resolve())}));n._loader._completePromises.push(r)},n=this,r=0;r<this._nodePromiseLODs.length;r++)t(r);var o=function(t){var n=Promise.all(a._materialPromiseLODs[t]).then((function(){0!==t&&(e._loader.endPerformanceCounter("Material LOD ".concat(t)),e._loader.log("Loaded material LOD ".concat(t))),e.onMaterialLODsLoadedObservable.notifyObservers(t),t!==e._materialPromiseLODs.length-1&&(e._loader.startPerformanceCounter("Material LOD ".concat(t+1)),e._loadBufferLOD(e._materialBufferLODs,t+1),e._materialSignalLODs[t]&&e._materialSignalLODs[t].resolve())}));a._loader._completePromises.push(n)},a=this;for(r=0;r<this._materialPromiseLODs.length;r++)o(r)},e.prototype.loadSceneAsync=function(e,t){var n=this._loader.loadSceneAsync(e,t);return this._loadBufferLOD(this._bufferLODs,0),n},e.prototype.loadNodeAsync=function(e,t,n){var a=this;return o.b.LoadExtensionAsync(e,t,this.name,(function(e,o){var i,s=a._getLODs(e,t,a._loader.gltf.nodes,o.ids);a._loader.logOpen("".concat(e));for(var l=function(e){var t=s[e];0!==e&&(a._nodeIndexLOD=e,a._nodeSignalLODs[e]=a._nodeSignalLODs[e]||new r.Deferred);var o=a._loader.loadNodeAsync("/nodes/".concat(t.index),t,(function(e){n(e),e.setEnabled(!1)})).then((function(t){if(0!==e){var n=s[e-1];n._babylonTransformNode&&(a._disposeTransformNode(n._babylonTransformNode),delete n._babylonTransformNode)}return t.setEnabled(!0),t}));a._nodePromiseLODs[e]=a._nodePromiseLODs[e]||[],0===e?i=o:(a._nodeIndexLOD=null,a._nodePromiseLODs[e].push(o))},c=0;c<s.length;c++)l(c);return a._loader.logClose(),i}))},e.prototype._loadMaterialAsync=function(e,t,n,r,a){var i=this;return this._nodeIndexLOD?null:o.b.LoadExtensionAsync(e,t,this.name,(function(e,o){var s,l=i._getLODs(e,t,i._loader.gltf.materials,o.ids);i._loader.logOpen("".concat(e));for(var c=function(e){var t=l[e];0!==e&&(i._materialIndexLOD=e);var o=i._loader._loadMaterialAsync("/materials/".concat(t.index),t,n,r,(function(t){0===e&&a(t)})).then((function(t){if(0!==e){a(t);var n=l[e-1]._data;n[r]&&(i._disposeMaterials([n[r].babylonMaterial]),delete n[r])}return t}));i._materialPromiseLODs[e]=i._materialPromiseLODs[e]||[],0===e?s=o:(i._materialIndexLOD=null,i._materialPromiseLODs[e].push(o))},u=0;u<l.length;u++)c(u);return i._loader.logClose(),s}))},e.prototype._loadUriAsync=function(e,t,n){var o=this;if(null!==this._nodeIndexLOD){this._loader.log("deferred");var a=this._nodeIndexLOD-1;return this._nodeSignalLODs[a]=this._nodeSignalLODs[a]||new r.Deferred,this._nodeSignalLODs[this._nodeIndexLOD-1].promise.then((function(){return o._loader.loadUriAsync(e,t,n)}))}if(null!==this._materialIndexLOD){this._loader.log("deferred");a=this._materialIndexLOD-1;return this._materialSignalLODs[a]=this._materialSignalLODs[a]||new r.Deferred,this._materialSignalLODs[a].promise.then((function(){return o._loader.loadUriAsync(e,t,n)}))}return null},e.prototype.loadBufferAsync=function(e,t,n,o){if(this._loader.parent.useRangeRequests&&!t.uri){if(!this._loader.bin)throw new Error("".concat(e,": Uri is missing or the binary glTF is missing its binary chunk"));var a=function(e,t){var a=n,i=a+o-1,s=e[t];return s?(s.start=Math.min(s.start,a),s.end=Math.max(s.end,i)):(s={start:a,end:i,loaded:new r.Deferred},e[t]=s),s.loaded.promise.then((function(e){return new Uint8Array(e.buffer,e.byteOffset+n-s.start,o)}))};return this._loader.log("deferred"),null!==this._nodeIndexLOD?a(this._nodeBufferLODs,this._nodeIndexLOD):null!==this._materialIndexLOD?a(this._materialBufferLODs,this._materialIndexLOD):a(this._bufferLODs,0)}return null},e.prototype._loadBufferLOD=function(e,t){var n=e[t];n&&(this._loader.log("Loading buffer range [".concat(n.start,"-").concat(n.end,"]")),this._loader.bin.readAsync(n.start,n.end-n.start+1).then((function(e){n.loaded.resolve(e)}),(function(e){n.loaded.reject(e)})))},e.prototype._getLODs=function(e,t,n,r){if(this.maxLODsToLoad<=0)throw new Error("maxLODsToLoad must be greater than zero");for(var a=new Array,i=r.length-1;i>=0;i--)if(a.push(o.a.Get("".concat(e,"/ids/").concat(r[i]),n,r[i])),a.length===this.maxLODsToLoad)return a;return a.push(t),a},e.prototype._disposeTransformNode=function(e){var t=this,n=new Array,r=e.material;r&&n.push(r);for(var o=0,a=e.getChildMeshes();o<a.length;o++){var i=a[o];i.material&&n.push(i.material)}e.dispose();var s=n.filter((function(e){return t._loader.babylonScene.meshes.every((function(t){return t.material!=e}))}));this._disposeMaterials(s)},e.prototype._disposeMaterials=function(e){for(var t={},n=0,r=e;n<r.length;n++){for(var o=0,a=(u=r[n]).getActiveTextures();o<a.length;o++){var i=a[o];t[i.uniqueId]=i}u.dispose()}for(var s in t)for(var l=0,c=this._loader.babylonScene.materials;l<c.length;l++){var u;(u=c[l]).hasTexture(t[s])&&delete t[s]}for(var s in t)t[s].dispose()},e}();o.b.RegisterExtension("MSFT_lod",(function(e){return new R(e)}));var w=function(){function e(e){this.name="MSFT_minecraftMesh",this._loader=e,this.enabled=this._loader.isExtensionUsed("MSFT_minecraftMesh")}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var a=this;return o.b.LoadExtraAsync(e,t,this.name,(function(o,i){if(i){if(!(n instanceof r.PBRMaterial))throw new Error("".concat(o,": Material type not supported"));var s=a._loader.loadMaterialPropertiesAsync(e,t,n);return n.needAlphaBlending()&&(n.forceDepthWrite=!0,n.separateCullingPass=!0),n.backFaceCulling=n.forceDepthWrite,n.twoSidedLighting=!0,s}return null}))},e}();o.b.RegisterExtension("MSFT_minecraftMesh",(function(e){return new w(e)}));var P=function(){function e(e){this.name="MSFT_sRGBFactors",this._loader=e,this.enabled=this._loader.isExtensionUsed("MSFT_sRGBFactors")}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var a=this;return o.b.LoadExtraAsync(e,t,this.name,(function(o,i){if(i){if(!(n instanceof r.PBRMaterial))throw new Error("".concat(o,": Material type not supported"));var s=a._loader.loadMaterialPropertiesAsync(e,t,n);return n.albedoTexture||n.albedoColor.toLinearSpaceToRef(n.albedoColor),n.reflectivityTexture||n.reflectivityColor.toLinearSpaceToRef(n.reflectivityColor),s}return null}))},e}();o.b.RegisterExtension("MSFT_sRGBFactors",(function(e){return new P(e)}));var N=function(){function e(e){this.name="ExtrasAsMetadata",this.enabled=!0,this._loader=e}return e.prototype._assignExtras=function(e,t){if(t.extras&&Object.keys(t.extras).length>0){var n=e.metadata=e.metadata||{};(n.gltf=n.gltf||{}).extras=t.extras}},e.prototype.dispose=function(){this._loader=null},e.prototype.loadNodeAsync=function(e,t,n){var r=this;return this._loader.loadNodeAsync(e,t,(function(e){r._assignExtras(e,t),n(e)}))},e.prototype.loadCameraAsync=function(e,t,n){var r=this;return this._loader.loadCameraAsync(e,t,(function(e){r._assignExtras(e,t),n(e)}))},e.prototype.createMaterial=function(e,t,n){var r=this._loader.createMaterial(e,t,n);return this._assignExtras(r,t),r},e}();o.b.RegisterExtension("ExtrasAsMetadata",(function(e){return new N(e)}))},function(e,t,n){"use strict";n.r(t),n.d(t,"GLTFBinaryExtension",(function(){return U})),n.d(t,"GLTFLoaderBase",(function(){return V})),n.d(t,"GLTFLoader",(function(){return G})),n.d(t,"GLTFLoaderExtension",(function(){return k})),n.d(t,"EComponentType",(function(){return r})),n.d(t,"EShaderType",(function(){return o})),n.d(t,"EParameterType",(function(){return a})),n.d(t,"ETextureWrapMode",(function(){return i})),n.d(t,"ETextureFilterType",(function(){return s})),n.d(t,"ETextureFormat",(function(){return l})),n.d(t,"ECullingType",(function(){return c})),n.d(t,"EBlendingFunction",(function(){return u})),n.d(t,"GLTFUtils",(function(){return p})),n.d(t,"GLTFMaterialsCommonExtension",(function(){return H}));var r,o,a,i,s,l,c,u,d=n(4);!function(e){e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.FLOAT=5126]="FLOAT"}(r||(r={})),function(e){e[e.FRAGMENT=35632]="FRAGMENT",e[e.VERTEX=35633]="VERTEX"}(o||(o={})),function(e){e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D"}(a||(a={})),function(e){e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.REPEAT=10497]="REPEAT"}(i||(i={})),function(e){e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9728]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR"}(s||(s={})),function(e){e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA"}(l||(l={})),function(e){e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK"}(c||(c={})),function(e){e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE"}(u||(u={}));var f,h=n(0),p=function(){function e(){}return e.SetMatrix=function(e,t,n,r,o){var i=null;if("MODEL"===n.semantic?i=t.getWorldMatrix():"PROJECTION"===n.semantic?i=e.getProjectionMatrix():"VIEW"===n.semantic?i=e.getViewMatrix():"MODELVIEWINVERSETRANSPOSE"===n.semantic?i=h.Matrix.Transpose(t.getWorldMatrix().multiply(e.getViewMatrix()).invert()):"MODELVIEW"===n.semantic?i=t.getWorldMatrix().multiply(e.getViewMatrix()):"MODELVIEWPROJECTION"===n.semantic?i=t.getWorldMatrix().multiply(e.getTransformMatrix()):"MODELINVERSE"===n.semantic?i=t.getWorldMatrix().invert():"VIEWINVERSE"===n.semantic?i=e.getViewMatrix().invert():"PROJECTIONINVERSE"===n.semantic?i=e.getProjectionMatrix().invert():"MODELVIEWINVERSE"===n.semantic?i=t.getWorldMatrix().multiply(e.getViewMatrix()).invert():"MODELVIEWPROJECTIONINVERSE"===n.semantic?i=t.getWorldMatrix().multiply(e.getTransformMatrix()).invert():"MODELINVERSETRANSPOSE"===n.semantic&&(i=h.Matrix.Transpose(t.getWorldMatrix().invert())),i)switch(n.type){case a.FLOAT_MAT2:o.setMatrix2x2(r,h.Matrix.GetAsMatrix2x2(i));break;case a.FLOAT_MAT3:o.setMatrix3x3(r,h.Matrix.GetAsMatrix3x3(i));break;case a.FLOAT_MAT4:o.setMatrix(r,i)}},e.SetUniform=function(e,t,n,r){switch(r){case a.FLOAT:return e.setFloat(t,n),!0;case a.FLOAT_VEC2:return e.setVector2(t,h.Vector2.FromArray(n)),!0;case a.FLOAT_VEC3:return e.setVector3(t,h.Vector3.FromArray(n)),!0;case a.FLOAT_VEC4:return e.setVector4(t,h.Vector4.FromArray(n)),!0;default:return!1}},e.GetWrapMode=function(e){switch(e){case i.CLAMP_TO_EDGE:return h.Texture.CLAMP_ADDRESSMODE;case i.MIRRORED_REPEAT:return h.Texture.MIRROR_ADDRESSMODE;case i.REPEAT:default:return h.Texture.WRAP_ADDRESSMODE}},e.GetByteStrideFromType=function(e){switch(e.type){case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:return 1}},e.GetTextureFilterMode=function(e){switch(e){case s.LINEAR:case s.LINEAR_MIPMAP_NEAREST:case s.LINEAR_MIPMAP_LINEAR:return h.Texture.TRILINEAR_SAMPLINGMODE;case s.NEAREST:case s.NEAREST_MIPMAP_NEAREST:return h.Texture.NEAREST_SAMPLINGMODE;default:return h.Texture.BILINEAR_SAMPLINGMODE}},e.GetBufferFromBufferView=function(e,t,n,o,a){n=t.byteOffset+n;var i=e.loadedBufferViews[t.buffer];if(n+o>i.byteLength)throw new Error("Buffer access is out of range");var s=i.buffer;switch(n+=i.byteOffset,a){case r.BYTE:return new Int8Array(s,n,o);case r.UNSIGNED_BYTE:return new Uint8Array(s,n,o);case r.SHORT:return new Int16Array(s,n,o);case r.UNSIGNED_SHORT:return new Uint16Array(s,n,o);default:return new Float32Array(s,n,o)}},e.GetBufferFromAccessor=function(t,n){var r=t.bufferViews[n.bufferView],o=n.count*e.GetByteStrideFromType(n);return e.GetBufferFromBufferView(t,r,n.byteOffset,o,n.componentType)},e.DecodeBufferToText=function(e){for(var t="",n=e.byteLength,r=0;r<n;++r)t+=String.fromCharCode(e[r]);return t},e.GetDefaultMaterial=function(t){if(!e._DefaultMaterial){h.Effect.ShadersStore.GLTFDefaultMaterialVertexShader=["precision highp float;","","uniform mat4 worldView;","uniform mat4 projection;","","attribute vec3 position;","","void main(void)","{","    gl_Position = projection * worldView * vec4(position, 1.0);","}"].join("\n"),h.Effect.ShadersStore.GLTFDefaultMaterialPixelShader=["precision highp float;","","uniform vec4 u_emission;","","void main(void)","{","    gl_FragColor = u_emission;","}"].join("\n");var n={attributes:["position"],uniforms:["worldView","projection","u_emission"],samplers:new Array,needAlphaBlending:!1};e._DefaultMaterial=new h.ShaderMaterial("GLTFDefaultMaterial",t,{vertex:"GLTFDefaultMaterial",fragment:"GLTFDefaultMaterial"},n),e._DefaultMaterial.setColor4("u_emission",new h.Color4(.5,.5,.5,1))}return e._DefaultMaterial},e._DefaultMaterial=null,e}(),_=n(2);!function(e){e[e.IDENTIFIER=1]="IDENTIFIER",e[e.UNKNOWN=2]="UNKNOWN",e[e.END_OF_INPUT=3]="END_OF_INPUT"}(f||(f={}));var m=function(){function e(e){this._pos=0,this.currentToken=f.UNKNOWN,this.currentIdentifier="",this.currentString="",this.isLetterOrDigitPattern=/^[a-zA-Z0-9]+$/,this._toParse=e,this._maxPos=e.length}return e.prototype.getNextToken=function(){if(this.isEnd())return f.END_OF_INPUT;if(this.currentString=this.read(),this.currentToken=f.UNKNOWN,"_"===this.currentString||this.isLetterOrDigitPattern.test(this.currentString))for(this.currentToken=f.IDENTIFIER,this.currentIdentifier=this.currentString;!this.isEnd()&&(this.isLetterOrDigitPattern.test(this.currentString=this.peek())||"_"===this.currentString);)this.currentIdentifier+=this.currentString,this.forward();return this.currentToken},e.prototype.peek=function(){return this._toParse[this._pos]},e.prototype.read=function(){return this._toParse[this._pos++]},e.prototype.forward=function(){this._pos++},e.prototype.isEnd=function(){return this._pos>=this._maxPos},e}(),y=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],b=["world","view","projection","worldView","worldViewProjection","mBones"],v=["translation","rotation","scale"],g=["position","rotationQuaternion","scaling"],A=function(e,t,n){for(var r in e){var o=e[r];n[t][r]=o}},T=function(e){if(e)for(var t=0;t<e.length/2;t++)e[2*t+1]=1-e[2*t+1]},x=function(e){if("NORMAL"===e.semantic)return"normal";if("POSITION"===e.semantic)return"position";if("JOINT"===e.semantic)return"matricesIndices";if("WEIGHT"===e.semantic)return"matricesWeights";if("COLOR"===e.semantic)return"color";if(e.semantic&&-1!==e.semantic.indexOf("TEXCOORD_")){var t=Number(e.semantic.split("_")[1]);return"uv"+(0===t?"":t+1)}return null},E=function(e){var t=null;if(e.translation||e.rotation||e.scale){var n=h.Vector3.FromArray(e.scale||[1,1,1]),r=h.Quaternion.FromArray(e.rotation||[0,0,0,1]),o=h.Vector3.FromArray(e.translation||[0,0,0]);t=h.Matrix.Compose(n,r,o)}else t=h.Matrix.FromArray(e.matrix);return t},O=function(e,t,n,r){for(var o=0;o<r.bones.length;o++)if(r.bones[o].name===n)return r.bones[o];var a=e.nodes;for(var i in a){var s=a[i];if(s.jointName){var l=s.children;for(o=0;o<l.length;o++){var c=e.nodes[l[o]];if(c.jointName&&c.jointName===n){var u=E(s),d=new h.Bone(s.name||"",r,O(e,t,s.jointName,r),u);return d.id=i,d}}}}return null},L=function(e,t){for(var n=0;n<e.length;n++)for(var r=e[n],o=0;o<r.node.children.length;o++){if(r.node.children[o]===t)return r.bone}return null},M=function(e,t){var n=e.nodes,r=n[t];if(r)return{node:r,id:t};for(var o in n)if((r=n[o]).jointName===t)return{node:r,id:o};return null},S=function(e,t){for(var n=0;n<e.jointNames.length;n++)if(e.jointNames[n]===t)return!0;return!1},C=function(e,t,n,r,o){if(r||(r=new h.Skeleton(t.name||"","",e.scene)),!t.babylonSkeleton)return r;var a=[],i=[];!function(e,t,n,r){for(var o in e.nodes){var a=e.nodes[o],i=o;if(a.jointName&&!S(n,a.jointName)){var s=E(a),l=new h.Bone(a.name||"",t,null,s);l.id=i,r.push({bone:l,node:a,id:i})}}for(var c=0;c<r.length;c++)for(var u=r[c],d=u.node.children,f=0;f<d.length;f++){for(var p=null,_=0;_<r.length;_++)if(r[_].id===d[f]){p=r[_];break}p&&(p.bone._parent=u.bone,u.bone.children.push(p.bone))}}(e,r,t,a),r.bones=[];for(var s=0;s<t.jointNames.length;s++){if(g=M(e,t.jointNames[s])){var l=g.node;if(l){o=g.id;var c=e.scene.getBoneById(o);if(c)r.bones.push(c);else{for(var u=!1,d=null,f=0;f<s;f++){var p=M(e,t.jointNames[f]);if(p){var _=p.node;if(_){var m=_.children;if(m){u=!1;for(var y=0;y<m.length;y++)if(m[y]===o){d=O(e,t,t.jointNames[f],r),u=!0;break}if(u)break}}else h.Tools.Warn("Joint named "+t.jointNames[f]+" does not exist when looking for parent")}}var b=E(l);!d&&a.length>0&&(d=L(a,o))&&-1===i.indexOf(d)&&i.push(d),new h.Bone(l.jointName||"",r,d,b).id=o}}else h.Tools.Warn("Joint named "+t.jointNames[s]+" does not exist")}}var v=r.bones;r.bones=[];for(s=0;s<t.jointNames.length;s++){var g;if(g=M(e,t.jointNames[s]))for(f=0;f<v.length;f++)if(v[f].id===g.id){r.bones.push(v[f]);break}}r.prepare();for(s=0;s<i.length;s++)r.bones.push(i[s]);return r},R=function(e,t,n,r,o){if(o||(e.scene._blockEntityCollection=!!e.assetContainer,(o=new h.Mesh(t.name||"",e.scene))._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,o.id=r),!t.babylonNode)return o;for(var a,i=[],s=null,l=new Array,c=new Array,u=new Array,d=new Array,f=0;f<n.length;f++){var m=n[f];if(P=e.meshes[m])for(var y=0;y<P.primitives.length;y++){var b=new h.VertexData,v=P.primitives[y];v.mode;var g=v.attributes,A=null,x=null;for(var E in g)if(A=e.accessors[g[E]],x=p.GetBufferFromAccessor(e,A),"NORMAL"===E)b.normals=new Float32Array(x.length),b.normals.set(x);else if("POSITION"===E){if(_.GLTFFileLoader.HomogeneousCoordinates){b.positions=new Float32Array(x.length-x.length/4);for(var O=0;O<x.length;O+=4)b.positions[O]=x[O],b.positions[O+1]=x[O+1],b.positions[O+2]=x[O+2]}else b.positions=new Float32Array(x.length),b.positions.set(x);c.push(b.positions.length)}else if(-1!==E.indexOf("TEXCOORD_")){var L=Number(E.split("_")[1]),M=h.VertexBuffer.UVKind+(0===L?"":L+1),S=new Float32Array(x.length);S.set(x),T(S),b.set(S,M)}else"JOINT"===E?(b.matricesIndices=new Float32Array(x.length),b.matricesIndices.set(x)):"WEIGHT"===E?(b.matricesWeights=new Float32Array(x.length),b.matricesWeights.set(x)):"COLOR"===E&&(b.colors=new Float32Array(x.length),b.colors.set(x));if(A=e.accessors[v.indices])x=p.GetBufferFromAccessor(e,A),b.indices=new Int32Array(x.length),b.indices.set(x),d.push(b.indices.length);else{var C=[];for(O=0;O<b.positions.length/3;O++)C.push(O);b.indices=new Int32Array(C),d.push(b.indices.length)}s?s.merge(b):s=b;var R=e.scene.getMaterialById(v.material);i.push(null===R?p.GetDefaultMaterial(e.scene):R),l.push(0===l.length?0:l[l.length-1]+c[c.length-2]),u.push(0===u.length?0:u[u.length-1]+d[d.length-2])}}e.scene._blockEntityCollection=!!e.assetContainer,i.length>1?(a=new h.MultiMaterial("multimat"+r,e.scene)).subMaterials=i:a=new h.StandardMaterial("multimat"+r,e.scene),1===i.length&&(a=i[0]),a._parentContainer=e.assetContainer,o.material||(o.material=a),new h.Geometry(r,e.scene,s,!1,o),o.computeWorldMatrix(!0),e.scene._blockEntityCollection=!1,o.subMeshes=[];var w=0;for(f=0;f<n.length;f++){var P;m=n[f];if(P=e.meshes[m])for(y=0;y<P.primitives.length;y++)P.primitives[y].mode,h.SubMesh.AddToMesh(w,l[w],c[w],u[w],d[w],o,o,!0),w++}return o},w=function(e,t,n,r){e.position&&(e.position=t),(e.rotationQuaternion||e.rotation)&&(e.rotationQuaternion=n),e.scaling&&(e.scaling=r)},P=function(e,t,n,r){var o=null;if(e.importOnlyMeshes&&(t.skin||t.meshes)&&e.importMeshesNames&&e.importMeshesNames.length>0&&-1===e.importMeshesNames.indexOf(t.name||""))return null;if(t.skin){if(t.meshes){var a=e.skins[t.skin];(i=R(e,t,t.meshes,n,t.babylonNode)).skeleton=e.scene.getLastSkeletonById(t.skin),null===i.skeleton&&(i.skeleton=C(e,a,0,a.babylonSkeleton,t.skin),a.babylonSkeleton||(a.babylonSkeleton=i.skeleton)),o=i}}else if(t.meshes){var i;o=i=R(e,t,t.mesh?[t.mesh]:t.meshes,n,t.babylonNode)}else if(!t.light||t.babylonNode||e.importOnlyMeshes){if(t.camera&&!t.babylonNode&&!e.importOnlyMeshes){var s=e.cameras[t.camera];if(s){if(e.scene._blockEntityCollection=!!e.assetContainer,"orthographic"===s.type){var l=new h.FreeCamera(t.camera,h.Vector3.Zero(),e.scene,!1);l.name=t.name||"",l.mode=h.Camera.ORTHOGRAPHIC_CAMERA,l.attachControl(),o=l,l._parentContainer=e.assetContainer}else if("perspective"===s.type){var c=s[s.type],u=new h.FreeCamera(t.camera,h.Vector3.Zero(),e.scene,!1);u.name=t.name||"",u.attachControl(),c.aspectRatio||(c.aspectRatio=e.scene.getEngine().getRenderWidth()/e.scene.getEngine().getRenderHeight()),c.znear&&c.zfar&&(u.maxZ=c.zfar,u.minZ=c.znear),o=u,u._parentContainer=e.assetContainer}e.scene._blockEntityCollection=!1}}}else{var d=e.lights[t.light];if(d)if("ambient"===d.type){var f=d[d.type],p=new h.HemisphericLight(t.light,h.Vector3.Zero(),e.scene);p.name=t.name||"",f.color&&(p.diffuse=h.Color3.FromArray(f.color)),o=p}else if("directional"===d.type){var _=d[d.type],m=new h.DirectionalLight(t.light,h.Vector3.Zero(),e.scene);m.name=t.name||"",_.color&&(m.diffuse=h.Color3.FromArray(_.color)),o=m}else if("point"===d.type){var y=d[d.type],b=new h.PointLight(t.light,h.Vector3.Zero(),e.scene);b.name=t.name||"",y.color&&(b.diffuse=h.Color3.FromArray(y.color)),o=b}else if("spot"===d.type){var v=d[d.type],g=new h.SpotLight(t.light,h.Vector3.Zero(),h.Vector3.Zero(),0,0,e.scene);g.name=t.name||"",v.color&&(g.diffuse=h.Color3.FromArray(v.color)),v.fallOfAngle&&(g.angle=v.fallOfAngle),v.fallOffExponent&&(g.exponent=v.fallOffExponent),o=g}}if(!t.jointName){if(t.babylonNode)return t.babylonNode;if(null===o){e.scene._blockEntityCollection=!!e.assetContainer;var A=new h.Mesh(t.name||"",e.scene);A._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,t.babylonNode=A,o=A}}if(null!==o){if(t.matrix&&o instanceof h.Mesh)!function(e,t,n){if(t.matrix){var r=new h.Vector3(0,0,0),o=new h.Quaternion,a=new h.Vector3(0,0,0);h.Matrix.FromArray(t.matrix).decompose(a,o,r),w(e,r,o,a)}else t.translation&&t.rotation&&t.scale&&w(e,h.Vector3.FromArray(t.translation),h.Quaternion.FromArray(t.rotation),h.Vector3.FromArray(t.scale));e.computeWorldMatrix(!0)}(o,t);else{var T=t.translation||[0,0,0],x=t.rotation||[0,0,0,1],E=t.scale||[1,1,1];w(o,h.Vector3.FromArray(T),h.Quaternion.FromArray(x),h.Vector3.FromArray(E))}o.updateCache(!0),t.babylonNode=o}return o},N=function(e,t,n,r){void 0===r&&(r=!1);var o=e.nodes[t],a=null;if(r=!(e.importOnlyMeshes&&!r&&e.importMeshesNames)||(-1!==e.importMeshesNames.indexOf(o.name||"")||0===e.importMeshesNames.length),!o.jointName&&r&&null!==(a=P(e,o,t))&&(a.id=t,a.parent=n),o.children)for(var i=0;i<o.children.length;i++)N(e,o.children[i],a,r)},I=function(e){var t=e.currentScene;if(t)for(var n=0;n<t.nodes.length;n++)N(e,t.nodes[n],null);else for(var r in e.scenes){t=e.scenes[r];for(n=0;n<t.nodes.length;n++)N(e,t.nodes[n],null)}!function(e){for(var t in e.animations){var n=e.animations[t];if(n.channels&&n.samplers)for(var r=null,o=0;o<n.channels.length;o++){var a=n.channels[o],i=n.samplers[a.sampler];if(i){var s=null,l=null;n.parameters?(s=n.parameters[i.input],l=n.parameters[i.output]):(s=i.input,l=i.output);var c=p.GetBufferFromAccessor(e,e.accessors[s]),u=p.GetBufferFromAccessor(e,e.accessors[l]),d=a.target.id,f=e.scene.getNodeById(d);if(null===f&&(f=e.scene.getNodeByName(d)),null!==f){var _=f instanceof h.Bone,m=a.target.path,y=v.indexOf(m);-1!==y&&(m=g[y]);var b=h.Animation.ANIMATIONTYPE_MATRIX;_||("rotationQuaternion"===m?(b=h.Animation.ANIMATIONTYPE_QUATERNION,f.rotationQuaternion=new h.Quaternion):b=h.Animation.ANIMATIONTYPE_VECTOR3);var A=null,T=[],x=0,E=!1;_&&r&&r.getKeys().length===c.length&&(A=r,E=!0),E||(e.scene._blockEntityCollection=!!e.assetContainer,A=new h.Animation(t,_?"_matrix":m,1,b,h.Animation.ANIMATIONLOOPMODE_CYCLE),e.scene._blockEntityCollection=!1);for(var O=0;O<c.length;O++){var L=null;if("rotationQuaternion"===m?(L=h.Quaternion.FromArray([u[x],u[x+1],u[x+2],u[x+3]]),x+=4):(L=h.Vector3.FromArray([u[x],u[x+1],u[x+2]]),x+=3),_){var M=f,S=h.Vector3.Zero(),C=new h.Quaternion,R=h.Vector3.Zero(),w=M.getBaseMatrix();E&&r&&(w=r.getKeys()[O].value),w.decompose(R,C,S),"position"===m?S=L:"rotationQuaternion"===m?C=L:R=L,L=h.Matrix.Compose(R,C,S)}E?r&&(r.getKeys()[O].value=L):T.push({frame:c[O],value:L})}!E&&A&&(A.setKeys(T),f.animations.push(A)),r=A,e.scene.stopAnimation(f),e.scene.beginAnimation(f,0,c[c.length-1],!0,1)}else h.Tools.Warn("Creating animation named "+t+". But cannot find node named "+d+" to attach to")}}}}(e);for(n=0;n<e.scene.skeletons.length;n++){var o=e.scene.skeletons[n];e.scene.beginAnimation(o,0,Number.MAX_VALUE,!0,1)}},F=function(e,t,n,r,o,i){return function(s){!function(e,t,n,r,o){var i=r.values||n.parameters,s=n.uniforms;for(var l in o){var c=o[l],u=c.type,d=i[s[l]];if(void 0===d&&(d=c.value),d){var f=function(e){return function(n){c.value&&e&&(t.setTexture(e,n),delete o[e])}};u===a.SAMPLER_2D?k.LoadTextureAsync(e,r.values?d:c.value,f(l),(function(){return f(null)})):c.value&&p.SetUniform(t,l,r.values?d:c.value,u)&&delete o[l]}}}(e,t,n,r,o),t.onBind=function(s){!function(e,t,n,r,o,i,s){var l=i.values||o.parameters;for(var c in n){var u=n[c],d=u.type;if(d===a.FLOAT_MAT2||d===a.FLOAT_MAT3||d===a.FLOAT_MAT4)if(!u.semantic||u.source||u.node){if(u.semantic&&(u.source||u.node)){var f=t.scene.getNodeByName(u.source||u.node||"");if(null===f&&(f=t.scene.getNodeById(u.source||u.node||"")),null===f)continue;p.SetMatrix(t.scene,f,u,c,r.getEffect())}}else p.SetMatrix(t.scene,e,u,c,r.getEffect());else{var h=l[o.uniforms[c]];if(!h)continue;if(d===a.SAMPLER_2D){var _=t.textures[i.values?h:u.value].babylonTexture;if(null==_)continue;r.getEffect().setTexture(c,_)}else p.SetUniform(r.getEffect(),c,h,d)}}s(r)}(s,e,o,t,n,r,i)}}},B=function(e,t,n){for(var r in t.uniforms){var o=t.uniforms[r],a=t.parameters[o];if(e.currentIdentifier===r&&a.semantic&&!a.source&&!a.node){var i=y.indexOf(a.semantic);if(-1!==i)return delete n[r],b[i]}}return e.currentIdentifier},D=function(e){for(var t in e.materials)k.LoadMaterialAsync(e,t,(function(e){}),(function(){}))},V=function(){function e(){}return e.CreateRuntime=function(e,t,n){var r={extensions:{},accessors:{},buffers:{},bufferViews:{},meshes:{},lights:{},cameras:{},nodes:{},images:{},textures:{},shaders:{},programs:{},samplers:{},techniques:{},materials:{},animations:{},skins:{},extensionsUsed:[],scenes:{},buffersCount:0,shaderscount:0,scene:t,rootUrl:n,loadedBufferCount:0,loadedBufferViews:{},loadedShaderCount:0,importOnlyMeshes:!1,dummyNodes:[],assetContainer:null};return e.extensions&&A(e.extensions,"extensions",r),e.extensionsUsed&&A(e.extensionsUsed,"extensionsUsed",r),e.buffers&&function(e,t){for(var n in e){var r=e[n];t.buffers[n]=r,t.buffersCount++}}(e.buffers,r),e.bufferViews&&A(e.bufferViews,"bufferViews",r),e.accessors&&A(e.accessors,"accessors",r),e.meshes&&A(e.meshes,"meshes",r),e.lights&&A(e.lights,"lights",r),e.cameras&&A(e.cameras,"cameras",r),e.nodes&&A(e.nodes,"nodes",r),e.images&&A(e.images,"images",r),e.textures&&A(e.textures,"textures",r),e.shaders&&function(e,t){for(var n in e){var r=e[n];t.shaders[n]=r,t.shaderscount++}}(e.shaders,r),e.programs&&A(e.programs,"programs",r),e.samplers&&A(e.samplers,"samplers",r),e.techniques&&A(e.techniques,"techniques",r),e.materials&&A(e.materials,"materials",r),e.animations&&A(e.animations,"animations",r),e.skins&&A(e.skins,"skins",r),e.scenes&&(r.scenes=e.scenes),e.scene&&e.scenes&&(r.currentScene=e.scenes[e.scene]),r},e.LoadBufferAsync=function(e,t,n,r,o){var a=e.buffers[t];h.Tools.IsBase64(a.uri)?setTimeout((function(){return n(new Uint8Array(h.Tools.DecodeBase64(a.uri)))})):h.Tools.LoadFile(e.rootUrl+a.uri,(function(e){return n(new Uint8Array(e))}),o,void 0,!0,(function(e){e&&r(e.status+" "+e.statusText)}))},e.LoadTextureBufferAsync=function(e,t,n,r){var o=e.textures[t];if(o&&o.source)if(o.babylonTexture)n(null);else{var a=e.images[o.source];h.Tools.IsBase64(a.uri)?setTimeout((function(){return n(new Uint8Array(h.Tools.DecodeBase64(a.uri)))})):h.Tools.LoadFile(e.rootUrl+a.uri,(function(e){return n(new Uint8Array(e))}),void 0,void 0,!0,(function(e){e&&r(e.status+" "+e.statusText)}))}else r("")},e.CreateTextureAsync=function(e,t,n,r,o){var a=e.textures[t];if(a.babylonTexture)r(a.babylonTexture);else{var i=e.samplers[a.sampler],l=i.minFilter===s.NEAREST_MIPMAP_NEAREST||i.minFilter===s.NEAREST_MIPMAP_LINEAR||i.minFilter===s.LINEAR_MIPMAP_NEAREST||i.minFilter===s.LINEAR_MIPMAP_LINEAR,c=h.Texture.BILINEAR_SAMPLINGMODE,u=null==n?new Blob:new Blob([n]),d=URL.createObjectURL(u),f=function(){return URL.revokeObjectURL(d)},_=new h.Texture(d,e.scene,!l,!0,c,f,f);void 0!==i.wrapS&&(_.wrapU=p.GetWrapMode(i.wrapS)),void 0!==i.wrapT&&(_.wrapV=p.GetWrapMode(i.wrapT)),_.name=t,a.babylonTexture=_,r(_)}},e.LoadShaderStringAsync=function(e,t,n,r){var o=e.shaders[t];if(h.Tools.IsBase64(o.uri)){var a=atob(o.uri.split(",")[1]);n&&n(a)}else h.Tools.LoadFile(e.rootUrl+o.uri,n,void 0,void 0,!1,(function(e){e&&r&&r(e.status+" "+e.statusText)}))},e.LoadMaterialAsync=function(e,t,n,r){var o=e.materials[t];if(o.technique){var i=e.techniques[o.technique];if(!i){e.scene._blockEntityCollection=!!e.assetContainer;var s=new h.StandardMaterial(t,e.scene);return s._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,s.diffuseColor=new h.Color3(.5,.5,.5),s.sideOrientation=h.Material.CounterClockWiseSideOrientation,void n(s)}var l=e.programs[i.program],d=i.states,p=h.Effect.ShadersStore[l.vertexShader+"VertexShader"],_=h.Effect.ShadersStore[l.fragmentShader+"PixelShader"],v="",g="",A=new m(p),T=new m(_),E={},O=[],L=[],M=[];for(var S in i.uniforms){var C=i.uniforms[S],R=i.parameters[C];if(E[S]=R,!R.semantic||R.node||R.source)R.type===a.SAMPLER_2D?M.push(S):O.push(S);else{var w=y.indexOf(R.semantic);-1!==w?(O.push(b[w]),delete E[S]):O.push(S)}}for(var P in i.attributes){var N=i.attributes[P];if((V=i.parameters[N]).semantic){var I=x(V);I&&L.push(I)}}for(;!A.isEnd()&&A.getNextToken();){if(A.currentToken===f.IDENTIFIER){var D=!1;for(var P in i.attributes){N=i.attributes[P];var V=i.parameters[N];if(A.currentIdentifier===P&&V.semantic){v+=x(V),D=!0;break}}D||(v+=B(A,i,E))}else v+=A.currentString}for(;!T.isEnd()&&T.getNextToken();){T.currentToken===f.IDENTIFIER?g+=B(T,i,E):g+=T.currentString}var G={vertex:l.vertexShader+t,fragment:l.fragmentShader+t},k={attributes:L,uniforms:O,samplers:M,needAlphaBlending:d&&d.enable&&-1!==d.enable.indexOf(3042)};h.Effect.ShadersStore[l.vertexShader+t+"VertexShader"]=v,h.Effect.ShadersStore[l.fragmentShader+t+"PixelShader"]=g;var U=new h.ShaderMaterial(t,e.scene,G,k);if(U.onError=function(e,t,n){return function(r,o){t.dispose(!0),n("Cannot compile program named "+e.name+". Error: "+o+". Default material will be applied")}}(l,U,r),U.onCompiled=F(e,U,i,o,E,n),U.sideOrientation=h.Material.CounterClockWiseSideOrientation,d&&d.functions){var H=d.functions;H.cullFace&&H.cullFace[0]!==c.BACK&&(U.backFaceCulling=!1);var K=H.blendFuncSeparate;K&&(K[0]===u.SRC_ALPHA&&K[1]===u.ONE_MINUS_SRC_ALPHA&&K[2]===u.ONE&&K[3]===u.ONE?U.alphaMode=h.Constants.ALPHA_COMBINE:K[0]===u.ONE&&K[1]===u.ONE&&K[2]===u.ZERO&&K[3]===u.ONE?U.alphaMode=h.Constants.ALPHA_ONEONE:K[0]===u.SRC_ALPHA&&K[1]===u.ONE&&K[2]===u.ZERO&&K[3]===u.ONE?U.alphaMode=h.Constants.ALPHA_ADD:K[0]===u.ZERO&&K[1]===u.ONE_MINUS_SRC_COLOR&&K[2]===u.ONE&&K[3]===u.ONE?U.alphaMode=h.Constants.ALPHA_SUBTRACT:K[0]===u.DST_COLOR&&K[1]===u.ZERO&&K[2]===u.ONE&&K[3]===u.ONE?U.alphaMode=h.Constants.ALPHA_MULTIPLY:K[0]===u.SRC_ALPHA&&K[1]===u.ONE_MINUS_SRC_COLOR&&K[2]===u.ONE&&K[3]===u.ONE&&(U.alphaMode=h.Constants.ALPHA_MAXIMIZED))}}else r&&r("No technique found.")},e}(),G=function(){function e(){}return e.RegisterExtension=function(t){e.Extensions[t.name]?h.Tools.Error('Tool with the same name "'+t.name+'" already exists'):e.Extensions[t.name]=t},e.prototype.dispose=function(){},e.prototype._importMeshAsync=function(e,t,n,r,o,a,i,s){var l=this;return t.useRightHandedSystem=!0,k.LoadRuntimeAsync(t,n,r,(function(t){t.assetContainer=o,t.importOnlyMeshes=!0,""===e?t.importMeshesNames=[]:"string"==typeof e?t.importMeshesNames=[e]:!e||e instanceof Array?(t.importMeshesNames=[],h.Tools.Warn("Argument meshesNames must be of type string or string[]")):t.importMeshesNames=[e],l._createNodes(t);var n=new Array,r=new Array;for(var s in t.nodes){var c=t.nodes[s];c.babylonNode instanceof h.AbstractMesh&&n.push(c.babylonNode)}for(var u in t.skins){var d=t.skins[u];d.babylonSkeleton instanceof h.Skeleton&&r.push(d.babylonSkeleton)}l._loadBuffersAsync(t,(function(){l._loadShadersAsync(t,(function(){D(t),I(t),!_.GLTFFileLoader.IncrementalLoading&&a&&a(n,r)}))}),i),_.GLTFFileLoader.IncrementalLoading&&a&&a(n,r)}),s),!0},e.prototype.importMeshAsync=function(e,t,n,r,o,a){var i=this;return new Promise((function(s,l){i._importMeshAsync(e,t,r,o,n,(function(e,t){s({meshes:e,particleSystems:[],skeletons:t,animationGroups:[],lights:[],transformNodes:[],geometries:[]})}),a,(function(e){l(new Error(e))}))}))},e.prototype._loadAsync=function(e,t,n,r,o,a){var i=this;e.useRightHandedSystem=!0,k.LoadRuntimeAsync(e,t,n,(function(e){k.LoadRuntimeExtensionsAsync(e,(function(){i._createNodes(e),i._loadBuffersAsync(e,(function(){i._loadShadersAsync(e,(function(){D(e),I(e),_.GLTFFileLoader.IncrementalLoading||r()}))})),_.GLTFFileLoader.IncrementalLoading&&r()}),a)}),a)},e.prototype.loadAsync=function(e,t,n,r){var o=this;return new Promise((function(a,i){o._loadAsync(e,t,n,(function(){a()}),r,(function(e){i(new Error(e))}))}))},e.prototype._loadShadersAsync=function(e,t){var n=!1,r=function(n,r){k.LoadShaderStringAsync(e,n,(function(a){a instanceof ArrayBuffer||(e.loadedShaderCount++,a&&(h.Effect.ShadersStore[n+(r.type===o.VERTEX?"VertexShader":"PixelShader")]=a),e.loadedShaderCount===e.shaderscount&&t())}),(function(){h.Tools.Error("Error when loading shader program named "+n+" located at "+r.uri)}))};for(var a in e.shaders){n=!0;var i=e.shaders[a];i?r.bind(this,a,i)():h.Tools.Error("No shader named: "+a)}n||t()},e.prototype._loadBuffersAsync=function(e,t,n){var r=!1,o=function(n,r){k.LoadBufferAsync(e,n,(function(o){e.loadedBufferCount++,o&&(o.byteLength!=e.buffers[n].byteLength&&h.Tools.Error("Buffer named "+n+" is length "+o.byteLength+". Expected: "+r.byteLength),e.loadedBufferViews[n]=o),e.loadedBufferCount===e.buffersCount&&t()}),(function(){h.Tools.Error("Error when loading buffer named "+n+" located at "+r.uri)}))};for(var a in e.buffers){r=!0;var i=e.buffers[a];i?o.bind(this,a,i)():h.Tools.Error("No buffer named: "+a)}r||t()},e.prototype._createNodes=function(e){var t=e.currentScene;if(t)for(var n=0;n<t.nodes.length;n++)N(e,t.nodes[n],null);else for(var r in e.scenes){t=e.scenes[r];for(n=0;n<t.nodes.length;n++)N(e,t.nodes[n],null)}},e.Extensions={},e}(),k=function(){function e(e){this._name=e}return Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),e.prototype.loadRuntimeAsync=function(e,t,n,r,o){return!1},e.prototype.loadRuntimeExtensionsAsync=function(e,t,n){return!1},e.prototype.loadBufferAsync=function(e,t,n,r,o){return!1},e.prototype.loadTextureBufferAsync=function(e,t,n,r){return!1},e.prototype.createTextureAsync=function(e,t,n,r,o){return!1},e.prototype.loadShaderStringAsync=function(e,t,n,r){return!1},e.prototype.loadMaterialAsync=function(e,t,n,r){return!1},e.LoadRuntimeAsync=function(t,n,r,o,a){e.ApplyExtensions((function(e){return e.loadRuntimeAsync(t,n,r,o,a)}),(function(){setTimeout((function(){o&&o(V.CreateRuntime(n.json,t,r))}))}))},e.LoadRuntimeExtensionsAsync=function(t,n,r){e.ApplyExtensions((function(e){return e.loadRuntimeExtensionsAsync(t,n,r)}),(function(){setTimeout((function(){n()}))}))},e.LoadBufferAsync=function(t,n,r,o,a){e.ApplyExtensions((function(e){return e.loadBufferAsync(t,n,r,o,a)}),(function(){V.LoadBufferAsync(t,n,r,o,a)}))},e.LoadTextureAsync=function(t,n,r,o){e.LoadTextureBufferAsync(t,n,(function(a){a&&e.CreateTextureAsync(t,n,a,r,o)}),o)},e.LoadShaderStringAsync=function(t,n,r,o){e.ApplyExtensions((function(e){return e.loadShaderStringAsync(t,n,r,o)}),(function(){V.LoadShaderStringAsync(t,n,r,o)}))},e.LoadMaterialAsync=function(t,n,r,o){e.ApplyExtensions((function(e){return e.loadMaterialAsync(t,n,r,o)}),(function(){V.LoadMaterialAsync(t,n,r,o)}))},e.LoadTextureBufferAsync=function(t,n,r,o){e.ApplyExtensions((function(e){return e.loadTextureBufferAsync(t,n,r,o)}),(function(){V.LoadTextureBufferAsync(t,n,r,o)}))},e.CreateTextureAsync=function(t,n,r,o,a){e.ApplyExtensions((function(e){return e.createTextureAsync(t,n,r,o,a)}),(function(){V.CreateTextureAsync(t,n,r,o,a)}))},e.ApplyExtensions=function(e,t){for(var n in G.Extensions){if(e(G.Extensions[n]))return}t()},e}();_.GLTFFileLoader._CreateGLTF1Loader=function(){return new G};var U=function(e){function t(){return e.call(this,"KHR_binary_glTF")||this}return Object(d.b)(t,e),t.prototype.loadRuntimeAsync=function(e,t,n,r,o){var a=t.json.extensionsUsed;return!(!a||-1===a.indexOf(this.name)||!t.bin)&&(this._bin=t.bin,r(V.CreateRuntime(t.json,e,n)),!0)},t.prototype.loadBufferAsync=function(e,t,n,r){return-1!==e.extensionsUsed.indexOf(this.name)&&("binary_glTF"===t&&(this._bin.readAsync(0,this._bin.byteLength).then(n,(function(e){return r(e.message)})),!0))},t.prototype.loadTextureBufferAsync=function(e,t,n,o){var a=e.textures[t],i=e.images[a.source];if(!i.extensions||!(this.name in i.extensions))return!1;var s=i.extensions[this.name],l=e.bufferViews[s.bufferView];return n(p.GetBufferFromBufferView(e,l,0,l.byteLength,r.UNSIGNED_BYTE)),!0},t.prototype.loadShaderStringAsync=function(e,t,n,o){var a=e.shaders[t];if(!a.extensions||!(this.name in a.extensions))return!1;var i=a.extensions[this.name],s=e.bufferViews[i.bufferView],l=p.GetBufferFromBufferView(e,s,0,s.byteLength,r.UNSIGNED_BYTE);return setTimeout((function(){var e=p.DecodeBufferToText(l);n(e)})),!0},t}(k);G.RegisterExtension(new U);var H=function(e){function t(){return e.call(this,"KHR_materials_common")||this}return Object(d.b)(t,e),t.prototype.loadRuntimeExtensionsAsync=function(e,t,n){if(!e.extensions)return!1;var r=e.extensions[this.name];if(!r)return!1;var o=r.lights;if(o)for(var a in o){var i=o[a];switch(i.type){case"ambient":var s=new h.HemisphericLight(i.name,new h.Vector3(0,1,0),e.scene),l=i.ambient;l&&(s.diffuse=h.Color3.FromArray(l.color||[1,1,1]));break;case"point":var c=new h.PointLight(i.name,new h.Vector3(10,10,10),e.scene),u=i.point;u&&(c.diffuse=h.Color3.FromArray(u.color||[1,1,1]));break;case"directional":var d=new h.DirectionalLight(i.name,new h.Vector3(0,-1,0),e.scene),f=i.directional;f&&(d.diffuse=h.Color3.FromArray(f.color||[1,1,1]));break;case"spot":var p=i.spot;if(p)new h.SpotLight(i.name,new h.Vector3(0,10,0),new h.Vector3(0,-1,0),p.fallOffAngle||Math.PI,p.fallOffExponent||0,e.scene).diffuse=h.Color3.FromArray(p.color||[1,1,1]);break;default:h.Tools.Warn('GLTF Material Common extension: light type "'+i.type+"” not supported")}}return!1},t.prototype.loadMaterialAsync=function(e,t,n,r){var o=e.materials[t];if(!o||!o.extensions)return!1;var a=o.extensions[this.name];if(!a)return!1;var i=new h.StandardMaterial(t,e.scene);return i.sideOrientation=h.Material.CounterClockWiseSideOrientation,"CONSTANT"===a.technique&&(i.disableLighting=!0),i.backFaceCulling=void 0!==a.doubleSided&&!a.doubleSided,i.alpha=void 0===a.values.transparency?1:a.values.transparency,i.specularPower=void 0===a.values.shininess?0:a.values.shininess,"string"==typeof a.values.ambient?this._loadTexture(e,a.values.ambient,i,"ambientTexture",r):i.ambientColor=h.Color3.FromArray(a.values.ambient||[0,0,0]),"string"==typeof a.values.diffuse?this._loadTexture(e,a.values.diffuse,i,"diffuseTexture",r):i.diffuseColor=h.Color3.FromArray(a.values.diffuse||[0,0,0]),"string"==typeof a.values.emission?this._loadTexture(e,a.values.emission,i,"emissiveTexture",r):i.emissiveColor=h.Color3.FromArray(a.values.emission||[0,0,0]),"string"==typeof a.values.specular?this._loadTexture(e,a.values.specular,i,"specularTexture",r):i.specularColor=h.Color3.FromArray(a.values.specular||[0,0,0]),!0},t.prototype._loadTexture=function(e,t,n,r,o){V.LoadTextureBufferAsync(e,t,(function(a){V.CreateTextureAsync(e,t,a,(function(e){return n[r]=e}),o)}),o)},t}(k);G.RegisterExtension(new H)},function(e,t,n){"use strict";n.r(t),n.d(t,"ArrayItem",(function(){return r.a})),n.d(t,"GLTFLoader",(function(){return r.b})),n.d(t,"EXT_lights_image_based",(function(){return o.EXT_lights_image_based})),n.d(t,"EXT_mesh_gpu_instancing",(function(){return o.EXT_mesh_gpu_instancing})),n.d(t,"EXT_meshopt_compression",(function(){return o.EXT_meshopt_compression})),n.d(t,"EXT_texture_webp",(function(){return o.EXT_texture_webp})),n.d(t,"KHR_draco_mesh_compression",(function(){return o.KHR_draco_mesh_compression})),n.d(t,"KHR_lights",(function(){return o.KHR_lights})),n.d(t,"KHR_materials_pbrSpecularGlossiness",(function(){return o.KHR_materials_pbrSpecularGlossiness})),n.d(t,"KHR_materials_unlit",(function(){return o.KHR_materials_unlit})),n.d(t,"KHR_materials_clearcoat",(function(){return o.KHR_materials_clearcoat})),n.d(t,"KHR_materials_emissive_strength",(function(){return o.KHR_materials_emissive_strength})),n.d(t,"KHR_materials_sheen",(function(){return o.KHR_materials_sheen})),n.d(t,"KHR_materials_specular",(function(){return o.KHR_materials_specular})),n.d(t,"KHR_materials_ior",(function(){return o.KHR_materials_ior})),n.d(t,"KHR_materials_variants",(function(){return o.KHR_materials_variants})),n.d(t,"KHR_materials_transmission",(function(){return o.KHR_materials_transmission})),n.d(t,"KHR_materials_translucency",(function(){return o.KHR_materials_translucency})),n.d(t,"KHR_materials_volume",(function(){return o.KHR_materials_volume})),n.d(t,"KHR_mesh_quantization",(function(){return o.KHR_mesh_quantization})),n.d(t,"KHR_texture_basisu",(function(){return o.KHR_texture_basisu})),n.d(t,"KHR_texture_transform",(function(){return o.KHR_texture_transform})),n.d(t,"KHR_xmp_json_ld",(function(){return o.KHR_xmp_json_ld})),n.d(t,"MSFT_audio_emitter",(function(){return o.MSFT_audio_emitter})),n.d(t,"MSFT_lod",(function(){return o.MSFT_lod})),n.d(t,"MSFT_minecraftMesh",(function(){return o.MSFT_minecraftMesh})),n.d(t,"MSFT_sRGBFactors",(function(){return o.MSFT_sRGBFactors})),n.d(t,"ExtrasAsMetadata",(function(){return o.ExtrasAsMetadata}));var r=n(1),o=(n(6),n(7))},,,function(e,t,n){"use strict";(function(e){var r=n(2),o=n(3);n.d(t,"a",(function(){return r.GLTFFileLoader})),n.d(t,"b",(function(){return r.GLTFLoaderAnimationStartMode})),n.d(t,"c",(function(){return r.GLTFLoaderCoordinateSystemMode})),n.d(t,"d",(function(){return r.GLTFLoaderState})),n.d(t,"e",(function(){return o.GLTFValidation}));var a=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==a){for(var i in a.BABYLON=a.BABYLON||{},r)a.BABYLON[i]=r[i];for(var i in o)a.BABYLON[i]=o[i]}}).call(this,n(5))},function(e,t,n){"use strict";(function(e){var r=n(8);n.d(t,"a",(function(){return r}));var o=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==o)for(var a in o.BABYLON=o.BABYLON||{},o.BABYLON.GLTF1=o.BABYLON.GLTF1||{},r)o.BABYLON.GLTF1[a]=r[a]}).call(this,n(5))},function(e,t,n){"use strict";(function(e){var r=n(7),o=n(6),a=n(9);n.d(t,"a",(function(){return a}));var i=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==i){i.BABYLON=i.BABYLON||{};var s=i.BABYLON;s.GLTF2=s.GLTF2||{},s.GLTF2.Loader=s.GLTF2.Loader||{},s.GLTF2.Loader.Extensions=s.GLTF2.Loader.Extensions||{};var l=[];for(var c in r)s.GLTF2.Loader.Extensions[c]=r[c],l.push(c);for(var c in o)s.GLTF2.Loader[c]=o[c],l.push(c);for(var c in a)l.indexOf(c)>-1||(s.GLTF2[c]=a[c])}}).call(this,n(5))},,,,,function(e,t,n){"use strict";n.r(t);var r=n(12);n.d(t,"GLTFLoaderCoordinateSystemMode",(function(){return r.c})),n.d(t,"GLTFLoaderAnimationStartMode",(function(){return r.b})),n.d(t,"GLTFLoaderState",(function(){return r.d})),n.d(t,"GLTFFileLoader",(function(){return r.a})),n.d(t,"GLTFValidation",(function(){return r.e}));var o=n(13);n.d(t,"GLTF1",(function(){return o.a}));var a=n(14);n.d(t,"GLTF2",(function(){return a.a}))}])}));