brepjs 18.20.5 → 18.22.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.
Files changed (76) hide show
  1. package/dist/2d.cjs +6 -6
  2. package/dist/2d.js +6 -6
  3. package/dist/{blueprint-B6vmOy5_.cjs → blueprint-BRsNfnfQ.cjs} +5 -5
  4. package/dist/{blueprint-0bBVK6Be.js → blueprint-CQ04Ov5Z.js} +5 -5
  5. package/dist/{blueprintFns-Aiise3pc.cjs → blueprintFns-C5DCLCtZ.cjs} +2 -2
  6. package/dist/{blueprintFns-BJbTjW94.js → blueprintFns-DpPZNhFx.js} +2 -2
  7. package/dist/{blueprintSketcher-D_Z8NfOF.cjs → blueprintSketcher-DaF5OR4M.cjs} +3 -3
  8. package/dist/{blueprintSketcher-BkZrvGoG.js → blueprintSketcher-OwXVDMOb.js} +3 -3
  9. package/dist/{boolean2D-BAJ3efk_.js → boolean2D-BQKMy6dN.js} +4 -4
  10. package/dist/{boolean2D-1gc4kqNS.cjs → boolean2D-gwOq0VXi.cjs} +4 -4
  11. package/dist/{booleanFns-BsjoPJAS.js → booleanFns-CuXl5XQP.js} +4 -4
  12. package/dist/{booleanFns-D3mYqZxL.cjs → booleanFns-cmeKRsth.cjs} +4 -4
  13. package/dist/brepjs.cjs +24 -24
  14. package/dist/brepjs.js +24 -24
  15. package/dist/{cameraFns-QK8ahyDz.js → cameraFns-DC2ShyXC.js} +2 -2
  16. package/dist/{cameraFns-DgTBC2w3.cjs → cameraFns-LurBny3f.cjs} +2 -2
  17. package/dist/core.cjs +1 -1
  18. package/dist/core.js +1 -1
  19. package/dist/{cornerFinder-CkLZ23Kp.cjs → cornerFinder-BjjFVnDq.cjs} +1 -1
  20. package/dist/{cornerFinder-BaSsAk69.js → cornerFinder-CF8fVEx2.js} +1 -1
  21. package/dist/{curveFns-CE3b2sDD.cjs → curveFns-BR8gQOAc.cjs} +1 -1
  22. package/dist/{curveFns-BiSx9FTh.js → curveFns-Cimni2kq.js} +1 -1
  23. package/dist/{drawFns-BtHAHYa-.js → drawFns-Bh1LGuSX.js} +12 -12
  24. package/dist/{drawFns-BaxDgrlX.cjs → drawFns-btYAn61y.cjs} +12 -12
  25. package/dist/{extrudeFns-CRG478Q3.js → extrudeFns-BmF17qhf.js} +1 -1
  26. package/dist/{extrudeFns-DUPpueiL.cjs → extrudeFns-CLrrRprF.cjs} +1 -1
  27. package/dist/{faceFns-CLzDRrUE.cjs → faceFns-BFEUkmn7.cjs} +2 -2
  28. package/dist/{faceFns-C3C6l-X0.js → faceFns-D9UAkqPb.js} +2 -2
  29. package/dist/{helpers-DwG3OFk0.cjs → helpers-BnF1MObz.cjs} +6 -6
  30. package/dist/{helpers-rNVdiDLn.js → helpers-DnrXynu0.js} +6 -6
  31. package/dist/{historyFns-DSCnjCkQ.cjs → historyFns-BX9Bu5NT.cjs} +4 -4
  32. package/dist/{historyFns-CEr9D6ay.js → historyFns-DGDKVD6-.js} +4 -4
  33. package/dist/{importFns-Hh3S9NPm.js → importFns-B9RUaVsc.js} +191 -139
  34. package/dist/{importFns-A8v4Pdw2.cjs → importFns-BMN4KCmX.cjs} +191 -139
  35. package/dist/io.cjs +2 -2
  36. package/dist/io.js +2 -2
  37. package/dist/kernel/occt/advancedOps.d.ts +9 -13
  38. package/dist/{measureFns-DMyJp_x3.cjs → measureFns-CaOR1TEA.cjs} +3 -3
  39. package/dist/{measureFns--uvW_r_P.js → measureFns-CiCx5o_s.js} +3 -3
  40. package/dist/measurement.cjs +1 -1
  41. package/dist/measurement.js +1 -1
  42. package/dist/{meshFns-DTn__aNb.cjs → meshFns-CIdP0f35.cjs} +2 -2
  43. package/dist/{meshFns-Bxt57KX1.js → meshFns-k-gSXquL.js} +2 -2
  44. package/dist/operations.cjs +2 -2
  45. package/dist/operations.js +2 -2
  46. package/dist/{primitiveFns-CX5c_YGt.cjs → primitiveFns-Ds2LNkol.cjs} +55 -34
  47. package/dist/{primitiveFns-w1zNsxTH.js → primitiveFns-OvPYb4CU.js} +55 -34
  48. package/dist/projection.cjs +1 -1
  49. package/dist/projection.js +1 -1
  50. package/dist/query.cjs +2 -2
  51. package/dist/query.js +2 -2
  52. package/dist/{shapeFns-cTuUm-aP.cjs → shapeFns-BD6oYLMM.cjs} +2 -2
  53. package/dist/{shapeFns-Dsxp5d_u.js → shapeFns-ByuSx62n.js} +2 -2
  54. package/dist/shapeRef.cjs +1 -1
  55. package/dist/shapeRef.js +1 -1
  56. package/dist/{shapeRefFns-zFWzAmQZ.js → shapeRefFns-Bv3Jj1vz.js} +4 -4
  57. package/dist/{shapeRefFns-SctbRFju.cjs → shapeRefFns-CybMlSCu.cjs} +4 -4
  58. package/dist/{shapeTypes-DmHPJc_M.js → shapeTypes-BdIQ-d5X.js} +119 -127
  59. package/dist/{shapeTypes-C1FUZ2zE.cjs → shapeTypes-D6hfaPZq.cjs} +119 -127
  60. package/dist/sketching.cjs +3 -3
  61. package/dist/sketching.js +3 -3
  62. package/dist/{solidBuilders-BGJvTrDt.cjs → solidBuilders-DAHTAqeh.cjs} +2 -2
  63. package/dist/{solidBuilders-CJ8ckc61.js → solidBuilders-TJZOIga_.js} +2 -2
  64. package/dist/{surfaceBuilders-B7A2uoBJ.cjs → surfaceBuilders-CzRFME5_.cjs} +2 -2
  65. package/dist/{surfaceBuilders-B_wXW8QS.js → surfaceBuilders-rNgtRqTR.js} +2 -2
  66. package/dist/text.cjs +2 -2
  67. package/dist/text.js +2 -2
  68. package/dist/{textBlueprints-LYHgEdsx.js → textBlueprints-C9eKTxef.js} +7 -7
  69. package/dist/{textBlueprints-BCTQk9T8.cjs → textBlueprints-D7gWCZ88.cjs} +7 -7
  70. package/dist/{textMetrics-Dd-Vva8S.js → textMetrics-0y73spLE.js} +1 -1
  71. package/dist/{textMetrics-BNfyRNxm.cjs → textMetrics-B5SN90x5.cjs} +1 -1
  72. package/dist/topology.cjs +7 -7
  73. package/dist/topology.js +7 -7
  74. package/dist/{topologyQueryFns-CcHXn5M2.js → topologyQueryFns-Ds2H75YB.js} +1 -1
  75. package/dist/{topologyQueryFns-DCICDnwA.cjs → topologyQueryFns-hG0APAJN.cjs} +1 -1
  76. package/package.json +2 -1
