1 |
- var BABYLON;!(function(e){var t=(function(){function t(){}return t.GLTF=function(t,r,a){var i=r.replace(/\.[^\/.]+$/,""),n=new e.GLTF2._Exporter(t,a);if(t.isReady)return n._generateGLTF(i);throw new Error("glTF Serializer: Scene is not ready!")},t.GLB=function(t,r,a){var i=r.replace(/\.[^\/.]+$/,""),n=new e.GLTF2._Exporter(t,a);if(t.isReady)return n._generateGLB(i);throw new Error("glTF Serializer: Scene is not ready!")},t})();e.GLTF2Export=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(){function r(e,t){this.asset={generator:"BabylonJS",version:"2.0"},this.babylonScene=e,this.bufferViews=new Array,this.accessors=new Array,this.meshes=new Array,this.scenes=new Array,this.nodes=new Array,this.images=new Array,this.materials=new Array,this.textures=new Array,this.imageData={},this.convertToRightHandedSystem=!this.babylonScene.useRightHandedSystem,t&&(this.options=t)}return r.prototype.createBufferView=function(e,t,r,a,i){var n={buffer:e,byteLength:r};return t&&(n.byteOffset=t),i&&(n.name=i),a&&(n.byteStride=a),n},r.prototype.createAccessor=function(e,t,r,a,i,n,s,o){var l={name:t,bufferView:e,componentType:a,count:i,type:r};return s&&(l.min=s),o&&(l.max=o),n&&(l.byteOffset=n),l},r.prototype.calculateMinMaxPositions=function(t,a,i){var n=[1/0,1/0,1/0],s=[-(1/0),-(1/0),-(1/0)],o=a+i;if(i)for(var l=a;l<o;++l)for(var u=3*l,c=e.Vector3.FromArray(t,u),h=this.convertToRightHandedSystem?r.GetRightHandedVector3(c).asArray():c.asArray(),f=0;f<3;++f){var d=h[f];d<n[f]&&(n[f]=d),d>s[f]&&(s[f]=d),++u}return{min:n,max:s}},r.GetRightHandedVector3=function(t){return new e.Vector3(t.x,t.y,-t.z)},r.GetRightHandedVector4=function(t){return new e.Vector4(t.x,t.y,-t.z,-t.w)},r.GetRightHandedQuaternion=function(t){return new e.Quaternion(-t.x,-t.y,t.z,t.w)},r.prototype.writeAttributeData=function(t,a,i,n,s,o){for(var l=s,u=a.length/i,c=0;c<u;++c){var h=c*i,f=[];if(t===e.VertexBuffer.PositionKind||t===e.VertexBuffer.NormalKind){var d=e.Vector3.FromArray(a,h);f=this.convertToRightHandedSystem?r.GetRightHandedVector3(d).asArray():d.asArray()}else if(t===e.VertexBuffer.TangentKind||t===e.VertexBuffer.ColorKind){var d=e.Vector4.FromArray(a,h);f=this.convertToRightHandedSystem&&t!==e.VertexBuffer.ColorKind?r.GetRightHandedVector4(d).asArray():d.asArray()}else t===e.VertexBuffer.UVKind||t===e.VertexBuffer.UV2Kind?f=[a[h],a[h+1]]:e.Tools.Warn("Unsupported Vertex Buffer Type: "+t);for(var p=0;p<f.length;++p)o.setFloat32(l,f[p],!0),l+=4}return 4*a.length},r.prototype.generateJSON=function(e,t,r){var a={byteLength:this.totalByteLength},i={asset:this.asset};if(a.byteLength&&(i.buffers=[a]),this.nodes&&this.nodes.length&&(i.nodes=this.nodes),this.meshes&&this.meshes.length&&(i.meshes=this.meshes),this.scenes&&this.scenes.length&&(i.scenes=this.scenes,i.scene=0),this.bufferViews&&this.bufferViews.length&&(i.bufferViews=this.bufferViews),this.accessors&&this.accessors.length&&(i.accessors=this.accessors),this.materials&&this.materials.length&&(i.materials=this.materials),this.textures&&this.textures.length&&(i.textures=this.textures),this.images&&this.images.length)if(e){i.images=[];for(var n=this.images.length,s=this.totalByteLength,o=0;o<n;++o){var l=this.images[o];if(l.uri){var u=this.imageData[l.uri],c=l.uri.split(".")[0]+" image",h=this.createBufferView(0,s,u.data.length,void 0,c);s+=u.data.buffer.byteLength,this.bufferViews.push(h),l.bufferView=this.bufferViews.length-1,l.name=c,l.mimeType=u.mimeType,l.uri=void 0,i.images.push(l)}}a.byteLength=s}else i.images=this.images;return e||(a.uri=t+".bin"),r?JSON.stringify(i,null,2):JSON.stringify(i)},r.prototype._generateGLTF=function(t){var r=this.generateBinary(),a=this.generateJSON(!1,t,!0),i=new Blob([r],{type:"application/octet-stream"}),n=t+".gltf",s=t+".bin",o=new e._GLTFData;if(o.glTFFiles[n]=a,o.glTFFiles[s]=i,this.imageData)for(var l in this.imageData)o.glTFFiles[l]=new Blob([this.imageData[l].data],{type:this.imageData[l].mimeType});return o},r.prototype.generateBinary=function(){var e=0;return e=this.createScene(this.babylonScene,e),this.binaryBuffer},r.prototype._getPadding=function(e){var t=e%4;return 0===t?t:4-t},r.prototype._generateGLB=function(t){var r=this.generateBinary(),a=this.generateJSON(!0),i=t+".glb",n=a.length,s=0;for(var o in this.imageData)s+=this.imageData[o].data.byteLength;var l=this._getPadding(n),u=this._getPadding(r.byteLength),c=this._getPadding(s),h=28+n+l+r.byteLength+u+s+c,f=new ArrayBuffer(12),d=new DataView(f);d.setUint32(0,1179937895,!0),d.setUint32(4,2,!0),d.setUint32(8,h,!0);var p=new ArrayBuffer(8+n+l),g=new DataView(p);g.setUint32(0,n+l,!0),g.setUint32(4,1313821514,!0);for(var m=new Uint8Array(p,8),v=0;v<n;++v)m[v]=a.charCodeAt(v);for(var T=new Uint8Array(p,8+n),v=0;v<l;++v)T[v]=32;var x=new ArrayBuffer(8),y=new DataView(x);y.setUint32(0,r.byteLength+s+c,!0),y.setUint32(4,5130562,!0);for(var b=new ArrayBuffer(u),B=new Uint8Array(b),v=0;v<u;++v)B[v]=0;for(var A=new ArrayBuffer(c),M=new Uint8Array(A),v=0;v<c;++v)M[v]=0;var w=[f,p,x,r];for(var o in this.imageData)w.push(this.imageData[o].data.buffer);w.push(b),w.push(A);var L=new Blob(w,{type:"application/octet-stream"}),F=new e._GLTFData;return F.glTFFiles[i]=L,F},r.prototype.setNodeTransformation=function(t,a){a.position.equalsToFloats(0,0,0)||(t.translation=this.convertToRightHandedSystem?r.GetRightHandedVector3(a.position).asArray():a.position.asArray()),a.scaling.equalsToFloats(1,1,1)||(t.scale=a.scaling.asArray());var i=e.Quaternion.RotationYawPitchRoll(a.rotation.y,a.rotation.x,a.rotation.z);a.rotationQuaternion&&(i=i.multiply(a.rotationQuaternion)),0===i.x&&0===i.y&&0===i.z&&1===i.w||(t.rotation=this.convertToRightHandedSystem?r.GetRightHandedQuaternion(i).asArray():i.asArray())},r.prototype.createBufferViewKind=function(t,r,a,i){var n=null,s=0;if(r instanceof e.Mesh?n=r:r instanceof e.InstancedMesh&&(n=r.sourceMesh),n){var o=null,l=null,u=null,c=null;if(n.isVerticesDataPresent(t)&&(o=n.getVertexBuffer(t))&&(l=o.getOffset(),u=o.getData()))if(c=o.getStrideSize(),i&&u)s=this.writeAttributeData(t,u,c,l,a,i),a+=s;else{s=4*u.length;var h=this.createBufferView(0,a,s,4*c,t+" - "+n.name);a+=s,this.bufferViews.push(h)}}return s},r.prototype.setPrimitiveAttributes=function(r,a,i,n){var s=null;a instanceof e.Mesh?s=a:a instanceof e.InstancedMesh&&(s=a.sourceMesh);var o=[{kind:e.VertexBuffer.PositionKind,accessorType:"VEC3"},{kind:e.VertexBuffer.NormalKind,accessorType:"VEC3"},{kind:e.VertexBuffer.ColorKind,accessorType:"VEC4"},{kind:e.VertexBuffer.TangentKind,accessorType:"VEC4"},{kind:e.VertexBuffer.UVKind,accessorType:"VEC2"},{kind:e.VertexBuffer.UV2Kind,accessorType:"VEC2"}],l=null;if(s){for(var u=0,c=o;u<c.length;u++){var h=c[u],f=h.kind;s.isVerticesDataPresent(f)&&(i+=this.createBufferViewKind(f,a,i,n),h.bufferViewIndex=this.bufferViews.length-1)}if(s.getTotalIndices()){var d=s.getIndices();if(d)if(n){for(var p=d.length,g=i,m=0;m<p;++m)n.setUint32(g,d[m],!0),g+=4;i=g}else{var v=4*d.length,T=this.createBufferView(0,i,v,void 0,"Indices - "+s.name);i+=v,this.bufferViews.push(T),l=this.bufferViews.length-1}}if(a.subMeshes)for(var x=!1,y=0,b=a.subMeshes;y<b.length;y++){var B=b[y],A={attributes:{}};if(!n){for(var M=0,w=o;M<w.length;M++){var h=w[M],f=h.kind;if(s.isVerticesDataPresent(f)){var L=s.getVertexBuffer(f);if(L){var F=L.getData();if(F){var R=L.getStrideSize(),S=void 0,V=null,C=null,E=h.bufferViewIndex;if(void 0!=E){f==e.VertexBuffer.PositionKind&&(S=this.calculateMinMaxPositions(F,0,F.length/R),V=S.min,C=S.max);var P=this.createAccessor(E,f+" - "+a.name,h.accessorType,5126,F.length/R,0,V,C);switch(this.accessors.push(P),f){case e.VertexBuffer.PositionKind:A.attributes.POSITION=this.accessors.length-1;break;case e.VertexBuffer.NormalKind:A.attributes.NORMAL=this.accessors.length-1;break;case e.VertexBuffer.ColorKind:A.attributes.COLOR_0=this.accessors.length-1;break;case e.VertexBuffer.TangentKind:A.attributes.TANGENT=this.accessors.length-1;break;case e.VertexBuffer.UVKind:A.attributes.TEXCOORD_0=this.accessors.length-1,x=!0;break;case e.VertexBuffer.UV2Kind:A.attributes.TEXCOORD_1=this.accessors.length-1,x=!0;break;default:e.Tools.Warn("Unsupported Vertex Buffer Type: "+f)}}}}}}if(l){var P=this.createAccessor(l,"indices - "+a.name,"SCALAR",5125,B.indexCount,4*B.indexStart,null,null);this.accessors.push(P),A.indices=this.accessors.length-1}}if(s.material){var O=null;if(s.material instanceof e.StandardMaterial||s.material instanceof e.PBRMetallicRoughnessMaterial||s.material instanceof e.PBRMaterial)O=a.getScene().materials.indexOf(s.material);else if(s.material instanceof e.MultiMaterial){var N=s.material,D=N.subMaterials[B.materialIndex];D&&(O=a.getScene().materials.indexOf(D))}else e.Tools.Warn("Material type "+s.material.getClassName()+" for material "+s.material.name+" is not yet implemented in glTF serializer.");if(null!=O)if(x||!t._GLTFMaterial.HasTexturesPresent(this.materials[O]))A.material=O;else{var G=t._GLTFMaterial.StripTexturesFromMaterial(this.materials[O]);this.materials.push(G),A.material=this.materials.length-1}}r.primitives.push(A)}}return i},r.prototype.createScene=function(r,a){if(r.meshes.length){var i=r.meshes,n={nodes:new Array};t._GLTFMaterial.ConvertMaterialsToGLTF(r.materials,"image/jpeg",this.images,this.textures,this.materials,this.imageData,!0);var s=this.createNodeMap(r,a);this.nodeMap=s.nodeMap,this.totalByteLength=s.byteOffset,this.binaryBuffer=new ArrayBuffer(this.totalByteLength);for(var o=new DataView(this.binaryBuffer),l=0;l<i.length;++l){var u=i[l],c=this.nodeMap[u.uniqueId],h=this.nodes[c];u.parent||(this.options&&void 0!=this.options.shouldExportMesh&&!this.options.shouldExportMesh(u)?e.Tools.Log("Omitting "+u.name+" from scene."):n.nodes.push(c));var f=u.getDescendants(!0);if(!h.children&&f&&f.length){h.children=[];for(var d=0,p=f;d<p.length;d++){var g=p[d];h.children.push(this.nodeMap[g.uniqueId])}}var m={primitives:new Array};a=this.setPrimitiveAttributes(m,u,a,o)}this.scenes.push(n)}return a},r.prototype.createNodeMap=function(e,t){for(var r={},a=0,i=e.meshes;a<i.length;a++){var n=i[a],s=this.createNode(n,t,null);this.nodes.push(s.node),r[n.uniqueId]=this.nodes.length-1,t=s.byteOffset}return{nodeMap:r,byteOffset:t}},r.prototype.createNode=function(e,t,r){var a={};e.name&&(a.name=e.name),this.setNodeTransformation(a,e);var i={primitives:new Array};return i.primitives=[],t=this.setPrimitiveAttributes(i,e,t,r),i.primitives.length&&(this.meshes.push(i),a.mesh=this.meshes.length-1),{node:a,byteOffset:t}},r})();t._Exporter=r})(e.GLTF2||(e.GLTF2={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this.glTFFiles={}}return e.prototype.downloadFiles=function(){function e(e,t){return e.indexOf(t,e.length-t.length)!==-1}for(var t in this.glTFFiles){var r=document.createElement("a");document.body.appendChild(r),r.setAttribute("type","hidden"),r.download=t;var a=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([a],i)),r.click()}},e})();e._GLTFData=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(){function t(){}return t.ConvertMaterialsToGLTF=function(r,a,i,n,s,o,l){for(var u=0;u<r.length;++u){var c=r[u];c instanceof e.StandardMaterial?t.ConvertStandardMaterial(c,a,i,n,s,o,l):c instanceof e.PBRMetallicRoughnessMaterial?t.ConvertPBRMetallicRoughnessMaterial(c,a,i,n,s,o,l):c instanceof e.PBRMaterial?t.ConvertPBRMaterial(c,a,i,n,s,o,l):e.Tools.Error("Unsupported material type: "+c.name)}},t.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},t.HasTexturesPresent=function(e){if(e.emissiveTexture||e.normalTexture||e.occlusionTexture)return!0;var t=e.pbrMetallicRoughness;return!(!t||!t.baseColorTexture&&!t.metallicRoughnessTexture)},t.ConvertToGLTFPBRMetallicRoughness=function(t){function r(e,t,r,a,i){return(1-e)*(1-e)*(1-e)*t+3*(1-e)*(1-e)*e*r+3*(1-e)*e*e*a+e*e*e*i}var a=new e.Vector2(0,1),i=new e.Vector2(0,.1),n=new e.Vector2(0,.1),s=new e.Vector2(1300,.1),o=t.diffuseColor.toLinearSpace().scale(.5),l=t.alpha,u=e.Scalar.Clamp(t.specularPower,0,this.maxSpecularPower),c=(function(e){return r(Math.pow(e/s.x,.333333),a.y,i.y,n.y,s.y)})(u);return{baseColorFactor:[o.r,o.g,o.b,l],metallicFactor:0,roughnessFactor:c}},t.SolveMetallic=function(r,a,i){if(a<t.dielectricSpecular.r)return t.dielectricSpecular,0;var n=t.dielectricSpecular.r,s=r*i/(1-t.dielectricSpecular.r)+a-2*t.dielectricSpecular.r,o=t.dielectricSpecular.r-a,l=s*s-4*n*o;return e.Scalar.Clamp((-s+Math.sqrt(l))/(2*n),0,1)},t.GetAlphaMode=function(t){if(t instanceof e.StandardMaterial){var r=t;return 1!=r.alpha||null!=r.diffuseTexture&&r.diffuseTexture.hasAlpha||null!=r.opacityTexture?"BLEND":"OPAQUE"}if(t instanceof e.PBRMetallicRoughnessMaterial){var a=t;switch(a.transparencyMode){case e.PBRMaterial.PBRMATERIAL_OPAQUE:return"OPAQUE";case e.PBRMaterial.PBRMATERIAL_ALPHABLEND:return"BLEND";case e.PBRMaterial.PBRMATERIAL_ALPHATEST:return"MASK";case e.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND:return e.Tools.Warn(t.name+": GLTF Exporter | Alpha test and blend mode not supported in glTF. Alpha blend used instead."),"BLEND";default:throw new Error("Unsupported alpha mode "+a.transparencyMode)}}else{if(!(t instanceof e.PBRMaterial))throw new Error("Unsupported Babylon material type");var i=t;switch(i.transparencyMode){case e.PBRMaterial.PBRMATERIAL_OPAQUE:return"OPAQUE";case e.PBRMaterial.PBRMATERIAL_ALPHABLEND:return"BLEND";case e.PBRMaterial.PBRMATERIAL_ALPHATEST:return"MASK";case e.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND:return e.Tools.Warn(t.name+": GLTF Exporter | Alpha test and blend mode not supported in glTF. Alpha blend used instead."),"BLEND";default:throw new Error("Unsupported alpha mode "+i.transparencyMode)}}},t.ConvertStandardMaterial=function(r,a,i,n,s,o,l){e.Tools.Warn(r.name+": Standard Material is currently not fully supported/implemented in glTF serializer");var u=t.ConvertToGLTFPBRMetallicRoughness(r),c={name:r.name};if(r.backFaceCulling&&(r.twoSidedLighting||e.Tools.Warn(r.name+": Back-face culling enabled and two-sided lighting disabled is not supported in glTF."),c.doubleSided=!0),l){if(r.diffuseTexture){var h=t.ExportTexture(r.diffuseTexture,a,i,n,o);null!=h&&(u.baseColorTexture=h)}if(r.bumpTexture){var h=t.ExportTexture(r.bumpTexture,a,i,n,o);h&&(c.normalTexture=h)}if(r.emissiveTexture){var f=t.ExportTexture(r.emissiveTexture,a,i,n,o);f&&(c.emissiveTexture=f),c.emissiveFactor=[1,1,1]}if(r.ambientTexture){var h=t.ExportTexture(r.ambientTexture,a,i,n,o);if(h){var d={index:h.index};c.occlusionTexture=d,d.strength=1}}}(r.alpha<1||r.opacityTexture)&&(r.alphaMode===e.Engine.ALPHA_COMBINE?c.alphaMode="BLEND":e.Tools.Warn(r.name+": glTF 2.0 does not support alpha mode: "+r.alphaMode.toString())),r.emissiveColor&&(c.emissiveFactor=r.emissiveColor.asArray()),c.pbrMetallicRoughness=u,s.push(c)},t.ConvertPBRMetallicRoughnessMaterial=function(e,r,a,i,n,s,o){var l={};e.baseColor&&(l.baseColorFactor=[e.baseColor.r,e.baseColor.g,e.baseColor.b,e.alpha]),null!=e.metallic&&(l.metallicFactor=e.metallic),null!=e.roughness&&(l.roughnessFactor=e.roughness);var u={name:e.name};if(e.doubleSided&&(u.doubleSided=e.doubleSided),o){if(null!=e.baseTexture){var c=t.ExportTexture(e.baseTexture,r,a,i,s);null!=c&&(l.baseColorTexture=c)}if(e.normalTexture){var c=t.ExportTexture(e.normalTexture,r,a,i,s);c&&(u.normalTexture=c)}if(e.occlusionTexture){var c=t.ExportTexture(e.occlusionTexture,r,a,i,s);c&&(u.occlusionTexture=c,null!=e.occlusionStrength&&(u.occlusionTexture.strength=e.occlusionStrength))}if(e.emissiveTexture){var c=t.ExportTexture(e.emissiveTexture,r,a,i,s);null!=c&&(u.emissiveTexture=c)}}if(e.emissiveColor.equalsFloats(0,0,0)&&(u.emissiveFactor=e.emissiveColor.asArray()),null!=e.transparencyMode){var h=t.GetAlphaMode(e);"OPAQUE"!==h&&(u.alphaMode=h,"BLEND"===h&&(u.alphaCutoff=e.alphaCutOff))}u.pbrMetallicRoughness=l,n.push(u)},t.GetPerceivedBrightness=function(e){return e?Math.sqrt(.299*e.r*e.r+.587*e.g*e.g+.114*e.b*e.b):0},t.GetMaxComponent=function(e){return e?Math.max(e.r,Math.max(e.g,e.b)):0},t.ConvertPBRMaterial=function(r,a,i,n,s,o,l){var u={},c={name:r.name},h=r.isMetallicWorkflow();if(r){if(h)u.baseColorFactor=[r.albedoColor.r,r.albedoColor.g,r.albedoColor.b,r.alpha],null!=r.metallic&&1!==r.metallic&&(u.metallicFactor=r.metallic),null!=r.roughness&&1!==r.roughness&&(u.roughnessFactor=r.roughness);else{var f=r.albedoColor||e.Color3.Black(),d=r.reflectionColor||e.Color3.Black(),p=t.GetPerceivedBrightness(f),g=t.GetPerceivedBrightness(d),m=1-t.GetMaxComponent(r.reflectionColor),v=t.SolveMetallic(p,g,m),T=r.microSurface||0,x=f.scale(m/(1-this.dielectricSpecular.r)/Math.max(1-v,this.epsilon)),y=d.subtract(this.dielectricSpecular.scale(1-v)).scale(1/Math.max(v,this.epsilon)),b=e.Color3.Lerp(x,y,v*v);b=b.clampToRef(0,1,b),u.baseColorFactor=[b.r,b.g,b.b,r.alpha],1!==v&&(u.metallicFactor=v),T&&(u.roughnessFactor=1-T)}if(r.backFaceCulling&&(r.twoSidedLighting||e.Tools.Warn(r.name+": Back-face culling enabled and two-sided lighting disabled is not supported in glTF."),c.doubleSided=!0),l){if(r.albedoTexture){var B=t.ExportTexture(r.albedoTexture,a,i,n,o);B&&(u.baseColorTexture=B)}if(r.bumpTexture){var B=t.ExportTexture(r.bumpTexture,a,i,n,o);B&&(c.normalTexture=B)}if(r.ambientTexture){var B=t.ExportTexture(r.ambientTexture,a,i,n,o);if(B){var A={index:B.index};c.occlusionTexture=A,r.ambientTextureStrength&&(A.strength=r.ambientTextureStrength)}}if(r.emissiveTexture){var B=t.ExportTexture(r.emissiveTexture,a,i,n,o);null!=B&&(c.emissiveTexture=B)}if(r.metallicTexture){var B=t.ExportTexture(r.metallicTexture,a,i,n,o);null!=B&&(u.metallicRoughnessTexture=B)}}if(r.emissiveColor.equalsFloats(0,0,0)||(c.emissiveFactor=r.emissiveColor.asArray()),null!=r.transparencyMode){var M=t.GetAlphaMode(r);"OPAQUE"!==M&&(c.alphaMode=M,"BLEND"===M&&(c.alphaCutoff=r.alphaCutOff))}}c.pbrMetallicRoughness=u,s.push(c)},t.ExportTexture=function(t,r,a,i,n){var s=null,o={source:a.length},l="texture_"+(i.length-1).toString(),u=t.getInternalTexture();null!=u&&(l=u.url),l=e.Tools.GetFilename(l);var c=l.split(".")[0],h="";"image/jpeg"===r?h=".jpg":"image/png"===r?h=".png":e.Tools.Error("Unsupported mime type "+r),l=c+h;var f=t.readPixels(),d=document.createElement("canvas");d.id="ImageCanvas";var p=d.getContext("2d"),g=t.getSize();d.width=g.width,d.height=g.height;var m=p.createImageData(g.width,g.height);m.data.set(f),p.putImageData(m,0,0);for(var v=d.toDataURL(r),T=atob(v.split(",")[1]),x=new Uint8Array(T.length),y=0;y<T.length;++y)x[y]=T.charCodeAt(y);var b={data:x,mimeType:r};if(n[l]=b,"image/jpeg"===r){for(var B={uri:l},A=-1,y=0;y<a.length;++y)if(a[y].uri===l){A=y;break}A===-1?(a.push(B),o.source=a.length-1,i.push({source:a.length-1}),s={index:a.length-1}):(o.source=A,s={index:A})}return s},t.dielectricSpecular=new e.Color3(.04,.04,.04),t.maxSpecularPower=1024,t.epsilon=1e-6,t})();t._GLTFMaterial=r})(e.GLTF2||(e.GLTF2={}))})(BABYLON||(BABYLON={}));
|