!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(e+": Failed to find index ("+n+")");return t[n]},e.Assign=function(e){if(e)for(var t=0;t "+o.GLTFLoaderState[o.GLTFLoaderState.READY],s=o.GLTFLoaderState[o.GLTFLoaderState.LOADING]+" => "+o.GLTFLoaderState[o.GLTFLoaderState.COMPLETE];n._parent._startPerformanceCounter(i),n._parent._startPerformanceCounter(s),n._setState(o.GLTFLoaderState.LOADING),n._extensionsOnLoading();var l=new Array,u=n._babylonScene.blockMaterialDirtyMechanism;if(n._babylonScene.blockMaterialDirtyMechanism=!0,e)l.push(n.loadSceneAsync("/nodes",{nodes:e,index:-1}));else if(null!=n._gltf.scene||n._gltf.scenes&&n._gltf.scenes[0]){var c=a.Get("/scene",n._gltf.scenes,n._gltf.scene||0);l.push(n.loadSceneAsync("/scenes/"+c.index,c))}if(n.parent.loadAllMaterials&&n._gltf.materials)for(var d=0;de.bin.byteLength)&&r.Logger.Warn("Binary buffer length ("+n.byteLength+") from JSON does not match chunk length ("+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=2)throw new Error(t+"/texCoord: Invalid value ("+n.texCoord+")");var s=a.Get(t+"/index",this._gltf.textures,n.index),l=this._loadTextureAsync("/textures/"+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(t+" "+(n.name||""));var i=null==n.sampler?e.DefaultSampler:a.Get(t+"/sampler",this._gltf.samplers,n.sampler),s=a.Get(t+"/source",this._gltf.images,n.source),l=this._createTextureAsync(t,i,s,r);return this.logClose(),l},e.prototype._createTextureAsync=function(e,t,n,o){var a=this;void 0===o&&(o=function(){});var i=this._loadSampler("/samplers/"+t.index,t),s=new Array,l=new r.Deferred;this._babylonScene._blockEntityCollection=this._forAssetContainer;var u=new r.Texture(null,this._babylonScene,i.noMipMaps,!1,i.samplingMode,(function(){a._disposed||l.resolve()}),(function(t,n){a._disposed||l.reject(new Error(e+": "+(n&&n.message?n.message:t||"Failed to load texture")))}),void 0,void 0,void 0,n.mimeType);return this._babylonScene._blockEntityCollection=!1,s.push(l.promise),s.push(this.loadImageAsync("/images/"+n.index,n).then((function(e){var t=n.uri||a._fileName+"#image"+n.index,r="data:"+a._uniqueRootUrl+t;u.updateURL(r,e)}))),u.wrapU=i.wrapU,u.wrapV=i.wrapV,o(u),Promise.all(s).then((function(){return u}))},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(t+"/wrapS",n.wrapS),wrapV:e._GetTextureWrapMode(t+"/wrapT",n.wrapT)}),n._data},e.prototype.loadImageAsync=function(e,t){if(!t._data){if(this.logOpen(e+" "+(t.name||"")),t.uri)t._data=this.loadUriAsync(e+"/uri",t,t.uri);else{var n=a.Get(e+"/bufferView",this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync("/bufferViews/"+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(t+": '"+o+"' is invalid");if(r.Tools.IsBase64(o)){var s=new Uint8Array(r.Tools.DecodeBase64(o));return this.log("Decoded "+o.substr(0,64)+"... ("+s.length+" bytes)"),Promise.resolve(s)}return this.log("Loading "+o),this._parent.preprocessUrlAsync(this._rootUrl+o).then((function(e){return new Promise((function(n,i){a._parent._loadFile(e,a._babylonScene,(function(e){a._disposed||(a.log("Loaded "+o+" ("+e.byteLength+" bytes)"),n(new Uint8Array(e)))}),!0,(function(e){i(new r.LoadFileError(t+": Failed to load '"+o+"'"+(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(e+": Invalid value ("+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(e+"/minFilter: Invalid value ("+o+")"),r.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(9728!==n&&r.Logger.Warn(e+"/magFilter: Invalid value ("+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(e+"/minFilter: Invalid value ("+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(e+": Invalid component type "+t)}},e._GetTypedArray=function(t,n,r,o,a){var i=r.buffer;o=r.byteOffset+(o||0);var s=e._GetTypedArrayConstructor(t+"/componentType",n);try{return new s(i,o,a)}catch(e){throw new Error(t+": "+e)}},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(e+": Invalid type ("+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(e+": Invalid mesh primitive mode ("+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-1&&s.materials.splice(t,1),(t=l.indexOf(e))>-1&&l.splice(t,1)}))}));var u=[];a.onTextureLoadedObservable.add((function(e){u.push(e),e.onDisposeObservable.addOnce((function(){var t=s.textures.indexOf(e);t>-1&&s.textures.splice(t,1),(t=u.indexOf(e))>-1&&u.splice(t,1)}))}));var c=[];return a.onCameraLoadedObservable.add((function(e){c.push(e)})),a._loader.importMeshAsync(null,e,!0,t,n,r,o).then((function(e){return 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,u),Array.prototype.push.apply(s.lights,e.lights),Array.prototype.push.apply(s.transformNodes,e.transformNodes),Array.prototype.push.apply(s.cameras,c),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: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,"application/octet-stream;base64,"+e.magicBase64Encoded)||i.StringTools.StartsWith(n,"model/gltf-binary;base64,"+e.magicBase64Encoded)){var r=i.Tools.DecodeBase64(n);return this._validate(t,r),this._unpackBinaryAsync(new i.DataReader({readAsync:function(e,t){return Promise.resolve(new Uint8Array(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._loader?this._loader.state:null},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._loadFile=function(e,t,n,r,o){var a=this,i=t._loadFile(e,n,(function(e){a._onProgress(e,i)}),void 0,r,o);return i.onCompleteObservable.add((function(e){a._requests.splice(a._requests.indexOf(e),1)})),this._requests.push(i),i},e.prototype._requestFile=function(e,t,n,r,o,a){var i=this,s=t._requestFile(e,n,(function(e){i._onProgress(e,s)}),void 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;a0)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: "+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: "+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: "+a+" != "+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: "+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.majort.minor?1:e.minor=0&&l.renderTargetTextures.splice(a,1)}if(this._opaqueRenderTarget&&(t=this._scene.customRenderTargets.indexOf(this._opaqueRenderTarget),this._opaqueRenderTarget.dispose()),this._opaqueRenderTarget=new r.RenderTargetTexture("opaqueSceneTexture",this._options.renderSize,this._scene,!0),this._opaqueRenderTarget.renderList=this._opaqueMeshesCache,this._opaqueRenderTarget.gammaSpace=!0,this._opaqueRenderTarget.lodGenerationScale=1,this._opaqueRenderTarget.lodGenerationOffset=-4,t>=0?this._scene.customRenderTargets.splice(t,0,this._opaqueRenderTarget):(t=this._scene.customRenderTargets.length,this._scene.customRenderTargets.push(this._opaqueRenderTarget)),this._scene.layers&&this._opaqueRenderTarget)for(var i=0,s=this._scene.layers;i=0;i--)if(a.push(o.a.Get(e+"/ids/"+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();o0){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 R(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 u})),n.d(t,"EBlendingFunction",(function(){return c})),n.d(t,"GLTFUtils",(function(){return p})),n.d(t,"GLTFMaterialsCommonExtension",(function(){return H}));var r,o,a,i,s,l,u,c,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"}(u||(u={})),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"}(c||(c={}));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=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;t0&&(d=O(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;s1?(a=new h.MultiMaterial("multimat"+r,e.scene)).subMaterials=i:a=new h.StandardMaterial("multimat"+r,e.scene),1===i.length&&(a=i[0]),o.material||(o.material=a),new h.Geometry(r,e.scene,s,!1,o),o.computeWorldMatrix(!0),e.scene._blockEntityCollection=!1,o.subMeshes=[];var C=0;for(f=0;f0&&-1===e.importMeshesNames.indexOf(t.name||""))return null;if(t.skin){if(t.meshes){var a=e.skins[t.skin];(i=w(e,t,t.meshes,n,t.babylonNode)).skeleton=e.scene.getLastSkeletonByID(t.skin),null===i.skeleton&&(i.skeleton=R(e,a,0,a.babylonSkeleton,t.skin),a.babylonSkeleton||(a.babylonSkeleton=i.skeleton)),o=i}}else if(t.meshes){var i;o=i=w(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.forAssetContainer,"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(e.scene.getEngine().getInputElement()),o=l}else if("perspective"===s.type){var u=s[s.type],c=new h.FreeCamera(t.camera,h.Vector3.Zero(),e.scene,!1);c.name=t.name||"",c.attachControl(e.scene.getEngine().getInputElement()),u.aspectRatio||(u.aspectRatio=e.scene.getEngine().getRenderWidth()/e.scene.getEngine().getRenderHeight()),u.znear&&u.zfar&&(c.maxZ=u.zfar,c.minZ=u.znear),o=c}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.forAssetContainer;var A=new h.Mesh(t.name||"",e.scene);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),C(e,r,o,a)}else t.translation&&t.rotation&&t.scale&&C(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];C(o,h.Vector3.FromArray(T),h.Quaternion.FromArray(x),h.Vector3.FromArray(E))}o.updateCache(!0),t.babylonNode=o}return o},P=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=N(e,o,t))&&(a.id=t,a.parent=n),o.children)for(var i=0;i-1||(s.GLTF2[u]=a[u])}}).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}))}])}));