babylonjs-serializers 9.5.0 → 9.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("babylonjs")):"function"==typeof define&&define.amd?define(["exports","babylonjs"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).BABYLON=e.BABYLON||{},e.BABYLON)}(this,function(e,t){"use strict";var o=function(){function e(){}return e.OBJ=function(e,o,r,i){var n=[],a=1,s=1;o&&(r||(r="mat"),n.push("mtllib "+r+".mtl"));for(var u=0;u<e.length;u++){var l=e[u],p=l.name||"mesh".concat(u,"}");n.push("o ".concat(p));var f=null;if(i){var d=l.computeWorldMatrix(!0);f=new t.Matrix,d.invertToRef(f),l.bakeTransformIntoVertices(d)}if(o){var m=l.material;m&&n.push("usemtl "+m.id)}var h=l.geometry;if(h){var c=h.getVerticesData("position"),x=h.getVerticesData("normal"),g=h.getVerticesData("uv"),v=h.getIndices(),b=0,T=0;if(c&&v){for(var _=e[0].getScene().useRightHandedSystem?1:-1,y=0;y<c.length;y+=3)n.push("v "+c[y]*_+" "+c[y+1]+" "+c[y+2]),b++;if(null!=x)for(y=0;y<x.length;y+=3)n.push("vn "+x[y]*_+" "+x[y+1]+" "+x[y+2]);if(null!=g)for(y=0;y<g.length;y+=2)n.push("vt "+g[y]+" "+g[y+1]),T++;var F=["","",""],C=(l.material||l.getScene().defaultMaterial)._getEffectiveOrientation(l)===t.Material.ClockWiseSideOrientation?[2,1]:[1,2],B=C[0],O=C[1];for(y=0;y<v.length;y+=3){var S=[String(v[y]+a),String(v[y+B]+a),String(v[y+O]+a)],w=[String(v[y]+s),String(v[y+B]+s),String(v[y+O]+s)],K=S,N=null!=g?w:F,j=null!=x?S:F;n.push("f "+K[0]+"/"+N[0]+"/"+j[0]+" "+K[1]+"/"+N[1]+"/"+j[1]+" "+K[2]+"/"+N[2]+"/"+j[2])}i&&f&&l.bakeTransformIntoVertices(f),a+=b,s+=T}else t.Tools.Warn("There are no position vertices or indices on the mesh!")}else t.Tools.Warn("No geometry is present on the mesh")}return n.join("\n")},e.MTL=function(e){var t=[],o=e.material;return t.push("newmtl mat1"),t.push(" Ns "+o.specularPower.toFixed(4)),t.push(" Ni 1.5000"),t.push(" d "+o.alpha.toFixed(4)),t.push(" Tr 0.0000"),t.push(" Tf 1.0000 1.0000 1.0000"),t.push(" illum 2"),t.push(" Ka "+o.ambientColor.r.toFixed(4)+" "+o.ambientColor.g.toFixed(4)+" "+o.ambientColor.b.toFixed(4)),t.push(" Kd "+o.diffuseColor.r.toFixed(4)+" "+o.diffuseColor.g.toFixed(4)+" "+o.diffuseColor.b.toFixed(4)),t.push(" Ks "+o.specularColor.r.toFixed(4)+" "+o.specularColor.g.toFixed(4)+" "+o.specularColor.b.toFixed(4)),t.push(" Ke "+o.emissiveColor.r.toFixed(4)+" "+o.emissiveColor.g.toFixed(4)+" "+o.emissiveColor.b.toFixed(4)),o.ambientTexture&&t.push(" map_Ka "+o.ambientTexture.name),o.diffuseTexture&&t.push(" map_Kd "+o.diffuseTexture.name),o.specularTexture&&t.push(" map_Ks "+o.specularTexture.name),o.bumpTexture&&t.push(" map_bump -imfchan z "+o.bumpTexture.name),o.opacityTexture&&t.push(" map_d "+o.opacityTexture.name),t.join("\n")},e}(),r={__proto__:null,OBJExport:o},i="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==i)for(var n in r)i.BABYLON[n]=r[n];var a={__proto__:null,OBJExport:o};e.default=a,e.serializers=a,Object.defineProperty(e,"__esModule",{value:!0})});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("babylonjs")):"function"==typeof define&&define.amd?define(["exports","babylonjs"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).BABYLON=e.BABYLON||{},e.BABYLON)}(this,function(e,t){"use strict";var o=function(){function e(){}return e.OBJ=function(e,o,i,r){var n=[],a=1,s=1;o&&(i||(i="mat"),n.push("mtllib "+i+".mtl"));for(var u=0;u<e.length;u++){var l=e[u],p=l.name||"mesh".concat(u,"}");n.push("o ".concat(p));var f=null;if(r){var d=l.computeWorldMatrix(!0);f=new t.Matrix,d.invertToRef(f),l.bakeTransformIntoVertices(d)}if(o){var m=l.material;m&&n.push("usemtl "+m.id)}var h=l.geometry;if(h){var c=h.getVerticesData("position"),x=h.getVerticesData("normal"),g=h.getVerticesData("uv"),v=h.getIndices(),b=0,T=0;if(c&&v){for(var F=e[0].getScene().useRightHandedSystem?1:-1,y=0;y<c.length;y+=3)n.push("v "+c[y]*F+" "+c[y+1]+" "+c[y+2]),b++;if(null!=x)for(y=0;y<x.length;y+=3)n.push("vn "+x[y]*F+" "+x[y+1]+" "+x[y+2]);if(null!=g)for(y=0;y<g.length;y+=2)n.push("vt "+g[y]+" "+g[y+1]),T++;var C=["","",""],B=(l.material||l.getScene().defaultMaterial)._getEffectiveOrientation(l)===t.Material.ClockWiseSideOrientation?[2,1]:[1,2],S=B[0],_=B[1];for(y=0;y<v.length;y+=3){var O=[String(v[y]+a),String(v[y+S]+a),String(v[y+_]+a)],w=[String(v[y]+s),String(v[y+S]+s),String(v[y+_]+s)],K=O,N=null!=g?w:C,j=null!=x?O:C;n.push("f "+K[0]+"/"+N[0]+"/"+j[0]+" "+K[1]+"/"+N[1]+"/"+j[1]+" "+K[2]+"/"+N[2]+"/"+j[2])}r&&f&&l.bakeTransformIntoVertices(f),a+=b,s+=T}else t.Tools.Warn("There are no position vertices or indices on the mesh!")}else t.Tools.Warn("No geometry is present on the mesh")}return n.join("\n")},e.MTL=function(e){var t=[],o=e.material;return t.push("newmtl mat1"),t.push(" Ns "+o.specularPower.toFixed(4)),t.push(" Ni 1.5000"),t.push(" d "+o.alpha.toFixed(4)),t.push(" Tr 0.0000"),t.push(" Tf 1.0000 1.0000 1.0000"),t.push(" illum 2"),t.push(" Ka "+o.ambientColor.r.toFixed(4)+" "+o.ambientColor.g.toFixed(4)+" "+o.ambientColor.b.toFixed(4)),t.push(" Kd "+o.diffuseColor.r.toFixed(4)+" "+o.diffuseColor.g.toFixed(4)+" "+o.diffuseColor.b.toFixed(4)),t.push(" Ks "+o.specularColor.r.toFixed(4)+" "+o.specularColor.g.toFixed(4)+" "+o.specularColor.b.toFixed(4)),t.push(" Ke "+o.emissiveColor.r.toFixed(4)+" "+o.emissiveColor.g.toFixed(4)+" "+o.emissiveColor.b.toFixed(4)),o.ambientTexture&&t.push(" map_Ka "+o.ambientTexture.name),o.diffuseTexture&&t.push(" map_Kd "+o.diffuseTexture.name),o.specularTexture&&t.push(" map_Ks "+o.specularTexture.name),o.bumpTexture&&t.push(" map_bump -imfchan z "+o.bumpTexture.name),o.opacityTexture&&t.push(" map_d "+o.opacityTexture.name),t.join("\n")},e}(),i={__proto__:null,OBJExport:o},r="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==r)for(var n in i)r.BABYLON[n]=i[n];e.OBJExport=o});
2
2
  //# sourceMappingURL=babylon.objSerializer.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"babylon.objSerializer.min.js","sources":["../../../../../../../dev/serializers/src/OBJ/objSerializer.ts","../../../../../../../dev/serializers/src/legacy/legacy-objSerializer.ts"],"sourcesContent":[null,null],"names":["OBJExport","OBJ","meshes","materials","matlibname","globalposition","output","v","textureV","push","j","length","mesh","objectName","name","concat","inverseTransform","transform","computeWorldMatrix","Matrix","invertToRef","bakeTransformIntoVertices","mat","material","id","g","geometry","trunkVerts","getVerticesData","trunkNormals","trunkUV","trunkFaces","getIndices","currentV","currentTextureV","handednessSign","getScene","useRightHandedSystem","i","blanks","_a","defaultMaterial","_getEffectiveOrientation","Material","ClockWiseSideOrientation","offset1","offset2","indices","String","textureIndices","facePositions","faceUVs","faceNormals","Tools","Warn","join","MTL","m","specularPower","toFixed","alpha","ambientColor","r","b","diffuseColor","specularColor","emissiveColor","ambientTexture","diffuseTexture","specularTexture","bumpTexture","opacityT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C,oBAAXC,OAAyBA,OAA2B,oBAAXC,OAAyBA,YAASC,EACvG,QAA4B,IAAjBH,EACP,IAAK,IAAMI,KAAcC,EACfL,EAAcM,QAAQF,GAAoBC,EAAaD"}
