babylonjs-serializers 9.4.1 → 9.5.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.min.js +2 -2
- package/babylon.glTF2Serializer.min.js.map +1 -1
- package/babylon.objSerializer.min.js +2 -2
- package/babylon.objSerializer.min.js.map +1 -1
- package/babylon.stlSerializer.min.js +2 -2
- package/babylon.stlSerializer.min.js.map +1 -1
- package/babylon.threemfSerializer.min.js +2 -2
- package/babylon.threemfSerializer.min.js.map +1 -1
- package/babylon.usdzSerializer.min.js +2 -2
- package/babylon.usdzSerializer.min.js.map +1 -1
- package/babylonjs.serializers.js +2 -2
- package/babylonjs.serializers.js.map +1 -0
- package/babylonjs.serializers.min.js +2 -2
- package/babylonjs.serializers.min.js.map +1 -1
- package/package.json +6 -11
- package/rollup.config.umd.mjs +25 -0
- package/babylon.glTF2Serializer.js +0 -2
- package/babylon.objSerializer.js +0 -2
- package/babylon.stlSerializer.js +0 -2
- package/babylon.threemfSerializer.js +0 -2
- package/babylon.usdzSerializer.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"
|
|
2
|
-
//# sourceMappingURL=babylon.objSerializer.min.js.map
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("babylonjs")):"function"==typeof define&&define.amd?define(["exports","babylonjs"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).BABYLON=e.BABYLON||{},e.BABYLON)}(this,function(e,t){"use strict";var o=function(){function e(){}return e.OBJ=function(e,o,r,i){var n=[],a=1,s=1;o&&(r||(r="mat"),n.push("mtllib "+r+".mtl"));for(var u=0;u<e.length;u++){var l=e[u],p=l.name||"mesh".concat(u,"}");n.push("o ".concat(p));var f=null;if(i){var d=l.computeWorldMatrix(!0);f=new t.Matrix,d.invertToRef(f),l.bakeTransformIntoVertices(d)}if(o){var m=l.material;m&&n.push("usemtl "+m.id)}var h=l.geometry;if(h){var c=h.getVerticesData("position"),x=h.getVerticesData("normal"),g=h.getVerticesData("uv"),v=h.getIndices(),b=0,T=0;if(c&&v){for(var _=e[0].getScene().useRightHandedSystem?1:-1,y=0;y<c.length;y+=3)n.push("v "+c[y]*_+" "+c[y+1]+" "+c[y+2]),b++;if(null!=x)for(y=0;y<x.length;y+=3)n.push("vn "+x[y]*_+" "+x[y+1]+" "+x[y+2]);if(null!=g)for(y=0;y<g.length;y+=2)n.push("vt "+g[y]+" "+g[y+1]),T++;var F=["","",""],C=(l.material||l.getScene().defaultMaterial)._getEffectiveOrientation(l)===t.Material.ClockWiseSideOrientation?[2,1]:[1,2],B=C[0],O=C[1];for(y=0;y<v.length;y+=3){var S=[String(v[y]+a),String(v[y+B]+a),String(v[y+O]+a)],w=[String(v[y]+s),String(v[y+B]+s),String(v[y+O]+s)],K=S,N=null!=g?w:F,j=null!=x?S:F;n.push("f "+K[0]+"/"+N[0]+"/"+j[0]+" "+K[1]+"/"+N[1]+"/"+j[1]+" "+K[2]+"/"+N[2]+"/"+j[2])}i&&f&&l.bakeTransformIntoVertices(f),a+=b,s+=T}else t.Tools.Warn("There are no position vertices or indices on the mesh!")}else t.Tools.Warn("No geometry is present on the mesh")}return n.join("\n")},e.MTL=function(e){var t=[],o=e.material;return t.push("newmtl mat1"),t.push(" Ns "+o.specularPower.toFixed(4)),t.push(" Ni 1.5000"),t.push(" d "+o.alpha.toFixed(4)),t.push(" Tr 0.0000"),t.push(" Tf 1.0000 1.0000 1.0000"),t.push(" illum 2"),t.push(" Ka "+o.ambientColor.r.toFixed(4)+" "+o.ambientColor.g.toFixed(4)+" "+o.ambientColor.b.toFixed(4)),t.push(" Kd "+o.diffuseColor.r.toFixed(4)+" "+o.diffuseColor.g.toFixed(4)+" "+o.diffuseColor.b.toFixed(4)),t.push(" Ks "+o.specularColor.r.toFixed(4)+" "+o.specularColor.g.toFixed(4)+" "+o.specularColor.b.toFixed(4)),t.push(" Ke "+o.emissiveColor.r.toFixed(4)+" "+o.emissiveColor.g.toFixed(4)+" "+o.emissiveColor.b.toFixed(4)),o.ambientTexture&&t.push(" map_Ka "+o.ambientTexture.name),o.diffuseTexture&&t.push(" map_Kd "+o.diffuseTexture.name),o.specularTexture&&t.push(" map_Ks "+o.specularTexture.name),o.bumpTexture&&t.push(" map_bump -imfchan z "+o.bumpTexture.name),o.opacityTexture&&t.push(" map_d "+o.opacityTexture.name),t.join("\n")},e}(),r={__proto__:null,OBJExport:o},i="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==i)for(var n in r)i.BABYLON[n]=r[n];var a={__proto__:null,OBJExport:o};e.default=a,e.serializers=a,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
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,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,E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AMF,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/../../../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":""}
|
|
1
|
+
{"version":3,"file":"babylon.objSerializer.min.js","sources":["../../../../../../../dev/serializers/src/OBJ/objSerializer.ts","../../../../../../../dev/serializers/src/legacy/legacy-objSerializer.ts"],"sourcesContent":[null,null],"names":["OBJExport","OBJ","meshes","materials","matlibname","globalposition","output","v","textureV","push","j","length","mesh","objectName","name","concat","inverseTransform","transform","computeWorldMatrix","Matrix","invertToRef","bakeTransformIntoVertices","mat","material","id","g","geometry","trunkVerts","getVerticesData","trunkNormals","trunkUV","trunkFaces","getIndices","currentV","currentTextureV","handednessSign","getScene","useRightHandedSystem","i","blanks","_a","defaultMaterial","_getEffectiveOrientation","Material","ClockWiseSideOrientation","offset1","offset2","indices","String","textureIndices","facePositions","faceUVs","faceNormals","Tools","Warn","join","MTL","m","specularPower","toFixed","alpha","ambientColor","r","b","diffuseColor","specularColor","emissiveColor","ambientTexture","diffuseTexture","specularTexture","bumpTexture","opacityTexture","GlobalObject","global","window","undefined","serializer","Serializers","BABYLON"],"mappings":"sSAWA,IAAAA,EAAA,WAAA,SAAAA,IA8LA,CAAA,OArLkBA,EAAAC,IAAd,SAAkBC,EAAgBC,EAAqBC,EAAqBC,GACxE,IAAMC,EAAmB,GACrBC,EAAI,EAEJC,EAAW,EAEXL,IACKC,IACDA,EAAa,OAEjBE,EAAOG,KAAK,UAAYL,EAAa,SAEzC,IAAK,IAAIM,EA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ined"!=typeof module?t(exports,require("babylonjs")):"function"==typeof define&&define.amd?define(["exports","babylonjs"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).BABYLON=e.BABYLON||{},e.BABYLON)}(this,function(e,t){"use strict";var n=function(){function e(){}return e.CreateSTL=function(e,n,r,o,i,a,s,f){void 0===n&&(n=!0),void 0===r&&(r="stlmesh"),void 0===o&&(o=!1),void 0===i&&(i=!0),void 0===a&&(a=!1),void 0===s&&(s=!1),void 0===f&&(f=!1);var d=function(e,n,r){var o=[3*e[r],3*e[r+1],3*e[r+2]],i=[new t.Vector3(n[o[0]],n[o[0]+2],n[o[0]+1]),new t.Vector3(n[o[1]],n[o[1]+2],n[o[1]+1]),new t.Vector3(n[o[2]],n[o[2]+2],n[o[2]+1])],a=i[0].subtract(i[1]),s=i[2].subtract(i[1]);return{v:i,n:t.Vector3.Cross(s,a).normalize()}},l=function(e,t,n,r){return t=v(e,t,n.x,r),t=v(e,t,n.y,r),v(e,t,n.z,r)},v=function(e,t,n,r){return e.setFloat32(t,n,r),t+4},c=function(e){if(s){var n=e;e instanceof t.InstancedMesh&&(n=e.sourceMesh);var r=n.getVerticesData(t.VertexBuffer.PositionKind,!0,!0);if(!r)return[];var o=t.Vector3.Zero(),i=void 0;for(i=0;i<r.length;i+=3)t.Vector3.TransformCoordinatesFromFloatsToRef(r[i],r[i+1],r[i+2],e.computeWorldMatrix(!0),o).toArray(r,i);return r}return e.getVerticesData(t.VertexBuffer.PositionKind)||[]};s&&(a=!0);var u="",p=0,y=0;if(o){for(var m=0;m<e.length;m++)p+=(w=(b=e[m]).getIndices())?w.length/3:0;var x=new ArrayBuffer(84+50*p);y+=80,(u=new DataView(x)).setUint32(y,p,i),y+=4}else f||(u="solid stlmesh\r\n");for(m=0;m<e.length;m++){var b=e[m];!o&&f&&(u+="solid "+b.name+"\r\n"),!a&&b instanceof t.Mesh&&b.bakeCurrentTransformIntoVertices();for(var h=c(b),w=b.getIndices()||[],g=0;g<w.length;g+=3){var B=d(w,h,g);o?(y=l(u,y,B.n,i),y=l(u,y,B.v[0],i),y=l(u,y,B.v[1],i),y=l(u,y,B.v[2],i),y+=2):(u+="\tfacet normal "+B.n.x+" "+B.n.y+" "+B.n.z+"\r\n",u+="\t\touter loop\r\n",u+="\t\t\tvertex "+B.v[0].x+" "+B.v[0].y+" "+B.v[0].z+"\r\n",u+="\t\t\tvertex "+B.v[1].x+" "+B.v[1].y+" "+B.v[1].z+"\r\n",u+="\t\t\tvertex "+B.v[2].x+" "+B.v[2].y+" "+B.v[2].z+"\r\n",u+="\t\tendloop\r\n",u+="\tendfacet\r\n")}!o&&f&&(u+="endsolid "+name+"\r\n")}if(o||f||(u+="endsolid stlmesh"),n){var V=document.createElement("a"),_=new Blob([u],{type:"application/octet-stream"});V.href=window.URL.createObjectURL(_),V.download=r+".stl",V.click()}return u},e}(),r={__proto__:null,STLExport:n},o="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==o)for(var i in r)o.BABYLON[i]=r[i];var a={__proto__:null,STLExport:n};e.default=a,e.serializers=a,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
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,KAAQC,G,iCCT1FP,EAAOD,QAAUQ,C,GCCbC,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,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0B,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/../../../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
|
+
{"version":3,"file":"babylon.stlSerializer.min.js","sources":["../../../../../../../dev/serializers/src/stl/stlSerializer.ts","../../../../../../../dev/serializers/src/legacy/legacy-stlSerializer.ts"],"sourcesContent":[null,null],"names":["STLExport","CreateSTL","meshes","download","fileName","binary","isLittleEndian","doNotBakeTransform","supportInstancedMeshes","exportIndividualMeshes","getFaceData","indices","vertices","i","id","v","Vector3","p1p2","subtract","p3p2","n","Cross","normalize","dataview","offset","vector","writeFloat","x","y","z","value","setFloat32","mesh","sourceMesh","InstancedMesh","data_1","getVerticesData","VertexBuffer","PositionKind","temp","Zero","index","length","TransformCoordinatesFromFloatsToRef","computeWorldMatrix","toArray","data","faceCount","getIndices","buffer","DataView","setUint32","name","Mesh","bakeCurrentTransformIntoVertices","i_1","fd","writeVector","GlobalObject","global","window","undefined","serializer","Serializers","BABYLON"],"mappings":"sSAQA,IAAAA,EAAA,WAAA,SAAAA,IAqJA,QAxIkBA,EAAAC,UAAd,SACIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,QANA,IAAAN,IACAA,GAAA,QAEA,IAAAC,IACAA,EAAA,gBAEA,IAAAC,IAIMA,WAEQ,IAAVC,IACIA,GAAY,QAEA,IAAZC,OACF,QAE2B,IAA7BC,IACAA,GAAwB,QAG1B,IAAAC,IAEIA,GAAwB,GAE1B,IAAAC,EAAS,SAAWC,EAAUC,EAAQC,GACtC,IAAAC,EAAO,CAAW,EAAXH,EAAWE,GAAyB,EAAjBF,EAAQE,EAAE,GAA0B,EAAhBF,EAAAE,EAAA,IAChDE,EAAA,CAEI,IAAAC,EAAAA,QAAaJ,EAAUE,EAAA,IAAeF,EAAgBE,EAAA,GAAe,GAAAF,EAAuBE,EAAA,GAAA,IAC9F,IAAQE,EAAAA,UAAYF,EAAQ,IAAKF,EAAEE,EAAA,GAAe,GAACF,EAAAE,EAAA,GAAA,IACnD,IAAOE,EAAAA,QAASJ,EAAEE,EAAA,IAAAF,EAAAE,EAAA,GAAA,GAAAF,EAAAE,EAAA,GAAA,KAGhBG,EAAAF,EAAA,GAAeG,SAAGH,EAAA,IAChBI,EAAAJ,EAAA,GAAAG,SAAAH,MAEA,MAAA,CAAIA,EAAIA,EAAAK,EADJJ,EAAAA,QAAAK,MAAaF,EAAKF,GAAAK,YAElB,IACH,SAAAC,EAAAC,EAAAC,EAAAnB,GAGG,OAFJkB,EAA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GAAM,EAAG,KACzCC,EAAI9C,IAAsBE,EAAA2C,GAC1BlD,GACHmB,EAAAiC,EAAAX,EAAAtB,EAAAgC,EAAApC,EAAAd,GACJkB,EAAAiC,EAAAX,EAAAtB,EAAAgC,EAAAzC,EAAA,GAAAT,GACIkB,EAAUiC,EAAAX,EAAAtB,EAAyBgC,EAAAzC,EAAA,GAAAT,GAChCkB,EAAIiC,EAAcX,IAAcU,EAAAzC,EAAA,GAAAT,GACvCkB,GAAA,IAIOsB,qBAAmBU,EAAApC,EAAAO,EAAA,IAAA6B,EAAApC,EAAAQ,EAAA,IAAA4B,EAAApC,EAAAS,EAAA,OAC9BiB,GAAA,qBAEWA,GAAG,gBAAAU,EAAAzC,EAAA,GAAAY,EAAA,IAAA6B,EAAAzC,EAAA,GAAAa,EAAA,IAAA4B,EAAAzC,EAAA,GAAAc,EAAA,OACDiB,GAAQ,gBAAkBU,EAAEzC,EAAA,GAAAY,EAAA,IAAA6B,EAAAzC,EAAA,GAAAa,EAAA,IAAA4B,EAAAzC,EAAA,GAAAc,EAAA,OAC5BiB,GAAO,gBAAmBU,EAAEzC,EAAA,GAAAY,EAAA,IAAA6B,EAAAzC,EAAA,GAAAa,EAA4B,IAAE4B,EAAAzC,EAAA,GAAAc,EAAA,OAC9DiB,GAAU,kBACdA,GAAW,iBAEhB,KAEWrC,IACfqC,GAAA,YAAAM,KAAA,OACJ,0OCtJKM,EAAiC,oBAAXC,OAAyBA,OAA2B,oBAAXC,OAAyBA,YAASC,EACvG,QAA4B,IAAjBH,EACP,IAAK,IAAMI,KAAcC,EACfL,EAAcM,QAAQF,GAAoBC,EAAaD"}
|
|
@@ -1,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:()=>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
|
-
//# sourceMappingURL=babylon.threemfSerializer.min.js.map
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("babylonjs")):"function"==typeof define&&define.amd?define(["exports","babylonjs"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).BABYLON=t.BABYLON||{},t.BABYLON)}(this,function(t,e){"use strict";var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},n(t,e)};function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var i=function(){return i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},i.apply(this,arguments)};function o(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a}function a(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())})}function s(t,e){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function u(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}function l(t){return"string"==typeof(null==t?void 0:t.name)}"function"==typeof SuppressedError&&SuppressedError;var c=Symbol("__xml:meta$__"),p=Symbol("__xml:name$__");function h(t,e){var n,r=t.constructor;(null!==(n=r[c])&&void 0!==n?n:r[c]=[]).push(e)}function f(t){return function(e){e[p]=t}}function m(){return function(t,e){return h(t,{kind:"none",prop:e,ignore:!0})}}function d(t){return function(e,n){return h(e,i({kind:"attr",prop:n},t))}}function v(t){return function(e,n){return h(e,i({kind:"elem",prop:n},t))}}function _(t){var e,n;return null!==(n=null===(e=null==t?void 0:t.constructor)||void 0===e?void 0:e[c])&&void 0!==n?n:[]}function y(t){var e;return(null===(e=null==t?void 0:t.constructor)||void 0===e?void 0:e[p])||void 0}function g(t){return/^[A-Za-z_][A-Za-z0-9._-]*$/.test(t)}function w(t){if(l(t))return t;var e=(null!=t?t:"").trim();if(!e)return{name:""};var n=e.indexOf(":");if(-1===n)return{name:e};if(-1!==e.indexOf(":",n+1))return{name:e};var r=e.slice(0,n),i=e.slice(n+1);return g(r)&&g(i)?{ns:r,name:i}:{name:e}}function b(t,e){return e?"".concat(e,":").concat(t):t}var T=Object.freeze({eps:1e-6,maxDecimalsCap:15,trimTrailingZeros:!0,allowScientific:!1,snapNearZero:!0}),M=Object.freeze({number:T});function x(t){var e,n,r,i,o,a,s=null!==(e=null==t?void 0:t.eps)&&void 0!==e?e:T.eps;return{eps:s,maxDecimalsCap:null!==(n=null==t?void 0:t.maxDecimalsCap)&&void 0!==n?n:T.maxDecimalsCap,trimTrailingZeros:null!==(r=null==t?void 0:t.trimTrailingZeros)&&void 0!==r?r:T.trimTrailingZeros,fixedDecimals:null==t?void 0:t.fixedDecimals,allowScientific:null!==(i=null==t?void 0:t.allowScientific)&&void 0!==i?i:T.allowScientific,snapNearZero:null!==(o=null==t?void 0:t.snapNearZero)&&void 0!==o?o:T.snapNearZero,zeroThreshold:null!==(a=null==t?void 0:t.zeroThreshold)&&void 0!==a?a:s,perAttributeEps:null==t?void 0:t.perAttributeEps}}function S(t){return{number:x(null==t?void 0:t.number)}}var C=function(){function t(t){if(this.o=t,this._o=t.number,!Number.isFinite(this._o.eps)||this._o.eps<=0)throw new Error("opts.eps must be a finite, positive number")}return t.prototype.toString=function(t){var e,n,r,i;if(!Number.isFinite(t))throw new Error("Cannot format non-finite number: ".concat(t));var o,a=this._o,s=this._clampInt(null!==(e=a.maxDecimalsCap)&&void 0!==e?e:15,0,20),u=null===(n=a.trimTrailingZeros)||void 0===n||n,l=null===(r=a.snapNearZero)||void 0===r||r,c=null!==(i=a.zeroThreshold)&&void 0!==i?i:a.eps,p=1/a.eps,h=Math.round(t*p)/p;if(Object.is(h,-0)&&(h=0),l&&Math.abs(h)<=c&&(h=0),o=void 0!==a.fixedDecimals?this._clampInt(a.fixedDecimals,0,s):this._clampInt(Math.ceil(-Math.log10(a.eps)),0,s),a.allowScientific,0===o)return String(Math.trunc(h));var f=h.toFixed(o);if(u&&void 0===a.fixedDecimals&&(f=f.replace(/(\.\d*?[1-9])0+$/,"$1").replace(/\.0+$/,"").replace(/\.$/,"")),/[eE]/.test(f))throw new Error("Scientific notation not allowed in XML output: ".concat(f));return f},t.prototype._clampInt=function(t,e,n){return Number.isFinite(t)?(t=Math.trunc(t),Math.max(e,Math.min(n,t))):e},t}();function N(t){return t instanceof Date}function j(t){return"string"==typeof t}function O(t){return"number"==typeof t}function k(t){return"string"==typeof t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t||N(t)}function D(t){return"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t||N(t)}var A,X=function(){function t(t,e){this._ns=new Map,this._prefixCount=0,this._builder=t,this._format=S(e),this._nFmt=new C(this._format)}return t.prototype.withNamespace=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=0,r=t;n<r.length;n++){var i=r[n];this._assignNamespace(i)}return this},t.prototype.serialize=function(t,e){if(!(e=null!=e?e:y(t)))throw new Error("can not find name for given object");var n=w(e);n.ns&&this._assignNamespace(n.ns,"xmlns"),this._gatherNamespaces(t,new WeakSet);for(var r=this._builder.ele(null,n.name),i=0,o=Array.from(this._ns.entries());i<o.length;i++){var a=o[i],s=a[0],u=a[1];r.att("xmlns",u,s)}this._writeObjectContent(r,t,(new WeakSet).add(t)),this._builder.end()},t.prototype._writeObject=function(t,e,n){if(!n.has(e))if(n.add(e),Array.isArray(e))for(var r=0,i=e;r<i.length;r++){var o=i[r];D(o)||(j(o)?this._builder.text(o):this._writeObject(t,o,n))}else{var a=y(e);if(a){var s=w(a),u=this._getPrefix(s),l=b(s.name,u);t.ele(null,l),this._writeObjectContent(t,e,n),this._builder.end()}}},t.prototype._getPrefix=function(t){if(t.ns){var e=this._ns.get(t.ns.toLowerCase());if("xmlns"!==e)return e}},t.prototype._writeObjectContent=function(t,e,n){for(var r,i,o,a=null!==(r=_(e))&&void 0!==r?r:[],s=new Map,u=0,l=a;u<l.length;u++){var c=l[u],p=null!==(i=s.get(c.prop))&&void 0!==i?i:[];p.push(c),s.set(c.prop,p)}for(var h=Object.keys(e).sort(function(t,e){var n,r,i=(null!==(n=s.get(t))&&void 0!==n?n:[]).some(function(t){return"attr"===t.kind}),o=(null!==(r=s.get(e))&&void 0!==r?r:[]).some(function(t){return"attr"===t.kind});return i===o?0:i?-1:1}),f=0,m=h;f<m.length;f++){var d=m[f],v=e[d];if(null!=v){var y=s.get(d);if(y){var g=y.some(function(t){return!0===t.ignore||"none"===t.kind});if(g)continue;for(var T=0,M=y;T<M.length;T++){var x=null!==(o=(c=M[T]).name)&&void 0!==o?o:c.prop.toLowerCase();if(x&&"attr"===c.kind){var S=null;if(O(v)&&this._nFmt&&(S=this._nFmt.toString(v)),c.formatter&&(S=new c.formatter(this._format).toString(v)),S=null!=S?S:v.toString()){var C=w(x),N=this._getPrefix(C),k=b(C.name,N);t.att(null,k,S)}}}}else D(v)||(j(v)?this._builder.text(v):this._writeObject(t,v,n))}}},t.prototype._gatherNamespaces=function(t,e){var n,r;if(!e.has(t))if(e.add(t),Array.isArray(t))for(var i=0,o=t;i<o.length;i++){var a=o[i];k(a)||this._gatherNamespaces(a,e)}else{var s=y(t);s&&this._assignNamespace(s);for(var u=null!==(n=_(t))&&void 0!==n?n:[],l=new Map,c=0,p=u;c<p.length;c++){var h=p[c],f=null!==(r=l.get(h.prop))&&void 0!==r?r:[];f.push(h),l.set(h.prop,f)}for(var m=[],d=0,v=Object.keys(t);d<v.length;d++){var g=v[d],w=t[g];if(null!=w){var b=l.get(g);if(b){var T=b.some(function(t){return!0===t.ignore||"none"===t.kind});if(T)continue;for(var M=0,x=b;M<x.length;M++)(h=x[M]).name&&this._assignNamespace(h.name)}m.push(w)}}for(var S=0,C=m;S<C.length;S++){var N=C[S];k(N)||this._gatherNamespaces(N,e)}}},t.prototype._assignNamespace=function(t,e){var n=w(t);if(null==n?void 0:n.ns){var r=n.ns.toLowerCase();this._ns.get(r)||this._ns.set(r,null!=e?e:this._buildNsPrefix(r))}else"xmlns"===e&&(r=n.name.toLowerCase(),this._ns.get(r)||this._ns.set(r,null!=e?e:this._buildNsPrefix(r)))},t.prototype._buildNsPrefix=function(t){var e,n=!1;do{e="ns".concat(this._prefixCount++);for(var r=0,i=Array.from(this._ns.values());r<i.length;r++)if(i[r]===e){n=!0;break}}while(n);return e},t}(),R=function(){function t(){}return t.OpenTag="<",t.CloseTag=">",t.Slash="/",t.Question="?",t.Quote='"',t.Equal="=",t.Space=" ",t.Semicolon=":",t.Dec="<?xml",t.Xml="xml",t.Xmlns="xmlns",t.Xsi="xsi",t.VersionKeyword="version",t.EncodingKeyword="encoding",t.StandaloneKeyword="standalone",t}();!function(t){t[t.Declaration=0]="Declaration",t[t.Tag=1]="Tag",t[t.Attribute=2]="Attribute",t[t.Text=3]="Text"}(A||(A={}));var B,P,E=function(){function t(t){this._ctxStack=[],this._d=0,this._w=t}return t.prototype.dec=function(t,e,n){return this._w.write(R.Dec),this._writeAttStr(R.VersionKeyword,t),e&&this._writeAttStr(R.EncodingKeyword,e),void 0!==n&&this._writeAttStr(R.StandaloneKeyword,n?"yes":"no"),this._w.write(R.Question,R.CloseTag),this},t.prototype.att=function(t,e,n){var r=this._peekContext();if(!r)throw new Error("att() without open element");if(r.closed)throw new Error("att() after start tag closed for <".concat(r.name,">"));if(this._isXmlnsDecl(t,e)){if(e===R.Xmlns)r.defaultNs=n,this._registerNamespace(r,"",n),this._writeAttStr(R.Xmlns,n);else if(t)this._registerNamespace(r,e,n),this._writeAttStr("".concat(t,":").concat(e),n);else{var i=e.slice(6);this._registerNamespace(r,i,n),this._writeAttStr(e,n)}return r.lastToken=A.Attribute,this}var o=e;if(t){var a=this._ensurePrefixDeclared(r,t);o="".concat(a,":").concat(e)}return r.lastToken=A.Attribute,this._writeAttStr(o,n),this},t.prototype.ele=function(t,e){var n,r=this._peekContext();r&&this._closeOpenTagIfNeeded(r);var i=e;if(t){var o=null!==(n=this._lookupPrefix(t))&&void 0!==n?n:t;i="".concat(o,":").concat(e)}return this._pushContext(i,++this._d),this._w.write(R.OpenTag,i),this},t.prototype.text=function(t){var e=this._peekContext();if(!e)throw new Error("text() without open element");return this._closeOpenTagIfNeeded(e),e.lastToken=A.Text,this._w.write(this._escText(t)),this},t.prototype.end=function(){var t=this._popContext();return t&&(this._d--,t.closed?this._w.write(R.OpenTag,R.Slash,t.name,R.CloseTag):this._w.write(R.Slash,R.CloseTag)),this},t.prototype._pushContext=function(e,n){var r=new t.Context(e,n);return this._ctxStack.push(r),r},t.prototype._popContext=function(){return this._ctxStack.pop()},t.prototype._peekContext=function(){return this._ctxStack[this._ctxStack.length-1]},Object.defineProperty(t.prototype,"_contextDepth",{get:function(){return this._ctxStack.length},enumerable:!1,configurable:!0}),t.prototype._writeAttStr=function(t,e){this._w.write(R.Space,t,R.Equal,R.Quote,this._escAttr(e),R.Quote)},t.prototype._lookupPrefix=function(t){var e,n=this._ctxStack.length-1;if(n>=0)do{var r=null===(e=this._ctxStack[n--].ns2prefix)||void 0===e?void 0:e.get(t);if(r)return r}while(n>=0)},t.prototype._escText=function(t){return t.replace(/&/g,"&").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===R.Xmlns;var n=e.length,r=R.Xmlns.length;return n>=r&&e.startsWith(R.Xmlns)&&(e.length==r||e[r]==R.Semicolon)},t.prototype._registerNamespace=function(t,e,n){if(e===R.Xml||e===R.Xmlns)throw new Error("reserved prefix '".concat(e,"'"));var r=t.prefix2ns.get(e);if(r&&r!==n)throw new Error("prefix '".concat(e,"' already bound to a different namespace"));t.ns2prefix.get(n)||t.ns2prefix.set(n,e),t.prefix2ns.set(e,n)},t.prototype._allocPrefix=function(t){for(var e=1;;){var n="ns".concat(e++);if(!t.prefix2ns.has(n))return n}},t.prototype._ensurePrefixDeclared=function(t,e){var n=this._lookupPrefix(e);if(n)return n;if(t.closed)throw new Error("can not declare namespace after start tag closed for <".concat(t.name,">"));var r=this._allocPrefix(t);return this._writeAttStr("".concat(R.Xmlns,":").concat(r),e),this._registerNamespace(t,r,e),r},t.prototype._closeOpenTagIfNeeded=function(t){t.closed||(this._w.write(R.CloseTag),t.closed=!0)},t.Context=function(t,e){this.name="",this.closed=!1,this.lastToken=null,this.ns2prefix=new Map,this.prefix2ns=new Map,this.defaultNs=null,this.name=t,this.depth=e},t}(),F=function(){function t(){this.count=0,this._chunks=[]}return t.prototype.write=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(0===t.length)return this;var n=t.join("");return this._chunks.push(n),this.count+=n.length,this},t.prototype.toString=function(){return this._chunks.join("")},t.prototype.clear=function(){this._chunks=[],this.count=0},t}(),I=function(){function t(t,e){void 0===e&&(e={}),this._sink=t,this._opts=e,this.count=0,this._encoder=new TextEncoder,this._pending="",this._pendingChars=0}return t.prototype.write=function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(0===e.length)return this;var r=e.join("");if(0===r.length)return this;this._pending+=r,this._pendingChars+=r.length;var i=null!==(t=this._opts.flushChars)&&void 0!==t?t:65536;return this._pendingChars>=i&&this.flush(),this},t.prototype.flush=function(){if(0===this._pendingChars)return this;var t=this._encoder.encode(this._pending);return this._sink.push(t),this.count+=t.length,this._pending="",this._pendingChars=0,this},t.prototype.finish=function(){this.flush(),this._sink.push(new Uint8Array(0),!0)},t.prototype.clear=function(){this._pending="",this._pendingChars=0,this.count=0},t}(),z="http://schemas.microsoft.com/3dmanufacturing/core/2015/02",Z="http://schemas.microsoft.com/3dmanufacturing/trianglesets/2021/07";!function(t){t.micron="micron",t.millimeter="millimeter",t.centimeter="centimeter",t.inch="inch",t.foot="foot",t.meter="meter"}(B||(B={})),function(t){t.model="model",t.solidsupport="solidsupport",t.support="support",t.surface="surface",t.other="other"}(P||(P={}));var L,K="http://schemas.openxmlformats.org/package/2006/content-types",U="http://schemas.openxmlformats.org/package/2006/relationships";!function(t){t.Relationships="application/vnd.openxmlformats-package.relationships+xml",t.Model="application/vnd.ms-package.3dmanufacturing-3dmodel+xml",t.Materials="application/vnd.ms-package.3dmanufacturing-material+xml",t.Colors="application/vnd.ms-package.3dmanufacturing-colors+xml",t.Texture="application/vnd.ms-package.3dmanufacturing-texture+xml",t.Texture2D="application/vnd.ms-package.3dmanufacturing-texture2d+xml",t.Production="application/vnd.ms-package.3dmanufacturing-production+xml",t.Slice="application/vnd.ms-package.3dmanufacturing-slice+xml",t.BeamLattice="application/vnd.ms-package.3dmanufacturing-beamlattice+xml",t.SecureContent="application/vnd.ms-package.3dmanufacturing-securecontent+xml",t.Png="image/png",t.Jpeg="image/jpeg",t.Tiff="image/tiff",t.Xml="application/xml"}(L||(L={}));var G="_rels/",Q="3D/",V="3dmodel.model",W=".rels",$="[Content_Types].xml",q=function(){function t(){}return t.IsKnown=function(e){return t.Known.has(e)},t.IsThreeDimModel=function(e){return e===t.ThreeDimModel},t.ThreeDimModel="http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel",t.Thumbnail="http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail",t.PrintTicket="http://schemas.microsoft.com/3dmanufacturing/2013/01/printticket",t.MustPreserve="http://schemas.openxmlformats.org/package/2006/relationships/mustpreserve",t.Known=new Set([t.ThreeDimModel,t.Thumbnail,t.PrintTicket,t.MustPreserve]),t}(),H=function(){function t(){this.items=[]}return o([f({ns:K,name:"Types"})],t)}(),Y=function(){function t(t,e){this.ext=t,this.ct=e}return o([d({name:{ns:K,name:"Extension"}})],t.prototype,"ext",void 0),o([d({name:{ns:K,name:"ContentType"}})],t.prototype,"ct",void 0),o([f({ns:K,name:"Default"})],t)}(),J=function(){function t(){this.items=[]}return o([f({ns:U,name:"Relationships"})],t)}(),tt=function(){function t(t,e,n){this.id=t,this.type=e,this.target=n}return o([d({name:"Id"})],t.prototype,"id",void 0),o([d({name:"Type"})],t.prototype,"type",void 0),o([d({name:"Target"})],t.prototype,"target",void 0),o([f({ns:U,name:"Relationship"})],t)}(),et=function(t,e,n){this.contentTypes=t,this.relationships=e,this.model=n},nt=function(){function t(t){this.values=t}return t.Zero=function(){return new t([0,0,0,0,0,0,0,0,0,0,0,0])},t.prototype.toString=function(){return this.values.join(" ")},t}(),rt=function(){function t(t){this.o=t,this._f=new C(t)}return t.prototype.toString=function(t){var e=this;return t.values.map(function(t){return e._f.toString(t)}).join(" ")},t}(),it=function(){function t(){this.unit=B.millimeter}return t.KnownMeta=["Title","Designer","Description","Copyright","LicenseTerms","Rating","CreationDate","ModificationDate","Application"],o([d({name:"unit"})],t.prototype,"unit",void 0),o([d({name:"requiredextensions"})],t.prototype,"requiredextensions",void 0),o([d({name:"recommendedextensions"})],t.prototype,"recommendedextensions",void 0),o([f({ns:z,name:"model"})],t)}(),ot=function(){function t(t,e,n,r){this.name=t,this.value=e,this.preserve=n,this.type=r}return o([d({name:"name"})],t.prototype,"name",void 0),o([d({name:"preserve"})],t.prototype,"preserve",void 0),o([d({name:"type"})],t.prototype,"type",void 0),o([f({ns:z,name:"meta"})],t)}(),at=function(){function t(){this.metadata=[]}return o([f({ns:z,name:"metadatagroup"})],t)}(),st=function(){function t(){this.object=[]}return o([f({ns:z,name:"resources"})],t)}(),ut=function(){function t(t,e){void 0===e&&(e=P.model),this.id=t,this.type=e}return o([d({name:"id"})],t.prototype,"id",void 0),o([d({name:"type"})],t.prototype,"type",void 0),o([d({name:"thumbnail"})],t.prototype,"thumbnail",void 0),o([d({name:"partnumber"})],t.prototype,"partnumber",void 0),o([d({name:"name"})],t.prototype,"name",void 0),o([d({name:"pid"})],t.prototype,"pid",void 0),o([d({name:"pindex"})],t.prototype,"pindex",void 0),o([f({ns:z,name:"object"})],t)}(),lt=function(){function t(t,e){this.vertices=null!=t?t:new ct,this.triangles=null!=e?e:new ht}return o([f({ns:z,name:"mesh"})],t)}(),ct=function(){function t(){this.vertex=[]}return o([f({ns:z,name:"vertices"})],t)}(),pt=function(){function t(t,e,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),this.x=t,this.y=e,this.z=n}return o([d({name:"x"})],t.prototype,"x",void 0),o([d({name:"y"})],t.prototype,"y",void 0),o([d({name:"z"})],t.prototype,"z",void 0),o([f({ns:z,name:"vertex"})],t)}(),ht=function(){function t(){this.triangle=[]}return o([f({ns:z,name:"triangles"})],t)}(),ft=function(){function t(t,e,n){this.v1=t,this.v2=e,this.v3=n}return o([d({name:"v1"})],t.prototype,"v1",void 0),o([d({name:"v2"})],t.prototype,"v2",void 0),o([d({name:"v3"})],t.prototype,"v3",void 0),o([d({name:"p1"})],t.prototype,"p1",void 0),o([d({name:"p2"})],t.prototype,"p2",void 0),o([d({name:"p3"})],t.prototype,"p3",void 0),o([d({name:"pid"})],t.prototype,"pid",void 0),o([f({ns:z,name:"triangle"})],t)}(),mt=function(){function t(){this.component=[]}return o([f({ns:z,name:"components"})],t)}(),dt=function(){function t(t,e){this.objectid=t,this.transform=e}return o([d({name:"objectid"})],t.prototype,"objectid",void 0),o([d({name:"transform",formatter:rt})],t.prototype,"transform",void 0),o([f({ns:z,name:"component"})],t)}(),vt=function(){function t(t){this.base=[],this.id=t}return o([d({name:"id"})],t.prototype,"id",void 0),o([f({ns:z,name:"basematerials"})],t)}(),_t=function(){function t(t,e){this.name=t,this.displaycolor=e}return o([d({name:"name"})],t.prototype,"name",void 0),o([d({name:"displaycolor"})],t.prototype,"displaycolor",void 0),o([f({ns:z,name:"base"})],t)}(),yt=function(){function t(){this.item=[]}return o([f({ns:z,name:"build"})],t)}(),gt=function(){function t(t,e,n){this.objectid=t,this.transform=e,this.partnumber=n}return o([d({name:"objectid"})],t.prototype,"objectid",void 0),o([d({name:"transform",formatter:rt})],t.prototype,"transform",void 0),o([d({name:"partnumber"})],t.prototype,"partnumber",void 0),o([f({ns:z,name:"item"})],t)}(),wt=function(){function t(t,e){this._object=new ut(t,e)}return t.prototype.withName=function(t){return this._object.name=t,this},t.prototype.withThumbnail=function(t){return this._object.thumbnail=t,this},t.prototype.withProperty=function(t,e){return void 0===e&&(e=0),this._object.pid=t,this._object.id=e,this},t.prototype.build=function(){return this._object},t.prototype.reset=function(t,e){this._object=new ut(t,e)},t}(),bt=function(t){function e(e,n){void 0===n&&(n=P.model);var r=t.call(this,e,n)||this;return r._object.content=new mt,r}return r(e,t),e.prototype.withComponent=function(t,e){return this._object.content.component.push(new dt(t,e)),this},e}(wt),Tt=function(t){function e(e){return t.call(this,e,P.model)||this}return r(e,t),e.prototype.withPostProcessHandlers=function(t,e){return this._vh=t,this._th=e,this},e.prototype.withData=function(t){return this._object.content=this._buildMesh(t),this},e.prototype.withMaterial=function(t,e){return this._object.pid=t,this._object.pindex=e,this},e.prototype._buildMesh=function(t){var e=this._buildVertices(t.positions),n=this._buildTriangle(t.indices);return new lt(e,n)},e.prototype._buildVertices=function(t){var e=new ct;if(t)for(var n=0;n<t.length;){var r=t[n++],i=t[n++],o=t[n++],a=new pt(r,i,o);this._vh&&(a=this._vh(a)),e.vertex.push(a)}return e},e.prototype._buildTriangle=function(t){var e=new ht;if(t)for(var n=0;n<t.length;){var r=t[n++],i=t[n++],o=t[n++],a=new ft(r,i,o);this._th&&(a=this._th(a)),e.triangle.push(a)}return e},e}(wt),Mt=function(){function t(t){this._m=new vt(t)}return t.prototype.withColor=function(t,e){var n;this._m.base=null!==(n=this._m.base)&&void 0!==n?n:[];var r=this._m.base.find(function(e){return e.name.toLowerCase()===t.toLowerCase()});return r?(r.displaycolor=this._rgbaToHex(e),this):(r=new _t(t,this._rgbaToHex(e)),this._m.base.push(r),this)},t.prototype.build=function(){return this._m},t.prototype._rgbaToHex=function(t){var e=function(t){return Math.round(Math.min(255,Math.max(0,255*Math.pow(t,1/2.2))))},n=e(t.r).toString(16).padStart(2,"0").toUpperCase(),r=e(t.g).toString(16).padStart(2,"0").toUpperCase(),i=e(t.b).toString(16).padStart(2,"0").toUpperCase();if("number"==typeof t.a){var o=Math.round(Math.min(255,Math.max(0,255*t.a))).toString(16).padStart(2,"0").toUpperCase();return"#".concat(n).concat(r).concat(i).concat(o)}return"#".concat(n).concat(r).concat(i)},t}(),xt=function(){function t(){this._model=new it,this._objects=new Map}return t.prototype.withMetaData=function(t,e,n,r){return this._model.metadata||(this._model.metadata=new Array),this._model.metadata.push(new ot(t,e,n,r)),this},t.prototype.withMaterial=function(t){var e,n;return t instanceof Mt&&(t=t.build()),t&&(this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new st,this._model.resources.basematerials=null!==(n=this._model.resources.basematerials)&&void 0!==n?n:[],this._model.resources.basematerials.push(t)),this},t.prototype.withMesh=function(t){var e;return t instanceof Tt&&(t=t.build()),this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new st,this._model.resources.object.push(t),this},t.prototype.withComponents=function(t){var e;return t instanceof bt&&(t=t.build()),this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new st,this._model.resources.object.push(t),this},t.prototype.withBuild=function(t,e,n){var r,i;return this._model.build=null!==(r=this._model.build)&&void 0!==r?r:new yt,null===(i=this._model.build.item)||void 0===i||i.push(new gt(t,e,n)),this},t.prototype.withUnit=function(t){return this._model.unit=t,this},t.prototype.reset=function(){return this._model=new it,this._objects=new Map,this},t.prototype.build=function(){var t,e,n,r;if(!(null===(e=null===(t=this._model.resources)||void 0===t?void 0:t.object)||void 0===e?void 0:e.length))throw new Error("Invalid state: resources MUST be defined ");if(!(null===(r=null===(n=this._model.build)||void 0===n?void 0:n.item)||void 0===r?void 0:r.length))throw new Error("Invalid state: Build MUST be defined ");return this._model},t.KnownMetaSet=new Set(it.KnownMeta.map(function(t){return t.toLowerCase()})),t}(),St=function(){function t(){}return t.prototype.withContentType=function(t){this._cts||(this._cts=new H);var e=this._cts.items;return e.some(function(e){return e.ext===t.ext&&e.ct===t.ct})||e.push(t),this},t.prototype.withRelationship=function(t){this._rs||(this._rs=new J);var e=this._rs.items;return e.some(function(e){return e.id===t.id})||e.push(t),this.withContentType(new Y("rels",L.Relationships)),this},t.prototype.withModel=function(t){return t instanceof xt&&(t=t.build()),this._m=t,this.withContentType(new Y("model",L.Model)),this},t.prototype.build=function(){if(!this._m)throw new Error("Invalid state: you Must provide at least a model.");var t="".concat(Q).concat(V);if(!this._rs){var e="/".concat(t);this.withRelationship(new tt("rel".concat(0),q.ThreeDimModel,e))}return new et(this._cts,this._rs,this._m)},t}(),Ct=function(){function t(t){this._o=t}return Object.defineProperty(t.prototype,"options",{get:function(){return this._o},enumerable:!1,configurable:!0}),t.prototype.serializeAsync=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return a(this,void 0,void 0,function(){var n,r,i,o,a,u,l;return s(this,function(s){switch(s.label){case 0:return[4,this.ensureZipLibReadyAsync()];case 1:if(!(n=s.sent()))return[2];if(r=n.Zip,i=n.ZipDeflate,!r||!i)throw new Error("fflate Zip / ZipDeflate not available");return o=function(t){return{push:function(e,n){return t.push(e,n)}}},a=function(t,e,n){var r=new i(e,{level:6});t.add(r);var a=o(r),s=new I(a),u=new E(s).dec("1.0","UTF-8");new X(u).serialize(n),s.finish()},(u=this.toDocument.apply(this,e))?(l=new r(t),a(l,$,u.contentTypes),a(l,"".concat(G).concat(W),u.relationships),a(l,"".concat(Q).concat(V),u.model),l.end(),[2]):[2]}})})},t.prototype.toDocument=function(){for(var t,e,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var i=(new xt).withUnit(null!==(e=null===(t=this._o)||void 0===t?void 0:t.unit)&&void 0!==e?e:B.millimeter);if(this.options.metadata)for(var o in this.options.metadata)i.withMetaData(o,this.options.metadata[o]);return(new St).withModel(this.toModel.apply(this,u([i],n,!1))).build()},t}(),Nt=function(){function t(){}return t.SerializeToMemoryAsync=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return a(this,void 0,void 0,function(){var n,r,i,o,a,l,c,p;return s(this,function(s){switch(s.label){case 0:return n=new Array,r=0,i=function(t,e,i){n.push(e),r+=e.length},[4,t.serializeAsync.apply(t,u([i],e,!1))];case 1:if(s.sent(),!r)return[2,void 0];for(o=new Uint8Array(r),a=0,l=0,c=n;l<c.length;l++)p=c[l],o.set(p,a),a+=p.length;return[2,o]}})})},t}(),jt=function(){function t(){}return t.FFLATEUrl="https://unpkg.com/fflate@0.8.2",t}(),Ot=function(){function t(t,e,n){void 0===t&&(t=0),void 0===e&&(e=Number.MIN_SAFE_INTEGER),void 0===n&&(n=1),this._from=t,this._to=e,this._step=n,this._i=t}return t.prototype.next=function(){if(this._i<this._to)throw new Error("ST_ResourceID out of bound");var t=this._i;return this._i+=this._step,t},t.prototype.reset=function(){return this._i=this._from,this},t}(),kt=function(t){function n(e){return void 0===e&&(e={}),t.call(this,i(i({},n.DefaultOptions),e))||this}return r(n,t),n.prototype.toModel=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];n=n.filter(function(t){return t instanceof e.Mesh||t instanceof e.InstancedMesh});for(var i=new Ot,o=t,a=new Map,s=this.options.exportInstances?[]:null,u=0;u<n.length;u++){var l=n[u];if(l instanceof e.InstancedMesh)null==s||s.push(l);else{var c=l.name||"mesh".concat(u),p=l.getWorldMatrix(),h=this._handleBabylonTo3mfMatrixTransformToRef(p,nt.Zero());if(void 0!==(S=l.subMeshes))for(var f=1==S.length,m=0;m<S.length;m++){var d=S[m],v=this._extractSubMesh(l,d);if(v){var _=f?"".concat(c):"".concat(c,"_").concat(m),y=new Tt(i.next()).withData(v).withName(_).build();o.withMesh(y),o.withBuild(y.id,h),a.set(d,y)}}}}if(s&&s.length)for(var g=this._groupBy(s,function(t){return t.sourceMesh}),w=0,b=Array.from(g.entries());w<b.length;w++){var T=b[w],M=T[0],x=T[1];if(x&&x.length)for(u=0;u<x.length;u++){p=x[u].getWorldMatrix();var S=M.subMeshes;for(m=0;m<S.length;m++){d=S[m];var C=a.get(d);C&&o.withBuild(C.id,this._handleBabylonTo3mfMatrixTransformToRef(p,nt.Zero()))}}}return o.build()},n.prototype.ensureZipLibReadyAsync=function(){return a(this,void 0,void 0,function(){var t=this;return s(this,function(n){switch(n.label){case 0:return this._fflateReadyPromise?[4,this._fflateReadyPromise]:[3,2];case 1:case 3:return[2,n.sent()];case 2:return this._fflateReadyPromise=a(t,void 0,void 0,function(){var t;return s(this,function(n){switch(n.label){case 0:return(t=globalThis).fflate?[3,2]:[4,e.Tools.LoadScriptAsync(jt.FFLATEUrl)];case 1:n.sent(),n.label=2;case 2:return[2,t.fflate]}})}),[4,this._fflateReadyPromise]}})})},n.prototype._extractSubMesh=function(t,e){var r=t.getIndices();if(r){var i=t.getVerticesData(n._PositionKind);if(i){if(0==e.indexStart&&e.indexCount==r.length)return{positions:i,indices:r};for(var o=e.indexStart,a=new Map,s=[],u=new Uint32Array(e.indexCount),l=0;l<e.indexCount;l++){var c=r[o+l],p=a.get(c);if(void 0===p){p=a.size,a.set(c,p);var h=3*c;s.push(i[h],i[h+1],i[h+2])}u[l]=p}return{positions:new Float32Array(s),indices:u}}}},n.prototype._groupBy=function(t,e){for(var n=new Map,r=0,i=t;r<i.length;r++){var o=i[r],a=e(o),s=n.get(a);s?s.push(o):n.set(a,[o])}return n},n.prototype._handleBabylonTo3mfMatrixTransformToRef=function(t,r){var i=t.multiplyToRef(n._R_BJS_TO_3MF,e.Matrix.Zero()).m;return r.values=[i[0],i[1],i[2],i[4],i[5],i[6],i[8],i[9],i[10],i[12],i[13],i[14]],r},n.DefaultOptions={unit:B.meter,exportInstances:!1},n._PositionKind="position",n._R_BJS_TO_3MF=e.Matrix.RotationX(Math.PI/2).multiply(e.Matrix.Scaling(1,-1,1)),n}(Ct),Dt={__proto__:null,AbstractThreeMfSerializer:Ct,ContentTypeFileName:$,DefaultXmlSerializerFormatOptions:M,DefaultXmlSerializerNumberOptions:T,GetXmlFieldMeta:_,GetXmlName:y,IsQualifiedName:l,Known3mfRelationshipTypes:q,get KnownI3mfContentType(){return L},Matrix3d:nt,MatrixFormatter:rt,ModelFileName:V,NumberFormatter:C,Object3dDirName:Q,OpenXmlContentTypesNamespace:K,OpenXmlRelationshipsNamespace:U,RelationshipDirName:G,RelationshipFileName:W,ResolveFormatOptions:S,ResolveNumberOptions:x,get ST_ObjectType(){return P},get ST_Unit(){return B},StringXmlWriter:F,ThreeDimModelNamespace:z,ThreeMf:Nt,ThreeMfBase:_t,ThreeMfBaseMaterials:vt,ThreeMfBuild:yt,ThreeMfComponent:dt,ThreeMfComponents:mt,ThreeMfComponentsBuilder:bt,ThreeMfContentType:Y,ThreeMfContentTypes:H,ThreeMfDocument:et,ThreeMfDocumentBuilder:St,ThreeMfItem:gt,ThreeMfMaterialBuilder:Mt,ThreeMfMesh:lt,ThreeMfMeshBuilder:Tt,ThreeMfMeta:ot,ThreeMfMetadataGroup:at,ThreeMfModel:it,ThreeMfModelBuilder:xt,ThreeMfObject:ut,ThreeMfObjectBuilder:wt,ThreeMfRelationship:tt,ThreeMfRelationships:J,ThreeMfResources:st,ThreeMfSerializer:kt,ThreeMfSerializerGlobalConfiguration:jt,ThreeMfTriangle:ft,ThreeMfTriangles:ht,ThreeMfVertex:pt,ThreeMfVertices:ct,ToQualifiedString:b,get TokenType(){return A},TriangleSetsNamespace:Z,Utf8XmlWriterToBytes:I,XmlAttr:d,XmlBuilder:E,XmlElem:v,XmlIgnore:m,XmlName:f,XmlNameToParts:w,XmlSerializer:X},At="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==At){var Xt=[];for(var Rt in Dt)Xt.indexOf(Rt)>-1||(At.BABYLON[Rt]=Dt[Rt],Xt.push(Rt))}var Bt={__proto__:null,AbstractThreeMfSerializer:Ct,ContentTypeFileName:$,DefaultXmlSerializerFormatOptions:M,DefaultXmlSerializerNumberOptions:T,GetXmlFieldMeta:_,GetXmlName:y,IsQualifiedName:l,Known3mfRelationshipTypes:q,get KnownI3mfContentType(){return L},Matrix3d:nt,MatrixFormatter:rt,ModelFileName:V,NumberFormatter:C,Object3dDirName:Q,OpenXmlContentTypesNamespace:K,OpenXmlRelationshipsNamespace:U,RelationshipDirName:G,RelationshipFileName:W,ResolveFormatOptions:S,ResolveNumberOptions:x,get ST_ObjectType(){return P},get ST_Unit(){return B},StringXmlWriter:F,ThreeDimModelNamespace:z,ThreeMf:Nt,ThreeMfBase:_t,ThreeMfBaseMaterials:vt,ThreeMfBuild:yt,ThreeMfComponent:dt,ThreeMfComponents:mt,ThreeMfComponentsBuilder:bt,ThreeMfContentType:Y,ThreeMfContentTypes:H,ThreeMfDocument:et,ThreeMfDocumentBuilder:St,ThreeMfItem:gt,ThreeMfMaterialBuilder:Mt,ThreeMfMesh:lt,ThreeMfMeshBuilder:Tt,ThreeMfMeta:ot,ThreeMfMetadataGroup:at,ThreeMfModel:it,ThreeMfModelBuilder:xt,ThreeMfObject:ut,ThreeMfObjectBuilder:wt,ThreeMfRelationship:tt,ThreeMfRelationships:J,ThreeMfResources:st,ThreeMfSerializer:kt,ThreeMfSerializerGlobalConfiguration:jt,ThreeMfTriangle:ft,ThreeMfTriangles:ht,ThreeMfVertex:pt,ThreeMfVertices:ct,ToQualifiedString:b,get TokenType(){return A},TriangleSetsNamespace:Z,Utf8XmlWriterToBytes:I,XmlAttr:d,XmlBuilder:E,XmlElem:v,XmlIgnore:m,XmlName:f,XmlNameToParts:w,XmlSerializer:X};t.default=Bt,t.serializers=Bt,Object.defineProperty(t,"__esModule",{value:!0})});
|
|
2
|
+
//# sourceMappingURL=babylon.threemfSerializer.min.js.map
|