babylon.glTF1FileLoader.min.js 48 KB

12345678910111213141516
  1. !function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-loaders",["babylonjs"],n):"object"==typeof exports?exports["babylonjs-loaders"]=n(require("babylonjs")):e.LOADERS=n(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,function(e){return function(e){var n={};function r(t){if(n[t])return n[t].exports;var o=n[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=n,r.d=function(e,n,t){r.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:t})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,n){if(1&n&&(e=r(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(r.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)r.d(t,o,function(n){return e[n]}.bind(null,o));return t},r.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(n,"a",n),n},r.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},r.p="",r(r.s=15)}([function(n,r){n.exports=e},,function(e,n,r){"use strict";r.r(n),r.d(n,"GLTFLoaderCoordinateSystemMode",function(){return t}),r.d(n,"GLTFLoaderAnimationStartMode",function(){return o}),r.d(n,"GLTFLoaderState",function(){return i}),r.d(n,"GLTFFileLoader",function(){return s});var t,o,i,a=r(0);!function(e){e[e.AUTO=0]="AUTO",e[e.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED"}(t||(t={})),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"}(i||(i={}));var s=function(){function e(){this.onParsedObservable=new a.Observable,this.coordinateSystemMode=t.AUTO,this.animationStartMode=o.FIRST,this.compileMaterials=!1,this.useClipPlane=!1,this.compileShadowGenerators=!1,this.transparencyAsCoverage=!1,this.preprocessUrlAsync=function(e){return Promise.resolve(e)},this.onMeshLoadedObservable=new a.Observable,this.onTextureLoadedObservable=new a.Observable,this.onMaterialLoadedObservable=new a.Observable,this.onCameraLoadedObservable=new a.Observable,this.onCompleteObservable=new a.Observable,this.onErrorObservable=new a.Observable,this.onDisposeObservable=new a.Observable,this.onExtensionLoadedObservable=new a.Observable,this.validate=!1,this.onValidatedObservable=new a.Observable,this._loader=null,this.name="gltf",this.extensions={".gltf":{isBinary:!1},".glb":{isBinary:!0}},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:!0,configurable:!0}),Object.defineProperty(e.prototype,"onMeshLoaded",{set:function(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onTextureLoaded",{set:function(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onMaterialLoaded",{set:function(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onCameraLoaded",{set:function(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{set:function(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onError",{set:function(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onExtensionLoaded",{set:function(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)},enumerable:!0,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:!0,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:!0,configurable:!0}),Object.defineProperty(e.prototype,"onValidated",{set:function(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this._loader&&(this._loader.dispose(),this._loader=null),this._clear(),this.onDisposeObservable.notifyObservers(void 0),this.onDisposeObservable.clear()},e.prototype._clear=function(){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()},e.prototype.importMeshAsync=function(e,n,r,t,o,i){var a=this;return this._parseAsync(n,r,t,i).then(function(r){return a._log("Loading "+(i||"")),a._loader=a._getLoader(r),a._loader.importMeshAsync(e,n,r,t,o,i)})},e.prototype.loadAsync=function(e,n,r,t,o){var i=this;return this._parseAsync(e,n,r,o).then(function(n){return i._log("Loading "+(o||"")),i._loader=i._getLoader(n),i._loader.loadAsync(e,n,r,t,o)})},e.prototype.loadAssetContainerAsync=function(e,n,r,t,o){var i=this;return this._parseAsync(e,n,r,o).then(function(n){return i._log("Loading "+(o||"")),i._loader=i._getLoader(n),i._loader.importMeshAsync(null,e,n,r,t,o).then(function(n){var r=new a.AssetContainer(e);return Array.prototype.push.apply(r.meshes,n.meshes),Array.prototype.push.apply(r.particleSystems,n.particleSystems),Array.prototype.push.apply(r.skeletons,n.skeletons),Array.prototype.push.apply(r.animationGroups,n.animationGroups),r.removeAllFromScene(),r})})},e.prototype.canDirectLoad=function(e){return-1!==e.indexOf("scene")&&-1!==e.indexOf("node")},e.prototype.createPlugin=function(){return new e},Object.defineProperty(e.prototype,"loaderState",{get:function(){return this._loader?this._loader.state:null},enumerable:!0,configurable:!0}),e.prototype.whenCompleteAsync=function(){var e=this;return new Promise(function(n,r){e.onCompleteObservable.addOnce(function(){n()}),e.onErrorObservable.addOnce(function(e){r(e)})})},e.prototype._parseAsync=function(e,n,r,t){var o=this;return Promise.resolve().then(function(){var i=n instanceof ArrayBuffer?o._unpackBinary(n):{json:n,bin:null};return o._validateAsync(e,i.json,r,t).then(function(){o._startPerformanceCounter("Parse JSON"),o._log("JSON length: "+i.json.length);var e={json:JSON.parse(i.json),bin:i.bin};return o._endPerformanceCounter("Parse JSON"),o.onParsedObservable.notifyObservers(e),o.onParsedObservable.clear(),e})})},e.prototype._validateAsync=function(e,n,r,t){var o=this;if(!this.validate||"undefined"==typeof GLTFValidator)return Promise.resolve();this._startPerformanceCounter("Validate JSON");var i={externalResourceFunction:function(n){return o.preprocessUrlAsync(r+n).then(function(n){return e._loadFileAsync(n,!0,!0)}).then(function(e){return new Uint8Array(e)})}};return t&&"data:"!==t.substr(0,5)&&(i.uri="file:"===r?t:""+r+t),GLTFValidator.validateString(n,i).then(function(e){o._endPerformanceCounter("Validate JSON"),o.onValidatedObservable.notifyObservers(e),o.onValidatedObservable.clear()},function(e){o._endPerformanceCounter("Validate JSON"),a.Tools.Warn("Failed to validate: "+e),o.onValidatedObservable.clear()})},e.prototype._getLoader=function(n){var r=n.json.asset||{};this._log("Asset version: "+r.version),r.minVersion&&this._log("Asset minimum version: "+r.minVersion),r.generator&&this._log("Asset generator: "+r.generator);var t=e._parseVersion(r.version);if(!t)throw new Error("Invalid version: "+r.version);if(void 0!==r.minVersion){var o=e._parseVersion(r.minVersion);if(!o)throw new Error("Invalid minimum version: "+r.minVersion);if(e._compareVersion(o,{major:2,minor:0})>0)throw new Error("Incompatible minimum version: "+r.minVersion)}var i={1:e._CreateGLTF1Loader,2:e._CreateGLTF2Loader}[t.major];if(!i)throw new Error("Unsupported version: "+r.version);return i(this)},e.prototype._unpackBinary=function(e){this._startPerformanceCounter("Unpack binary"),this._log("Binary length: "+e.byteLength);var n=new u(e),r=n.readUint32();if(1179937895!==r)throw new Error("Unexpected magic: "+r);var t,o=n.readUint32();switch(this.loggingEnabled&&this._log("Binary version: "+o),o){case 1:t=this._unpackBinaryV1(n);break;case 2:t=this._unpackBinaryV2(n);break;default:throw new Error("Unsupported version: "+o)}return this._endPerformanceCounter("Unpack binary"),t},e.prototype._unpackBinaryV1=function(n){var r=n.readUint32();if(r!=n.getLength())throw new Error("Length in header does not match actual data length: "+r+" != "+n.getLength());var t,o=n.readUint32(),i=n.readUint32();switch(i){case 0:t=e._decodeBufferToText(n.readUint8Array(o));break;default:throw new Error("Unexpected content format: "+i)}var a=n.getLength()-n.getPosition();return{json:t,bin:n.readUint8Array(a)}},e.prototype._unpackBinaryV2=function(n){var r=1313821514,t=5130562,o=n.readUint32();if(o!==n.getLength())throw new Error("Length in header does not match actual data length: "+o+" != "+n.getLength());var i=n.readUint32();if(n.readUint32()!==r)throw new Error("First chunk format is not JSON");for(var a=e._decodeBufferToText(n.readUint8Array(i)),s=null;n.getPosition()<n.getLength();){var u=n.readUint32();switch(n.readUint32()){case r:throw new Error("Unexpected JSON chunk");case t:s=n.readUint8Array(u);break;default:n.skipBytes(u)}}return{json:a,bin:s}},e._parseVersion=function(e){if("1.0"===e||"1.0.1"===e)return{major:1,minor:0};var n=(e+"").match(/^(\d+)\.(\d+)/);return n?{major:parseInt(n[1]),minor:parseInt(n[2])}:null},e._compareVersion=function(e,n){return e.major>n.major?1:e.major<n.major?-1:e.minor>n.minor?1:e.minor<n.minor?-1:0},e._decodeBufferToText=function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var n="",r=e.byteLength,t=0;t<r;t++)n+=String.fromCharCode(e[t]);return n},e.prototype._logOpen=function(e){this._log(e),this._logIndentLevel++},e.prototype._logClose=function(){--this._logIndentLevel},e.prototype._logEnabled=function(n){var r=e._logSpaces.substr(0,2*this._logIndentLevel);a.Tools.Log(""+r+n)},e.prototype._logDisabled=function(e){},e.prototype._startPerformanceCounterEnabled=function(e){a.Tools.StartPerformanceCounter(e)},e.prototype._startPerformanceCounterDisabled=function(e){},e.prototype._endPerformanceCounterEnabled=function(e){a.Tools.EndPerformanceCounter(e)},e.prototype._endPerformanceCounterDisabled=function(e){},e.IncrementalLoading=!0,e.HomogeneousCoordinates=!1,e._logSpaces=" ",e}(),u=function(){function e(e){this._arrayBuffer=e,this._dataView=new DataView(e),this._byteOffset=0}return e.prototype.getPosition=function(){return this._byteOffset},e.prototype.getLength=function(){return this._arrayBuffer.byteLength},e.prototype.readUint32=function(){var e=this._dataView.getUint32(this._byteOffset,!0);return this._byteOffset+=4,e},e.prototype.readUint8Array=function(e){var n=new Uint8Array(this._arrayBuffer,this._byteOffset,e);return this._byteOffset+=e,n},e.prototype.skipBytes=function(e){this._byteOffset+=e},e}();a.SceneLoader&&a.SceneLoader.RegisterPlugin(new s)},function(e,n){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},,,function(e,n,r){"use strict";r.r(n);
  2. /*! *****************************************************************************
  3. Copyright (c) Microsoft Corporation. All rights reserved.
  4. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  5. this file except in compliance with the License. You may obtain a copy of the
  6. License at http://www.apache.org/licenses/LICENSE-2.0
  7. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  8. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  9. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  10. MERCHANTABLITY OR NON-INFRINGEMENT.
  11. See the Apache Version 2.0 License for specific language governing permissions
  12. and limitations under the License.
  13. ***************************************************************************** */
  14. var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])})(e,n)};function o(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var i,a,s,u,l,c,f,d;!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"}(i||(i={})),function(e){e[e.FRAGMENT=35632]="FRAGMENT",e[e.VERTEX=35633]="VERTEX"}(a||(a={})),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"}(s||(s={})),function(e){e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.REPEAT=10497]="REPEAT"}(u||(u={})),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"}(l||(l={})),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"}(c||(c={})),function(e){e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK"}(f||(f={})),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"}(d||(d={}));var h,m=r(0),p=function(){function e(){}return e.SetMatrix=function(e,n,r,t,o){var i=null;if("MODEL"===r.semantic?i=n.getWorldMatrix():"PROJECTION"===r.semantic?i=e.getProjectionMatrix():"VIEW"===r.semantic?i=e.getViewMatrix():"MODELVIEWINVERSETRANSPOSE"===r.semantic?i=m.Matrix.Transpose(n.getWorldMatrix().multiply(e.getViewMatrix()).invert()):"MODELVIEW"===r.semantic?i=n.getWorldMatrix().multiply(e.getViewMatrix()):"MODELVIEWPROJECTION"===r.semantic?i=n.getWorldMatrix().multiply(e.getTransformMatrix()):"MODELINVERSE"===r.semantic?i=n.getWorldMatrix().invert():"VIEWINVERSE"===r.semantic?i=e.getViewMatrix().invert():"PROJECTIONINVERSE"===r.semantic?i=e.getProjectionMatrix().invert():"MODELVIEWINVERSE"===r.semantic?i=n.getWorldMatrix().multiply(e.getViewMatrix()).invert():"MODELVIEWPROJECTIONINVERSE"===r.semantic?i=n.getWorldMatrix().multiply(e.getTransformMatrix()).invert():"MODELINVERSETRANSPOSE"===r.semantic&&(i=m.Matrix.Transpose(n.getWorldMatrix().invert())),i)switch(r.type){case s.FLOAT_MAT2:o.setMatrix2x2(t,m.Matrix.GetAsMatrix2x2(i));break;case s.FLOAT_MAT3:o.setMatrix3x3(t,m.Matrix.GetAsMatrix3x3(i));break;case s.FLOAT_MAT4:o.setMatrix(t,i)}},e.SetUniform=function(e,n,r,t){switch(t){case s.FLOAT:return e.setFloat(n,r),!0;case s.FLOAT_VEC2:return e.setVector2(n,m.Vector2.FromArray(r)),!0;case s.FLOAT_VEC3:return e.setVector3(n,m.Vector3.FromArray(r)),!0;case s.FLOAT_VEC4:return e.setVector4(n,m.Vector4.FromArray(r)),!0;default:return!1}},e.GetWrapMode=function(e){switch(e){case u.CLAMP_TO_EDGE:return m.Texture.CLAMP_ADDRESSMODE;case u.MIRRORED_REPEAT:return m.Texture.MIRROR_ADDRESSMODE;case u.REPEAT:default:return m.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 l.LINEAR:case l.LINEAR_MIPMAP_NEAREST:case l.LINEAR_MIPMAP_LINEAR:return m.Texture.TRILINEAR_SAMPLINGMODE;case l.NEAREST:case l.NEAREST_MIPMAP_NEAREST:return m.Texture.NEAREST_SAMPLINGMODE;default:return m.Texture.BILINEAR_SAMPLINGMODE}},e.GetBufferFromBufferView=function(e,n,r,t,o){r=n.byteOffset+r;var a=e.loadedBufferViews[n.buffer];if(r+t>a.byteLength)throw new Error("Buffer access is out of range");var s=a.buffer;switch(r+=a.byteOffset,o){case i.BYTE:return new Int8Array(s,r,t);case i.UNSIGNED_BYTE:return new Uint8Array(s,r,t);case i.SHORT:return new Int16Array(s,r,t);case i.UNSIGNED_SHORT:return new Uint16Array(s,r,t);default:return new Float32Array(s,r,t)}},e.GetBufferFromAccessor=function(n,r){var t=n.bufferViews[r.bufferView],o=r.count*e.GetByteStrideFromType(r);return e.GetBufferFromBufferView(n,t,r.byteOffset,o,r.componentType)},e.DecodeBufferToText=function(e){for(var n="",r=e.byteLength,t=0;t<r;++t)n+=String.fromCharCode(e[t]);return n},e.GetDefaultMaterial=function(n){if(!e._DefaultMaterial){m.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"),m.Effect.ShadersStore.GLTFDefaultMaterialPixelShader=["precision highp float;","","uniform vec4 u_emission;","","void main(void)","{"," gl_FragColor = u_emission;","}"].join("\n");var r={attributes:["position"],uniforms:["worldView","projection","u_emission"],samplers:new Array,needAlphaBlending:!1};e._DefaultMaterial=new m.ShaderMaterial("GLTFDefaultMaterial",n,{vertex:"GLTFDefaultMaterial",fragment:"GLTFDefaultMaterial"},r),e._DefaultMaterial.setColor4("u_emission",new m.Color4(.5,.5,.5,1))}return e._DefaultMaterial},e._DefaultMaterial=null,e}(),A=r(2);!function(e){e[e.IDENTIFIER=1]="IDENTIFIER",e[e.UNKNOWN=2]="UNKNOWN",e[e.END_OF_INPUT=3]="END_OF_INPUT"}(h||(h={}));var v=function(){function e(e){this._pos=0,this.currentToken=h.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 h.END_OF_INPUT;if(this.currentString=this.read(),this.currentToken=h.UNKNOWN,"_"===this.currentString||this.isLetterOrDigitPattern.test(this.currentString))for(this.currentToken=h.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}(),b=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],y=["world","view","projection","worldView","worldViewProjection","mBones"],_=["translation","rotation","scale"],O=["position","rotationQuaternion","scaling"],E=function(e,n,r){for(var t in e){var o=e[t];r[n][t]=o}},g=function(e){if(e)for(var n=0;n<e.length/2;n++)e[2*n+1]=1-e[2*n+1]},T=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 n=Number(e.semantic.split("_")[1]);return"uv"+(0===n?"":n+1)}return null},L=function(e){var n=null;if(e.translation||e.rotation||e.scale){var r=m.Vector3.FromArray(e.scale||[1,1,1]),t=m.Quaternion.FromArray(e.rotation||[0,0,0,1]),o=m.Vector3.FromArray(e.translation||[0,0,0]);n=m.Matrix.Compose(r,t,o)}else n=m.Matrix.FromArray(e.matrix);return n},N=function(e,n,r,t){for(var o=0;o<t.bones.length;o++)if(t.bones[o].name===r)return t.bones[o];var i=e.nodes;for(var a in i){var s=i[a];if(s.jointName){var u=s.children;for(o=0;o<u.length;o++){var l=e.nodes[u[o]];if(l.jointName&&l.jointName===r){var c=L(s),f=new m.Bone(s.name||"",t,N(e,n,s.jointName,t),c);return f.id=a,f}}}}return null},S=function(e,n){for(var r=0;r<e.length;r++)for(var t=e[r],o=0;o<t.node.children.length;o++){if(t.node.children[o]===n)return t.bone}return null},M=function(e,n){var r=e.nodes,t=r[n];if(t)return{node:t,id:n};for(var o in r)if((t=r[o]).jointName===n)return{node:t,id:o};return null},x=function(e,n){for(var r=0;r<e.jointNames.length;r++)if(e.jointNames[r]===n)return!0;return!1},C=function(e,n,r,t,o){if(t||(t=new m.Skeleton(n.name||"","",e.scene)),!n.babylonSkeleton)return t;var i=[],a=[];!function(e,n,r,t){for(var o in e.nodes){var i=e.nodes[o],a=o;if(i.jointName&&!x(r,i.jointName)){var s=L(i),u=new m.Bone(i.name||"",n,null,s);u.id=a,t.push({bone:u,node:i,id:a})}}for(var l=0;l<t.length;l++)for(var c=t[l],f=c.node.children,d=0;d<f.length;d++){for(var h=null,p=0;p<t.length;p++)if(t[p].id===f[d]){h=t[p];break}h&&(h.bone._parent=c.bone,c.bone.children.push(h.bone))}}(e,t,n,i),t.bones=[];for(var s=0;s<n.jointNames.length;s++){if(_=M(e,n.jointNames[s])){var u=_.node;if(u){o=_.id;var l=e.scene.getBoneByID(o);if(l)t.bones.push(l);else{for(var c=!1,f=null,d=0;d<s;d++){var h=M(e,n.jointNames[d]);if(h){var p=h.node;if(p){var A=p.children;if(A){c=!1;for(var v=0;v<A.length;v++)if(A[v]===o){f=N(e,n,n.jointNames[d],t),c=!0;break}if(c)break}}else m.Tools.Warn("Joint named "+n.jointNames[d]+" does not exist when looking for parent")}}var b=L(u);!f&&i.length>0&&(f=S(i,o))&&-1===a.indexOf(f)&&a.push(f),new m.Bone(u.jointName||"",t,f,b).id=o}}else m.Tools.Warn("Joint named "+n.jointNames[s]+" does not exist")}}var y=t.bones;t.bones=[];for(s=0;s<n.jointNames.length;s++){var _;if(_=M(e,n.jointNames[s]))for(d=0;d<y.length;d++)if(y[d].id===_.id){t.bones.push(y[d]);break}}t.prepare();for(s=0;s<a.length;s++)t.bones.push(a[s]);return t},R=function(e,n,r,t,o){if(o||((o=new m.Mesh(n.name||"",e.scene)).id=t),!n.babylonNode)return o;for(var i,a=[],s=null,u=new Array,l=new Array,c=new Array,f=new Array,d=0;d<r.length;d++){var h=r[d];if(I=e.meshes[h])for(var v=0;v<I.primitives.length;v++){var b=new m.VertexData,y=I.primitives[v];y.mode;var _=y.attributes,O=null,E=null;for(var T in _)if(O=e.accessors[_[T]],E=p.GetBufferFromAccessor(e,O),"NORMAL"===T)b.normals=new Float32Array(E.length),b.normals.set(E);else if("POSITION"===T){if(A.GLTFFileLoader.HomogeneousCoordinates){b.positions=new Float32Array(E.length-E.length/4);for(var L=0;L<E.length;L+=4)b.positions[L]=E[L],b.positions[L+1]=E[L+1],b.positions[L+2]=E[L+2]}else b.positions=new Float32Array(E.length),b.positions.set(E);l.push(b.positions.length)}else if(-1!==T.indexOf("TEXCOORD_")){var N=Number(T.split("_")[1]),S=m.VertexBuffer.UVKind+(0===N?"":N+1),M=new Float32Array(E.length);M.set(E),g(M),b.set(M,S)}else"JOINT"===T?(b.matricesIndices=new Float32Array(E.length),b.matricesIndices.set(E)):"WEIGHT"===T?(b.matricesWeights=new Float32Array(E.length),b.matricesWeights.set(E)):"COLOR"===T&&(b.colors=new Float32Array(E.length),b.colors.set(E));if(O=e.accessors[y.indices])E=p.GetBufferFromAccessor(e,O),b.indices=new Int32Array(E.length),b.indices.set(E),f.push(b.indices.length);else{var x=[];for(L=0;L<b.positions.length/3;L++)x.push(L);b.indices=new Int32Array(x),f.push(b.indices.length)}s?s.merge(b):s=b;var C=e.scene.getMaterialByID(y.material);a.push(null===C?p.GetDefaultMaterial(e.scene):C),u.push(0===u.length?0:u[u.length-1]+l[l.length-2]),c.push(0===c.length?0:c[c.length-1]+f[f.length-2])}}a.length>1?(i=new m.MultiMaterial("multimat"+t,e.scene)).subMaterials=a:i=new m.StandardMaterial("multimat"+t,e.scene),1===a.length&&(i=a[0]),o.material||(o.material=i),new m.Geometry(t,e.scene,s,!1,o),o.computeWorldMatrix(!0),o.subMeshes=[];var R=0;for(d=0;d<r.length;d++){var I;h=r[d];if(I=e.meshes[h])for(v=0;v<I.primitives.length;v++)I.primitives[v].mode,m.SubMesh.AddToMesh(R,u[R],l[R],c[R],f[R],o,o,!0),R++}return o},I=function(e,n,r,t){e.position&&(e.position=n),(e.rotationQuaternion||e.rotation)&&(e.rotationQuaternion=r),e.scaling&&(e.scaling=t)},w=function(e,n,r,t){var o=null;if(e.importOnlyMeshes&&(n.skin||n.meshes)&&e.importMeshesNames&&e.importMeshesNames.length>0&&-1===e.importMeshesNames.indexOf(n.name||""))return null;if(n.skin){if(n.meshes){var i=e.skins[n.skin];(a=R(e,n,n.meshes,r,n.babylonNode)).skeleton=e.scene.getLastSkeletonByID(n.skin),null===a.skeleton&&(a.skeleton=C(e,i,0,i.babylonSkeleton,n.skin),i.babylonSkeleton||(i.babylonSkeleton=a.skeleton)),o=a}}else if(n.meshes){var a;o=a=R(e,n,n.mesh?[n.mesh]:n.meshes,r,n.babylonNode)}else if(!n.light||n.babylonNode||e.importOnlyMeshes){if(n.camera&&!n.babylonNode&&!e.importOnlyMeshes){var s=e.cameras[n.camera];if(s)if("orthographic"===s.type){var u=new m.FreeCamera(n.camera,m.Vector3.Zero(),e.scene,!1);u.name=n.name||"",u.mode=m.Camera.ORTHOGRAPHIC_CAMERA,u.attachControl(e.scene.getEngine().getRenderingCanvas()),o=u}else if("perspective"===s.type){var l=s[s.type],c=new m.FreeCamera(n.camera,m.Vector3.Zero(),e.scene,!1);c.name=n.name||"",c.attachControl(e.scene.getEngine().getRenderingCanvas()),l.aspectRatio||(l.aspectRatio=e.scene.getEngine().getRenderWidth()/e.scene.getEngine().getRenderHeight()),l.znear&&l.zfar&&(c.maxZ=l.zfar,c.minZ=l.znear),o=c}}}else{var f=e.lights[n.light];if(f)if("ambient"===f.type){var d=f[f.type],h=new m.HemisphericLight(n.light,m.Vector3.Zero(),e.scene);h.name=n.name||"",d.color&&(h.diffuse=m.Color3.FromArray(d.color)),o=h}else if("directional"===f.type){var p=f[f.type],A=new m.DirectionalLight(n.light,m.Vector3.Zero(),e.scene);A.name=n.name||"",p.color&&(A.diffuse=m.Color3.FromArray(p.color)),o=A}else if("point"===f.type){var v=f[f.type],b=new m.PointLight(n.light,m.Vector3.Zero(),e.scene);b.name=n.name||"",v.color&&(b.diffuse=m.Color3.FromArray(v.color)),o=b}else if("spot"===f.type){var y=f[f.type],_=new m.SpotLight(n.light,m.Vector3.Zero(),m.Vector3.Zero(),0,0,e.scene);_.name=n.name||"",y.color&&(_.diffuse=m.Color3.FromArray(y.color)),y.fallOfAngle&&(_.angle=y.fallOfAngle),y.fallOffExponent&&(_.exponent=y.fallOffExponent),o=_}}if(!n.jointName){if(n.babylonNode)return n.babylonNode;if(null===o){var O=new m.Mesh(n.name||"",e.scene);n.babylonNode=O,o=O}}if(null!==o){if(n.matrix&&o instanceof m.Mesh)!function(e,n,r){if(n.matrix){var t=new m.Vector3(0,0,0),o=new m.Quaternion,i=new m.Vector3(0,0,0);m.Matrix.FromArray(n.matrix).decompose(i,o,t),I(e,t,o,i)}else n.translation&&n.rotation&&n.scale&&I(e,m.Vector3.FromArray(n.translation),m.Quaternion.FromArray(n.rotation),m.Vector3.FromArray(n.scale));e.computeWorldMatrix(!0)}(o,n);else{var E=n.translation||[0,0,0],g=n.rotation||[0,0,0,1],T=n.scale||[1,1,1];I(o,m.Vector3.FromArray(E),m.Quaternion.FromArray(g),m.Vector3.FromArray(T))}o.updateCache(!0),n.babylonNode=o}return o},P=function(e,n,r,t){void 0===t&&(t=!1);var o=e.nodes[n],i=null;if(t=!(e.importOnlyMeshes&&!t&&e.importMeshesNames)||(-1!==e.importMeshesNames.indexOf(o.name||"")||0===e.importMeshesNames.length),!o.jointName&&t&&null!==(i=w(e,o,n))&&(i.id=n,i.parent=r),o.children)for(var a=0;a<o.children.length;a++)P(e,o.children[a],i,t)},F=function(e){var n=e.currentScene;if(n)for(var r=0;r<n.nodes.length;r++)P(e,n.nodes[r],null);else for(var t in e.scenes){n=e.scenes[t];for(r=0;r<n.nodes.length;r++)P(e,n.nodes[r],null)}!function(e){for(var n in e.animations){var r=e.animations[n];if(r.channels&&r.samplers)for(var t=null,o=0;o<r.channels.length;o++){var i=r.channels[o],a=r.samplers[i.sampler];if(a){var s=null,u=null;r.parameters?(s=r.parameters[a.input],u=r.parameters[a.output]):(s=a.input,u=a.output);var l=p.GetBufferFromAccessor(e,e.accessors[s]),c=p.GetBufferFromAccessor(e,e.accessors[u]),f=i.target.id,d=e.scene.getNodeByID(f);if(null===d&&(d=e.scene.getNodeByName(f)),null!==d){var h=d instanceof m.Bone,A=i.target.path,v=_.indexOf(A);-1!==v&&(A=O[v]);var b=m.Animation.ANIMATIONTYPE_MATRIX;h||("rotationQuaternion"===A?(b=m.Animation.ANIMATIONTYPE_QUATERNION,d.rotationQuaternion=new m.Quaternion):b=m.Animation.ANIMATIONTYPE_VECTOR3);var y=null,E=[],g=0,T=!1;h&&t&&t.getKeys().length===l.length&&(y=t,T=!0),T||(y=new m.Animation(n,h?"_matrix":A,1,b,m.Animation.ANIMATIONLOOPMODE_CYCLE));for(var L=0;L<l.length;L++){var N=null;if("rotationQuaternion"===A?(N=m.Quaternion.FromArray([c[g],c[g+1],c[g+2],c[g+3]]),g+=4):(N=m.Vector3.FromArray([c[g],c[g+1],c[g+2]]),g+=3),h){var S=d,M=m.Vector3.Zero(),x=new m.Quaternion,C=m.Vector3.Zero(),R=S.getBaseMatrix();T&&t&&(R=t.getKeys()[L].value),R.decompose(C,x,M),"position"===A?M=N:"rotationQuaternion"===A?x=N:C=N,N=m.Matrix.Compose(C,x,M)}T?t&&(t.getKeys()[L].value=N):E.push({frame:l[L],value:N})}!T&&y&&(y.setKeys(E),d.animations.push(y)),t=y,e.scene.stopAnimation(d),e.scene.beginAnimation(d,0,l[l.length-1],!0,1)}else m.Tools.Warn("Creating animation named "+n+". But cannot find node named "+f+" to attach to")}}}}(e);for(r=0;r<e.scene.skeletons.length;r++){var o=e.scene.skeletons[r];e.scene.beginAnimation(o,0,Number.MAX_VALUE,!0,1)}},B=function(e,n,r,t,o,i){return function(a){!function(e,n,r,t,o){var i=t.values||r.parameters,a=r.uniforms;for(var u in o){var l=o[u],c=l.type,f=i[a[u]];if(void 0===f&&(f=l.value),f){var d=function(e){return function(r){l.value&&e&&(n.setTexture(e,r),delete o[e])}};c===s.SAMPLER_2D?j.LoadTextureAsync(e,t.values?f:l.value,d(u),function(){return d(null)}):l.value&&p.SetUniform(n,u,t.values?f:l.value,c)&&delete o[u]}}}(e,n,r,t,o),n.onBind=function(a){!function(e,n,r,t,o,i,a){var u=i.values||o.parameters;for(var l in r){var c=r[l],f=c.type;if(f===s.FLOAT_MAT2||f===s.FLOAT_MAT3||f===s.FLOAT_MAT4)if(!c.semantic||c.source||c.node){if(c.semantic&&(c.source||c.node)){var d=n.scene.getNodeByName(c.source||c.node||"");if(null===d&&(d=n.scene.getNodeByID(c.source||c.node||"")),null===d)continue;p.SetMatrix(n.scene,d,c,l,t.getEffect())}}else p.SetMatrix(n.scene,e,c,l,t.getEffect());else{var h=u[o.uniforms[l]];if(!h)continue;if(f===s.SAMPLER_2D){var m=n.textures[i.values?h:c.value].babylonTexture;if(null==m)continue;t.getEffect().setTexture(l,m)}else p.SetUniform(t.getEffect(),l,h,f)}}a(t)}(a,e,o,n,r,t,i)}}},V=function(e,n,r){for(var t in n.uniforms){var o=n.uniforms[t],i=n.parameters[o];if(e.currentIdentifier===t&&i.semantic&&!i.source&&!i.node){var a=b.indexOf(i.semantic);if(-1!==a)return delete r[t],y[a]}}return e.currentIdentifier},D=function(e){for(var n in e.materials)j.LoadMaterialAsync(e,n,function(e){},function(){})},U=function(){function e(){}return e.CreateRuntime=function(e,n,r){var t={extensions:{},accessors:{},buffers:{},bufferViews:{},meshes:{},lights:{},cameras:{},nodes:{},images:{},textures:{},shaders:{},programs:{},samplers:{},techniques:{},materials:{},animations:{},skins:{},extensionsUsed:[],scenes:{},buffersCount:0,shaderscount:0,scene:n,rootUrl:r,loadedBufferCount:0,loadedBufferViews:{},loadedShaderCount:0,importOnlyMeshes:!1,dummyNodes:[]};return e.extensions&&E(e.extensions,"extensions",t),e.extensionsUsed&&E(e.extensionsUsed,"extensionsUsed",t),e.buffers&&function(e,n){for(var r in e){var t=e[r];n.buffers[r]=t,n.buffersCount++}}(e.buffers,t),e.bufferViews&&E(e.bufferViews,"bufferViews",t),e.accessors&&E(e.accessors,"accessors",t),e.meshes&&E(e.meshes,"meshes",t),e.lights&&E(e.lights,"lights",t),e.cameras&&E(e.cameras,"cameras",t),e.nodes&&E(e.nodes,"nodes",t),e.images&&E(e.images,"images",t),e.textures&&E(e.textures,"textures",t),e.shaders&&function(e,n){for(var r in e){var t=e[r];n.shaders[r]=t,n.shaderscount++}}(e.shaders,t),e.programs&&E(e.programs,"programs",t),e.samplers&&E(e.samplers,"samplers",t),e.techniques&&E(e.techniques,"techniques",t),e.materials&&E(e.materials,"materials",t),e.animations&&E(e.animations,"animations",t),e.skins&&E(e.skins,"skins",t),e.scenes&&(t.scenes=e.scenes),e.scene&&e.scenes&&(t.currentScene=e.scenes[e.scene]),t},e.LoadBufferAsync=function(e,n,r,t,o){var i=e.buffers[n];m.Tools.IsBase64(i.uri)?setTimeout(function(){return r(new Uint8Array(m.Tools.DecodeBase64(i.uri)))}):m.Tools.LoadFile(e.rootUrl+i.uri,function(e){return r(new Uint8Array(e))},o,void 0,!0,function(e){e&&t(e.status+" "+e.statusText)})},e.LoadTextureBufferAsync=function(e,n,r,t){var o=e.textures[n];if(o&&o.source)if(o.babylonTexture)r(null);else{var i=e.images[o.source];m.Tools.IsBase64(i.uri)?setTimeout(function(){return r(new Uint8Array(m.Tools.DecodeBase64(i.uri)))}):m.Tools.LoadFile(e.rootUrl+i.uri,function(e){return r(new Uint8Array(e))},void 0,void 0,!0,function(e){e&&t(e.status+" "+e.statusText)})}else t("")},e.CreateTextureAsync=function(e,n,r,t,o){var i=e.textures[n];if(i.babylonTexture)t(i.babylonTexture);else{var a=e.samplers[i.sampler],s=a.minFilter===l.NEAREST_MIPMAP_NEAREST||a.minFilter===l.NEAREST_MIPMAP_LINEAR||a.minFilter===l.LINEAR_MIPMAP_NEAREST||a.minFilter===l.LINEAR_MIPMAP_LINEAR,u=m.Texture.BILINEAR_SAMPLINGMODE,c=null==r?new Blob:new Blob([r]),f=URL.createObjectURL(c),d=function(){return URL.revokeObjectURL(f)},h=new m.Texture(f,e.scene,!s,!0,u,d,d);void 0!==a.wrapS&&(h.wrapU=p.GetWrapMode(a.wrapS)),void 0!==a.wrapT&&(h.wrapV=p.GetWrapMode(a.wrapT)),h.name=n,i.babylonTexture=h,t(h)}},e.LoadShaderStringAsync=function(e,n,r,t){var o=e.shaders[n];if(m.Tools.IsBase64(o.uri)){var i=atob(o.uri.split(",")[1]);r&&r(i)}else m.Tools.LoadFile(e.rootUrl+o.uri,r,void 0,void 0,!1,function(e){e&&t&&t(e.status+" "+e.statusText)})},e.LoadMaterialAsync=function(e,n,r,t){var o=e.materials[n];if(o.technique){var i=e.techniques[o.technique];if(!i){var a=new m.StandardMaterial(n,e.scene);return a.diffuseColor=new m.Color3(.5,.5,.5),a.sideOrientation=m.Material.CounterClockWiseSideOrientation,void r(a)}var u=e.programs[i.program],l=i.states,c=m.Effect.ShadersStore[u.vertexShader+"VertexShader"],p=m.Effect.ShadersStore[u.fragmentShader+"PixelShader"],A="",_="",O=new v(c),E=new v(p),g={},L=[],N=[],S=[];for(var M in i.uniforms){var x=i.uniforms[M],C=i.parameters[x];if(g[M]=C,!C.semantic||C.node||C.source)C.type===s.SAMPLER_2D?S.push(M):L.push(M);else{var R=b.indexOf(C.semantic);-1!==R?(L.push(y[R]),delete g[M]):L.push(M)}}for(var I in i.attributes){var w=i.attributes[I];if((D=i.parameters[w]).semantic){var P=T(D);P&&N.push(P)}}for(;!O.isEnd()&&O.getNextToken();){if(O.currentToken===h.IDENTIFIER){var F=!1;for(var I in i.attributes){w=i.attributes[I];var D=i.parameters[w];if(O.currentIdentifier===I&&D.semantic){A+=T(D),F=!0;break}}F||(A+=V(O,i,g))}else A+=O.currentString}for(;!E.isEnd()&&E.getNextToken();){E.currentToken===h.IDENTIFIER?_+=V(E,i,g):_+=E.currentString}var U={vertex:u.vertexShader+n,fragment:u.fragmentShader+n},G={attributes:N,uniforms:L,samplers:S,needAlphaBlending:l&&l.enable&&-1!==l.enable.indexOf(3042)};m.Effect.ShadersStore[u.vertexShader+n+"VertexShader"]=A,m.Effect.ShadersStore[u.fragmentShader+n+"PixelShader"]=_;var j=new m.ShaderMaterial(n,e.scene,U,G);if(j.onError=function(e,n,r){return function(t,o){n.dispose(!0),r("Cannot compile program named "+e.name+". Error: "+o+". Default material will be applied")}}(u,j,t),j.onCompiled=B(e,j,i,o,g,r),j.sideOrientation=m.Material.CounterClockWiseSideOrientation,l&&l.functions){var k=l.functions;k.cullFace&&k.cullFace[0]!==f.BACK&&(j.backFaceCulling=!1);var H=k.blendFuncSeparate;H&&(H[0]===d.SRC_ALPHA&&H[1]===d.ONE_MINUS_SRC_ALPHA&&H[2]===d.ONE&&H[3]===d.ONE?j.alphaMode=m.Engine.ALPHA_COMBINE:H[0]===d.ONE&&H[1]===d.ONE&&H[2]===d.ZERO&&H[3]===d.ONE?j.alphaMode=m.Engine.ALPHA_ONEONE:H[0]===d.SRC_ALPHA&&H[1]===d.ONE&&H[2]===d.ZERO&&H[3]===d.ONE?j.alphaMode=m.Engine.ALPHA_ADD:H[0]===d.ZERO&&H[1]===d.ONE_MINUS_SRC_COLOR&&H[2]===d.ONE&&H[3]===d.ONE?j.alphaMode=m.Engine.ALPHA_SUBTRACT:H[0]===d.DST_COLOR&&H[1]===d.ZERO&&H[2]===d.ONE&&H[3]===d.ONE?j.alphaMode=m.Engine.ALPHA_MULTIPLY:H[0]===d.SRC_ALPHA&&H[1]===d.ONE_MINUS_SRC_COLOR&&H[2]===d.ONE&&H[3]===d.ONE&&(j.alphaMode=m.Engine.ALPHA_MAXIMIZED))}}else t&&t("No technique found.")},e}(),G=function(){function e(){this.state=null}return e.RegisterExtension=function(n){e.Extensions[n.name]?m.Tools.Error('Tool with the same name "'+n.name+'" already exists'):e.Extensions[n.name]=n},e.prototype.dispose=function(){},e.prototype._importMeshAsync=function(e,n,r,t,o,i,a){var s=this;return n.useRightHandedSystem=!0,j.LoadRuntimeAsync(n,r,t,function(n){n.importOnlyMeshes=!0,""===e?n.importMeshesNames=[]:"string"==typeof e?n.importMeshesNames=[e]:!e||e instanceof Array?(n.importMeshesNames=[],m.Tools.Warn("Argument meshesNames must be of type string or string[]")):n.importMeshesNames=[e],s._createNodes(n);var r=new Array,t=new Array;for(var a in n.nodes){var u=n.nodes[a];u.babylonNode instanceof m.AbstractMesh&&r.push(u.babylonNode)}for(var l in n.skins){var c=n.skins[l];c.babylonSkeleton instanceof m.Skeleton&&t.push(c.babylonSkeleton)}s._loadBuffersAsync(n,function(){s._loadShadersAsync(n,function(){D(n),F(n),!A.GLTFFileLoader.IncrementalLoading&&o&&o(r,t)})},i),A.GLTFFileLoader.IncrementalLoading&&o&&o(r,t)},a),!0},e.prototype.importMeshAsync=function(e,n,r,t,o){var i=this;return new Promise(function(a,s){i._importMeshAsync(e,n,r,t,function(e,n){a({meshes:e,particleSystems:[],skeletons:n,animationGroups:[]})},o,function(e){s(new Error(e))})})},e.prototype._loadAsync=function(e,n,r,t,o,i){var a=this;e.useRightHandedSystem=!0,j.LoadRuntimeAsync(e,n,r,function(e){j.LoadRuntimeExtensionsAsync(e,function(){a._createNodes(e),a._loadBuffersAsync(e,function(){a._loadShadersAsync(e,function(){D(e),F(e),A.GLTFFileLoader.IncrementalLoading||t()})}),A.GLTFFileLoader.IncrementalLoading&&t()},i)},i)},e.prototype.loadAsync=function(e,n,r,t){var o=this;return new Promise(function(i,a){o._loadAsync(e,n,r,function(){i()},t,function(e){a(new Error(e))})})},e.prototype._loadShadersAsync=function(e,n){var r=!1,t=function(r,t){j.LoadShaderStringAsync(e,r,function(o){o instanceof ArrayBuffer||(e.loadedShaderCount++,o&&(m.Effect.ShadersStore[r+(t.type===a.VERTEX?"VertexShader":"PixelShader")]=o),e.loadedShaderCount===e.shaderscount&&n())},function(){m.Tools.Error("Error when loading shader program named "+r+" located at "+t.uri)})};for(var o in e.shaders){r=!0;var i=e.shaders[o];i?t.bind(this,o,i)():m.Tools.Error("No shader named: "+o)}r||n()},e.prototype._loadBuffersAsync=function(e,n,r){var t=!1,o=function(r,t){j.LoadBufferAsync(e,r,function(o){e.loadedBufferCount++,o&&(o.byteLength!=e.buffers[r].byteLength&&m.Tools.Error("Buffer named "+r+" is length "+o.byteLength+". Expected: "+t.byteLength),e.loadedBufferViews[r]=o),e.loadedBufferCount===e.buffersCount&&n()},function(){m.Tools.Error("Error when loading buffer named "+r+" located at "+t.uri)})};for(var i in e.buffers){t=!0;var a=e.buffers[i];a?o.bind(this,i,a)():m.Tools.Error("No buffer named: "+i)}t||n()},e.prototype._createNodes=function(e){var n=e.currentScene;if(n)for(var r=0;r<n.nodes.length;r++)P(e,n.nodes[r],null);else for(var t in e.scenes){n=e.scenes[t];for(r=0;r<n.nodes.length;r++)P(e,n.nodes[r],null)}},e.Extensions={},e}(),j=function(){function e(e){this._name=e}return Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),e.prototype.loadRuntimeAsync=function(e,n,r,t,o){return!1},e.prototype.loadRuntimeExtensionsAsync=function(e,n,r){return!1},e.prototype.loadBufferAsync=function(e,n,r,t,o){return!1},e.prototype.loadTextureBufferAsync=function(e,n,r,t){return!1},e.prototype.createTextureAsync=function(e,n,r,t,o){return!1},e.prototype.loadShaderStringAsync=function(e,n,r,t){return!1},e.prototype.loadMaterialAsync=function(e,n,r,t){return!1},e.LoadRuntimeAsync=function(n,r,t,o,i){e.ApplyExtensions(function(e){return e.loadRuntimeAsync(n,r,t,o,i)},function(){setTimeout(function(){o&&o(U.CreateRuntime(r.json,n,t))})})},e.LoadRuntimeExtensionsAsync=function(n,r,t){e.ApplyExtensions(function(e){return e.loadRuntimeExtensionsAsync(n,r,t)},function(){setTimeout(function(){r()})})},e.LoadBufferAsync=function(n,r,t,o,i){e.ApplyExtensions(function(e){return e.loadBufferAsync(n,r,t,o,i)},function(){U.LoadBufferAsync(n,r,t,o,i)})},e.LoadTextureAsync=function(n,r,t,o){e.LoadTextureBufferAsync(n,r,function(i){i&&e.CreateTextureAsync(n,r,i,t,o)},o)},e.LoadShaderStringAsync=function(n,r,t,o){e.ApplyExtensions(function(e){return e.loadShaderStringAsync(n,r,t,o)},function(){U.LoadShaderStringAsync(n,r,t,o)})},e.LoadMaterialAsync=function(n,r,t,o){e.ApplyExtensions(function(e){return e.loadMaterialAsync(n,r,t,o)},function(){U.LoadMaterialAsync(n,r,t,o)})},e.LoadTextureBufferAsync=function(n,r,t,o){e.ApplyExtensions(function(e){return e.loadTextureBufferAsync(n,r,t,o)},function(){U.LoadTextureBufferAsync(n,r,t,o)})},e.CreateTextureAsync=function(n,r,t,o,i){e.ApplyExtensions(function(e){return e.createTextureAsync(n,r,t,o,i)},function(){U.CreateTextureAsync(n,r,t,o,i)})},e.ApplyExtensions=function(e,n){for(var r in G.Extensions){if(e(G.Extensions[r]))return}n()},e}();A.GLTFFileLoader._CreateGLTF1Loader=function(){return new G};var k=function(e){function n(){return e.call(this,"KHR_binary_glTF")||this}return o(n,e),n.prototype.loadRuntimeAsync=function(e,n,r,t,o){var i=n.json.extensionsUsed;return!(!i||-1===i.indexOf(this.name)||!n.bin)&&(this._bin=n.bin,t(U.CreateRuntime(n.json,e,r)),!0)},n.prototype.loadBufferAsync=function(e,n,r,t){return-1!==e.extensionsUsed.indexOf(this.name)&&("binary_glTF"===n&&(r(this._bin),!0))},n.prototype.loadTextureBufferAsync=function(e,n,r,t){var o=e.textures[n],a=e.images[o.source];if(!(a.extensions&&this.name in a.extensions))return!1;var s=a.extensions[this.name],u=e.bufferViews[s.bufferView];return r(p.GetBufferFromBufferView(e,u,0,u.byteLength,i.UNSIGNED_BYTE)),!0},n.prototype.loadShaderStringAsync=function(e,n,r,t){var o=e.shaders[n];if(!(o.extensions&&this.name in o.extensions))return!1;var a=o.extensions[this.name],s=e.bufferViews[a.bufferView],u=p.GetBufferFromBufferView(e,s,0,s.byteLength,i.UNSIGNED_BYTE);return setTimeout(function(){var e=p.DecodeBufferToText(u);r(e)}),!0},n}(j);G.RegisterExtension(new k);var H=function(e){function n(){return e.call(this,"KHR_materials_common")||this}return o(n,e),n.prototype.loadRuntimeExtensionsAsync=function(e,n,r){if(!e.extensions)return!1;var t=e.extensions[this.name];if(!t)return!1;var o=t.lights;if(o)for(var i in o){var a=o[i];switch(a.type){case"ambient":var s=new m.HemisphericLight(a.name,new m.Vector3(0,1,0),e.scene),u=a.ambient;u&&(s.diffuse=m.Color3.FromArray(u.color||[1,1,1]));break;case"point":var l=new m.PointLight(a.name,new m.Vector3(10,10,10),e.scene),c=a.point;c&&(l.diffuse=m.Color3.FromArray(c.color||[1,1,1]));break;case"directional":var f=new m.DirectionalLight(a.name,new m.Vector3(0,-1,0),e.scene),d=a.directional;d&&(f.diffuse=m.Color3.FromArray(d.color||[1,1,1]));break;case"spot":var h=a.spot;if(h)new m.SpotLight(a.name,new m.Vector3(0,10,0),new m.Vector3(0,-1,0),h.fallOffAngle||Math.PI,h.fallOffExponent||0,e.scene).diffuse=m.Color3.FromArray(h.color||[1,1,1]);break;default:m.Tools.Warn('GLTF Material Common extension: light type "'+a.type+"” not supported")}}return!1},n.prototype.loadMaterialAsync=function(e,n,r,t){var o=e.materials[n];if(!o||!o.extensions)return!1;var i=o.extensions[this.name];if(!i)return!1;var a=new m.StandardMaterial(n,e.scene);return a.sideOrientation=m.Material.CounterClockWiseSideOrientation,"CONSTANT"===i.technique&&(a.disableLighting=!0),a.backFaceCulling=void 0!==i.doubleSided&&!i.doubleSided,a.alpha=void 0===i.values.transparency?1:i.values.transparency,a.specularPower=void 0===i.values.shininess?0:i.values.shininess,"string"==typeof i.values.ambient?this._loadTexture(e,i.values.ambient,a,"ambientTexture",t):a.ambientColor=m.Color3.FromArray(i.values.ambient||[0,0,0]),"string"==typeof i.values.diffuse?this._loadTexture(e,i.values.diffuse,a,"diffuseTexture",t):a.diffuseColor=m.Color3.FromArray(i.values.diffuse||[0,0,0]),"string"==typeof i.values.emission?this._loadTexture(e,i.values.emission,a,"emissiveTexture",t):a.emissiveColor=m.Color3.FromArray(i.values.emission||[0,0,0]),"string"==typeof i.values.specular?this._loadTexture(e,i.values.specular,a,"specularTexture",t):a.specularColor=m.Color3.FromArray(i.values.specular||[0,0,0]),!0},n.prototype._loadTexture=function(e,n,r,t,o){U.LoadTextureBufferAsync(e,n,function(i){U.CreateTextureAsync(e,n,i,function(e){return r[t]=e},o)},o)},n}(j);G.RegisterExtension(new H),r.d(n,"GLTFBinaryExtension",function(){return k}),r.d(n,"GLTFLoaderBase",function(){return U}),r.d(n,"GLTFLoader",function(){return G}),r.d(n,"GLTFLoaderExtension",function(){return j}),r.d(n,"EComponentType",function(){return i}),r.d(n,"EShaderType",function(){return a}),r.d(n,"EParameterType",function(){return s}),r.d(n,"ETextureWrapMode",function(){return u}),r.d(n,"ETextureFilterType",function(){return l}),r.d(n,"ETextureFormat",function(){return c}),r.d(n,"ECullingType",function(){return f}),r.d(n,"EBlendingFunction",function(){return d}),r.d(n,"GLTFUtils",function(){return p}),r.d(n,"GLTFMaterialsCommonExtension",function(){return H})},,,function(e,n,r){"use strict";(function(e){var t=r(2);r.d(n,"a",function(){return t.GLTFFileLoader}),r.d(n,"b",function(){return t.GLTFLoaderAnimationStartMode}),r.d(n,"c",function(){return t.GLTFLoaderCoordinateSystemMode}),r.d(n,"d",function(){return t.GLTFLoaderState});var o=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==o)for(var i in o.BABYLON=o.BABYLON||{},t)o.BABYLON[i]=t[i]}).call(this,r(3))},,function(e,n,r){"use strict";(function(e){var t=r(6);r.d(n,"a",function(){return t});var o=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==o)for(var i in o.BABYLON=o.BABYLON||{},o.BABYLON.GLTF1=o.BABYLON.GLTF1||{},t)o.BABYLON.GLTF1[i]=t[i]}).call(this,r(3))},,,,function(e,n,r){"use strict";r.r(n);var t=r(9);r.d(n,"GLTFLoaderCoordinateSystemMode",function(){return t.c}),r.d(n,"GLTFLoaderAnimationStartMode",function(){return t.b}),r.d(n,"GLTFLoaderState",function(){return t.d}),r.d(n,"GLTFFileLoader",function(){return t.a});var o=r(11);r.d(n,"GLTF1",function(){return o.a})}])});