var BABYLON;!(function(e){var t;!(function(e){e[e.AUTO=0]="AUTO",e[e.PASS_THROUGH=1]="PASS_THROUGH",e[e.FORCE_RIGHT_HANDED=2]="FORCE_RIGHT_HANDED"})(t=e.GLTFLoaderCoordinateSystemMode||(e.GLTFLoaderCoordinateSystemMode={}));var r=(function(){function e(){this.coordinateSystemMode=t.AUTO,this.name="gltf",this.extensions={".gltf":{isBinary:!1},".glb":{isBinary:!0}}}return e.prototype.dispose=function(){this._loader&&(this._loader.dispose(),this._loader=null)},e.prototype.importMeshAsync=function(t,r,n,a,o,i,s){var l=e._parse(n,s);l&&(this.onParsed&&this.onParsed(l),this._loader=this._getLoader(l,s),this._loader&&this._loader.importMeshAsync(t,r,l,a,o,i,s))},e.prototype.loadAsync=function(t,r,n,a,o,i){var s=e._parse(r,i);if(s&&(this.onParsed&&this.onParsed(s),this._loader=this._getLoader(s,i),this._loader))return this._loader.loadAsync(t,s,n,a,o,i)},e.prototype.canDirectLoad=function(e){return e.indexOf("scene")!==-1&&e.indexOf("node")!==-1},e._parse=function(t,r){try{return t instanceof ArrayBuffer?e._parseBinary(t,r):{json:JSON.parse(t),bin:null}}catch(e){return r(e.message),null}},e.prototype._getLoader=function(t,r){var n={major:2,minor:0},a=t.json.asset||{},o=e._parseVersion(a.version);if(!o)return r("Invalid version: "+a.version),null;if(void 0!==a.minVersion){var i=e._parseVersion(a.minVersion);if(!i)return r("Invalid minimum version: "+a.minVersion),null;if(e._compareVersion(i,n)>0)return r("Incompatible minimum version: "+a.minVersion),null}var s={1:e.CreateGLTFLoaderV1,2:e.CreateGLTFLoaderV2},l=s[o.major];return l?l(this):(r("Unsupported version: "+a.version),null)},e._parseBinary=function(t,r){var a={Magic:1179937895},o=new n(t),i=o.readUint32();if(i!==a.Magic)return r("Unexpected magic: "+i),null;var s=o.readUint32();switch(s){case 1:return e._parseV1(o,r);case 2:return e._parseV2(o,r)}return r("Unsupported version: "+s),null},e._parseV1=function(t,r){var n={JSON:0},a=t.readUint32();if(a!=t.getLength())return r("Length in header does not match actual data length: "+a+" != "+t.getLength()),null;var o,i=t.readUint32(),s=t.readUint32();switch(s){case n.JSON:o=JSON.parse(e._decodeBufferToText(t.readUint8Array(i)));break;default:return r("Unexpected content format: "+s),null}var l=t.getLength()-t.getPosition();return{json:o,bin:t.readUint8Array(l)}},e._parseV2=function(t,r){var n={JSON:1313821514,BIN:5130562},a=t.readUint32();if(a!==t.getLength())return r("Length in header does not match actual data length: "+a+" != "+t.getLength()),null;var o=t.readUint32();if(t.readUint32()!==n.JSON)return r("First chunk format is not JSON"),null;for(var i=JSON.parse(e._decodeBufferToText(t.readUint8Array(o))),s=null;t.getPosition()t.major?1:e.majort.minor?1:e.minor=0;l--){var u=t.GLTFUtils.GetArrayItem(e._gltf.nodes,i.ids[l]);if(!u)throw new Error(r+": Failed to find node "+i.ids[l]);e._traverseNode(r,u,a,o)}e._traverseNode(r,n,a,o),s()}))},n.prototype._loadNode=function(e,t,r){var n=this;return this._loadExtension(r,(function(a,o){var i=[r.index].concat(a.ids).map((function(t){return e._gltf.nodes[t]}));e._addLoaderPendingData(r),n._loadNodeLOD(e,t,i,i.length-1,(function(){e._removeLoaderPendingData(r),o()}))}))},n.prototype._loadNodeLOD=function(e,t,r,a,o){var i=this;e._whenAction((function(){e._loadNode(t,r[a])}),(function(){if(a!==r.length-1){r[a+1].babylonMesh.setEnabled(!1)}if(0===a)return void o();setTimeout((function(){e._tryCatchOnError((function(){i._loadNodeLOD(e,t,r,a-1,o)}))}),n.MinimalLODDelay)}))},n.prototype._loadMaterial=function(e,t,r,n){var a=this;return this._loadExtension(r,(function(o,i){var s=[r.index].concat(o.ids).map((function(t){return e._gltf.materials[t]}));e._addLoaderPendingData(r),a._loadMaterialLOD(e,t,s,s.length-1,n,(function(){r.extensions[a.name]=o,e._removeLoaderPendingData(r),i()}))}))},n.prototype._loadMaterialLOD=function(t,r,a,o,i,s){var l=this;t._loadMaterial(r,a[o],(function(u,d){if(i(u,d),0===o)return void s();t._executeWhenRenderReady((function(){e.BaseTexture.WhenAllReady(u.getActiveTextures(),(function(){setTimeout((function(){t._tryCatchOnError((function(){l._loadMaterialLOD(t,r,a,o-1,i,s)}))}),n.MinimalLODDelay)}))}))}))},n.MinimalLODDelay=250,n})(t.GLTFLoaderExtension);r.MSFTLOD=n,t.GLTFLoader.RegisterExtension(new n)})(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=(function(r){function n(){return null!==r&&r.apply(this,arguments)||this}return __extends(n,r),Object.defineProperty(n.prototype,"name",{get:function(){return"KHR_materials_pbrSpecularGlossiness"},enumerable:!0,configurable:!0}),n.prototype._loadMaterial=function(e,t,r,n){var a=this;return this._loadExtension(r,(function(o,i){e._createPbrMaterial(r),e._loadMaterialBaseProperties(t,r),a._loadSpecularGlossinessProperties(e,t,r,o),n(r.babylonMaterial,!0)}))},n.prototype._loadSpecularGlossinessProperties=function(r,n,a,o){var i=a.babylonMaterial;if(i.albedoColor=o.diffuseFactor?e.Color3.FromArray(o.diffuseFactor):new e.Color3(1,1,1),i.reflectivityColor=o.specularFactor?e.Color3.FromArray(o.specularFactor):new e.Color3(1,1,1),i.microSurface=null==o.glossinessFactor?1:o.glossinessFactor,o.diffuseTexture){var s=t.GLTFUtils.GetArrayItem(r._gltf.textures,o.diffuseTexture.index);if(!s)throw new Error(n+": Failed to find diffuse texture "+o.diffuseTexture.index);i.albedoTexture=r._loadTexture("textures["+s.index+"]",s,o.diffuseTexture.texCoord)}if(o.specularGlossinessTexture){var s=t.GLTFUtils.GetArrayItem(r._gltf.textures,o.specularGlossinessTexture.index);if(!s)throw new Error(n+": Failed to find diffuse texture "+o.specularGlossinessTexture.index);i.reflectivityTexture=r._loadTexture("textures["+s.index+"]",s,o.specularGlossinessTexture.texCoord),i.reflectivityTexture.hasAlpha=!0,i.useMicroSurfaceFromReflectivityMapAlpha=!0}r._loadMaterialAlphaProperties(n,a,o.diffuseFactor)},n})(t.GLTFLoaderExtension);r.KHRMaterialsPbrSpecularGlossiness=n,t.GLTFLoader.RegisterExtension(new n)})(t.Extensions||(t.Extensions={}))})(e.GLTF2||(e.GLTF2={}))})(BABYLON||(BABYLON={}));