@@ -1,8 +1,8 @@
1
- const require_shapeTypes = require("./shapeTypes-C1FUZ2zE.cjs");
1
+ const require_shapeTypes = require("./shapeTypes-D6hfaPZq.cjs");
2
2
  const require_vec3 = require("./vec3-CFwOI0ZI.cjs");
3
3
  const require_errors = require("./errors-DxoD7zgx.cjs");
4
4
  const require_arrayAccess = require("./arrayAccess-e4H9cBfh.cjs");
5
- const require_blueprint = require("./blueprint-B6vmOy5_.cjs");
5
+ const require_blueprint = require("./blueprint-BRsNfnfQ.cjs");
6
6
  //#region src/io/objExportFns.ts
7
7
  /** Read a vec3 from a typed array at the given vertex index. */
8
8
  function vec3At(arr, i) {
@@ -160,6 +160,52 @@ function exportGlb(mesh, options) {
160
160
  output.set(binChunk, binOffset + 8);
161
161
  return glb;
162
162
  }
163
+ function buildSingleAccessors(triangles, vertices, normals, min, max) {
164
+ return [
165
+ {
166
+ bufferView: 0,
167
+ componentType: UNSIGNED_INT,
168
+ count: triangles.length,
169
+ type: "SCALAR"
170
+ },
171
+ {
172
+ bufferView: 1,
173
+ componentType: FLOAT,
174
+ count: vertices.length / 3,
175
+ type: "VEC3",
176
+ min,
177
+ max
178
+ },
179
+ {
180
+ bufferView: 2,
181
+ componentType: FLOAT,
182
+ count: normals.length / 3,
183
+ type: "VEC3"
184
+ }
185
+ ];
186
+ }
187
+ function buildSingleBufferViews(indicesByteLength, verticesByteLength, normalsByteLength) {
188
+ return [
189
+ {
190
+ buffer: 0,
191
+ byteOffset: 0,
192
+ byteLength: indicesByteLength,
193
+ target: ELEMENT_ARRAY_BUFFER
194
+ },
195
+ {
196
+ buffer: 0,
197
+ byteOffset: align4(indicesByteLength),
198
+ byteLength: verticesByteLength,
199
+ target: ARRAY_BUFFER
200
+ },
201
+ {
202
+ buffer: 0,
203
+ byteOffset: align4(indicesByteLength) + verticesByteLength,
204
+ byteLength: normalsByteLength,
205
+ target: ARRAY_BUFFER
206
+ }
207
+ ];
208
+ }
163
209
  function buildGltfDocument(mesh, mode, options) {
164
210
  const { vertices, normals, triangles } = mesh;
165
211
  const materialMap = options?.materials;
@@ -184,48 +230,8 @@ function buildGltfDocument(mesh, mode, options) {
184
230
  },
185
231
  indices: 0
186
232
  }] }],
