text: !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-serializers",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-serializers"]=t(require("babylonjs")):e.SERIALIZERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=13)}([function(t,r){t.exports=e},function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(0),a=function(){function e(){}return e._CreateBufferView=function(e,t,r,n,a){var i={buffer:e,byteLength:r};return t&&(i.byteOffset=t),a&&(i.name=a),n&&(i.byteStride=n),i},e._CreateAccessor=function(e,t,r,n,a,i,o,s){var u={name:t,bufferView:e,componentType:n,count:a,type:r};return null!=o&&(u.min=o),null!=s&&(u.max=s),null!=i&&(u.byteOffset=i),u},e._CalculateMinMaxPositions=function(t,r,a,i){var o,s,u,l=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];if(a)for(var f=r,h=r+a;f<h;++f){o=3*f,s=n.Vector3.FromArray(t,o),i&&e._GetRightHandedPositionVector3FromRef(s),u=s.asArray();for(var p=0;p<3;++p){var d=u[p];d<l[p]&&(l[p]=d),d>c[p]&&(c[p]=d),++o}}return{min:l,max:c}},e._GetRightHandedPositionVector3=function(e){return new n.Vector3(e.x,e.y,-e.z)},e._GetRightHandedPositionVector3FromRef=function(e){e.z*=-1},e._GetRightHandedPositionArray3FromRef=function(e){e[2]*=-1},e._GetRightHandedNormalVector3=function(e){return new n.Vector3(e.x,e.y,-e.z)},e._GetRightHandedNormalVector3FromRef=function(e){e.z*=-1},e._GetRightHandedNormalArray3FromRef=function(e){e[2]*=-1},e._GetRightHandedVector4FromRef=function(e){e.z*=-1,e.w*=-1},e._GetRightHandedArray4FromRef=function(e){e[2]*=-1,e[3]*=-1},e._GetRightHandedQuaternionFromRef=function(e){e.x*=-1,e.y*=-1},e._GetRightHandedQuaternionArrayFromRef=function(e){e[0]*=-1,e[1]*=-1},e._NormalizeTangentFromRef=function(e){var t=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z);t>0&&(e.x/=t,e.y/=t,e.z/=t)},e._GetRightHandedMatrixFromRef=function(e){var t=e.m;n.Matrix.FromValuesToRef(t[0],t[1],-t[2],t[3],t[4],t[5],-t[6],t[7],-t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15],e)},e._GetDataAccessorElementCount=function(e){switch(e){case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":return 4}},e}()},function(e,t,r){"use strict";r.d(t,"b",(function(){return u})),r.d(t,"a",(function(){return l}));Object.create;Object.create;var n=r(0),a=r(10),i=r(1),o=r(3),s=r(7),u=function(){function e(e,t){this._includeCoordinateSystemConversionNodes=!1,this._extensions={},this._glTF={asset:{generator:"BabylonJS",version:"2.0"}},this._babylonScene=e,this._bufferViews=[],this._accessors=[],this._meshes=[],this._scenes=[],this._nodes=[],this._images=[],this._materials=[],this._materialMap=[],this._textures=[],this._samplers=[],this._skins=[],this._animations=[],this._imageData={},this._orderedImageData=[],this._options=t||{},this._animationSampleRate=t&&t.animationSampleRate?t.animationSampleRate:1/60,this._includeCoordinateSystemConversionNodes=!(!t||!t.includeCoordinateSystemConversionNodes),this._glTFMaterialExporter=new a.a(this),this._loadExtensions()}return e.prototype._applyExtension=function(e,t,r,n){var a=this;if(r>=t.length)return Promise.resolve(e);var i=n(t[r],e);return i?i.then((function(e){return a._applyExtension(e,t,r+1,n)})):this._applyExtension(e,t,r+1,n)},e.prototype._applyExtensions=function(t,r){for(var n=[],a=0,i=e._ExtensionNames;a<i.length;a++){var o=i[a];n.push(this._extensions[o])}return this._applyExtension(t,n,0,r)},e.prototype._extensionsPreExportTextureAsync=function(e,t,r){return this._applyExtensions(t,(function(t,n){return t.preExportTextureAsync&&t.preExportTextureAsync(e,n,r)}))},e.prototype._extensionsPostExportMeshPrimitiveAsync=function(e,t,r,n){return this._applyExtensions(t,(function(t,a){return t.postExportMeshPrimitiveAsync&&t.postExportMeshPrimitiveAsync(e,a,r,n)}))},e.prototype._extensionsPostExportNodeAsync=function(e,t,r,n){return this._applyExtensions(t,(function(t,a){return t.postExportNodeAsync&&t.postExportNodeAsync(e,a,r,n)}))},e.prototype._extensionsPostExportMaterialAsync=function(e,t,r){return this._applyExtensions(t,(function(t,n){return t.postExportMaterialAsync&&t.postExportMaterialAsync(e,n,r)}))},e.prototype._extensionsPostExportMaterialAdditionalTextures=function(t,r,n){for(var a=[],i=0,o=e._ExtensionNames;i<o.length;i++){var s=o[i],u=this._extensions[s];u.postExportMaterialAdditionalTextures&&a.push.apply(a,u.postExportMaterialAdditionalTextures(t,r,n))}return a},e.prototype._extensionsPostExportTextures=function(t,r,n){for(var a=0,i=e._ExtensionNames;a<i.length;a++){var o=i[a],s=this._extensions[o];s.postExportTexture&&s.postExportTexture(t,r,n)}},e.prototype._forEachExtensions=function(t){for(var r=0,n=e._ExtensionNames;r<n.length;r++){var a=n[r],i=this._extensions[a];i.enabled&&t(i)}},e.prototype._extensionsOnExporting=function(){var e=this;this._forEachExtensions((function(t){t.wasUsed&&(null==e._glTF.extensionsUsed&&(e._glTF.extensionsUsed=[]),-1===e._glTF.extensionsUsed.indexOf(t.name)&&e._glTF.extensionsUsed.push(t.name),t.required&&(null==e._glTF.extensionsRequired&&(e._glTF.extensionsRequired=[]),-1===e._glTF.extensionsRequired.indexOf(t.name)&&e._glTF.extensionsRequired.push(t.name)),null==e._glTF.extensions&&(e._glTF.extensions={}),t.onExporting&&t.onExporting())}))},e.prototype._loadExtensions=function(){for(var t=0,r=e._ExtensionNames;t<r.length;t++){var n=r[t],a=e._ExtensionFactories[n](this);this._extensions[n]=a}},e.prototype.dispose=function(){for(var e in this._extensions){this._extensions[e].dispose()}},e.RegisterExtension=function(t,r){e.UnregisterExtension(t)&&n.Tools.Warn("Extension with the name "+t+" already exists"),e._ExtensionFactories[t]=r,e._ExtensionNames.push(t)},e.UnregisterExtension=function(t){if(!e._ExtensionFactories[t])return!1;delete e._ExtensionFactories[t];var r=e._ExtensionNames.indexOf(t);return-1!==r&&e._ExtensionNames.splice(r,1),!0},e.prototype._getLocalEngine=function(){if(!this._localEngine){var e=document.createElement("canvas");e.id="WriteCanvas",e.width=2048,e.height=2048,this._localEngine=new n.Engine(e,!0,{premultipliedAlpha:n.Tools.IsSafari(),preserveDrawingBuffer:!0}),this._localEngine.setViewport(new n.Viewport(0,0,1,1))}return this._localEngine},e.prototype.reorderIndicesBasedOnPrimitiveMode=function(e,t,r,a,i){switch(t){case n.Material.TriangleFillMode:a||(a=0);for(var o=e.indexStart,s=e.indexStart+e.indexCount;o<s;o+=3){var u=a+4*o,l=i.getUInt32(u+4),c=i.getUInt32(u+8);i.setUInt32(c,u+4),i.setUInt32(l,u+8)}break;case n.Material.TriangleFanDrawMode:o=e.indexStart+e.indexCount-1;for(var f=e.indexStart;o>=f;--o)i.setUInt32(r[o],a),a+=4;break;case n.Material.TriangleStripDrawMode:e.indexCount>=3&&(i.setUInt32(r[e.indexStart+2],a+4),i.setUInt32(r[e.indexStart+1],a+8))}},e.prototype.reorderVertexAttributeDataBasedOnPrimitiveMode=function(e,t,r,a,i,o,s,u){if(u&&r===n.Material.ClockWiseSideOrientation)switch(t){case n.Material.TriangleFillMode:this.reorderTriangleFillMode(e,t,r,a,i,o,s,u);break;case n.Material.TriangleStripDrawMode:this.reorderTriangleStripDrawMode(e,t,r,a,i,o,s,u);break;case n.Material.TriangleFanDrawMode:this.reorderTriangleFanMode(e,t,r,a,i,o,s,u)}},e.prototype.reorderTriangleFillMode=function(e,t,r,a,i,o,s,u){var l=this.getVertexBufferFromMesh(a,e.getMesh());if(l){var c=l.byteStride/n.VertexBuffer.GetTypeByteLength(l.type);if(e.verticesCount%3!=0)n.Tools.Error("The submesh vertices for the triangle fill mode is not divisible by 3!");else{var f=[],h=0;switch(a){case n.VertexBuffer.PositionKind:case n.VertexBuffer.NormalKind:for(var p=e.verticesStart;p<e.verticesStart+e.verticesCount;p+=3)h=p*c,f.push(n.Vector3.FromArray(i,h)),f.push(n.Vector3.FromArray(i,h+2*c)),f.push(n.Vector3.FromArray(i,h+c));break;case n.VertexBuffer.TangentKind:for(p=e.verticesStart;p<e.verticesStart+e.verticesCount;p+=3)h=p*c,f.push(n.Vector4.FromArray(i,h)),f.push(n.Vector4.FromArray(i,h+2*c)),f.push(n.Vector4.FromArray(i,h+c));break;case n.VertexBuffer.ColorKind:var d=l.getSize();for(p=e.verticesStart;p<e.verticesStart+e.verticesCount;p+=d)h=p*c,4===d?(f.push(n.Vector4.FromArray(i,h)),f.push(n.Vector4.FromArray(i,h+2*c)),f.push(n.Vector4.FromArray(i,h+c))):(f.push(n.Vector3.FromArray(i,h)),f.push(n.Vector3.FromArray(i,h+2*c)),f.push(n.Vector3.FromArray(i,h+c)));break;case n.VertexBuffer.UVKind:case n.VertexBuffer.UV2Kind:for(p=e.verticesStart;p<e.verticesStart+e.verticesCount;p+=3)h=p*c,f.push(n.Vector2.FromArray(i,h)),f.push(n.Vector2.FromArray(i,h+2*c)),f.push(n.Vector2.FromArray(i,h+c));break;default:n.Tools.Error("Unsupported Vertex Buffer type: "+a)}this.writeVertexAttributeData(f,o,a,i,s,u)}}else n.Tools.Warn("reorderTriangleFillMode: Vertex Buffer Kind "+a+" not present!")},e.prototype.reorderTriangleStripDrawMode=function(e,t,r,a,i,o,s,u){var l=this.getVertexBufferFromMesh(a,e.getMesh());if(l){var c=l.byteStride/n.VertexBuffer.GetTypeByteLength(l.type),f=[],h=0;switch(a){case n.VertexBuffer.PositionKind:case n.VertexBuffer.NormalKind:h=e.verticesStart,f.push(n.Vector3.FromArray(i,h+2*c)),f.push(n.Vector3.FromArray(i,h+c));break;case n.VertexBuffer.TangentKind:for(var p=e.verticesStart+e.verticesCount-1;p>=e.verticesStart;--p)h=p*c,f.push(n.Vector4.FromArray(i,h));break;case n.VertexBuffer.ColorKind:for(p=e.verticesStart+e.verticesCount-1;p>=e.verticesStart;--p)h=p*c,4===l.getSize()?f.push(n.Vector4.FromArray(i,h)):f.push(n.Vector3.FromArray(i,h));break;case n.VertexBuffer.UVKind:case n.VertexBuffer.UV2Kind:for(p=e.verticesStart+e.verticesCount-1;p>=e.verticesStart;--p)h=p*c,f.push(n.Vector2.FromArray(i,h));break;default:n.Tools.Error("Unsupported Vertex Buffer type: "+a)}this.writeVertexAttributeData(f,o+12,a,i,s,u)}else n.Tools.Warn("reorderTriangleStripDrawMode: Vertex buffer kind "+a+" not present!")},e.prototype.reorderTriangleFanMode=function(e,t,r,a,i,o,s,u){var l=this.getVertexBufferFromMesh(a,e.getMesh());if(l){var c=l.byteStride/n.VertexBuffer.GetTypeByteLength(l.type),f=[],h=0;switch(a){case n.VertexBuffer.PositionKind:case n.VertexBuffer.NormalKind:for(var p=e.verticesStart+e.verticesCount-1;p>=e.verticesStart;--p)h=p*c,f.push(n.Vector3.FromArray(i,h));break;case n.VertexBuffer.TangentKind:for(p=e.verticesStart+e.verticesCount-1;p>=e.verticesStart;--p)h=p*c,f.push(n.Vector4.FromArray(i,h));break;case n.VertexBuffer.ColorKind:for(p=e.verticesStart+e.verticesCount-1;p>=e.verticesStart;--p)h=p*c,f.push(n.Vector4.FromArray(i,h)),4===l.getSize()?f.push(n.Vector4.FromArray(i,h)):f.push(n.Vector3.FromArray(i,h));break;case n.VertexBuffer.UVKind:case n.VertexBuffer.UV2Kind:for(p=e.verticesStart+e.verticesCount-1;p>=e.verticesStart;--p)h=p*c,f.push(n.Vector2.FromArray(i,h));break;default:n.Tools.Error("Unsupported Vertex Buffer type: "+a)}this.writeVertexAttributeData(f,o,a,i,s,u)}else n.Tools.Warn("reorderTriangleFanMode: Vertex buffer kind "+a+" not present!")},e.prototype.writeVertexAttributeData=function(e,t,r,a,o,s){for(var u=0,l=e;u<l.length;u++){var c=l[u];!s||r===n.VertexBuffer.ColorKind||c instanceof n.Vector2||(c instanceof n.Vector3?r===n.VertexBuffer.NormalKind?i.a._GetRightHandedNormalVector3FromRef(c):r===n.VertexBuffer.PositionKind?i.a._GetRightHandedPositionVector3FromRef(c):n.Tools.Error("Unsupported vertex attribute kind!"):i.a._GetRightHandedVector4FromRef(c)),r===n.VertexBuffer.NormalKind?c.normalize():r===n.VertexBuffer.TangentKind&&c instanceof n.Vector4&&i.a._NormalizeTangentFromRef(c);for(var f=0,h=c.asArray();f<h.length;f++){var p=h[f];o.setFloat32(p,t),t+=4}}},e.prototype.writeAttributeData=function(e,t,r,a,o,s,u){var l,c,f=[];switch(e){case n.VertexBuffer.PositionKind:for(var h=0,p=r.length/a;h<p;++h){l=h*a;var d=n.Vector3.FromArray(r,l);s&&i.a._GetRightHandedPositionVector3FromRef(d),f.push(d.asArray())}break;case n.VertexBuffer.NormalKind:h=0;for(var m=r.length/a;h<m;++h){l=h*a;d=n.Vector3.FromArray(r,l);s&&i.a._GetRightHandedNormalVector3FromRef(d),d.normalize(),f.push(d.asArray())}break;case n.VertexBuffer.TangentKind:h=0;for(var g=r.length/a;h<g;++h){l=h*a;d=n.Vector4.FromArray(r,l);s&&i.a._GetRightHandedVector4FromRef(d),i.a._NormalizeTangentFromRef(d),f.push(d.asArray())}break;case n.VertexBuffer.ColorKind:for(var _=u.material,x=!_||_ instanceof n.StandardMaterial,y=(d=3===a?new n.Color3:new n.Color4,h=0,r.length/a);h<y;++h)l=h*a,3===a?(n.Color3.FromArrayToRef(r,l,d),x&&d.toLinearSpaceToRef(d)):(n.Color4.FromArrayToRef(r,l,d),x&&d.toLinearSpaceToRef(d)),f.push(d.asArray());break;case n.VertexBuffer.UVKind:case n.VertexBuffer.UV2Kind:h=0;for(var T=r.length/a;h<T;++h)l=h*a,f.push([r[l],r[l+1]]);break;case n.VertexBuffer.MatricesIndicesKind:case n.VertexBuffer.MatricesIndicesExtraKind:h=0;for(var v=r.length/a;h<v;++h){l=h*a;d=n.Vector4.FromArray(r,l);f.push(d.asArray())}break;case n.VertexBuffer.MatricesWeightsKind:case n.VertexBuffer.MatricesWeightsExtraKind:h=0;for(var b=r.length/a;h<b;++h){l=h*a;d=n.Vector4.FromArray(r,l);f.push(d.asArray())}break;default:n.Tools.Warn("Unsupported Vertex Buffer Type: "+e),f=[]}switch(t){case 5121:c=o.setUInt8.bind(o);break;case 5123:c=o.setUInt16.bind(o);break;case 5125:c=o.setUInt32.bind(o);case 5126:c=o.setFloat32.bind(o);break;default:return void n.Tools.Warn("Unsupported Attribute Component kind: "+t)}for(var A=0,F=f;A<F.length;A++)for(var M=0,E=F[A];M<E.length;M++){c(E[M])}},e.prototype.writeMorphTargetAttributeData=function(e,t,r,a,o,s,u,l,c,f){var h,p,d=[],m=new n.Vector3,g=new n.Vector4(0,0,0,0);switch(e){case n.VertexBuffer.PositionKind:for(var _=r.verticesStart;_<r.verticesCount;++_){h=r.indexStart+_*u;var x=n.Vector3.FromArray(o,h);m=(y=n.Vector3.FromArray(s,h)).subtractToRef(x,m),c&&i.a._GetRightHandedPositionVector3FromRef(m),f&&(f.min.copyFromFloats(Math.min(m.x,f.min.x),Math.min(m.y,f.min.y),Math.min(m.z,f.min.z)),f.max.copyFromFloats(Math.max(m.x,f.max.x),Math.max(m.y,f.max.y),Math.max(m.z,f.max.z))),d.push(m.asArray())}break;case n.VertexBuffer.NormalKind:for(_=r.verticesStart;_<r.verticesCount;++_){h=r.indexStart+_*u,(x=n.Vector3.FromArray(o,h)).normalize(),(y=n.Vector3.FromArray(s,h)).normalize(),m=y.subtractToRef(x,m),c&&i.a._GetRightHandedNormalVector3FromRef(m),d.push(m.asArray())}break;case n.VertexBuffer.TangentKind:for(_=r.verticesStart;_<r.verticesCount;++_){h=r.indexStart+_*(u+1);x=n.Vector4.FromArray(o,h);i.a._NormalizeTangentFromRef(x);var y=n.Vector4.FromArray(s,h);i.a._NormalizeTangentFromRef(y),g=y.subtractToRef(x,g),c&&i.a._GetRightHandedVector4FromRef(g),d.push([g.x,g.y,g.z])}break;default:n.Tools.Warn("Unsupported Vertex Buffer Type: "+e),d=[]}switch(t){case 5121:p=l.setUInt8.bind(l);break;case 5123:p=l.setUInt16.bind(l);break;case 5125:p=l.setUInt32.bind(l);case 5126:p=l.setFloat32.bind(l);break;default:return void n.Tools.Warn("Unsupported Attribute Component kind: "+t)}for(var T=0,v=d;T<v.length;T++)for(var b=0,A=v[T];b<A.length;b++){p(A[b])}},e.prototype.generateJSON=function(e,t,r){var n,a,o,s=this,u={byteLength:this._totalByteLength},l=this._totalByteLength;return u.byteLength&&(this._glTF.buffers=[u]),this._nodes&&this._nodes.length&&(this._glTF.nodes=this._nodes),this._meshes&&this._meshes.length&&(this._glTF.meshes=this._meshes),this._scenes&&this._scenes.length&&(this._glTF.scenes=this._scenes,this._glTF.scene=0),this._bufferViews&&this._bufferViews.length&&(this._glTF.bufferViews=this._bufferViews),this._accessors&&this._accessors.length&&(this._glTF.accessors=this._accessors),this._animations&&this._animations.length&&(this._glTF.animations=this._animations),this._materials&&this._materials.length&&(this._glTF.materials=this._materials),this._textures&&this._textures.length&&(this._glTF.textures=this._textures),this._samplers&&this._samplers.length&&(this._glTF.samplers=this._samplers),this._skins&&this._skins.length&&(this._glTF.skins=this._skins),this._images&&this._images.length&&(e?(this._glTF.images=[],this._images.forEach((function(e){e.uri&&(a=s._imageData[e.uri],s._orderedImageData.push(a),n=e.uri.split(".")[0]+" image",o=i.a._CreateBufferView(0,l,a.data.length,void 0,n),l+=a.data.buffer.byteLength,s._bufferViews.push(o),e.bufferView=s._bufferViews.length-1,e.name=n,e.mimeType=a.mimeType,e.uri=void 0,s._glTF.images||(s._glTF.images=[]),s._glTF.images.push(e))})),u.byteLength=l):this._glTF.images=this._images),e||(u.uri=t+".bin"),r?JSON.stringify(this._glTF,null,2):JSON.stringify(this._glTF)},e.prototype._generateGLTFAsync=function(e,t){var r=this;return void 0===t&&(t=!0),this._generateBinaryAsync().then((function(n){r._extensionsOnExporting();var a=r.generateJSON(!1,e,!0),i=new Blob([n],{type:"application/octet-stream"}),s=e+".gltf",u=e+".bin",l=new o.GLTFData;if(l.glTFFiles[s]=a,l.glTFFiles[u]=i,r._imageData)for(var c in r._imageData)l.glTFFiles[c]=new Blob([r._imageData[c].data],{type:r._imageData[c].mimeType});return t&&r.dispose(),l}))},e.prototype._generateBinaryAsync=function(){var e=this,t=new l(4);return this.createSceneAsync(this._babylonScene,t).then((function(){return e._localEngine&&e._localEngine.dispose(),t.getArrayBuffer()}))},e.prototype._getPadding=function(e){var t=e%4;return 0===t?t:4-t},e.prototype._generateGLBAsync=function(e,t){var r=this;return void 0===t&&(t=!0),this._generateBinaryAsync().then((function(n){r._extensionsOnExporting();for(var a=r.generateJSON(!0),i=e+".glb",s=a.length,u=0,l=0;l<r._orderedImageData.length;++l)u+=r._orderedImageData[l].data.byteLength;var c=r._getPadding(s),f=r._getPadding(n.byteLength),h=r._getPadding(u),p=28+s+c+n.byteLength+f+u+h,d=new ArrayBuffer(12),m=new DataView(d);m.setUint32(0,1179937895,!0),m.setUint32(4,2,!0),m.setUint32(8,p,!0);var g=new ArrayBuffer(8+s+c),_=new DataView(g);_.setUint32(0,s+c,!0),_.setUint32(4,1313821514,!0);var x=new Uint8Array(g,8);for(l=0;l<s;++l)x[l]=a.charCodeAt(l);var y=new Uint8Array(g,8+s);for(l=0;l<c;++l)y[l]=32;var T=new ArrayBuffer(8),v=new DataView(T);v.setUint32(0,n.byteLength+u+h,!0),v.setUint32(4,5130562,!0);var b=new ArrayBuffer(f),A=new Uint8Array(b);for(l=0;l<f;++l)A[l]=0;var F=new ArrayBuffer(h),M=new Uint8Array(F);for(l=0;l<h;++l)M[l]=0;var E=[d,g,T,n];for(l=0;l<r._orderedImageData.length;++l)E.push(r._orderedImageData[l].data.buffer);E.push(b),E.push(F);var R=new Blob(E,{type:"application/octet-stream"}),V=new o.GLTFData;return V.glTFFiles[i]=R,null!=r._localEngine&&r._localEngine.dispose(),t&&r.dispose(),V}))},e.prototype.setNodeTransformation=function(e,t,r){t.getPivotPoint().equalsToFloats(0,0,0)||n.Tools.Warn("Pivot points are not supported in the glTF serializer"),t.position.equalsToFloats(0,0,0)||(e.translation=r?i.a._GetRightHandedPositionVector3(t.position).asArray():t.position.asArray()),t.scaling.equalsToFloats(1,1,1)||(e.scale=t.scaling.asArray());var a=n.Quaternion.RotationYawPitchRoll(t.rotation.y,t.rotation.x,t.rotation.z);t.rotationQuaternion&&a.multiplyInPlace(t.rotationQuaternion),0===a.x&&0===a.y&&0===a.z&&1===a.w||(r&&i.a._GetRightHandedQuaternionFromRef(a),e.rotation=a.normalize().asArray())},e.prototype.getVertexBufferFromMesh=function(e,t){if(t.isVerticesDataPresent(e)){var r=t.getVertexBuffer(e);if(r)return r}return null},e.prototype.createBufferViewKind=function(e,t,r,a,o,s){var u=r instanceof n.Mesh?r:r instanceof n.InstancedMesh?r.sourceMesh:null;if(u){var l=u.getVertexBuffer(e),c=u.getVerticesData(e);if(l&&c){var f=n.VertexBuffer.GetTypeByteLength(t),h=c.length*f,p=i.a._CreateBufferView(0,a.getByteOffset(),h,o,e+" - "+u.name);this._bufferViews.push(p),this.writeAttributeData(e,t,c,o/f,a,s,r)}}},e.prototype.setMorphTargetAttributes=function(e,t,r,a,o){if(r){t.targets||(t.targets=[]);var s={};if(r.hasNormals){var u=e.getMesh().getVerticesData(n.VertexBuffer.NormalKind),l=r.getNormals(),c=(_=e.verticesCount)*(x=12),f=i.a._CreateBufferView(0,a.getByteOffset(),c,x,r.name+"_NORMAL");this._bufferViews.push(f);var h=this._bufferViews.length-1,p=i.a._CreateAccessor(h,r.name+" - NORMAL","VEC3",5126,_,0,null,null);this._accessors.push(p),s.NORMAL=this._accessors.length-1,this.writeMorphTargetAttributeData(n.VertexBuffer.NormalKind,5126,e,r,u,l,x/4,a,o)}if(r.hasPositions){var d=e.getMesh().getVerticesData(n.VertexBuffer.PositionKind),m=r.getPositions();c=(_=e.verticesCount)*(x=12),f=i.a._CreateBufferView(0,a.getByteOffset(),c,x,r.name+"_POSITION");this._bufferViews.push(f);h=this._bufferViews.length-1;var g={min:new n.Vector3(1/0,1/0,1/0),max:new n.Vector3(-1/0,-1/0,-1/0)};p=i.a._CreateAccessor(h,r.name+" - POSITION","VEC3",5126,_,0,null,null);this._accessors.push(p),s.POSITION=this._accessors.length-1,this.writeMorphTargetAttributeData(n.VertexBuffer.PositionKind,5126,e,r,d,m,x/4,a,o,g),p.min=g.min.asArray(),p.max=g.max.asArray()}if(r.hasTangents){var _,x,y=e.getMesh().getVerticesData(n.VertexBuffer.TangentKind),T=r.getTangents();c=(_=e.verticesCount)*(x=12),f=i.a._CreateBufferView(0,a.getByteOffset(),c,x,r.name+"_NORMAL");this._bufferViews.push(f);h=this._bufferViews.length-1,p=i.a._CreateAccessor(h,r.name+" - TANGENT","VEC3",5126,_,0,null,null);this._accessors.push(p),s.TANGENT=this._accessors.length-1,this.writeMorphTargetAttributeData(n.VertexBuffer.TangentKind,5126,e,r,y,T,x/4,a,o)}t.targets.push(s)}},e.prototype.getMeshPrimitiveMode=function(e){return e instanceof n.LinesMesh?n.Material.LineListDrawMode:e.material?e.material.fillMode:n.Material.TriangleFillMode},e.prototype.setPrimitiveMode=function(e,t){switch(t){case n.Material.TriangleFillMode:break;case n.Material.TriangleStripDrawMode:e.mode=5;break;case n.Material.TriangleFanDrawMode:e.mode=6;break;case n.Material.PointListDrawMode:e.mode=0;case n.Material.PointFillMode:e.mode=0;break;case n.Material.LineLoopDrawMode:e.mode=2;break;case n.Material.LineListDrawMode:e.mode=1;break;case n.Material.LineStripDrawMode:e.mode=3}},e.prototype.setAttributeKind=function(e,t){switch(t){case n.VertexBuffer.PositionKind:e.attributes.POSITION=this._accessors.length-1;break;case n.VertexBuffer.NormalKind:e.attributes.NORMAL=this._accessors.length-1;break;case n.VertexBuffer.ColorKind:e.attributes.COLOR_0=this._accessors.length-1;break;case n.VertexBuffer.TangentKind:e.attributes.TANGENT=this._accessors.length-1;break;case n.VertexBuffer.UVKind:e.attributes.TEXCOORD_0=this._accessors.length-1;break;case n.VertexBuffer.UV2Kind:e.attributes.TEXCOORD_1=this._accessors.length-1;break;case n.VertexBuffer.MatricesIndicesKind:e.attributes.JOINTS_0=this._accessors.length-1;break;case n.VertexBuffer.MatricesIndicesExtraKind:e.attributes.JOINTS_1=this._accessors.length-1;break;case n.VertexBuffer.MatricesWeightsKind:e.attributes.WEIGHTS_0=this._accessors.length-1;break;case n.VertexBuffer.MatricesWeightsExtraKind:e.attributes.WEIGHTS_1=this._accessors.length-1;break;default:n.Tools.Warn("Unsupported Vertex Buffer Type: "+t)}},e.prototype.setPrimitiveAttributesAsync=function(e,t,r,a){var o,s,u,l=[],c=null;t instanceof n.Mesh?c=t:t instanceof n.InstancedMesh&&(c=t.sourceMesh);var f=[{kind:n.VertexBuffer.PositionKind,accessorType:"VEC3",accessorComponentType:5126,byteStride:12},{kind:n.VertexBuffer.NormalKind,accessorType:"VEC3",accessorComponentType:5126,byteStride:12},{kind:n.VertexBuffer.ColorKind,accessorType:"VEC4",accessorComponentType:5126,byteStride:16},{kind:n.VertexBuffer.TangentKind,accessorType:"VEC4",accessorComponentType:5126,byteStride:16},{kind:n.VertexBuffer.UVKind,accessorType:"VEC2",accessorComponentType:5126,byteStride:8},{kind:n.VertexBuffer.UV2Kind,accessorType:"VEC2",accessorComponentType:5126,byteStride:8},{kind:n.VertexBuffer.MatricesIndicesKind,accessorType:"VEC4",accessorComponentType:5123,byteStride:8},{kind:n.VertexBuffer.MatricesIndicesExtraKind,accessorType:"VEC4",accessorComponentType:5123,byteStride:8},{kind:n.VertexBuffer.MatricesWeightsKind,accessorType:"VEC4",accessorComponentType:5126,byteStride:16},{kind:n.VertexBuffer.MatricesWeightsExtraKind,accessorType:"VEC4",accessorComponentType:5126,byteStride:16}];if(c){for(var h=null,p=this.getMeshPrimitiveMode(c),d={},m=c.morphTargetManager,g=0,_=f;g<_.length;g++){var x=(W=_[g]).kind,y=W.accessorComponentType;if(c.isVerticesDataPresent(x)){var T=this.getVertexBufferFromMesh(x,c);W.byteStride=T?T.getSize()*n.VertexBuffer.GetTypeByteLength(W.accessorComponentType):4*n.VertexBuffer.DeduceStride(x),12===W.byteStride&&(W.accessorType="VEC3"),this.createBufferViewKind(x,y,t,r,W.byteStride,a),W.bufferViewIndex=this._bufferViews.length-1,d[x]=W.bufferViewIndex}}if(c.getTotalIndices()){var v=c.getIndices();if(v){var b=4*v.length;s=i.a._CreateBufferView(0,r.getByteOffset(),b,void 0,"Indices - "+c.name),this._bufferViews.push(s),h=this._bufferViews.length-1;for(var A=0,F=v.length;A<F;++A)r.setUInt32(v[A])}}if(c.subMeshes)for(var M=0,E=c.subMeshes;M<E.length;M++){var R=E[M],V=R.getMaterial()||c.getScene().defaultMaterial,S=null;if(V)if(c instanceof n.LinesMesh){var w={name:c.name+" material"};(!c.color.equals(n.Color3.White())||c.alpha<1)&&(w.pbrMetallicRoughness={baseColorFactor:c.color.asArray().concat([c.alpha])}),this._materials.push(w),S=this._materials.length-1}else if(V instanceof n.MultiMaterial){var C=V.subMaterials[R.materialIndex];C&&(V=C,S=this._materialMap[V.uniqueId])}else S=this._materialMap[V.uniqueId];var B=null!=S?this._materials[S]:null,I={attributes:{}};this.setPrimitiveMode(I,p);for(var P=0,N=f;P<N.length;P++){if((x=(W=N[P]).kind)!==n.VertexBuffer.UVKind&&x!==n.VertexBuffer.UV2Kind||!B||this._glTFMaterialExporter._hasTexturesPresent(B))if(z=c.getVerticesData(x))if(T=this.getVertexBufferFromMesh(x,c)){var L=T.getSize(),O=W.bufferViewIndex;if(null!=O){u={min:null,max:null},x==n.VertexBuffer.PositionKind&&(u=i.a._CalculateMinMaxPositions(z,0,z.length/L,a));var G=i.a._CreateAccessor(O,x+" - "+t.name,W.accessorType,W.accessorComponentType,z.length/L,0,u.min,u.max);this._accessors.push(G),this.setAttributeKind(I,x)}}}if(h){G=i.a._CreateAccessor(h,"indices - "+t.name,"SCALAR",5125,R.indexCount,4*R.indexStart,null,null);this._accessors.push(G),I.indices=this._accessors.length-1}if(null!=S&&Object.keys(I.attributes).length>0){var k=null!==c.overrideMaterialSideOrientation?c.overrideMaterialSideOrientation:V.sideOrientation;if(k==n.Material.ClockWiseSideOrientation&&this._babylonScene.useRightHandedSystem||k==n.Material.ClockWiseSideOrientation&&a&&c.overrideMaterialSideOrientation!==(null===(o=c.material)||void 0===o?void 0:o.sideOrientation)){var D=null!=h?this._bufferViews[h].byteOffset:null;null==D&&(D=0);var U=null;if(null!=h&&(U=c.getIndices()),U)this.reorderIndicesBasedOnPrimitiveMode(R,p,U,D,r);else for(var K=0,H=f;K<H.length;K++){var z,W=H[K];if(z=c.getVerticesData(W.kind)){var q=this._bufferViews[d[W.kind]].byteOffset;q||(q=0),this.reorderVertexAttributeDataBasedOnPrimitiveMode(R,p,k,W.kind,z,q,r,a)}}}I.material=S}if(m)for(var Q=void 0,j=0;j<m.numTargets;++j)Q=m.getTarget(j),this.setMorphTargetAttributes(R,I,Q,r,a);e.primitives.push(I),this._extensionsPostExportMeshPrimitiveAsync("postExport",I,R,r)&&l.push()}}return Promise.all(l).then((function(){}))},e.prototype.isBabylonCoordinateSystemConvertingNode=function(e){if(e instanceof n.TransformNode){if("__root__"!==e.name)return!1;for(var t=e.getWorldMatrix(),r=n.Matrix.Compose(this._convertToRightHandedSystem?new n.Vector3(-1,1,1):n.Vector3.One(),n.Quaternion.Identity(),n.Vector3.Zero()),a=t.multiply(r),i=n.Matrix.IdentityReadOnly,o=0;o<16;o++)if(Math.abs(a.m[o]-i.m[o])>n.Epsilon)return!1;return!(e instanceof n.Mesh&&null!==e.geometry||e instanceof n.InstancedMesh&&null!==e.sourceMesh.geometry)&&!this._includeCoordinateSystemConversionNodes}return!1},e.prototype.createSceneAsync=function(e,t){var r,a,i,o=this,s={nodes:[]},u=function(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),a=0;for(t=0;t<r;t++)for(var i=arguments[t],o=0,s=i.length;o<s;o++,a++)n[a]=i[o];return n}(e.transformNodes,e.meshes,e.lights),l=[];return this._convertToRightHandedSystem=!e.useRightHandedSystem,this._convertToRightHandedSystemMap={},e.rootNodes.forEach((function(e){o._convertToRightHandedSystemMap[e.uniqueId]=o._convertToRightHandedSystem,e.getDescendants(!1).forEach((function(e){o._convertToRightHandedSystemMap[e.uniqueId]=o._convertToRightHandedSystem}))})),e.rootNodes.forEach((function(e){if(o.isBabylonCoordinateSystemConvertingNode(e)){l.push(e);var t=u.indexOf(e);-1!==t&&u.splice(t,1),e.getDescendants(!1).forEach((function(e){o._convertToRightHandedSystemMap[e.uniqueId]=!1}))}})),this._glTFMaterialExporter._convertMaterialsToGLTFAsync(e.materials,"image/png",!0).then((function(){return o.createNodeMapAndAnimationsAsync(e,u,t).then((function(c){return o.createSkinsAsync(e,c,t).then((function(e){if(o._nodeMap=c,o._totalByteLength=t.getByteOffset(),null==o._totalByteLength)throw new Error("undefined byte length!");for(var f=0,h=u;f<h.length;f++){var p=h[f];if(void 0!==(r=o._nodeMap[p.uniqueId])){if(a=o._nodes[r],p.metadata&&(o._options.metadataSelector?a.extras=o._options.metadataSelector(p.metadata):p.metadata.gltf&&(a.extras=p.metadata.gltf.extras)),!p.parent||-1!==l.indexOf(p.parent))if(o._options.shouldExportNode&&!o._options.shouldExportNode(p))n.Tools.Log("Omitting "+p.name+" from scene.");else o._convertToRightHandedSystemMap[p.uniqueId]&&(a.translation&&(a.translation[2]*=-1,a.translation[0]*=-1),a.rotation=a.rotation?n.Quaternion.FromArray([0,1,0,0]).multiply(n.Quaternion.FromArray(a.rotation)).asArray():n.Quaternion.FromArray([0,1,0,0]).asArray()),s.nodes.push(r);if(p instanceof n.Mesh){var d=p;d.skeleton&&(a.skin=e[d.skeleton.uniqueId])}if(i=p.getDescendants(!0),!a.children&&i&&i.length){for(var m=[],g=0,_=i;g<_.length;g++){var x=_[g];null!=o._nodeMap[x.uniqueId]&&m.push(o._nodeMap[x.uniqueId])}m.length&&(a.children=m)}}}s.nodes.length&&o._scenes.push(s)}))}))}))},e.prototype.createNodeMapAndAnimationsAsync=function(e,t,r){for(var a,i=this,o=Promise.resolve(),u={},l={name:"runtime animations",channels:[],samplers:[]},c=[],f=function(t){!h._options.shouldExportNode||h._options.shouldExportNode(t)?o=o.then((function(){var o=i._convertToRightHandedSystemMap[t.uniqueId];return i.createNodeAsync(t,r,o,u).then((function(f){var h=i._extensionsPostExportNodeAsync("createNodeAsync",f,t,u);return null==h?(n.Tools.Warn("Not exporting node "+t.name),Promise.resolve()):h.then((function(n){n&&(i._nodes.push(n),a=i._nodes.length-1,u[t.uniqueId]=a,e.animationGroups.length||(s.a._CreateMorphTargetAnimationFromMorphTargetAnimations(t,l,c,u,i._nodes,r,i._bufferViews,i._accessors,o,i._animationSampleRate),t.animations.length&&s.a._CreateNodeAnimationFromNodeAnimations(t,l,c,u,i._nodes,r,i._bufferViews,i._accessors,o,i._animationSampleRate)))}))}))})):t.name},h=this,p=0,d=t;p<d.length;p++){f(d[p])}return o.then((function(){return l.channels.length&&l.samplers.length&&i._animations.push(l),c.forEach((function(e){e.channels.length&&e.samplers.length&&i._animations.push(e)})),e.animationGroups.length&&s.a._CreateNodeAndMorphAnimationFromAnimationGroups(e,i._animations,u,i._nodes,r,i._bufferViews,i._accessors,i._convertToRightHandedSystemMap,i._animationSampleRate),u}))},e.prototype.createNodeAsync=function(e,t,r,a){var i=this;return Promise.resolve().then((function(){var a={},o={primitives:[]};if(e.name&&(a.name=e.name),e instanceof n.TransformNode){if(i.setNodeTransformation(a,e,r),e instanceof n.Mesh){var s=e.morphTargetManager;if(s&&s.numTargets>0){o.weights=[];for(var u=0;u<s.numTargets;++u)o.weights.push(s.getTarget(u).influence)}}return i.setPrimitiveAttributesAsync(o,e,t,r).then((function(){return o.primitives.length&&(i._meshes.push(o),a.mesh=i._meshes.length-1),a}))}return a}))},e.prototype.createSkinsAsync=function(e,t,r){for(var n=Promise.resolve(),a={},o=function(n){var o={joints:[]},u=[],l=e.meshes.find((function(e){e.skeleton}));o.skeleton=null===n.overrideMesh?l?t[l.uniqueId]:void 0:t[n.overrideMesh.uniqueId];for(var c={},f=-1,h=-1,p=0,d=n.bones;p<d.length;p++){(h=(g=d[p]).getIndex())>-1&&(c[h]=g),f=Math.max(f,h)}for(var m=0;m<=f;++m){var g,_=(g=c[m]).getTransformNode();if(_){var x=g.getInvertedAbsoluteTransform();s._convertToRightHandedSystem&&i.a._GetRightHandedMatrixFromRef(x),u.push(x),o.joints.push(t[_.uniqueId])}}var y=64*u.length,T=r.getByteOffset(),v=i.a._CreateBufferView(0,T,y,64,"InverseBindMatrices - "+n.name);s._bufferViews.push(v);var b=s._bufferViews.length-1,A=i.a._CreateAccessor(b,"InverseBindMatrices - "+n.name,"MAT4",5126,u.length,null,null,null),F=s._accessors.push(A)-1;o.inverseBindMatrices=F,s._skins.push(o),a[n.uniqueId]=s._skins.length-1,u.forEach((function(e){e.m.forEach((function(e){r.setFloat32(e)}))}))},s=this,u=0,l=e.skeletons;u<l.length;u++){o(l[u])}return n.then((function(){return a}))},e._ExtensionNames=new Array,e._ExtensionFactories={},e}(),l=function(){function e(e){this._arrayBuffer=new ArrayBuffer(e),this._dataView=new DataView(this._arrayBuffer),this._byteOffset=0}return e.prototype.resizeBuffer=function(e){for(var t=new ArrayBuffer(e),r=new Uint8Array(this._arrayBuffer),n=new Uint8Array(t),a=0,i=n.byteLength;a<i;++a)n[a]=r[a];return this._arrayBuffer=t,this._dataView=new DataView(this._arrayBuffer),t},e.prototype.getArrayBuffer=function(){return this.resizeBuffer(this.getByteOffset())},e.prototype.getByteOffset=function(){if(null==this._byteOffset)throw new Error("Byte offset is undefined!");return this._byteOffset},e.prototype.setUInt8=function(e,t){null!=t?t<this._byteOffset?this._dataView.setUint8(t,e):n.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(this._byteOffset+1>this._arrayBuffer.byteLength&&this.resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setUint8(this._byteOffset,e),this._byteOffset+=1)},e.prototype.setUInt16=function(e,t){null!=t?t<this._byteOffset?this._dataView.setUint16(t,e,!0):n.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(this._byteOffset+2>this._arrayBuffer.byteLength&&this.resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setUint16(this._byteOffset,e,!0),this._byteOffset+=2)},e.prototype.getUInt32=function(e){if(e<this._byteOffset)return this._dataView.getUint32(e,!0);throw n.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"),new Error("BinaryWriter: byteoffset is greater than the current binary buffer length!")},e.prototype.getVector3Float32FromRef=function(e,t){t+8>this._byteOffset?n.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?n.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?n.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?n.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)&&n.Tools.Error("Invalid data being written!"),null!=t&&(t<this._byteOffset?this._dataView.setFloat32(t,e,!0):n.Tools.Error("BinaryWriter: byteoffset is greater than the current binary length!")),this._byteOffset+4>this._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?t<this._byteOffset?this._dataView.setUint32(t,e,!0):n.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(this._byteOffset+4>this._arrayBuffer.byteLength&&this.resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setUint32(this._byteOffset,e,!0),this._byteOffset+=4)},e}()},function(e,t,r){"use strict";r.r(t),r.d(t,"GLTFData",(function(){return n}));var n=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}()},function(e,t,r){"use strict";r.r(t),r.d(t,"__IGLTFExporterExtension",(function(){return n}));var n=0},,function(e,t,r){"use strict";r.r(t),r.d(t,"_GLTFAnimation",(function(){return n.a})),r.d(t,"GLTFData",(function(){return a.GLTFData})),r.d(t,"_Exporter",(function(){return i.b})),r.d(t,"_BinaryWriter",(function(){return i.a})),r.d(t,"__IGLTFExporterExtensionV2",(function(){return o})),r.d(t,"_GLTFMaterialExporter",(function(){return s.a})),r.d(t,"GLTF2Export",(function(){return u.GLTF2Export})),r.d(t,"_GLTFUtilities",(function(){return l.a})),r.d(t,"KHR_texture_transform",(function(){return c.KHR_texture_transform})),r.d(t,"KHR_lights_punctual",(function(){return c.KHR_lights_punctual})),r.d(t,"KHR_materials_sheen",(function(){return c.KHR_materials_sheen})),r.d(t,"KHR_materials_unlit",(function(){return c.KHR_materials_unlit}));var n=r(7),a=r(3),i=r(2),o=0,s=r(10),u=r(8),l=r(1),c=r(9)},function(e,t,r){"use strict";r.d(t,"a",(function(){return o}));var n,a=r(0),i=r(1);!function(e){e[e.INTANGENT=0]="INTANGENT",e[e.OUTTANGENT=1]="OUTTANGENT"}(n||(n={}));var o=function(){function e(){}return e._CreateNodeAnimation=function(t,r,n,i,o,s){var u=[],l=[],c=r.getKeys(),f=e.calculateMinMaxKeyFrames(c),h=e._DeduceInterpolation(c,n,o),p=f.max-f.min,d=h.interpolationType,m=h.shouldBakeAnimation;return m?e._CreateBakedAnimation(t,r,n,f.min,f.max,r.framePerSecond,s,u,l,f,i,o):"LINEAR"===d||"STEP"===d?e._CreateLinearOrStepAnimation(t,r,n,p,u,l,i,o):"CUBICSPLINE"===d?e._CreateCubicSplineAnimation(t,r,n,p,u,l,i,o):e._CreateBakedAnimation(t,r,n,f.min,f.max,r.framePerSecond,s,u,l,f,i,o),u.length&&l.length?{inputs:u,outputs:l,samplerInterpolation:d,inputsMin:m?f.min:a.Tools.FloatRound(f.min/r.framePerSecond),inputsMax:m?f.max:a.Tools.FloatRound(f.max/r.framePerSecond)}:null},e._DeduceAnimationInfo=function(e){var t=null,r="VEC3",n=!1,i=e.targetProperty.split(".");switch(i[0]){case"scaling":t="scale";break;case"position":t="translation";break;case"rotation":r="VEC4",t="rotation";break;case"rotationQuaternion":r="VEC4",n=!0,t="rotation";break;case"influence":r="SCALAR",t="weights";break;default:a.Tools.Error("Unsupported animatable property "+i[0])}return t?{animationChannelTargetPath:t,dataAccessorType:r,useQuaternion:n}:(a.Tools.Error("animation channel target path and data accessor type could be deduced"),null)},e._CreateNodeAnimationFromNodeAnimations=function(t,r,n,i,o,s,u,l,c,f){var h;if(t instanceof a.TransformNode&&t.animations)for(var p=0,d=t.animations;p<d.length;p++){var m=d[p],g=e._DeduceAnimationInfo(m);g&&(h={name:m.name,samplers:[],channels:[]},e.AddAnimation(""+m.name,m.hasRunningRuntimeAnimations?r:h,t,m,g.dataAccessorType,g.animationChannelTargetPath,i,s,u,l,c,g.useQuaternion,f),h.samplers.length&&h.channels.length&&n.push(h))}},e._CreateMorphTargetAnimationFromMorphTargetAnimations=function(t,r,n,i,o,s,u,l,c,f){var h;if(t instanceof a.Mesh){var p=t.morphTargetManager;if(p)for(var d=0;d<p.numTargets;++d)for(var m=0,g=p.getTarget(d).animations;m<g.length;m++){for(var _=g[m],x=new a.Animation(""+_.name,"influence",_.framePerSecond,_.dataType,_.loopMode,_.enableBlending),y=[],T=_.getKeys(),v=0;v<T.length;++v)for(var b=T[v],A=0;A<p.numTargets;++A)A==d?y.push(b):y.push({frame:b.frame,value:0});x.setKeys(y);var F=e._DeduceAnimationInfo(x);F&&(h={name:x.name,samplers:[],channels:[]},e.AddAnimation(_.name,_.hasRunningRuntimeAnimations?r:h,t,x,F.dataAccessorType,F.animationChannelTargetPath,i,s,u,l,c,F.useQuaternion,f,p.numTargets),h.samplers.length&&h.channels.length&&n.push(h))}}},e._CreateNodeAndMorphAnimationFromAnimationGroups=function(t,r,n,i,o,s,u,l,c){var f,h;if(t.animationGroups)for(var p=function(i){var p=new Map,d=new Map,m=new Set,g=i.to-i.from;h={name:i.name,channels:[],samplers:[]};for(var _=function(r){var g=i.targetedAnimations[r],_=g.target,x=g.animation;if(_ instanceof a.TransformNode||1===_.length&&_[0]instanceof a.TransformNode){if(v=e._DeduceAnimationInfo(g.animation)){var y=_ instanceof a.TransformNode?_:_[0],T=l[y.uniqueId];e.AddAnimation(""+x.name,h,y,x,v.dataAccessorType,v.animationChannelTargetPath,n,o,s,u,T,v.useQuaternion,c)}}else if(_ instanceof a.MorphTarget||1===_.length&&_[0]instanceof a.MorphTarget){var v;if(v=e._DeduceAnimationInfo(g.animation)){var b=_ instanceof a.MorphTarget?_:_[0];if(b){var A=t.morphTargetManagers.find((function(e){for(var t=0;t<e.numTargets;++t)if(e.getTarget(t)===b)return!0;return!1}));if(A){var F=t.meshes.find((function(e){return e.morphTargetManager===A}));F&&(p.has(F)||p.set(F,new Map),null===(f=p.get(F))||void 0===f||f.set(b,x),m.add(F),d.set(F,x))}}}}},x=0;x<i.targetedAnimations.length;++x)_(x);m.forEach((function(t){for(var r=t.morphTargetManager,l=null,f=[],m=d.get(t).getKeys(),_=m.length,x=0;x<_;++x)for(var y=0;y<r.numTargets;++y){var T=r.getTarget(y),v=p.get(t);if(v){var b=v.get(T);b?(l||(l=new a.Animation(i.name+"_"+t.name+"_MorphWeightAnimation","influence",b.framePerSecond,a.Animation.ANIMATIONTYPE_FLOAT,b.loopMode,b.enableBlending)),f.push(b.getKeys()[x])):f.push({frame:i.from+g/_*x,value:T.influence,inTangent:m[0].inTangent?0:void 0,outTangent:m[0].outTangent?0:void 0})}}l.setKeys(f);var A=e._DeduceAnimationInfo(l);A&&e.AddAnimation(i.name+"_"+t.name+"_MorphWeightAnimation",h,t,l,A.dataAccessorType,A.animationChannelTargetPath,n,o,s,u,!1,A.useQuaternion,c,null==r?void 0:r.numTargets)})),h.channels.length&&h.samplers.length&&r.push(h)},d=0,m=t.animationGroups;d<m.length;d++){p(m[d])}},e.AddAnimation=function(t,r,n,a,o,s,u,l,c,f,h,p,d,m){var g,_,x,y,T,v,b,A=e._CreateNodeAnimation(n,a,s,h,p,d);if(A){if(m){for(var F=0,M=0,E=[];A.inputs.length>0;)M=A.inputs.shift(),F%m==0&&E.push(M),F++;A.inputs=E}var R=u[n.uniqueId],V=4*A.inputs.length;g=i.a._CreateBufferView(0,l.getByteOffset(),V,void 0,t+"  keyframe data view"),c.push(g),A.inputs.forEach((function(e){l.setFloat32(e)})),_=i.a._CreateAccessor(c.length-1,t+"  keyframes","SCALAR",5126,A.inputs.length,null,[A.inputsMin],[A.inputsMax]),f.push(_),x=f.length-1,T=A.outputs.length,V=4*i.a._GetDataAccessorElementCount(o)*A.outputs.length,g=i.a._CreateBufferView(0,l.getByteOffset(),V,void 0,t+"  data view"),c.push(g),A.outputs.forEach((function(e){e.forEach((function(e){l.setFloat32(e)}))})),_=i.a._CreateAccessor(c.length-1,t+"  data",o,5126,T,null,null,null),f.push(_),y=f.length-1,v={interpolation:A.samplerInterpolation,input:x,output:y},r.samplers.push(v),b={sampler:r.samplers.length-1,target:{node:R,path:s}},r.channels.push(b)}},e._CreateBakedAnimation=function(t,r,n,i,o,s,u,l,c,f,h,p){var d,m,g=a.Quaternion.Identity(),_=null,x=null,y=null,T=null,v=null,b=null;f.min=a.Tools.FloatRound(i/s);for(var A=r.getKeys(),F=0,M=A.length;F<M;++F){if(b=null,y=A[F],F+1<M)if(T=A[F+1],y.value.equals&&y.value.equals(T.value)||y.value===T.value){if(0!==F)continue;b=y.frame}else b=T.frame;else{if(v=A[F-1],y.value.equals&&y.value.equals(v.value)||y.value===v.value)continue;b=o}if(b)for(var E=y.frame;E<=b;E+=u)if((m=a.Tools.FloatRound(E/s))!==_){_=m,x=m;var R={key:0,repeatCount:0,loopMode:r.loopMode};d=r._interpolate(E,R),e._SetInterpolatedValue(t,d,m,r,n,g,l,c,h,p)}}x&&(f.max=x)},e._ConvertFactorToVector3OrQuaternion=function(t,r,n,i,o,s,u){var l,c,f=null,h=e._GetBasePositionRotationOrScale(r,o,s,u);if(i===a.Animation.ANIMATIONTYPE_FLOAT)switch(c=(l=n.targetProperty.split("."))?l[1]:"",f=u?a.Quaternion.FromArray(h).normalize():a.Vector3.FromArray(h),c){case"x":case"y":f[c]=s&&u&&"scale"!==o?-t:t;break;case"z":f[c]=s&&!u&&"scale"!==o?-t:t;break;case"w":f.w=t;break;default:a.Tools.Error('glTFAnimation: Unsupported component type "'+c+'" for scale animation!')}return f},e._SetInterpolatedValue=function(e,t,r,n,o,s,u,l,c,f){var h,p=n.dataType;u.push(r),"number"==typeof t&&e instanceof a.TransformNode&&(t=this._ConvertFactorToVector3OrQuaternion(t,e,n,p,o,c,f)),t&&("rotation"===o?(f?s=t:(h=t,a.Quaternion.RotationYawPitchRollToRef(h.y,h.x,h.z,s)),c&&(i.a._GetRightHandedQuaternionFromRef(s),e.parent||(s=a.Quaternion.FromArray([0,1,0,0]).multiply(s))),l.push(s.asArray())):"weights"===o?l.push([t]):(h=t,c&&"scale"!==o&&(i.a._GetRightHandedPositionVector3FromRef(h),e.parent||(h.x*=-1,h.z*=-1)),l.push(h.asArray())))},e._CreateLinearOrStepAnimation=function(t,r,n,a,i,o,s,u){for(var l=0,c=r.getKeys();l<c.length;l++){var f=c[l];i.push(f.frame/r.framePerSecond),e._AddKeyframeValue(f,r,o,n,t,s,u)}},e._CreateCubicSplineAnimation=function(t,r,a,i,o,s,u,l){r.getKeys().forEach((function(c){o.push(c.frame/r.framePerSecond),e.AddSplineTangent(t,n.INTANGENT,s,a,"CUBICSPLINE",c,i,l,u),e._AddKeyframeValue(c,r,s,a,t,u,l),e.AddSplineTangent(t,n.OUTTANGENT,s,a,"CUBICSPLINE",c,i,l,u)}))},e._GetBasePositionRotationOrScale=function(e,t,r,n){var o;return"rotation"===t?n?e.rotationQuaternion?(o=e.rotationQuaternion.asArray(),r&&(i.a._GetRightHandedQuaternionArrayFromRef(o),e.parent||(o=a.Quaternion.FromArray([0,1,0,0]).multiply(a.Quaternion.FromArray(o)).asArray()))):o=a.Quaternion.Identity().asArray():(o=e.rotation.asArray(),i.a._GetRightHandedNormalArray3FromRef(o)):"translation"===t?(o=e.position.asArray(),r&&i.a._GetRightHandedPositionArray3FromRef(o)):o=e.scaling.asArray(),o},e._AddKeyframeValue=function(e,t,r,n,o,s,u){var l,c,f=t.dataType;if(f===a.Animation.ANIMATIONTYPE_VECTOR3){if(l=e.value.asArray(),"rotation"===n){var h=a.Vector3.FromArray(l),p=a.Quaternion.RotationYawPitchRoll(h.y,h.x,h.z);s&&(i.a._GetRightHandedQuaternionFromRef(p),o.parent||(p=a.Quaternion.FromArray([0,1,0,0]).multiply(p))),l=p.asArray()}else"translation"===n&&s&&(i.a._GetRightHandedNormalArray3FromRef(l),o.parent||(l[0]*=-1,l[2]*=-1));r.push(l)}else if(f===a.Animation.ANIMATIONTYPE_FLOAT){if("weights"===n)r.push([e.value]);else if(c=this._ConvertFactorToVector3OrQuaternion(e.value,o,t,f,n,s,u)){if("rotation"===n){var d=u?c:a.Quaternion.RotationYawPitchRoll(c.y,c.x,c.z).normalize();s&&(i.a._GetRightHandedQuaternionFromRef(d),o.parent||(d=a.Quaternion.FromArray([0,1,0,0]).multiply(d))),r.push(d.asArray())}else"translation"===n&&s&&(i.a._GetRightHandedNormalVector3FromRef(c),o.parent||(c.x*=-1,c.z*=-1));r.push(c.asArray())}}else f===a.Animation.ANIMATIONTYPE_QUATERNION?(l=e.value.normalize().asArray(),s&&(i.a._GetRightHandedQuaternionArrayFromRef(l),o.parent||(l=a.Quaternion.FromArray([0,1,0,0]).multiply(a.Quaternion.FromArray(l)).asArray())),r.push(l)):a.Tools.Error("glTFAnimation: Unsupported key frame values for animation!")},e._DeduceInterpolation=function(e,t,r){var n,i,o=!1;if("rotation"===t&&!r)return{interpolationType:"LINEAR",shouldBakeAnimation:!0};for(var s=0,u=e.length;s<u;++s)if((i=e[s]).inTangent||i.outTangent)if(n){if("CUBICSPLINE"!==n){n="LINEAR",o=!0;break}}else n="CUBICSPLINE";else if(n){if("CUBICSPLINE"===n||i.interpolation&&i.interpolation===a.AnimationKeyInterpolation.STEP&&"STEP"!==n){n="LINEAR",o=!0;break}}else n=i.interpolation&&i.interpolation===a.AnimationKeyInterpolation.STEP?"STEP":"LINEAR";return n||(n="LINEAR"),{interpolationType:n,shouldBakeAnimation:o}},e.AddSplineTangent=function(e,t,r,o,s,u,l,c,f){var h,p=t===n.INTANGENT?u.inTangent:u.outTangent;if("CUBICSPLINE"===s){if("rotation"===o)if(p){if(c)h=p.asArray();else{var d=p;h=a.Quaternion.RotationYawPitchRoll(d.y,d.x,d.z).asArray()}f&&(i.a._GetRightHandedQuaternionArrayFromRef(h),e.parent||(h=a.Quaternion.FromArray([0,1,0,0]).multiply(a.Quaternion.FromArray(h)).asArray()))}else h=[0,0,0,0];else"weights"===o?h=p?[p]:[0]:p?(h=p.asArray(),f&&"translation"===o&&(i.a._GetRightHandedPositionArray3FromRef(h),e.parent||(h[0]*=-1,h[2]*=-1))):h=[0,0,0];r.push(h)}},e.calculateMinMaxKeyFrames=function(e){var t=1/0,r=-1/0;return e.forEach((function(e){t=Math.min(t,e.frame),r=Math.max(r,e.frame)})),{min:t,max:r}},e}()},function(e,t,r){"use strict";r.r(t),r.d(t,"GLTF2Export",(function(){return a}));var n=r(2),a=function(){function e(){}return e.GLTFAsync=function(e,t,r){return e.whenReadyAsync().then((function(){var a=t.replace(/\.[^/.]+$/,"");return new n.b(e,r)._generateGLTFAsync(a)}))},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(e,t,r){var a=this;return this._PreExportAsync(e,r).then((function(){var i=t.replace(/\.[^/.]+$/,"");return new n.b(e,r)._generateGLBAsync(i).then((function(t){return a._PostExportAsync(e,t,r)}))}))},e}()},function(e,t,r){"use strict";r.r(t),r.d(t,"KHR_texture_transform",(function(){return s})),r.d(t,"KHR_lights_punctual",(function(){return l})),r.d(t,"KHR_materials_sheen",(function(){return c})),r.d(t,"KHR_materials_unlit",(function(){return f}));var n=r(0),a=r(2),i="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}";n.Effect.ShadersStore.textureTransformPixelShader=i;var o="KHR_texture_transform",s=function(){function e(e){this._recordedTextures=[],this.name=o,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){for(var e=0,t=this._recordedTextures;e<t.length;e++){t[e].dispose()}},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportTexture=function(e,t,r){if(r&&(0===r.uAng&&0===r.wAng&&0===r.vAng||0===r.uRotationCenter&&0===r.vRotationCenter)){var n={},a=!1;if(0===r.uOffset&&0===r.vOffset||(n.offset=[r.uOffset,r.vOffset],a=!0),1===r.uScale&&1===r.vScale||(n.scale=[r.uScale,r.vScale],a=!0),0!==r.wAng&&(n.rotation=r.wAng,a=!0),0!==r.coordinatesIndex&&(n.texCoord=r.coordinatesIndex,a=!0),!a)return;this._wasUsed=!0,t.extensions||(t.extensions={}),t.extensions[o]=n}},e.prototype.preExportTextureAsync=function(e,t,r){var n=this;return new Promise((function(r,a){var i=t.getScene();if(i){var o=!1;if(0===t.uAng&&0===t.wAng&&0===t.vAng||0===t.uRotationCenter&&0===t.vRotationCenter||(o=!0),o)return n._textureTransformTextureAsync(t,i).then((function(e){r(e)})).catch((function(e){a(e)}));r(t)}else a(e+': "scene" is not defined for Babylon texture '+t.name+"!")}))},e.prototype._textureTransformTextureAsync=function(e,t){var r=this;return new Promise((function(a){var i=new n.ProceduralTexture(""+e.name,e.getSize(),"textureTransform",t);i||(n.Tools.Log("Cannot create procedural texture for "+e.name+"!"),a(e)),i.reservedDataStore={hidden:!0,source:e},r._recordedTextures.push(i),i.coordinatesIndex=e.coordinatesIndex,i.setTexture("textureSampler",e),i.setMatrix("textureTransformMat",e.getTextureMatrix()),i.isReady()?(i.render(),a(i)):i.getEffect().executeWhenCompiled((function(){i.render(),a(i)}))}))},e}();a.b.RegisterExtension(o,(function(e){return new s(e)}));var u=r(1),l=function(){function e(e){this.name="KHR_lights_punctual",this.enabled=!0,this.required=!1,this._exporter=e}return e.prototype.dispose=function(){this._lights=null},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return!!this._lights},enumerable:!1,configurable:!0}),e.prototype.onExporting=function(){this._exporter._glTF.extensions.KHR_lights_punctual=this._lights},e.prototype.postExportNodeAsync=function(e,t,r,a){var i=this;return new Promise((function(o,s){if(t&&r instanceof n.ShadowLight){var l=r,c=void 0,f=l.getTypeID()==n.Light.LIGHTTYPEID_POINTLIGHT?"point":l.getTypeID()==n.Light.LIGHTTYPEID_DIRECTIONALLIGHT?"directional":l.getTypeID()==n.Light.LIGHTTYPEID_SPOTLIGHT?"spot":null;if(null==f)n.Logger.Warn(e+": Light "+l.name+" is not supported in KHR_lights_punctual");else{var h=l.position.clone(),p=i._exporter._convertToRightHandedSystemMap[r.uniqueId];if(h.equals(n.Vector3.Zero())||(p&&u.a._GetRightHandedPositionVector3FromRef(h),t.translation=h.asArray()),"point"!==f){var d=l.direction,m=-Math.atan2(d.z*(i._exporter._babylonScene.useRightHandedSystem?-1:1),d.x)+Math.PI/2,g=Math.sqrt(d.x*d.x+d.z*d.z),_=-Math.atan2(d.y,g),x=n.Quaternion.RotationYawPitchRoll(m,_,0);p&&u.a._GetRightHandedQuaternionFromRef(x),x.equals(n.Quaternion.Identity())||(t.rotation=x.asArray())}if(l.falloffType!==n.Light.FALLOFF_GLTF&&n.Logger.Warn(e+": Light falloff for "+l.name+" does not match the KHR_lights_punctual specification!"),c={type:f},l.diffuse.equals(n.Color3.White())||(c.color=l.diffuse.asArray()),1!==l.intensity&&(c.intensity=l.intensity),l.range!==Number.MAX_VALUE&&(c.range=l.range),"spot"===f){var y=l;y.angle!==Math.PI/2&&(null==c.spot&&(c.spot={}),c.spot.outerConeAngle=y.angle/2),0!==y.innerAngle&&(null==c.spot&&(c.spot={}),c.spot.innerConeAngle=y.innerAngle/2)}null==i._lights&&(i._lights={lights:[]}),i._lights.lights.push(c);var T={light:i._lights.lights.length-1},v=r.parent;if(v&&1==v.getChildren().length){var b=i._exporter._nodes[a[v.uniqueId]];if(b){var A=n.TmpVectors.Matrix[0],F=n.TmpVectors.Matrix[1],M=b.translation?new n.Vector3(b.translation[0],b.translation[1],b.translation[2]):n.Vector3.Zero(),E=b.rotation?new n.Quaternion(b.rotation[0],b.rotation[1],b.rotation[2],b.rotation[3]):n.Quaternion.Identity(),R=b.scale?new n.Vector3(b.scale[0],b.scale[1],b.scale[2]):n.Vector3.One();n.Matrix.ComposeToRef(R,E,M,A),A.invertToRef(F);var V=n.TmpVectors.Matrix[2],S=t.translation?new n.Vector3(t.translation[0],t.translation[1],t.translation[2]):n.Vector3.Zero();l instanceof n.DirectionalLight&&S.subtractInPlace(i._exporter._babylonScene.useRightHandedSystem?l.direction:u.a._GetRightHandedPositionVector3(l.direction));var w=i._exporter._babylonScene.useRightHandedSystem?n.Quaternion.Identity():new n.Quaternion(0,1,0,0);t.rotation&&w.multiplyInPlace(new n.Quaternion(t.rotation[0],t.rotation[1],t.rotation[2],t.rotation[3]));var C=t.scale?new n.Vector3(t.scale[0],t.scale[1],t.scale[2]):n.Vector3.One();n.Matrix.ComposeToRef(C,w,S,V),V.multiplyToRef(F,V);var B=n.TmpVectors.Vector3[0],I=n.TmpVectors.Quaternion[0],P=n.TmpVectors.Vector3[1];return V.decompose(B,I,P),b.scale=B.asArray(),b.rotation=I.asArray(),b.translation=P.asArray(),null==b.extensions&&(b.extensions={}),b.extensions.KHR_lights_punctual=T,void o(void 0)}}null==t.extensions&&(t.extensions={}),t.extensions.KHR_lights_punctual=T}}o(t)}))},e}();a.b.RegisterExtension("KHR_lights_punctual",(function(e){return new l(e)}));var c=function(){function e(e){this.name="KHR_materials_sheen",this.enabled=!0,this.required=!1,this._textureInfos=[],this._exportedTextures=[],this._wasUsed=!1}return e.prototype.dispose=function(){this._textureInfos=[],this._exportedTextures=[]},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype._getTextureIndex=function(e){var t=this._exportedTextures.indexOf(e);return-1===t&&e.reservedDataStore&&(t=this._exportedTextures.indexOf(e.reservedDataStore.source)),t},e.prototype.postExportTexture=function(e,t,r){var n=this._getTextureIndex(r);n>-1&&(this._textureInfos[n]=t)},e.prototype.postExportMaterialAdditionalTextures=function(e,t,r){return r instanceof n.PBRMaterial&&r.sheen.isEnabled&&r.sheen.texture?(this._exportedTextures.push(r.sheen.texture),[r.sheen.texture]):[]},e.prototype.postExportMaterialAsync=function(e,t,r){var a=this;return new Promise((function(e,i){var o;if(r instanceof n.PBRMaterial){if(!r.sheen.isEnabled)return void e(t);a._wasUsed=!0,null==t.extensions&&(t.extensions={});var s={sheenColorFactor:r.sheen.color.asArray(),sheenRoughnessFactor:null!==(o=r.sheen.roughness)&&void 0!==o?o:0};if(r.sheen.texture)(u=a._getTextureIndex(r.sheen.texture))>-1&&(s.sheenColorTexture=a._textureInfos[u]);if(r.sheen.textureRoughness&&!r.sheen.useRoughnessFromMainTexture)(u=a._getTextureIndex(r.sheen.textureRoughness))>-1&&(s.sheenRoughnessTexture=a._textureInfos[u]);else if(r.sheen.texture&&r.sheen.useRoughnessFromMainTexture){var u;(u=a._getTextureIndex(r.sheen.texture))>-1&&(s.sheenRoughnessTexture=a._textureInfos[u])}t.extensions.KHR_materials_sheen=s}e(t)}))},e}();a.b.RegisterExtension("KHR_materials_sheen",(function(e){return new c(e)}));var f=function(){function e(e){this.name="KHR_materials_unlit",this.enabled=!0,this.required=!1,this._wasUsed=!1}return Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){},e.prototype.postExportMaterialAsync=function(e,t,r){var a=this;return new Promise((function(e,i){var o=!1;r instanceof n.PBRMaterial?o=r.unlit:r instanceof n.StandardMaterial&&(o=r.disableLighting),o&&(a._wasUsed=!0,null==t.extensions&&(t.extensions={}),t.extensions.KHR_materials_unlit={}),e(t)}))},e}();a.b.RegisterExtension("KHR_materials_unlit",(function(e){return new f(e)}))},function(e,t,r){"use strict";r.d(t,"a",(function(){return a}));var n=r(0),a=function(){function e(e){this._textureMap={},this._textureMap={},this._exporter=e}return e.FuzzyEquals=function(e,t,r){return n.Scalar.WithinEpsilon(e.r,t.r,r)&&n.Scalar.WithinEpsilon(e.g,t.g,r)&&n.Scalar.WithinEpsilon(e.b,t.b,r)},e.prototype._convertMaterialsToGLTFAsync=function(e,t,r){for(var a=[],i=0,o=e;i<o.length;i++){var s=o[i];s instanceof n.StandardMaterial?a.push(this._convertStandardMaterialAsync(s,t,r)):s instanceof n.PBRMetallicRoughnessMaterial?a.push(this._convertPBRMetallicRoughnessMaterialAsync(s,t,r)):s instanceof n.PBRMaterial?a.push(this._convertPBRMaterialAsync(s,t,r)):n.Tools.Warn("Unsupported material type: "+s.name)}return Promise.all(a).then((function(){}))},e.prototype._stripTexturesFromMaterial=function(e){var t={};if(e){t.name=e.name,t.doubleSided=e.doubleSided,t.alphaMode=e.alphaMode,t.alphaCutoff=e.alphaCutoff,t.emissiveFactor=e.emissiveFactor;var r=e.pbrMetallicRoughness;r&&(t.pbrMetallicRoughness={},t.pbrMetallicRoughness.baseColorFactor=r.baseColorFactor,t.pbrMetallicRoughness.metallicFactor=r.metallicFactor,t.pbrMetallicRoughness.roughnessFactor=r.roughnessFactor)}return t},e.prototype._hasTexturesPresent=function(e){if(e.emissiveTexture||e.normalTexture||e.occlusionTexture)return!0;var t=e.pbrMetallicRoughness;return!(!t||!t.baseColorTexture&&!t.metallicRoughnessTexture)},e.prototype._convertToGLTFPBRMetallicRoughness=function(t){var r=new n.Vector2(0,1),a=new n.Vector2(0,.1),i=new n.Vector2(0,.1),o=new n.Vector2(1300,.1);var s=t.diffuseColor.toLinearSpace().scale(.5),u=t.alpha,l=function(e){return function(e,t,r,n,a){return(1-e)*(1-e)*(1-e)*t+3*(1-e)*(1-e)*e*r+3*(1-e)*e*e*n+e*e*e*a}(Math.pow(e/o.x,.333333),r.y,a.y,i.y,o.y)}(n.Scalar.Clamp(t.specularPower,0,e._MaxSpecularPower));return{baseColorFactor:[s.r,s.g,s.b,u],metallicFactor:0,roughnessFactor:l}},e._SolveMetallic=function(e,t,r){if(t<this._DielectricSpecular.r)return this._DielectricSpecular,0;var a=this._DielectricSpecular.r,i=e*r/(1-this._DielectricSpecular.r)+t-2*this._DielectricSpecular.r,o=i*i-4*a*(this._DielectricSpecular.r-t);return n.Scalar.Clamp((-i+Math.sqrt(o))/(2*a),0,1)},e._SetAlphaMode=function(e,t){t.needAlphaBlending()?e.alphaMode="BLEND":t.needAlphaTesting()&&(e.alphaMode="MASK",e.alphaCutoff=t.alphaCutOff)},e.prototype._convertStandardMaterialAsync=function(t,r,a){var i=this._exporter._materialMap,o=this._exporter._materials,s=[],u=this._convertToGLTFPBRMetallicRoughness(t),l={name:t.name};return null==t.backFaceCulling||t.backFaceCulling||(t.twoSidedLighting||n.Tools.Warn(t.name+": Back-face culling enabled and two-sided lighting disabled is not supported in glTF."),l.doubleSided=!0),a&&(t.diffuseTexture&&s.push(this._exportTextureAsync(t.diffuseTexture,r).then((function(e){e&&(u.baseColorTexture=e)}))),t.bumpTexture&&s.push(this._exportTextureAsync(t.bumpTexture,r).then((function(e){e&&(l.normalTexture=e,null!=t.bumpTexture&&1!==t.bumpTexture.level&&(l.normalTexture.scale=t.bumpTexture.level))}))),t.emissiveTexture&&(l.emissiveFactor=[1,1,1],s.push(this._exportTextureAsync(t.emissiveTexture,r).then((function(e){e&&(l.emissiveTexture=e)})))),t.ambientTexture&&s.push(this._exportTextureAsync(t.ambientTexture,r).then((function(e){if(e){var t={index:e.index};l.occlusionTexture=t,t.strength=1}})))),(t.alpha<1||t.opacityTexture)&&(t.alphaMode===n.Constants.ALPHA_COMBINE?l.alphaMode="BLEND":n.Tools.Warn(t.name+": glTF 2.0 does not support alpha mode: "+t.alphaMode.toString())),t.emissiveColor&&!e.FuzzyEquals(t.emissiveColor,n.Color3.Black(),e._Epsilon)&&(l.emissiveFactor=t.emissiveColor.asArray()),l.pbrMetallicRoughness=u,e._SetAlphaMode(l,t),o.push(l),i[t.uniqueId]=o.length-1,this._finishMaterial(s,l,t,r)},e.prototype._finishMaterial=function(e,t,r,n){var a=this;return Promise.all(e).then((function(){for(var e=null,i=0,o=a._exporter._extensionsPostExportMaterialAdditionalTextures("exportMaterial",t,r);i<o.length;i++){var s=o[i];e||(e=[]),e.push(a._exportTextureAsync(s,n))}return e||(e=[Promise.resolve(null)]),Promise.all(e).then((function(){var e=a._exporter._extensionsPostExportMaterialAsync("exportMaterial",t,r);return e?e.then((function(){return t})):t}))}))},e.prototype._convertPBRMetallicRoughnessMaterialAsync=function(t,r,a){var i=this._exporter._materialMap,o=this._exporter._materials,s=[],u={};t.baseColor&&(u.baseColorFactor=[t.baseColor.r,t.baseColor.g,t.baseColor.b,t.alpha]),null!=t.metallic&&1!==t.metallic&&(u.metallicFactor=t.metallic),null!=t.roughness&&1!==t.roughness&&(u.roughnessFactor=t.roughness);var l={name:t.name};return t.doubleSided&&(l.doubleSided=t.doubleSided),e._SetAlphaMode(l,t),a&&(null!=t.baseTexture&&s.push(this._exportTextureAsync(t.baseTexture,r).then((function(e){e&&(u.baseColorTexture=e)}))),t.normalTexture&&s.push(this._exportTextureAsync(t.normalTexture,r).then((function(e){e&&(l.normalTexture=e,1!==t.normalTexture.level&&(l.normalTexture.scale=t.normalTexture.level))}))),t.occlusionTexture&&s.push(this._exportTextureAsync(t.occlusionTexture,r).then((function(e){e&&(l.occlusionTexture=e,null!=t.occlusionStrength&&(l.occlusionTexture.strength=t.occlusionStrength))}))),t.emissiveTexture&&s.push(this._exportTextureAsync(t.emissiveTexture,r).then((function(e){e&&(l.emissiveTexture=e)})))),e.FuzzyEquals(t.emissiveColor,n.Color3.Black(),e._Epsilon)&&(l.emissiveFactor=t.emissiveColor.asArray()),l.pbrMetallicRoughness=u,o.push(l),i[t.uniqueId]=o.length-1,this._finishMaterial(s,l,t,r)},e.prototype._createBase64FromCanvasAsync=function(e,t,r,a){var i=this;return new Promise((function(o,s){var u,l=n.Constants.TEXTURETYPE_UNSIGNED_INT,c=i._exporter._getLocalEngine();u=new n.Scene(c);var f=c.createRawTexture(e,t,r,n.Constants.TEXTUREFORMAT_RGBA,!1,!0,n.Texture.NEAREST_SAMPLINGMODE,null,l),h=new n.PostProcess("pass","pass",null,null,1,null,n.Texture.NEAREST_SAMPLINGMODE,c,!1,void 0,n.Constants.TEXTURETYPE_UNSIGNED_INT,void 0,null,!1);h.getEffect().executeWhenCompiled((function(){var e,i;h.onApply=function(e){e._bindTexture("textureSampler",f)},c.setSize(t,r),u.postProcessManager.directRender([h],null),h.dispose(),f.dispose();var l=c.getRenderingCanvas(),p=document.createElement("canvas");if(p.width=null!==(e=null==l?void 0:l.width)&&void 0!==e?e:0,p.height=null!==(i=null==l?void 0:l.height)&&void 0!==i?i:0,p.getContext("2d").drawImage(l,0,0),p)if(p.toBlob)n.Tools.ToBlob(p,(function(e){if(p=null,e){var t=new FileReader;t.onload=function(e){var t=e.target.result;u.dispose(),o(t)},t.readAsDataURL(e)}else s("gltfMaterialExporter: Failed to get blob from image canvas!")}),a);else{var d=p.toDataURL();o(d)}else s("Engine is missing a canvas!")}))}))},e.prototype._createWhiteTexture=function(e,t,r){for(var a=new Uint8Array(e*t*4),i=0;i<a.length;i+=4)a[i]=a[i+1]=a[i+2]=a[i+3]=255;return n.RawTexture.CreateRGBATexture(a,e,t,r)},e.prototype._resizeTexturesToSameDimensions=function(e,t,r){var a,i,o=e?e.getSize():{width:0,height:0},s=t?t.getSize():{width:0,height:0};return o.width<s.width?(a=e&&e instanceof n.Texture?n.TextureTools.CreateResizedCopy(e,s.width,s.height,!0):this._createWhiteTexture(s.width,s.height,r),i=t):o.width>s.width?(i=t&&t instanceof n.Texture?n.TextureTools.CreateResizedCopy(t,o.width,o.height,!0):this._createWhiteTexture(o.width,o.height,r),a=e):(a=e,i=t),{texture1:a,texture2:i}},e.prototype._convertPixelArrayToFloat32=function(e){if(e instanceof Uint8Array){for(var t=e.length,r=new Float32Array(e.length),n=0;n<t;++n)r[n]=e[n]/255;return r}if(e instanceof Float32Array)return e;throw new Error("Unsupported pixel format!")},e.prototype._convertSpecularGlossinessTexturesToMetallicRoughnessAsync=function(t,r,a,i){var o=[];if(!t&&!r)return Promise.reject("_ConvertSpecularGlosinessTexturesToMetallicRoughness: diffuse and specular glossiness textures are not defined!");var s=t?t.getScene():r?r.getScene():null;if(s){var u=this._resizeTexturesToSameDimensions(t,r,s),l=u.texture1.getSize(),c=void 0,f=void 0,h=l.width,p=l.height,d=u.texture1.readPixels(),m=u.texture2.readPixels();if(!d)return Promise.reject("Failed to retrieve pixels from diffuse texture!");if(c=this._convertPixelArrayToFloat32(d),!m)return Promise.reject("Failed to retrieve pixels from specular glossiness texture!");for(var g=(f=this._convertPixelArrayToFloat32(m)).byteLength,_=new Uint8Array(g),x=new Uint8Array(g),y=n.Color3.Black(),T=0,v=0,b=0;b<p;++b)for(var A=0;A<h;++A){var F=4*(h*b+A),M={diffuseColor:new n.Color3(c[F],c[F+1],c[F+2]).toLinearSpace().multiply(a.diffuseColor),specularColor:new n.Color3(f[F],f[F+1],f[F+2]).toLinearSpace().multiply(a.specularColor),glossiness:f[F+3]*a.glossiness},E=this._convertSpecularGlossinessToMetallicRoughness(M);y.r=Math.max(y.r,E.baseColor.r),y.g=Math.max(y.g,E.baseColor.g),y.b=Math.max(y.b,E.baseColor.b),T=Math.max(T,E.metallic),v=Math.max(v,E.roughness),x[F]=255*E.baseColor.r,x[F+1]=255*E.baseColor.g,x[F+2]=255*E.baseColor.b,x[F+3]=u.texture1.hasAlpha?255*c[F+3]:255,_[F]=0,_[F+1]=255*E.roughness,_[F+2]=255*E.metallic,_[F+3]=255}var R={baseColor:y,metallic:T,roughness:v},V=!1,S=!1;for(b=0;b<p;++b)for(A=0;A<h;++A){var w=4*(h*b+A);x[w]/=R.baseColor.r>e._Epsilon?R.baseColor.r:1,x[w+1]/=R.baseColor.g>e._Epsilon?R.baseColor.g:1,x[w+2]/=R.baseColor.b>e._Epsilon?R.baseColor.b:1;var C=n.Color3.FromInts(x[w],x[w+1],x[w+2]).toGammaSpace();x[w]=255*C.r,x[w+1]=255*C.g,x[w+2]=255*C.b,e.FuzzyEquals(C,n.Color3.White(),e._Epsilon)||(S=!0),_[w+1]/=R.roughness>e._Epsilon?R.roughness:1,_[w+2]/=R.metallic>e._Epsilon?R.metallic:1;var B=n.Color3.FromInts(255,_[w+1],_[w+2]);e.FuzzyEquals(B,n.Color3.White(),e._Epsilon)||(V=!0)}if(V){var I=this._createBase64FromCanvasAsync(_,h,p,i).then((function(e){R.metallicRoughnessTextureBase64=e}));o.push(I)}if(S){I=this._createBase64FromCanvasAsync(x,h,p,i).then((function(e){R.baseColorTextureBase64=e}));o.push(I)}return Promise.all(o).then((function(){return R}))}return Promise.reject("_ConvertSpecularGlossinessTexturesToMetallicRoughness: Scene from textures is missing!")},e.prototype._convertSpecularGlossinessToMetallicRoughness=function(t){var r=this._getPerceivedBrightness(t.diffuseColor),a=this._getPerceivedBrightness(t.specularColor),i=1-this._getMaxComponent(t.specularColor),o=e._SolveMetallic(r,a,i),s=t.diffuseColor.scale(i/(1-e._DielectricSpecular.r)/Math.max(1-o,e._Epsilon)),u=t.specularColor.subtract(e._DielectricSpecular.scale(1-o)).scale(1/Math.max(o,e._Epsilon)),l=n.Color3.Lerp(s,u,o*o);return{baseColor:l=l.clampToRef(0,1,l),metallic:o,roughness:1-t.glossiness}},e.prototype._getPerceivedBrightness=function(e){return e?Math.sqrt(.299*e.r*e.r+.587*e.g*e.g+.114*e.b*e.b):0},e.prototype._getMaxComponent=function(e){return e?Math.max(e.r,Math.max(e.g,e.b)):0},e.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}))},e.prototype._getGLTFTextureSampler=function(e){var t=this._getGLTFTextureWrapModesSampler(e),r=e instanceof n.Texture?e.samplingMode:null;if(null!=r)switch(r){case n.Texture.LINEAR_LINEAR:t.magFilter=9729,t.minFilter=9729;break;case n.Texture.LINEAR_NEAREST:t.magFilter=9729,t.minFilter=9728;break;case n.Texture.NEAREST_LINEAR:t.magFilter=9728,t.minFilter=9729;break;case n.Texture.NEAREST_LINEAR_MIPLINEAR:t.magFilter=9728,t.minFilter=9987;break;case n.Texture.NEAREST_NEAREST:t.magFilter=9728,t.minFilter=9728;break;case n.Texture.NEAREST_LINEAR_MIPNEAREST:t.magFilter=9728,t.minFilter=9985;break;case n.Texture.LINEAR_NEAREST_MIPNEAREST:t.magFilter=9729,t.minFilter=9984;break;case n.Texture.LINEAR_NEAREST_MIPLINEAR:t.magFilter=9729,t.minFilter=9986;break;case n.Texture.NEAREST_NEAREST_MIPLINEAR:t.magFilter=9728,t.minFilter=9986;break;case n.Texture.LINEAR_LINEAR_MIPLINEAR:t.magFilter=9729,t.minFilter=9987;break;case n.Texture.LINEAR_LINEAR_MIPNEAREST:t.magFilter=9729,t.minFilter=9985;break;case n.Texture.NEAREST_NEAREST_MIPNEAREST:t.magFilter=9728,t.minFilter=9984}return t},e.prototype._getGLTFTextureWrapMode=function(e){switch(e){case n.Texture.WRAP_ADDRESSMODE:return 10497;case n.Texture.CLAMP_ADDRESSMODE:return 33071;case n.Texture.MIRROR_ADDRESSMODE:return 33648;default:return n.Tools.Error("Unsupported Texture Wrap Mode "+e+"!"),10497}},e.prototype._getGLTFTextureWrapModesSampler=function(e){var t=this._getGLTFTextureWrapMode(e instanceof n.Texture?e.wrapU:n.Texture.WRAP_ADDRESSMODE),r=this._getGLTFTextureWrapMode(e instanceof n.Texture?e.wrapV:n.Texture.WRAP_ADDRESSMODE);return 10497===t&&10497===r?{}:{wrapS:t,wrapT:r}},e.prototype._convertSpecGlossFactorsToMetallicRoughnessAsync=function(e,t,r,a){var i=this;return Promise.resolve().then((function(){var o=i._exporter._samplers,s=i._exporter._textures,u={diffuseColor:e.albedoColor||n.Color3.White(),specularColor:e.reflectivityColor||n.Color3.White(),glossiness:e.microSurface||1},l=null,c=i._getGLTFTextureSampler(e.albedoTexture);return null!=c.magFilter&&null!=c.minFilter&&null!=c.wrapS&&null!=c.wrapT&&(o.push(c),l=o.length-1),e.reflectivityTexture&&!e.useMicroSurfaceFromReflectivityMapAlpha?Promise.reject("_ConvertPBRMaterial: Glossiness values not included in the reflectivity texture are currently not supported"):(e.albedoTexture||e.reflectivityTexture)&&a?i._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(e.albedoTexture,e.reflectivityTexture,u,t).then((function(n){if(n.baseColorTextureBase64){var a=i._getTextureInfoFromBase64(n.baseColorTextureBase64,"bjsBaseColorTexture_"+s.length+".png",t,e.albedoTexture?e.albedoTexture.coordinatesIndex:null,l);a&&(r.baseColorTexture=a)}if(n.metallicRoughnessTextureBase64){var o=i._getTextureInfoFromBase64(n.metallicRoughnessTextureBase64,"bjsMetallicRoughnessTexture_"+s.length+".png",t,e.reflectivityTexture?e.reflectivityTexture.coordinatesIndex:null,l);o&&(r.metallicRoughnessTexture=o)}return n})):i._convertSpecularGlossinessToMetallicRoughness(u)}))},e.prototype._convertPBRMaterialAsync=function(e,t,r){var n=this,a={},i={name:e.name};return e.isMetallicWorkflow()?(e.albedoColor&&(a.baseColorFactor=[e.albedoColor.r,e.albedoColor.g,e.albedoColor.b,e.alpha]),this._convertMetalRoughFactorsToMetallicRoughnessAsync(e,t,a,r).then((function(o){return n.setMetallicRoughnessPbrMaterial(o,e,i,a,t,r)}))):this._convertSpecGlossFactorsToMetallicRoughnessAsync(e,t,a,r).then((function(o){return n.setMetallicRoughnessPbrMaterial(o,e,i,a,t,r)}))},e.prototype.setMetallicRoughnessPbrMaterial=function(t,r,a,i,o,s){var u=this._exporter._materialMap,l=this._exporter._materials,c=[];if(t){if(e._SetAlphaMode(a,r),e.FuzzyEquals(t.baseColor,n.Color3.White(),e._Epsilon)&&r.alpha>=e._Epsilon||(i.baseColorFactor=[t.baseColor.r,t.baseColor.g,t.baseColor.b,r.alpha]),null!=t.metallic&&1!==t.metallic&&(i.metallicFactor=t.metallic),null!=t.roughness&&1!==t.roughness&&(i.roughnessFactor=t.roughness),null==r.backFaceCulling||r.backFaceCulling||(r.twoSidedLighting||n.Tools.Warn(r.name+": Back-face culling enabled and two-sided lighting disabled is not supported in glTF."),a.doubleSided=!0),s){if(r.bumpTexture){var f=this._exportTextureAsync(r.bumpTexture,o).then((function(e){e&&(a.normalTexture=e,1!==r.bumpTexture.level&&(a.normalTexture.scale=r.bumpTexture.level))}));c.push(f)}if(r.ambientTexture){f=this._exportTextureAsync(r.ambientTexture,o).then((function(e){if(e){var t={index:e.index,texCoord:e.texCoord};a.occlusionTexture=t,r.ambientTextureStrength&&(t.strength=r.ambientTextureStrength)}}));c.push(f)}if(r.emissiveTexture){f=this._exportTextureAsync(r.emissiveTexture,o).then((function(e){e&&(a.emissiveTexture=e)}));c.push(f)}}e.FuzzyEquals(r.emissiveColor,n.Color3.Black(),e._Epsilon)||(a.emissiveFactor=r.emissiveColor.asArray()),a.pbrMetallicRoughness=i,l.push(a),u[r.uniqueId]=l.length-1}return this._finishMaterial(c,a,r,o)},e.prototype.getPixelsFromTexture=function(e){return e.textureType,n.Constants.TEXTURETYPE_UNSIGNED_INT,e.readPixels()},e.prototype._exportTextureAsync=function(e,t){var r=this,n=this._exporter._extensionsPreExportTextureAsync("exporter",e,t);return n?n.then((function(n){return n?r._exportTextureInfoAsync(n,t):r._exportTextureInfoAsync(e,t)})):this._exportTextureInfoAsync(e,t)},e.prototype._exportTextureInfoAsync=function(e,t){var r=this;return Promise.resolve().then((function(){var n=e.uid;if(n in r._textureMap)return r._textureMap[n];var a=r.getPixelsFromTexture(e);if(!a)return null;for(var i=r._exporter._samplers,o=r._getGLTFTextureSampler(e),s=null,u=null,l=0;l<i.length;++l){var c=i[l];if(c.minFilter===o.minFilter&&c.magFilter===o.magFilter&&c.wrapS===o.wrapS&&c.wrapT===o.wrapT){u=l;break}}null==u?(i.push(o),s=i.length-1):s=u;var f=e.getSize();if(e.mimeType)switch(e.mimeType){case"image/jpeg":t="image/jpeg";break;case"image/png":t="image/png"}return r._createBase64FromCanvasAsync(a,f.width,f.height,t).then((function(a){var i=r._getTextureInfoFromBase64(a,e.name.replace(/\.\/|\/|\.\\|\\/g,"_"),t,e.coordinatesIndex,s);return i&&(r._textureMap[n]=i,r._exporter._extensionsPostExportTextures("linkTextureInfo",i,e)),i}))}))},e.prototype._getTextureInfoFromBase64=function(e,t,r,a,i){var o=this._exporter._textures,s=this._exporter._images,u=this._exporter._imageData,l=null,c={source:s.length,name:t};null!=i&&(c.sampler=i);for(var f=atob(e.split(",")[1]),h=new ArrayBuffer(f.length),p=new Uint8Array(h),d=0,m=f.length;d<m;++d)p[d]=f.charCodeAt(d);var g={data:p,mimeType:r},_="image/jpeg"===r?".jpeg":".png",x=t+_,y=x;if(x in u&&(x=t+"_"+n.Tools.RandomId()+_),u[x]=g,"image/jpeg"===r||"image/png"===r){var T={name:t,uri:x},v=null;for(d=0;d<s.length;++d)if(s[d].uri===y){v=d;break}null==v?(s.push(T),c.source=s.length-1):c.source=v,o.push(c),l={index:o.length-1},null!=a&&(l.texCoord=a)}else n.Tools.Error("Unsupported texture mime type "+r);return l},e._DielectricSpecular=new n.Color3(.04,.04,.04),e._MaxSpecularPower=1024,e._Epsilon=1e-6,e}()},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},,function(e,t,r){"use strict";r.r(t),function(e){var n=r(4),a=r(3),i=r(8),o=r(9),s=r(6);r.d(t,"__IGLTFExporterExtension",(function(){return n.__IGLTFExporterExtension})),r.d(t,"_GLTFAnimation",(function(){return s._GLTFAnimation})),r.d(t,"GLTFData",(function(){return s.GLTFData})),r.d(t,"_Exporter",(function(){return s._Exporter})),r.d(t,"_BinaryWriter",(function(){return s._BinaryWriter})),r.d(t,"__IGLTFExporterExtensionV2",(function(){return s.__IGLTFExporterExtensionV2})),r.d(t,"_GLTFMaterialExporter",(function(){return s._GLTFMaterialExporter})),r.d(t,"GLTF2Export",(function(){return s.GLTF2Export})),r.d(t,"_GLTFUtilities",(function(){return s._GLTFUtilities})),r.d(t,"KHR_texture_transform",(function(){return s.KHR_texture_transform})),r.d(t,"KHR_lights_punctual",(function(){return s.KHR_lights_punctual})),r.d(t,"KHR_materials_sheen",(function(){return s.KHR_materials_sheen})),r.d(t,"KHR_materials_unlit",(function(){return s.KHR_materials_unlit}));var u=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==u){u.BABYLON=u.BABYLON||{};var l=u.BABYLON;l.GLTF2=l.GLTF2||{},l.GLTF2.Exporter=l.GLTF2.Exporter||{},l.GLTF2.Exporter.Extensions=l.GLTF2.Exporter.Extensions||{};var c=[];for(var f in n)l[f]=n[f],c.push(f);for(var f in a)l[f]=a[f],c.push(f);for(var f in i)l[f]=i[f],c.push(f);for(var f in o)l.GLTF2.Exporter.Extensions[f]=o[f],c.push(f);for(var f in s)c.indexOf(f)>-1||(l.GLTF2.Exporter[f]=s[f])}}.call(this,r(11))}])}));