!(function(a){var e,n,r,t,o;(n=e=a.GLTFLoaderCoordinateSystemMode||(a.GLTFLoaderCoordinateSystemMode={}))[n.AUTO=0]="AUTO",n[n.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED",(t=r=a.GLTFLoaderAnimationStartMode||(a.GLTFLoaderAnimationStartMode={}))[t.NONE=0]="NONE",t[t.FIRST=1]="FIRST",t[t.ALL=2]="ALL",(o=a.GLTFLoaderState||(a.GLTFLoaderState={}))[o.LOADING=0]="LOADING",o[o.READY=1]="READY",o[o.COMPLETE=2]="COMPLETE";var i=(function(){function u(){this.onParsedObservable=new a.Observable,this.coordinateSystemMode=e.AUTO,this.animationStartMode=r.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(u.prototype,"onParsed",{set:function(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),this._onParsedObserver=this.onParsedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"onMeshLoaded",{set:function(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"onTextureLoaded",{set:function(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"onMaterialLoaded",{set:function(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"onCameraLoaded",{set:function(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"onComplete",{set:function(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"onError",{set:function(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"onExtensionLoaded",{set:function(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(u.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(u.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(u.prototype,"onValidated",{set:function(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)},enumerable:!0,configurable:!0}),u.prototype.dispose=function(){this._loader&&(this._loader.dispose(),this._loader=null),this._clear(),this.onDisposeObservable.notifyObservers(void 0),this.onDisposeObservable.clear()},u.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()},u.prototype.importMeshAsync=function(n,r,e,t,o,i){var a=this;return this._parseAsync(r,e,t,i).then((function(e){return a._log("Loading "+(i||"")),a._loader=a._getLoader(e),a._loader.importMeshAsync(n,r,e,t,o,i)}))},u.prototype.loadAsync=function(n,e,r,t,o){var i=this;return this._parseAsync(n,e,r,o).then((function(e){return i._log("Loading "+(o||"")),i._loader=i._getLoader(e),i._loader.loadAsync(n,e,r,t,o)}))},u.prototype.loadAssetContainerAsync=function(r,e,n,t,o){var i=this;return this._parseAsync(r,e,n,o).then((function(e){return i._log("Loading "+(o||"")),i._loader=i._getLoader(e),i._loader.importMeshAsync(null,r,e,n,t,o).then((function(e){var n=new a.AssetContainer(r);return Array.prototype.push.apply(n.meshes,e.meshes),Array.prototype.push.apply(n.particleSystems,e.particleSystems),Array.prototype.push.apply(n.skeletons,e.skeletons),Array.prototype.push.apply(n.animationGroups,e.animationGroups),n.removeAllFromScene(),n}))}))},u.prototype.canDirectLoad=function(e){return-1!==e.indexOf("scene")&&-1!==e.indexOf("node")},u.prototype.createPlugin=function(){return new u},Object.defineProperty(u.prototype,"loaderState",{get:function(){return this._loader?this._loader.state:null},enumerable:!0,configurable:!0}),u.prototype.whenCompleteAsync=function(){var r=this;return new Promise(function(e,n){r.onCompleteObservable.addOnce((function(){e()})),r.onErrorObservable.addOnce((function(e){n(e)}))})},u.prototype._parseAsync=function(e,r,t,o){var i=this;return Promise.resolve().then((function(){var n=r instanceof ArrayBuffer?i._unpackBinary(r):{json:r,bin:null};return i._validateAsync(e,n.json,t,o).then((function(){i._startPerformanceCounter("Parse JSON"),i._log("JSON length: "+n.json.length);var e={json:JSON.parse(n.json),bin:n.bin};return i._endPerformanceCounter("Parse JSON"),i.onParsedObservable.notifyObservers(e),i.onParsedObservable.clear(),e}))}))},u.prototype._validateAsync=function(n,e,r,t){var o=this;if(!this.validate||"undefined"==typeof GLTFValidator)return Promise.resolve();this._startPerformanceCounter("Validate JSON");var i={externalResourceFunction:function(e){return o.preprocessUrlAsync(r+e).then((function(e){return n._loadFileAsync(e,!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(e,i).then((function(e){o._endPerformanceCounter("Validate JSON"),o.onValidatedObservable.notifyObservers(e),o.onValidatedObservable.clear()}))},u.prototype._getLoader=function(e){var n=e.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 r=u._parseVersion(n.version);if(!r)throw new Error("Invalid version: "+n.version);if(void 0!==n.minVersion){var t=u._parseVersion(n.minVersion);if(!t)throw new Error("Invalid minimum version: "+n.minVersion);if(0n.major?1:e.majorn.minor?1:e.minor=this._maxPos},e})(),D=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],U=["world","view","projection","worldView","worldViewProjection","mBones"],M=["translation","rotation","scale"],x=["position","rotationQuaternion","scaling"],o=function(e,n,r){for(var t in e){var o=e[t];r[n][t]=o}},F=function(e){if(e)for(var n=0;ni.byteLength)throw new Error("Buffer access is out of range");var a=i.buffer;switch(r+=i.byteOffset,o){case s.EComponentType.BYTE:return new Int8Array(a,r,t);case s.EComponentType.UNSIGNED_BYTE:return new Uint8Array(a,r,t);case s.EComponentType.SHORT:return new Int16Array(a,r,t);case s.EComponentType.UNSIGNED_SHORT:return new Uint16Array(a,r,t);default:return new Float32Array(a,r,t)}},o.GetBufferFromAccessor=function(e,n){var r=e.bufferViews[n.bufferView],t=n.count*o.GetByteStrideFromType(n);return o.GetBufferFromBufferView(e,r,n.byteOffset,t,n.componentType)},o.DecodeBufferToText=function(e){for(var n="",r=e.byteLength,t=0;t