1
+ {"version":3,"file":"babylon.objSerializer.min.js","sources":["file:///home/vsts/work/1/s/packages/dev/serializers/src/OBJ/objSerializer.ts","file:///home/vsts/work/1/s/packages/dev/serializers/src/legacy/legacy-objSerializer.ts"],"sourcesContent":["import { type Nullable } from \"core/types\";\r\nimport { Matrix } from \"core/Maths/math.vector\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { type StandardMaterial } from \"core/Materials/standardMaterial\";\r\nimport { type Geometry } from \"core/Meshes/geometry\";\r\nimport { type Mesh } from \"core/Meshes/mesh\";\r\nimport { Material } from \"core/Materials/material\";\r\n\r\n/**\r\n * Class for generating OBJ data from a Babylon scene.\r\n */\r\nexport class OBJExport {\r\n /**\r\n * Exports the geometry of a Mesh array in .OBJ file format (text)\r\n * @param meshes defines the list of meshes to serialize\r\n * @param materials defines if materials should be exported\r\n * @param matlibname defines the name of the associated mtl file\r\n * @param globalposition defines if the exported positions are globals or local to the exported mesh\r\n * @returns the OBJ content\r\n */\r\n public static OBJ(meshes: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string {\r\n const output: string[] = [];\r\n let v = 1;\r\n // keep track of uv index in case mixed meshes are passed in\r\n let textureV = 1;\r\n\r\n if (materials) {\r\n if (!matlibname) {\r\n matlibname = \"mat\";\r\n }\r\n output.push(\"mtllib \" + matlibname + \".mtl\");\r\n }\r\n for (let j = 0; j < meshes.length; j++) {\r\n const mesh = meshes[j];\r\n const objectName = mesh.name || `mesh${j}}`;\r\n output.push(`o ${objectName}`);\r\n\r\n //Uses the position of the item in the scene, to the file (this back to normal in the end)\r\n let inverseTransform: Nullable<Matrix> = null;\r\n if (globalposition) {\r\n const transform = mesh.computeWorldMatrix(true);\r\n inverseTransform = new Matrix();\r\n transform.invertToRef(inverseTransform);\r\n\r\n mesh.bakeTransformIntoVertices(transform);\r\n }\r\n\r\n //TODO: submeshes (groups)\r\n //TODO: smoothing groups (s 1, s off);\r\n if (materials) {\r\n const mat = mesh.material;\r\n\r\n if (mat) {\r\n output.push(\"usemtl \" + mat.id);\r\n }\r\n }\r\n const g: Nullable<Geometry> = mesh.geometry;\r\n\r\n if (!g) {\r\n Tools.Warn(\"No geometry is present on the mesh\");\r\n continue;\r\n }\r\n\r\n const trunkVerts = g.getVerticesData(\"position\");\r\n const trunkNormals = g.getVerticesData(\"normal\");\r\n const trunkUV = g.getVerticesData(\"uv\");\r\n const trunkFaces = g.getIndices();\r\n let currentV = 0;\r\n let currentTextureV = 0;\r\n\r\n if (!trunkVerts || !trunkFaces) {\r\n Tools.Warn(\"There are no position vertices or indices on the mesh!\");\r\n continue;\r\n }\r\n\r\n const useRightHandedSystem = meshes[0].getScene().useRightHandedSystem;\r\n const handednessSign = useRightHandedSystem ? 1 : -1;\r\n\r\n for (let i = 0; i < trunkVerts.length; i += 3) {\r\n output.push(\"v \" + trunkVerts[i] * handednessSign + \" \" + trunkVerts[i + 1] + \" \" + trunkVerts[i + 2]);\r\n currentV++;\r\n }\r\n\r\n if (trunkNormals != null) {\r\n for (let i = 0; i < trunkNormals.length; i += 3) {\r\n output.push(\"vn \" + trunkNormals[i] * handednessSign + \" \" + trunkNormals[i + 1] + \" \" + trunkNormals[i + 2]);\r\n }\r\n }\r\n if (trunkUV != null) {\r\n for (let i = 0; i < trunkUV.length; i += 2) {\r\n output.push(\"vt \" + trunkUV[i] + \" \" + trunkUV[i + 1]);\r\n currentTextureV++;\r\n }\r\n }\r\n\r\n const blanks: string[] = [\"\", \"\", \"\"];\r\n const material = mesh.material || mesh.getScene().defaultMaterial;\r\n\r\n const sideOrientation = material._getEffectiveOrientation(mesh);\r\n const [offset1, offset2] = sideOrientation === Material.ClockWiseSideOrientation ? [2, 1] : [1, 2];\r\n\r\n for (let i = 0; i < trunkFaces.length; i += 3) {\r\n const indices = [String(trunkFaces[i] + v), String(trunkFaces[i + offset1] + v), String(trunkFaces[i + offset2] + v)];\r\n const textureIndices = [String(trunkFaces[i] + textureV), String(trunkFaces[i + offset1] + textureV), String(trunkFaces[i + offset2] + textureV)];\r\n\r\n const facePositions = indices;\r\n const faceUVs = trunkUV != null ? textureIndices : blanks;\r\n const faceNormals = trunkNormals != null ? indices : blanks;\r\n\r\n output.push(\r\n \"f \" +\r\n facePositions[0] +\r\n \"/\" +\r\n faceUVs[0] +\r\n \"/\" +\r\n faceNormals[0] +\r\n \" \" +\r\n facePositions[1] +\r\n \"/\" +\r\n faceUVs[1] +\r\n \"/\" +\r\n faceNormals[1] +\r\n \" \" +\r\n facePositions[2] +\r\n \"/\" +\r\n faceUVs[2] +\r\n \"/\" +\r\n faceNormals[2]\r\n );\r\n }\r\n //back de previous matrix, to not change the original mesh in the scene\r\n if (globalposition && inverseTransform) {\r\n mesh.bakeTransformIntoVertices(inverseTransform);\r\n }\r\n v += currentV;\r\n textureV += currentTextureV;\r\n }\r\n const text: string = output.join(\"\\n\");\r\n return text;\r\n }\r\n\r\n /**\r\n * Exports the material(s) of a mesh in .MTL file format (text)\r\n * @param mesh defines the mesh to extract the material from\r\n * @returns the mtl content\r\n */\r\n //TODO: Export the materials of mesh array\r\n public static MTL(mesh: Mesh): string {\r\n const output = [];\r\n const m = <StandardMaterial>mesh.material;\r\n output.push(\"newmtl mat1\");\r\n output.push(\" Ns \" + m.specularPower.toFixed(4));\r\n output.push(\" Ni 1.5000\");\r\n output.push(\" d \" + m.alpha.toFixed(4));\r\n output.push(\" Tr 0.0000\");\r\n output.push(\" Tf 1.0000 1.0000 1.0000\");\r\n output.push(\" illum 2\");\r\n output.push(\" Ka \" + m.ambientColor.r.toFixed(4) + \" \" + m.ambientColor.g.toFixed(4) + \" \" + m.ambientColor.b.toFixed(4));\r\n output.push(\" Kd \" + m.diffuseColor.r.toFixed(4) + \" \" + m.diffuseColor.g.toFixed(4) + \" \" + m.diffuseColor.b.toFixed(4));\r\n output.push(\" Ks \" + m.specularColor.r.toFixed(4) + \" \" + m.specularColor.g.toFixed(4) + \" \" + m.specularColor.b.toFixed(4));\r\n output.push(\" Ke \" + m.emissiveColor.r.toFixed(4) + \" \" + m.emissiveColor.g.toFixed(4) + \" \" + m.emissiveColor.b.toFixed(4));\r\n\r\n //TODO: uv scale, offset, wrap\r\n //TODO: UV mirrored in Blender? second UV channel? lightMap? reflection textures?\r\n const uvscale = \"\";\r\n\r\n if (m.ambientTexture) {\r\n output.push(\" map_Ka \" + uvscale + m.ambientTexture.name);\r\n }\r\n\r\n if (m.diffuseTexture) {\r\n output.push(\" map_Kd \" + uvscale + m.diffuseTexture.name);\r\n //TODO: alpha testing, opacity in diffuse texture alpha channel (diffuseTexture.hasAlpha -> map_d)\r\n }\r\n\r\n if (m.specularTexture) {\r\n output.push(\" map_Ks \" + uvscale + m.specularTexture.name);\r\n /* TODO: glossiness = specular highlight component is in alpha channel of specularTexture. (???)\r\n if (m.useGlossinessFromSpecularMapAlpha) {\r\n output.push(\" map_Ns \"+uvscale + m.specularTexture.name);\r\n }\r\n */\r\n }\r\n\r\n /* TODO: emissive texture not in .MAT format (???)\r\n if (m.emissiveTexture) {\r\n output.push(\" map_d \"+uvscale+m.emissiveTexture.name);\r\n }\r\n */\r\n\r\n if (m.bumpTexture) {\r\n output.push(\" map_bump -imfchan z \" + uvscale + m.bumpTexture.name);\r\n }\r\n\r\n if (m.opacityTexture) {\r\n output.push(\" map_d \" + uvscale + m.opacityTexture.name);\r\n }\r\n\r\n const text = output.join(\"\\n\");\r\n return text;\r\n }\r\n}\r\n","/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nimport * as Serializers from \"serializers/OBJ/index\";\r\n\r\n/**\r\n * This is the entry point for the UMD module.\r\n * The entry point for a future ESM package should be index.ts\r\n */\r\nconst GlobalObject = typeof global !== \"undefined\" ? global : typeof window !== \"undefined\" ? window : undefined;\r\nif (typeof GlobalObject !== \"undefined\") {\r\n for (const serializer in Serializers) {\r\n (<any>GlobalObject).BABYLON[serializer] = (<any>Serializers)[serializer];\r\n }\r\n}\r\n\r\nexport * from \"serializers/OBJ/index\";\r\n"],"names":["OBJExport","OBJ","meshes","materials","matlibname","globalposition","output","v","textureV","push","j","length","mesh","objectName","name","concat","inverseTransform","transform","computeWorldMatrix","Matrix","invertToRef","bakeTransformIntoVertices","mat","material","id","g","geometry","trunkVerts","getVerticesData","trunkNormals","trunkUV","trunkFaces","getIndices","currentV","currentTextureV","handednessSign","getScene","useRightHandedSystem","i","blanks","_a","defaultMaterial","_getEffectiveOrientation","Material","ClockWiseSideOrientation","offset1","offset2","indices","String","textureIndices","facePositions","faceUVs","faceNormals","Tools","Warn","join","MTL","m","specularPower","toFixed","alpha","ambientColor","r","b","diffuseColor","specularColor","emissiveColor","ambientTexture","diffuseTexture","specularTexture","bumpTexture","opacityTexture","GlobalObject","global","window","undefined","serializer","Serializers","BABYLON"],"mappings":"sSAWA,IAAAA,EAAA,WAAA,SAAAA,IA8LA,CAAA,OArLkBA,EAAAC,IAAd,SAAkBC,EAAgBC,EAAqBC,EAAqBC,GACxE,IAAMC,EAAmB,GACrBC,EAAI,EAEJC,EAAW,EAEXL,IACKC,IACDA,EAAa,OAEjBE,EAAOG,KAAK,UAAYL,EAAa,SAEzC,IAAK,IAAIM,EAAI,EAAGA,EAAIR,EAAOS,OAAQD,IAAK,CACpC,IAAME,EAAOV,EAAOQ,GACdG,EAAaD,EAAKE,MAAQ,OAAAC,OAAOL,EAAC,KACxCJ,EAAOG,KAAK,YAAKI,IAGjB,IAAIG,EAAqC,KACzC,GAAIX,EAAgB,CAChB,IAAMY,EAAYL,EAAKM,oBAAmB,GAC1CF,EAAmB,IAAIG,EAAAA,OACvBF,EAAUG,YAAYJ,GAEtBJ,EAAKS,0BAA0BJ,EACnC,CAIA,GAAId,EAAW,CACX,IAAMmB,EAAMV,EAAKW,SAEbD,GACAhB,EAAOG,KAAK,UAAYa,EAAIE,GAEpC,CACA,IAAMC,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AcF,EAAEJ,QAAQ,IAC1HrD,EAAOG,KAAK,QAAUgD,EAAES,cAAcJ,EAAEH,QAAQ,GAAK,IAAMF,EAAES,cAAczC,EAAEkC,QAAQ,GAAK,IAAMF,EAAES,cAAcH,EAAEJ,QAAQ,IAMtHF,EAAEU,gBACF7D,EAAOG,KAAK,YAAwBgD,EAAEU,eAAerD,MAGrD2C,EAAEW,gBACF9D,EAAOG,KAAK,YAAwBgD,EAAEW,eAAetD,MAIrD2C,EAAEY,iBACF/D,EAAOG,KAAK,YAAwBgD,EAAEY,gBAAgBvD,MActD2C,EAAEa,aACFhE,EAAOG,KAAK,yBAAqCgD,EAAEa,YAAYxD,MAG/D2C,EAAEc,gBACFjE,EAAOG,KAAK,WAAuBgD,EAAEc,eAAezD,MAG3CR,EAAOiD,KAAK,KAE7B,EACJvD,CAAA,mCClMMwE,EAAiC,oBAAXC,OAAyBA,OAA2B,oBAAXC,OAAyBA,YAASC,EACvG,QAA4B,IAAjBH,EACP,IAAK,IAAMI,KAAcC,EACfL,EAAcM,QAAQF,GAAoBC,EAAaD"}
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("babylonjs")):"function"==typeof define&&define.amd?define(["exports","babylonjs"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).BABYLON=e.BABYLON||{},e.BABYLON)}(this,function(e,t){"use strict";var n=function(){function e(){}return e.CreateSTL=function(e,n,r,o,i,a,s,f){void 0===n&&(n=!0),void 0===r&&(r="stlmesh"),void 0===o&&(o=!1),void 0===i&&(i=!0),void 0===a&&(a=!1),void 0===s&&(s=!1),void 0===f&&(f=!1);var d=function(e,n,r){var o=[3*e[r],3*e[r+1],3*e[r+2]],i=[new t.Vector3(n[o[0]],n[o[0]+2],n[o[0]+1]),new t.Vector3(n[o[1]],n[o[1]+2],n[o[1]+1]),new t.Vector3(n[o[2]],n[o[2]+2],n[o[2]+1])],a=i[0].subtract(i[1]),s=i[2].subtract(i[1]);return{v:i,n:t.Vector3.Cross(s,a).normalize()}},l=function(e,t,n,r){return t=v(e,t,n.x,r),t=v(e,t,n.y,r),v(e,t,n.z,r)},v=function(e,t,n,r){return e.setFloat32(t,n,r),t+4},c=function(e){if(s){var n=e;e instanceof t.InstancedMesh&&(n=e.sourceMesh);var r=n.getVerticesData(t.VertexBuffer.PositionKind,!0,!0);if(!r)return[];var o=t.Vector3.Zero(),i=void 0;for(i=0;i<r.length;i+=3)t.Vector3.TransformCoordinatesFromFloatsToRef(r[i],r[i+1],r[i+2],e.computeWorldMatrix(!0),o).toArray(r,i);return r}return e.getVerticesData(t.VertexBuffer.PositionKind)||[]};s&&(a=!0);var u="",p=0,y=0;if(o){for(var m=0;m<e.length;m++)p+=(w=(b=e[m]).getIndices())?w.length/3:0;var x=new ArrayBuffer(84+50*p);y+=80,(u=new DataView(x)).setUint32(y,p,i),y+=4}else f||(u="solid stlmesh\r\n");for(m=0;m<e.length;m++){var b=e[m];!o&&f&&(u+="solid "+b.name+"\r\n"),!a&&b instanceof t.Mesh&&b.bakeCurrentTransformIntoVertices();for(var h=c(b),w=b.getIndices()||[],g=0;g<w.length;g+=3){var B=d(w,h,g);o?(y=l(u,y,B.n,i),y=l(u,y,B.v[0],i),y=l(u,y,B.v[1],i),y=l(u,y,B.v[2],i),y+=2):(u+="\tfacet normal "+B.n.x+" "+B.n.y+" "+B.n.z+"\r\n",u+="\t\touter loop\r\n",u+="\t\t\tvertex "+B.v[0].x+" "+B.v[0].y+" "+B.v[0].z+"\r\n",u+="\t\t\tvertex "+B.v[1].x+" "+B.v[1].y+" "+B.v[1].z+"\r\n",u+="\t\t\tvertex "+B.v[2].x+" "+B.v[2].y+" "+B.v[2].z+"\r\n",u+="\t\tendloop\r\n",u+="\tendfacet\r\n")}!o&&f&&(u+="endsolid "+name+"\r\n")}if(o||f||(u+="endsolid stlmesh"),n){var V=document.createElement("a"),_=new Blob([u],{type:"application/octet-stream"});V.href=window.URL.createObjectURL(_),V.download=r+".stl",V.click()}return u},e}(),r={__proto__:null,STLExport:n},o="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==o)for(var i in r)o.BABYLON[i]=r[i];var a={__proto__:null,STLExport:n};e.default=a,e.serializers=a,Object.defineProperty(e,"__esModule",{value:!0})});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("babylonjs")):"function"==typeof define&&define.amd?define(["exports","babylonjs"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).BABYLON=e.BABYLON||{},e.BABYLON)}(this,function(e,t){"use strict";var n=function(){function e(){}return e.CreateSTL=function(e,n,r,o,i,a,f,s){void 0===n&&(n=!0),void 0===r&&(r="stlmesh"),void 0===o&&(o=!1),void 0===i&&(i=!0),void 0===a&&(a=!1),void 0===f&&(f=!1),void 0===s&&(s=!1);var d=function(e,n,r){var o=[3*e[r],3*e[r+1],3*e[r+2]],i=[new t.Vector3(n[o[0]],n[o[0]+2],n[o[0]+1]),new t.Vector3(n[o[1]],n[o[1]+2],n[o[1]+1]),new t.Vector3(n[o[2]],n[o[2]+2],n[o[2]+1])],a=i[0].subtract(i[1]),f=i[2].subtract(i[1]);return{v:i,n:t.Vector3.Cross(f,a).normalize()}},c=function(e,t,n,r){return t=l(e,t,n.x,r),t=l(e,t,n.y,r),l(e,t,n.z,r)},l=function(e,t,n,r){return e.setFloat32(t,n,r),t+4},v=function(e){if(f){var n=e;e instanceof t.InstancedMesh&&(n=e.sourceMesh);var r=n.getVerticesData(t.VertexBuffer.PositionKind,!0,!0);if(!r)return[];var o=t.Vector3.Zero(),i=void 0;for(i=0;i<r.length;i+=3)t.Vector3.TransformCoordinatesFromFloatsToRef(r[i],r[i+1],r[i+2],e.computeWorldMatrix(!0),o).toArray(r,i);return r}return e.getVerticesData(t.VertexBuffer.PositionKind)||[]};f&&(a=!0);var u="",p=0,m=0;if(o){for(var x=0;x<e.length;x++)p+=(w=(h=e[x]).getIndices())?w.length/3:0;var y=new ArrayBuffer(84+50*p);m+=80,(u=new DataView(y)).setUint32(m,p,i),m+=4}else s||(u="solid stlmesh\r\n");for(x=0;x<e.length;x++){var h=e[x];!o&&s&&(u+="solid "+h.name+"\r\n"),!a&&h instanceof t.Mesh&&h.bakeCurrentTransformIntoVertices();for(var b=v(h),w=h.getIndices()||[],g=0;g<w.length;g+=3){var B=d(w,b,g);o?(m=c(u,m,B.n,i),m=c(u,m,B.v[0],i),m=c(u,m,B.v[1],i),m=c(u,m,B.v[2],i),m+=2):(u+="\tfacet normal "+B.n.x+" "+B.n.y+" "+B.n.z+"\r\n",u+="\t\touter loop\r\n",u+="\t\t\tvertex "+B.v[0].x+" "+B.v[0].y+" "+B.v[0].z+"\r\n",u+="\t\t\tvertex "+B.v[1].x+" "+B.v[1].y+" "+B.v[1].z+"\r\n",u+="\t\t\tvertex "+B.v[2].x+" "+B.v[2].y+" "+B.v[2].z+"\r\n",u+="\t\tendloop\r\n",u+="\tendfacet\r\n")}!o&&s&&(u+="endsolid "+name+"\r\n")}if(o||s||(u+="endsolid stlmesh"),n){var V=document.createElement("a"),L=new Blob([u],{type:"application/octet-stream"});V.href=window.URL.createObjectURL(L),V.download=r+".stl",V.click()}return u},e}(),r={__proto__:null,STLExport:n},o="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==o)for(var i in r)o.BABYLON[i]=r[i];e.STLExport=n});
2
2
  //# sourceMappingURL=babylon.stlSerializer.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"babylon.stlSerializer.min.js","sources":["../../../../../../../dev/serializers/src/stl/stlSerializer.ts","../../../../../../../dev/serializers/src/legacy/legacy-stlSerializer.ts"],"sourcesContent":[null,null],"names":["STLExport","CreateSTL","meshes","download","fileName","binary","isLittleEndian","doNotBakeTransform","supportInstancedMeshes","exportIndividualMeshes","getFaceData","indices","vertices","i","id","v","Vector3","p1p2","subtract","p3p2","n","Cross","normalize","dataview","offset","vector","writeFloat","x","y","z","value","setFloat32","mesh","sourceMesh","InstancedMesh","data_1","getVerticesData","VertexBuffer","PositionKind","temp","Zero","index","length","TransformCoordinatesFromFloatsToRef","computeWorldMatrix","toArray","data","faceCount","getIndices","buffer","DataView","setUint32","name","Mesh","bakeCurrentTransformIntoVertices","i_1","fd","writeVector","GlobalObject","global","window","undefined","serializer","Serializers","BABYLON"],"mappings":"sSAQA,IAAAA,EAAA,WAAA,SAAAA,IAqJA,QAxIkBA,EAAAC,UAAd,SACIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,QANA,IAAAN,IACAA,GAAA,QAEA,IAAAC,IACAA,EAAA,gBAEA,IAAAC,IAIMA,WAEQ,IAAVC,IACIA,GAAY,QAEA,IAAZC,OACF,QAE2B,IAA7BC,IACAA,GAAwB,QAG1B,IAAAC,IAEIA,GAAwB,GAE1B,IAAAC,EAAS,SAAWC,EAAUC,EAAQC,GACtC,IAAAC,EAAO,CAAW,EAAXH,EAAWE,GAAyB,EAAjBF,EAAQE,EAAE,GAA0B,EAAhBF,EAAAE,EAAA,IAChDE,EAAA,CAEI,IAAAC,EAAAA,QAAaJ,EAAUE,EAAA,IAAeF,EAAgBE,EAAA,GAAe,GAAAF,EAAuBE,EAAA,GAAA,IAC9F,IAAQE,EAAAA,UAAYF,EAAQ,IAAKF,EAAEE,EAAA,GAAe,GAACF,EAAAE,EAAA,GAAA,IACnD,IAAOE,EAAAA,QAASJ,EAAEE,EAAA,IAAAF,EAAAE,EAAA,GAAA,GAAAF,EAAAE,EAAA,GAAA,KAGhBG,EAAAF,EAAA,GAAeG,SAAGH,EAAA,IAChBI,EAAAJ,EAAA,GAAAG,SAAAH,MAEA,MAAA,CAAIA,EAAIA,EAAAK,EADJJ,EAAAA,QAAAK,MAAaF,EAAKF,GAAAK,YAElB,IACH,SAAAC,EAAAC,EAAAC,EAAAnB,GAGG,OAFJkB,EAAME,EAAOH,MAA2BI,EAAArB,KACnCoB,EAAOH,EAAAC,EAAAC,EAAAG,EAAAtB,GACRoB,EAAUH,EAAAC,EAAAC,E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EAAAd,GACJkB,EAAAiC,EAAAX,EAAAtB,EAAAgC,EAAAzC,EAAA,GAAAT,GACIkB,EAAUiC,EAAAX,EAAAtB,EAAyBgC,EAAAzC,EAAA,GAAAT,GAChCkB,EAAIiC,EAAcX,IAAcU,EAAAzC,EAAA,GAAAT,GACvCkB,GAAA,IAIOsB,qBAAmBU,EAAApC,EAAAO,EAAA,IAAA6B,EAAApC,EAAAQ,EAAA,IAAA4B,EAAApC,EAAAS,EAAA,OAC9BiB,GAAA,qBAEWA,GAAG,gBAAAU,EAAAzC,EAAA,GAAAY,EAAA,IAAA6B,EAAAzC,EAAA,GAAAa,EAAA,IAAA4B,EAAAzC,EAAA,GAAAc,EAAA,OACDiB,GAAQ,gBAAkBU,EAAEzC,EAAA,GAAAY,EAAA,IAAA6B,EAAAzC,EAAA,GAAAa,EAAA,IAAA4B,EAAAzC,EAAA,GAAAc,EAAA,OAC5BiB,GAAO,gBAAmBU,EAAEzC,EAAA,GAAAY,EAAA,IAAA6B,EAAAzC,EAAA,GAAAa,EAA4B,IAAE4B,EAAAzC,EAAA,GAAAc,EAAA,OAC9DiB,GAAU,kBACdA,GAAW,iBAEhB,KAEWrC,IACfqC,GAAA,YAAAM,KAAA,OACJ,0OCtJKM,EAAiC,oBAAXC,OAAyBA,OAA2B,oBAAXC,OAAyBA,YAASC,EACvG,QAA4B,IAAjBH,EACP,IAAK,IAAMI,KAAcC,EACfL,EAAcM,QAAQF,GAAoBC,EAAaD"}
