var BABYLON;BABYLON.Effect.ShadersStore.textureTransformPixelShader="precision highp float;\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform mat4 textureTransformMat;\nvoid main(void) {\nvec2 uvTransformed=(textureTransformMat*vec4(vUV.xy,1,1)).xy;\ngl_FragColor=texture2D(textureSampler,uvTransformed);\n}",(function(i){var e=(function(){function e(){}return e.GLTFAsync=function(t,r,n){return t.whenReadyAsync().then((function(){var e=r.replace(/\.[^/.]+$/,"");return new i.GLTF2.Exporter._Exporter(t,n)._generateGLTFAsync(e)}))},e._PreExportAsync=function(e,t){return Promise.resolve().then((function(){return t&&t.exportWithoutWaitingForScene?Promise.resolve():e.whenReadyAsync()}))},e._PostExportAsync=function(e,t,r){return Promise.resolve().then((function(){return r&&r.exportWithoutWaitingForScene,t}))},e.GLBAsync=function(t,r,n){var a=this;return this._PreExportAsync(t,n).then((function(){var e=r.replace(/\.[^/.]+$/,"");return new i.GLTF2.Exporter._Exporter(t,n)._generateGLBAsync(e).then((function(e){return a._PostExportAsync(t,e,n)}))}))},e})();i.GLTF2Export=e})(BABYLON||(BABYLON={})),(function(W){var e;(function(z){var e=(function(){function u(e,t){this._extensions={},this._asset={generator:"BabylonJS",version:"2.0"},this._extensionsUsed=[],this._extensionsRequired=[],this._babylonScene=e,this._bufferViews=[],this._accessors=[],this._meshes=[],this._scenes=[],this._nodes=[],this._images=[],this._materials=[],this._materialMap=[],this._textures=[],this._samplers=[],this._animations=[],this._imageData={},this._convertToRightHandedSystem=!this._babylonScene.useRightHandedSystem;var r=t||{};this._shouldExportTransformNode=r.shouldExportTransformNode?r.shouldExportTransformNode:function(e){return!0},this._animationSampleRate=r.animationSampleRate?r.animationSampleRate:1/60,this._glTFMaterialExporter=new z._GLTFMaterialExporter(this),this._loadExtensions()}return u.prototype._applyExtensions=function(e,t){for(var r=0,n=u._ExtensionNames;r=e.verticesStart;--f)c=f*l,u.push(W.Vector4.FromArray(a,c));break;case W.VertexBuffer.ColorKind:for(f=e.verticesStart+e.verticesCount-1;f>=e.verticesStart;--f)c=f*l,4===s.getSize()?u.push(W.Vector4.FromArray(a,c)):u.push(W.Vector3.FromArray(a,c));break;case W.VertexBuffer.UVKind:case W.VertexBuffer.UV2Kind:for(f=e.verticesStart+e.verticesCount-1;f>=e.verticesStart;--f)c=f*l,u.push(W.Vector2.FromArray(a,c));break;default:W.Tools.Error("Unsupported Vertex Buffer type: "+n)}this.writeVertexAttributeData(u,i+12,n,a,o)}else W.Tools.Warn("reorderTriangleStripDrawMode: Vertex buffer kind "+n+" not present!")},u.prototype.reorderTriangleFanMode=function(e,t,r,n,a,i,o){var s=this.getVertexBufferFromMesh(n,e.getMesh());if(s){var l=s.byteStride/W.VertexBuffer.GetTypeByteLength(s.type),u=[],c=0;switch(n){case W.VertexBuffer.PositionKind:case W.VertexBuffer.NormalKind:for(var f=e.verticesStart+e.verticesCount-1;f>=e.verticesStart;--f)c=f*l,u.push(W.Vector3.FromArray(a,c));break;case W.VertexBuffer.TangentKind:for(f=e.verticesStart+e.verticesCount-1;f>=e.verticesStart;--f)c=f*l,u.push(W.Vector4.FromArray(a,c));break;case W.VertexBuffer.ColorKind:for(f=e.verticesStart+e.verticesCount-1;f>=e.verticesStart;--f)c=f*l,u.push(W.Vector4.FromArray(a,c)),4===s.getSize()?u.push(W.Vector4.FromArray(a,c)):u.push(W.Vector3.FromArray(a,c));break;case W.VertexBuffer.UVKind:case W.VertexBuffer.UV2Kind:for(f=e.verticesStart+e.verticesCount-1;f>=e.verticesStart;--f)c=f*l,u.push(W.Vector2.FromArray(a,c));break;default:W.Tools.Error("Unsupported Vertex Buffer type: "+n)}this.writeVertexAttributeData(u,i,n,a,o)}else W.Tools.Warn("reorderTriangleFanMode: Vertex buffer kind "+n+" not present!")},u.prototype.writeVertexAttributeData=function(e,t,r,n,a){for(var i=0,o=e;ithis._arrayBuffer.byteLength&&this.resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setUint8(this._byteOffset++,e))},e.prototype.getUInt32=function(e){if(ethis._byteOffset?W.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(e.x=this._dataView.getFloat32(t,!0),e.y=this._dataView.getFloat32(t+4,!0),e.z=this._dataView.getFloat32(t+8,!0))},e.prototype.setVector3Float32FromRef=function(e,t){t+8>this._byteOffset?W.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(this._dataView.setFloat32(t,e.x,!0),this._dataView.setFloat32(t+4,e.y,!0),this._dataView.setFloat32(t+8,e.z,!0))},e.prototype.getVector4Float32FromRef=function(e,t){t+12>this._byteOffset?W.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(e.x=this._dataView.getFloat32(t,!0),e.y=this._dataView.getFloat32(t+4,!0),e.z=this._dataView.getFloat32(t+8,!0),e.w=this._dataView.getFloat32(t+12,!0))},e.prototype.setVector4Float32FromRef=function(e,t){t+12>this._byteOffset?W.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(this._dataView.setFloat32(t,e.x,!0),this._dataView.setFloat32(t+4,e.y,!0),this._dataView.setFloat32(t+8,e.z,!0),this._dataView.setFloat32(t+12,e.w,!0))},e.prototype.setFloat32=function(e,t){isNaN(e)&&W.Tools.Error("Invalid data being written!"),null!=t&&(tthis._arrayBuffer.byteLength&&this.resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setFloat32(this._byteOffset,e,!0),this._byteOffset+=4},e.prototype.setUInt32=function(e,t){null!=t?tthis._arrayBuffer.byteLength&&this.resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setUint32(this._byteOffset,e,!0),this._byteOffset+=4)},e})();z._BinaryWriter=r})((e=W.GLTF2||(W.GLTF2={})).Exporter||(e.Exporter={}))})(BABYLON||(BABYLON={})),(function(e){var t=(function(){function e(){this.glTFFiles={}}return e.prototype.downloadFiles=function(){function e(e,t){return-1!==e.indexOf(t,e.length-t.length)}for(var t in this.glTFFiles){var r=document.createElement("a");document.body.appendChild(r),r.setAttribute("type","hidden"),r.download=t;var n=this.glTFFiles[t],a=void 0;e(t,".glb")?a={type:"model/gltf-binary"}:e(t,".bin")?a={type:"application/octet-stream"}:e(t,".gltf")?a={type:"model/gltf+json"}:e(t,".jpeg")?a={type:"image/jpeg"}:e(t,".png")&&(a={type:"image/png"}),r.href=window.URL.createObjectURL(new Blob([n],a)),r.click()}},e})();e.GLTFData=t})(BABYLON||(BABYLON={})),(function(L){var e,t,r;e=L.GLTF2||(L.GLTF2={}),t=e.Exporter||(e.Exporter={}),r=(function(){function C(e){this._textureMap={},this._textureMap={},this._exporter=e}return C.FuzzyEquals=function(e,t,r){return L.Scalar.WithinEpsilon(e.r,t.r,r)&&L.Scalar.WithinEpsilon(e.g,t.g,r)&&L.Scalar.WithinEpsilon(e.b,t.b,r)},C.prototype._convertMaterialsToGLTFAsync=function(e,t,r){for(var n=[],a=0,i=e;ao.width?(a=t&&t instanceof L.Texture?L.TextureTools.CreateResizedCopy(t,i.width,i.height,!0):this._createWhiteTexture(i.width,i.height,r),n=e):(n=e,a=t),{texture1:n,texture2:a}},C.prototype._convertPixelArrayToFloat32=function(e){if(e instanceof Uint8Array){for(var t=e.length,r=new Float32Array(e.length),n=0;nC._Epsilon?E.baseColor.r:1,g[S+1]/=E.baseColor.g>C._Epsilon?E.baseColor.g:1,g[S+2]/=E.baseColor.b>C._Epsilon?E.baseColor.b:1;var V=L.Color3.FromInts(g[S],g[S+1],g[S+2]).toGammaSpace();g[S]=255*V.r,g[S+1]=255*V.g,g[S+2]=255*V.b,C.FuzzyEquals(V,L.Color3.White(),C._Epsilon)||(R=!0),m[S+1]/=E.roughness>C._Epsilon?E.roughness:1,m[S+2]/=E.metallic>C._Epsilon?E.metallic:1;var B=L.Color3.FromInts(255,m[S+1],m[S+2]);C.FuzzyEquals(B,L.Color3.White(),C._Epsilon)||(M=!0)}if(M){var w=this._createBase64FromCanvasAsync(m,c,f,n).then((function(e){E.metallicRoughnessTextureBase64=e}));a.push(w)}return R&&(w=this._createBase64FromCanvasAsync(g,c,f,n).then((function(e){E.baseColorTextureBase64=e})),a.push(w)),Promise.all(a).then((function(){return E}))}return Promise.reject("_ConvertSpecularGlossinessTexturesToMetallicRoughness: Scene from textures is missing!")},C.prototype._convertSpecularGlossinessToMetallicRoughness=function(e){var t=this._getPerceivedBrightness(e.diffuseColor),r=this._getPerceivedBrightness(e.specularColor),n=1-this._getMaxComponent(e.specularColor),a=C._SolveMetallic(t,r,n),i=e.diffuseColor.scale(n/(1-C._DielectricSpecular.r)/Math.max(1-a,C._Epsilon)),o=e.specularColor.subtract(C._DielectricSpecular.scale(1-a)).scale(1/Math.max(a,C._Epsilon)),s=L.Color3.Lerp(i,o,a*a);return{baseColor:s=s.clampToRef(0,1,s),metallic:a,roughness:1-e.glossiness}},C.prototype._getPerceivedBrightness=function(e){return e?Math.sqrt(.299*e.r*e.r+.587*e.g*e.g+.114*e.b*e.b):0},C.prototype._getMaxComponent=function(e){return e?Math.max(e.r,Math.max(e.g,e.b)):0},C.prototype._convertMetalRoughFactorsToMetallicRoughnessAsync=function(e,t,r,n){var a=[],i={baseColor:e.albedoColor,metallic:e.metallic,roughness:e.roughness};return n&&(e.albedoTexture&&a.push(this._exportTextureAsync(e.albedoTexture,t).then((function(e){e&&(r.baseColorTexture=e)}))),e.metallicTexture&&a.push(this._exportTextureAsync(e.metallicTexture,t).then((function(e){e&&(r.metallicRoughnessTexture=e)})))),Promise.all(a).then((function(){return i}))},C.prototype._getGLTFTextureSampler=function(e){var t=this._getGLTFTextureWrapModesSampler(e),r=e instanceof L.Texture?e.samplingMode:null;if(null!=r)switch(r){case L.Texture.LINEAR_LINEAR:t.magFilter=9729,t.minFilter=9729;break;case L.Texture.LINEAR_NEAREST:t.magFilter=9729,t.minFilter=9728;break;case L.Texture.NEAREST_LINEAR:t.magFilter=9728,t.minFilter=9729;break;case L.Texture.NEAREST_LINEAR_MIPLINEAR:t.magFilter=9728,t.minFilter=9987;break;case L.Texture.NEAREST_NEAREST:t.magFilter=9728,t.minFilter=9728;break;case L.Texture.NEAREST_LINEAR_MIPNEAREST:t.magFilter=9728,t.minFilter=9985;break;case L.Texture.LINEAR_NEAREST_MIPNEAREST:t.magFilter=9729,t.minFilter=9984;break;case L.Texture.LINEAR_NEAREST_MIPLINEAR:t.magFilter=9729,t.minFilter=9986;break;case L.Texture.NEAREST_NEAREST_MIPLINEAR:t.magFilter=9728,t.minFilter=9986;break;case L.Texture.LINEAR_LINEAR_MIPLINEAR:t.magFilter=9729,t.minFilter=9987;break;case L.Texture.LINEAR_LINEAR_MIPNEAREST:t.magFilter=9729,t.minFilter=9985;break;case L.Texture.NEAREST_NEAREST_MIPNEAREST:t.magFilter=9728,t.minFilter=9984}return t},C.prototype._getGLTFTextureWrapMode=function(e){switch(e){case L.Texture.WRAP_ADDRESSMODE:return 10497;case L.Texture.CLAMP_ADDRESSMODE:return 33071;case L.Texture.MIRROR_ADDRESSMODE:return 33648;default:return L.Tools.Error("Unsupported Texture Wrap Mode "+e+"!"),10497}},C.prototype._getGLTFTextureWrapModesSampler=function(e){var t=this._getGLTFTextureWrapMode(e instanceof L.Texture?e.wrapU:L.Texture.WRAP_ADDRESSMODE),r=this._getGLTFTextureWrapMode(e instanceof L.Texture?e.wrapV:L.Texture.WRAP_ADDRESSMODE);return 10497===t&&10497===r?{}:{wrapS:t,wrapT:r}},C.prototype._convertSpecGlossFactorsToMetallicRoughnessAsync=function(i,o,s,l){var u=this;return Promise.resolve().then((function(){var e=u._exporter._samplers,n=u._exporter._textures,t={diffuseColor:i.albedoColor||L.Color3.White(),specularColor:i.reflectivityColor||L.Color3.White(),glossiness:i.microSurface||1},a=null,r=u._getGLTFTextureSampler(i.albedoTexture);return null!=r.magFilter&&null!=r.minFilter&&null!=r.wrapS&&null!=r.wrapT&&(e.push(r),a=e.length-1),i.reflectivityTexture&&!i.useMicroSurfaceFromReflectivityMapAlpha?Promise.reject("_ConvertPBRMaterial: Glossiness values not included in the reflectivity texture are currently not supported"):(i.albedoTexture||i.reflectivityTexture)&&l?u._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(i.albedoTexture,i.reflectivityTexture,t,o).then((function(e){if(e.baseColorTextureBase64){var t=u._getTextureInfoFromBase64(e.baseColorTextureBase64,"bjsBaseColorTexture_"+n.length+".png",o,i.albedoTexture?i.albedoTexture.coordinatesIndex:null,a);t&&(s.baseColorTexture=t)}if(e.metallicRoughnessTextureBase64){var r=u._getTextureInfoFromBase64(e.metallicRoughnessTextureBase64,"bjsMetallicRoughnessTexture_"+n.length+".png",o,i.reflectivityTexture?i.reflectivityTexture.coordinatesIndex:null,a);r&&(s.metallicRoughnessTexture=r)}return e})):u._convertSpecularGlossinessToMetallicRoughness(t)}))},C.prototype._convertPBRMaterialAsync=function(t,r,n){var a=this,i={},o={name:t.name};return t.isMetallicWorkflow()?(t.albedoColor&&(i.baseColorFactor=[t.albedoColor.r,t.albedoColor.g,t.albedoColor.b,t.alpha]),this._convertMetalRoughFactorsToMetallicRoughnessAsync(t,r,i,n).then((function(e){return a.setMetallicRoughnessPbrMaterial(e,t,o,i,r,n)}))):this._convertSpecGlossFactorsToMetallicRoughnessAsync(t,r,i,n).then((function(e){return a.setMetallicRoughnessPbrMaterial(e,t,o,i,r,n)}))},C.prototype.setMetallicRoughnessPbrMaterial=function(e,r,n,t,a,i){var o=this._exporter._materialMap,s=this._exporter._materials,l=[];if(e){var u=null;if(null!=r.transparencyMode&&(u=this._getAlphaMode(r))&&"OPAQUE"!==u&&"MASK"===(n.alphaMode=u)&&(n.alphaCutoff=r.alphaCutOff),C.FuzzyEquals(e.baseColor,L.Color3.White(),C._Epsilon)&&r.alpha>=C._Epsilon||(t.baseColorFactor=[e.baseColor.r,e.baseColor.g,e.baseColor.b,r.alpha]),null!=e.metallic&&1!==e.metallic&&(t.metallicFactor=e.metallic),null!=e.roughness&&1!==e.roughness&&(t.roughnessFactor=e.roughness),null==r.backFaceCulling||r.backFaceCulling||(r.twoSidedLighting||L.Tools.Warn(r.name+": Back-face culling enabled and two-sided lighting disabled is not supported in glTF."),n.doubleSided=!0),i){if(r.bumpTexture){var c=this._exportTextureAsync(r.bumpTexture,a).then((function(e){e&&(n.normalTexture=e,1!==r.bumpTexture.level&&(n.normalTexture.scale=r.bumpTexture.level))}));l.push(c)}r.ambientTexture&&(c=this._exportTextureAsync(r.ambientTexture,a).then((function(e){if(e){var t={index:e.index};n.occlusionTexture=t,r.ambientTextureStrength&&(t.strength=r.ambientTextureStrength)}})),l.push(c)),r.emissiveTexture&&(c=this._exportTextureAsync(r.emissiveTexture,a).then((function(e){e&&(n.emissiveTexture=e)})),l.push(c))}C.FuzzyEquals(r.emissiveColor,L.Color3.Black(),C._Epsilon)||(n.emissiveFactor=r.emissiveColor.asArray()),n.pbrMetallicRoughness=t,s.push(n),o[r.uniqueId]=s.length-1}return Promise.all(l).then((function(e){}))},C.prototype.getPixelsFromTexture=function(e){return e.textureType,L.Engine.TEXTURETYPE_UNSIGNED_INT,e.readPixels()},C.prototype._exportTextureAsync=function(t,r){var n=this,e=this._exporter._extensionsPreExportTextureAsync("exporter",t,r);return e?e.then((function(e){return e?n._exportTextureInfoAsync(e,r):n._exportTextureInfoAsync(t,r)})):this._exportTextureInfoAsync(t,r)},C.prototype._exportTextureInfoAsync=function(u,c){var f=this;return Promise.resolve().then((function(){var r=u.uid;if(r in f._textureMap)return f._textureMap[r];for(var e=f._exporter._samplers,t=f._getGLTFTextureSampler(u),n=null,a=null,i=0;il[f]&&(l[f]=h),++a}}return{min:s,max:l}},p._GetRightHandedPositionVector3=function(e){return new d.Vector3(e.x,e.y,-e.z)},p._GetRightHandedPositionVector3FromRef=function(e){e.z*=-1},p._GetRightHandedPositionArray3FromRef=function(e){e[2]*=-1},p._GetRightHandedNormalVector3=function(e){return new d.Vector3(e.x,e.y,-e.z)},p._GetRightHandedNormalVector3FromRef=function(e){e.z*=-1},p._GetRightHandedNormalArray3FromRef=function(e){e[2]*=-1},p._GetRightHandedVector4FromRef=function(e){e.z*=-1,e.w*=-1},p._GetRightHandedArray4FromRef=function(e){e[2]*=-1,e[3]*=-1},p._GetRightHandedQuaternionFromRef=function(e){e.x*=-1,e.y*=-1},p._GetRightHandedQuaternionArrayFromRef=function(e){e[0]*=-1,e[1]*=-1},p._NormalizeTangentFromRef=function(e){var t=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z);0