babylonjs-serializers 8.56.2 → 9.1.0
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.
- package/babylon.glTF2Serializer.js +1 -1
- package/babylon.glTF2Serializer.min.js +1 -1
- package/babylon.glTF2Serializer.min.js.map +1 -1
- package/babylon.objSerializer.js +1 -1
- package/babylon.objSerializer.min.js +1 -1
- package/babylon.objSerializer.min.js.map +1 -1
- package/babylon.stlSerializer.js +1 -1
- package/babylon.stlSerializer.min.js +1 -1
- package/babylon.stlSerializer.min.js.map +1 -1
- package/babylon.threemfSerializer.js +1 -1
- package/babylon.threemfSerializer.min.js +1 -1
- package/babylon.threemfSerializer.min.js.map +1 -1
- package/babylon.usdzSerializer.js +1 -1
- package/babylon.usdzSerializer.min.js +1 -1
- package/babylon.usdzSerializer.min.js.map +1 -1
- package/babylonjs.serializers.d.ts +13 -13
- package/babylonjs.serializers.js +1 -1
- package/babylonjs.serializers.min.js +1 -1
- package/babylonjs.serializers.min.js.map +1 -1
- package/babylonjs.serializers.module.d.ts +64 -72
- package/config.json +1 -1
- package/package.json +4 -4
- package/readme.md +21 -21
- package/src/3mf.ts +1 -1
- package/src/USDZ.ts +1 -1
- package/src/glTF2.ts +1 -1
- package/src/index.ts +1 -1
- package/src/obj.ts +1 -1
- package/src/stl.ts +1 -1
- package/tsconfig.build.json +4 -3
- package/tsconfig.json +2 -2
- package/webpack.config.js +25 -26
package/babylon.objSerializer.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-serializers",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-serializers"]=t(require("babylonjs")):e.SERIALIZERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-serializers",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-serializers"]=t(require("babylonjs")):e.SERIALIZERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,e=>(()=>{"use strict";var t={597(t){t.exports=e}},r={};function o(e){var i=r[e];if(void 0!==i)return i.exports;var n=r[e]={exports:{}};return t[e](n,n.exports,o),n.exports}o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};o.d(i,{default:()=>f});var n={};o.r(n),o.d(n,{OBJExport:()=>u});var a={};o.r(a),o.d(a,{OBJExport:()=>u});var s=o(597),u=function(){function e(){}return e.OBJ=function(e,t,r,o){var i=[],n=1,a=1;t&&(r||(r="mat"),i.push("mtllib "+r+".mtl"));for(var u=0;u<e.length;u++){var l=e[u],p=l.name||"mesh".concat(u,"}");i.push("o ".concat(p));var f=null;if(o){var d=l.computeWorldMatrix(!0);f=new s.Matrix,d.invertToRef(f),l.bakeTransformIntoVertices(d)}if(t){var m=l.material;m&&i.push("usemtl "+m.id)}var c=l.geometry;if(c){var h=c.getVerticesData("position"),b=c.getVerticesData("normal"),g=c.getVerticesData("uv"),v=c.getIndices(),x=0,y=0;if(h&&v){for(var T=e[0].getScene().useRightHandedSystem?1:-1,S=0;S<h.length;S+=3)i.push("v "+h[S]*T+" "+h[S+1]+" "+h[S+2]),x++;if(null!=b)for(S=0;S<b.length;S+=3)i.push("vn "+b[S]*T+" "+b[S+1]+" "+b[S+2]);if(null!=g)for(S=0;S<g.length;S+=2)i.push("vt "+g[S]+" "+g[S+1]),y++;var j=["","",""],F=(l.material||l.getScene().defaultMaterial)._getEffectiveOrientation(l)===s.Material.ClockWiseSideOrientation?[2,1]:[1,2],w=F[0],C=F[1];for(S=0;S<v.length;S+=3){var O=[String(v[S]+n),String(v[S+w]+n),String(v[S+C]+n)],_=[String(v[S]+a),String(v[S+w]+a),String(v[S+C]+a)],B=O,K=null!=g?_:j,M=null!=b?O:j;i.push("f "+B[0]+"/"+K[0]+"/"+M[0]+" "+B[1]+"/"+K[1]+"/"+M[1]+" "+B[2]+"/"+K[2]+"/"+M[2])}o&&f&&l.bakeTransformIntoVertices(f),n+=x,a+=y}else s.Tools.Warn("There are no position vertices or indices on the mesh!")}else s.Tools.Warn("No geometry is present on the mesh")}return i.join("\n")},e.MTL=function(e){var t=[],r=e.material;return t.push("newmtl mat1"),t.push(" Ns "+r.specularPower.toFixed(4)),t.push(" Ni 1.5000"),t.push(" d "+r.alpha.toFixed(4)),t.push(" Tr 0.0000"),t.push(" Tf 1.0000 1.0000 1.0000"),t.push(" illum 2"),t.push(" Ka "+r.ambientColor.r.toFixed(4)+" "+r.ambientColor.g.toFixed(4)+" "+r.ambientColor.b.toFixed(4)),t.push(" Kd "+r.diffuseColor.r.toFixed(4)+" "+r.diffuseColor.g.toFixed(4)+" "+r.diffuseColor.b.toFixed(4)),t.push(" Ks "+r.specularColor.r.toFixed(4)+" "+r.specularColor.g.toFixed(4)+" "+r.specularColor.b.toFixed(4)),t.push(" Ke "+r.emissiveColor.r.toFixed(4)+" "+r.emissiveColor.g.toFixed(4)+" "+r.emissiveColor.b.toFixed(4)),r.ambientTexture&&t.push(" map_Ka "+r.ambientTexture.name),r.diffuseTexture&&t.push(" map_Kd "+r.diffuseTexture.name),r.specularTexture&&t.push(" map_Ks "+r.specularTexture.name),r.bumpTexture&&t.push(" map_bump -imfchan z "+r.bumpTexture.name),r.opacityTexture&&t.push(" map_d "+r.opacityTexture.name),t.join("\n")},e}(),l=void 0!==o.g?o.g:"undefined"!=typeof window?window:void 0;if(void 0!==l)for(var p in n)l.BABYLON[p]=n[p];const f=a;return i.default})());
|
|
2
2
|
//# sourceMappingURL=babylon.objSerializer.min.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-serializers",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-serializers"]=t(require("babylonjs")):e.SERIALIZERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-serializers",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-serializers"]=t(require("babylonjs")):e.SERIALIZERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,e=>(()=>{"use strict";var t={597(t){t.exports=e}},r={};function o(e){var i=r[e];if(void 0!==i)return i.exports;var n=r[e]={exports:{}};return t[e](n,n.exports,o),n.exports}o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};o.d(i,{default:()=>f});var n={};o.r(n),o.d(n,{OBJExport:()=>u});var a={};o.r(a),o.d(a,{OBJExport:()=>u});var s=o(597),u=function(){function e(){}return e.OBJ=function(e,t,r,o){var i=[],n=1,a=1;t&&(r||(r="mat"),i.push("mtllib "+r+".mtl"));for(var u=0;u<e.length;u++){var l=e[u],p=l.name||"mesh".concat(u,"}");i.push("o ".concat(p));var f=null;if(o){var d=l.computeWorldMatrix(!0);f=new s.Matrix,d.invertToRef(f),l.bakeTransformIntoVertices(d)}if(t){var m=l.material;m&&i.push("usemtl "+m.id)}var c=l.geometry;if(c){var h=c.getVerticesData("position"),b=c.getVerticesData("normal"),g=c.getVerticesData("uv"),v=c.getIndices(),x=0,y=0;if(h&&v){for(var T=e[0].getScene().useRightHandedSystem?1:-1,S=0;S<h.length;S+=3)i.push("v "+h[S]*T+" "+h[S+1]+" "+h[S+2]),x++;if(null!=b)for(S=0;S<b.length;S+=3)i.push("vn "+b[S]*T+" "+b[S+1]+" "+b[S+2]);if(null!=g)for(S=0;S<g.length;S+=2)i.push("vt "+g[S]+" "+g[S+1]),y++;var j=["","",""],F=(l.material||l.getScene().defaultMaterial)._getEffectiveOrientation(l)===s.Material.ClockWiseSideOrientation?[2,1]:[1,2],w=F[0],C=F[1];for(S=0;S<v.length;S+=3){var O=[String(v[S]+n),String(v[S+w]+n),String(v[S+C]+n)],_=[String(v[S]+a),String(v[S+w]+a),String(v[S+C]+a)],B=O,K=null!=g?_:j,M=null!=b?O:j;i.push("f "+B[0]+"/"+K[0]+"/"+M[0]+" "+B[1]+"/"+K[1]+"/"+M[1]+" "+B[2]+"/"+K[2]+"/"+M[2])}o&&f&&l.bakeTransformIntoVertices(f),n+=x,a+=y}else s.Tools.Warn("There are no position vertices or indices on the mesh!")}else s.Tools.Warn("No geometry is present on the mesh")}return i.join("\n")},e.MTL=function(e){var t=[],r=e.material;return t.push("newmtl mat1"),t.push(" Ns "+r.specularPower.toFixed(4)),t.push(" Ni 1.5000"),t.push(" d "+r.alpha.toFixed(4)),t.push(" Tr 0.0000"),t.push(" Tf 1.0000 1.0000 1.0000"),t.push(" illum 2"),t.push(" Ka "+r.ambientColor.r.toFixed(4)+" "+r.ambientColor.g.toFixed(4)+" "+r.ambientColor.b.toFixed(4)),t.push(" Kd "+r.diffuseColor.r.toFixed(4)+" "+r.diffuseColor.g.toFixed(4)+" "+r.diffuseColor.b.toFixed(4)),t.push(" Ks "+r.specularColor.r.toFixed(4)+" "+r.specularColor.g.toFixed(4)+" "+r.specularColor.b.toFixed(4)),t.push(" Ke "+r.emissiveColor.r.toFixed(4)+" "+r.emissiveColor.g.toFixed(4)+" "+r.emissiveColor.b.toFixed(4)),r.ambientTexture&&t.push(" map_Ka "+r.ambientTexture.name),r.diffuseTexture&&t.push(" map_Kd "+r.diffuseTexture.name),r.specularTexture&&t.push(" map_Ks "+r.specularTexture.name),r.bumpTexture&&t.push(" map_bump -imfchan z "+r.bumpTexture.name),r.opacityTexture&&t.push(" map_d "+r.opacityTexture.name),t.join("\n")},e}(),l=void 0!==o.g?o.g:"undefined"!=typeof window?window:void 0;if(void 0!==l)for(var p in n)l.BABYLON[p]=n[p];const f=a;return i.default})());
|
|
2
2
|
//# sourceMappingURL=babylon.objSerializer.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babylon.objSerializer.min.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,cACR,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,wBAAyB,CAAC,aAAcJ,GACrB,iBAAZC,QACdA,QAAQ,yBAA2BD,EAAQG,QAAQ,cAEnDJ,EAAkB,YAAIC,EAAQD,EAAc,QAC7C,CATD,CASoB,oBAATO,KAAuBA,KAAyB,oBAAXC,OAAyBA,OAASC,MAAQC,G,iCCT1FP,EAAOD,QAAUQ,C,GCCbC,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaZ,QAGrB,IAAIC,EAASQ,EAAyBE,GAAY,CAGjDX,QAAS,CAAC,GAOX,OAHAc,EAAoBH,GAAUV,EAAQA,EAAOD,QAASU,GAG/CT,EAAOD,OACf,CCrBAU,EAAoBK,EAAI,CAACf,EAASgB,KACjC,I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Q,cAAcjE,EAAE2D,QAAQ,GAAK,IAAMF,EAAEQ,cAAc3E,EAAEqE,QAAQ,GAAK,IAAMF,EAAEQ,cAAcH,EAAEH,QAAQ,IAMtHF,EAAES,gBACFzD,EAAOG,KAAK,YAAwB6C,EAAES,eAAejD,MAGrDwC,EAAEU,gBACF1D,EAAOG,KAAK,YAAwB6C,EAAEU,eAAelD,MAIrDwC,EAAEW,iBACF3D,EAAOG,KAAK,YAAwB6C,EAAEW,gBAAgBnD,MActDwC,EAAEY,aACF5D,EAAOG,KAAK,yBAAqC6C,EAAEY,YAAYpD,MAG/DwC,EAAEa,gBACF7D,EAAOG,KAAK,WAAuB6C,EAAEa,eAAerD,MAG3CR,EAAO8C,KAAK,KAE7B,EACJ,EA9LA,GCJMgB,OAAiC,IAAX,EAAAjF,EAAyB,EAAAA,EAA2B,oBAAXI,OAAyBA,YAASd,EACvG,QAA4B,IAAjB2F,EACP,IAAK,IAAMC,KAAc,EACfD,EAAcE,QAAQD,GAAoB,EAAaA,GCRrE,U","sources":["webpack://SERIALIZERS/webpack/universalModuleDefinition","webpack://SERIALIZERS/external umd {\"root\":\"BABYLON\",\"commonjs\":\"babylonjs\",\"commonjs2\":\"babylonjs\",\"amd\":\"babylonjs\"}","webpack://SERIALIZERS/webpack/bootstrap","webpack://SERIALIZERS/webpack/runtime/define property getters","webpack://SERIALIZERS/webpack/runtime/global","webpack://SERIALIZERS/webpack/runtime/hasOwnProperty shorthand","webpack://SERIALIZERS/webpack/runtime/make namespace object","webpack://SERIALIZERS/../../../dev/serializers/src/OBJ/objSerializer.ts","webpack://SERIALIZERS/../../../lts/serializers/src/legacy/legacy-objSerializer.ts","webpack://SERIALIZERS/./src/obj.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"babylonjs\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"babylonjs-serializers\", [\"babylonjs\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"babylonjs-serializers\"] = factory(require(\"babylonjs\"));\n\telse\n\t\troot[\"SERIALIZERS\"] = factory(root[\"BABYLON\"]);\n})((typeof self !== \"undefined\" ? self : typeof global !== \"undefined\" ? global : this), (__WEBPACK_EXTERNAL_MODULE__597__) => {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__597__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","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","import * as serializers from \"@lts/serializers/legacy/legacy-objSerializer\";\r\nexport { serializers };\r\nexport default serializers;\r\n"],"names":["root","factory","exports","module","require","define","amd","self","global","this","__WEBPACK_EXTERNAL_MODULE__597__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","g","globalThis","Function","e","window","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","OBJ","meshes","materials","matlibname","globalposition","output","v","textureV","push","j","length","mesh","objectName","name","inverseTransform","transform","computeWorldMatrix","Matrix","invertToRef","bakeTransformIntoVertices","mat","material","id","geometry","trunkVerts","getVerticesData","trunkNormals","trunkUV","trunkFaces","getIndices","currentV","currentTextureV","handednessSign","getScene","useRightHandedSystem","i","blanks","defaultMaterial","_getEffectiveOrientation","Material","ClockWiseSideOrientation","offset1","offset2","indices","String","textureIndices","facePositions","faceUVs","faceNormals","Tools","Warn","join","MTL","m","specularPower","toFixed","alpha","ambientColor","b","diffuseColor","specularColor","emissiveColor","ambientTexture","diffuseTexture","specularTexture","bumpTexture","opacityTexture","globalObject","serializer","BABYLON"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"babylon.objSerializer.min.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,cACR,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,wBAAyB,CAAC,aAAcJ,GACrB,iBAAZC,QACdA,QAAQ,yBAA2BD,EAAQG,QAAQ,cAEnDJ,EAAkB,YAAIC,EAAQD,EAAc,QAC7C,CATD,CASoB,oBAATO,KAAuBA,KAAyB,oBAAXC,OAAyBA,OAASC,KAAQC,G,iCCT1FP,EAAOD,QAAUQ,C,GCCbC,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaZ,QAGrB,IAAIC,EAASQ,EAAyBE,GAAY,CAGjDX,QAAS,CAAC,GAOX,OAHAc,EAAoBH,GAAUV,EAAQA,EAAOD,QAASU,GAG/CT,EAAOD,OACf,CCrBAU,EAAoBK,EAAI,CAACf,EAASgB,KACjC,IAAI,IAAIC,KAAOD,EACXN,EAAoBQ,EAAEF,EAAYC,KAASP,EAAoBQ,EAAElB,EAASiB,IAC5EE,OAAOC,eAAepB,EAASiB,EAAK,CAAEI,YAAY,EAAMC,IAA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EAAOG,KAAK,YAAwB6C,EAAES,eAAejD,MAGrDwC,EAAEU,gBACF1D,EAAOG,KAAK,YAAwB6C,EAAEU,eAAelD,MAIrDwC,EAAEW,iBACF3D,EAAOG,KAAK,YAAwB6C,EAAEW,gBAAgBnD,MActDwC,EAAEY,aACF5D,EAAOG,KAAK,yBAAqC6C,EAAEY,YAAYpD,MAG/DwC,EAAEa,gBACF7D,EAAOG,KAAK,WAAuB6C,EAAEa,eAAerD,MAG3CR,EAAO8C,KAAK,KAE7B,EACJ,EA9LA,GCJMgB,OAAiC,IAAX,EAAAjF,EAAyB,EAAAA,EAA2B,oBAAXI,OAAyBA,YAASd,EACvG,QAA4B,IAAjB2F,EACP,IAAK,IAAMC,KAAc,EACfD,EAAcE,QAAQD,GAAoB,EAAaA,GCRrE,U","sources":["webpack://SERIALIZERS/webpack/universalModuleDefinition","webpack://SERIALIZERS/external umd {\"root\":\"BABYLON\",\"commonjs\":\"babylonjs\",\"commonjs2\":\"babylonjs\",\"amd\":\"babylonjs\"}","webpack://SERIALIZERS/webpack/bootstrap","webpack://SERIALIZERS/webpack/runtime/define property getters","webpack://SERIALIZERS/webpack/runtime/global","webpack://SERIALIZERS/webpack/runtime/hasOwnProperty shorthand","webpack://SERIALIZERS/webpack/runtime/make namespace object","webpack://SERIALIZERS/../../../dev/serializers/src/OBJ/objSerializer.ts","webpack://SERIALIZERS/../../../dev/serializers/src/legacy/legacy-objSerializer.ts","webpack://SERIALIZERS/./src/obj.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"babylonjs\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"babylonjs-serializers\", [\"babylonjs\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"babylonjs-serializers\"] = factory(require(\"babylonjs\"));\n\telse\n\t\troot[\"SERIALIZERS\"] = factory(root[\"BABYLON\"]);\n})((typeof self !== \"undefined\" ? self : typeof global !== \"undefined\" ? global : this), (__WEBPACK_EXTERNAL_MODULE__597__) => {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__597__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","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","import * as serializers from \"serializers/legacy/legacy-objSerializer\";\r\nexport { serializers };\r\nexport default serializers;\r\n"],"names":["root","factory","exports","module","require","define","amd","self","global","this","__WEBPACK_EXTERNAL_MODULE__597__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","g","globalThis","Function","e","window","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","OBJ","meshes","materials","matlibname","globalposition","output","v","textureV","push","j","length","mesh","objectName","name","inverseTransform","transform","computeWorldMatrix","Matrix","invertToRef","bakeTransformIntoVertices","mat","material","id","geometry","trunkVerts","getVerticesData","trunkNormals","trunkUV","trunkFaces","getIndices","currentV","currentTextureV","handednessSign","getScene","useRightHandedSystem","i","blanks","defaultMaterial","_getEffectiveOrientation","Material","ClockWiseSideOrientation","offset1","offset2","indices","String","textureIndices","facePositions","faceUVs","faceNormals","Tools","Warn","join","MTL","m","specularPower","toFixed","alpha","ambientColor","b","diffuseColor","specularColor","emissiveColor","ambientTexture","diffuseTexture","specularTexture","bumpTexture","opacityTexture","GlobalObject","serializer","BABYLON"],"sourceRoot":""}
|
package/babylon.stlSerializer.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-serializers",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-serializers"]=t(require("babylonjs")):e.SERIALIZERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-serializers",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-serializers"]=t(require("babylonjs")):e.SERIALIZERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,e=>(()=>{"use strict";var t={597(t){t.exports=e}},r={};function o(e){var n=r[e];if(void 0!==n)return n.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};o.d(n,{default:()=>c});var i={};o.r(i),o.d(i,{STLExport:()=>f});var a={};o.r(a),o.d(a,{STLExport:()=>f});var s=o(597),f=function(){function e(){}return e.CreateSTL=function(e,t,r,o,n,i,a,f){void 0===t&&(t=!0),void 0===r&&(r="stlmesh"),void 0===o&&(o=!1),void 0===n&&(n=!0),void 0===i&&(i=!1),void 0===a&&(a=!1),void 0===f&&(f=!1);var d=function(e,t,r){var o=[3*e[r],3*e[r+1],3*e[r+2]],n=[new s.Vector3(t[o[0]],t[o[0]+2],t[o[0]+1]),new s.Vector3(t[o[1]],t[o[1]+2],t[o[1]+1]),new s.Vector3(t[o[2]],t[o[2]+2],t[o[2]+1])],i=n[0].subtract(n[1]),a=n[2].subtract(n[1]);return{v:n,n:s.Vector3.Cross(a,i).normalize()}},l=function(e,t,r,o){return t=c(e,t,r.x,o),t=c(e,t,r.y,o),c(e,t,r.z,o)},c=function(e,t,r,o){return e.setFloat32(t,r,o),t+4},u=function(e){if(a){var t=e;e instanceof s.InstancedMesh&&(t=e.sourceMesh);var r=t.getVerticesData(s.VertexBuffer.PositionKind,!0,!0);if(!r)return[];var o=s.Vector3.Zero(),n=void 0;for(n=0;n<r.length;n+=3)s.Vector3.TransformCoordinatesFromFloatsToRef(r[n],r[n+1],r[n+2],e.computeWorldMatrix(!0),o).toArray(r,n);return r}return e.getVerticesData(s.VertexBuffer.PositionKind)||[]};a&&(i=!0);var v="",p=0,b=0;if(o){for(var y=0;y<e.length;y++)p+=(w=(g=e[y]).getIndices())?w.length/3:0;var x=new ArrayBuffer(84+50*p);b+=80,(v=new DataView(x)).setUint32(b,p,n),b+=4}else f||(v="solid stlmesh\r\n");for(y=0;y<e.length;y++){var g=e[y];!o&&f&&(v+="solid "+g.name+"\r\n"),!i&&g instanceof s.Mesh&&g.bakeCurrentTransformIntoVertices();for(var m=u(g),w=g.getIndices()||[],h=0;h<w.length;h+=3){var j=d(w,m,h);o?(b=l(v,b,j.n,n),b=l(v,b,j.v[0],n),b=l(v,b,j.v[1],n),b=l(v,b,j.v[2],n),b+=2):(v+="\tfacet normal "+j.n.x+" "+j.n.y+" "+j.n.z+"\r\n",v+="\t\touter loop\r\n",v+="\t\t\tvertex "+j.v[0].x+" "+j.v[0].y+" "+j.v[0].z+"\r\n",v+="\t\t\tvertex "+j.v[1].x+" "+j.v[1].y+" "+j.v[1].z+"\r\n",v+="\t\t\tvertex "+j.v[2].x+" "+j.v[2].y+" "+j.v[2].z+"\r\n",v+="\t\tendloop\r\n",v+="\tendfacet\r\n")}!o&&f&&(v+="endsolid "+name+"\r\n")}if(o||f||(v+="endsolid stlmesh"),t){var V=document.createElement("a"),S=new Blob([v],{type:"application/octet-stream"});V.href=window.URL.createObjectURL(S),V.download=r+".stl",V.click()}return v},e}(),d=void 0!==o.g?o.g:"undefined"!=typeof window?window:void 0;if(void 0!==d)for(var l in i)d.BABYLON[l]=i[l];const c=a;return n.default})());
|
|
2
2
|
//# sourceMappingURL=babylon.stlSerializer.min.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-serializers",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-serializers"]=t(require("babylonjs")):e.SERIALIZERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-serializers",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-serializers"]=t(require("babylonjs")):e.SERIALIZERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,e=>(()=>{"use strict";var t={597(t){t.exports=e}},r={};function o(e){var n=r[e];if(void 0!==n)return n.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};o.d(n,{default:()=>c});var i={};o.r(i),o.d(i,{STLExport:()=>f});var a={};o.r(a),o.d(a,{STLExport:()=>f});var s=o(597),f=function(){function e(){}return e.CreateSTL=function(e,t,r,o,n,i,a,f){void 0===t&&(t=!0),void 0===r&&(r="stlmesh"),void 0===o&&(o=!1),void 0===n&&(n=!0),void 0===i&&(i=!1),void 0===a&&(a=!1),void 0===f&&(f=!1);var d=function(e,t,r){var o=[3*e[r],3*e[r+1],3*e[r+2]],n=[new s.Vector3(t[o[0]],t[o[0]+2],t[o[0]+1]),new s.Vector3(t[o[1]],t[o[1]+2],t[o[1]+1]),new s.Vector3(t[o[2]],t[o[2]+2],t[o[2]+1])],i=n[0].subtract(n[1]),a=n[2].subtract(n[1]);return{v:n,n:s.Vector3.Cross(a,i).normalize()}},l=function(e,t,r,o){return t=c(e,t,r.x,o),t=c(e,t,r.y,o),c(e,t,r.z,o)},c=function(e,t,r,o){return e.setFloat32(t,r,o),t+4},u=function(e){if(a){var t=e;e instanceof s.InstancedMesh&&(t=e.sourceMesh);var r=t.getVerticesData(s.VertexBuffer.PositionKind,!0,!0);if(!r)return[];var o=s.Vector3.Zero(),n=void 0;for(n=0;n<r.length;n+=3)s.Vector3.TransformCoordinatesFromFloatsToRef(r[n],r[n+1],r[n+2],e.computeWorldMatrix(!0),o).toArray(r,n);return r}return e.getVerticesData(s.VertexBuffer.PositionKind)||[]};a&&(i=!0);var v="",p=0,b=0;if(o){for(var y=0;y<e.length;y++)p+=(w=(g=e[y]).getIndices())?w.length/3:0;var x=new ArrayBuffer(84+50*p);b+=80,(v=new DataView(x)).setUint32(b,p,n),b+=4}else f||(v="solid stlmesh\r\n");for(y=0;y<e.length;y++){var g=e[y];!o&&f&&(v+="solid "+g.name+"\r\n"),!i&&g instanceof s.Mesh&&g.bakeCurrentTransformIntoVertices();for(var m=u(g),w=g.getIndices()||[],h=0;h<w.length;h+=3){var j=d(w,m,h);o?(b=l(v,b,j.n,n),b=l(v,b,j.v[0],n),b=l(v,b,j.v[1],n),b=l(v,b,j.v[2],n),b+=2):(v+="\tfacet normal "+j.n.x+" "+j.n.y+" "+j.n.z+"\r\n",v+="\t\touter loop\r\n",v+="\t\t\tvertex "+j.v[0].x+" "+j.v[0].y+" "+j.v[0].z+"\r\n",v+="\t\t\tvertex "+j.v[1].x+" "+j.v[1].y+" "+j.v[1].z+"\r\n",v+="\t\t\tvertex "+j.v[2].x+" "+j.v[2].y+" "+j.v[2].z+"\r\n",v+="\t\tendloop\r\n",v+="\tendfacet\r\n")}!o&&f&&(v+="endsolid "+name+"\r\n")}if(o||f||(v+="endsolid stlmesh"),t){var V=document.createElement("a"),S=new Blob([v],{type:"application/octet-stream"});V.href=window.URL.createObjectURL(S),V.download=r+".stl",V.click()}return v},e}(),d=void 0!==o.g?o.g:"undefined"!=typeof window?window:void 0;if(void 0!==d)for(var l in i)d.BABYLON[l]=i[l];const c=a;return n.default})());
|
|
2
2
|
//# sourceMappingURL=babylon.stlSerializer.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babylon.stlSerializer.min.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,cACR,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,wBAAyB,CAAC,aAAcJ,GACrB,iBAAZC,QACdA,QAAQ,yBAA2BD,EAAQG,QAAQ,cAEnDJ,EAAkB,YAAIC,EAAQD,EAAc,QAC7C,CATD,CASoB,oBAATO,KAAuBA,KAAyB,oBAAXC,OAAyBA,OAASC,MAAQC,G,iCCT1FP,EAAOD,QAAUQ,C,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,gBAAkBU,EAAGxC,EAAE,GAAGa,EAAI,IAAM2B,EAAGxC,EAAE,GAAGc,EAAI,IAAM0B,EAAGxC,EAAE,GAAGe,EAAI,OAC1Ee,GAAQ,gBAAkBU,EAAGxC,EAAE,GAAGa,EAAI,IAAM2B,EAAGxC,EAAE,GAAGc,EAAI,IAAM0B,EAAGxC,EAAE,GAAGe,EAAI,OAC1Ee,GAAQ,gBAAkBU,EAAGxC,EAAE,GAAGa,EAAI,IAAM2B,EAAGxC,EAAE,GAAGc,EAAI,IAAM0B,EAAGxC,EAAE,GAAGe,EAAI,OAC1Ee,GAAQ,kBACRA,GAAQ,iBAEhB,EACKxC,GAAUI,IACXoC,GAAQ,YAAcO,KAAO,OAErC,CAMA,GAJK/C,GAAWI,IACZoC,GAAQ,oBAGR1C,EAAU,CACV,IAAMqD,EAAIC,SAASC,cAAc,KAC3BC,EAAO,IAAIC,KAAK,CAACf,GAAO,CAAEgB,KAAM,6BACtCL,EAAEM,KAAOvE,OAAOwE,IAAIC,gBAAgBL,GACpCH,EAAErD,SAAWC,EAAW,OACxBoD,EAAES,OACN,CAEA,OAAOpB,CACX,EACJ,EArJA,GCDMqB,OAAiC,IAAX,EAAA/E,EAAyB,EAAAA,EAA2B,oBAAXI,OAAyBA,YAASd,EACvG,QAA4B,IAAjByF,EACP,IAAK,IAAMC,KAAc,EACfD,EAAcE,QAAQD,GAAoB,EAAaA,GCRrE,U","sources":["webpack://SERIALIZERS/webpack/universalModuleDefinition","webpack://SERIALIZERS/external umd {\"root\":\"BABYLON\",\"commonjs\":\"babylonjs\",\"commonjs2\":\"babylonjs\",\"amd\":\"babylonjs\"}","webpack://SERIALIZERS/webpack/bootstrap","webpack://SERIALIZERS/webpack/runtime/define property getters","webpack://SERIALIZERS/webpack/runtime/global","webpack://SERIALIZERS/webpack/runtime/hasOwnProperty shorthand","webpack://SERIALIZERS/webpack/runtime/make namespace object","webpack://SERIALIZERS/../../../dev/serializers/src/stl/stlSerializer.ts","webpack://SERIALIZERS/../../../lts/serializers/src/legacy/legacy-stlSerializer.ts","webpack://SERIALIZERS/./src/stl.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"babylonjs\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"babylonjs-serializers\", [\"babylonjs\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"babylonjs-serializers\"] = factory(require(\"babylonjs\"));\n\telse\n\t\troot[\"SERIALIZERS\"] = factory(root[\"BABYLON\"]);\n})((typeof self !== \"undefined\" ? self : typeof global !== \"undefined\" ? global : this), (__WEBPACK_EXTERNAL_MODULE__597__) => {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__597__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","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","import * as serializers from \"@lts/serializers/legacy/legacy-stlSerializer\";\r\nexport { serializers };\r\nexport default serializers;\r\n"],"names":["root","factory","exports","module","require","define","amd","self","global","this","__WEBPACK_EXTERNAL_MODULE__597__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","g","globalThis","Function","e","window","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","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","setFloat32","getVerticesData","mesh","sourceMesh","InstancedMesh","VertexBuffer","PositionKind","temp","Zero","index","length","TransformCoordinatesFromFloatsToRef","computeWorldMatrix","toArray","data","faceCount","getIndices","buffer","ArrayBuffer","DataView","setUint32","name","Mesh","bakeCurrentTransformIntoVertices","fd","a","document","createElement","blob","Blob","type","href","URL","createObjectURL","click","globalObject","serializer","BABYLON"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"babylon.stlSerializer.min.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,cACR,mBAAXC,QAAyBA,OAAOC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\":\"babylonjs\"}","webpack://SERIALIZERS/webpack/bootstrap","webpack://SERIALIZERS/webpack/runtime/define property getters","webpack://SERIALIZERS/webpack/runtime/global","webpack://SERIALIZERS/webpack/runtime/hasOwnProperty shorthand","webpack://SERIALIZERS/webpack/runtime/make namespace object","webpack://SERIALIZERS/../../../dev/serializers/src/stl/stlSerializer.ts","webpack://SERIALIZERS/../../../dev/serializers/src/legacy/legacy-stlSerializer.ts","webpack://SERIALIZERS/./src/stl.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"babylonjs\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"babylonjs-serializers\", [\"babylonjs\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"babylonjs-serializers\"] = factory(require(\"babylonjs\"));\n\telse\n\t\troot[\"SERIALIZERS\"] = factory(root[\"BABYLON\"]);\n})((typeof self !== \"undefined\" ? self : typeof global !== \"undefined\" ? global : this), (__WEBPACK_EXTERNAL_MODULE__597__) => {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__597__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","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","import * as serializers from \"serializers/legacy/legacy-stlSerializer\";\r\nexport { serializers };\r\nexport default serializers;\r\n"],"names":["root","factory","exports","module","require","define","amd","self","global","this","__WEBPACK_EXTERNAL_MODULE__597__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","g","globalThis","Function","e","window","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","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","setFloat32","getVerticesData","mesh","sourceMesh","InstancedMesh","VertexBuffer","PositionKind","temp","Zero","index","length","TransformCoordinatesFromFloatsToRef","computeWorldMatrix","toArray","data","faceCount","getIndices","buffer","ArrayBuffer","DataView","setUint32","name","Mesh","bakeCurrentTransformIntoVertices","fd","a","document","createElement","blob","Blob","type","href","URL","createObjectURL","click","GlobalObject","serializer","BABYLON"],"sourceRoot":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-serializers",["babylonjs"],e):"object"==typeof exports?exports["babylonjs-serializers"]=e(require("babylonjs")):t.SERIALIZERS=e(t.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(t=>(()=>{"use strict";var e={597(e){e.exports=t}},n={};function r(t){var i=n[t];if(void 0!==i)return i.exports;var o=n[t]={exports:{}};return e[t](o,o.exports,r),o.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};r.d(i,{default:()=>Ft});var o={};r.r(o),r.d(o,{AbstractThreeMfSerializer:()=>kt,ContentTypeFileName:()=>Y,DefaultXmlSerializerFormatOptions:()=>N,DefaultXmlSerializerNumberOptions:()=>C,GetXmlFieldMeta:()=>T,GetXmlName:()=>M,IsQualifiedName:()=>m,Known3mfRelationshipTypes:()=>tt,KnownI3mfContentType:()=>Q,Matrix3d:()=>at,MatrixFormatter:()=>st,ModelFileName:()=>H,NumberFormatter:()=>D,Object3dDirName:()=>$,OpenXmlContentTypesNamespace:()=>V,OpenXmlRelationshipsNamespace:()=>W,RelationshipDirName:()=>q,RelationshipFileName:()=>J,ResolveFormatOptions:()=>k,ResolveNumberOptions:()=>O,ST_ObjectType:()=>z,ST_Unit:()=>F,StringXmlWriter:()=>K,ThreeDimModelNamespace:()=>U,ThreeMf:()=>Dt,ThreeMfBase:()=>wt,ThreeMfBaseMaterials:()=>bt,ThreeMfBuild:()=>Tt,ThreeMfComponent:()=>gt,ThreeMfComponents:()=>_t,ThreeMfComponentsBuilder:()=>St,ThreeMfContentType:()=>nt,ThreeMfContentTypes:()=>et,ThreeMfDocument:()=>ot,ThreeMfDocumentBuilder:()=>Ot,ThreeMfItem:()=>Mt,ThreeMfMaterialBuilder:()=>Ct,ThreeMfMesh:()=>ft,ThreeMfMeshBuilder:()=>jt,ThreeMfMeta:()=>lt,ThreeMfMetadataGroup:()=>ct,ThreeMfModel:()=>ut,ThreeMfModelBuilder:()=>Nt,ThreeMfObject:()=>ht,ThreeMfObjectBuilder:()=>xt,ThreeMfRelationship:()=>it,ThreeMfRelationships:()=>rt,ThreeMfResources:()=>pt,ThreeMfSerializer:()=>Pt,ThreeMfSerializerGlobalConfiguration:()=>Xt,ThreeMfTriangle:()=>yt,ThreeMfTriangles:()=>vt,ThreeMfVertex:()=>dt,ThreeMfVertices:()=>mt,ToQualifiedString:()=>j,TokenType:()=>B,TriangleSetsNamespace:()=>G,Utf8XmlWriterToBytes:()=>L,XmlAttr:()=>b,XmlBuilder:()=>Z,XmlElem:()=>w,XmlIgnore:()=>g,XmlName:()=>_,XmlNameToParts:()=>S,XmlSerializer:()=>E});var a={};r.r(a),r.d(a,{AbstractThreeMfSerializer:()=>kt,ContentTypeFileName:()=>Y,DefaultXmlSerializerFormatOptions:()=>N,DefaultXmlSerializerNumberOptions:()=>C,GetXmlFieldMeta:()=>T,GetXmlName:()=>M,IsQualifiedName:()=>m,Known3mfRelationshipTypes:()=>tt,KnownI3mfContentType:()=>Q,Matrix3d:()=>at,MatrixFormatter:()=>st,ModelFileName:()=>H,NumberFormatter:()=>D,Object3dDirName:()=>$,OpenXmlContentTypesNamespace:()=>V,OpenXmlRelationshipsNamespace:()=>W,RelationshipDirName:()=>q,RelationshipFileName:()=>J,ResolveFormatOptions:()=>k,ResolveNumberOptions:()=>O,ST_ObjectType:()=>z,ST_Unit:()=>F,StringXmlWriter:()=>K,ThreeDimModelNamespace:()=>U,ThreeMf:()=>Dt,ThreeMfBase:()=>wt,ThreeMfBaseMaterials:()=>bt,ThreeMfBuild:()=>Tt,ThreeMfComponent:()=>gt,ThreeMfComponents:()=>_t,ThreeMfComponentsBuilder:()=>St,ThreeMfContentType:()=>nt,ThreeMfContentTypes:()=>et,ThreeMfDocument:()=>ot,ThreeMfDocumentBuilder:()=>Ot,ThreeMfItem:()=>Mt,ThreeMfMaterialBuilder:()=>Ct,ThreeMfMesh:()=>ft,ThreeMfMeshBuilder:()=>jt,ThreeMfMeta:()=>lt,ThreeMfMetadataGroup:()=>ct,ThreeMfModel:()=>ut,ThreeMfModelBuilder:()=>Nt,ThreeMfObject:()=>ht,ThreeMfObjectBuilder:()=>xt,ThreeMfRelationship:()=>it,ThreeMfRelationships:()=>rt,ThreeMfResources:()=>pt,ThreeMfSerializer:()=>Pt,ThreeMfSerializerGlobalConfiguration:()=>Xt,ThreeMfTriangle:()=>yt,ThreeMfTriangles:()=>vt,ThreeMfVertex:()=>dt,ThreeMfVertices:()=>mt,ToQualifiedString:()=>j,TokenType:()=>B,TriangleSetsNamespace:()=>G,Utf8XmlWriterToBytes:()=>L,XmlAttr:()=>b,XmlBuilder:()=>Z,XmlElem:()=>w,XmlIgnore:()=>g,XmlName:()=>_,XmlNameToParts:()=>S,XmlSerializer:()=>E});var s=function(t,e){return s=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])},s(t,e)};function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var l=function(){return l=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},l.apply(this,arguments)};function c(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 p(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 h(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 f(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 m(t){return"string"==typeof(null==t?void 0:t.name)}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var d=Symbol("__xml:meta$__"),v=Symbol("__xml:name$__");function y(t,e){var n,r=t.constructor;(null!==(n=r[d])&&void 0!==n?n:r[d]=[]).push(e)}function _(t){return function(e){e[v]=t}}function g(){return function(t,e){return y(t,{kind:"none",prop:e,ignore:!0})}}function b(t){return function(e,n){return y(e,l({kind:"attr",prop:n},t))}}function w(t){return function(e,n){return y(e,l({kind:"elem",prop:n},t))}}function T(t){var e,n;return null!==(n=null===(e=null==t?void 0:t.constructor)||void 0===e?void 0:e[d])&&void 0!==n?n:[]}function M(t){var e;return(null===(e=null==t?void 0:t.constructor)||void 0===e?void 0:e[v])||void 0}function x(t){return/^[A-Za-z_][A-Za-z0-9._-]*$/.test(t)}function S(t){if(m(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 x(r)&&x(i)?{ns:r,name:i}:{name:e}}function j(t,e){return e?"".concat(e,":").concat(t):t}var C=Object.freeze({eps:1e-6,maxDecimalsCap:15,trimTrailingZeros:!0,allowScientific:!1,snapNearZero:!0}),N=Object.freeze({number:C});function O(t){var e,n,r,i,o,a,s=null!==(e=null==t?void 0:t.eps)&&void 0!==e?e:C.eps;return{eps:s,maxDecimalsCap:null!==(n=null==t?void 0:t.maxDecimalsCap)&&void 0!==n?n:C.maxDecimalsCap,trimTrailingZeros:null!==(r=null==t?void 0:t.trimTrailingZeros)&&void 0!==r?r:C.trimTrailingZeros,fixedDecimals:null==t?void 0:t.fixedDecimals,allowScientific:null!==(i=null==t?void 0:t.allowScientific)&&void 0!==i?i:C.allowScientific,snapNearZero:null!==(o=null==t?void 0:t.snapNearZero)&&void 0!==o?o:C.snapNearZero,zeroThreshold:null!==(a=null==t?void 0:t.zeroThreshold)&&void 0!==a?a:s,perAttributeEps:null==t?void 0:t.perAttributeEps}}function k(t){return{number:O(null==t?void 0:t.number)}}var D=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 A(t){return t instanceof Date}function X(t){return"string"==typeof t}function R(t){return"string"==typeof t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t||A(t)}function P(t){return"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t||A(t)}var B,E=function(){function t(t,e){this._ns=new Map,this._prefixCount=0,this._builder=t,this._format=k(e),this._nFmt=new D(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:M(t)))throw new Error("can not find name for given object");var n=S(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];P(o)||(X(o)?this._builder.text(o):this._writeObject(t,o,n))}else{var a=M(e);if(a){var s=S(a),u=this._getPrefix(s),l=j(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=T(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 _=y.some((function(t){return!0===t.ignore||"none"===t.kind}));if(_)continue;for(var g=0,b=y;g<b.length;g++){var w=null!==(o=(c=b[g]).name)&&void 0!==o?o:c.prop.toLowerCase();if(w&&"attr"===c.kind){var M=null;if("number"==typeof v&&this._nFmt&&(M=this._nFmt.toString(v)),c.formatter&&(M=new c.formatter(this._format).toString(v)),M=null!=M?M:v.toString()){var x=S(w),C=this._getPrefix(x),N=j(x.name,C);t.att(null,N,M)}}}}else P(v)||(X(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];R(a)||this._gatherNamespaces(a,e)}else{var s=M(t);s&&this._assignNamespace(s);for(var u=null!==(n=T(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 y=v[d],_=t[y];if(null!=_){var g=l.get(y);if(g){var b=g.some((function(t){return!0===t.ignore||"none"===t.kind}));if(b)continue;for(var w=0,x=g;w<x.length;w++)(h=x[w]).name&&this._assignNamespace(h.name)}m.push(_)}}for(var S=0,j=m;S<j.length;S++){var C=j[S];R(C)||this._gatherNamespaces(C,e)}}},t.prototype._assignNamespace=function(t,e){var n=S(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}(),I=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"}(B||(B={}));var F,z,Z=function(){function t(t){this._ctxStack=[],this._d=0,this._w=t}return t.prototype.dec=function(t,e,n){return this._w.write(I.Dec),this._writeAttStr(I.VersionKeyword,t),e&&this._writeAttStr(I.EncodingKeyword,e),void 0!==n&&this._writeAttStr(I.StandaloneKeyword,n?"yes":"no"),this._w.write(I.Question,I.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===I.Xmlns)r.defaultNs=n,this._registerNamespace(r,"",n),this._writeAttStr(I.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=B.Attribute,this}var o=e;if(t){var a=this._ensurePrefixDeclared(r,t);o="".concat(a,":").concat(e)}return r.lastToken=B.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(I.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=B.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(I.OpenTag,I.Slash,t.name,I.CloseTag):this._w.write(I.Slash,I.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(I.Space,t,I.Equal,I.Quote,this._escAttr(e),I.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,"&").replace(/</g,"<").replace(/>/g,">")},t.prototype._escAttr=function(t){return this._escText(t).replace(/"/g,""").replace(/'/g,"'")},t.prototype._isXmlnsDecl=function(t,e){if(t)return t===I.Xmlns;var n=e.length,r=I.Xmlns.length;return n>=r&&e.startsWith(I.Xmlns)&&(e.length==r||e[r]==I.Semicolon)},t.prototype._registerNamespace=function(t,e,n){if(e===I.Xml||e===I.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(I.Xmlns,":").concat(r),e),this._registerNamespace(t,r,e),r},t.prototype._closeOpenTagIfNeeded=function(t){t.closed||(this._w.write(I.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}(),K=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}(),L=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}(),U="http://schemas.microsoft.com/3dmanufacturing/core/2015/02",G="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"}(F||(F={})),function(t){t.model="model",t.solidsupport="solidsupport",t.support="support",t.surface="surface",t.other="other"}(z||(z={}));var Q,V="http://schemas.openxmlformats.org/package/2006/content-types",W="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"}(Q||(Q={}));var q="_rels/",$="3D/",H="3dmodel.model",J=".rels",Y="[Content_Types].xml",tt=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}(),et=function(){function t(){this.items=[]}return c([_({ns:V,name:"Types"})],t)}(),nt=function(){function t(t,e){this.ext=t,this.ct=e}return c([b({name:{ns:V,name:"Extension"}})],t.prototype,"ext",void 0),c([b({name:{ns:V,name:"ContentType"}})],t.prototype,"ct",void 0),c([_({ns:V,name:"Default"})],t)}(),rt=function(){function t(){this.items=[]}return c([_({ns:W,name:"Relationships"})],t)}(),it=function(){function t(t,e,n){this.id=t,this.type=e,this.target=n}return c([b({name:"Id"})],t.prototype,"id",void 0),c([b({name:"Type"})],t.prototype,"type",void 0),c([b({name:"Target"})],t.prototype,"target",void 0),c([_({ns:W,name:"Relationship"})],t)}(),ot=function(t,e,n){this.contentTypes=t,this.relationships=e,this.model=n},at=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}(),st=function(){function t(t){this.o=t,this._f=new D(t)}return t.prototype.toString=function(t){var e=this;return t.values.map((function(t){return e._f.toString(t)})).join(" ")},t}(),ut=function(){function t(){this.unit=F.millimeter}return t.KnownMeta=["Title","Designer","Description","Copyright","LicenseTerms","Rating","CreationDate","ModificationDate","Application"],c([b({name:"unit"})],t.prototype,"unit",void 0),c([b({name:"requiredextensions"})],t.prototype,"requiredextensions",void 0),c([b({name:"recommendedextensions"})],t.prototype,"recommendedextensions",void 0),c([_({ns:U,name:"model"})],t)}(),lt=function(){function t(t,e,n,r){this.name=t,this.value=e,this.preserve=n,this.type=r}return c([b({name:"name"})],t.prototype,"name",void 0),c([b({name:"preserve"})],t.prototype,"preserve",void 0),c([b({name:"type"})],t.prototype,"type",void 0),c([_({ns:U,name:"meta"})],t)}(),ct=function(){function t(){this.metadata=[]}return c([_({ns:U,name:"metadatagroup"})],t)}(),pt=function(){function t(){this.object=[]}return c([_({ns:U,name:"resources"})],t)}(),ht=function(){function t(t,e){void 0===e&&(e=z.model),this.id=t,this.type=e}return c([b({name:"id"})],t.prototype,"id",void 0),c([b({name:"type"})],t.prototype,"type",void 0),c([b({name:"thumbnail"})],t.prototype,"thumbnail",void 0),c([b({name:"partnumber"})],t.prototype,"partnumber",void 0),c([b({name:"name"})],t.prototype,"name",void 0),c([b({name:"pid"})],t.prototype,"pid",void 0),c([b({name:"pindex"})],t.prototype,"pindex",void 0),c([_({ns:U,name:"object"})],t)}(),ft=function(){function t(t,e){this.vertices=null!=t?t:new mt,this.triangles=null!=e?e:new vt}return c([_({ns:U,name:"mesh"})],t)}(),mt=function(){function t(){this.vertex=[]}return c([_({ns:U,name:"vertices"})],t)}(),dt=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 c([b({name:"x"})],t.prototype,"x",void 0),c([b({name:"y"})],t.prototype,"y",void 0),c([b({name:"z"})],t.prototype,"z",void 0),c([_({ns:U,name:"vertex"})],t)}(),vt=function(){function t(){this.triangle=[]}return c([_({ns:U,name:"triangles"})],t)}(),yt=function(){function t(t,e,n){this.v1=t,this.v2=e,this.v3=n}return c([b({name:"v1"})],t.prototype,"v1",void 0),c([b({name:"v2"})],t.prototype,"v2",void 0),c([b({name:"v3"})],t.prototype,"v3",void 0),c([b({name:"p1"})],t.prototype,"p1",void 0),c([b({name:"p2"})],t.prototype,"p2",void 0),c([b({name:"p3"})],t.prototype,"p3",void 0),c([b({name:"pid"})],t.prototype,"pid",void 0),c([_({ns:U,name:"triangle"})],t)}(),_t=function(){function t(){this.component=[]}return c([_({ns:U,name:"components"})],t)}(),gt=function(){function t(t,e){this.objectid=t,this.transform=e}return c([b({name:"objectid"})],t.prototype,"objectid",void 0),c([b({name:"transform",formatter:st})],t.prototype,"transform",void 0),c([_({ns:U,name:"component"})],t)}(),bt=function(){function t(t){this.base=[],this.id=t}return c([b({name:"id"})],t.prototype,"id",void 0),c([_({ns:U,name:"basematerials"})],t)}(),wt=function(){function t(t,e){this.name=t,this.displaycolor=e}return c([b({name:"name"})],t.prototype,"name",void 0),c([b({name:"displaycolor"})],t.prototype,"displaycolor",void 0),c([_({ns:U,name:"base"})],t)}(),Tt=function(){function t(){this.item=[]}return c([_({ns:U,name:"build"})],t)}(),Mt=function(){function t(t,e,n){this.objectid=t,this.transform=e,this.partnumber=n}return c([b({name:"objectid"})],t.prototype,"objectid",void 0),c([b({name:"transform",formatter:st})],t.prototype,"transform",void 0),c([b({name:"partnumber"})],t.prototype,"partnumber",void 0),c([_({ns:U,name:"item"})],t)}(),xt=function(){function t(t,e){this._object=new ht(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 ht(t,e)},t}(),St=function(t){function e(e,n){void 0===n&&(n=z.model);var r=t.call(this,e,n)||this;return r._object.content=new _t,r}return u(e,t),e.prototype.withComponent=function(t,e){return this._object.content.component.push(new gt(t,e)),this},e}(xt),jt=function(t){function e(e){return t.call(this,e,z.model)||this}return u(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 ft(e,n)},e.prototype._buildVertices=function(t){var e=new mt;if(t)for(var n=0;n<t.length;){var r=t[n++],i=t[n++],o=t[n++],a=new dt(r,i,o);this._vh&&(a=this._vh(a)),e.vertex.push(a)}return e},e.prototype._buildTriangle=function(t){var e=new vt;if(t)for(var n=0;n<t.length;){var r=t[n++],i=t[n++],o=t[n++],a=new yt(r,i,o);this._th&&(a=this._th(a)),e.triangle.push(a)}return e},e}(xt),Ct=function(){function t(t){this._m=new bt(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 wt(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}(),Nt=function(){function t(){this._model=new ut,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 lt(t,e,n,r)),this},t.prototype.withMaterial=function(t){var e,n;return t instanceof Ct&&(t=t.build()),t&&(this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new pt,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 jt&&(t=t.build()),this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new pt,this._model.resources.object.push(t),this},t.prototype.withComponents=function(t){var e;return t instanceof St&&(t=t.build()),this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new pt,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 Tt,null===(i=this._model.build.item)||void 0===i||i.push(new Mt(t,e,n)),this},t.prototype.withUnit=function(t){return this._model.unit=t,this},t.prototype.reset=function(){return this._model=new ut,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(ut.KnownMeta.map((function(t){return t.toLowerCase()}))),t}(),Ot=function(){function t(){}return t.prototype.withContentType=function(t){this._cts||(this._cts=new et);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 rt);var e=this._rs.items;return e.some((function(e){return e.id===t.id}))||e.push(t),this.withContentType(new nt("rels",Q.Relationships)),this},t.prototype.withModel=function(t){return t instanceof Nt&&(t=t.build()),this._m=t,this.withContentType(new nt("model",Q.Model)),this},t.prototype.build=function(){if(!this._m)throw new Error("Invalid state: you Must provide at least a model.");var t="".concat($).concat(H);if(!this._rs){var e="/".concat(t);this.withRelationship(new it("rel".concat(0),tt.ThreeDimModel,e))}return new ot(this._cts,this._rs,this._m)},t}(),kt=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 p(this,void 0,void 0,(function(){var n,r,i,o,a,s,u;return h(this,(function(l){switch(l.label){case 0:return[4,this.ensureZipLibReadyAsync()];case 1:if(!(n=l.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 L(a),u=new Z(s).dec("1.0","UTF-8");new E(u).serialize(n),s.finish()},(s=this.toDocument.apply(this,e))?(u=new r(t),a(u,Y,s.contentTypes),a(u,"".concat(q).concat(J),s.relationships),a(u,"".concat($).concat(H),s.model),u.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 Nt).withUnit(null!==(e=null===(t=this._o)||void 0===t?void 0:t.unit)&&void 0!==e?e:F.millimeter);if(this.options.metadata)for(var o in this.options.metadata)i.withMetaData(o,this.options.metadata[o]);return(new Ot).withModel(this.toModel.apply(this,f([i],n,!1))).build()},t}(),Dt=function(){function t(){}return t.SerializeToMemoryAsync=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return p(this,void 0,void 0,(function(){var n,r,i,o,a,s,u,l;return h(this,(function(c){switch(c.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,f([i],e,!1))];case 1:if(c.sent(),!r)return[2,void 0];for(o=new Uint8Array(r),a=0,s=0,u=n;s<u.length;s++)l=u[s],o.set(l,a),a+=l.length;return[2,o]}}))}))},t}(),At=r(597),Xt=function(){function t(){}return t.FFLATEUrl="https://unpkg.com/fflate@0.8.2",t}(),Rt=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}(),Pt=function(t){function e(n){return void 0===n&&(n={}),t.call(this,l(l({},e.DefaultOptions),n))||this}return u(e,t),e.prototype.toModel=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];e=e.filter((function(t){return t instanceof At.Mesh||t instanceof At.InstancedMesh}));for(var r=new Rt,i=t,o=new Map,a=this.options.exportInstances?[]:null,s=0;s<e.length;s++){var u=e[s];if(u instanceof At.InstancedMesh)null==a||a.push(u);else{var l=u.name||"mesh".concat(s),c=u.getWorldMatrix(),p=this._handleBabylonTo3mfMatrixTransformToRef(c,at.Zero());if(void 0!==(x=u.subMeshes))for(var h=1==x.length,f=0;f<x.length;f++){var m=x[f],d=this._extractSubMesh(u,m);if(d){var v=h?"".concat(l):"".concat(l,"_").concat(f),y=new jt(r.next()).withData(d).withName(v).build();i.withMesh(y),i.withBuild(y.id,p),o.set(m,y)}}}}if(a&&a.length)for(var _=this._groupBy(a,(function(t){return t.sourceMesh})),g=0,b=Array.from(_.entries());g<b.length;g++){var w=b[g],T=w[0],M=w[1];if(M&&M.length)for(s=0;s<M.length;s++){c=M[s].getWorldMatrix();var x=T.subMeshes;for(f=0;f<x.length;f++){m=x[f];var S=o.get(m);S&&i.withBuild(S.id,this._handleBabylonTo3mfMatrixTransformToRef(c,at.Zero()))}}}return i.build()},e.prototype.ensureZipLibReadyAsync=function(){return p(this,void 0,void 0,(function(){var t=this;return h(this,(function(e){switch(e.label){case 0:return this._fflateReadyPromise?[4,this._fflateReadyPromise]:[3,2];case 1:case 3:return[2,e.sent()];case 2:return this._fflateReadyPromise=p(t,void 0,void 0,(function(){var t;return h(this,(function(e){switch(e.label){case 0:return(t=globalThis).fflate?[3,2]:[4,At.Tools.LoadScriptAsync(Xt.FFLATEUrl)];case 1:e.sent(),e.label=2;case 2:return[2,t.fflate]}}))})),[4,this._fflateReadyPromise]}}))}))},e.prototype._extractSubMesh=function(t,n){var r=t.getIndices();if(r){var i=t.getVerticesData(e._PositionKind);if(i){if(0==n.indexStart&&n.indexCount==r.length)return{positions:i,indices:r};for(var o=n.indexStart,a=new Map,s=[],u=new Uint32Array(n.indexCount),l=0;l<n.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}}}},e.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},e.prototype._handleBabylonTo3mfMatrixTransformToRef=function(t,n){var r=t.multiplyToRef(e._R_BJS_TO_3MF,At.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},e.DefaultOptions={unit:F.meter,exportInstances:!1},e._PositionKind="position",e._R_BJS_TO_3MF=At.Matrix.RotationX(Math.PI/2).multiply(At.Matrix.Scaling(1,-1,1)),e}(kt),Bt=void 0!==r.g?r.g:"undefined"!=typeof window?window:void 0;if(void 0!==Bt){var Et=[];for(var It in o)Et.indexOf(It)>-1||(Bt.BABYLON[It]=o[It],Et.push(It))}const Ft=a;return i.default})()));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-serializers",["babylonjs"],e):"object"==typeof exports?exports["babylonjs-serializers"]=e(require("babylonjs")):t.SERIALIZERS=e(t.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,t=>(()=>{"use strict";var e={597(e){e.exports=t}},n={};function r(t){var i=n[t];if(void 0!==i)return i.exports;var o=n[t]={exports:{}};return e[t](o,o.exports,r),o.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};r.d(i,{default:()=>zt});var o={};r.r(o),r.d(o,{AbstractThreeMfSerializer:()=>Dt,ContentTypeFileName:()=>tt,DefaultXmlSerializerFormatOptions:()=>N,DefaultXmlSerializerNumberOptions:()=>C,GetXmlFieldMeta:()=>T,GetXmlName:()=>M,IsQualifiedName:()=>m,Known3mfRelationshipTypes:()=>et,KnownI3mfContentType:()=>V,Matrix3d:()=>st,MatrixFormatter:()=>ut,ModelFileName:()=>J,NumberFormatter:()=>D,Object3dDirName:()=>H,OpenXmlContentTypesNamespace:()=>W,OpenXmlRelationshipsNamespace:()=>q,RelationshipDirName:()=>$,RelationshipFileName:()=>Y,ResolveFormatOptions:()=>k,ResolveNumberOptions:()=>O,ST_ObjectType:()=>Z,ST_Unit:()=>z,StringXmlWriter:()=>L,ThreeDimModelNamespace:()=>G,ThreeMf:()=>At,ThreeMfBase:()=>Tt,ThreeMfBaseMaterials:()=>wt,ThreeMfBuild:()=>Mt,ThreeMfComponent:()=>bt,ThreeMfComponents:()=>gt,ThreeMfComponentsBuilder:()=>jt,ThreeMfContentType:()=>rt,ThreeMfContentTypes:()=>nt,ThreeMfDocument:()=>at,ThreeMfDocumentBuilder:()=>kt,ThreeMfItem:()=>xt,ThreeMfMaterialBuilder:()=>Nt,ThreeMfMesh:()=>mt,ThreeMfMeshBuilder:()=>Ct,ThreeMfMeta:()=>ct,ThreeMfMetadataGroup:()=>pt,ThreeMfModel:()=>lt,ThreeMfModelBuilder:()=>Ot,ThreeMfObject:()=>ft,ThreeMfObjectBuilder:()=>St,ThreeMfRelationship:()=>ot,ThreeMfRelationships:()=>it,ThreeMfResources:()=>ht,ThreeMfSerializer:()=>Bt,ThreeMfSerializerGlobalConfiguration:()=>Rt,ThreeMfTriangle:()=>_t,ThreeMfTriangles:()=>yt,ThreeMfVertex:()=>vt,ThreeMfVertices:()=>dt,ToQualifiedString:()=>j,TokenType:()=>E,TriangleSetsNamespace:()=>Q,Utf8XmlWriterToBytes:()=>U,XmlAttr:()=>b,XmlBuilder:()=>K,XmlElem:()=>w,XmlIgnore:()=>g,XmlName:()=>_,XmlNameToParts:()=>S,XmlSerializer:()=>I});var a={};r.r(a),r.d(a,{AbstractThreeMfSerializer:()=>Dt,ContentTypeFileName:()=>tt,DefaultXmlSerializerFormatOptions:()=>N,DefaultXmlSerializerNumberOptions:()=>C,GetXmlFieldMeta:()=>T,GetXmlName:()=>M,IsQualifiedName:()=>m,Known3mfRelationshipTypes:()=>et,KnownI3mfContentType:()=>V,Matrix3d:()=>st,MatrixFormatter:()=>ut,ModelFileName:()=>J,NumberFormatter:()=>D,Object3dDirName:()=>H,OpenXmlContentTypesNamespace:()=>W,OpenXmlRelationshipsNamespace:()=>q,RelationshipDirName:()=>$,RelationshipFileName:()=>Y,ResolveFormatOptions:()=>k,ResolveNumberOptions:()=>O,ST_ObjectType:()=>Z,ST_Unit:()=>z,StringXmlWriter:()=>L,ThreeDimModelNamespace:()=>G,ThreeMf:()=>At,ThreeMfBase:()=>Tt,ThreeMfBaseMaterials:()=>wt,ThreeMfBuild:()=>Mt,ThreeMfComponent:()=>bt,ThreeMfComponents:()=>gt,ThreeMfComponentsBuilder:()=>jt,ThreeMfContentType:()=>rt,ThreeMfContentTypes:()=>nt,ThreeMfDocument:()=>at,ThreeMfDocumentBuilder:()=>kt,ThreeMfItem:()=>xt,ThreeMfMaterialBuilder:()=>Nt,ThreeMfMesh:()=>mt,ThreeMfMeshBuilder:()=>Ct,ThreeMfMeta:()=>ct,ThreeMfMetadataGroup:()=>pt,ThreeMfModel:()=>lt,ThreeMfModelBuilder:()=>Ot,ThreeMfObject:()=>ft,ThreeMfObjectBuilder:()=>St,ThreeMfRelationship:()=>ot,ThreeMfRelationships:()=>it,ThreeMfResources:()=>ht,ThreeMfSerializer:()=>Bt,ThreeMfSerializerGlobalConfiguration:()=>Rt,ThreeMfTriangle:()=>_t,ThreeMfTriangles:()=>yt,ThreeMfVertex:()=>vt,ThreeMfVertices:()=>dt,ToQualifiedString:()=>j,TokenType:()=>E,TriangleSetsNamespace:()=>Q,Utf8XmlWriterToBytes:()=>U,XmlAttr:()=>b,XmlBuilder:()=>K,XmlElem:()=>w,XmlIgnore:()=>g,XmlName:()=>_,XmlNameToParts:()=>S,XmlSerializer:()=>I});var s=function(t,e){return s=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])},s(t,e)};function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var l=function(){return l=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},l.apply(this,arguments)};function c(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 p(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 h(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 f(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 m(t){return"string"==typeof(null==t?void 0:t.name)}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var d=Symbol("__xml:meta$__"),v=Symbol("__xml:name$__");function y(t,e){var n,r=t.constructor;(null!==(n=r[d])&&void 0!==n?n:r[d]=[]).push(e)}function _(t){return function(e){e[v]=t}}function g(){return function(t,e){return y(t,{kind:"none",prop:e,ignore:!0})}}function b(t){return function(e,n){return y(e,l({kind:"attr",prop:n},t))}}function w(t){return function(e,n){return y(e,l({kind:"elem",prop:n},t))}}function T(t){var e,n;return null!==(n=null===(e=null==t?void 0:t.constructor)||void 0===e?void 0:e[d])&&void 0!==n?n:[]}function M(t){var e;return(null===(e=null==t?void 0:t.constructor)||void 0===e?void 0:e[v])||void 0}function x(t){return/^[A-Za-z_][A-Za-z0-9._-]*$/.test(t)}function S(t){if(m(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 x(r)&&x(i)?{ns:r,name:i}:{name:e}}function j(t,e){return e?"".concat(e,":").concat(t):t}var C=Object.freeze({eps:1e-6,maxDecimalsCap:15,trimTrailingZeros:!0,allowScientific:!1,snapNearZero:!0}),N=Object.freeze({number:C});function O(t){var e,n,r,i,o,a,s=null!==(e=null==t?void 0:t.eps)&&void 0!==e?e:C.eps;return{eps:s,maxDecimalsCap:null!==(n=null==t?void 0:t.maxDecimalsCap)&&void 0!==n?n:C.maxDecimalsCap,trimTrailingZeros:null!==(r=null==t?void 0:t.trimTrailingZeros)&&void 0!==r?r:C.trimTrailingZeros,fixedDecimals:null==t?void 0:t.fixedDecimals,allowScientific:null!==(i=null==t?void 0:t.allowScientific)&&void 0!==i?i:C.allowScientific,snapNearZero:null!==(o=null==t?void 0:t.snapNearZero)&&void 0!==o?o:C.snapNearZero,zeroThreshold:null!==(a=null==t?void 0:t.zeroThreshold)&&void 0!==a?a:s,perAttributeEps:null==t?void 0:t.perAttributeEps}}function k(t){return{number:O(null==t?void 0:t.number)}}var D=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 A(t){return t instanceof Date}function X(t){return"string"==typeof t}function R(t){return"number"==typeof t}function P(t){return"string"==typeof t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t||A(t)}function B(t){return"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t||A(t)}var E,I=function(){function t(t,e){this._ns=new Map,this._prefixCount=0,this._builder=t,this._format=k(e),this._nFmt=new D(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:M(t)))throw new Error("can not find name for given object");var n=S(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];B(o)||(X(o)?this._builder.text(o):this._writeObject(t,o,n))}else{var a=M(e);if(a){var s=S(a),u=this._getPrefix(s),l=j(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=T(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 _=y.some(function(t){return!0===t.ignore||"none"===t.kind});if(_)continue;for(var g=0,b=y;g<b.length;g++){var w=null!==(o=(c=b[g]).name)&&void 0!==o?o:c.prop.toLowerCase();if(w&&"attr"===c.kind){var M=null;if(R(v)&&this._nFmt&&(M=this._nFmt.toString(v)),c.formatter&&(M=new c.formatter(this._format).toString(v)),M=null!=M?M:v.toString()){var x=S(w),C=this._getPrefix(x),N=j(x.name,C);t.att(null,N,M)}}}}else B(v)||(X(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];P(a)||this._gatherNamespaces(a,e)}else{var s=M(t);s&&this._assignNamespace(s);for(var u=null!==(n=T(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 y=v[d],_=t[y];if(null!=_){var g=l.get(y);if(g){var b=g.some(function(t){return!0===t.ignore||"none"===t.kind});if(b)continue;for(var w=0,x=g;w<x.length;w++)(h=x[w]).name&&this._assignNamespace(h.name)}m.push(_)}}for(var S=0,j=m;S<j.length;S++){var C=j[S];P(C)||this._gatherNamespaces(C,e)}}},t.prototype._assignNamespace=function(t,e){var n=S(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}(),F=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"}(E||(E={}));var z,Z,K=function(){function t(t){this._ctxStack=[],this._d=0,this._w=t}return t.prototype.dec=function(t,e,n){return this._w.write(F.Dec),this._writeAttStr(F.VersionKeyword,t),e&&this._writeAttStr(F.EncodingKeyword,e),void 0!==n&&this._writeAttStr(F.StandaloneKeyword,n?"yes":"no"),this._w.write(F.Question,F.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===F.Xmlns)r.defaultNs=n,this._registerNamespace(r,"",n),this._writeAttStr(F.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=E.Attribute,this}var o=e;if(t){var a=this._ensurePrefixDeclared(r,t);o="".concat(a,":").concat(e)}return r.lastToken=E.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(F.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=E.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(F.OpenTag,F.Slash,t.name,F.CloseTag):this._w.write(F.Slash,F.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(F.Space,t,F.Equal,F.Quote,this._escAttr(e),F.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,"&").replace(/</g,"<").replace(/>/g,">")},t.prototype._escAttr=function(t){return this._escText(t).replace(/"/g,""").replace(/'/g,"'")},t.prototype._isXmlnsDecl=function(t,e){if(t)return t===F.Xmlns;var n=e.length,r=F.Xmlns.length;return n>=r&&e.startsWith(F.Xmlns)&&(e.length==r||e[r]==F.Semicolon)},t.prototype._registerNamespace=function(t,e,n){if(e===F.Xml||e===F.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(F.Xmlns,":").concat(r),e),this._registerNamespace(t,r,e),r},t.prototype._closeOpenTagIfNeeded=function(t){t.closed||(this._w.write(F.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}(),L=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}(),U=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}(),G="http://schemas.microsoft.com/3dmanufacturing/core/2015/02",Q="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"}(z||(z={})),function(t){t.model="model",t.solidsupport="solidsupport",t.support="support",t.surface="surface",t.other="other"}(Z||(Z={}));var V,W="http://schemas.openxmlformats.org/package/2006/content-types",q="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"}(V||(V={}));var $="_rels/",H="3D/",J="3dmodel.model",Y=".rels",tt="[Content_Types].xml",et=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}(),nt=function(){function t(){this.items=[]}return c([_({ns:W,name:"Types"})],t)}(),rt=function(){function t(t,e){this.ext=t,this.ct=e}return c([b({name:{ns:W,name:"Extension"}})],t.prototype,"ext",void 0),c([b({name:{ns:W,name:"ContentType"}})],t.prototype,"ct",void 0),c([_({ns:W,name:"Default"})],t)}(),it=function(){function t(){this.items=[]}return c([_({ns:q,name:"Relationships"})],t)}(),ot=function(){function t(t,e,n){this.id=t,this.type=e,this.target=n}return c([b({name:"Id"})],t.prototype,"id",void 0),c([b({name:"Type"})],t.prototype,"type",void 0),c([b({name:"Target"})],t.prototype,"target",void 0),c([_({ns:q,name:"Relationship"})],t)}(),at=function(t,e,n){this.contentTypes=t,this.relationships=e,this.model=n},st=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}(),ut=function(){function t(t){this.o=t,this._f=new D(t)}return t.prototype.toString=function(t){var e=this;return t.values.map(function(t){return e._f.toString(t)}).join(" ")},t}(),lt=function(){function t(){this.unit=z.millimeter}return t.KnownMeta=["Title","Designer","Description","Copyright","LicenseTerms","Rating","CreationDate","ModificationDate","Application"],c([b({name:"unit"})],t.prototype,"unit",void 0),c([b({name:"requiredextensions"})],t.prototype,"requiredextensions",void 0),c([b({name:"recommendedextensions"})],t.prototype,"recommendedextensions",void 0),c([_({ns:G,name:"model"})],t)}(),ct=function(){function t(t,e,n,r){this.name=t,this.value=e,this.preserve=n,this.type=r}return c([b({name:"name"})],t.prototype,"name",void 0),c([b({name:"preserve"})],t.prototype,"preserve",void 0),c([b({name:"type"})],t.prototype,"type",void 0),c([_({ns:G,name:"meta"})],t)}(),pt=function(){function t(){this.metadata=[]}return c([_({ns:G,name:"metadatagroup"})],t)}(),ht=function(){function t(){this.object=[]}return c([_({ns:G,name:"resources"})],t)}(),ft=function(){function t(t,e){void 0===e&&(e=Z.model),this.id=t,this.type=e}return c([b({name:"id"})],t.prototype,"id",void 0),c([b({name:"type"})],t.prototype,"type",void 0),c([b({name:"thumbnail"})],t.prototype,"thumbnail",void 0),c([b({name:"partnumber"})],t.prototype,"partnumber",void 0),c([b({name:"name"})],t.prototype,"name",void 0),c([b({name:"pid"})],t.prototype,"pid",void 0),c([b({name:"pindex"})],t.prototype,"pindex",void 0),c([_({ns:G,name:"object"})],t)}(),mt=function(){function t(t,e){this.vertices=null!=t?t:new dt,this.triangles=null!=e?e:new yt}return c([_({ns:G,name:"mesh"})],t)}(),dt=function(){function t(){this.vertex=[]}return c([_({ns:G,name:"vertices"})],t)}(),vt=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 c([b({name:"x"})],t.prototype,"x",void 0),c([b({name:"y"})],t.prototype,"y",void 0),c([b({name:"z"})],t.prototype,"z",void 0),c([_({ns:G,name:"vertex"})],t)}(),yt=function(){function t(){this.triangle=[]}return c([_({ns:G,name:"triangles"})],t)}(),_t=function(){function t(t,e,n){this.v1=t,this.v2=e,this.v3=n}return c([b({name:"v1"})],t.prototype,"v1",void 0),c([b({name:"v2"})],t.prototype,"v2",void 0),c([b({name:"v3"})],t.prototype,"v3",void 0),c([b({name:"p1"})],t.prototype,"p1",void 0),c([b({name:"p2"})],t.prototype,"p2",void 0),c([b({name:"p3"})],t.prototype,"p3",void 0),c([b({name:"pid"})],t.prototype,"pid",void 0),c([_({ns:G,name:"triangle"})],t)}(),gt=function(){function t(){this.component=[]}return c([_({ns:G,name:"components"})],t)}(),bt=function(){function t(t,e){this.objectid=t,this.transform=e}return c([b({name:"objectid"})],t.prototype,"objectid",void 0),c([b({name:"transform",formatter:ut})],t.prototype,"transform",void 0),c([_({ns:G,name:"component"})],t)}(),wt=function(){function t(t){this.base=[],this.id=t}return c([b({name:"id"})],t.prototype,"id",void 0),c([_({ns:G,name:"basematerials"})],t)}(),Tt=function(){function t(t,e){this.name=t,this.displaycolor=e}return c([b({name:"name"})],t.prototype,"name",void 0),c([b({name:"displaycolor"})],t.prototype,"displaycolor",void 0),c([_({ns:G,name:"base"})],t)}(),Mt=function(){function t(){this.item=[]}return c([_({ns:G,name:"build"})],t)}(),xt=function(){function t(t,e,n){this.objectid=t,this.transform=e,this.partnumber=n}return c([b({name:"objectid"})],t.prototype,"objectid",void 0),c([b({name:"transform",formatter:ut})],t.prototype,"transform",void 0),c([b({name:"partnumber"})],t.prototype,"partnumber",void 0),c([_({ns:G,name:"item"})],t)}(),St=function(){function t(t,e){this._object=new ft(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 ft(t,e)},t}(),jt=function(t){function e(e,n){void 0===n&&(n=Z.model);var r=t.call(this,e,n)||this;return r._object.content=new gt,r}return u(e,t),e.prototype.withComponent=function(t,e){return this._object.content.component.push(new bt(t,e)),this},e}(St),Ct=function(t){function e(e){return t.call(this,e,Z.model)||this}return u(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 mt(e,n)},e.prototype._buildVertices=function(t){var e=new dt;if(t)for(var n=0;n<t.length;){var r=t[n++],i=t[n++],o=t[n++],a=new vt(r,i,o);this._vh&&(a=this._vh(a)),e.vertex.push(a)}return e},e.prototype._buildTriangle=function(t){var e=new yt;if(t)for(var n=0;n<t.length;){var r=t[n++],i=t[n++],o=t[n++],a=new _t(r,i,o);this._th&&(a=this._th(a)),e.triangle.push(a)}return e},e}(St),Nt=function(){function t(t){this._m=new wt(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 Tt(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}(),Ot=function(){function t(){this._model=new lt,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 ct(t,e,n,r)),this},t.prototype.withMaterial=function(t){var e,n;return t instanceof Nt&&(t=t.build()),t&&(this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new ht,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 Ct&&(t=t.build()),this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new ht,this._model.resources.object.push(t),this},t.prototype.withComponents=function(t){var e;return t instanceof jt&&(t=t.build()),this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new ht,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 Mt,null===(i=this._model.build.item)||void 0===i||i.push(new xt(t,e,n)),this},t.prototype.withUnit=function(t){return this._model.unit=t,this},t.prototype.reset=function(){return this._model=new lt,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(lt.KnownMeta.map(function(t){return t.toLowerCase()})),t}(),kt=function(){function t(){}return t.prototype.withContentType=function(t){this._cts||(this._cts=new nt);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 it);var e=this._rs.items;return e.some(function(e){return e.id===t.id})||e.push(t),this.withContentType(new rt("rels",V.Relationships)),this},t.prototype.withModel=function(t){return t instanceof Ot&&(t=t.build()),this._m=t,this.withContentType(new rt("model",V.Model)),this},t.prototype.build=function(){if(!this._m)throw new Error("Invalid state: you Must provide at least a model.");var t="".concat(H).concat(J);if(!this._rs){var e="/".concat(t);this.withRelationship(new ot("rel".concat(0),et.ThreeDimModel,e))}return new at(this._cts,this._rs,this._m)},t}(),Dt=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 p(this,void 0,void 0,function(){var n,r,i,o,a,s,u;return h(this,function(l){switch(l.label){case 0:return[4,this.ensureZipLibReadyAsync()];case 1:if(!(n=l.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 U(a),u=new K(s).dec("1.0","UTF-8");new I(u).serialize(n),s.finish()},(s=this.toDocument.apply(this,e))?(u=new r(t),a(u,tt,s.contentTypes),a(u,"".concat($).concat(Y),s.relationships),a(u,"".concat(H).concat(J),s.model),u.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 Ot).withUnit(null!==(e=null===(t=this._o)||void 0===t?void 0:t.unit)&&void 0!==e?e:z.millimeter);if(this.options.metadata)for(var o in this.options.metadata)i.withMetaData(o,this.options.metadata[o]);return(new kt).withModel(this.toModel.apply(this,f([i],n,!1))).build()},t}(),At=function(){function t(){}return t.SerializeToMemoryAsync=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return p(this,void 0,void 0,function(){var n,r,i,o,a,s,u,l;return h(this,function(c){switch(c.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,f([i],e,!1))];case 1:if(c.sent(),!r)return[2,void 0];for(o=new Uint8Array(r),a=0,s=0,u=n;s<u.length;s++)l=u[s],o.set(l,a),a+=l.length;return[2,o]}})})},t}(),Xt=r(597),Rt=function(){function t(){}return t.FFLATEUrl="https://unpkg.com/fflate@0.8.2",t}(),Pt=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}(),Bt=function(t){function e(n){return void 0===n&&(n={}),t.call(this,l(l({},e.DefaultOptions),n))||this}return u(e,t),e.prototype.toModel=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];e=e.filter(function(t){return t instanceof Xt.Mesh||t instanceof Xt.InstancedMesh});for(var r=new Pt,i=t,o=new Map,a=this.options.exportInstances?[]:null,s=0;s<e.length;s++){var u=e[s];if(u instanceof Xt.InstancedMesh)null==a||a.push(u);else{var l=u.name||"mesh".concat(s),c=u.getWorldMatrix(),p=this._handleBabylonTo3mfMatrixTransformToRef(c,st.Zero());if(void 0!==(x=u.subMeshes))for(var h=1==x.length,f=0;f<x.length;f++){var m=x[f],d=this._extractSubMesh(u,m);if(d){var v=h?"".concat(l):"".concat(l,"_").concat(f),y=new Ct(r.next()).withData(d).withName(v).build();i.withMesh(y),i.withBuild(y.id,p),o.set(m,y)}}}}if(a&&a.length)for(var _=this._groupBy(a,function(t){return t.sourceMesh}),g=0,b=Array.from(_.entries());g<b.length;g++){var w=b[g],T=w[0],M=w[1];if(M&&M.length)for(s=0;s<M.length;s++){c=M[s].getWorldMatrix();var x=T.subMeshes;for(f=0;f<x.length;f++){m=x[f];var S=o.get(m);S&&i.withBuild(S.id,this._handleBabylonTo3mfMatrixTransformToRef(c,st.Zero()))}}}return i.build()},e.prototype.ensureZipLibReadyAsync=function(){return p(this,void 0,void 0,function(){var t=this;return h(this,function(e){switch(e.label){case 0:return this._fflateReadyPromise?[4,this._fflateReadyPromise]:[3,2];case 1:case 3:return[2,e.sent()];case 2:return this._fflateReadyPromise=p(t,void 0,void 0,function(){var t;return h(this,function(e){switch(e.label){case 0:return(t=globalThis).fflate?[3,2]:[4,Xt.Tools.LoadScriptAsync(Rt.FFLATEUrl)];case 1:e.sent(),e.label=2;case 2:return[2,t.fflate]}})}),[4,this._fflateReadyPromise]}})})},e.prototype._extractSubMesh=function(t,n){var r=t.getIndices();if(r){var i=t.getVerticesData(e._PositionKind);if(i){if(0==n.indexStart&&n.indexCount==r.length)return{positions:i,indices:r};for(var o=n.indexStart,a=new Map,s=[],u=new Uint32Array(n.indexCount),l=0;l<n.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}}}},e.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},e.prototype._handleBabylonTo3mfMatrixTransformToRef=function(t,n){var r=t.multiplyToRef(e._R_BJS_TO_3MF,Xt.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},e.DefaultOptions={unit:z.meter,exportInstances:!1},e._PositionKind="position",e._R_BJS_TO_3MF=Xt.Matrix.RotationX(Math.PI/2).multiply(Xt.Matrix.Scaling(1,-1,1)),e}(Dt),Et=void 0!==r.g?r.g:"undefined"!=typeof window?window:void 0;if(void 0!==Et){var It=[];for(var Ft in o)It.indexOf(Ft)>-1||(Et.BABYLON[Ft]=o[Ft],It.push(Ft))}const zt=a;return i.default})());
|
|
2
2
|
//# sourceMappingURL=babylon.threemfSerializer.min.js.map
|