1
+ {"version":3,"file":"babylon.stlSerializer.min.js","sources":["file:///home/vsts/work/1/s/packages/dev/serializers/src/stl/stlSerializer.ts","file:///home/vsts/work/1/s/packages/dev/serializers/src/legacy/legacy-stlSerializer.ts"],"sourcesContent":["import { Mesh } from \"core/Meshes/mesh\";\r\nimport { InstancedMesh } from \"core/Meshes/instancedMesh\";\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\n\r\n/**\r\n * Class for generating STL data from a Babylon scene.\r\n */\r\nexport class STLExport {\r\n /**\r\n * Exports the geometry of a Mesh array in .STL file format (ASCII)\r\n * @param meshes list defines the mesh to serialize\r\n * @param download triggers the automatic download of the file.\r\n * @param fileName changes the downloads fileName.\r\n * @param binary changes the STL to a binary type.\r\n * @param isLittleEndian toggle for binary type exporter.\r\n * @param doNotBakeTransform toggle if meshes transforms should be baked or not.\r\n * @param supportInstancedMeshes toggle to export instanced Meshes. Enabling support for instanced meshes will override doNoBakeTransform as true\r\n * @param exportIndividualMeshes toggle to export each mesh as an independent mesh. By default, all the meshes are combined into one mesh. This property has no effect when exporting in binary format\r\n * @returns the STL as UTF8 string\r\n */\r\n public static CreateSTL(\r\n meshes: (Mesh | InstancedMesh)[],\r\n download: boolean = true,\r\n fileName: string = \"stlmesh\",\r\n binary: boolean = false,\r\n isLittleEndian: boolean = true,\r\n doNotBakeTransform: boolean = false,\r\n supportInstancedMeshes: boolean = false,\r\n exportIndividualMeshes: boolean = false\r\n ): any {\r\n //Binary support adapted from https://gist.github.com/paulkaplan/6d5f0ab2c7e8fdc68a61\r\n\r\n const getFaceData = function (indices: any, vertices: any, i: number) {\r\n const id = [indices[i] * 3, indices[i + 1] * 3, indices[i + 2] * 3];\r\n const v = [\r\n new Vector3(vertices[id[0]], vertices[id[0] + 2], vertices[id[0] + 1]),\r\n new Vector3(vertices[id[1]], vertices[id[1] + 2], vertices[id[1] + 1]),\r\n new Vector3(vertices[id[2]], vertices[id[2] + 2], vertices[id[2] + 1]),\r\n ];\r\n const p1p2 = v[0].subtract(v[1]);\r\n const p3p2 = v[2].subtract(v[1]);\r\n const n = Vector3.Cross(p3p2, p1p2).normalize();\r\n\r\n return { v, n };\r\n };\r\n\r\n const writeVector = function (dataview: any, offset: number, vector: Vector3, isLittleEndian: boolean) {\r\n offset = writeFloat(dataview, offset, vector.x, isLittleEndian);\r\n offset = writeFloat(dataview, offset, vector.y, isLittleEndian);\r\n return writeFloat(dataview, offset, vector.z, isLittleEndian);\r\n };\r\n\r\n const writeFloat = function (dataview: any, offset: number, value: number, isLittleEndian: boolean) {\r\n dataview.setFloat32(offset, value, isLittleEndian);\r\n return offset + 4;\r\n };\r\n\r\n const getVerticesData = function (mesh: InstancedMesh | Mesh) {\r\n if (supportInstancedMeshes) {\r\n let sourceMesh = mesh;\r\n if (mesh instanceof InstancedMesh) {\r\n sourceMesh = mesh.sourceMesh;\r\n }\r\n const data = sourceMesh.getVerticesData(VertexBuffer.PositionKind, true, true);\r\n if (!data) {\r\n return [];\r\n }\r\n const temp = Vector3.Zero();\r\n let index;\r\n for (index = 0; index < data.length; index += 3) {\r\n Vector3.TransformCoordinatesFromFloatsToRef(data[index], data[index + 1], data[index + 2], mesh.computeWorldMatrix(true), temp).toArray(data, index);\r\n }\r\n return data;\r\n } else {\r\n return mesh.getVerticesData(VertexBuffer.PositionKind) || [];\r\n }\r\n };\r\n\r\n if (supportInstancedMeshes) {\r\n doNotBakeTransform = true;\r\n }\r\n\r\n let data: DataView<ArrayBuffer> | string = \"\";\r\n\r\n let faceCount = 0;\r\n let offset = 0;\r\n\r\n if (binary) {\r\n for (let i = 0; i < meshes.length; i++) {\r\n const mesh = meshes[i];\r\n const indices = mesh.getIndices();\r\n faceCount += indices ? indices.length / 3 : 0;\r\n }\r\n\r\n const bufferSize = 84 + 50 * faceCount;\r\n const buffer = new ArrayBuffer(bufferSize);\r\n data = new DataView(buffer);\r\n\r\n offset += 80;\r\n data.setUint32(offset, faceCount, isLittleEndian);\r\n offset += 4;\r\n } else {\r\n if (!exportIndividualMeshes) {\r\n data = \"solid stlmesh\\r\\n\";\r\n }\r\n }\r\n\r\n for (let i = 0; i < meshes.length; i++) {\r\n const mesh = meshes[i];\r\n if (!binary && exportIndividualMeshes) {\r\n data += \"solid \" + mesh.name + \"\\r\\n\";\r\n }\r\n if (!doNotBakeTransform && mesh instanceof Mesh) {\r\n mesh.bakeCurrentTransformIntoVertices();\r\n }\r\n const vertices = getVerticesData(mesh);\r\n const indices = mesh.getIndices() || [];\r\n\r\n for (let i = 0; i < indices.length; i += 3) {\r\n const fd = getFaceData(indices, vertices, i);\r\n\r\n if (binary) {\r\n offset = writeVector(data, offset, fd.n, isLittleEndian);\r\n offset = writeVector(data, offset, fd.v[0], isLittleEndian);\r\n offset = writeVector(data, offset, fd.v[1], isLittleEndian);\r\n offset = writeVector(data, offset, fd.v[2], isLittleEndian);\r\n offset += 2;\r\n } else {\r\n data += \"\\tfacet normal \" + fd.n.x + \" \" + fd.n.y + \" \" + fd.n.z + \"\\r\\n\";\r\n data += \"\\t\\touter loop\\r\\n\";\r\n data += \"\\t\\t\\tvertex \" + fd.v[0].x + \" \" + fd.v[0].y + \" \" + fd.v[0].z + \"\\r\\n\";\r\n data += \"\\t\\t\\tvertex \" + fd.v[1].x + \" \" + fd.v[1].y + \" \" + fd.v[1].z + \"\\r\\n\";\r\n data += \"\\t\\t\\tvertex \" + fd.v[2].x + \" \" + fd.v[2].y + \" \" + fd.v[2].z + \"\\r\\n\";\r\n data += \"\\t\\tendloop\\r\\n\";\r\n data += \"\\tendfacet\\r\\n\";\r\n }\r\n }\r\n if (!binary && exportIndividualMeshes) {\r\n data += \"endsolid \" + name + \"\\r\\n\";\r\n }\r\n }\r\n\r\n if (!binary && !exportIndividualMeshes) {\r\n data += \"endsolid stlmesh\";\r\n }\r\n\r\n if (download) {\r\n const a = document.createElement(\"a\");\r\n const blob = new Blob([data], { type: \"application/octet-stream\" });\r\n a.href = window.URL.createObjectURL(blob);\r\n a.download = fileName + \".stl\";\r\n a.click();\r\n }\r\n\r\n return data;\r\n }\r\n}\r\n","/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nimport * as Serializers from \"serializers/stl/index\";\r\n\r\n/**\r\n * This is the entry point for the UMD module.\r\n * The entry point for a future ESM package should be index.ts\r\n */\r\nconst GlobalObject = typeof global !== \"undefined\" ? global : typeof window !== \"undefined\" ? window : undefined;\r\nif (typeof GlobalObject !== \"undefined\") {\r\n for (const serializer in Serializers) {\r\n (<any>GlobalObject).BABYLON[serializer] = (<any>Serializers)[serializer];\r\n }\r\n}\r\n\r\nexport * from \"serializers/stl/index\";\r\n"],"names":["STLExport","CreateSTL","meshes","download","fileName","binary","isLittleEndian","doNotBakeTransform","supportInstancedMeshes","exportIndividualMeshes","getFaceData","indices","vertices","i","id","v","Vector3","p1p2","subtract","p3p2","n","Cross","normalize","writeVector","dataview","offset","vector","writeFloat","x","y","z","value","setFloat32","getVerticesData","mesh","sourceMesh","InstancedMesh","data_1","VertexBuffer","PositionKind","temp","Zero","index","length","TransformCoordinatesFromFloatsToRef","computeWorldMatrix","toArray","data","faceCount","getIndices","buffer","ArrayBuffer","DataView","setUint32","name","Mesh","bakeCurrentTransformIntoVertices","i_1","fd","a","document","createElement","blob","Blob","type","href","window","URL","createObjectURL","click","GlobalObject","global","undefined","serializer","Serializers","BABYLON"],"mappings":"sSAQA,IAAAA,EAAA,WAAA,SAAAA,IAqJA,CAAA,OAxIkBA,EAAAC,UAAd,SACIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,QANA,IAAAN,IAAAA,GAAA,QACA,IAAAC,IAAAA,EAAA,gBACA,IAAAC,IAAAA,GAAA,QACA,IAAAC,IAAAA,GAAA,QACA,IAAAC,IAAAA,GAAA,QACA,IAAAC,IAAAA,GAAA,QACA,IAAAC,IAAAA,GAAA,GAIA,IAAMC,EAAc,SAAUC,EAAcC,EAAeC,GACvD,IAAMC,EAAK,CAAc,EAAbH,EAAQE,GAAyB,EAAjBF,EAAQE,EAAI,GAAyB,EAAjBF,EAAQE,EAAI,IACtDE,EAAI,CACN,IAAIC,EAAAA,QAAQJ,EAASE,EAAG,IAAKF,EAASE,EAAG,GAAK,GAAIF,EAASE,EAAG,GAAK,IACnE,IAAIE,EAAAA,QAAQJ,EAASE,EAAG,IAAKF,EAASE,EAAG,GAAK,GAAIF,EAASE,EAAG,GAAK,IACnE,IAAIE,EAAAA,QAAQJ,EAASE,EAAG,IAAKF,EAASE,EAAG,GAAK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EAAE,GAAGc,EAAI,IAAM6B,EAAG3C,EAAE,GAAGe,EAAI,OAC1EiB,GAAQ,kBACRA,GAAQ,iBAEhB,EACK1C,GAAUI,IACXsC,GAAQ,YAAcO,KAAO,OAErC,CAMA,GAJKjD,GAAWI,IACZsC,GAAQ,oBAGR5C,EAAU,CACV,IAAMwD,EAAIC,SAASC,cAAc,KAC3BC,EAAO,IAAIC,KAAK,CAAChB,GAAO,CAAEiB,KAAM,6BACtCL,EAAEM,KAAOC,OAAOC,IAAIC,gBAAgBN,GACpCH,EAAExD,SAAWC,EAAW,OACxBuD,EAAEU,OACN,CAEA,OAAOtB,CACX,EACJ/C,CAAA,mCCtJMsE,EAAiC,oBAAXC,OAAyBA,OAA2B,oBAAXL,OAAyBA,YAASM,EACvG,QAA4B,IAAjBF,EACP,IAAK,IAAMG,KAAcC,EACfJ,EAAcK,QAAQF,GAAoBC,EAAaD"}
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("babylonjs")):"function"==typeof define&&define.amd?define(["exports","babylonjs"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).BABYLON=t.BABYLON||{},t.BABYLON)}(this,function(t,e){"use strict";var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},n(t,e)};function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var i=function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},i.apply(this,arguments)};function o(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a}function a(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())})}function s(t,e){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function u(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}function l(t){return"string"==typeof(null==t?void 0:t.name)}"function"==typeof SuppressedError&&SuppressedError;var c=Symbol("__xml:meta$__"),p=Symbol("__xml:name$__");function h(t,e){var n,r=t.constructor;(null!==(n=r[c])&&void 0!==n?n:r[c]=[]).push(e)}function f(t){return function(e){e[p]=t}}function m(){return function(t,e){return h(t,{kind:"none",prop:e,ignore:!0})}}function d(t){return function(e,n){return h(e,i({kind:"attr",prop:n},t))}}function v(t){return function(e,n){return h(e,i({kind:"elem",prop:n},t))}}function _(t){var e,n;return null!==(n=null===(e=null==t?void 0:t.constructor)||void 0===e?void 0:e[c])&&void 0!==n?n:[]}function y(t){var e;return(null===(e=null==t?void 0:t.constructor)||void 0===e?void 0:e[p])||void 0}function g(t){return/^[A-Za-z_][A-Za-z0-9._-]*$/.test(t)}function w(t){if(l(t))return t;var e=(null!=t?t:"").trim();if(!e)return{name:""};var n=e.indexOf(":");if(-1===n)return{name:e};if(-1!==e.indexOf(":",n+1))return{name:e};var r=e.slice(0,n),i=e.slice(n+1);return g(r)&&g(i)?{ns:r,name:i}:{name:e}}function b(t,e){return e?"".concat(e,":").concat(t):t}var T=Object.freeze({eps:1e-6,maxDecimalsCap:15,trimTrailingZeros:!0,allowScientific:!1,snapNearZero:!0}),M=Object.freeze({number:T});function x(t){var e,n,r,i,o,a,s=null!==(e=null==t?void 0:t.eps)&&void 0!==e?e:T.eps;return{eps:s,maxDecimalsCap:null!==(n=null==t?void 0:t.maxDecimalsCap)&&void 0!==n?n:T.maxDecimalsCap,trimTrailingZeros:null!==(r=null==t?void 0:t.trimTrailingZeros)&&void 0!==r?r:T.trimTrailingZeros,fixedDecimals:null==t?void 0:t.fixedDecimals,allowScientific:null!==(i=null==t?void 0:t.allowScientific)&&void 0!==i?i:T.allowScientific,snapNearZero:null!==(o=null==t?void 0:t.snapNearZero)&&void 0!==o?o:T.snapNearZero,zeroThreshold:null!==(a=null==t?void 0:t.zeroThreshold)&&void 0!==a?a:s,perAttributeEps:null==t?void 0:t.perAttributeEps}}function S(t){return{number:x(null==t?void 0:t.number)}}var C=function(){function t(t){if(this.o=t,this._o=t.number,!Number.isFinite(this._o.eps)||this._o.eps<=0)throw new Error("opts.eps must be a finite, positive number")}return t.prototype.toString=function(t){var e,n,r,i;if(!Number.isFinite(t))throw new Error("Cannot format non-finite number: ".concat(t));var o,a=this._o,s=this._clampInt(null!==(e=a.maxDecimalsCap)&&void 0!==e?e:15,0,20),u=null===(n=a.trimTrailingZeros)||void 0===n||n,l=null===(r=a.snapNearZero)||void 0===r||r,c=null!==(i=a.zeroThreshold)&&void 0!==i?i:a.eps,p=1/a.eps,h=Math.round(t*p)/p;if(Object.is(h,-0)&&(h=0),l&&Math.abs(h)<=c&&(h=0),o=void 0!==a.fixedDecimals?this._clampInt(a.fixedDecimals,0,s):this._clampInt(Math.ceil(-Math.log10(a.eps)),0,s),a.allowScientific,0===o)return String(Math.trunc(h));var f=h.toFixed(o);if(u&&void 0===a.fixedDecimals&&(f=f.replace(/(\.\d*?[1-9])0+$/,"$1").replace(/\.0+$/,"").replace(/\.$/,"")),/[eE]/.test(f))throw new Error("Scientific notation not allowed in XML output: ".concat(f));return f},t.prototype._clampInt=function(t,e,n){return Number.isFinite(t)?(t=Math.trunc(t),Math.max(e,Math.min(n,t))):e},t}();function N(t){return t instanceof Date}function j(t){return"string"==typeof t}function O(t){return"number"==typeof t}function k(t){return"string"==typeof t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t||N(t)}function D(t){return"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t||N(t)}var A,X=function(){function t(t,e){this._ns=new Map,this._prefixCount=0,this._builder=t,this._format=S(e),this._nFmt=new C(this._format)}return t.prototype.withNamespace=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=0,r=t;n<r.length;n++){var i=r[n];this._assignNamespace(i)}return this},t.prototype.serialize=function(t,e){if(!(e=null!=e?e:y(t)))throw new Error("can not find name for given object");var n=w(e);n.ns&&this._assignNamespace(n.ns,"xmlns"),this._gatherNamespaces(t,new WeakSet);for(var r=this._builder.ele(null,n.name),i=0,o=Array.from(this._ns.entries());i<o.length;i++){var a=o[i],s=a[0],u=a[1];r.att("xmlns",u,s)}this._writeObjectContent(r,t,(new WeakSet).add(t)),this._builder.end()},t.prototype._writeObject=function(t,e,n){if(!n.has(e))if(n.add(e),Array.isArray(e))for(var r=0,i=e;r<i.length;r++){var o=i[r];D(o)||(j(o)?this._builder.text(o):this._writeObject(t,o,n))}else{var a=y(e);if(a){var s=w(a),u=this._getPrefix(s),l=b(s.name,u);t.ele(null,l),this._writeObjectContent(t,e,n),this._builder.end()}}},t.prototype._getPrefix=function(t){if(t.ns){var e=this._ns.get(t.ns.toLowerCase());if("xmlns"!==e)return e}},t.prototype._writeObjectContent=function(t,e,n){for(var r,i,o,a=null!==(r=_(e))&&void 0!==r?r:[],s=new Map,u=0,l=a;u<l.length;u++){var c=l[u],p=null!==(i=s.get(c.prop))&&void 0!==i?i:[];p.push(c),s.set(c.prop,p)}for(var h=Object.keys(e).sort(function(t,e){var n,r,i=(null!==(n=s.get(t))&&void 0!==n?n:[]).some(function(t){return"attr"===t.kind}),o=(null!==(r=s.get(e))&&void 0!==r?r:[]).some(function(t){return"attr"===t.kind});return i===o?0:i?-1:1}),f=0,m=h;f<m.length;f++){var d=m[f],v=e[d];if(null!=v){var y=s.get(d);if(y){var g=y.some(function(t){return!0===t.ignore||"none"===t.kind});if(g)continue;for(var T=0,M=y;T<M.length;T++){var x=null!==(o=(c=M[T]).name)&&void 0!==o?o:c.prop.toLowerCase();if(x&&"attr"===c.kind){var S=null;if(O(v)&&this._nFmt&&(S=this._nFmt.toString(v)),c.formatter&&(S=new c.formatter(this._format).toString(v)),S=null!=S?S:v.toString()){var C=w(x),N=this._getPrefix(C),k=b(C.name,N);t.att(null,k,S)}}}}else D(v)||(j(v)?this._builder.text(v):this._writeObject(t,v,n))}}},t.prototype._gatherNamespaces=function(t,e){var n,r;if(!e.has(t))if(e.add(t),Array.isArray(t))for(var i=0,o=t;i<o.length;i++){var a=o[i];k(a)||this._gatherNamespaces(a,e)}else{var s=y(t);s&&this._assignNamespace(s);for(var u=null!==(n=_(t))&&void 0!==n?n:[],l=new Map,c=0,p=u;c<p.length;c++){var h=p[c],f=null!==(r=l.get(h.prop))&&void 0!==r?r:[];f.push(h),l.set(h.prop,f)}for(var m=[],d=0,v=Object.keys(t);d<v.length;d++){var g=v[d],w=t[g];if(null!=w){var b=l.get(g);if(b){var T=b.some(function(t){return!0===t.ignore||"none"===t.kind});if(T)continue;for(var M=0,x=b;M<x.length;M++)(h=x[M]).name&&this._assignNamespace(h.name)}m.push(w)}}for(var S=0,C=m;S<C.length;S++){var N=C[S];k(N)||this._gatherNamespaces(N,e)}}},t.prototype._assignNamespace=function(t,e){var n=w(t);if(null==n?void 0:n.ns){var r=n.ns.toLowerCase();this._ns.get(r)||this._ns.set(r,null!=e?e:this._buildNsPrefix(r))}else"xmlns"===e&&(r=n.name.toLowerCase(),this._ns.get(r)||this._ns.set(r,null!=e?e:this._buildNsPrefix(r)))},t.prototype._buildNsPrefix=function(t){var e,n=!1;do{e="ns".concat(this._prefixCount++);for(var r=0,i=Array.from(this._ns.values());r<i.length;r++)if(i[r]===e){n=!0;break}}while(n);return e},t}(),R=function(){function t(){}return t.OpenTag="<",t.CloseTag=">",t.Slash="/",t.Question="?",t.Quote='"',t.Equal="=",t.Space=" ",t.Semicolon=":",t.Dec="<?xml",t.Xml="xml",t.Xmlns="xmlns",t.Xsi="xsi",t.VersionKeyword="version",t.EncodingKeyword="encoding",t.StandaloneKeyword="standalone",t}();!function(t){t[t.Declaration=0]="Declaration",t[t.Tag=1]="Tag",t[t.Attribute=2]="Attribute",t[t.Text=3]="Text"}(A||(A={}));var B,P,E=function(){function t(t){this._ctxStack=[],this._d=0,this._w=t}return t.prototype.dec=function(t,e,n){return this._w.write(R.Dec),this._writeAttStr(R.VersionKeyword,t),e&&this._writeAttStr(R.EncodingKeyword,e),void 0!==n&&this._writeAttStr(R.StandaloneKeyword,n?"yes":"no"),this._w.write(R.Question,R.CloseTag),this},t.prototype.att=function(t,e,n){var r=this._peekContext();if(!r)throw new Error("att() without open element");if(r.closed)throw new Error("att() after start tag closed for <".concat(r.name,">"));if(this._isXmlnsDecl(t,e)){if(e===R.Xmlns)r.defaultNs=n,this._registerNamespace(r,"",n),this._writeAttStr(R.Xmlns,n);else if(t)this._registerNamespace(r,e,n),this._writeAttStr("".concat(t,":").concat(e),n);else{var i=e.slice(6);this._registerNamespace(r,i,n),this._writeAttStr(e,n)}return r.lastToken=A.Attribute,this}var o=e;if(t){var a=this._ensurePrefixDeclared(r,t);o="".concat(a,":").concat(e)}return r.lastToken=A.Attribute,this._writeAttStr(o,n),this},t.prototype.ele=function(t,e){var n,r=this._peekContext();r&&this._closeOpenTagIfNeeded(r);var i=e;if(t){var o=null!==(n=this._lookupPrefix(t))&&void 0!==n?n:t;i="".concat(o,":").concat(e)}return this._pushContext(i,++this._d),this._w.write(R.OpenTag,i),this},t.prototype.text=function(t){var e=this._peekContext();if(!e)throw new Error("text() without open element");return this._closeOpenTagIfNeeded(e),e.lastToken=A.Text,this._w.write(this._escText(t)),this},t.prototype.end=function(){var t=this._popContext();return t&&(this._d--,t.closed?this._w.write(R.OpenTag,R.Slash,t.name,R.CloseTag):this._w.write(R.Slash,R.CloseTag)),this},t.prototype._pushContext=function(e,n){var r=new t.Context(e,n);return this._ctxStack.push(r),r},t.prototype._popContext=function(){return this._ctxStack.pop()},t.prototype._peekContext=function(){return this._ctxStack[this._ctxStack.length-1]},Object.defineProperty(t.prototype,"_contextDepth",{get:function(){return this._ctxStack.length},enumerable:!1,configurable:!0}),t.prototype._writeAttStr=function(t,e){this._w.write(R.Space,t,R.Equal,R.Quote,this._escAttr(e),R.Quote)},t.prototype._lookupPrefix=function(t){var e,n=this._ctxStack.length-1;if(n>=0)do{var r=null===(e=this._ctxStack[n--].ns2prefix)||void 0===e?void 0:e.get(t);if(r)return r}while(n>=0)},t.prototype._escText=function(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},t.prototype._escAttr=function(t){return this._escText(t).replace(/"/g,"&quot;").replace(/'/g,"&apos;")},t.prototype._isXmlnsDecl=function(t,e){if(t)return t===R.Xmlns;var n=e.length,r=R.Xmlns.length;return n>=r&&e.startsWith(R.Xmlns)&&(e.length==r||e[r]==R.Semicolon)},t.prototype._registerNamespace=function(t,e,n){if(e===R.Xml||e===R.Xmlns)throw new Error("reserved prefix '".concat(e,"'"));var r=t.prefix2ns.get(e);if(r&&r!==n)throw new Error("prefix '".concat(e,"' already bound to a different namespace"));t.ns2prefix.get(n)||t.ns2prefix.set(n,e),t.prefix2ns.set(e,n)},t.prototype._allocPrefix=function(t){for(var e=1;;){var n="ns".concat(e++);if(!t.prefix2ns.has(n))return n}},t.prototype._ensurePrefixDeclared=function(t,e){var n=this._lookupPrefix(e);if(n)return n;if(t.closed)throw new Error("can not declare namespace after start tag closed for <".concat(t.name,">"));var r=this._allocPrefix(t);return this._writeAttStr("".concat(R.Xmlns,":").concat(r),e),this._registerNamespace(t,r,e),r},t.prototype._closeOpenTagIfNeeded=function(t){t.closed||(this._w.write(R.CloseTag),t.closed=!0)},t.Context=function(t,e){this.name="",this.closed=!1,this.lastToken=null,this.ns2prefix=new Map,this.prefix2ns=new Map,this.defaultNs=null,this.name=t,this.depth=e},t}(),F=function(){function t(){this.count=0,this._chunks=[]}return t.prototype.write=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(0===t.length)return this;var n=t.join("");return this._chunks.push(n),this.count+=n.length,this},t.prototype.toString=function(){return this._chunks.join("")},t.prototype.clear=function(){this._chunks=[],this.count=0},t}(),I=function(){function t(t,e){void 0===e&&(e={}),this._sink=t,this._opts=e,this.count=0,this._encoder=new TextEncoder,this._pending="",this._pendingChars=0}return t.prototype.write=function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(0===e.length)return this;var r=e.join("");if(0===r.length)return this;this._pending+=r,this._pendingChars+=r.length;var i=null!==(t=this._opts.flushChars)&&void 0!==t?t:65536;return this._pendingChars>=i&&this.flush(),this},t.prototype.flush=function(){if(0===this._pendingChars)return this;var t=this._encoder.encode(this._pending);return this._sink.push(t),this.count+=t.length,this._pending="",this._pendingChars=0,this},t.prototype.finish=function(){this.flush(),this._sink.push(new Uint8Array(0),!0)},t.prototype.clear=function(){this._pending="",this._pendingChars=0,this.count=0},t}(),z="http://schemas.microsoft.com/3dmanufacturing/core/2015/02",Z="http://schemas.microsoft.com/3dmanufacturing/trianglesets/2021/07";!function(t){t.micron="micron",t.millimeter="millimeter",t.centimeter="centimeter",t.inch="inch",t.foot="foot",t.meter="meter"}(B||(B={})),function(t){t.model="model",t.solidsupport="solidsupport",t.support="support",t.surface="surface",t.other="other"}(P||(P={}));var L,K="http://schemas.openxmlformats.org/package/2006/content-types",U="http://schemas.openxmlformats.org/package/2006/relationships";!function(t){t.Relationships="application/vnd.openxmlformats-package.relationships+xml",t.Model="application/vnd.ms-package.3dmanufacturing-3dmodel+xml",t.Materials="application/vnd.ms-package.3dmanufacturing-material+xml",t.Colors="application/vnd.ms-package.3dmanufacturing-colors+xml",t.Texture="application/vnd.ms-package.3dmanufacturing-texture+xml",t.Texture2D="application/vnd.ms-package.3dmanufacturing-texture2d+xml",t.Production="application/vnd.ms-package.3dmanufacturing-production+xml",t.Slice="application/vnd.ms-package.3dmanufacturing-slice+xml",t.BeamLattice="application/vnd.ms-package.3dmanufacturing-beamlattice+xml",t.SecureContent="application/vnd.ms-package.3dmanufacturing-securecontent+xml",t.Png="image/png",t.Jpeg="image/jpeg",t.Tiff="image/tiff",t.Xml="application/xml"}(L||(L={}));var G="_rels/",Q="3D/",V="3dmodel.model",W=".rels",$="[Content_Types].xml",q=function(){function t(){}return t.IsKnown=function(e){return t.Known.has(e)},t.IsThreeDimModel=function(e){return e===t.ThreeDimModel},t.ThreeDimModel="http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel",t.Thumbnail="http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail",t.PrintTicket="http://schemas.microsoft.com/3dmanufacturing/2013/01/printticket",t.MustPreserve="http://schemas.openxmlformats.org/package/2006/relationships/mustpreserve",t.Known=new Set([t.ThreeDimModel,t.Thumbnail,t.PrintTicket,t.MustPreserve]),t}(),H=function(){function t(){this.items=[]}return o([f({ns:K,name:"Types"})],t)}(),Y=function(){function t(t,e){this.ext=t,this.ct=e}return o([d({name:{ns:K,name:"Extension"}})],t.prototype,"ext",void 0),o([d({name:{ns:K,name:"ContentType"}})],t.prototype,"ct",void 0),o([f({ns:K,name:"Default"})],t)}(),J=function(){function t(){this.items=[]}return o([f({ns:U,name:"Relationships"})],t)}(),tt=function(){function t(t,e,n){this.id=t,this.type=e,this.target=n}return o([d({name:"Id"})],t.prototype,"id",void 0),o([d({name:"Type"})],t.prototype,"type",void 0),o([d({name:"Target"})],t.prototype,"target",void 0),o([f({ns:U,name:"Relationship"})],t)}(),et=function(t,e,n){this.contentTypes=t,this.relationships=e,this.model=n},nt=function(){function t(t){this.values=t}return t.Zero=function(){return new t([0,0,0,0,0,0,0,0,0,0,0,0])},t.prototype.toString=function(){return this.values.join(" ")},t}(),rt=function(){function t(t){this.o=t,this._f=new C(t)}return t.prototype.toString=function(t){var e=this;return t.values.map(function(t){return e._f.toString(t)}).join(" ")},t}(),it=function(){function t(){this.unit=B.millimeter}return t.KnownMeta=["Title","Designer","Description","Copyright","LicenseTerms","Rating","CreationDate","ModificationDate","Application"],o([d({name:"unit"})],t.prototype,"unit",void 0),o([d({name:"requiredextensions"})],t.prototype,"requiredextensions",void 0),o([d({name:"recommendedextensions"})],t.prototype,"recommendedextensions",void 0),o([f({ns:z,name:"model"})],t)}(),ot=function(){function t(t,e,n,r){this.name=t,this.value=e,this.preserve=n,this.type=r}return o([d({name:"name"})],t.prototype,"name",void 0),o([d({name:"preserve"})],t.prototype,"preserve",void 0),o([d({name:"type"})],t.prototype,"type",void 0),o([f({ns:z,name:"meta"})],t)}(),at=function(){function t(){this.metadata=[]}return o([f({ns:z,name:"metadatagroup"})],t)}(),st=function(){function t(){this.object=[]}return o([f({ns:z,name:"resources"})],t)}(),ut=function(){function t(t,e){void 0===e&&(e=P.model),this.id=t,this.type=e}return o([d({name:"id"})],t.prototype,"id",void 0),o([d({name:"type"})],t.prototype,"type",void 0),o([d({name:"thumbnail"})],t.prototype,"thumbnail",void 0),o([d({name:"partnumber"})],t.prototype,"partnumber",void 0),o([d({name:"name"})],t.prototype,"name",void 0),o([d({name:"pid"})],t.prototype,"pid",void 0),o([d({name:"pindex"})],t.prototype,"pindex",void 0),o([f({ns:z,name:"object"})],t)}(),lt=function(){function t(t,e){this.vertices=null!=t?t:new ct,this.triangles=null!=e?e:new ht}return o([f({ns:z,name:"mesh"})],t)}(),ct=function(){function t(){this.vertex=[]}return o([f({ns:z,name:"vertices"})],t)}(),pt=function(){function t(t,e,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),this.x=t,this.y=e,this.z=n}return o([d({name:"x"})],t.prototype,"x",void 0),o([d({name:"y"})],t.prototype,"y",void 0),o([d({name:"z"})],t.prototype,"z",void 0),o([f({ns:z,name:"vertex"})],t)}(),ht=function(){function t(){this.triangle=[]}return o([f({ns:z,name:"triangles"})],t)}(),ft=function(){function t(t,e,n){this.v1=t,this.v2=e,this.v3=n}return o([d({name:"v1"})],t.prototype,"v1",void 0),o([d({name:"v2"})],t.prototype,"v2",void 0),o([d({name:"v3"})],t.prototype,"v3",void 0),o([d({name:"p1"})],t.prototype,"p1",void 0),o([d({name:"p2"})],t.prototype,"p2",void 0),o([d({name:"p3"})],t.prototype,"p3",void 0),o([d({name:"pid"})],t.prototype,"pid",void 0),o([f({ns:z,name:"triangle"})],t)}(),mt=function(){function t(){this.component=[]}return o([f({ns:z,name:"components"})],t)}(),dt=function(){function t(t,e){this.objectid=t,this.transform=e}return o([d({name:"objectid"})],t.prototype,"objectid",void 0),o([d({name:"transform",formatter:rt})],t.prototype,"transform",void 0),o([f({ns:z,name:"component"})],t)}(),vt=function(){function t(t){this.base=[],this.id=t}return o([d({name:"id"})],t.prototype,"id",void 0),o([f({ns:z,name:"basematerials"})],t)}(),_t=function(){function t(t,e){this.name=t,this.displaycolor=e}return o([d({name:"name"})],t.prototype,"name",void 0),o([d({name:"displaycolor"})],t.prototype,"displaycolor",void 0),o([f({ns:z,name:"base"})],t)}(),yt=function(){function t(){this.item=[]}return o([f({ns:z,name:"build"})],t)}(),gt=function(){function t(t,e,n){this.objectid=t,this.transform=e,this.partnumber=n}return o([d({name:"objectid"})],t.prototype,"objectid",void 0),o([d({name:"transform",formatter:rt})],t.prototype,"transform",void 0),o([d({name:"partnumber"})],t.prototype,"partnumber",void 0),o([f({ns:z,name:"item"})],t)}(),wt=function(){function t(t,e){this._object=new ut(t,e)}return t.prototype.withName=function(t){return this._object.name=t,this},t.prototype.withThumbnail=function(t){return this._object.thumbnail=t,this},t.prototype.withProperty=function(t,e){return void 0===e&&(e=0),this._object.pid=t,this._object.id=e,this},t.prototype.build=function(){return this._object},t.prototype.reset=function(t,e){this._object=new ut(t,e)},t}(),bt=function(t){function e(e,n){void 0===n&&(n=P.model);var r=t.call(this,e,n)||this;return r._object.content=new mt,r}return r(e,t),e.prototype.withComponent=function(t,e){return this._object.content.component.push(new dt(t,e)),this},e}(wt),Tt=function(t){function e(e){return t.call(this,e,P.model)||this}return r(e,t),e.prototype.withPostProcessHandlers=function(t,e){return this._vh=t,this._th=e,this},e.prototype.withData=function(t){return this._object.content=this._buildMesh(t),this},e.prototype.withMaterial=function(t,e){return this._object.pid=t,this._object.pindex=e,this},e.prototype._buildMesh=function(t){var e=this._buildVertices(t.positions),n=this._buildTriangle(t.indices);return new lt(e,n)},e.prototype._buildVertices=function(t){var e=new ct;if(t)for(var n=0;n<t.length;){var r=t[n++],i=t[n++],o=t[n++],a=new pt(r,i,o);this._vh&&(a=this._vh(a)),e.vertex.push(a)}return e},e.prototype._buildTriangle=function(t){var e=new ht;if(t)for(var n=0;n<t.length;){var r=t[n++],i=t[n++],o=t[n++],a=new ft(r,i,o);this._th&&(a=this._th(a)),e.triangle.push(a)}return e},e}(wt),Mt=function(){function t(t){this._m=new vt(t)}return t.prototype.withColor=function(t,e){var n;this._m.base=null!==(n=this._m.base)&&void 0!==n?n:[];var r=this._m.base.find(function(e){return e.name.toLowerCase()===t.toLowerCase()});return r?(r.displaycolor=this._rgbaToHex(e),this):(r=new _t(t,this._rgbaToHex(e)),this._m.base.push(r),this)},t.prototype.build=function(){return this._m},t.prototype._rgbaToHex=function(t){var e=function(t){return Math.round(Math.min(255,Math.max(0,255*Math.pow(t,1/2.2))))},n=e(t.r).toString(16).padStart(2,"0").toUpperCase(),r=e(t.g).toString(16).padStart(2,"0").toUpperCase(),i=e(t.b).toString(16).padStart(2,"0").toUpperCase();if("number"==typeof t.a){var o=Math.round(Math.min(255,Math.max(0,255*t.a))).toString(16).padStart(2,"0").toUpperCase();return"#".concat(n).concat(r).concat(i).concat(o)}return"#".concat(n).concat(r).concat(i)},t}(),xt=function(){function t(){this._model=new it,this._objects=new Map}return t.prototype.withMetaData=function(t,e,n,r){return this._model.metadata||(this._model.metadata=new Array),this._model.metadata.push(new ot(t,e,n,r)),this},t.prototype.withMaterial=function(t){var e,n;return t instanceof Mt&&(t=t.build()),t&&(this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new st,this._model.resources.basematerials=null!==(n=this._model.resources.basematerials)&&void 0!==n?n:[],this._model.resources.basematerials.push(t)),this},t.prototype.withMesh=function(t){var e;return t instanceof Tt&&(t=t.build()),this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new st,this._model.resources.object.push(t),this},t.prototype.withComponents=function(t){var e;return t instanceof bt&&(t=t.build()),this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new st,this._model.resources.object.push(t),this},t.prototype.withBuild=function(t,e,n){var r,i;return this._model.build=null!==(r=this._model.build)&&void 0!==r?r:new yt,null===(i=this._model.build.item)||void 0===i||i.push(new gt(t,e,n)),this},t.prototype.withUnit=function(t){return this._model.unit=t,this},t.prototype.reset=function(){return this._model=new it,this._objects=new Map,this},t.prototype.build=function(){var t,e,n,r;if(!(null===(e=null===(t=this._model.resources)||void 0===t?void 0:t.object)||void 0===e?void 0:e.length))throw new Error("Invalid state: resources MUST be defined ");if(!(null===(r=null===(n=this._model.build)||void 0===n?void 0:n.item)||void 0===r?void 0:r.length))throw new Error("Invalid state: Build MUST be defined ");return this._model},t.KnownMetaSet=new Set(it.KnownMeta.map(function(t){return t.toLowerCase()})),t}(),St=function(){function t(){}return t.prototype.withContentType=function(t){this._cts||(this._cts=new H);var e=this._cts.items;return e.some(function(e){return e.ext===t.ext&&e.ct===t.ct})||e.push(t),this},t.prototype.withRelationship=function(t){this._rs||(this._rs=new J);var e=this._rs.items;return e.some(function(e){return e.id===t.id})||e.push(t),this.withContentType(new Y("rels",L.Relationships)),this},t.prototype.withModel=function(t){return t instanceof xt&&(t=t.build()),this._m=t,this.withContentType(new Y("model",L.Model)),this},t.prototype.build=function(){if(!this._m)throw new Error("Invalid state: you Must provide at least a model.");var t="".concat(Q).concat(V);if(!this._rs){var e="/".concat(t);this.withRelationship(new tt("rel".concat(0),q.ThreeDimModel,e))}return new et(this._cts,this._rs,this._m)},t}(),Ct=function(){function t(t){this._o=t}return Object.defineProperty(t.prototype,"options",{get:function(){return this._o},enumerable:!1,configurable:!0}),t.prototype.serializeAsync=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return a(this,void 0,void 0,function(){var n,r,i,o,a,u,l;return s(this,function(s){switch(s.label){case 0:return[4,this.ensureZipLibReadyAsync()];case 1:if(!(n=s.sent()))return[2];if(r=n.Zip,i=n.ZipDeflate,!r||!i)throw new Error("fflate Zip / ZipDeflate not available");return o=function(t){return{push:function(e,n){return t.push(e,n)}}},a=function(t,e,n){var r=new i(e,{level:6});t.add(r);var a=o(r),s=new I(a),u=new E(s).dec("1.0","UTF-8");new X(u).serialize(n),s.finish()},(u=this.toDocument.apply(this,e))?(l=new r(t),a(l,$,u.contentTypes),a(l,"".concat(G).concat(W),u.relationships),a(l,"".concat(Q).concat(V),u.model),l.end(),[2]):[2]}})})},t.prototype.toDocument=function(){for(var t,e,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var i=(new xt).withUnit(null!==(e=null===(t=this._o)||void 0===t?void 0:t.unit)&&void 0!==e?e:B.millimeter);if(this.options.metadata)for(var o in this.options.metadata)i.withMetaData(o,this.options.metadata[o]);return(new St).withModel(this.toModel.apply(this,u([i],n,!1))).build()},t}(),Nt=function(){function t(){}return t.SerializeToMemoryAsync=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return a(this,void 0,void 0,function(){var n,r,i,o,a,l,c,p;return s(this,function(s){switch(s.label){case 0:return n=new Array,r=0,i=function(t,e,i){n.push(e),r+=e.length},[4,t.serializeAsync.apply(t,u([i],e,!1))];case 1:if(s.sent(),!r)return[2,void 0];for(o=new Uint8Array(r),a=0,l=0,c=n;l<c.length;l++)p=c[l],o.set(p,a),a+=p.length;return[2,o]}})})},t}(),jt=function(){function t(){}return t.FFLATEUrl="https://unpkg.com/fflate@0.8.2",t}(),Ot=function(){function t(t,e,n){void 0===t&&(t=0),void 0===e&&(e=Number.MIN_SAFE_INTEGER),void 0===n&&(n=1),this._from=t,this._to=e,this._step=n,this._i=t}return t.prototype.next=function(){if(this._i<this._to)throw new Error("ST_ResourceID out of bound");var t=this._i;return this._i+=this._step,t},t.prototype.reset=function(){return this._i=this._from,this},t}(),kt=function(t){function n(e){return void 0===e&&(e={}),t.call(this,i(i({},n.DefaultOptions),e))||this}return r(n,t),n.prototype.toModel=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];n=n.filter(function(t){return t instanceof e.Mesh||t instanceof e.InstancedMesh});for(var i=new Ot,o=t,a=new Map,s=this.options.exportInstances?[]:null,u=0;u<n.length;u++){var l=n[u];if(l instanceof e.InstancedMesh)null==s||s.push(l);else{var c=l.name||"mesh".concat(u),p=l.getWorldMatrix(),h=this._handleBabylonTo3mfMatrixTransformToRef(p,nt.Zero());if(void 0!==(S=l.subMeshes))for(var f=1==S.length,m=0;m<S.length;m++){var d=S[m],v=this._extractSubMesh(l,d);if(v){var _=f?"".concat(c):"".concat(c,"_").concat(m),y=new Tt(i.next()).withData(v).withName(_).build();o.withMesh(y),o.withBuild(y.id,h),a.set(d,y)}}}}if(s&&s.length)for(var g=this._groupBy(s,function(t){return t.sourceMesh}),w=0,b=Array.from(g.entries());w<b.length;w++){var T=b[w],M=T[0],x=T[1];if(x&&x.length)for(u=0;u<x.length;u++){p=x[u].getWorldMatrix();var S=M.subMeshes;for(m=0;m<S.length;m++){d=S[m];var C=a.get(d);C&&o.withBuild(C.id,this._handleBabylonTo3mfMatrixTransformToRef(p,nt.Zero()))}}}return o.build()},n.prototype.ensureZipLibReadyAsync=function(){return a(this,void 0,void 0,function(){var t=this;return s(this,function(n){switch(n.label){case 0:return this._fflateReadyPromise?[4,this._fflateReadyPromise]:[3,2];case 1:case 3:return[2,n.sent()];case 2:return this._fflateReadyPromise=a(t,void 0,void 0,function(){var t;return s(this,function(n){switch(n.label){case 0:return(t=globalThis).fflate?[3,2]:[4,e.Tools.LoadScriptAsync(jt.FFLATEUrl)];case 1:n.sent(),n.label=2;case 2:return[2,t.fflate]}})}),[4,this._fflateReadyPromise]}})})},n.prototype._extractSubMesh=function(t,e){var r=t.getIndices();if(r){var i=t.getVerticesData(n._PositionKind);if(i){if(0==e.indexStart&&e.indexCount==r.length)return{positions:i,indices:r};for(var o=e.indexStart,a=new Map,s=[],u=new Uint32Array(e.indexCount),l=0;l<e.indexCount;l++){var c=r[o+l],p=a.get(c);if(void 0===p){p=a.size,a.set(c,p);var h=3*c;s.push(i[h],i[h+1],i[h+2])}u[l]=p}return{positions:new Float32Array(s),indices:u}}}},n.prototype._groupBy=function(t,e){for(var n=new Map,r=0,i=t;r<i.length;r++){var o=i[r],a=e(o),s=n.get(a);s?s.push(o):n.set(a,[o])}return n},n.prototype._handleBabylonTo3mfMatrixTransformToRef=function(t,r){var i=t.multiplyToRef(n._R_BJS_TO_3MF,e.Matrix.Zero()).m;return r.values=[i[0],i[1],i[2],i[4],i[5],i[6],i[8],i[9],i[10],i[12],i[13],i[14]],r},n.DefaultOptions={unit:B.meter,exportInstances:!1},n._PositionKind="position",n._R_BJS_TO_3MF=e.Matrix.RotationX(Math.PI/2).multiply(e.Matrix.Scaling(1,-1,1)),n}(Ct),Dt={__proto__:null,AbstractThreeMfSerializer:Ct,ContentTypeFileName:$,DefaultXmlSerializerFormatOptions:M,DefaultXmlSerializerNumberOptions:T,GetXmlFieldMeta:_,GetXmlName:y,IsQualifiedName:l,Known3mfRelationshipTypes:q,get KnownI3mfContentType(){return L},Matrix3d:nt,MatrixFormatter:rt,ModelFileName:V,NumberFormatter:C,Object3dDirName:Q,OpenXmlContentTypesNamespace:K,OpenXmlRelationshipsNamespace:U,RelationshipDirName:G,RelationshipFileName:W,ResolveFormatOptions:S,ResolveNumberOptions:x,get ST_ObjectType(){return P},get ST_Unit(){return B},StringXmlWriter:F,ThreeDimModelNamespace:z,ThreeMf:Nt,ThreeMfBase:_t,ThreeMfBaseMaterials:vt,ThreeMfBuild:yt,ThreeMfComponent:dt,ThreeMfComponents:mt,ThreeMfComponentsBuilder:bt,ThreeMfContentType:Y,ThreeMfContentTypes:H,ThreeMfDocument:et,ThreeMfDocumentBuilder:St,ThreeMfItem:gt,ThreeMfMaterialBuilder:Mt,ThreeMfMesh:lt,ThreeMfMeshBuilder:Tt,ThreeMfMeta:ot,ThreeMfMetadataGroup:at,ThreeMfModel:it,ThreeMfModelBuilder:xt,ThreeMfObject:ut,ThreeMfObjectBuilder:wt,ThreeMfRelationship:tt,ThreeMfRelationships:J,ThreeMfResources:st,ThreeMfSerializer:kt,ThreeMfSerializerGlobalConfiguration:jt,ThreeMfTriangle:ft,ThreeMfTriangles:ht,ThreeMfVertex:pt,ThreeMfVertices:ct,ToQualifiedString:b,get TokenType(){return A},TriangleSetsNamespace:Z,Utf8XmlWriterToBytes:I,XmlAttr:d,XmlBuilder:E,XmlElem:v,XmlIgnore:m,XmlName:f,XmlNameToParts:w,XmlSerializer:X},At="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==At){var Xt=[];for(var Rt in Dt)Xt.indexOf(Rt)>-1||(At.BABYLON[Rt]=Dt[Rt],Xt.push(Rt))}var Bt={__proto__:null,AbstractThreeMfSerializer:Ct,ContentTypeFileName:$,DefaultXmlSerializerFormatOptions:M,DefaultXmlSerializerNumberOptions:T,GetXmlFieldMeta:_,GetXmlName:y,IsQualifiedName:l,Known3mfRelationshipTypes:q,get KnownI3mfContentType(){return L},Matrix3d:nt,MatrixFormatter:rt,ModelFileName:V,NumberFormatter:C,Object3dDirName:Q,OpenXmlContentTypesNamespace:K,OpenXmlRelationshipsNamespace:U,RelationshipDirName:G,RelationshipFileName:W,ResolveFormatOptions:S,ResolveNumberOptions:x,get ST_ObjectType(){return P},get ST_Unit(){return B},StringXmlWriter:F,ThreeDimModelNamespace:z,ThreeMf:Nt,ThreeMfBase:_t,ThreeMfBaseMaterials:vt,ThreeMfBuild:yt,ThreeMfComponent:dt,ThreeMfComponents:mt,ThreeMfComponentsBuilder:bt,ThreeMfContentType:Y,ThreeMfContentTypes:H,ThreeMfDocument:et,ThreeMfDocumentBuilder:St,ThreeMfItem:gt,ThreeMfMaterialBuilder:Mt,ThreeMfMesh:lt,ThreeMfMeshBuilder:Tt,ThreeMfMeta:ot,ThreeMfMetadataGroup:at,ThreeMfModel:it,ThreeMfModelBuilder:xt,ThreeMfObject:ut,ThreeMfObjectBuilder:wt,ThreeMfRelationship:tt,ThreeMfRelationships:J,ThreeMfResources:st,ThreeMfSerializer:kt,ThreeMfSerializerGlobalConfiguration:jt,ThreeMfTriangle:ft,ThreeMfTriangles:ht,ThreeMfVertex:pt,ThreeMfVertices:ct,ToQualifiedString:b,get TokenType(){return A},TriangleSetsNamespace:Z,Utf8XmlWriterToBytes:I,XmlAttr:d,XmlBuilder:E,XmlElem:v,XmlIgnore:m,XmlName:f,XmlNameToParts:w,XmlSerializer:X};t.default=Bt,t.serializers=Bt,Object.defineProperty(t,"__esModule",{value:!0})});
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("babylonjs")):"function"==typeof define&&define.amd?define(["exports","babylonjs"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).BABYLON=t.BABYLON||{},t.BABYLON)}(this,function(t,e){"use strict";var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},n(t,e)};function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var i=function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},i.apply(this,arguments)};function o(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a}function a(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())})}function s(t,e){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function u(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}function l(t){return"string"==typeof(null==t?void 0:t.name)}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var c=Symbol("__xml:meta$__"),p=Symbol("__xml:name$__");function h(t,e){var n,r=t.constructor;(null!==(n=r[c])&&void 0!==n?n:r[c]=[]).push(e)}function f(t){return function(e){e[p]=t}}function m(){return function(t,e){return h(t,{kind:"none",prop:e,ignore:!0})}}function d(t){return function(e,n){return h(e,i({kind:"attr",prop:n},t))}}function v(t){return function(e,n){return h(e,i({kind:"elem",prop:n},t))}}function _(t){var e,n;return null!==(n=null===(e=null==t?void 0:t.constructor)||void 0===e?void 0:e[c])&&void 0!==n?n:[]}function y(t){var e;return(null===(e=null==t?void 0:t.constructor)||void 0===e?void 0:e[p])||void 0}function g(t){return/^[A-Za-z_][A-Za-z0-9._-]*$/.test(t)}function T(t){if(l(t))return t;var e=(null!=t?t:"").trim();if(!e)return{name:""};var n=e.indexOf(":");if(-1===n)return{name:e};if(-1!==e.indexOf(":",n+1))return{name:e};var r=e.slice(0,n),i=e.slice(n+1);return g(r)&&g(i)?{ns:r,name:i}:{name:e}}function w(t,e){return e?"".concat(e,":").concat(t):t}var b=Object.freeze({eps:1e-6,maxDecimalsCap:15,trimTrailingZeros:!0,allowScientific:!1,snapNearZero:!0}),M=Object.freeze({number:b});function x(t){var e,n,r,i,o,a,s=null!==(e=null==t?void 0:t.eps)&&void 0!==e?e:b.eps;return{eps:s,maxDecimalsCap:null!==(n=null==t?void 0:t.maxDecimalsCap)&&void 0!==n?n:b.maxDecimalsCap,trimTrailingZeros:null!==(r=null==t?void 0:t.trimTrailingZeros)&&void 0!==r?r:b.trimTrailingZeros,fixedDecimals:null==t?void 0:t.fixedDecimals,allowScientific:null!==(i=null==t?void 0:t.allowScientific)&&void 0!==i?i:b.allowScientific,snapNearZero:null!==(o=null==t?void 0:t.snapNearZero)&&void 0!==o?o:b.snapNearZero,zeroThreshold:null!==(a=null==t?void 0:t.zeroThreshold)&&void 0!==a?a:s,perAttributeEps:null==t?void 0:t.perAttributeEps}}function S(t){return{number:x(null==t?void 0:t.number)}}var C=function(){function t(t){if(this.o=t,this._o=t.number,!Number.isFinite(this._o.eps)||this._o.eps<=0)throw new Error("opts.eps must be a finite, positive number")}return t.prototype.toString=function(t){var e,n,r,i;if(!Number.isFinite(t))throw new Error("Cannot format non-finite number: ".concat(t));var o,a=this._o,s=this._clampInt(null!==(e=a.maxDecimalsCap)&&void 0!==e?e:15,0,20),u=null===(n=a.trimTrailingZeros)||void 0===n||n,l=null===(r=a.snapNearZero)||void 0===r||r,c=null!==(i=a.zeroThreshold)&&void 0!==i?i:a.eps,p=1/a.eps,h=Math.round(t*p)/p;if(Object.is(h,-0)&&(h=0),l&&Math.abs(h)<=c&&(h=0),o=void 0!==a.fixedDecimals?this._clampInt(a.fixedDecimals,0,s):this._clampInt(Math.ceil(-Math.log10(a.eps)),0,s),a.allowScientific,0===o)return String(Math.trunc(h));var f=h.toFixed(o);if(u&&void 0===a.fixedDecimals&&(f=f.replace(/(\.\d*?[1-9])0+$/,"$1").replace(/\.0+$/,"").replace(/\.$/,"")),/[eE]/.test(f))throw new Error("Scientific notation not allowed in XML output: ".concat(f));return f},t.prototype._clampInt=function(t,e,n){return Number.isFinite(t)?(t=Math.trunc(t),Math.max(e,Math.min(n,t))):e},t}();function j(t){return t instanceof Date}function N(t){return"string"==typeof t}function O(t){return"number"==typeof t}function k(t){return"string"==typeof t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t||j(t)}function D(t){return"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t||j(t)}var A,X=function(){function t(t,e){this._ns=new Map,this._prefixCount=0,this._builder=t,this._format=S(e),this._nFmt=new C(this._format)}return t.prototype.withNamespace=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=0,r=t;n<r.length;n++){var i=r[n];this._assignNamespace(i)}return this},t.prototype.serialize=function(t,e){if(!(e=null!=e?e:y(t)))throw new Error("can not find name for given object");var n=T(e);n.ns&&this._assignNamespace(n.ns,"xmlns"),this._gatherNamespaces(t,new WeakSet);for(var r=this._builder.ele(null,n.name),i=0,o=Array.from(this._ns.entries());i<o.length;i++){var a=o[i],s=a[0],u=a[1];r.att("xmlns",u,s)}this._writeObjectContent(r,t,(new WeakSet).add(t)),this._builder.end()},t.prototype._writeObject=function(t,e,n){if(!n.has(e))if(n.add(e),Array.isArray(e))for(var r=0,i=e;r<i.length;r++){var o=i[r];D(o)||(N(o)?this._builder.text(o):this._writeObject(t,o,n))}else{var a=y(e);if(a){var s=T(a),u=this._getPrefix(s),l=w(s.name,u);t.ele(null,l),this._writeObjectContent(t,e,n),this._builder.end()}}},t.prototype._getPrefix=function(t){if(t.ns){var e=this._ns.get(t.ns.toLowerCase());if("xmlns"!==e)return e}},t.prototype._writeObjectContent=function(t,e,n){for(var r,i,o,a=null!==(r=_(e))&&void 0!==r?r:[],s=new Map,u=0,l=a;u<l.length;u++){var c=l[u],p=null!==(i=s.get(c.prop))&&void 0!==i?i:[];p.push(c),s.set(c.prop,p)}for(var h=Object.keys(e).sort(function(t,e){var n,r,i=(null!==(n=s.get(t))&&void 0!==n?n:[]).some(function(t){return"attr"===t.kind}),o=(null!==(r=s.get(e))&&void 0!==r?r:[]).some(function(t){return"attr"===t.kind});return i===o?0:i?-1:1}),f=0,m=h;f<m.length;f++){var d=m[f],v=e[d];if(null!=v){var y=s.get(d);if(y){var g=y.some(function(t){return!0===t.ignore||"none"===t.kind});if(g)continue;for(var b=0,M=y;b<M.length;b++){var x=null!==(o=(c=M[b]).name)&&void 0!==o?o:c.prop.toLowerCase();if(x&&"attr"===c.kind){var S=null;if(O(v)&&this._nFmt&&(S=this._nFmt.toString(v)),c.formatter&&(S=new c.formatter(this._format).toString(v)),S=null!=S?S:v.toString()){var C=T(x),j=this._getPrefix(C),k=w(C.name,j);t.att(null,k,S)}}}}else D(v)||(N(v)?this._builder.text(v):this._writeObject(t,v,n))}}},t.prototype._gatherNamespaces=function(t,e){var n,r;if(!e.has(t))if(e.add(t),Array.isArray(t))for(var i=0,o=t;i<o.length;i++){var a=o[i];k(a)||this._gatherNamespaces(a,e)}else{var s=y(t);s&&this._assignNamespace(s);for(var u=null!==(n=_(t))&&void 0!==n?n:[],l=new Map,c=0,p=u;c<p.length;c++){var h=p[c],f=null!==(r=l.get(h.prop))&&void 0!==r?r:[];f.push(h),l.set(h.prop,f)}for(var m=[],d=0,v=Object.keys(t);d<v.length;d++){var g=v[d],T=t[g];if(null!=T){var w=l.get(g);if(w){var b=w.some(function(t){return!0===t.ignore||"none"===t.kind});if(b)continue;for(var M=0,x=w;M<x.length;M++)(h=x[M]).name&&this._assignNamespace(h.name)}m.push(T)}}for(var S=0,C=m;S<C.length;S++){var j=C[S];k(j)||this._gatherNamespaces(j,e)}}},t.prototype._assignNamespace=function(t,e){var n=T(t);if(null==n?void 0:n.ns){var r=n.ns.toLowerCase();this._ns.get(r)||this._ns.set(r,null!=e?e:this._buildNsPrefix(r))}else"xmlns"===e&&(r=n.name.toLowerCase(),this._ns.get(r)||this._ns.set(r,null!=e?e:this._buildNsPrefix(r)))},t.prototype._buildNsPrefix=function(t){var e,n=!1;do{e="ns".concat(this._prefixCount++);for(var r=0,i=Array.from(this._ns.values());r<i.length;r++)if(i[r]===e){n=!0;break}}while(n);return e},t}(),R=function(){function t(){}return t.OpenTag="<",t.CloseTag=">",t.Slash="/",t.Question="?",t.Quote='"',t.Equal="=",t.Space=" ",t.Semicolon=":",t.Dec="<?xml",t.Xml="xml",t.Xmlns="xmlns",t.Xsi="xsi",t.VersionKeyword="version",t.EncodingKeyword="encoding",t.StandaloneKeyword="standalone",t}();t.TokenType=void 0,(A=t.TokenType||(t.TokenType={}))[A.Declaration=0]="Declaration",A[A.Tag=1]="Tag",A[A.Attribute=2]="Attribute",A[A.Text=3]="Text";var B,P,I=function(){function e(t){this._ctxStack=[],this._d=0,this._w=t}return e.prototype.dec=function(t,e,n){return this._w.write(R.Dec),this._writeAttStr(R.VersionKeyword,t),e&&this._writeAttStr(R.EncodingKeyword,e),void 0!==n&&this._writeAttStr(R.StandaloneKeyword,n?"yes":"no"),this._w.write(R.Question,R.CloseTag),this},e.prototype.att=function(e,n,r){var i=this._peekContext();if(!i)throw new Error("att() without open element");if(i.closed)throw new Error("att() after start tag closed for <".concat(i.name,">"));if(this._isXmlnsDecl(e,n)){if(n===R.Xmlns)i.defaultNs=r,this._registerNamespace(i,"",r),this._writeAttStr(R.Xmlns,r);else if(e)this._registerNamespace(i,n,r),this._writeAttStr("".concat(e,":").concat(n),r);else{var o=n.slice(6);this._registerNamespace(i,o,r),this._writeAttStr(n,r)}return i.lastToken=t.TokenType.Attribute,this}var a=n;if(e){var s=this._ensurePrefixDeclared(i,e);a="".concat(s,":").concat(n)}return i.lastToken=t.TokenType.Attribute,this._writeAttStr(a,r),this},e.prototype.ele=function(t,e){var n,r=this._peekContext();r&&this._closeOpenTagIfNeeded(r);var i=e;if(t){var o=null!==(n=this._lookupPrefix(t))&&void 0!==n?n:t;i="".concat(o,":").concat(e)}return this._pushContext(i,++this._d),this._w.write(R.OpenTag,i),this},e.prototype.text=function(e){var n=this._peekContext();if(!n)throw new Error("text() without open element");return this._closeOpenTagIfNeeded(n),n.lastToken=t.TokenType.Text,this._w.write(this._escText(e)),this},e.prototype.end=function(){var t=this._popContext();return t&&(this._d--,t.closed?this._w.write(R.OpenTag,R.Slash,t.name,R.CloseTag):this._w.write(R.Slash,R.CloseTag)),this},e.prototype._pushContext=function(t,n){var r=new e.Context(t,n);return this._ctxStack.push(r),r},e.prototype._popContext=function(){return this._ctxStack.pop()},e.prototype._peekContext=function(){return this._ctxStack[this._ctxStack.length-1]},Object.defineProperty(e.prototype,"_contextDepth",{get:function(){return this._ctxStack.length},enumerable:!1,configurable:!0}),e.prototype._writeAttStr=function(t,e){this._w.write(R.Space,t,R.Equal,R.Quote,this._escAttr(e),R.Quote)},e.prototype._lookupPrefix=function(t){var e,n=this._ctxStack.length-1;if(n>=0)do{var r=null===(e=this._ctxStack[n--].ns2prefix)||void 0===e?void 0:e.get(t);if(r)return r}while(n>=0)},e.prototype._escText=function(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},e.prototype._escAttr=function(t){return this._escText(t).replace(/"/g,"&quot;").replace(/'/g,"&apos;")},e.prototype._isXmlnsDecl=function(t,e){if(t)return t===R.Xmlns;var n=e.length,r=R.Xmlns.length;return n>=r&&e.startsWith(R.Xmlns)&&(e.length==r||e[r]==R.Semicolon)},e.prototype._registerNamespace=function(t,e,n){if(e===R.Xml||e===R.Xmlns)throw new Error("reserved prefix '".concat(e,"'"));var r=t.prefix2ns.get(e);if(r&&r!==n)throw new Error("prefix '".concat(e,"' already bound to a different namespace"));t.ns2prefix.get(n)||t.ns2prefix.set(n,e),t.prefix2ns.set(e,n)},e.prototype._allocPrefix=function(t){for(var e=1;;){var n="ns".concat(e++);if(!t.prefix2ns.has(n))return n}},e.prototype._ensurePrefixDeclared=function(t,e){var n=this._lookupPrefix(e);if(n)return n;if(t.closed)throw new Error("can not declare namespace after start tag closed for <".concat(t.name,">"));var r=this._allocPrefix(t);return this._writeAttStr("".concat(R.Xmlns,":").concat(r),e),this._registerNamespace(t,r,e),r},e.prototype._closeOpenTagIfNeeded=function(t){t.closed||(this._w.write(R.CloseTag),t.closed=!0)},e.Context=function(t,e){this.name="",this.closed=!1,this.lastToken=null,this.ns2prefix=new Map,this.prefix2ns=new Map,this.defaultNs=null,this.name=t,this.depth=e},e}(),E=function(){function t(){this.count=0,this._chunks=[]}return t.prototype.write=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(0===t.length)return this;var n=t.join("");return this._chunks.push(n),this.count+=n.length,this},t.prototype.toString=function(){return this._chunks.join("")},t.prototype.clear=function(){this._chunks=[],this.count=0},t}(),F=function(){function t(t,e){void 0===e&&(e={}),this._sink=t,this._opts=e,this.count=0,this._encoder=new TextEncoder,this._pending="",this._pendingChars=0}return t.prototype.write=function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(0===e.length)return this;var r=e.join("");if(0===r.length)return this;this._pending+=r,this._pendingChars+=r.length;var i=null!==(t=this._opts.flushChars)&&void 0!==t?t:65536;return this._pendingChars>=i&&this.flush(),this},t.prototype.flush=function(){if(0===this._pendingChars)return this;var t=this._encoder.encode(this._pending);return this._sink.push(t),this.count+=t.length,this._pending="",this._pendingChars=0,this},t.prototype.finish=function(){this.flush(),this._sink.push(new Uint8Array(0),!0)},t.prototype.clear=function(){this._pending="",this._pendingChars=0,this.count=0},t}(),z="http://schemas.microsoft.com/3dmanufacturing/core/2015/02",U="http://schemas.microsoft.com/3dmanufacturing/trianglesets/2021/07";t.ST_Unit=void 0,(B=t.ST_Unit||(t.ST_Unit={})).micron="micron",B.millimeter="millimeter",B.centimeter="centimeter",B.inch="inch",B.foot="foot",B.meter="meter",t.ST_ObjectType=void 0,(P=t.ST_ObjectType||(t.ST_ObjectType={})).model="model",P.solidsupport="solidsupport",P.support="support",P.surface="surface",P.other="other";var K,Z="http://schemas.openxmlformats.org/package/2006/content-types",L="http://schemas.openxmlformats.org/package/2006/relationships";t.KnownI3mfContentType=void 0,(K=t.KnownI3mfContentType||(t.KnownI3mfContentType={})).Relationships="application/vnd.openxmlformats-package.relationships+xml",K.Model="application/vnd.ms-package.3dmanufacturing-3dmodel+xml",K.Materials="application/vnd.ms-package.3dmanufacturing-material+xml",K.Colors="application/vnd.ms-package.3dmanufacturing-colors+xml",K.Texture="application/vnd.ms-package.3dmanufacturing-texture+xml",K.Texture2D="application/vnd.ms-package.3dmanufacturing-texture2d+xml",K.Production="application/vnd.ms-package.3dmanufacturing-production+xml",K.Slice="application/vnd.ms-package.3dmanufacturing-slice+xml",K.BeamLattice="application/vnd.ms-package.3dmanufacturing-beamlattice+xml",K.SecureContent="application/vnd.ms-package.3dmanufacturing-securecontent+xml",K.Png="image/png",K.Jpeg="image/jpeg",K.Tiff="image/tiff",K.Xml="application/xml";var G="_rels/",Q="3D/",V="3dmodel.model",W=".rels",$="[Content_Types].xml",q=function(){function t(){}return t.IsKnown=function(e){return t.Known.has(e)},t.IsThreeDimModel=function(e){return e===t.ThreeDimModel},t.ThreeDimModel="http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel",t.Thumbnail="http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail",t.PrintTicket="http://schemas.microsoft.com/3dmanufacturing/2013/01/printticket",t.MustPreserve="http://schemas.openxmlformats.org/package/2006/relationships/mustpreserve",t.Known=new Set([t.ThreeDimModel,t.Thumbnail,t.PrintTicket,t.MustPreserve]),t}(),H=function(){function t(){this.items=[]}return o([f({ns:Z,name:"Types"})],t)}(),Y=function(){function t(t,e){this.ext=t,this.ct=e}return o([d({name:{ns:Z,name:"Extension"}})],t.prototype,"ext",void 0),o([d({name:{ns:Z,name:"ContentType"}})],t.prototype,"ct",void 0),o([f({ns:Z,name:"Default"})],t)}(),J=function(){function t(){this.items=[]}return o([f({ns:L,name:"Relationships"})],t)}(),tt=function(){function t(t,e,n){this.id=t,this.type=e,this.target=n}return o([d({name:"Id"})],t.prototype,"id",void 0),o([d({name:"Type"})],t.prototype,"type",void 0),o([d({name:"Target"})],t.prototype,"target",void 0),o([f({ns:L,name:"Relationship"})],t)}(),et=function(t,e,n){this.contentTypes=t,this.relationships=e,this.model=n},nt=function(){function t(t){this.values=t}return t.Zero=function(){return new t([0,0,0,0,0,0,0,0,0,0,0,0])},t.prototype.toString=function(){return this.values.join(" ")},t}(),rt=function(){function t(t){this.o=t,this._f=new C(t)}return t.prototype.toString=function(t){var e=this;return t.values.map(function(t){return e._f.toString(t)}).join(" ")},t}(),it=function(){function e(){this.unit=t.ST_Unit.millimeter}return e.KnownMeta=["Title","Designer","Description","Copyright","LicenseTerms","Rating","CreationDate","ModificationDate","Application"],o([d({name:"unit"})],e.prototype,"unit",void 0),o([d({name:"requiredextensions"})],e.prototype,"requiredextensions",void 0),o([d({name:"recommendedextensions"})],e.prototype,"recommendedextensions",void 0),o([f({ns:z,name:"model"})],e)}(),ot=function(){function t(t,e,n,r){this.name=t,this.value=e,this.preserve=n,this.type=r}return o([d({name:"name"})],t.prototype,"name",void 0),o([d({name:"preserve"})],t.prototype,"preserve",void 0),o([d({name:"type"})],t.prototype,"type",void 0),o([f({ns:z,name:"meta"})],t)}(),at=function(){function t(){this.metadata=[]}return o([f({ns:z,name:"metadatagroup"})],t)}(),st=function(){function t(){this.object=[]}return o([f({ns:z,name:"resources"})],t)}(),ut=function(){function e(e,n){void 0===n&&(n=t.ST_ObjectType.model),this.id=e,this.type=n}return o([d({name:"id"})],e.prototype,"id",void 0),o([d({name:"type"})],e.prototype,"type",void 0),o([d({name:"thumbnail"})],e.prototype,"thumbnail",void 0),o([d({name:"partnumber"})],e.prototype,"partnumber",void 0),o([d({name:"name"})],e.prototype,"name",void 0),o([d({name:"pid"})],e.prototype,"pid",void 0),o([d({name:"pindex"})],e.prototype,"pindex",void 0),o([f({ns:z,name:"object"})],e)}(),lt=function(){function t(t,e){this.vertices=null!=t?t:new ct,this.triangles=null!=e?e:new ht}return o([f({ns:z,name:"mesh"})],t)}(),ct=function(){function t(){this.vertex=[]}return o([f({ns:z,name:"vertices"})],t)}(),pt=function(){function t(t,e,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),this.x=t,this.y=e,this.z=n}return o([d({name:"x"})],t.prototype,"x",void 0),o([d({name:"y"})],t.prototype,"y",void 0),o([d({name:"z"})],t.prototype,"z",void 0),o([f({ns:z,name:"vertex"})],t)}(),ht=function(){function t(){this.triangle=[]}return o([f({ns:z,name:"triangles"})],t)}(),ft=function(){function t(t,e,n){this.v1=t,this.v2=e,this.v3=n}return o([d({name:"v1"})],t.prototype,"v1",void 0),o([d({name:"v2"})],t.prototype,"v2",void 0),o([d({name:"v3"})],t.prototype,"v3",void 0),o([d({name:"p1"})],t.prototype,"p1",void 0),o([d({name:"p2"})],t.prototype,"p2",void 0),o([d({name:"p3"})],t.prototype,"p3",void 0),o([d({name:"pid"})],t.prototype,"pid",void 0),o([f({ns:z,name:"triangle"})],t)}(),mt=function(){function t(){this.component=[]}return o([f({ns:z,name:"components"})],t)}(),dt=function(){function t(t,e){this.objectid=t,this.transform=e}return o([d({name:"objectid"})],t.prototype,"objectid",void 0),o([d({name:"transform",formatter:rt})],t.prototype,"transform",void 0),o([f({ns:z,name:"component"})],t)}(),vt=function(){function t(t){this.base=[],this.id=t}return o([d({name:"id"})],t.prototype,"id",void 0),o([f({ns:z,name:"basematerials"})],t)}(),_t=function(){function t(t,e){this.name=t,this.displaycolor=e}return o([d({name:"name"})],t.prototype,"name",void 0),o([d({name:"displaycolor"})],t.prototype,"displaycolor",void 0),o([f({ns:z,name:"base"})],t)}(),yt=function(){function t(){this.item=[]}return o([f({ns:z,name:"build"})],t)}(),gt=function(){function t(t,e,n){this.objectid=t,this.transform=e,this.partnumber=n}return o([d({name:"objectid"})],t.prototype,"objectid",void 0),o([d({name:"transform",formatter:rt})],t.prototype,"transform",void 0),o([d({name:"partnumber"})],t.prototype,"partnumber",void 0),o([f({ns:z,name:"item"})],t)}(),Tt=function(){function t(t,e){this._object=new ut(t,e)}return t.prototype.withName=function(t){return this._object.name=t,this},t.prototype.withThumbnail=function(t){return this._object.thumbnail=t,this},t.prototype.withProperty=function(t,e){return void 0===e&&(e=0),this._object.pid=t,this._object.id=e,this},t.prototype.build=function(){return this._object},t.prototype.reset=function(t,e){this._object=new ut(t,e)},t}(),wt=function(e){function n(n,r){void 0===r&&(r=t.ST_ObjectType.model);var i=e.call(this,n,r)||this;return i._object.content=new mt,i}return r(n,e),n.prototype.withComponent=function(t,e){return this._object.content.component.push(new dt(t,e)),this},n}(Tt),bt=function(e){function n(n){return e.call(this,n,t.ST_ObjectType.model)||this}return r(n,e),n.prototype.withPostProcessHandlers=function(t,e){return this._vh=t,this._th=e,this},n.prototype.withData=function(t){return this._object.content=this._buildMesh(t),this},n.prototype.withMaterial=function(t,e){return this._object.pid=t,this._object.pindex=e,this},n.prototype._buildMesh=function(t){var e=this._buildVertices(t.positions),n=this._buildTriangle(t.indices);return new lt(e,n)},n.prototype._buildVertices=function(t){var e=new ct;if(t)for(var n=0;n<t.length;){var r=t[n++],i=t[n++],o=t[n++],a=new pt(r,i,o);this._vh&&(a=this._vh(a)),e.vertex.push(a)}return e},n.prototype._buildTriangle=function(t){var e=new ht;if(t)for(var n=0;n<t.length;){var r=t[n++],i=t[n++],o=t[n++],a=new ft(r,i,o);this._th&&(a=this._th(a)),e.triangle.push(a)}return e},n}(Tt),Mt=function(){function t(t){this._m=new vt(t)}return t.prototype.withColor=function(t,e){var n;this._m.base=null!==(n=this._m.base)&&void 0!==n?n:[];var r=this._m.base.find(function(e){return e.name.toLowerCase()===t.toLowerCase()});return r?(r.displaycolor=this._rgbaToHex(e),this):(r=new _t(t,this._rgbaToHex(e)),this._m.base.push(r),this)},t.prototype.build=function(){return this._m},t.prototype._rgbaToHex=function(t){var e=function(t){return Math.round(Math.min(255,Math.max(0,255*Math.pow(t,1/2.2))))},n=e(t.r).toString(16).padStart(2,"0").toUpperCase(),r=e(t.g).toString(16).padStart(2,"0").toUpperCase(),i=e(t.b).toString(16).padStart(2,"0").toUpperCase();if("number"==typeof t.a){var o=Math.round(Math.min(255,Math.max(0,255*t.a))).toString(16).padStart(2,"0").toUpperCase();return"#".concat(n).concat(r).concat(i).concat(o)}return"#".concat(n).concat(r).concat(i)},t}(),xt=function(){function t(){this._model=new it,this._objects=new Map}return t.prototype.withMetaData=function(t,e,n,r){return this._model.metadata||(this._model.metadata=new Array),this._model.metadata.push(new ot(t,e,n,r)),this},t.prototype.withMaterial=function(t){var e,n;return t instanceof Mt&&(t=t.build()),t&&(this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new st,this._model.resources.basematerials=null!==(n=this._model.resources.basematerials)&&void 0!==n?n:[],this._model.resources.basematerials.push(t)),this},t.prototype.withMesh=function(t){var e;return t instanceof bt&&(t=t.build()),this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new st,this._model.resources.object.push(t),this},t.prototype.withComponents=function(t){var e;return t instanceof wt&&(t=t.build()),this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new st,this._model.resources.object.push(t),this},t.prototype.withBuild=function(t,e,n){var r,i;return this._model.build=null!==(r=this._model.build)&&void 0!==r?r:new yt,null===(i=this._model.build.item)||void 0===i||i.push(new gt(t,e,n)),this},t.prototype.withUnit=function(t){return this._model.unit=t,this},t.prototype.reset=function(){return this._model=new it,this._objects=new Map,this},t.prototype.build=function(){var t,e,n,r;if(!(null===(e=null===(t=this._model.resources)||void 0===t?void 0:t.object)||void 0===e?void 0:e.length))throw new Error("Invalid state: resources MUST be defined ");if(!(null===(r=null===(n=this._model.build)||void 0===n?void 0:n.item)||void 0===r?void 0:r.length))throw new Error("Invalid state: Build MUST be defined ");return this._model},t.KnownMetaSet=new Set(it.KnownMeta.map(function(t){return t.toLowerCase()})),t}(),St=function(){function e(){}return e.prototype.withContentType=function(t){this._cts||(this._cts=new H);var e=this._cts.items;return e.some(function(e){return e.ext===t.ext&&e.ct===t.ct})||e.push(t),this},e.prototype.withRelationship=function(e){this._rs||(this._rs=new J);var n=this._rs.items;return n.some(function(t){return t.id===e.id})||n.push(e),this.withContentType(new Y("rels",t.KnownI3mfContentType.Relationships)),this},e.prototype.withModel=function(e){return e instanceof xt&&(e=e.build()),this._m=e,this.withContentType(new Y("model",t.KnownI3mfContentType.Model)),this},e.prototype.build=function(){if(!this._m)throw new Error("Invalid state: you Must provide at least a model.");var t="".concat(Q).concat(V);if(!this._rs){var e="/".concat(t);this.withRelationship(new tt("rel".concat(0),q.ThreeDimModel,e))}return new et(this._cts,this._rs,this._m)},e}(),Ct=function(){function e(t){this._o=t}return Object.defineProperty(e.prototype,"options",{get:function(){return this._o},enumerable:!1,configurable:!0}),e.prototype.serializeAsync=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return a(this,void 0,void 0,function(){var n,r,i,o,a,u,l;return s(this,function(s){switch(s.label){case 0:return[4,this.ensureZipLibReadyAsync()];case 1:if(!(n=s.sent()))return[2];if(r=n.Zip,i=n.ZipDeflate,!r||!i)throw new Error("fflate Zip / ZipDeflate not available");return o=function(t){return{push:function(e,n){return t.push(e,n)}}},a=function(t,e,n){var r=new i(e,{level:6});t.add(r);var a=o(r),s=new F(a),u=new I(s).dec("1.0","UTF-8");new X(u).serialize(n),s.finish()},(u=this.toDocument.apply(this,e))?(l=new r(t),a(l,$,u.contentTypes),a(l,"".concat(G).concat(W),u.relationships),a(l,"".concat(Q).concat(V),u.model),l.end(),[2]):[2]}})})},e.prototype.toDocument=function(){for(var e,n,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];var o=(new xt).withUnit(null!==(n=null===(e=this._o)||void 0===e?void 0:e.unit)&&void 0!==n?n:t.ST_Unit.millimeter);if(this.options.metadata)for(var a in this.options.metadata)o.withMetaData(a,this.options.metadata[a]);return(new St).withModel(this.toModel.apply(this,u([o],r,!1))).build()},e}(),jt=function(){function t(){}return t.SerializeToMemoryAsync=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return a(this,void 0,void 0,function(){var n,r,i,o,a,l,c,p;return s(this,function(s){switch(s.label){case 0:return n=new Array,r=0,i=function(t,e,i){n.push(e),r+=e.length},[4,t.serializeAsync.apply(t,u([i],e,!1))];case 1:if(s.sent(),!r)return[2,void 0];for(o=new Uint8Array(r),a=0,l=0,c=n;l<c.length;l++)p=c[l],o.set(p,a),a+=p.length;return[2,o]}})})},t}(),Nt=function(){function t(){}return t.FFLATEUrl="https://unpkg.com/fflate@0.8.2",t}(),Ot=function(){function t(t,e,n){void 0===t&&(t=0),void 0===e&&(e=Number.MIN_SAFE_INTEGER),void 0===n&&(n=1),this._from=t,this._to=e,this._step=n,this._i=t}return t.prototype.next=function(){if(this._i<this._to)throw new Error("ST_ResourceID out of bound");var t=this._i;return this._i+=this._step,t},t.prototype.reset=function(){return this._i=this._from,this},t}(),kt=function(n){function o(t){return void 0===t&&(t={}),n.call(this,i(i({},o.DefaultOptions),t))||this}return r(o,n),o.prototype.toModel=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];n=n.filter(function(t){return t instanceof e.Mesh||t instanceof e.InstancedMesh});for(var i=new Ot,o=t,a=new Map,s=this.options.exportInstances?[]:null,u=0;u<n.length;u++){var l=n[u];if(l instanceof e.InstancedMesh)null==s||s.push(l);else{var c=l.name||"mesh".concat(u),p=l.getWorldMatrix(),h=this._handleBabylonTo3mfMatrixTransformToRef(p,nt.Zero());if(void 0!==(S=l.subMeshes))for(var f=1==S.length,m=0;m<S.length;m++){var d=S[m],v=this._extractSubMesh(l,d);if(v){var _=f?"".concat(c):"".concat(c,"_").concat(m),y=new bt(i.next()).withData(v).withName(_).build();o.withMesh(y),o.withBuild(y.id,h),a.set(d,y)}}}}if(s&&s.length)for(var g=this._groupBy(s,function(t){return t.sourceMesh}),T=0,w=Array.from(g.entries());T<w.length;T++){var b=w[T],M=b[0],x=b[1];if(x&&x.length)for(u=0;u<x.length;u++){p=x[u].getWorldMatrix();var S=M.subMeshes;for(m=0;m<S.length;m++){d=S[m];var C=a.get(d);C&&o.withBuild(C.id,this._handleBabylonTo3mfMatrixTransformToRef(p,nt.Zero()))}}}return o.build()},o.prototype.ensureZipLibReadyAsync=function(){return a(this,void 0,void 0,function(){var t=this;return s(this,function(n){switch(n.label){case 0:return this._fflateReadyPromise?[4,this._fflateReadyPromise]:[3,2];case 1:case 3:return[2,n.sent()];case 2:return this._fflateReadyPromise=a(t,void 0,void 0,function(){var t;return s(this,function(n){switch(n.label){case 0:return(t=globalThis).fflate?[3,2]:[4,e.Tools.LoadScriptAsync(Nt.FFLATEUrl)];case 1:n.sent(),n.label=2;case 2:return[2,t.fflate]}})}),[4,this._fflateReadyPromise]}})})},o.prototype._extractSubMesh=function(t,e){var n=t.getIndices();if(n){var r=t.getVerticesData(o._PositionKind);if(r){if(0==e.indexStart&&e.indexCount==n.length)return{positions:r,indices:n};for(var i=e.indexStart,a=new Map,s=[],u=new Uint32Array(e.indexCount),l=0;l<e.indexCount;l++){var c=n[i+l],p=a.get(c);if(void 0===p){p=a.size,a.set(c,p);var h=3*c;s.push(r[h],r[h+1],r[h+2])}u[l]=p}return{positions:new Float32Array(s),indices:u}}}},o.prototype._groupBy=function(t,e){for(var n=new Map,r=0,i=t;r<i.length;r++){var o=i[r],a=e(o),s=n.get(a);s?s.push(o):n.set(a,[o])}return n},o.prototype._handleBabylonTo3mfMatrixTransformToRef=function(t,n){var r=t.multiplyToRef(o._R_BJS_TO_3MF,e.Matrix.Zero()).m;return n.values=[r[0],r[1],r[2],r[4],r[5],r[6],r[8],r[9],r[10],r[12],r[13],r[14]],n},o.DefaultOptions={unit:t.ST_Unit.meter,exportInstances:!1},o._PositionKind="position",o._R_BJS_TO_3MF=e.Matrix.RotationX(Math.PI/2).multiply(e.Matrix.Scaling(1,-1,1)),o}(Ct),Dt={__proto__:null,AbstractThreeMfSerializer:Ct,ContentTypeFileName:$,DefaultXmlSerializerFormatOptions:M,DefaultXmlSerializerNumberOptions:b,GetXmlFieldMeta:_,GetXmlName:y,IsQualifiedName:l,Known3mfRelationshipTypes:q,get KnownI3mfContentType(){return t.KnownI3mfContentType},Matrix3d:nt,MatrixFormatter:rt,ModelFileName:V,NumberFormatter:C,Object3dDirName:Q,OpenXmlContentTypesNamespace:Z,OpenXmlRelationshipsNamespace:L,RelationshipDirName:G,RelationshipFileName:W,ResolveFormatOptions:S,ResolveNumberOptions:x,get ST_ObjectType(){return t.ST_ObjectType},get ST_Unit(){return t.ST_Unit},StringXmlWriter:E,ThreeDimModelNamespace:z,ThreeMf:jt,ThreeMfBase:_t,ThreeMfBaseMaterials:vt,ThreeMfBuild:yt,ThreeMfComponent:dt,ThreeMfComponents:mt,ThreeMfComponentsBuilder:wt,ThreeMfContentType:Y,ThreeMfContentTypes:H,ThreeMfDocument:et,ThreeMfDocumentBuilder:St,ThreeMfItem:gt,ThreeMfMaterialBuilder:Mt,ThreeMfMesh:lt,ThreeMfMeshBuilder:bt,ThreeMfMeta:ot,ThreeMfMetadataGroup:at,ThreeMfModel:it,ThreeMfModelBuilder:xt,ThreeMfObject:ut,ThreeMfObjectBuilder:Tt,ThreeMfRelationship:tt,ThreeMfRelationships:J,ThreeMfResources:st,ThreeMfSerializer:kt,ThreeMfSerializerGlobalConfiguration:Nt,ThreeMfTriangle:ft,ThreeMfTriangles:ht,ThreeMfVertex:pt,ThreeMfVertices:ct,ToQualifiedString:w,get TokenType(){return t.TokenType},TriangleSetsNamespace:U,Utf8XmlWriterToBytes:F,XmlAttr:d,XmlBuilder:I,XmlElem:v,XmlIgnore:m,XmlName:f,XmlNameToParts:T,XmlSerializer:X},At="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==At){var Xt=[];for(var Rt in Dt)Xt.indexOf(Rt)>-1||(At.BABYLON[Rt]=Dt[Rt],Xt.push(Rt))}t.AbstractThreeMfSerializer=Ct,t.ContentTypeFileName=$,t.DefaultXmlSerializerFormatOptions=M,t.DefaultXmlSerializerNumberOptions=b,t.GetXmlFieldMeta=_,t.GetXmlName=y,t.IsQualifiedName=l,t.Known3mfRelationshipTypes=q,t.Matrix3d=nt,t.MatrixFormatter=rt,t.ModelFileName=V,t.NumberFormatter=C,t.Object3dDirName=Q,t.OpenXmlContentTypesNamespace=Z,t.OpenXmlRelationshipsNamespace=L,t.RelationshipDirName=G,t.RelationshipFileName=W,t.ResolveFormatOptions=S,t.ResolveNumberOptions=x,t.StringXmlWriter=E,t.ThreeDimModelNamespace=z,t.ThreeMf=jt,t.ThreeMfBase=_t,t.ThreeMfBaseMaterials=vt,t.ThreeMfBuild=yt,t.ThreeMfComponent=dt,t.ThreeMfComponents=mt,t.ThreeMfComponentsBuilder=wt,t.ThreeMfContentType=Y,t.ThreeMfContentTypes=H,t.ThreeMfDocument=et,t.ThreeMfDocumentBuilder=St,t.ThreeMfItem=gt,t.ThreeMfMaterialBuilder=Mt,t.ThreeMfMesh=lt,t.ThreeMfMeshBuilder=bt,t.ThreeMfMeta=ot,t.ThreeMfMetadataGroup=at,t.ThreeMfModel=it,t.ThreeMfModelBuilder=xt,t.ThreeMfObject=ut,t.ThreeMfObjectBuilder=Tt,t.ThreeMfRelationship=tt,t.ThreeMfRelationships=J,t.ThreeMfResources=st,t.ThreeMfSerializer=kt,t.ThreeMfSerializerGlobalConfiguration=Nt,t.ThreeMfTriangle=ft,t.ThreeMfTriangles=ht,t.ThreeMfVertex=pt,t.ThreeMfVertices=ct,t.ToQualifiedString=w,t.TriangleSetsNamespace=U,t.Utf8XmlWriterToBytes=F,t.XmlAttr=d,t.XmlBuilder=I,t.XmlElem=v,t.XmlIgnore=m,t.XmlName=f,t.XmlNameToParts=T,t.XmlSerializer=X});
2
2
  //# sourceMappingURL=babylon.threemfSerializer.min.js.map