187
- accessors: [
188
- {
189
- bufferView: 0,
190
- componentType: UNSIGNED_INT,
191
- count: triangles.length,
192
- type: "SCALAR"
193
- },
194
- {
195
- bufferView: 1,
196
- componentType: FLOAT,
197
- count: vertices.length / 3,
198
- type: "VEC3",
199
- min,
200
- max
201
- },
202
- {
203
- bufferView: 2,
204
- componentType: FLOAT,
205
- count: normals.length / 3,
206
- type: "VEC3"
207
- }
208
- ],
209
- bufferViews: [
210
- {
211
- buffer: 0,
212
- byteOffset: 0,
213
- byteLength: indicesByteLength,
214
- target: ELEMENT_ARRAY_BUFFER
215
- },
216
- {
217
- buffer: 0,
218
- byteOffset: align4(indicesByteLength),
219
- byteLength: verticesByteLength,
220
- target: ARRAY_BUFFER
221
- },
222
- {
223
- buffer: 0,
224
- byteOffset: align4(indicesByteLength) + verticesByteLength,
225
- byteLength: normalsByteLength,
226
- target: ARRAY_BUFFER
227
- }
228
- ],
233
+ accessors: buildSingleAccessors(triangles, vertices, normals, min, max),
234
+ bufferViews: buildSingleBufferViews(indicesByteLength, verticesByteLength, normalsByteLength),
229
235
  buffers: [{ byteLength: totalByteLength }]
230
236
  };
231
237
  if (mode === "base64") {
@@ -335,24 +341,17 @@ function computeMaterialLayout(mesh, materialMap) {
335
341
  uniqueMaterials
336
342
  };
337
343
  }
