12345678910111213141516 |
- !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-loaders",["babylonjs"],r):"object"==typeof exports?exports["babylonjs-loaders"]=r(require("babylonjs")):e.LOADERS=r(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,function(e){return function(e){var r={};function n(t){if(r[t])return r[t].exports;var o=r[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=r,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},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,r){if(1&r&&(e=n(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(n.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)n.d(t,o,function(r){return e[r]}.bind(null,o));return t},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},n.p="",n(n.s=15)}([function(r,n){r.exports=e},,function(e,r,n){"use strict";n.r(r),n.d(r,"GLTFLoaderCoordinateSystemMode",function(){return t}),n.d(r,"GLTFLoaderAnimationStartMode",function(){return o}),n.d(r,"GLTFLoaderState",function(){return i}),n.d(r,"GLTFFileLoader",function(){return s});var t,o,i,a=n(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,r,n,t,o,i){var a=this;return this._parseAsync(r,n,t,i).then(function(n){return a._log("Loading "+(i||"")),a._loader=a._getLoader(n),a._loader.importMeshAsync(e,r,n,t,o,i)})},e.prototype.loadAsync=function(e,r,n,t,o){var i=this;return this._parseAsync(e,r,n,o).then(function(r){return i._log("Loading "+(o||"")),i._loader=i._getLoader(r),i._loader.loadAsync(e,r,n,t,o)})},e.prototype.loadAssetContainerAsync=function(e,r,n,t,o){var i=this;return this._parseAsync(e,r,n,o).then(function(r){i._log("Loading "+(o||"")),i._loader=i._getLoader(r);var s=[];i.onMaterialLoadedObservable.add(function(e){s.push(e)});var u=[];return i.onTextureLoadedObservable.add(function(e){u.push(e)}),i._loader.importMeshAsync(null,e,r,n,t,o).then(function(r){var n=new a.AssetContainer(e);return Array.prototype.push.apply(n.meshes,r.meshes),Array.prototype.push.apply(n.particleSystems,r.particleSystems),Array.prototype.push.apply(n.skeletons,r.skeletons),Array.prototype.push.apply(n.animationGroups,r.animationGroups),Array.prototype.push.apply(n.materials,s),Array.prototype.push.apply(n.textures,u),n.removeAllFromScene(),n})})},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(r,n){e.onCompleteObservable.addOnce(function(){r()}),e.onErrorObservable.addOnce(function(e){n(e)})})},e.prototype._parseAsync=function(e,r,n,t){var o=this;return Promise.resolve().then(function(){var i=r instanceof ArrayBuffer?o._unpackBinary(r):{json:r,bin:null};return o._validateAsync(e,i.json,n,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,r,n,t){var o=this;if(!this.validate||"undefined"==typeof GLTFValidator)return Promise.resolve();this._startPerformanceCounter("Validate JSON");var i={externalResourceFunction:function(r){return o.preprocessUrlAsync(n+r).then(function(r){return e._loadFileAsync(r,!0,!0)}).then(function(e){return new Uint8Array(e)})}};return t&&"data:"!==t.substr(0,5)&&(i.uri="file:"===n?t:""+n+t),GLTFValidator.validateString(r,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(r){var n=r.json.asset||{};this._log("Asset version: "+n.version),n.minVersion&&this._log("Asset minimum version: "+n.minVersion),n.generator&&this._log("Asset generator: "+n.generator);var t=e._parseVersion(n.version);if(!t)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 i={1:e._CreateGLTF1Loader,2:e._CreateGLTF2Loader}[t.major];if(!i)throw new Error("Unsupported version: "+n.version);return i(this)},e.prototype._unpackBinary=function(e){this._startPerformanceCounter("Unpack binary"),this._log("Binary length: "+e.byteLength);var r=new u(e),n=r.readUint32();if(1179937895!==n)throw new Error("Unexpected magic: "+n);var t,o=r.readUint32();switch(this.loggingEnabled&&this._log("Binary version: "+o),o){case 1:t=this._unpackBinaryV1(r);break;case 2:t=this._unpackBinaryV2(r);break;default:throw new Error("Unsupported version: "+o)}return this._endPerformanceCounter("Unpack binary"),t},e.prototype._unpackBinaryV1=function(r){var n=r.readUint32();if(n!=r.getLength())throw new Error("Length in header does not match actual data length: "+n+" != "+r.getLength());var t,o=r.readUint32(),i=r.readUint32();switch(i){case 0:t=e._decodeBufferToText(r.readUint8Array(o));break;default:throw new Error("Unexpected content format: "+i)}var a=r.getLength()-r.getPosition();return{json:t,bin:r.readUint8Array(a)}},e.prototype._unpackBinaryV2=function(r){var n=1313821514,t=5130562,o=r.readUint32();if(o!==r.getLength())throw new Error("Length in header does not match actual data length: "+o+" != "+r.getLength());var i=r.readUint32();if(r.readUint32()!==n)throw new Error("First chunk format is not JSON");for(var a=e._decodeBufferToText(r.readUint8Array(i)),s=null;r.getPosition()<r.getLength();){var u=r.readUint32();switch(r.readUint32()){case n:throw new Error("Unexpected JSON chunk");case t:s=r.readUint8Array(u);break;default:r.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 r=(e+"").match(/^(\d+)\.(\d+)/);return r?{major:parseInt(r[1]),minor:parseInt(r[2])}:null},e._compareVersion=function(e,r){return e.major>r.major?1:e.major<r.major?-1:e.minor>r.minor?1:e.minor<r.minor?-1:0},e._decodeBufferToText=function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var r="",n=e.byteLength,t=0;t<n;t++)r+=String.fromCharCode(e[t]);return r},e.prototype._logOpen=function(e){this._log(e),this._logIndentLevel++},e.prototype._logClose=function(){--this._logIndentLevel},e.prototype._logEnabled=function(r){var n=e._logSpaces.substr(0,2*this._logIndentLevel);a.Tools.Log(""+n+r)},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 r=new Uint8Array(this._arrayBuffer,this._byteOffset,e);return this._byteOffset+=e,r},e.prototype.skipBytes=function(e){this._byteOffset+=e},e}();a.SceneLoader&&a.SceneLoader.RegisterPlugin(new s)},function(e,r){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,r,n){"use strict";n.r(r);
- /*! *****************************************************************************
- Copyright (c) Microsoft Corporation. All rights reserved.
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
- this file except in compliance with the License. You may obtain a copy of the
- License at http://www.apache.org/licenses/LICENSE-2.0
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
- MERCHANTABLITY OR NON-INFRINGEMENT.
- See the Apache Version 2.0 License for specific language governing permissions
- and limitations under the License.
- ***************************************************************************** */
- var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])})(e,r)};function o(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}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=n(0),p=function(){function e(){}return e.SetMatrix=function(e,r,n,t,o){var i=null;if("MODEL"===n.semantic?i=r.getWorldMatrix():"PROJECTION"===n.semantic?i=e.getProjectionMatrix():"VIEW"===n.semantic?i=e.getViewMatrix():"MODELVIEWINVERSETRANSPOSE"===n.semantic?i=m.Matrix.Transpose(r.getWorldMatrix().multiply(e.getViewMatrix()).invert()):"MODELVIEW"===n.semantic?i=r.getWorldMatrix().multiply(e.getViewMatrix()):"MODELVIEWPROJECTION"===n.semantic?i=r.getWorldMatrix().multiply(e.getTransformMatrix()):"MODELINVERSE"===n.semantic?i=r.getWorldMatrix().invert():"VIEWINVERSE"===n.semantic?i=e.getViewMatrix().invert():"PROJECTIONINVERSE"===n.semantic?i=e.getProjectionMatrix().invert():"MODELVIEWINVERSE"===n.semantic?i=r.getWorldMatrix().multiply(e.getViewMatrix()).invert():"MODELVIEWPROJECTIONINVERSE"===n.semantic?i=r.getWorldMatrix().multiply(e.getTransformMatrix()).invert():"MODELINVERSETRANSPOSE"===n.semantic&&(i=m.Matrix.Transpose(r.getWorldMatrix().invert())),i)switch(n.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,r,n,t){switch(t){case s.FLOAT:return e.setFloat(r,n),!0;case s.FLOAT_VEC2:return e.setVector2(r,m.Vector2.FromArray(n)),!0;case s.FLOAT_VEC3:return e.setVector3(r,m.Vector3.FromArray(n)),!0;case s.FLOAT_VEC4:return e.setVector4(r,m.Vector4.FromArray(n)),!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,r,n,t,o){n=r.byteOffset+n;var a=e.loadedBufferViews[r.buffer];if(n+t>a.byteLength)throw new Error("Buffer access is out of range");var s=a.buffer;switch(n+=a.byteOffset,o){case i.BYTE:return new Int8Array(s,n,t);case i.UNSIGNED_BYTE:return new Uint8Array(s,n,t);case i.SHORT:return new Int16Array(s,n,t);case i.UNSIGNED_SHORT:return new Uint16Array(s,n,t);default:return new Float32Array(s,n,t)}},e.GetBufferFromAccessor=function(r,n){var t=r.bufferViews[n.bufferView],o=n.count*e.GetByteStrideFromType(n);return e.GetBufferFromBufferView(r,t,n.byteOffset,o,n.componentType)},e.DecodeBufferToText=function(e){for(var r="",n=e.byteLength,t=0;t<n;++t)r+=String.fromCharCode(e[t]);return r},e.GetDefaultMaterial=function(r){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 n={attributes:["position"],uniforms:["worldView","projection","u_emission"],samplers:new Array,needAlphaBlending:!1};e._DefaultMaterial=new m.ShaderMaterial("GLTFDefaultMaterial",r,{vertex:"GLTFDefaultMaterial",fragment:"GLTFDefaultMaterial"},n),e._DefaultMaterial.setColor4("u_emission",new m.Color4(.5,.5,.5,1))}return e._DefaultMaterial},e._DefaultMaterial=null,e}(),A=n(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,r,n){for(var t in e){var o=e[t];n[r][t]=o}},g=function(e){if(e)for(var r=0;r<e.length/2;r++)e[2*r+1]=1-e[2*r+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 r=Number(e.semantic.split("_")[1]);return"uv"+(0===r?"":r+1)}return null},L=function(e){var r=null;if(e.translation||e.rotation||e.scale){var n=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]);r=m.Matrix.Compose(n,t,o)}else r=m.Matrix.FromArray(e.matrix);return r},N=function(e,r,n,t){for(var o=0;o<t.bones.length;o++)if(t.bones[o].name===n)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===n){var c=L(s),f=new m.Bone(s.name||"",t,N(e,r,s.jointName,t),c);return f.id=a,f}}}}return null},S=function(e,r){for(var n=0;n<e.length;n++)for(var t=e[n],o=0;o<t.node.children.length;o++){if(t.node.children[o]===r)return t.bone}return null},M=function(e,r){var n=e.nodes,t=n[r];if(t)return{node:t,id:r};for(var o in n)if((t=n[o]).jointName===r)return{node:t,id:o};return null},x=function(e,r){for(var n=0;n<e.jointNames.length;n++)if(e.jointNames[n]===r)return!0;return!1},C=function(e,r,n,t,o){if(t||(t=new m.Skeleton(r.name||"","",e.scene)),!r.babylonSkeleton)return t;var i=[],a=[];!function(e,r,n,t){for(var o in e.nodes){var i=e.nodes[o],a=o;if(i.jointName&&!x(n,i.jointName)){var s=L(i),u=new m.Bone(i.name||"",r,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,r,i),t.bones=[];for(var s=0;s<r.jointNames.length;s++){if(_=M(e,r.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,r.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,r,r.jointNames[d],t),c=!0;break}if(c)break}}else m.Tools.Warn("Joint named "+r.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 "+r.jointNames[s]+" does not exist")}}var y=t.bones;t.bones=[];for(s=0;s<r.jointNames.length;s++){var _;if(_=M(e,r.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,r,n,t,o){if(o||((o=new m.Mesh(r.name||"",e.scene)).id=t),!r.babylonNode)return o;for(var i,a=[],s=null,u=new Array,l=new Array,c=new Array,f=new Array,d=0;d<n.length;d++){var h=n[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<n.length;d++){var I;h=n[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,r,n,t){e.position&&(e.position=r),(e.rotationQuaternion||e.rotation)&&(e.rotationQuaternion=n),e.scaling&&(e.scaling=t)},w=function(e,r,n,t){var o=null;if(e.importOnlyMeshes&&(r.skin||r.meshes)&&e.importMeshesNames&&e.importMeshesNames.length>0&&-1===e.importMeshesNames.indexOf(r.name||""))return null;if(r.skin){if(r.meshes){var i=e.skins[r.skin];(a=R(e,r,r.meshes,n,r.babylonNode)).skeleton=e.scene.getLastSkeletonByID(r.skin),null===a.skeleton&&(a.skeleton=C(e,i,0,i.babylonSkeleton,r.skin),i.babylonSkeleton||(i.babylonSkeleton=a.skeleton)),o=a}}else if(r.meshes){var a;o=a=R(e,r,r.mesh?[r.mesh]:r.meshes,n,r.babylonNode)}else if(!r.light||r.babylonNode||e.importOnlyMeshes){if(r.camera&&!r.babylonNode&&!e.importOnlyMeshes){var s=e.cameras[r.camera];if(s)if("orthographic"===s.type){var u=new m.FreeCamera(r.camera,m.Vector3.Zero(),e.scene,!1);u.name=r.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(r.camera,m.Vector3.Zero(),e.scene,!1);c.name=r.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[r.light];if(f)if("ambient"===f.type){var d=f[f.type],h=new m.HemisphericLight(r.light,m.Vector3.Zero(),e.scene);h.name=r.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(r.light,m.Vector3.Zero(),e.scene);A.name=r.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(r.light,m.Vector3.Zero(),e.scene);b.name=r.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(r.light,m.Vector3.Zero(),m.Vector3.Zero(),0,0,e.scene);_.name=r.name||"",y.color&&(_.diffuse=m.Color3.FromArray(y.color)),y.fallOfAngle&&(_.angle=y.fallOfAngle),y.fallOffExponent&&(_.exponent=y.fallOffExponent),o=_}}if(!r.jointName){if(r.babylonNode)return r.babylonNode;if(null===o){var O=new m.Mesh(r.name||"",e.scene);r.babylonNode=O,o=O}}if(null!==o){if(r.matrix&&o instanceof m.Mesh)!function(e,r,n){if(r.matrix){var t=new m.Vector3(0,0,0),o=new m.Quaternion,i=new m.Vector3(0,0,0);m.Matrix.FromArray(r.matrix).decompose(i,o,t),I(e,t,o,i)}else r.translation&&r.rotation&&r.scale&&I(e,m.Vector3.FromArray(r.translation),m.Quaternion.FromArray(r.rotation),m.Vector3.FromArray(r.scale));e.computeWorldMatrix(!0)}(o,r);else{var E=r.translation||[0,0,0],g=r.rotation||[0,0,0,1],T=r.scale||[1,1,1];I(o,m.Vector3.FromArray(E),m.Quaternion.FromArray(g),m.Vector3.FromArray(T))}o.updateCache(!0),r.babylonNode=o}return o},P=function(e,r,n,t){void 0===t&&(t=!1);var o=e.nodes[r],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,r))&&(i.id=r,i.parent=n),o.children)for(var a=0;a<o.children.length;a++)P(e,o.children[a],i,t)},F=function(e){var r=e.currentScene;if(r)for(var n=0;n<r.nodes.length;n++)P(e,r.nodes[n],null);else for(var t in e.scenes){r=e.scenes[t];for(n=0;n<r.nodes.length;n++)P(e,r.nodes[n],null)}!function(e){for(var r in e.animations){var n=e.animations[r];if(n.channels&&n.samplers)for(var t=null,o=0;o<n.channels.length;o++){var i=n.channels[o],a=n.samplers[i.sampler];if(a){var s=null,u=null;n.parameters?(s=n.parameters[a.input],u=n.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(r,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 "+r+". But cannot find node named "+f+" 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)}},B=function(e,r,n,t,o,i){return function(a){!function(e,r,n,t,o){var i=t.values||n.parameters,a=n.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(n){l.value&&e&&(r.setTexture(e,n),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(r,u,t.values?f:l.value,c)&&delete o[u]}}}(e,r,n,t,o),r.onBind=function(a){!function(e,r,n,t,o,i,a){var u=i.values||o.parameters;for(var l in n){var c=n[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=r.scene.getNodeByName(c.source||c.node||"");if(null===d&&(d=r.scene.getNodeByID(c.source||c.node||"")),null===d)continue;p.SetMatrix(r.scene,d,c,l,t.getEffect())}}else p.SetMatrix(r.scene,e,c,l,t.getEffect());else{var h=u[o.uniforms[l]];if(!h)continue;if(f===s.SAMPLER_2D){var m=r.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,r,n,t,i)}}},V=function(e,r,n){for(var t in r.uniforms){var o=r.uniforms[t],i=r.parameters[o];if(e.currentIdentifier===t&&i.semantic&&!i.source&&!i.node){var a=b.indexOf(i.semantic);if(-1!==a)return delete n[t],y[a]}}return e.currentIdentifier},D=function(e){for(var r in e.materials)j.LoadMaterialAsync(e,r,function(e){},function(){})},U=function(){function e(){}return e.CreateRuntime=function(e,r,n){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:r,rootUrl:n,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,r){for(var n in e){var t=e[n];r.buffers[n]=t,r.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,r){for(var n in e){var t=e[n];r.shaders[n]=t,r.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,r,n,t,o){var i=e.buffers[r];m.Tools.IsBase64(i.uri)?setTimeout(function(){return n(new Uint8Array(m.Tools.DecodeBase64(i.uri)))}):m.Tools.LoadFile(e.rootUrl+i.uri,function(e){return n(new Uint8Array(e))},o,void 0,!0,function(e){e&&t(e.status+" "+e.statusText)})},e.LoadTextureBufferAsync=function(e,r,n,t){var o=e.textures[r];if(o&&o.source)if(o.babylonTexture)n(null);else{var i=e.images[o.source];m.Tools.IsBase64(i.uri)?setTimeout(function(){return n(new Uint8Array(m.Tools.DecodeBase64(i.uri)))}):m.Tools.LoadFile(e.rootUrl+i.uri,function(e){return n(new Uint8Array(e))},void 0,void 0,!0,function(e){e&&t(e.status+" "+e.statusText)})}else t("")},e.CreateTextureAsync=function(e,r,n,t,o){var i=e.textures[r];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==n?new Blob:new Blob([n]),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=r,i.babylonTexture=h,t(h)}},e.LoadShaderStringAsync=function(e,r,n,t){var o=e.shaders[r];if(m.Tools.IsBase64(o.uri)){var i=atob(o.uri.split(",")[1]);n&&n(i)}else m.Tools.LoadFile(e.rootUrl+o.uri,n,void 0,void 0,!1,function(e){e&&t&&t(e.status+" "+e.statusText)})},e.LoadMaterialAsync=function(e,r,n,t){var o=e.materials[r];if(o.technique){var i=e.techniques[o.technique];if(!i){var a=new m.StandardMaterial(r,e.scene);return a.diffuseColor=new m.Color3(.5,.5,.5),a.sideOrientation=m.Material.CounterClockWiseSideOrientation,void n(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+r,fragment:u.fragmentShader+r},G={attributes:N,uniforms:L,samplers:S,needAlphaBlending:l&&l.enable&&-1!==l.enable.indexOf(3042)};m.Effect.ShadersStore[u.vertexShader+r+"VertexShader"]=A,m.Effect.ShadersStore[u.fragmentShader+r+"PixelShader"]=_;var j=new m.ShaderMaterial(r,e.scene,U,G);if(j.onError=function(e,r,n){return function(t,o){r.dispose(!0),n("Cannot compile program named "+e.name+". Error: "+o+". Default material will be applied")}}(u,j,t),j.onCompiled=B(e,j,i,o,g,n),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(r){e.Extensions[r.name]?m.Tools.Error('Tool with the same name "'+r.name+'" already exists'):e.Extensions[r.name]=r},e.prototype.dispose=function(){},e.prototype._importMeshAsync=function(e,r,n,t,o,i,a){var s=this;return r.useRightHandedSystem=!0,j.LoadRuntimeAsync(r,n,t,function(r){r.importOnlyMeshes=!0,""===e?r.importMeshesNames=[]:"string"==typeof e?r.importMeshesNames=[e]:!e||e instanceof Array?(r.importMeshesNames=[],m.Tools.Warn("Argument meshesNames must be of type string or string[]")):r.importMeshesNames=[e],s._createNodes(r);var n=new Array,t=new Array;for(var a in r.nodes){var u=r.nodes[a];u.babylonNode instanceof m.AbstractMesh&&n.push(u.babylonNode)}for(var l in r.skins){var c=r.skins[l];c.babylonSkeleton instanceof m.Skeleton&&t.push(c.babylonSkeleton)}s._loadBuffersAsync(r,function(){s._loadShadersAsync(r,function(){D(r),F(r),!A.GLTFFileLoader.IncrementalLoading&&o&&o(n,t)})},i),A.GLTFFileLoader.IncrementalLoading&&o&&o(n,t)},a),!0},e.prototype.importMeshAsync=function(e,r,n,t,o){var i=this;return new Promise(function(a,s){i._importMeshAsync(e,r,n,t,function(e,r){a({meshes:e,particleSystems:[],skeletons:r,animationGroups:[]})},o,function(e){s(new Error(e))})})},e.prototype._loadAsync=function(e,r,n,t,o,i){var a=this;e.useRightHandedSystem=!0,j.LoadRuntimeAsync(e,r,n,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,r,n,t){var o=this;return new Promise(function(i,a){o._loadAsync(e,r,n,function(){i()},t,function(e){a(new Error(e))})})},e.prototype._loadShadersAsync=function(e,r){var n=!1,t=function(n,t){j.LoadShaderStringAsync(e,n,function(o){o instanceof ArrayBuffer||(e.loadedShaderCount++,o&&(m.Effect.ShadersStore[n+(t.type===a.VERTEX?"VertexShader":"PixelShader")]=o),e.loadedShaderCount===e.shaderscount&&r())},function(){m.Tools.Error("Error when loading shader program named "+n+" located at "+t.uri)})};for(var o in e.shaders){n=!0;var i=e.shaders[o];i?t.bind(this,o,i)():m.Tools.Error("No shader named: "+o)}n||r()},e.prototype._loadBuffersAsync=function(e,r,n){var t=!1,o=function(n,t){j.LoadBufferAsync(e,n,function(o){e.loadedBufferCount++,o&&(o.byteLength!=e.buffers[n].byteLength&&m.Tools.Error("Buffer named "+n+" is length "+o.byteLength+". Expected: "+t.byteLength),e.loadedBufferViews[n]=o),e.loadedBufferCount===e.buffersCount&&r()},function(){m.Tools.Error("Error when loading buffer named "+n+" 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||r()},e.prototype._createNodes=function(e){var r=e.currentScene;if(r)for(var n=0;n<r.nodes.length;n++)P(e,r.nodes[n],null);else for(var t in e.scenes){r=e.scenes[t];for(n=0;n<r.nodes.length;n++)P(e,r.nodes[n],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,r,n,t,o){return!1},e.prototype.loadRuntimeExtensionsAsync=function(e,r,n){return!1},e.prototype.loadBufferAsync=function(e,r,n,t,o){return!1},e.prototype.loadTextureBufferAsync=function(e,r,n,t){return!1},e.prototype.createTextureAsync=function(e,r,n,t,o){return!1},e.prototype.loadShaderStringAsync=function(e,r,n,t){return!1},e.prototype.loadMaterialAsync=function(e,r,n,t){return!1},e.LoadRuntimeAsync=function(r,n,t,o,i){e.ApplyExtensions(function(e){return e.loadRuntimeAsync(r,n,t,o,i)},function(){setTimeout(function(){o&&o(U.CreateRuntime(n.json,r,t))})})},e.LoadRuntimeExtensionsAsync=function(r,n,t){e.ApplyExtensions(function(e){return e.loadRuntimeExtensionsAsync(r,n,t)},function(){setTimeout(function(){n()})})},e.LoadBufferAsync=function(r,n,t,o,i){e.ApplyExtensions(function(e){return e.loadBufferAsync(r,n,t,o,i)},function(){U.LoadBufferAsync(r,n,t,o,i)})},e.LoadTextureAsync=function(r,n,t,o){e.LoadTextureBufferAsync(r,n,function(i){i&&e.CreateTextureAsync(r,n,i,t,o)},o)},e.LoadShaderStringAsync=function(r,n,t,o){e.ApplyExtensions(function(e){return e.loadShaderStringAsync(r,n,t,o)},function(){U.LoadShaderStringAsync(r,n,t,o)})},e.LoadMaterialAsync=function(r,n,t,o){e.ApplyExtensions(function(e){return e.loadMaterialAsync(r,n,t,o)},function(){U.LoadMaterialAsync(r,n,t,o)})},e.LoadTextureBufferAsync=function(r,n,t,o){e.ApplyExtensions(function(e){return e.loadTextureBufferAsync(r,n,t,o)},function(){U.LoadTextureBufferAsync(r,n,t,o)})},e.CreateTextureAsync=function(r,n,t,o,i){e.ApplyExtensions(function(e){return e.createTextureAsync(r,n,t,o,i)},function(){U.CreateTextureAsync(r,n,t,o,i)})},e.ApplyExtensions=function(e,r){for(var n in G.Extensions){if(e(G.Extensions[n]))return}r()},e}();A.GLTFFileLoader._CreateGLTF1Loader=function(){return new G};var k=function(e){function r(){return e.call(this,"KHR_binary_glTF")||this}return o(r,e),r.prototype.loadRuntimeAsync=function(e,r,n,t,o){var i=r.json.extensionsUsed;return!(!i||-1===i.indexOf(this.name)||!r.bin)&&(this._bin=r.bin,t(U.CreateRuntime(r.json,e,n)),!0)},r.prototype.loadBufferAsync=function(e,r,n,t){return-1!==e.extensionsUsed.indexOf(this.name)&&("binary_glTF"===r&&(n(this._bin),!0))},r.prototype.loadTextureBufferAsync=function(e,r,n,t){var o=e.textures[r],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 n(p.GetBufferFromBufferView(e,u,0,u.byteLength,i.UNSIGNED_BYTE)),!0},r.prototype.loadShaderStringAsync=function(e,r,n,t){var o=e.shaders[r];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);n(e)}),!0},r}(j);G.RegisterExtension(new k);var H=function(e){function r(){return e.call(this,"KHR_materials_common")||this}return o(r,e),r.prototype.loadRuntimeExtensionsAsync=function(e,r,n){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},r.prototype.loadMaterialAsync=function(e,r,n,t){var o=e.materials[r];if(!o||!o.extensions)return!1;var i=o.extensions[this.name];if(!i)return!1;var a=new m.StandardMaterial(r,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},r.prototype._loadTexture=function(e,r,n,t,o){U.LoadTextureBufferAsync(e,r,function(i){U.CreateTextureAsync(e,r,i,function(e){return n[t]=e},o)},o)},r}(j);G.RegisterExtension(new H),n.d(r,"GLTFBinaryExtension",function(){return k}),n.d(r,"GLTFLoaderBase",function(){return U}),n.d(r,"GLTFLoader",function(){return G}),n.d(r,"GLTFLoaderExtension",function(){return j}),n.d(r,"EComponentType",function(){return i}),n.d(r,"EShaderType",function(){return a}),n.d(r,"EParameterType",function(){return s}),n.d(r,"ETextureWrapMode",function(){return u}),n.d(r,"ETextureFilterType",function(){return l}),n.d(r,"ETextureFormat",function(){return c}),n.d(r,"ECullingType",function(){return f}),n.d(r,"EBlendingFunction",function(){return d}),n.d(r,"GLTFUtils",function(){return p}),n.d(r,"GLTFMaterialsCommonExtension",function(){return H})},,,function(e,r,n){"use strict";(function(e){var t=n(2);n.d(r,"a",function(){return t.GLTFFileLoader}),n.d(r,"b",function(){return t.GLTFLoaderAnimationStartMode}),n.d(r,"c",function(){return t.GLTFLoaderCoordinateSystemMode}),n.d(r,"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,n(3))},,function(e,r,n){"use strict";(function(e){var t=n(6);n.d(r,"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,n(3))},,,,function(e,r,n){"use strict";n.r(r);var t=n(9);n.d(r,"GLTFLoaderCoordinateSystemMode",function(){return t.c}),n.d(r,"GLTFLoaderAnimationStartMode",function(){return t.b}),n.d(r,"GLTFLoaderState",function(){return t.d}),n.d(r,"GLTFFileLoader",function(){return t.a});var o=n(11);n.d(r,"GLTF1",function(){return o.a})}])});
|