babylonjs-serializers
Advanced tools
Comparing version 3.2.0-alpha9 to 3.2.0-alphaA
@@ -1,1 +0,1 @@ | ||
var globalObject="undefined"!=typeof global?global:"undefined"!=typeof window?window:this,babylonDependency=globalObject&&globalObject.BABYLON||BABYLON||"undefined"!=typeof require&&require("babylonjs"),BABYLON=babylonDependency,__decorate=this&&this.__decorate||function(e,t,r,a){var i,n=arguments.length,s=n<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,r):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,a);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(s=(n<3?i(s):n>3?i(t,r,s):i(t,r))||s);return n>3&&s&&Object.defineProperty(t,r,s),s},__extends=this&&this.__extends||(function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function a(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(a.prototype=r.prototype,new a)}})(),BABYLON;!(function(e){var t=(function(){function t(){}return t.OBJ=function(t,r,a,i){var n=[],s=1;r&&(a||(a="mat"),n.push("mtllib "+a+".mtl"));for(var o=0;o<t.length;o++){n.push("g object"+o),n.push("o object_"+o);var l=null;if(i){var u=e.Matrix.Translation(t[o].position.x,t[o].position.y,t[o].position.z);l=e.Matrix.Translation(-t[o].position.x,-t[o].position.y,-t[o].position.z),t[o].bakeTransformIntoVertices(u)}if(r){var c=t[o].material;c&&n.push("usemtl "+c.id)}var f=t[o].geometry;if(f){var h=f.getVerticesData("position"),d=f.getVerticesData("normal"),p=f.getVerticesData("uv"),g=f.getIndices(),m=0;if(h&&d&&p&&g){for(var y=0;y<h.length;y+=3)n.push("v "+h[y]+" "+h[y+1]+" "+h[y+2]),m++;for(y=0;y<d.length;y+=3)n.push("vn "+d[y]+" "+d[y+1]+" "+d[y+2]);for(y=0;y<p.length;y+=2)n.push("vt "+p[y]+" "+p[y+1]);for(y=0;y<g.length;y+=3)n.push("f "+(g[y+2]+s)+"/"+(g[y+2]+s)+"/"+(g[y+2]+s)+" "+(g[y+1]+s)+"/"+(g[y+1]+s)+"/"+(g[y+1]+s)+" "+(g[y]+s)+"/"+(g[y]+s)+"/"+(g[y]+s));i&&l&&t[o].bakeTransformIntoVertices(l),s+=m}}}return n.join("\n")},t.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")},t})();e.OBJExport=t})(BABYLON||(BABYLON={}));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),f=this.convertToRightHandedSystem?r.GetRightHandedVector3(c).asArray():c.asArray(),h=0;h<3;++h){var d=f[h];d<n[h]&&(n[h]=d),d>s[h]&&(s[h]=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 f=c*i,h=[];if(t===e.VertexBuffer.PositionKind||t===e.VertexBuffer.NormalKind){var d=e.Vector3.FromArray(a,f);h=this.convertToRightHandedSystem?r.GetRightHandedVector3(d).asArray():d.asArray()}else if(t===e.VertexBuffer.TangentKind||t===e.VertexBuffer.ColorKind){var d=e.Vector4.FromArray(a,f);h=this.convertToRightHandedSystem&&t!==e.VertexBuffer.ColorKind?r.GetRightHandedVector4(d).asArray():d.asArray()}else t===e.VertexBuffer.UVKind||t===e.VertexBuffer.UV2Kind?h=[a[f],a[f+1]]:e.Tools.Warn("Unsupported Vertex Buffer Type: "+t);for(var p=0;p<h.length;++p)o.setFloat32(l,h[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",f=this.createBufferView(0,s,u.data.length,void 0,c);s+=u.data.buffer.byteLength,this.bufferViews.push(f),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),f=28+n+l+r.byteLength+u+s+c,h=new ArrayBuffer(12),d=new DataView(h);d.setUint32(0,1179937895,!0),d.setUint32(4,2,!0),d.setUint32(8,f,!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),y=0;y<n;++y)m[y]=a.charCodeAt(y);for(var v=new Uint8Array(p,8+n),y=0;y<l;++y)v[y]=32;var b=new ArrayBuffer(8),x=new DataView(b);x.setUint32(0,r.byteLength+s+c,!0),x.setUint32(4,5130562,!0);for(var T=new ArrayBuffer(u),B=new Uint8Array(T),y=0;y<u;++y)B[y]=0;for(var w=new ArrayBuffer(c),A=new Uint8Array(w),y=0;y<c;++y)A[y]=0;var V=[h,p,b,r];for(var o in this.imageData)V.push(this.imageData[o].data.buffer);V.push(T),V.push(w);var L=new Blob(V,{type:"application/octet-stream"}),M=new e._GLTFData;return M.glTFFiles[i]=L,M},r.prototype.setNodeTransformation=function(t,a){0===a.position.x&&0===a.position.y&&0===a.position.z||(t.translation=this.convertToRightHandedSystem?r.GetRightHandedVector3(a.position).asArray():a.position.asArray()),1===a.scaling.x&&1===a.scaling.y&&1===a.scaling.z||(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 f=this.createBufferView(0,a,s,4*c,t+" - "+n.name);a+=s,this.bufferViews.push(f)}}return s},r.prototype.setPrimitiveAttributes=function(t,r,a,i){var n=null;r instanceof e.Mesh?n=r:r instanceof e.InstancedMesh&&(n=r.sourceMesh);var s=[{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"}],o=null;if(n){for(var l=0,u=s;l<u.length;l++){var c=u[l],f=c.kind;n.isVerticesDataPresent(f)&&(a+=this.createBufferViewKind(f,r,a,i),c.bufferViewIndex=this.bufferViews.length-1)}if(n.getTotalIndices()){var h=n.getIndices();if(h)if(i){for(var d=h.length,p=a,g=0;g<d;++g)i.setUint32(p,h[g],!0),p+=4;a=p}else{var m=4*h.length,y=this.createBufferView(0,a,m,void 0,"Indices - "+n.name);a+=m,this.bufferViews.push(y),o=this.bufferViews.length-1}}if(r.subMeshes)for(var v=0,b=r.subMeshes;v<b.length;v++){var x=b[v],T={attributes:{}};if(!i){for(var B=0,w=s;B<w.length;B++){var c=w[B],f=c.kind;if(n.isVerticesDataPresent(f)){var A=n.getVertexBuffer(f);if(A){var V=A.getData();if(V){var L=A.getStrideSize(),M=void 0,F=null,O=null,S=c.bufferViewIndex;if(void 0!=S){f==e.VertexBuffer.PositionKind&&(M=this.calculateMinMaxPositions(V,0,V.length/L),F=M.min,O=M.max);var C=this.createAccessor(S,f+" - "+r.name,c.accessorType,5126,V.length/L,0,F,O);switch(this.accessors.push(C),f){case e.VertexBuffer.PositionKind:T.attributes.POSITION=this.accessors.length-1;break;case e.VertexBuffer.NormalKind:T.attributes.NORMAL=this.accessors.length-1;break;case e.VertexBuffer.ColorKind:T.attributes.COLOR_0=this.accessors.length-1;break;case e.VertexBuffer.TangentKind:T.attributes.TANGENT=this.accessors.length-1;break;case e.VertexBuffer.UVKind:T.attributes.TEXCOORD_0=this.accessors.length-1;break;case e.VertexBuffer.UV2Kind:T.attributes.TEXCOORD_1=this.accessors.length-1;break;default:e.Tools.Warn("Unsupported Vertex Buffer Type: "+f)}}}}}}if(o){var C=this.createAccessor(o,"indices - "+r.name,"SCALAR",5125,x.indexCount,4*x.indexStart,null,null);this.accessors.push(C),T.indices=this.accessors.length-1}}if(n.material)if(n.material instanceof e.StandardMaterial||n.material instanceof e.PBRMetallicRoughnessMaterial){var R=r.getScene().materials.indexOf(n.material);T.material=R}else if(n.material instanceof e.MultiMaterial){var E=n.material,N=E.subMaterials[x.materialIndex];if(N){var R=r.getScene().materials.indexOf(N);T.material=R}}else e.Tools.Warn("Material type "+n.material.getClassName()+" for material "+n.material.name+" is not yet implemented in glTF serializer.");t.primitives.push(T)}}return a},r.prototype.createScene=function(e,r){if(e.meshes.length){var a=e.meshes,i={nodes:new Array};t._GLTFMaterial.ConvertMaterialsToGLTF(e.materials,"image/jpeg",this.images,this.textures,this.materials,this.imageData,!0);var n=this.createNodeMap(e,r);this.nodeMap=n.nodeMap,this.totalByteLength=n.byteOffset,this.binaryBuffer=new ArrayBuffer(this.totalByteLength);for(var s=new DataView(this.binaryBuffer),o=0;o<a.length;++o)if(!this.options||void 0==this.options.shouldExportMesh||this.options.shouldExportMesh(a[o])){var l=a[o],u=this.nodeMap[l.uniqueId],c=this.nodes[u];l.parent||i.nodes.push(u);var f=l.getDescendants(!0);if(!c.children&&f&&f.length){c.children=[];for(var h=0,d=f;h<d.length;h++){var p=d[h];c.children.push(this.nodeMap[p.uniqueId])}}var g={primitives:new Array};r=this.setPrimitiveAttributes(g,l,r,s)}this.scenes.push(i)}return r},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-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 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)}},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))throw new Error("Unsupported Babylon material type");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)}},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 f=t.ExportTexture(r.diffuseTexture,a,i,n,o);null!=f&&(u.baseColorTexture=f)}if(r.bumpTexture){var f=t.ExportTexture(r.bumpTexture,a,i,n,o);f&&(c.normalTexture=f)}if(r.emissiveTexture){var h=t.ExportTexture(r.emissiveTexture,a,i,n,o);h&&(c.emissiveTexture=h),c.emissiveFactor=[1,1,1]}if(r.ambientTexture){var d=t.ExportTexture(r.ambientTexture,a,i,n,o);d&&(c.occlusionTexture=d)}}(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())),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 f=t.GetAlphaMode(e);"OPAQUE"!==f&&(u.alphaMode=f,"BLEND"===f&&(u.alphaCutoff=e.alphaCutOff))}u.pbrMetallicRoughness=l,n.push(u)},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],f="";"image/jpeg"===r?f=".jpg":"image/png"===r?f=".png":e.Tools.Error("Unsupported mime type "+r),l=c+f;var h=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(h),p.putImageData(m,0,0);for(var y=d.toDataURL(r),v=atob(y.split(",")[1]),b=new Uint8Array(v.length),x=0;x<v.length;++x)b[x]=v.charCodeAt(x);var T={data:b,mimeType:r};if(n[l]=T,"image/jpeg"===r){for(var B={uri:l},w=-1,x=0;x<a.length;++x)if(a[x].uri===l){w=x;break}-1===w?(a.push(B),o.source=a.length-1,i.push({source:a.length-1}),s={index:a.length-1}):(o.source=w,s={index:w})}return s},t.dielectricSpecular=new e.Color3(.04,.04,.04),t.maxSpecularPower=1024,t})();t._GLTFMaterial=r})(e.GLTF2||(e.GLTF2={}))})(BABYLON||(BABYLON={})),(function(e,t){var r=t();"object"==typeof exports&&"object"==typeof module?module.exports=r:"function"==typeof define&&define.amd?define("babylonjs-serializers",["BABYLON"],t):"object"==typeof exports?exports["babylonjs-serializers"]=r:e.BABYLON=r})(this,(function(){return BABYLON})); | ||
var __decorate=this&&this.__decorate||function(e,t,r,a){var i,n=arguments.length,s=n<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,r):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,a);else for(var o=e.length-1;o>=0;o--)(i=e[o])&&(s=(n<3?i(s):n>3?i(t,r,s):i(t,r))||s);return n>3&&s&&Object.defineProperty(t,r,s),s},__extends=this&&this.__extends||(function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function a(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(a.prototype=r.prototype,new a)}})();!(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.BABYLON=t(e.BABYLON)})(this,(function(e){var e;!(function(e){var t=(function(){function t(){}return t.OBJ=function(t,r,a,i){var n=[],s=1;r&&(a||(a="mat"),n.push("mtllib "+a+".mtl"));for(var o=0;o<t.length;o++){n.push("g object"+o),n.push("o object_"+o);var l=null;if(i){var u=e.Matrix.Translation(t[o].position.x,t[o].position.y,t[o].position.z);l=e.Matrix.Translation(-t[o].position.x,-t[o].position.y,-t[o].position.z),t[o].bakeTransformIntoVertices(u)}if(r){var c=t[o].material;c&&n.push("usemtl "+c.id)}var f=t[o].geometry;if(f){var h=f.getVerticesData("position"),p=f.getVerticesData("normal"),d=f.getVerticesData("uv"),g=f.getIndices(),m=0;if(h&&p&&d&&g){for(var v=0;v<h.length;v+=3)n.push("v "+h[v]+" "+h[v+1]+" "+h[v+2]),m++;for(v=0;v<p.length;v+=3)n.push("vn "+p[v]+" "+p[v+1]+" "+p[v+2]);for(v=0;v<d.length;v+=2)n.push("vt "+d[v]+" "+d[v+1]);for(v=0;v<g.length;v+=3)n.push("f "+(g[v+2]+s)+"/"+(g[v+2]+s)+"/"+(g[v+2]+s)+" "+(g[v+1]+s)+"/"+(g[v+1]+s)+"/"+(g[v+1]+s)+" "+(g[v]+s)+"/"+(g[v]+s)+"/"+(g[v]+s));i&&l&&t[o].bakeTransformIntoVertices(l),s+=m}}}return n.join("\n")},t.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")},t})();e.OBJExport=t})(e||(e={}));var e;!(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})(e||(e={}));var e;!(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),f=this.convertToRightHandedSystem?r.GetRightHandedVector3(c).asArray():c.asArray(),h=0;h<3;++h){var p=f[h];p<n[h]&&(n[h]=p),p>s[h]&&(s[h]=p),++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 f=c*i,h=[];if(t===e.VertexBuffer.PositionKind||t===e.VertexBuffer.NormalKind){var p=e.Vector3.FromArray(a,f);h=this.convertToRightHandedSystem?r.GetRightHandedVector3(p).asArray():p.asArray()}else if(t===e.VertexBuffer.TangentKind||t===e.VertexBuffer.ColorKind){var p=e.Vector4.FromArray(a,f);h=this.convertToRightHandedSystem&&t!==e.VertexBuffer.ColorKind?r.GetRightHandedVector4(p).asArray():p.asArray()}else t===e.VertexBuffer.UVKind||t===e.VertexBuffer.UV2Kind?h=[a[f],a[f+1]]:e.Tools.Warn("Unsupported Vertex Buffer Type: "+t);for(var d=0;d<h.length;++d)o.setFloat32(l,h[d],!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",f=this.createBufferView(0,s,u.data.length,void 0,c);s+=u.data.buffer.byteLength,this.bufferViews.push(f),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),f=28+n+l+r.byteLength+u+s+c,h=new ArrayBuffer(12),p=new DataView(h);p.setUint32(0,1179937895,!0),p.setUint32(4,2,!0),p.setUint32(8,f,!0);var d=new ArrayBuffer(8+n+l),g=new DataView(d);g.setUint32(0,n+l,!0),g.setUint32(4,1313821514,!0);for(var m=new Uint8Array(d,8),v=0;v<n;++v)m[v]=a.charCodeAt(v);for(var y=new Uint8Array(d,8+n),v=0;v<l;++v)y[v]=32;var x=new ArrayBuffer(8),b=new DataView(x);b.setUint32(0,r.byteLength+s+c,!0),b.setUint32(4,5130562,!0);for(var T=new ArrayBuffer(u),w=new Uint8Array(T),v=0;v<u;++v)w[v]=0;for(var B=new ArrayBuffer(c),V=new Uint8Array(B),v=0;v<c;++v)V[v]=0;var A=[h,d,x,r];for(var o in this.imageData)A.push(this.imageData[o].data.buffer);A.push(T),A.push(B);var M=new Blob(A,{type:"application/octet-stream"}),F=new e._GLTFData;return F.glTFFiles[i]=M,F},r.prototype.setNodeTransformation=function(t,a){0===a.position.x&&0===a.position.y&&0===a.position.z||(t.translation=this.convertToRightHandedSystem?r.GetRightHandedVector3(a.position).asArray():a.position.asArray()),1===a.scaling.x&&1===a.scaling.y&&1===a.scaling.z||(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 f=this.createBufferView(0,a,s,4*c,t+" - "+n.name);a+=s,this.bufferViews.push(f)}}return s},r.prototype.setPrimitiveAttributes=function(t,r,a,i){var n=null;r instanceof e.Mesh?n=r:r instanceof e.InstancedMesh&&(n=r.sourceMesh);var s=[{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"}],o=null;if(n){for(var l=0,u=s;l<u.length;l++){var c=u[l],f=c.kind;n.isVerticesDataPresent(f)&&(a+=this.createBufferViewKind(f,r,a,i),c.bufferViewIndex=this.bufferViews.length-1)}if(n.getTotalIndices()){var h=n.getIndices();if(h)if(i){for(var p=h.length,d=a,g=0;g<p;++g)i.setUint32(d,h[g],!0),d+=4;a=d}else{var m=4*h.length,v=this.createBufferView(0,a,m,void 0,"Indices - "+n.name);a+=m,this.bufferViews.push(v),o=this.bufferViews.length-1}}if(r.subMeshes)for(var y=0,x=r.subMeshes;y<x.length;y++){var b=x[y],T={attributes:{}};if(!i){for(var w=0,B=s;w<B.length;w++){var c=B[w],f=c.kind;if(n.isVerticesDataPresent(f)){var V=n.getVertexBuffer(f);if(V){var A=V.getData();if(A){var M=V.getStrideSize(),F=void 0,S=null,L=null,C=c.bufferViewIndex;if(void 0!=C){f==e.VertexBuffer.PositionKind&&(F=this.calculateMinMaxPositions(A,0,A.length/M),S=F.min,L=F.max);var R=this.createAccessor(C,f+" - "+r.name,c.accessorType,5126,A.length/M,0,S,L);switch(this.accessors.push(R),f){case e.VertexBuffer.PositionKind:T.attributes.POSITION=this.accessors.length-1;break;case e.VertexBuffer.NormalKind:T.attributes.NORMAL=this.accessors.length-1;break;case e.VertexBuffer.ColorKind:T.attributes.COLOR_0=this.accessors.length-1;break;case e.VertexBuffer.TangentKind:T.attributes.TANGENT=this.accessors.length-1;break;case e.VertexBuffer.UVKind:T.attributes.TEXCOORD_0=this.accessors.length-1;break;case e.VertexBuffer.UV2Kind:T.attributes.TEXCOORD_1=this.accessors.length-1;break;default:e.Tools.Warn("Unsupported Vertex Buffer Type: "+f)}}}}}}if(o){var R=this.createAccessor(o,"indices - "+r.name,"SCALAR",5125,b.indexCount,4*b.indexStart,null,null);this.accessors.push(R),T.indices=this.accessors.length-1}}if(n.material)if(n.material instanceof e.StandardMaterial||n.material instanceof e.PBRMetallicRoughnessMaterial){var E=r.getScene().materials.indexOf(n.material);T.material=E}else if(n.material instanceof e.MultiMaterial){var P=n.material,_=P.subMaterials[b.materialIndex];if(_){var E=r.getScene().materials.indexOf(_);T.material=E}}else e.Tools.Warn("Material type "+n.material.getClassName()+" for material "+n.material.name+" is not yet implemented in glTF serializer.");t.primitives.push(T)}}return a},r.prototype.createScene=function(e,r){if(e.meshes.length){var a=e.meshes,i={nodes:new Array};t._GLTFMaterial.ConvertMaterialsToGLTF(e.materials,"image/jpeg",this.images,this.textures,this.materials,this.imageData,!0);var n=this.createNodeMap(e,r);this.nodeMap=n.nodeMap,this.totalByteLength=n.byteOffset,this.binaryBuffer=new ArrayBuffer(this.totalByteLength);for(var s=new DataView(this.binaryBuffer),o=0;o<a.length;++o)if(!this.options||void 0==this.options.shouldExportMesh||this.options.shouldExportMesh(a[o])){var l=a[o],u=this.nodeMap[l.uniqueId],c=this.nodes[u];l.parent||i.nodes.push(u);var f=l.getDescendants(!0);if(!c.children&&f&&f.length){c.children=[];for(var h=0,p=f;h<p.length;h++){var d=p[h];c.children.push(this.nodeMap[d.uniqueId])}}var g={primitives:new Array};r=this.setPrimitiveAttributes(g,l,r,s)}this.scenes.push(i)}return r},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={}))})(e||(e={}));var e;!(function(e){var t=(function(){function e(){this.glTFFiles={}}return e.prototype.downloadFiles=function(){function e(e,t){return-1!==e.indexOf(t,e.length-t.length)}for(var t in this.glTFFiles){var r=document.createElement("a");document.body.appendChild(r),r.setAttribute("type","hidden"),r.download=t;var 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})(e||(e={}));var e;return (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)}},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))throw new Error("Unsupported Babylon material type");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)}},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 f=t.ExportTexture(r.diffuseTexture,a,i,n,o);null!=f&&(u.baseColorTexture=f)}if(r.bumpTexture){var f=t.ExportTexture(r.bumpTexture,a,i,n,o);f&&(c.normalTexture=f)}if(r.emissiveTexture){var h=t.ExportTexture(r.emissiveTexture,a,i,n,o);h&&(c.emissiveTexture=h),c.emissiveFactor=[1,1,1]}if(r.ambientTexture){var p=t.ExportTexture(r.ambientTexture,a,i,n,o);p&&(c.occlusionTexture=p)}}(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 f=t.GetAlphaMode(e);"OPAQUE"!==f&&(u.alphaMode=f,"BLEND"===f&&(u.alphaCutoff=e.alphaCutOff))}u.pbrMetallicRoughness=l,n.push(u)},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],f="";"image/jpeg"===r?f=".jpg":"image/png"===r?f=".png":e.Tools.Error("Unsupported mime type "+r),l=c+f;var h=t.readPixels(),p=document.createElement("canvas");p.id="ImageCanvas";var d=p.getContext("2d"),g=t.getSize();p.width=g.width,p.height=g.height;var m=d.createImageData(g.width,g.height);m.data.set(h),d.putImageData(m,0,0);for(var v=p.toDataURL(r),y=atob(v.split(",")[1]),x=new Uint8Array(y.length),b=0;b<y.length;++b)x[b]=y.charCodeAt(b);var T={data:x,mimeType:r};if(n[l]=T,"image/jpeg"===r){for(var w={uri:l},B=-1,b=0;b<a.length;++b)if(a[b].uri===l){B=b;break}-1===B?(a.push(w),o.source=a.length-1,i.push({source:a.length-1}),s={index:a.length-1}):(o.source=B,s={index:B})}return s},t.dielectricSpecular=new e.Color3(.04,.04,.04),t.maxSpecularPower=1024,t})();t._GLTFMaterial=r})(e.GLTF2||(e.GLTF2={}))})(e||(e={})),e})); |
@@ -7,3 +7,3 @@ { | ||
"description": "The Babylon.js serializers library is an extension you can use to serialize Babylon scenes.", | ||
"version": "3.2.0-alpha9", | ||
"version": "3.2.0-alphaA", | ||
"repository": { | ||
@@ -31,3 +31,3 @@ "type": "git", | ||
"dependencies": { | ||
"babylonjs-gltf2interface": "3.2.0-alpha9" | ||
"babylonjs-gltf2interface": "3.2.0-alphaA" | ||
}, | ||
@@ -34,0 +34,0 @@ "peerDependencies": { |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
109554
1678
+ Addedbabylonjs-gltf2interface@3.2.0-alphaA(transitive)
- Removedbabylonjs-gltf2interface@3.2.0-alpha9(transitive)