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