338
- /**
339
- * Build a glTF document from material layout.
340
- */
341
- function buildGltfDocFromLayout(mesh, layout) {
344
+ function appendVertexNormalSections(mesh, verticesOffset, accessors, bufferViews) {
342
345
  const { vertices, normals } = mesh;
343
- const { primitiveData, indexBufferInfos, verticesOffset, totalByteLength, uniqueMaterials } = layout;
344
346
  const { min, max } = computeMinMax(vertices);
345
- const accessors = [];
346
- const bufferViews = [];
347
- const primitives = [];
348
- const verticesBvIdx = 0;
347
+ const verticesBvIdx = bufferViews.length;
349
348
  bufferViews.push({
350
349
  buffer: 0,
351
350
  byteOffset: verticesOffset,
352
351
  byteLength: vertices.byteLength,
353
352
  target: ARRAY_BUFFER
354
353
  });
355
- const verticesAccIdx = 0;
354
+ const verticesAccIdx = accessors.length;
356
355
  accessors.push({
357
356
  bufferView: verticesBvIdx,
358
357
  componentType: FLOAT,
@@ -361,20 +360,27 @@ function buildGltfDocFromLayout(mesh, layout) {
361
360
  min,
362
361
  max
363
362
  });
364
- const normalsBvIdx = 1;
363
+ const normalsBvIdx = bufferViews.length;
365
364
  bufferViews.push({
366
365
  buffer: 0,
367
366
  byteOffset: verticesOffset + vertices.byteLength,
368
367
  byteLength: normals.byteLength,
369
368
  target: ARRAY_BUFFER
370
369
  });
371
- const normalsAccIdx = 1;
370
+ const normalsAccIdx = accessors.length;
372
371
  accessors.push({
373
372
  bufferView: normalsBvIdx,
374
373
  componentType: FLOAT,
375
374
  count: normals.length / 3,
376
375
  type: "VEC3"
377
376
  });
377
+ return {
378
+ verticesAccIdx,
379
+ normalsAccIdx
380
+ };
381
+ }
382
+ function appendIndexPrimitives(primitiveData, indexBufferInfos, verticesAccIdx, normalsAccIdx, accessors, bufferViews) {
383
+ const primitives = [];
378
384
  for (let pi = 0; pi < primitiveData.length; pi++) {
379
385
  const pd = require_arrayAccess.getAtOrThrow(primitiveData, pi);
380
386
  const info = require_arrayAccess.getAtOrThrow(indexBufferInfos, pi);
@@ -402,6 +408,16 @@ function buildGltfDocFromLayout(mesh, layout) {
402
408
  if (pd.materialIdx >= 0) prim.material = pd.materialIdx;
403
409
  primitives.push(prim);
404
410
  }
411
+ return primitives;
412
+ }
413
+ /**
414
+ * Build a glTF document from material layout.
415
+ */
416
+ function buildGltfDocFromLayout(mesh, layout) {
417
+ const { primitiveData, indexBufferInfos, verticesOffset, totalByteLength, uniqueMaterials } = layout;
418
+ const accessors = [];
419
+ const bufferViews = [];
420
+ const { verticesAccIdx, normalsAccIdx } = appendVertexNormalSections(mesh, verticesOffset, accessors, bufferViews);
405
421
  return {
406
422
  asset: {
407
423
  version: "2.0",
@@ -410,7 +426,7 @@ function buildGltfDocFromLayout(mesh, layout) {
410
426
  scene: 0,
411
427
  scenes: [{ nodes: [0] }],
412
428
  nodes: [{ mesh: 0 }],
413
- meshes: [{ primitives }],
429
+ meshes: [{ primitives: appendIndexPrimitives(primitiveData, indexBufferInfos, verticesAccIdx, normalsAccIdx, accessors, bufferViews) }],
414
430
  accessors,
415
431
  bufferViews,
416
432
  buffers: [{ byteLength: totalByteLength }],
@@ -587,6 +603,91 @@ function crc32(data) {
587
603
  for (const byte of data) crc = crcTable[(crc ^ byte) & 255] ^ crc >>> 8;
588
604
  return (crc ^ 4294967295) >>> 0;
589
605
  }
606
+ function writeLocalHeader(view, bytes, pos, entry) {
607
+ view.setUint32(pos, 67324752, true);
608
+ pos += 4;
609
+ view.setUint16(pos, 20, true);
610
+ pos += 2;
611
+ view.setUint16(pos, 0, true);
612
+ pos += 2;
613
+ view.setUint16(pos, 0, true);
614
+ pos += 2;
615
+ view.setUint16(pos, 0, true);
616
+ pos += 2;
617
+ view.setUint16(pos, 0, true);
618
+ pos += 2;
619
+ view.setUint32(pos, entry.crc, true);
620
+ pos += 4;
621
+ view.setUint32(pos, entry.data.length, true);
622
+ pos += 4;
623
+ view.setUint32(pos, entry.data.length, true);
624
+ pos += 4;
625
+ view.setUint16(pos, entry.name.length, true);
626
+ pos += 2;
627
+ view.setUint16(pos, 0, true);
628
+ pos += 2;
629
+ bytes.set(entry.name, pos);
630
+ pos += entry.name.length;
631
+ bytes.set(entry.data, pos);
632
+ pos += entry.data.length;
633
+ return pos;
634
+ }
635
+ function writeCentralDirEntry(view, bytes, pos, localOff, entry) {
636
+ view.setUint32(pos, 33639248, true);
637
+ pos += 4;
638
+ view.setUint16(pos, 20, true);
639
+ pos += 2;
640
+ view.setUint16(pos, 20, true);
641
+ pos += 2;
642
+ view.setUint16(pos, 0, true);
643
+ pos += 2;
644
+ view.setUint16(pos, 0, true);
645
+ pos += 2;
646
+ view.setUint16(pos, 0, true);
647
+ pos += 2;
648
+ view.setUint16(pos, 0, true);
649
+ pos += 2;
650
+ view.setUint32(pos, entry.crc, true);
651
+ pos += 4;
652
+ view.setUint32(pos, entry.data.length, true);
653
+ pos += 4;
654
+ view.setUint32(pos, entry.data.length, true);
655
+ pos += 4;
656
+ view.setUint16(pos, entry.name.length, true);
657
+ pos += 2;
658
+ view.setUint16(pos, 0, true);
659
+ pos += 2;
660
+ view.setUint16(pos, 0, true);
661
+ pos += 2;
662
+ view.setUint16(pos, 0, true);
663
+ pos += 2;
664
+ view.setUint16(pos, 0, true);
665
+ pos += 2;
666
+ view.setUint32(pos, 0, true);
667
+ pos += 4;
668
+ view.setUint32(pos, localOff, true);
669
+ pos += 4;
670
+ bytes.set(entry.name, pos);
671
+ pos += entry.name.length;
672
+ return pos;
673
+ }
674
+ function writeEndOfCentralDir(view, pos, entryCount, centralStart, centralSize) {
675
+ view.setUint32(pos, 101010256, true);
676
+ pos += 4;
677
+ view.setUint16(pos, 0, true);
678
+ pos += 2;
679
+ view.setUint16(pos, 0, true);
680
+ pos += 2;
681
+ view.setUint16(pos, entryCount, true);
682
+ pos += 2;
683
+ view.setUint16(pos, entryCount, true);
684
+ pos += 2;
685
+ view.setUint32(pos, centralSize, true);
686
+ pos += 4;
687
+ view.setUint32(pos, centralStart, true);
688
+ pos += 4;
689
+ view.setUint16(pos, 0, true);
690
+ }
590
691
  function buildZip(entries) {
591
692
  let offset = 0;
592
693
  const localHeaders = [];
@@ -605,87 +706,9 @@ function buildZip(entries) {
605
706
  const view = new DataView(buf);
606
707
  const bytes = new Uint8Array(buf);
607
708
  let pos = 0;
608
- for (const { entry } of localHeaders) {
609
- view.setUint32(pos, 67324752, true);
610
- pos += 4;
611
- view.setUint16(pos, 20, true);
612
- pos += 2;
613
- view.setUint16(pos, 0, true);
614
- pos += 2;
615
- view.setUint16(pos, 0, true);
616
- pos += 2;
617
- view.setUint16(pos, 0, true);
618
- pos += 2;
619
- view.setUint16(pos, 0, true);
620
- pos += 2;
621
- view.setUint32(pos, entry.crc, true);
622
- pos += 4;
623
- view.setUint32(pos, entry.data.length, true);
624
- pos += 4;
625
- view.setUint32(pos, entry.data.length, true);
626
- pos += 4;
627
- view.setUint16(pos, entry.name.length, true);
628
- pos += 2;
629
- view.setUint16(pos, 0, true);
630
- pos += 2;
631
- bytes.set(entry.name, pos);
632
- pos += entry.name.length;
633
- bytes.set(entry.data, pos);
634
- pos += entry.data.length;
635
- }
636
- for (const { offset: localOff, entry } of localHeaders) {
637
- view.setUint32(pos, 33639248, true);
638
- pos += 4;
639
- view.setUint16(pos, 20, true);
640
- pos += 2;
641
- view.setUint16(pos, 20, true);
642
- pos += 2;
643
- view.setUint16(pos, 0, true);
644
- pos += 2;
645
- view.setUint16(pos, 0, true);
646
- pos += 2;
647
- view.setUint16(pos, 0, true);
648
- pos += 2;
649
- view.setUint16(pos, 0, true);
650
- pos += 2;
651
- view.setUint32(pos, entry.crc, true);
652
- pos += 4;
653
- view.setUint32(pos, entry.data.length, true);
654
- pos += 4;
655
- view.setUint32(pos, entry.data.length, true);
656
- pos += 4;
657
- view.setUint16(pos, entry.name.length, true);
658
- pos += 2;
659
- view.setUint16(pos, 0, true);
660
- pos += 2;
661
- view.setUint16(pos, 0, true);
662
- pos += 2;
663
- view.setUint16(pos, 0, true);
664
- pos += 2;
665
- view.setUint16(pos, 0, true);
666
- pos += 2;
667
- view.setUint32(pos, 0, true);
668
- pos += 4;
669
- view.setUint32(pos, localOff, true);
670
- pos += 4;
671
- bytes.set(entry.name, pos);
672
- pos += entry.name.length;
673
- }
674
- view.setUint32(pos, 101010256, true);
675
- pos += 4;
676
- view.setUint16(pos, 0, true);
677
- pos += 2;
678
- view.setUint16(pos, 0, true);
679
- pos += 2;
680
- view.setUint16(pos, entries.length, true);
681
- pos += 2;
682
- view.setUint16(pos, entries.length, true);
683
- pos += 2;
684
- view.setUint32(pos, centralSize, true);
685
- pos += 4;
686
- view.setUint32(pos, centralStart, true);
687
- pos += 4;
688
- view.setUint16(pos, 0, true);
709
+ for (const { entry } of localHeaders) pos = writeLocalHeader(view, bytes, pos, entry);
710
+ for (const { offset: localOff, entry } of localHeaders) pos = writeCentralDirEntry(view, bytes, pos, localOff, entry);
711
+ writeEndOfCentralDir(view, pos, entries.length, centralStart, centralSize);
689
712
  return buf;
690
713
  }
691
714
  /** Escape XML special characters in attribute values. */
@@ -696,7 +719,7 @@ function colorToHex(rgba) {
696
719
  const to8 = (v) => Math.round(Math.max(0, Math.min(1, v)) * 255).toString(16).padStart(2, "0").toUpperCase();
697
720
  return `#${to8(rgba[0])}${to8(rgba[1])}${to8(rgba[2])}${to8(rgba[3])}`;
698
721
  }
699
- function build3MFModel(mesh, name, unit, colors, materials) {
722
+ function buildVertexLines(mesh) {
700
723
  const vertices = [];
701
724
  for (let i = 0; i < mesh.vertices.length; i += 3) {
702
725
  const x = mesh.vertices[i] ?? 0;
@@ -704,6 +727,9 @@ function build3MFModel(mesh, name, unit, colors, materials) {
704
727
  const z = mesh.vertices[i + 2] ?? 0;
705
728
  vertices.push(` <vertex x="${x}" y="${y}" z="${z}" />`);
706
729
  }
730
+ return vertices;
731
+ }
732
+ function buildColorPalette(colors) {
707
733
  const colorIndexByHex = /* @__PURE__ */ new Map();
708
734
  const colorHexList = [];
709
735
  if (colors !== void 0 && colors.size > 0) for (const rgba of colors.values()) {
@@ -713,6 +739,12 @@ function build3MFModel(mesh, name, unit, colors, materials) {
713
739
  colorHexList.push(hex);
714
740
  }
715
741
  }
742
+ return {
743
+ colorIndexByHex,
744
+ colorHexList
745
+ };
746
+ }
747
+ function buildMaterialList(materials) {
716
748
  const materialIndexByName = /* @__PURE__ */ new Map();
717
749
  const materialList = [];
718
750
  if (materials !== void 0 && materials.size > 0) {
@@ -721,6 +753,12 @@ function build3MFModel(mesh, name, unit, colors, materials) {
721
753
  materialList.push(mat);
722
754
  }
723
755
  }
756
+ return {
757
+ materialIndexByName,
758
+ materialList
759
+ };
760
+ }
761
+ function buildTriangleAttrs(mesh, colors, materials, colorIndexByHex, materialIndexByName) {
724
762
  const triangleAttrs = /* @__PURE__ */ new Map();
725
763
  for (const group of mesh.faceGroups) {
726
764
  const triStart = group.start / 3;
@@ -750,6 +788,9 @@ function build3MFModel(mesh, name, unit, colors, materials) {
750
788
  }
751
789
  if (attrs !== void 0) for (let t = triStart; t < triStart + triCount; t++) triangleAttrs.set(t, attrs);
752
790
  }
791
+ return triangleAttrs;
792
+ }
793
+ function buildTriangleLines(mesh, triangleAttrs) {
753
794
  const triangles = [];
754
795
  for (let i = 0; i < mesh.triangles.length; i += 3) {
755
796
  const triIdx = i / 3;
@@ -760,6 +801,9 @@ function build3MFModel(mesh, name, unit, colors, materials) {
760
801
  if (attrs !== void 0) triangles.push(` <triangle v1="${v1}" v2="${v2}" v3="${v3}" pid="${attrs.pid}" p1="${attrs.p1}" />`);
761
802
  else triangles.push(` <triangle v1="${v1}" v2="${v2}" v3="${v3}" />`);
762
803
  }
804
+ return triangles;
805
+ }
806
+ function buildResourceBlocks(colorHexList, materialList) {
763
807
  const resourceBlocks = [];
764
808
  if (colorHexList.length > 0) {
765
809
  const colorItems = colorHexList.map((hex) => ` <color color="${hex}" />`).join("\n");
@@ -772,6 +816,14 @@ function build3MFModel(mesh, name, unit, colors, materials) {
772
816
  }).join("\n");
773
817
  resourceBlocks.push(` <basematerials id="3">\n${matItems}\n </basematerials>`);
774
818
  }
819
+ return resourceBlocks;
820
+ }
821
+ function build3MFModel(mesh, name, unit, colors, materials) {
822
+ const vertices = buildVertexLines(mesh);
823
+ const { colorIndexByHex, colorHexList } = buildColorPalette(colors);
824
+ const { materialIndexByName, materialList } = buildMaterialList(materials);
825
+ const triangles = buildTriangleLines(mesh, buildTriangleAttrs(mesh, colors, materials, colorIndexByHex, materialIndexByName));
826
+ const resourceBlocks = buildResourceBlocks(colorHexList, materialList);
775
827
  return `<?xml version="1.0" encoding="UTF-8"?>
776
828
  <model unit="${unit}" xmlns="http://schemas.microsoft.com/3dmanufacturing/core/2015/02"${materialList.length > 0 ? "\n xmlns:m=\"http://schemas.microsoft.com/3dmanufacturing/material/2015/02\"" : ""}>
777
829
  <resources>${resourceBlocks.length > 0 ? "\n" + resourceBlocks.join("\n") : ""}
package/dist/io.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_meshFns = require("./meshFns-DTn__aNb.cjs");
3
- const require_importFns = require("./importFns-A8v4Pdw2.cjs");
2
+ const require_meshFns = require("./meshFns-CIdP0f35.cjs");
3
+ const require_importFns = require("./importFns-BMN4KCmX.cjs");
4
4
  exports.blueprintToDXF = require_importFns.blueprintToDXF;
5
5
  exports.exportDXF = require_importFns.exportDXF;
6
6
  exports.exportGlb = require_importFns.exportGlb;
package/dist/io.js CHANGED
@@ -1,3 +1,3 @@
1
- import { n as exportSTEP, r as exportSTL, t as exportIGES } from "./meshFns-Bxt57KX1.js";
2
- import { a as importSVG, c as blueprintToDXF, d as exportGltf, f as exportOBJ, i as exportSTEPConfigured, l as exportDXF, n as importSTEP, o as importSVGPathD, r as importSTL, s as exportThreeMF, t as importIGES, u as exportGlb } from "./importFns-Hh3S9NPm.js";
1
+ import { n as exportSTEP, r as exportSTL, t as exportIGES } from "./meshFns-k-gSXquL.js";
2
+ import { a as importSVG, c as blueprintToDXF, d as exportGltf, f as exportOBJ, i as exportSTEPConfigured, l as exportDXF, n as importSTEP, o as importSVGPathD, r as importSTL, s as exportThreeMF, t as importIGES, u as exportGlb } from "./importFns-B9RUaVsc.js";
3
3
  export { blueprintToDXF, exportDXF, exportGlb, exportGltf, exportIGES, exportOBJ, exportSTEP, exportSTEPConfigured, exportSTL, exportThreeMF, importIGES, importSTEP, importSTL, importSVG, importSVGPathD };
@@ -89,8 +89,7 @@ export declare function sewAndSolidify(oc: KernelInstance, faces: KernelShape[],
89
89
  export declare function fixShape(oc: KernelInstance, shape: KernelShape): KernelShape;
90
90
  /** Fix self-intersections in a wire. */
91
91
  export declare function fixSelfIntersection(oc: KernelInstance, wire: KernelShape): KernelShape;
92
- /** Compute surface curvature at a UV point on a face. */
93
- export declare function surfaceCurvature(oc: KernelInstance, face: KernelShape, u: number, v: number): {
92
+ type CurvatureResult = {
94
93
  gaussian: number;
95
94
  mean: number;
96
95
  max: number;
@@ -98,6 +97,8 @@ export declare function surfaceCurvature(oc: KernelInstance, face: KernelShape,
98
97
  maxDirection: [number, number, number];
99
98
  minDirection: [number, number, number];
100
99
  };
100
+ /** Compute surface curvature at a UV point on a face. */
101
+ export declare function surfaceCurvature(oc: KernelInstance, face: KernelShape, u: number, v: number): CurvatureResult;
101
102
  /** Surface-based center of mass. */
102
103
  export declare function surfaceCenterOfMass(oc: KernelInstance, face: KernelShape): [number, number, number];
103
104
  /** Create a persistent distance query tool. */
@@ -135,12 +136,13 @@ export declare function writeXCAFToSTEP(oc: KernelInstance, doc: KernelType, opt
135
136
  unit?: string | undefined;
136
137
  modelUnit?: string | undefined;
137
138
  }): string;
138
- /** Export shapes to STEP with full configuration. */
139
- export declare function exportSTEPConfigured(oc: KernelInstance, shapes: Array<{
139
+ type ConfiguredStepPart = {
140
140
  shape: KernelShape;
141
141
  name?: string | undefined;
142
142
  color?: [number, number, number, number] | undefined;
143
- }>, options?: {
143
+ };
144
+ /** Export shapes to STEP with full configuration. */
145
+ export declare function exportSTEPConfigured(oc: KernelInstance, shapes: ConfiguredStepPart[], options?: {
144
146
  unit?: string | undefined;
145
147
  modelUnit?: string | undefined;
146
148
  schema?: number | undefined;
@@ -198,14 +200,7 @@ export declare function makeAdvancedOps(oc: KernelInstance): {
198
200
  sewAndSolidify: (faces: any[], tolerance: number) => any;
199
201
  fixShape: (shape: any) => any;
200
202
  fixSelfIntersection: (wire: any) => any;
201
- surfaceCurvature: (face: any, u: number, v: number) => {
202
- gaussian: number;
203
- mean: number;
204
- max: number;
205
- min: number;
206
- maxDirection: [number, number, number];
207
- minDirection: [number, number, number];
208
- };
203
+ surfaceCurvature: (face: any, u: number, v: number) => CurvatureResult;
209
204
  surfaceCenterOfMass: (face: any) => [number, number, number];
210
205
  createDistanceQuery: (referenceShape: any) => {
211
206
  distanceTo(shape: KernelShape): {
@@ -248,3 +243,4 @@ export declare function makeAdvancedOps(oc: KernelInstance): {
248
243
  schema?: number | undefined;
249
244
  } | undefined) => string;
250
245
  };
246
+ export {};
@@ -1,7 +1,7 @@
1
- const require_shapeTypes = require("./shapeTypes-C1FUZ2zE.cjs");
1
+ const require_shapeTypes = require("./shapeTypes-D6hfaPZq.cjs");
2
2
  const require_errors = require("./errors-DxoD7zgx.cjs");
3
- const require_topologyQueryFns = require("./topologyQueryFns-DCICDnwA.cjs");
4
- const require_faceFns = require("./faceFns-CLzDRrUE.cjs");
3
+ const require_topologyQueryFns = require("./topologyQueryFns-hG0APAJN.cjs");
4
+ const require_faceFns = require("./faceFns-BFEUkmn7.cjs");
5
5
  //#region src/measurement/measureCache.ts
6
6
  var cache = /* @__PURE__ */ new WeakMap();
7
7
  function getCachedMeasurement(shape, key) {
@@ -1,7 +1,7 @@
1
- import { Z as getKernel } from "./shapeTypes-DmHPJc_M.js";
1
+ import { Z as getKernel } from "./shapeTypes-BdIQ-d5X.js";
2
2
  import { A as ok, b as err, d as validationError, t as BrepErrorCode } from "./errors-BJSTLaDI.js";
3
- import { v as kernelCallRaw } from "./topologyQueryFns-CcHXn5M2.js";
4
- import { p as uvBounds } from "./faceFns-C3C6l-X0.js";
3
+ import { v as kernelCallRaw } from "./topologyQueryFns-Ds2H75YB.js";
4
+ import { p as uvBounds } from "./faceFns-D9UAkqPb.js";
5
5
  //#region src/measurement/measureCache.ts
6
6
  var cache = /* @__PURE__ */ new WeakMap();
7
7
  function getCachedMeasurement(shape, key) {
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_measureFns = require("./measureFns-DMyJp_x3.cjs");
2
+ const require_measureFns = require("./measureFns-CaOR1TEA.cjs");
3
3
  exports.createDistanceQuery = require_measureFns.createDistanceQuery;
4
4
  exports.measureArea = require_measureFns.measureArea;
5
5
  exports.measureDistance = require_measureFns.measureDistance;
@@ -1,2 +1,2 @@
1
- import { a as measureDistance, c as measureLinearProps, d as measureVolumeProps, l as measureSurfaceProps, n as measureArea, o as measureDistanceProps, s as measureLength, t as createDistanceQuery, u as measureVolume } from "./measureFns--uvW_r_P.js";
1
+ import { a as measureDistance, c as measureLinearProps, d as measureVolumeProps, l as measureSurfaceProps, n as measureArea, o as measureDistanceProps, s as measureLength, t as createDistanceQuery, u as measureVolume } from "./measureFns-CiCx5o_s.js";
2
2
  export { createDistanceQuery, measureArea, measureDistance, measureDistanceProps, measureLength, measureLinearProps, measureSurfaceProps, measureVolume, measureVolumeProps };
@@ -1,6 +1,6 @@
1
- const require_shapeTypes = require("./shapeTypes-C1FUZ2zE.cjs");
1
+ const require_shapeTypes = require("./shapeTypes-D6hfaPZq.cjs");
2
2
  const require_errors = require("./errors-DxoD7zgx.cjs");
3
- const require_shapeFns = require("./shapeFns-cTuUm-aP.cjs");
3
+ const require_shapeFns = require("./shapeFns-BD6oYLMM.cjs");
4
4
  //#region src/topology/meshCache.ts
5
5
  /**
6
6
  * Build a parameter key for the inner cache map (excludes shape identity).
@@ -1,6 +1,6 @@
1
- import { Z as getKernel } from "./shapeTypes-DmHPJc_M.js";
1
+ import { Z as getKernel } from "./shapeTypes-BdIQ-d5X.js";
2
2
  import { A as ok, b as err, r as ioError } from "./errors-BJSTLaDI.js";
3
- import { O as getFaceOrigins } from "./shapeFns-Dsxp5d_u.js";
3
+ import { O as getFaceOrigins } from "./shapeFns-ByuSx62n.js";
4
4
  //#region src/topology/meshCache.ts
5
5
  /**
6
6
  * Build a parameter key for the inner cache map (excludes shape identity).
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_historyFns = require("./historyFns-DSCnjCkQ.cjs");
3
- const require_extrudeFns = require("./extrudeFns-DUPpueiL.cjs");
2
+ const require_historyFns = require("./historyFns-BX9Bu5NT.cjs");
3
+ const require_extrudeFns = require("./extrudeFns-CLrrRprF.cjs");
4
4
  exports.addChild = require_historyFns.addChild;
5
5
  exports.addStep = require_historyFns.addStep;
6
6
  exports.circularPattern = require_historyFns.circularPattern;
@@ -1,3 +1,3 @@
1
- import { C as walkAssembly, D as exportAssemblySTEP, E as linearPattern, O as createAssembly, S as updateNode, T as gridPattern, _ as collectShapes, a as findStep, b as findNode, c as registerOperation, d as replayHistory, g as addChild, h as undoLast, l as registerShape, m as stepsFrom, n as createHistory, o as getShape, p as stepCount, r as createRegistry, s as modifyStep, t as addStep, u as replayFrom, v as countNodes, w as circularPattern, x as removeChild, y as createAssemblyNode } from "./historyFns-CEr9D6ay.js";
2
- import { c as sweep, i as complexExtrude, l as twistExtrude, s as supportExtrude } from "./extrudeFns-CRG478Q3.js";
1
+ import { C as walkAssembly, D as exportAssemblySTEP, E as linearPattern, O as createAssembly, S as updateNode, T as gridPattern, _ as collectShapes, a as findStep, b as findNode, c as registerOperation, d as replayHistory, g as addChild, h as undoLast, l as registerShape, m as stepsFrom, n as createHistory, o as getShape, p as stepCount, r as createRegistry, s as modifyStep, t as addStep, u as replayFrom, v as countNodes, w as circularPattern, x as removeChild, y as createAssemblyNode } from "./historyFns-DGDKVD6-.js";
2
+ import { c as sweep, i as complexExtrude, l as twistExtrude, s as supportExtrude } from "./extrudeFns-BmF17qhf.js";
3
3
  export { addChild, addStep, circularPattern, collectShapes, complexExtrude, countNodes, createAssembly, createAssemblyNode, createHistory, createRegistry, exportAssemblySTEP, findNode, findStep, getShape as getHistoryShape, gridPattern, linearPattern, modifyStep, registerOperation, registerShape, removeChild, replayFrom, replayHistory, stepCount, stepsFrom, supportExtrude, sweep, twistExtrude, undoLast, updateNode, walkAssembly };