var BABYLON;!(function(e){var t;!(function(e){e[e.AUTO=0]="AUTO",e[e.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED"})(t=e.GLTFLoaderCoordinateSystemMode||(e.GLTFLoaderCoordinateSystemMode={}));var r;!(function(e){e[e.NONE=0]="NONE",e[e.FIRST=1]="FIRST",e[e.ALL=2]="ALL"})(r=e.GLTFLoaderAnimationStartMode||(e.GLTFLoaderAnimationStartMode={}));!(function(e){e[e.Loading=0]="Loading",e[e.Ready=1]="Ready",e[e.Complete=2]="Complete"})(e.GLTFLoaderState||(e.GLTFLoaderState={}));var n=(function(){function n(){this.onParsedObservable=new e.Observable,this.coordinateSystemMode=t.AUTO,this.animationStartMode=r.FIRST,this.compileMaterials=!1,this.useClipPlane=!1,this.compileShadowGenerators=!1,this.onMeshLoadedObservable=new e.Observable,this.onTextureLoadedObservable=new e.Observable,this.onMaterialLoadedObservable=new e.Observable,this.onAnimationGroupLoadedObservable=new e.Observable,this.onCompleteObservable=new e.Observable,this.onDisposeObservable=new e.Observable,this.onExtensionLoadedObservable=new e.Observable,this._loader=null,this.name="gltf",this.extensions={".gltf":{isBinary:!1},".glb":{isBinary:!0}}}return Object.defineProperty(n.prototype,"onParsed",{set:function(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),this._onParsedObserver=this.onParsedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"onMeshLoaded",{set:function(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"onTextureLoaded",{set:function(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"onMaterialLoaded",{set:function(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"onAnimationGroupLoaded",{set:function(e){this._onAnimationGroupLoadedObserver&&this.onAnimationGroupLoadedObservable.remove(this._onAnimationGroupLoadedObserver),this._onAnimationGroupLoadedObserver=this.onAnimationGroupLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"onComplete",{set:function(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"onExtensionLoaded",{set:function(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)},enumerable:!0,configurable:!0}),n.prototype.whenCompleteAsync=function(){var e=this;return new Promise(function(t){e.onCompleteObservable.add((function(){t()}),void 0,void 0,void 0,!0)})},Object.defineProperty(n.prototype,"loaderState",{get:function(){return this._loader?this._loader.state:null},enumerable:!0,configurable:!0}),n.prototype.dispose=function(){this._loader&&(this._loader.dispose(),this._loader=null),this.onMeshLoadedObservable.clear(),this.onTextureLoadedObservable.clear(),this.onMaterialLoadedObservable.clear(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},n.prototype.importMeshAsync=function(e,t,r,n,o){var a=this;return Promise.resolve().then((function(){var i=a._parse(r);return a._loader=a._getLoader(i),a._loader.importMeshAsync(e,t,i,n,o)}))},n.prototype.loadAsync=function(e,t,r,n){var o=this;return Promise.resolve().then((function(){var a=o._parse(t);return o._loader=o._getLoader(a),o._loader.loadAsync(e,a,r,n)}))},n.prototype.loadAssetContainerAsync=function(t,r,n,o){var a=this;return Promise.resolve().then((function(){var i=a._parse(r);return a._loader=a._getLoader(i),a._loader.importMeshAsync(null,t,i,n,o).then((function(r){var n=new e.AssetContainer(t);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),n.removeAllFromScene(),n}))}))},n.prototype.canDirectLoad=function(e){return e.indexOf("scene")!==-1&&e.indexOf("node")!==-1},n.prototype.createPlugin=function(){return new n},n.prototype._parse=function(e){var t;return t=e instanceof ArrayBuffer?n._parseBinary(e):{json:JSON.parse(e),bin:null},this.onParsedObservable.notifyObservers(t),this.onParsedObservable.clear(),t},n.prototype._getLoader=function(e){var t=this,r={major:2,minor:0},o=e.json.asset||{},a=n._parseVersion(o.version);if(!a)throw new Error("Invalid version: "+o.version);if(void 0!==o.minVersion){var i=n._parseVersion(o.minVersion);if(!i)throw new Error("Invalid minimum version: "+o.minVersion);if(n._compareVersion(i,r)>0)throw new Error("Incompatible minimum version: "+o.minVersion)}var s={1:n.CreateGLTFLoaderV1,2:n.CreateGLTFLoaderV2},l=s[a.major];if(!l)throw new Error("Unsupported version: "+o.version);var d=l();return d.coordinateSystemMode=this.coordinateSystemMode,d.animationStartMode=this.animationStartMode,d.compileMaterials=this.compileMaterials,d.useClipPlane=this.useClipPlane,d.compileShadowGenerators=this.compileShadowGenerators,d.onMeshLoadedObservable.add((function(e){return t.onMeshLoadedObservable.notifyObservers(e)})),d.onTextureLoadedObservable.add((function(e){return t.onTextureLoadedObservable.notifyObservers(e)})),d.onMaterialLoadedObservable.add((function(e){return t.onMaterialLoadedObservable.notifyObservers(e)})),d.onExtensionLoadedObservable.add((function(e){return t.onExtensionLoadedObservable.notifyObservers(e)})),d.onCompleteObservable.add((function(){t.onMeshLoadedObservable.clear(),t.onTextureLoadedObservable.clear(),t.onMaterialLoadedObservable.clear(),t.onCompleteObservable.notifyObservers(t),t.onCompleteObservable.clear()})),d},n._parseBinary=function(e){var t={Magic:1179937895},r=new o(e),a=r.readUint32();if(a!==t.Magic)throw new Error("Unexpected magic: "+a);var i=r.readUint32();switch(i){case 1:return n._parseV1(r);case 2:return n._parseV2(r)}throw new Error("Unsupported version: "+i)},n._parseV1=function(e){var t={JSON:0},r=e.readUint32();if(r!=e.getLength())throw new Error("Length in header does not match actual data length: "+r+" != "+e.getLength());var o,a=e.readUint32(),i=e.readUint32();switch(i){case t.JSON:o=JSON.parse(n._decodeBufferToText(e.readUint8Array(a)));break;default:throw new Error("Unexpected content format: "+i)}var s=e.getLength()-e.getPosition();return{json:o,bin:e.readUint8Array(s)}},n._parseV2=function(e){var t={JSON:1313821514,BIN:5130562},r=e.readUint32();if(r!==e.getLength())throw new Error("Length in header does not match actual data length: "+r+" != "+e.getLength());var o=e.readUint32();if(e.readUint32()!==t.JSON)throw new Error("First chunk format is not JSON");for(var a=JSON.parse(n._decodeBufferToText(e.readUint8Array(o))),i=null;e.getPosition()t.major?1:e.majort.minor?1:e.minort.bin.byteLength)&&e.Tools.Warn("Binary buffer length ("+n.byteLength+") from JSON does not match chunk length ("+t.bin.byteLength+")"),n._data=Promise.resolve(t.bin)}else e.Tools.Warn("Unexpected BIN chunk")}},r.prototype._setupData=function(){if(t.ArrayItem.Assign(this._gltf.accessors),t.ArrayItem.Assign(this._gltf.animations),t.ArrayItem.Assign(this._gltf.buffers),t.ArrayItem.Assign(this._gltf.bufferViews),t.ArrayItem.Assign(this._gltf.cameras),t.ArrayItem.Assign(this._gltf.images),t.ArrayItem.Assign(this._gltf.materials),t.ArrayItem.Assign(this._gltf.meshes),t.ArrayItem.Assign(this._gltf.nodes),t.ArrayItem.Assign(this._gltf.samplers),t.ArrayItem.Assign(this._gltf.scenes),t.ArrayItem.Assign(this._gltf.skins),t.ArrayItem.Assign(this._gltf.textures),this._gltf.nodes){for(var e={},r=0,n=this._gltf.nodes;r=0;i--)if(a.push(t.GLTFLoader._GetProperty(e+"/ids/"+o[i],n,o[i])),a.length===this.maxLODsToLoad)return a;return a.push(r),a},o})(t.GLTFLoaderExtension);r.MSFT_lod=o,t.GLTFLoader._Register(n,(function(e){return new o(e)}))})(t.Extensions||(t.Extensions={}))})(e.GLTF2||(e.GLTF2={}))})(BABYLON||(BABYLON={}));var __extends=this&&this.__extends||(function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}})(),BABYLON;!(function(e){!(function(t){!(function(r){var n="KHR_draco_mesh_compression",o=(function(r){function o(t){var o=r.call(this,t)||this;return o.name=n,o._dracoCompression=null,e.DracoCompression.DecoderUrl||(o.enabled=!1),o}return __extends(o,r),o.prototype.dispose=function(){this._dracoCompression&&this._dracoCompression.dispose(),r.prototype.dispose.call(this)},o.prototype._loadVertexDataAsync=function(r,n,o){var a=this;return this._loadExtensionAsync(r,n,(function(i,s){if(void 0!=n.mode){if(5!==n.mode&&4!==n.mode)throw new Error(r+": Unsupported mode "+n.mode);if(5===n.mode)throw new Error(r+": Mode "+n.mode+" is not currently supported")}var l={},d=function(e,t){var r=s.attributes[e];void 0!=r&&(o._delayInfo=o._delayInfo||[],o._delayInfo.indexOf(t)===-1&&o._delayInfo.push(t),l[t]=r)};d("POSITION",e.VertexBuffer.PositionKind),d("NORMAL",e.VertexBuffer.NormalKind),d("TANGENT",e.VertexBuffer.TangentKind),d("TEXCOORD_0",e.VertexBuffer.UVKind),d("TEXCOORD_1",e.VertexBuffer.UV2Kind),d("JOINTS_0",e.VertexBuffer.MatricesIndicesKind),d("WEIGHTS_0",e.VertexBuffer.MatricesWeightsKind),d("COLOR_0",e.VertexBuffer.ColorKind);var u=t.GLTFLoader._GetProperty(i,a._loader._gltf.bufferViews,s.bufferView);return a._loader._loadBufferViewAsync("#/bufferViews/"+u._index,u).then((function(t){try{return a._dracoCompression||(a._dracoCompression=new e.DracoCompression),a._dracoCompression.decodeMeshAsync(t,l)}catch(e){throw new Error(r+": "+e.message)}}))}))},o})(t.GLTFLoaderExtension);r.KHR_draco_mesh_compression=o,t.GLTFLoader._Register(n,(function(e){return new o(e)}))})(t.Extensions||(t.Extensions={}))})(e.GLTF2||(e.GLTF2={}))})(BABYLON||(BABYLON={}));var __extends=this&&this.__extends||(function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}})(),BABYLON;!(function(e){!(function(t){!(function(r){var n="KHR_materials_pbrSpecularGlossiness",o=(function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e.name=n,e}return __extends(r,t),r.prototype._loadMaterialAsync=function(e,t,r,n){var o=this;return this._loadExtensionAsync(e,t,(function(e,a){if(t._babylonMeshes=t._babylonMeshes||[],t._babylonMeshes.push(r),!t._loaded){var i=new Array,s=o._loader._createMaterial(t);t._babylonMaterial=s,i.push(o._loader._loadMaterialBasePropertiesAsync(e,t)),i.push(o._loadSpecularGlossinessPropertiesAsync(e,t,a)),o._loader.onMaterialLoadedObservable.notifyObservers(s),t._loaded=Promise.all(i).then((function(){}))}return n(t._babylonMaterial),t._loaded}))},r.prototype._loadSpecularGlossinessPropertiesAsync=function(t,r,n){var o=new Array,a=r._babylonMaterial;return n.diffuseFactor?(a.albedoColor=e.Color3.FromArray(n.diffuseFactor),a.alpha=n.diffuseFactor[3]):a.albedoColor=e.Color3.White(),a.reflectivityColor=n.specularFactor?e.Color3.FromArray(n.specularFactor):e.Color3.White(),a.microSurface=void 0==n.glossinessFactor?1:n.glossinessFactor,n.diffuseTexture&&o.push(this._loader._loadTextureAsync(t+"/diffuseTexture",n.diffuseTexture,(function(e){a.albedoTexture=e}))),n.specularGlossinessTexture&&(o.push(this._loader._loadTextureAsync(t+"/specularGlossinessTexture",n.specularGlossinessTexture,(function(e){a.reflectivityTexture=e}))),a.reflectivityTexture.hasAlpha=!0,a.useMicroSurfaceFromReflectivityMapAlpha=!0),this._loader._loadMaterialAlphaProperties(t,r),Promise.all(o).then((function(){}))},r})(t.GLTFLoaderExtension);r.KHR_materials_pbrSpecularGlossiness=o,t.GLTFLoader._Register(n,(function(e){return new o(e)}))})(t.Extensions||(t.Extensions={}))})(e.GLTF2||(e.GLTF2={}))})(BABYLON||(BABYLON={}));var __extends=this&&this.__extends||(function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}})(),BABYLON;!(function(e){!(function(t){!(function(r){var n,o="KHR_lights";!(function(e){e.AMBIENT="ambient",e.DIRECTIONAL="directional",e.POINT="point",e.SPOT="spot"})(n||(n={}));var a=(function(r){function a(){var e=null!==r&&r.apply(this,arguments)||this;return e.name=o,e}return __extends(a,r),a.prototype._loadSceneAsync=function(r,o){var a=this;return this._loadExtensionAsync(r,o,(function(r,i){var s=a._loader._loadSceneAsync(r,o),l=t.GLTFLoader._GetProperty(r,a._lights,i.light);if(l.type!==n.AMBIENT)throw new Error(r+": Only ambient lights are allowed on a scene");return a._loader._babylonScene.ambientColor=l.color?e.Color3.FromArray(l.color):e.Color3.Black(),s}))},a.prototype._loadNodeAsync=function(r,o){var a=this;return this._loadExtensionAsync(r,o,(function(r,i){var s,l=a._loader._loadNodeAsync(r,o),d=t.GLTFLoader._GetProperty(r,a._lights,i.light),u=o._babylonMesh.name;switch(d.type){case n.AMBIENT:throw new Error(r+": Ambient lights are not allowed on a node");case n.DIRECTIONAL:s=new e.DirectionalLight(u,e.Vector3.Forward(),a._loader._babylonScene);break;case n.POINT:s=new e.PointLight(u,e.Vector3.Zero(),a._loader._babylonScene);break;case n.SPOT:var c=d,h=c.outerConeAngle||Math.PI/4;s=new e.SpotLight(u,e.Vector3.Zero(),e.Vector3.Forward(),h,2,a._loader._babylonScene);break;default:throw new Error(r+": Invalid light type ("+d.type+")")}return s.diffuse=d.color?e.Color3.FromArray(d.color):e.Color3.White(),s.intensity=void 0==d.intensity?1:d.intensity,s.parent=o._babylonMesh,l}))},Object.defineProperty(a.prototype,"_lights",{get:function(){var e=this._loader._gltf.extensions;if(!e||!e[this.name])throw new Error("#/extensions: '"+this.name+"' not found");return e[this.name].lights},enumerable:!0,configurable:!0}),a})(t.GLTFLoaderExtension);r.KHR_lights=a,t.GLTFLoader._Register(o,(function(e){return new a(e)}))})(t.Extensions||(t.Extensions={}))})(e.GLTF2||(e.GLTF2={}))})(BABYLON||(BABYLON={}));