12 |
- !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)}(window,function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.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 i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));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=7)}([function(t,r){t.exports=e},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),i=function(){function e(){}return e._CreateBufferView=function(e,t,r,n,i){var a={buffer:e,byteLength:r};return t&&(a.byteOffset=t),i&&(a.name=i),n&&(a.byteStride=n),a},e._CreateAccessor=function(e,t,r,n,i,a,o,s){var l={name:t,bufferView:e,componentType:n,count:i,type:r};return null!=o&&(l.min=o),null!=s&&(l.max=s),null!=a&&(l.byteOffset=a),l},e._CalculateMinMaxPositions=function(t,r,i,a){var o,s,l,u=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];if(i)for(var f=r,h=r+i;f<h;++f){o=3*f,s=n.Vector3.FromArray(t,o),a&&e._GetRightHandedPositionVector3FromRef(s),l=s.asArray();for(var p=0;p<3;++p){var d=l[p];d<u[p]&&(u[p]=d),d>c[p]&&(c[p]=d),++o}}return{min:u,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}();t._GLTFUtilities=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),i=r(6),a=r(1),o=r(5),s=r(4),l=function(){function e(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 i._GLTFMaterialExporter(this),this._loadExtensions()}return e.prototype._applyExtensions=function(t,r){for(var n=0,i=e._ExtensionNames;n<i.length;n++){var a=i[n],o=this._extensions[a];if(o.enabled){var s=t;s._activeLoaderExtensions=s._activeLoaderExtensions||{};var l=s._activeLoaderExtensions;if(!l[a]){l[a]=!0;try{var u=r(o);if(u)return u}finally{delete l[a],delete s._activeLoaderExtensions}}}}return null},e.prototype._extensionsPreExportTextureAsync=function(e,t,r){return this._applyExtensions(t,function(n){return n.preExportTextureAsync&&n.preExportTextureAsync(e,t,r)})},e.prototype._extensionsPostExportMeshPrimitiveAsync=function(e,t,r,n){return this._applyExtensions(t,function(i){return i.postExportMeshPrimitiveAsync&&i.postExportMeshPrimitiveAsync(e,t,r,n)})},e.prototype._loadExtensions=function(){for(var t=0,r=e._ExtensionNames;t<r.length;t++){var n=r[t],i=e._ExtensionFactories[n](this);this._extensions[n]=i}},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:!1,preserveDrawingBuffer:!0}),this._localEngine.setViewport(new n.Viewport(0,0,1,1))}return this._localEngine},e.prototype.reorderIndicesBasedOnPrimitiveMode=function(e,t,r,i,a){switch(t){case n.Material.TriangleFillMode:i||(i=0);for(var o=e.indexStart,s=e.indexStart+e.indexCount;o<s;o+=3){var l=i+4*o,u=a.getUInt32(l+4),c=a.getUInt32(l+8);a.setUInt32(c,l+4),a.setUInt32(u,l+8)}break;case n.Material.TriangleFanDrawMode:o=e.indexStart+e.indexCount-1;for(var f=e.indexStart;o>=f;--o)a.setUInt32(r[o],i),i+=4;break;case n.Material.TriangleStripDrawMode:e.indexCount>=3&&(a.setUInt32(r[e.indexStart+2],i+4),a.setUInt32(r[e.indexStart+1],i+8))}},e.prototype.reorderVertexAttributeDataBasedOnPrimitiveMode=function(e,t,r,i,a,o,s){if(this._convertToRightHandedSystem&&r===n.Material.ClockWiseSideOrientation)switch(t){case n.Material.TriangleFillMode:this.reorderTriangleFillMode(e,t,r,i,a,o,s);break;case n.Material.TriangleStripDrawMode:this.reorderTriangleStripDrawMode(e,t,r,i,a,o,s);break;case n.Material.TriangleFanDrawMode:this.reorderTriangleFanMode(e,t,r,i,a,o,s)}},e.prototype.reorderTriangleFillMode=function(e,t,r,i,a,o,s){var l=this.getVertexBufferFromMesh(i,e.getMesh());if(l){var u=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 c=[],f=0;switch(i){case n.VertexBuffer.PositionKind:case n.VertexBuffer.NormalKind:for(var h=e.verticesStart;h<e.verticesStart+e.verticesCount;h+=3)f=h*u,c.push(n.Vector3.FromArray(a,f)),c.push(n.Vector3.FromArray(a,f+2*u)),c.push(n.Vector3.FromArray(a,f+u));break;case n.VertexBuffer.TangentKind:for(h=e.verticesStart;h<e.verticesStart+e.verticesCount;h+=3)f=h*u,c.push(n.Vector4.FromArray(a,f)),c.push(n.Vector4.FromArray(a,f+2*u)),c.push(n.Vector4.FromArray(a,f+u));break;case n.VertexBuffer.ColorKind:var p=l.getSize();for(h=e.verticesStart;h<e.verticesStart+e.verticesCount;h+=p)f=h*u,4===p?(c.push(n.Vector4.FromArray(a,f)),c.push(n.Vector4.FromArray(a,f+2*u)),c.push(n.Vector4.FromArray(a,f+u))):(c.push(n.Vector3.FromArray(a,f)),c.push(n.Vector3.FromArray(a,f+2*u)),c.push(n.Vector3.FromArray(a,f+u)));break;case n.VertexBuffer.UVKind:case n.VertexBuffer.UV2Kind:for(h=e.verticesStart;h<e.verticesStart+e.verticesCount;h+=3)f=h*u,c.push(n.Vector2.FromArray(a,f)),c.push(n.Vector2.FromArray(a,f+2*u)),c.push(n.Vector2.FromArray(a,f+u));break;default:n.Tools.Error("Unsupported Vertex Buffer type: "+i)}this.writeVertexAttributeData(c,o,i,a,s)}}else n.Tools.Warn("reorderTriangleFillMode: Vertex Buffer Kind "+i+" not present!")},e.prototype.reorderTriangleStripDrawMode=function(e,t,r,i,a,o,s){var l=this.getVertexBufferFromMesh(i,e.getMesh());if(l){var u=l.byteStride/n.VertexBuffer.GetTypeByteLength(l.type),c=[],f=0;switch(i){case n.VertexBuffer.PositionKind:case n.VertexBuffer.NormalKind:f=e.verticesStart,c.push(n.Vector3.FromArray(a,f+2*u)),c.push(n.Vector3.FromArray(a,f+u));break;case n.VertexBuffer.TangentKind:for(var h=e.verticesStart+e.verticesCount-1;h>=e.verticesStart;--h)f=h*u,c.push(n.Vector4.FromArray(a,f));break;case n.VertexBuffer.ColorKind:for(h=e.verticesStart+e.verticesCount-1;h>=e.verticesStart;--h)f=h*u,4===l.getSize()?c.push(n.Vector4.FromArray(a,f)):c.push(n.Vector3.FromArray(a,f));break;case n.VertexBuffer.UVKind:case n.VertexBuffer.UV2Kind:for(h=e.verticesStart+e.verticesCount-1;h>=e.verticesStart;--h)f=h*u,c.push(n.Vector2.FromArray(a,f));break;default:n.Tools.Error("Unsupported Vertex Buffer type: "+i)}this.writeVertexAttributeData(c,o+12,i,a,s)}else n.Tools.Warn("reorderTriangleStripDrawMode: Vertex buffer kind "+i+" not present!")},e.prototype.reorderTriangleFanMode=function(e,t,r,i,a,o,s){var l=this.getVertexBufferFromMesh(i,e.getMesh());if(l){var u=l.byteStride/n.VertexBuffer.GetTypeByteLength(l.type),c=[],f=0;switch(i){case n.VertexBuffer.PositionKind:case n.VertexBuffer.NormalKind:for(var h=e.verticesStart+e.verticesCount-1;h>=e.verticesStart;--h)f=h*u,c.push(n.Vector3.FromArray(a,f));break;case n.VertexBuffer.TangentKind:for(h=e.verticesStart+e.verticesCount-1;h>=e.verticesStart;--h)f=h*u,c.push(n.Vector4.FromArray(a,f));break;case n.VertexBuffer.ColorKind:for(h=e.verticesStart+e.verticesCount-1;h>=e.verticesStart;--h)f=h*u,c.push(n.Vector4.FromArray(a,f)),4===l.getSize()?c.push(n.Vector4.FromArray(a,f)):c.push(n.Vector3.FromArray(a,f));break;case n.VertexBuffer.UVKind:case n.VertexBuffer.UV2Kind:for(h=e.verticesStart+e.verticesCount-1;h>=e.verticesStart;--h)f=h*u,c.push(n.Vector2.FromArray(a,f));break;default:n.Tools.Error("Unsupported Vertex Buffer type: "+i)}this.writeVertexAttributeData(c,o,i,a,s)}else n.Tools.Warn("reorderTriangleFanMode: Vertex buffer kind "+i+" not present!")},e.prototype.writeVertexAttributeData=function(e,t,r,i,o){for(var s=0,l=e;s<l.length;s++){var u=l[s];!this._convertToRightHandedSystem||r===n.VertexBuffer.ColorKind||u instanceof n.Vector2||(u instanceof n.Vector3?r===n.VertexBuffer.NormalKind?a._GLTFUtilities._GetRightHandedNormalVector3FromRef(u):r===n.VertexBuffer.PositionKind?a._GLTFUtilities._GetRightHandedPositionVector3FromRef(u):n.Tools.Error("Unsupported vertex attribute kind!"):a._GLTFUtilities._GetRightHandedVector4FromRef(u)),r===n.VertexBuffer.NormalKind?u.normalize():r===n.VertexBuffer.TangentKind&&u instanceof n.Vector4&&a._GLTFUtilities._NormalizeTangentFromRef(u);for(var c=0,f=u.asArray();c<f.length;c++){var h=f[c];o.setFloat32(h,t),t+=4}}},e.prototype.writeAttributeData=function(e,t,r,i){var o,s=r/4,l=[];switch(e){case n.VertexBuffer.PositionKind:for(var u=0,c=t.length/s;u<c;++u){o=u*s;var f=n.Vector3.FromArray(t,o);this._convertToRightHandedSystem&&a._GLTFUtilities._GetRightHandedPositionVector3FromRef(f),l.push(f.asArray())}break;case n.VertexBuffer.NormalKind:u=0;for(var h=t.length/s;u<h;++u){o=u*s;f=n.Vector3.FromArray(t,o);this._convertToRightHandedSystem&&a._GLTFUtilities._GetRightHandedNormalVector3FromRef(f),f.normalize(),l.push(f.asArray())}break;case n.VertexBuffer.TangentKind:u=0;for(var p=t.length/s;u<p;++u){o=u*s;f=n.Vector4.FromArray(t,o);this._convertToRightHandedSystem&&a._GLTFUtilities._GetRightHandedVector4FromRef(f),a._GLTFUtilities._NormalizeTangentFromRef(f),l.push(f.asArray())}break;case n.VertexBuffer.ColorKind:u=0;for(var d=t.length/s;u<d;++u){o=u*s;f=3===s?n.Vector3.FromArray(t,o):n.Vector4.FromArray(t,o);l.push(f.asArray())}break;case n.VertexBuffer.UVKind:case n.VertexBuffer.UV2Kind:u=0;for(var m=t.length/s;u<m;++u)o=u*s,l.push((this._convertToRightHandedSystem,[t[o],t[o+1]]));break;default:n.Tools.Warn("Unsupported Vertex Buffer Type: "+e),l=[]}for(var g=0,_=l;g<_.length;g++)for(var y=0,x=_[g];y<x.length;y++){var T=x[y];i.setFloat32(T)}},e.prototype.generateJSON=function(e,t,r){var n,i,o,s=this,l={byteLength:this._totalByteLength},u=this._totalByteLength,c={asset:this._asset};return this._extensionsUsed&&this._extensionsUsed.length&&(c.extensionsUsed=this._extensionsUsed),this._extensionsRequired&&this._extensionsRequired.length&&(c.extensionsRequired=this._extensionsRequired),l.byteLength&&(c.buffers=[l]),this._nodes&&this._nodes.length&&(c.nodes=this._nodes),this._meshes&&this._meshes.length&&(c.meshes=this._meshes),this._scenes&&this._scenes.length&&(c.scenes=this._scenes,c.scene=0),this._bufferViews&&this._bufferViews.length&&(c.bufferViews=this._bufferViews),this._accessors&&this._accessors.length&&(c.accessors=this._accessors),this._animations&&this._animations.length&&(c.animations=this._animations),this._materials&&this._materials.length&&(c.materials=this._materials),this._textures&&this._textures.length&&(c.textures=this._textures),this._samplers&&this._samplers.length&&(c.samplers=this._samplers),this._images&&this._images.length&&(e?(c.images=[],this._images.forEach(function(e){e.uri&&(i=s._imageData[e.uri],n=e.uri.split(".")[0]+" image",o=a._GLTFUtilities._CreateBufferView(0,u,i.data.length,void 0,n),u+=i.data.buffer.byteLength,s._bufferViews.push(o),e.bufferView=s._bufferViews.length-1,e.name=n,e.mimeType=i.mimeType,e.uri=void 0,c.images||(c.images=[]),c.images.push(e))}),l.byteLength=u):c.images=this._images),e||(l.uri=t+".bin"),r?JSON.stringify(c,null,2):JSON.stringify(c)},e.prototype._generateGLTFAsync=function(e){var t=this;return this._generateBinaryAsync().then(function(r){var n=t.generateJSON(!1,e,!0),i=new Blob([r],{type:"application/octet-stream"}),a=e+".gltf",s=e+".bin",l=new o.GLTFData;if(l.glTFFiles[a]=n,l.glTFFiles[s]=i,t._imageData)for(var u in t._imageData)l.glTFFiles[u]=new Blob([t._imageData[u].data],{type:t._imageData[u].mimeType});return l})},e.prototype._generateBinaryAsync=function(){var e=this,t=new u(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){var t=this;return this._generateBinaryAsync().then(function(r){var n=t.generateJSON(!0),i=e+".glb",a=n.length,s=0;for(var l in t._imageData)s+=t._imageData[l].data.byteLength;var u=t._getPadding(a),c=t._getPadding(r.byteLength),f=t._getPadding(s),h=28+a+u+r.byteLength+c+s+f,p=new ArrayBuffer(12),d=new DataView(p);d.setUint32(0,1179937895,!0),d.setUint32(4,2,!0),d.setUint32(8,h,!0);var m=new ArrayBuffer(8+a+u),g=new DataView(m);g.setUint32(0,a+u,!0),g.setUint32(4,1313821514,!0);for(var _=new Uint8Array(m,8),y=0;y<a;++y)_[y]=n.charCodeAt(y);var x=new Uint8Array(m,8+a);for(y=0;y<u;++y)x[y]=32;var T=new ArrayBuffer(8),v=new DataView(T);v.setUint32(0,r.byteLength+s+f,!0),v.setUint32(4,5130562,!0);var b=new ArrayBuffer(c),A=new Uint8Array(b);for(y=0;y<c;++y)A[y]=0;var F=new ArrayBuffer(f),M=new Uint8Array(F);for(y=0;y<f;++y)M[y]=0;var E=[p,m,T,r];for(var l in t._imageData)E.push(t._imageData[l].data.buffer);E.push(b),E.push(F);var S=new Blob(E,{type:"application/octet-stream"}),R=new o.GLTFData;return R.glTFFiles[i]=S,null!=t._localEngine&&t._localEngine.dispose(),R})},e.prototype.setNodeTransformation=function(e,t){t.getPivotPoint().equalsToFloats(0,0,0)||BABYLON.Tools.Warn("Pivot points are not supported in the glTF serializer"),t.position.equalsToFloats(0,0,0)||(e.translation=this._convertToRightHandedSystem?a._GLTFUtilities._GetRightHandedPositionVector3(t.position).asArray():t.position.asArray()),t.scaling.equalsToFloats(1,1,1)||(e.scale=t.scaling.asArray());var r=n.Quaternion.RotationYawPitchRoll(t.rotation.y,t.rotation.x,t.rotation.z);t.rotationQuaternion&&r.multiplyInPlace(t.rotationQuaternion),0===r.x&&0===r.y&&0===r.z&&1===r.w||(this._convertToRightHandedSystem&&a._GLTFUtilities._GetRightHandedQuaternionFromRef(r),e.rotation=r.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,i){var o=t instanceof n.Mesh?t:t instanceof n.InstancedMesh?t.sourceMesh:null;if(o){var s=o.getVerticesData(e);if(s){var l=4*s.length,u=a._GLTFUtilities._CreateBufferView(0,r.getByteOffset(),l,i,e+" - "+o.name);this._bufferViews.push(u),this.writeAttributeData(e,s,i,r)}}},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;default:n.Tools.Warn("Unsupported Vertex Buffer Type: "+t)}},e.prototype.setPrimitiveAttributesAsync=function(e,t,r){var i,o,s,l=[],u=null;t instanceof n.Mesh?u=t:t instanceof n.InstancedMesh&&(u=t.sourceMesh);var c=[{kind:n.VertexBuffer.PositionKind,accessorType:"VEC3",byteStride:12},{kind:n.VertexBuffer.NormalKind,accessorType:"VEC3",byteStride:12},{kind:n.VertexBuffer.ColorKind,accessorType:"VEC4",byteStride:16},{kind:n.VertexBuffer.TangentKind,accessorType:"VEC4",byteStride:16},{kind:n.VertexBuffer.UVKind,accessorType:"VEC2",byteStride:8},{kind:n.VertexBuffer.UV2Kind,accessorType:"VEC2",byteStride:8}];if(u){for(var f=null,h=this.getMeshPrimitiveMode(u),p={},d=0,m=c;d<m.length;d++){var g=(K=m[d]).kind;if(u.isVerticesDataPresent(g)){var _=this.getVertexBufferFromMesh(g,u);K.byteStride=_?4*_.getSize():4*n.VertexBuffer.DeduceStride(g),12===K.byteStride&&(K.accessorType="VEC3"),this.createBufferViewKind(g,t,r,K.byteStride),K.bufferViewIndex=this._bufferViews.length-1,p[g]=K.bufferViewIndex}}if(u.getTotalIndices()){var y=u.getIndices();if(y){var x=4*y.length;i=a._GLTFUtilities._CreateBufferView(0,r.getByteOffset(),x,void 0,"Indices - "+u.name),this._bufferViews.push(i),f=this._bufferViews.length-1;for(var T=0,v=y.length;T<v;++T)r.setUInt32(y[T])}}if(u.subMeshes)for(var b=0,A=u.subMeshes;b<A.length;b++){var F=A[b];o=!1;var M=F.getMaterial()||u.getScene().defaultMaterial,E=null;if(M)if(u instanceof n.LinesMesh){var S={name:u.name+" material"};(!u.color.equals(n.Color3.White())||u.alpha<1)&&(S.pbrMetallicRoughness={baseColorFactor:u.color.asArray().concat([u.alpha])}),this._materials.push(S),E=this._materials.length-1}else if(M instanceof n.MultiMaterial){var R=M.subMaterials[F.materialIndex];R&&(M=R,E=this._materialMap[M.uniqueId])}else E=this._materialMap[M.uniqueId];var V=null!=E?this._materials[E]:null,w={attributes:{}};this.setPrimitiveMode(w,h);for(var B=0,C=c;B<C.length;B++){if((g=(K=C[B]).kind)!==n.VertexBuffer.UVKind&&g!==n.VertexBuffer.UV2Kind||!V||this._glTFMaterialExporter._hasTexturesPresent(V))if(k=u.getVerticesData(g))if(_=this.getVertexBufferFromMesh(g,u)){var P=_.getSize(),L=K.bufferViewIndex;if(void 0!=L){s={min:null,max:null},g==n.VertexBuffer.PositionKind&&(s=a._GLTFUtilities._CalculateMinMaxPositions(k,0,k.length/P,this._convertToRightHandedSystem));var N=a._GLTFUtilities._CreateAccessor(L,g+" - "+t.name,K.accessorType,5126,k.length/P,0,s.min,s.max);this._accessors.push(N),this.setAttributeKind(w,g),null==w.attributes.TEXCOORD_0&&null==w.attributes.TEXCOORD_1||(o=!0)}}}if(f){N=a._GLTFUtilities._CreateAccessor(f,"indices - "+t.name,"SCALAR",5125,F.indexCount,4*F.indexStart,null,null);this._accessors.push(N),w.indices=this._accessors.length-1}if(null!=E&&Object.keys(w.attributes).length>0){var O=M.sideOrientation;if(this._convertToRightHandedSystem&&O===n.Material.ClockWiseSideOrientation){var I=null!=f?this._bufferViews[f].byteOffset:null;null==I&&(I=0);var U=null;if(null!=f&&(U=u.getIndices()),U)this.reorderIndicesBasedOnPrimitiveMode(F,h,U,I,r);else for(var G=0,D=c;G<D.length;G++){var k,K=D[G];if(k=u.getVerticesData(K.kind)){var z=this._bufferViews[p[K.kind]].byteOffset;z||(z=0),this.reorderVertexAttributeDataBasedOnPrimitiveMode(F,h,O,K.kind,k,z,r)}}}if(!o&&this._glTFMaterialExporter._hasTexturesPresent(this._materials[E])){var W=this._glTFMaterialExporter._stripTexturesFromMaterial(this._materials[E]);this._materials.push(W),E=this._materials.length-1}w.material=E}e.primitives.push(w),this._extensionsPostExportMeshPrimitiveAsync("postExport",w,F,r)&&l.push()}}return Promise.all(l).then(function(){})},e.prototype.createSceneAsync=function(e,t){var r,i,a,o=this,s={nodes:[]},l=e.transformNodes.concat(e.meshes);return this._glTFMaterialExporter._convertMaterialsToGLTFAsync(e.materials,"image/png",!0).then(function(){return o.createNodeMapAndAnimationsAsync(e,l,o._shouldExportTransformNode,t).then(function(e){if(o._nodeMap=e,o._totalByteLength=t.getByteOffset(),void 0==o._totalByteLength)throw new Error("undefined byte length!");for(var u=0,c=l;u<c.length;u++){var f=c[u];if(null!=(r=o._nodeMap[f.uniqueId])&&(i=o._nodes[r],f.parent||(o._shouldExportTransformNode(f)?(o._convertToRightHandedSystem&&(i.translation&&(i.translation[2]*=-1,i.translation[0]*=-1),i.rotation=i.rotation?n.Quaternion.FromArray([0,1,0,0]).multiply(n.Quaternion.FromArray(i.rotation)).asArray():n.Quaternion.FromArray([0,1,0,0]).asArray()),s.nodes.push(r)):n.Tools.Log("Omitting "+f.name+" from scene.")),a=f.getDescendants(!0),!i.children&&a&&a.length)){for(var h=[],p=0,d=a;p<d.length;p++){var m=d[p];null!=o._nodeMap[m.uniqueId]&&h.push(o._nodeMap[m.uniqueId])}h.length&&(i.children=h)}}s.nodes.length&&o._scenes.push(s)})})},e.prototype.createNodeMapAndAnimationsAsync=function(e,t,r,i){for(var a,o=this,l=Promise.resolve(),u={},c={name:"runtime animations",channels:[],samplers:[]},f=[],h=function(t){r(t)?l=l.then(function(){return o.createNodeAsync(t,i).then(function(r){(t.getDescendants(!0,function(e){return e instanceof n.TransformNode}).length||null!=r.mesh)&&(o._nodes.push(r),a=o._nodes.length-1,u[t.uniqueId]=a),!e.animationGroups.length&&t.animations.length&&s._GLTFAnimation._CreateNodeAnimationFromTransformNodeAnimations(t,c,f,u,o._nodes,i,o._bufferViews,o._accessors,o._convertToRightHandedSystem,o._animationSampleRate)})}):t.name},p=0,d=t;p<d.length;p++){h(d[p])}return l.then(function(){return c.channels.length&&c.samplers.length&&o._animations.push(c),f.forEach(function(e){e.channels.length&&e.samplers.length&&o._animations.push(e)}),e.animationGroups.length&&s._GLTFAnimation._CreateNodeAnimationFromAnimationGroups(e,o._animations,u,o._nodes,i,o._bufferViews,o._accessors,o._convertToRightHandedSystem,o._animationSampleRate),u})},e.prototype.createNodeAsync=function(e,t){var r=this;return Promise.resolve().then(function(){var n={},i={primitives:[]};return e.name&&(n.name=e.name),r.setNodeTransformation(n,e),r.setPrimitiveAttributesAsync(i,e,t).then(function(){return i.primitives.length&&(r._meshes.push(i),n.mesh=r._meshes.length-1),n})})},e._ExtensionNames=new Array,e._ExtensionFactories={},e}();t._Exporter=l;var u=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),i=0,a=n.byteLength;i<a;++i)n[i]=r[i];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(void 0==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))},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}();t._BinaryWriter=u},function(e,t,r){"use strict";function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0}),n(r(9)),n(r(11))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n,i=r(0),a=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,a,o,s){var l=[],u=[],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,l,u,f,a,o):"LINEAR"===d||"STEP"===d?e._CreateLinearOrStepAnimation(t,r,n,p,l,u,a,o):"CUBICSPLINE"===d?e._CreateCubicSplineAnimation(t,r,n,p,l,u,a,o):e._CreateBakedAnimation(t,r,n,f.min,f.max,r.framePerSecond,s,l,u,f,a,o),l.length&&u.length?{inputs:l,outputs:u,samplerInterpolation:d,inputsMin:m?f.min:i.Tools.FloatRound(f.min/r.framePerSecond),inputsMax:m?f.max:i.Tools.FloatRound(f.max/r.framePerSecond)}:null},e._DeduceAnimationInfo=function(e){var t=null,r="VEC3",n=!1,a=e.targetProperty.split(".");switch(a[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;default:i.Tools.Error("Unsupported animatable property "+a[0])}return t?{animationChannelTargetPath:t,dataAccessorType:r,useQuaternion:n}:(i.Tools.Error("animation channel target path and data accessor type could be deduced"),null)},e._CreateNodeAnimationFromTransformNodeAnimations=function(t,r,n,i,a,o,s,l,u,c){var f;if(t.animations)for(var h=0,p=t.animations;h<p.length;h++){var d=p[h],m=e._DeduceAnimationInfo(d);m&&(f={name:d.name,samplers:[],channels:[]},e.AddAnimation(""+d.name,d.hasRunningRuntimeAnimations?r:f,t,d,m.dataAccessorType,m.animationChannelTargetPath,i,o,s,l,u,m.useQuaternion,c),f.samplers.length&&f.channels.length&&n.push(f))}},e._CreateNodeAnimationFromAnimationGroups=function(t,r,n,a,o,s,l,u,c){var f;if(t.animationGroups)for(var h=0,p=t.animationGroups;h<p.length;h++){var d=p[h];f={name:d.name,channels:[],samplers:[]};for(var m=0,g=d.targetedAnimations;m<g.length;m++){var _=g[m],y=_.target,x=_.animation;if(y instanceof i.Mesh||1===y.length&&y[0]instanceof i.Mesh){var T=e._DeduceAnimationInfo(_.animation);if(T){var v=y instanceof i.Mesh?y:y[0];e.AddAnimation(""+x.name,f,v,x,T.dataAccessorType,T.animationChannelTargetPath,n,o,s,l,u,T.useQuaternion,c)}}}f.channels.length&&f.samplers.length&&r.push(f)}},e.AddAnimation=function(t,r,n,i,o,s,l,u,c,f,h,p,d){var m,g,_,y,x,T,v,b=e._CreateNodeAnimation(n,i,s,h,p,d);if(b){var A=l[n.uniqueId],F=4*b.inputs.length;m=a._GLTFUtilities._CreateBufferView(0,u.getByteOffset(),F,void 0,t+" keyframe data view"),c.push(m),b.inputs.forEach(function(e){u.setFloat32(e)}),g=a._GLTFUtilities._CreateAccessor(c.length-1,t+" keyframes","SCALAR",5126,b.inputs.length,null,[b.inputsMin],[b.inputsMax]),f.push(g),_=f.length-1,x=b.outputs.length,F="VEC3"===o?12*b.outputs.length:16*b.outputs.length,m=a._GLTFUtilities._CreateBufferView(0,u.getByteOffset(),F,void 0,t+" data view"),c.push(m),b.outputs.forEach(function(e){e.forEach(function(e){u.setFloat32(e)})}),g=a._GLTFUtilities._CreateAccessor(c.length-1,t+" data",o,5126,x,null,null,null),f.push(g),y=f.length-1,T={interpolation:b.samplerInterpolation,input:_,output:y},r.samplers.push(T),v={sampler:r.samplers.length-1,target:{node:A,path:s}},r.channels.push(v)}},e._CreateBakedAnimation=function(t,r,n,a,o,s,l,u,c,f,h,p){var d,m,g=i.Quaternion.Identity(),_=null,y=null,x=null,T=null,v=null,b=null;f.min=i.Tools.FloatRound(a/s);for(var A=r.getKeys(),F=0,M=A.length;F<M;++F){if(b=null,x=A[F],F+1<M)if(T=A[F+1],x.value.equals(T.value)){if(0!==F)continue;b=x.frame}else b=T.frame;else{if(v=A[F-1],x.value.equals(v.value))continue;b=o}if(b)for(var E=x.frame;E<=b;E+=l)(m=i.Tools.FloatRound(E/s))!==_&&(_=m,y=m,d=r._interpolate(E,0,void 0,r.loopMode),e._SetInterpolatedValue(t,d,m,r,n,g,u,c,h,p))}y&&(f.max=y)},e._ConvertFactorToVector3OrQuaternion=function(t,r,n,a,o,s,l){var u,c,f=null,h=e._GetBasePositionRotationOrScale(r,o,s,l);if(a===i.Animation.ANIMATIONTYPE_FLOAT)switch(c=(u=n.targetProperty.split("."))?u[1]:"",f=l?BABYLON.Quaternion.FromArray(h).normalize():BABYLON.Vector3.FromArray(h),c){case"x":case"y":f[c]=s&&l&&"scale"!==o?-t:t;break;case"z":f[c]=s&&!l&&"scale"!==o?-t:t;break;case"w":f.w=t;break;default:i.Tools.Error('glTFAnimation: Unsupported component type "'+c+'" for scale animation!')}return f},e._SetInterpolatedValue=function(e,t,r,n,o,s,l,u,c,f){var h,p=n.dataType;l.push(r),"number"==typeof t&&(t=this._ConvertFactorToVector3OrQuaternion(t,e,n,p,o,c,f)),t&&("rotation"===o?(f?s=t:(h=t,i.Quaternion.RotationYawPitchRollToRef(h.y,h.x,h.z,s)),c&&(a._GLTFUtilities._GetRightHandedQuaternionFromRef(s),e.parent||(s=i.Quaternion.FromArray([0,1,0,0]).multiply(s))),u.push(s.asArray())):(h=t,c&&"scale"!==o&&(a._GLTFUtilities._GetRightHandedPositionVector3FromRef(h),e.parent||(h.x*=-1,h.z*=-1)),u.push(h.asArray())))},e._CreateLinearOrStepAnimation=function(t,r,n,i,a,o,s,l){for(var u=0,c=r.getKeys();u<c.length;u++){var f=c[u];a.push(f.frame/r.framePerSecond),e._AddKeyframeValue(f,r,o,n,t,s,l)}},e._CreateCubicSplineAnimation=function(t,r,i,a,o,s,l,u){r.getKeys().forEach(function(c){o.push(c.frame/r.framePerSecond),e.AddSplineTangent(t,n.INTANGENT,s,i,"CUBICSPLINE",c,a,u,l),e._AddKeyframeValue(c,r,s,i,t,l,u),e.AddSplineTangent(t,n.OUTTANGENT,s,i,"CUBICSPLINE",c,a,u,l)})},e._GetBasePositionRotationOrScale=function(e,t,r,n){var o;return"rotation"===t?n?e.rotationQuaternion?(o=e.rotationQuaternion.asArray(),r&&(a._GLTFUtilities._GetRightHandedQuaternionArrayFromRef(o),e.parent||(o=i.Quaternion.FromArray([0,1,0,0]).multiply(i.Quaternion.FromArray(o)).asArray()))):o=BABYLON.Quaternion.Identity().asArray():(o=e.rotation.asArray(),a._GLTFUtilities._GetRightHandedNormalArray3FromRef(o)):"translation"===t?(o=e.position.asArray(),r&&a._GLTFUtilities._GetRightHandedPositionArray3FromRef(o)):o=e.scaling.asArray(),o},e._AddKeyframeValue=function(e,t,r,n,o,s,l){var u,c,f=t.dataType;if(f===i.Animation.ANIMATIONTYPE_VECTOR3){if(u=e.value.asArray(),"rotation"===n){var h=i.Vector3.FromArray(u),p=i.Quaternion.RotationYawPitchRoll(h.y,h.x,h.z);s&&(a._GLTFUtilities._GetRightHandedQuaternionFromRef(p),o.parent||(p=i.Quaternion.FromArray([0,1,0,0]).multiply(p))),u=p.asArray()}else"translation"===n&&s&&(a._GLTFUtilities._GetRightHandedNormalArray3FromRef(u),o.parent||(u[0]*=-1,u[2]*=-1));r.push(u)}else if(f===i.Animation.ANIMATIONTYPE_FLOAT){if(c=this._ConvertFactorToVector3OrQuaternion(e.value,o,t,f,n,s,l)){if("rotation"===n){var d=l?c:i.Quaternion.RotationYawPitchRoll(c.y,c.x,c.z).normalize();s&&(a._GLTFUtilities._GetRightHandedQuaternionFromRef(d),o.parent||(d=i.Quaternion.FromArray([0,1,0,0]).multiply(d))),r.push(d.asArray())}else"translation"===n&&s&&(a._GLTFUtilities._GetRightHandedNormalVector3FromRef(c),o.parent||(c.x*=-1,c.z*=-1));r.push(c.asArray())}}else f===i.Animation.ANIMATIONTYPE_QUATERNION?(u=e.value.normalize().asArray(),s&&(a._GLTFUtilities._GetRightHandedQuaternionArrayFromRef(u),o.parent||(u=i.Quaternion.FromArray([0,1,0,0]).multiply(i.Quaternion.FromArray(u)).asArray())),r.push(u)):i.Tools.Error("glTFAnimation: Unsupported key frame values for animation!")},e._DeduceInterpolation=function(e,t,r){var n,a,o=!1;if("rotation"===t&&!r)return{interpolationType:"LINEAR",shouldBakeAnimation:!0};for(var s=0,l=e.length;s<l;++s)if((a=e[s]).inTangent||a.outTangent)if(n){if("CUBICSPLINE"!==n){n="LINEAR",o=!0;break}}else n="CUBICSPLINE";else if(n){if("CUBICSPLINE"===n||a.interpolation&&a.interpolation===i.AnimationKeyInterpolation.STEP&&"STEP"!==n){n="LINEAR",o=!0;break}}else n=a.interpolation&&a.interpolation===i.AnimationKeyInterpolation.STEP?"STEP":"LINEAR";return n||(n="LINEAR"),{interpolationType:n,shouldBakeAnimation:o}},e.AddSplineTangent=function(e,t,r,o,s,l,u,c,f){var h,p=t===n.INTANGENT?l.inTangent:l.outTangent;if("CUBICSPLINE"===s){if("rotation"===o)if(p){if(c)h=p.scale(u).asArray();else{var d=p.scale(u);h=i.Quaternion.RotationYawPitchRoll(d.y,d.x,d.z).asArray()}f&&(a._GLTFUtilities._GetRightHandedQuaternionArrayFromRef(h),e.parent||(h=i.Quaternion.FromArray([0,1,0,0]).multiply(i.Quaternion.FromArray(h)).asArray()))}else h=[0,0,0,0];else p?(h=p.scale(u).asArray(),f&&"translation"===o&&(a._GLTFUtilities._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}();t._GLTFAnimation=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});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],i=void 0;e(t,".glb")?i={type:"model/gltf-binary"}:e(t,".bin")?i={type:"application/octet-stream"}:e(t,".gltf")?i={type:"model/gltf+json"}:e(t,".jpeg")?i={type:"image/jpeg"}:e(t,".png")&&(i={type:"image/png"}),r.href=window.URL.createObjectURL(new Blob([n],i)),r.click()}},e}();t.GLTFData=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),i=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 i=[],a=0,o=e;a<o.length;a++){var s=o[a];s instanceof n.StandardMaterial?i.push(this._convertStandardMaterialAsync(s,t,r)):s instanceof n.PBRMetallicRoughnessMaterial?i.push(this._convertPBRMetallicRoughnessMaterialAsync(s,t,r)):s instanceof n.PBRMaterial?i.push(this._convertPBRMaterialAsync(s,t,r)):n.Tools.Warn("Unsupported material type: "+s.name)}return Promise.all(i).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 BABYLON.Vector2(0,1),i=new BABYLON.Vector2(0,.1),a=new BABYLON.Vector2(0,.1),o=new BABYLON.Vector2(1300,.1);var s=t.diffuseColor.toLinearSpace().scale(.5),l=t.alpha,u=function(e){return function(e,t,r,n,i){return(1-e)*(1-e)*(1-e)*t+3*(1-e)*(1-e)*e*r+3*(1-e)*e*e*n+e*e*e*i}(Math.pow(e/o.x,.333333),r.y,i.y,a.y,o.y)}(n.Scalar.Clamp(t.specularPower,0,e._MaxSpecularPower));return{baseColorFactor:[s.r,s.g,s.b,l],metallicFactor:0,roughnessFactor:u}},e._SolveMetallic=function(e,t,r){if(t<this._DielectricSpecular.r)return this._DielectricSpecular,0;var n=this._DielectricSpecular.r,i=e*r/(1-this._DielectricSpecular.r)+t-2*this._DielectricSpecular.r,a=i*i-4*n*(this._DielectricSpecular.r-t);return BABYLON.Scalar.Clamp((-i+Math.sqrt(a))/(2*n),0,1)},e.prototype._getAlphaMode=function(e){return e.needAlphaBlending()?"BLEND":e.needAlphaTesting()?"MASK":"OPAQUE"},e.prototype._convertStandardMaterialAsync=function(t,r,i){var a=this._exporter._materialMap,o=this._exporter._materials,s=this._getAlphaMode(t),l=[],u=this._convertToGLTFPBRMetallicRoughness(t),c={name:t.name};if(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."),c.doubleSided=!0),i&&(t.diffuseTexture&&l.push(this._exportTextureAsync(t.diffuseTexture,r).then(function(e){e&&(u.baseColorTexture=e)})),t.bumpTexture&&l.push(this._exportTextureAsync(t.bumpTexture,r).then(function(e){e&&(c.normalTexture=e,null!=t.bumpTexture&&1!==t.bumpTexture.level&&(c.normalTexture.scale=t.bumpTexture.level))})),t.emissiveTexture&&(c.emissiveFactor=[1,1,1],l.push(this._exportTextureAsync(t.emissiveTexture,r).then(function(e){e&&(c.emissiveTexture=e)}))),t.ambientTexture&&l.push(this._exportTextureAsync(t.ambientTexture,r).then(function(e){if(e){var t={index:e.index};c.occlusionTexture=t,t.strength=1}}))),(t.alpha<1||t.opacityTexture)&&(t.alphaMode===n.Engine.ALPHA_COMBINE?c.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)&&(c.emissiveFactor=t.emissiveColor.asArray()),c.pbrMetallicRoughness=u,"OPAQUE"!==s)switch(s){case"BLEND":c.alphaMode="BLEND";break;case"MASK":c.alphaMode="MASK",c.alphaCutoff=t.alphaCutOff;break;default:n.Tools.Warn("Unsupported alpha mode "+s)}return o.push(c),a[t.uniqueId]=o.length-1,Promise.all(l).then(function(){})},e.prototype._convertPBRMetallicRoughnessMaterialAsync=function(t,r,i){var a=this._exporter._materialMap,o=this._exporter._materials,s=[],l={};t.baseColor&&(l.baseColorFactor=[t.baseColor.r,t.baseColor.g,t.baseColor.b,t.alpha]),null!=t.metallic&&1!==t.metallic&&(l.metallicFactor=t.metallic),null!=t.roughness&&1!==t.roughness&&(l.roughnessFactor=t.roughness);var u={name:t.name};t.doubleSided&&(u.doubleSided=t.doubleSided);var c=null;return null!=t.transparencyMode&&(c=this._getAlphaMode(t))&&"OPAQUE"!==c&&(u.alphaMode=c,"MASK"===c&&(u.alphaCutoff=t.alphaCutOff)),i&&(null!=t.baseTexture&&s.push(this._exportTextureAsync(t.baseTexture,r).then(function(e){e&&(l.baseColorTexture=e)})),t.normalTexture&&s.push(this._exportTextureAsync(t.normalTexture,r).then(function(e){e&&(u.normalTexture=e,1!==t.normalTexture.level&&(u.normalTexture.scale=t.normalTexture.level))})),t.occlusionTexture&&s.push(this._exportTextureAsync(t.occlusionTexture,r).then(function(e){e&&(u.occlusionTexture=e,null!=t.occlusionStrength&&(u.occlusionTexture.strength=t.occlusionStrength))})),t.emissiveTexture&&s.push(this._exportTextureAsync(t.emissiveTexture,r).then(function(e){e&&(u.emissiveTexture=e)}))),e.FuzzyEquals(t.emissiveColor,n.Color3.Black(),e._Epsilon)&&(u.emissiveFactor=t.emissiveColor.asArray()),u.pbrMetallicRoughness=l,o.push(u),a[t.uniqueId]=o.length-1,Promise.all(s).then(function(){})},e.prototype._createBase64FromCanvasAsync=function(e,t,r,i){var a=this;return new Promise(function(i,o){var s,l=n.Engine.TEXTURETYPE_UNSIGNED_INT,u=a._exporter._getLocalEngine();s=new n.Scene(u);var c=u.createRawTexture(e,t,r,n.Engine.TEXTUREFORMAT_RGBA,!1,!0,n.Texture.NEAREST_SAMPLINGMODE,null,l),f=new n.PostProcess("pass","pass",null,null,1,null,n.Texture.NEAREST_SAMPLINGMODE,u,!1,void 0,n.Engine.TEXTURETYPE_UNSIGNED_INT,void 0,null,!1);f.getEffect().executeWhenCompiled(function(){f.onApply=function(e){e._bindTexture("textureSampler",c)},u.setSize(t,r),s.postProcessManager.directRender([f],null),f.dispose(),c.dispose();var e=u.getRenderingCanvas();if(e)if(e.toBlob)BABYLON.Tools.ToBlob(e,function(e){if(e){var t=new FileReader;t.onload=function(e){var t=e.target.result;s.dispose(),i(t)},t.readAsDataURL(e)}else o("gltfMaterialExporter: Failed to get blob from image canvas!")});else{var n=e.toDataURL();i(n)}else o("Engine is missing a canvas!")})})},e.prototype._createWhiteTexture=function(e,t,r){for(var i=new Uint8Array(e*t*4),a=0;a<i.length;a+=4)i[a]=i[a+1]=i[a+2]=i[a+3]=255;return n.RawTexture.CreateRGBATexture(i,e,t,r)},e.prototype._resizeTexturesToSameDimensions=function(e,t,r){var i,a,o=e?e.getSize():{width:0,height:0},s=t?t.getSize():{width:0,height:0};return o.width<s.width?(i=e&&e instanceof n.Texture?n.TextureTools.CreateResizedCopy(e,s.width,s.height,!0):this._createWhiteTexture(s.width,s.height,r),a=t):o.width>s.width?(a=t&&t instanceof n.Texture?n.TextureTools.CreateResizedCopy(t,o.width,o.height,!0):this._createWhiteTexture(o.width,o.height,r),i=e):(i=e,a=t),{texture1:i,texture2:a}},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,i,a){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 l=this._resizeTexturesToSameDimensions(t,r,s),u=l.texture1.getSize(),c=void 0,f=void 0,h=u.width,p=u.height,d=l.texture1.readPixels(),m=l.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),y=new Uint8Array(g),x=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(i.diffuseColor),specularColor:new n.Color3(f[F],f[F+1],f[F+2]).toLinearSpace().multiply(i.specularColor),glossiness:f[F+3]*i.glossiness},E=this._convertSpecularGlossinessToMetallicRoughness(M);x.r=Math.max(x.r,E.baseColor.r),x.g=Math.max(x.g,E.baseColor.g),x.b=Math.max(x.b,E.baseColor.b),T=Math.max(T,E.metallic),v=Math.max(v,E.roughness),y[F]=255*E.baseColor.r,y[F+1]=255*E.baseColor.g,y[F+2]=255*E.baseColor.b,y[F+3]=l.texture1.hasAlpha?255*c[F+3]:255,_[F]=0,_[F+1]=255*E.roughness,_[F+2]=255*E.metallic,_[F+3]=255}var S={baseColor:x,metallic:T,roughness:v},R=!1,V=!1;for(b=0;b<p;++b)for(A=0;A<h;++A){var w=4*(h*b+A);y[w]/=S.baseColor.r>e._Epsilon?S.baseColor.r:1,y[w+1]/=S.baseColor.g>e._Epsilon?S.baseColor.g:1,y[w+2]/=S.baseColor.b>e._Epsilon?S.baseColor.b:1;var B=n.Color3.FromInts(y[w],y[w+1],y[w+2]).toGammaSpace();y[w]=255*B.r,y[w+1]=255*B.g,y[w+2]=255*B.b,e.FuzzyEquals(B,n.Color3.White(),e._Epsilon)||(V=!0),_[w+1]/=S.roughness>e._Epsilon?S.roughness:1,_[w+2]/=S.metallic>e._Epsilon?S.metallic:1;var C=n.Color3.FromInts(255,_[w+1],_[w+2]);e.FuzzyEquals(C,n.Color3.White(),e._Epsilon)||(R=!0)}if(R){var P=this._createBase64FromCanvasAsync(_,h,p,a).then(function(e){S.metallicRoughnessTextureBase64=e});o.push(P)}if(V){P=this._createBase64FromCanvasAsync(y,h,p,a).then(function(e){S.baseColorTextureBase64=e});o.push(P)}return Promise.all(o).then(function(){return S})}return Promise.reject("_ConvertSpecularGlossinessTexturesToMetallicRoughness: Scene from textures is missing!")},e.prototype._convertSpecularGlossinessToMetallicRoughness=function(t){var r=this._getPerceivedBrightness(t.diffuseColor),i=this._getPerceivedBrightness(t.specularColor),a=1-this._getMaxComponent(t.specularColor),o=e._SolveMetallic(r,i,a),s=t.diffuseColor.scale(a/(1-e._DielectricSpecular.r)/Math.max(1-o,e._Epsilon)),l=t.specularColor.subtract(e._DielectricSpecular.scale(1-o)).scale(1/Math.max(o,e._Epsilon)),u=n.Color3.Lerp(s,l,o*o);return{baseColor:u=u.clampToRef(0,1,u),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 i=[],a={baseColor:e.albedoColor,metallic:e.metallic,roughness:e.roughness};return n&&(e.albedoTexture&&i.push(this._exportTextureAsync(e.albedoTexture,t).then(function(e){e&&(r.baseColorTexture=e)})),e.metallicTexture&&i.push(this._exportTextureAsync(e.metallicTexture,t).then(function(e){e&&(r.metallicRoughnessTexture=e)}))),Promise.all(i).then(function(){return a})},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,i){var a=this;return Promise.resolve().then(function(){var o=a._exporter._samplers,s=a._exporter._textures,l={diffuseColor:e.albedoColor||n.Color3.White(),specularColor:e.reflectivityColor||n.Color3.White(),glossiness:e.microSurface||1},u=null,c=a._getGLTFTextureSampler(e.albedoTexture);return null!=c.magFilter&&null!=c.minFilter&&null!=c.wrapS&&null!=c.wrapT&&(o.push(c),u=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)&&i?a._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(e.albedoTexture,e.reflectivityTexture,l,t).then(function(n){if(n.baseColorTextureBase64){var i=a._getTextureInfoFromBase64(n.baseColorTextureBase64,"bjsBaseColorTexture_"+s.length+".png",t,e.albedoTexture?e.albedoTexture.coordinatesIndex:null,u);i&&(r.baseColorTexture=i)}if(n.metallicRoughnessTextureBase64){var o=a._getTextureInfoFromBase64(n.metallicRoughnessTextureBase64,"bjsMetallicRoughnessTexture_"+s.length+".png",t,e.reflectivityTexture?e.reflectivityTexture.coordinatesIndex:null,u);o&&(r.metallicRoughnessTexture=o)}return n}):a._convertSpecularGlossinessToMetallicRoughness(l)})},e.prototype._convertPBRMaterialAsync=function(e,t,r){var n=this,i={},a={name:e.name};return e.isMetallicWorkflow()?(e.albedoColor&&(i.baseColorFactor=[e.albedoColor.r,e.albedoColor.g,e.albedoColor.b,e.alpha]),this._convertMetalRoughFactorsToMetallicRoughnessAsync(e,t,i,r).then(function(o){return n.setMetallicRoughnessPbrMaterial(o,e,a,i,t,r)})):this._convertSpecGlossFactorsToMetallicRoughnessAsync(e,t,i,r).then(function(o){return n.setMetallicRoughnessPbrMaterial(o,e,a,i,t,r)})},e.prototype.setMetallicRoughnessPbrMaterial=function(t,r,i,a,o,s){var l=this._exporter._materialMap,u=this._exporter._materials,c=[];if(t){var f=null;if(null!=r.transparencyMode&&(f=this._getAlphaMode(r))&&"OPAQUE"!==f&&(i.alphaMode=f,"MASK"===f&&(i.alphaCutoff=r.alphaCutOff)),e.FuzzyEquals(t.baseColor,n.Color3.White(),e._Epsilon)&&r.alpha>=e._Epsilon||(a.baseColorFactor=[t.baseColor.r,t.baseColor.g,t.baseColor.b,r.alpha]),null!=t.metallic&&1!==t.metallic&&(a.metallicFactor=t.metallic),null!=t.roughness&&1!==t.roughness&&(a.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."),i.doubleSided=!0),s){if(r.bumpTexture){var h=this._exportTextureAsync(r.bumpTexture,o).then(function(e){e&&(i.normalTexture=e,1!==r.bumpTexture.level&&(i.normalTexture.scale=r.bumpTexture.level))});c.push(h)}if(r.ambientTexture){h=this._exportTextureAsync(r.ambientTexture,o).then(function(e){if(e){var t={index:e.index};i.occlusionTexture=t,r.ambientTextureStrength&&(t.strength=r.ambientTextureStrength)}});c.push(h)}if(r.emissiveTexture){h=this._exportTextureAsync(r.emissiveTexture,o).then(function(e){e&&(i.emissiveTexture=e)});c.push(h)}}e.FuzzyEquals(r.emissiveColor,n.Color3.Black(),e._Epsilon)||(i.emissiveFactor=r.emissiveColor.asArray()),i.pbrMetallicRoughness=a,u.push(i),l[r.uniqueId]=u.length-1}return Promise.all(c).then(function(e){})},e.prototype.getPixelsFromTexture=function(e){return e.textureType,n.Engine.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];for(var i=r._exporter._samplers,a=r._getGLTFTextureSampler(e),o=null,s=null,l=0;l<i.length;++l){var u=i[l];if(u.minFilter===a.minFilter&&u.magFilter===a.magFilter&&u.wrapS===a.wrapS&&u.wrapT===a.wrapT){s=l;break}}null==s?(i.push(a),o=i.length-1):o=s;var c=r.getPixelsFromTexture(e),f=e.getSize();return r._createBase64FromCanvasAsync(c,f.width,f.height,t).then(function(i){var a=r._getTextureInfoFromBase64(i,e.name.replace(/\.\/|\/|\.\\|\\/g,"_"),t,e.coordinatesIndex,o);return a&&(r._textureMap[n]=a),a})})},e.prototype._getTextureInfoFromBase64=function(e,t,r,i,a){var o=this._exporter._textures,s=this._exporter._images,l=this._exporter._imageData,u=null,c={source:s.length,name:t};null!=a&&(c.sampler=a);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",y=t+_;if(y in l&&(y=t+"_"+n.Tools.RandomId()+_),l[y]=g,"image/jpeg"===r||"image/png"===r){var x={name:t,uri:y},T=null;for(d=0;d<s.length;++d)if(s[d].uri===y){T=d;break}null==T?(s.push(x),c.source=s.length-1):c.source=T,o.push(c),u={index:o.length-1},null!=i&&(u.texCoord=i)}else n.Tools.Error("Unsupported texture mime type "+r);return u},e._DielectricSpecular=new n.Color3(.04,.04,.04),e._MaxSpecularPower=1024,e._Epsilon=1e-6,e}();t._GLTFMaterialExporter=i},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});var n=r(3),i=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==i)for(var a in i.BABYLON=i.BABYLON||{},n)n.hasOwnProperty(a)&&(i.BABYLON[a]=n[a]);!function(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}(r(3))}).call(this,r(8))},function(e,t){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}(r(10))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),i=function(){function e(){}return e.OBJ=function(e,t,r,i){var a=[],o=1;t&&(r||(r="mat"),a.push("mtllib "+r+".mtl"));for(var s=0;s<e.length;s++){a.push("g object"+s),a.push("o object_"+s);var l=null;if(i){var u=BABYLON.Matrix.Translation(e[s].position.x,e[s].position.y,e[s].position.z);l=BABYLON.Matrix.Translation(-e[s].position.x,-e[s].position.y,-e[s].position.z),e[s].bakeTransformIntoVertices(u)}if(t){var c=e[s].material;c&&a.push("usemtl "+c.id)}var f=e[s].geometry;if(f){var h=f.getVerticesData("position"),p=f.getVerticesData("normal"),d=f.getVerticesData("uv"),m=f.getIndices(),g=0;if(h&&m){for(var _=0;_<h.length;_+=3)a.push("v "+h[_]+" "+h[_+1]+" "+h[_+2]),g++;if(null!=p)for(_=0;_<p.length;_+=3)a.push("vn "+p[_]+" "+p[_+1]+" "+p[_+2]);if(null!=d)for(_=0;_<d.length;_+=2)a.push("vt "+d[_]+" "+d[_+1]);for(_=0;_<m.length;_+=3){var y=[String(m[_+2]+o),String(m[_+1]+o),String(m[_]+o)],x=["","",""],T=y,v=null!=d?y:x,b=null!=p?y:x;a.push("f "+T[0]+"/"+v[0]+"/"+b[0]+" "+T[1]+"/"+v[1]+"/"+b[1]+" "+T[2]+"/"+v[2]+"/"+b[2])}i&&l&&e[s].bakeTransformIntoVertices(l),o+=g}else n.Tools.Warn("There are no position vertices or indices on the mesh!")}else n.Tools.Warn("No geometry is present on the mesh")}return a.join("\n")},e.MTL=function(e){var t=[],r=e.material;t.push("newmtl mat1"),t.push(" Ns "+r.specularPower.toFixed(4)),t.push(" Ni 1.5000"),t.push(" d "+r.alpha.toFixed(4)),t.push(" Tr 0.0000"),t.push(" Tf 1.0000 1.0000 1.0000"),t.push(" illum 2"),t.push(" Ka "+r.ambientColor.r.toFixed(4)+" "+r.ambientColor.g.toFixed(4)+" "+r.ambientColor.b.toFixed(4)),t.push(" Kd "+r.diffuseColor.r.toFixed(4)+" "+r.diffuseColor.g.toFixed(4)+" "+r.diffuseColor.b.toFixed(4)),t.push(" Ks "+r.specularColor.r.toFixed(4)+" "+r.specularColor.g.toFixed(4)+" "+r.specularColor.b.toFixed(4)),t.push(" Ke "+r.emissiveColor.r.toFixed(4)+" "+r.emissiveColor.g.toFixed(4)+" "+r.emissiveColor.b.toFixed(4));return r.ambientTexture&&t.push(" map_Ka "+r.ambientTexture.name),r.diffuseTexture&&t.push(" map_Kd "+r.diffuseTexture.name),r.specularTexture&&t.push(" map_Ks "+r.specularTexture.name),r.bumpTexture&&t.push(" map_bump -imfchan z "+r.bumpTexture.name),r.opacityTexture&&t.push(" map_d "+r.opacityTexture.name),t.join("\n")},e}();t.OBJExport=i},function(e,t,r){"use strict";function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0}),n(r(12)),n(r(13))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.__IGLTFExporterExtension=0},function(e,t,r){"use strict";function n(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}Object.defineProperty(t,"__esModule",{value:!0}),n(r(4)),n(r(5)),n(r(2)),n(r(14)),n(r(6)),n(r(15)),n(r(1)),n(r(16))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.__IGLTFExporterExtensionV2=0},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(2),i=function(){function e(){}return e.GLTFAsync=function(e,t,r){return e.whenReadyAsync().then(function(){var i=t.replace(/\.[^/.]+$/,"");return new n._Exporter(e,r)._generateGLTFAsync(i)})},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 i=this;return this._PreExportAsync(e,r).then(function(){var a=t.replace(/\.[^/.]+$/,"");return new n._Exporter(e,r)._generateGLBAsync(a).then(function(t){return i._PostExportAsync(e,t,r)})})},e}();t.GLTF2Export=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){for(var r in e)t.hasOwnProperty(r)||(t[r]=e[r])}(r(17))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(0),i=r(2),a="KHR_texture_transform";n.Effect.ShadersStore.textureTransformPixelShader=r(18);var o=function(){function e(e){this.name=a,this.enabled=!0,this.required=!1,this._exporter=e}return e.prototype.dispose=function(){delete this._exporter},e.prototype.preExportTextureAsync=function(e,t,r){var i=this;return new Promise(function(r,a){var o={};0===t.uOffset&&0===t.vOffset||(o.offset=[t.uOffset,t.vOffset]),1===t.uScale&&1===t.vScale||(o.scale=[t.uScale,t.vScale]),0!==t.wAng&&(o.rotation=t.wAng),Object.keys(o).length||r(t);var s=o.scale?new n.Vector2(o.scale[0],o.scale[1]):n.Vector2.One(),l=null!=o.rotation?o.rotation:0,u=o.offset?new n.Vector2(o.offset[0],o.offset[1]):n.Vector2.Zero(),c=t.getScene();c?i.textureTransformTextureAsync(t,u,l,s,c).then(function(e){r(e)}):a(e+': "scene" is not defined for Babylon texture '+t.name+"!")})},e.prototype.textureTransformTextureAsync=function(e,t,r,i,a){return new Promise(function(t,r){var i=new n.ProceduralTexture(""+e.name,e.getSize(),"textureTransform",a);i||(n.Tools.Log("Cannot create procedural texture for "+e.name+"!"),t(e)),i.setTexture("textureSampler",e),i.setMatrix("textureTransformMat",e.getTextureMatrix()),i.isReady()?(i.render(),t(i)):i.getEffect().executeWhenCompiled(function(){i.render(),t(i)})})},e}();t.KHR_texture_transform=o,i._Exporter.RegisterExtension(a,function(e){return new o(e)})},function(e,t){e.exports="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}"}])});
- //# sourceMappingURL=babylonjs.serializers.min.js.map
|