brepjs 18.69.0 → 18.69.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/2d.cjs +6 -6
  2. package/dist/2d.js +6 -6
  3. package/dist/{blueprint-a7QLhV4U.cjs → blueprint-DIQeD9xj.cjs} +5 -5
  4. package/dist/{blueprint-Z5mhI2QD.js → blueprint-Dgl9IkCV.js} +5 -5
  5. package/dist/{blueprintFns-DULa6FpG.cjs → blueprintFns-BO44cqFY.cjs} +2 -2
  6. package/dist/{blueprintFns-BNhsXv6q.js → blueprintFns-sKzHcJ4U.js} +2 -2
  7. package/dist/{blueprintSketcher-4zOPSOnK.cjs → blueprintSketcher-BpOknLmX.cjs} +3 -3
  8. package/dist/{blueprintSketcher-0DeTMXwj.js → blueprintSketcher-DbINWerx.js} +3 -3
  9. package/dist/{boolean2D-BNWuFXK_.js → boolean2D-CreNaKXt.js} +4 -4
  10. package/dist/{boolean2D-xDBZQH_n.cjs → boolean2D-DZcOTOSA.cjs} +4 -4
  11. package/dist/{booleanFns-CaKngiuu.js → booleanFns-0jDBFjAv.js} +4 -4
  12. package/dist/{booleanFns-aeG4pQmM.cjs → booleanFns-DvXg6a2Y.cjs} +4 -4
  13. package/dist/brepjs.cjs +25 -25
  14. package/dist/brepjs.js +25 -25
  15. package/dist/{cameraFns-k787od3u.js → cameraFns-Bwxq0IDz.js} +2 -2
  16. package/dist/{cameraFns-Bk8frXwa.cjs → cameraFns-CsGSVYgb.cjs} +2 -2
  17. package/dist/core.cjs +1 -1
  18. package/dist/core.js +1 -1
  19. package/dist/{cornerFinder-tTS3ny7e.cjs → cornerFinder-ChltJ_ur.cjs} +1 -1
  20. package/dist/{cornerFinder-B8GvvW0U.js → cornerFinder-fMf9-El_.js} +1 -1
  21. package/dist/{curveFns-DvNBwUdJ.js → curveFns-BhTtS18d.js} +1 -1
  22. package/dist/{curveFns-CYP8UOgX.cjs → curveFns-CXytEfTr.cjs} +1 -1
  23. package/dist/{drawFns-Chpdmj4G.cjs → drawFns-Bn4vzbUr.cjs} +12 -12
  24. package/dist/{drawFns-DmAPsfmx.js → drawFns-Bzr38vZx.js} +12 -12
  25. package/dist/{extrudeFns-IvYW5-8y.cjs → extrudeFns-C0FsOXev.cjs} +1 -1
  26. package/dist/{extrudeFns-CMr1tf7I.js → extrudeFns-rnUgev_g.js} +1 -1
  27. package/dist/{faceFns-CZp3Y8vi.js → faceFns-Dreo5ksY.js} +2 -2
  28. package/dist/{faceFns-Byt7Vd3F.cjs → faceFns-FAZgMVCx.cjs} +2 -2
  29. package/dist/{helpers-BX-0e71G.js → helpers--BMa_zB7.js} +6 -6
  30. package/dist/{helpers-wFts3ttt.cjs → helpers-D8ycrNeD.cjs} +6 -6
  31. package/dist/{historyFns-CZ9oNL7j.js → historyFns-CR0RejKJ.js} +4 -4
  32. package/dist/{historyFns-BzPsKySX.cjs → historyFns-mnmeZ0kB.cjs} +4 -4
  33. package/dist/{importFns-CwILDYiQ.cjs → importFns-4mi5Ih46.cjs} +32 -13
  34. package/dist/{importFns-1SHLSNtG.js → importFns-DRPQExAD.js} +32 -13
  35. package/dist/index.d.ts +1 -1
  36. package/dist/io/gltfExportFns.d.ts +25 -0
  37. package/dist/io.cjs +2 -2
  38. package/dist/io.d.ts +1 -1
  39. package/dist/io.js +2 -2
  40. package/dist/kernel/brepkit/ioOps.d.ts +2 -2
  41. package/dist/kernel/occtWasm/ioOps.d.ts +1 -1
  42. package/dist/kernel/occtWasm/occtWasmAdapter.cjs +1 -1
  43. package/dist/kernel/occtWasm/occtWasmAdapter.js +1 -1
  44. package/dist/kernel/stlBuilder.d.ts +20 -0
  45. package/dist/{measureFns-CvvenWkS.js → measureFns-BLEx4ZU3.js} +3 -3
  46. package/dist/{measureFns-CrSEblGG.cjs → measureFns-CT0XaSOt.cjs} +3 -3
  47. package/dist/measurement.cjs +1 -1
  48. package/dist/measurement.js +1 -1
  49. package/dist/{meshFns-0RHalM3t.js → meshFns-B3MjIqk1.js} +3 -3
  50. package/dist/{meshFns-DwHAYqRN.cjs → meshFns-lwgHYQ79.cjs} +3 -3
  51. package/dist/{occtWasmAdapter-BPu07Zxg.cjs → occtWasmAdapter-BH7r2nTq.cjs} +137 -51
  52. package/dist/{occtWasmAdapter-Ctfykwr2.js → occtWasmAdapter-C7FDeTaw.js} +114 -52
  53. package/dist/operations.cjs +2 -2
  54. package/dist/operations.js +2 -2
  55. package/dist/{primitiveFns-CKCALTVe.cjs → primitiveFns-DZmgvzvk.cjs} +7 -7
  56. package/dist/{primitiveFns-ecKWNC5k.js → primitiveFns-DcZDTQ_R.js} +7 -7
  57. package/dist/projection.cjs +1 -1
  58. package/dist/projection.js +1 -1
  59. package/dist/query.cjs +2 -2
  60. package/dist/query.js +2 -2
  61. package/dist/{shapeFns-D63FuB8f.js → shapeFns-BnkizFjV.js} +2 -2
  62. package/dist/{shapeFns-B5JrP5aD.cjs → shapeFns-w1YoIn_p.cjs} +2 -2
  63. package/dist/shapeRef.cjs +1 -1
  64. package/dist/shapeRef.js +1 -1
  65. package/dist/{shapeRefFns-H_O8zyAx.cjs → shapeRefFns-B3myHs0D.cjs} +4 -4
  66. package/dist/{shapeRefFns-DjGKujf0.js → shapeRefFns-OVWdFOAC.js} +4 -4
  67. package/dist/{shapeTypes-kAKwccy_.cjs → shapeTypes-BIlZar9m.cjs} +174 -172
  68. package/dist/{shapeTypes-RYLpXWzG.js → shapeTypes-yCQ8z5Hc.js} +174 -172
  69. package/dist/sketching.cjs +3 -3
  70. package/dist/sketching.js +3 -3
  71. package/dist/{solidBuilders-0SgkQ386.js → solidBuilders-CPOTKI5i.js} +2 -2
  72. package/dist/{solidBuilders-B2IX6Pm8.cjs → solidBuilders-dNhToZgl.cjs} +2 -2
  73. package/dist/{surfaceBuilders-jx81G_YJ.js → surfaceBuilders-CS1QccDv.js} +2 -2
  74. package/dist/{surfaceBuilders-BkvJS8pw.cjs → surfaceBuilders-CzHPZtd3.cjs} +2 -2
  75. package/dist/text.cjs +2 -2
  76. package/dist/text.js +2 -2
  77. package/dist/{textBlueprints-BXGrW7Ak.js → textBlueprints-B57ej88L.js} +7 -7
  78. package/dist/{textBlueprints-Q2gxuZd1.cjs → textBlueprints-TG6AH06v.cjs} +7 -7
  79. package/dist/{textMetrics-V7TXOETY.js → textMetrics-BxtB3sjj.js} +1 -1
  80. package/dist/{textMetrics-CnCjqf59.cjs → textMetrics-Dag-YREs.cjs} +1 -1
  81. package/dist/topology.cjs +7 -7
  82. package/dist/topology.js +7 -7
  83. package/dist/{topologyQueryFns-Ck5trXrW.cjs → topologyQueryFns-BuWZAQ_o.cjs} +1 -1
  84. package/dist/{topologyQueryFns-BtWPlP5v.js → topologyQueryFns-Bxdnl5Vt.js} +1 -1
  85. package/package.json +1 -1
@@ -1004,6 +1004,111 @@ function evaluateBSpline2d(c, t) {
1004
1004
  return d[p];
1005
1005
  }
1006
1006
  //#endregion
1007
+ //#region src/kernel/stlBuilder.ts
1008
+ /**
1009
+ * Kernel-agnostic STL serializers.
1010
+ *
1011
+ * Both writers take a triangle soup (positions + indices) and emit STL. Facet
1012
+ * normals are derived from triangle winding (right-hand rule) rather than the
1013
+ * mesh's per-vertex normals, matching the per-facet STL format.
1014
+ * @module
1015
+ */
1016
+ /**
1017
+ * Default tessellation tolerances for STL export, shared by every kernel
1018
+ * adapter so per-adapter defaults can't drift. Callers normally pass explicit
1019
+ * values (the public `exportSTL` derives them from the active quality level);
1020
+ * these apply only to direct kernel-level calls made without arguments.
1021
+ */
1022
+ var DEFAULT_STL_TOLERANCE = .001;
1023
+ var DEFAULT_STL_ANGULAR_TOLERANCE = .1;
1024
+ var scratch = {
1025
+ nx: 0,
1026
+ ny: 0,
1027
+ nz: 0,
1028
+ ax: 0,
1029
+ ay: 0,
1030
+ az: 0,
1031
+ bx: 0,
1032
+ by: 0,
1033
+ bz: 0,
1034
+ cx: 0,
1035
+ cy: 0,
1036
+ cz: 0
1037
+ };
1038
+ function facetAt(vertices, triangles, i) {
1039
+ const ia = (triangles[i * 3] ?? 0) * 3;
1040
+ const ib = (triangles[i * 3 + 1] ?? 0) * 3;
1041
+ const ic = (triangles[i * 3 + 2] ?? 0) * 3;
1042
+ const ax = vertices[ia] ?? 0, ay = vertices[ia + 1] ?? 0, az = vertices[ia + 2] ?? 0;
1043
+ const bx = vertices[ib] ?? 0, by = vertices[ib + 1] ?? 0, bz = vertices[ib + 2] ?? 0;
1044
+ const cx = vertices[ic] ?? 0, cy = vertices[ic + 1] ?? 0, cz = vertices[ic + 2] ?? 0;
1045
+ const ux = bx - ax, uy = by - ay, uz = bz - az;
1046
+ const vx = cx - ax, vy = cy - ay, vz = cz - az;
1047
+ let nx = uy * vz - uz * vy;
1048
+ let ny = uz * vx - ux * vz;
1049
+ let nz = ux * vy - uy * vx;
1050
+ const len = Math.hypot(nx, ny, nz) || 1;
1051
+ nx /= len;
1052
+ ny /= len;
1053
+ nz /= len;
1054
+ scratch.nx = nx;
1055
+ scratch.ny = ny;
1056
+ scratch.nz = nz;
1057
+ scratch.ax = ax;
1058
+ scratch.ay = ay;
1059
+ scratch.az = az;
1060
+ scratch.bx = bx;
1061
+ scratch.by = by;
1062
+ scratch.bz = bz;
1063
+ scratch.cx = cx;
1064
+ scratch.cy = cy;
1065
+ scratch.cz = cz;
1066
+ return scratch;
1067
+ }
1068
+ /** Serialize a triangle soup as a binary STL (80-byte header + uint32 count + 50B/tri). */
1069
+ function buildBinarySTL(vertices, triangles) {
1070
+ const triCount = Math.floor(triangles.length / 3);
1071
+ const buffer = /* @__PURE__ */ new ArrayBuffer(84 + triCount * 50);
1072
+ const view = new DataView(buffer);
1073
+ view.setUint32(80, triCount, true);
1074
+ let offset = 84;
1075
+ for (let i = 0; i < triCount; i++) {
1076
+ const f = facetAt(vertices, triangles, i);
1077
+ view.setFloat32(offset, f.nx, true);
1078
+ view.setFloat32(offset + 4, f.ny, true);
1079
+ view.setFloat32(offset + 8, f.nz, true);
1080
+ view.setFloat32(offset + 12, f.ax, true);
1081
+ view.setFloat32(offset + 16, f.ay, true);
1082
+ view.setFloat32(offset + 20, f.az, true);
1083
+ view.setFloat32(offset + 24, f.bx, true);
1084
+ view.setFloat32(offset + 28, f.by, true);
1085
+ view.setFloat32(offset + 32, f.bz, true);
1086
+ view.setFloat32(offset + 36, f.cx, true);
1087
+ view.setFloat32(offset + 40, f.cy, true);
1088
+ view.setFloat32(offset + 44, f.cz, true);
1089
+ view.setUint16(offset + 48, 0, true);
1090
+ offset += 50;
1091
+ }
1092
+ return buffer;
1093
+ }
1094
+ /** Serialize a triangle soup as an ASCII STL. */
1095
+ function buildAsciiSTL(vertices, triangles) {
1096
+ const triCount = Math.floor(triangles.length / 3);
1097
+ const lines = ["solid brepjs"];
1098
+ for (let i = 0; i < triCount; i++) {
1099
+ const f = facetAt(vertices, triangles, i);
1100
+ lines.push(`facet normal ${f.nx} ${f.ny} ${f.nz}`);
1101
+ lines.push("outer loop");
1102
+ lines.push(`vertex ${f.ax} ${f.ay} ${f.az}`);
1103
+ lines.push(`vertex ${f.bx} ${f.by} ${f.bz}`);
1104
+ lines.push(`vertex ${f.cx} ${f.cy} ${f.cz}`);
1105
+ lines.push("endloop");
1106
+ lines.push("endfacet");
1107
+ }
1108
+ lines.push("endsolid brepjs");
1109
+ return lines.join("\n") + "\n";
1110
+ }
1111
+ //#endregion
1007
1112
  //#region src/kernel/occtWasm/helpers.ts
1008
1113
  var noop = () => {};
1009
1114
  /** Build an opaque kernel handle for an arena-allocated WASM shape. */
@@ -2671,56 +2776,13 @@ function exportSTEP(k, makeCompound, shapes) {
2671
2776
  const compound = makeCompound(shapes);
2672
2777
  return k.exportStep(unwrap(compound));
2673
2778
  }
2674
- function exportSTL(k, mesh, shape, binary, tolerance = .001, angularTolerance = .1) {
2675
- if (binary) {
2676
- const { vertices, triangles } = mesh(shape, {
2677
- tolerance,
2678
- angularTolerance,
2679
- skipNormals: true
2680
- });
2681
- return buildBinarySTL(vertices, triangles);
2682
- }
2683
- return k.exportStl(unwrap(shape), tolerance, true);
2684
- }
2685
- /** Serialize a triangle soup as a binary STL (80-byte header + uint32 count + 50B/tri). */
2686
- function buildBinarySTL(vertices, triangles) {
2687
- const triCount = Math.floor(triangles.length / 3);
2688
- const buffer = /* @__PURE__ */ new ArrayBuffer(84 + triCount * 50);
2689
- const view = new DataView(buffer);
2690
- view.setUint32(80, triCount, true);
2691
- let offset = 84;
2692
- for (let i = 0; i < triCount; i++) {
2693
- const ia = (triangles[i * 3] ?? 0) * 3;
2694
- const ib = (triangles[i * 3 + 1] ?? 0) * 3;
2695
- const ic = (triangles[i * 3 + 2] ?? 0) * 3;
2696
- const ax = vertices[ia] ?? 0, ay = vertices[ia + 1] ?? 0, az = vertices[ia + 2] ?? 0;
2697
- const bx = vertices[ib] ?? 0, by = vertices[ib + 1] ?? 0, bz = vertices[ib + 2] ?? 0;
2698
- const cx = vertices[ic] ?? 0, cy = vertices[ic + 1] ?? 0, cz = vertices[ic + 2] ?? 0;
2699
- const ux = bx - ax, uy = by - ay, uz = bz - az;
2700
- const vx = cx - ax, vy = cy - ay, vz = cz - az;
2701
- let nx = uy * vz - uz * vy;
2702
- let ny = uz * vx - ux * vz;
2703
- let nz = ux * vy - uy * vx;
2704
- const len = Math.hypot(nx, ny, nz) || 1;
2705
- nx /= len;
2706
- ny /= len;
2707
- nz /= len;
2708
- view.setFloat32(offset, nx, true);
2709
- view.setFloat32(offset + 4, ny, true);
2710
- view.setFloat32(offset + 8, nz, true);
2711
- view.setFloat32(offset + 12, ax, true);
2712
- view.setFloat32(offset + 16, ay, true);
2713
- view.setFloat32(offset + 20, az, true);
2714
- view.setFloat32(offset + 24, bx, true);
2715
- view.setFloat32(offset + 28, by, true);
2716
- view.setFloat32(offset + 32, bz, true);
2717
- view.setFloat32(offset + 36, cx, true);
2718
- view.setFloat32(offset + 40, cy, true);
2719
- view.setFloat32(offset + 44, cz, true);
2720
- view.setUint16(offset + 48, 0, true);
2721
- offset += 50;
2722
- }
2723
- return buffer;
2779
+ function exportSTL(mesh, shape, binary, tolerance = DEFAULT_STL_TOLERANCE, angularTolerance = DEFAULT_STL_ANGULAR_TOLERANCE) {
2780
+ const { vertices, triangles } = mesh(shape, {
2781
+ tolerance,
2782
+ angularTolerance,
2783
+ skipNormals: true
2784
+ });
2785
+ return binary ? buildBinarySTL(vertices, triangles) : buildAsciiSTL(vertices, triangles);
2724
2786
  }
2725
2787
  function importSTEP(k, data) {
2726
2788
  const str = typeof data === "string" ? data : new TextDecoder().decode(data);
@@ -4503,7 +4565,7 @@ var OcctWasmAdapter = class OcctWasmAdapter {
4503
4565
  return exportSTEP(this.k, this.makeCompound.bind(this), shapes);
4504
4566
  }
4505
4567
  exportSTL(shape, binary, tolerance, angularTolerance) {
4506
- return exportSTL(this.k, this.mesh.bind(this), shape, binary, tolerance, angularTolerance);
4568
+ return exportSTL(this.mesh.bind(this), shape, binary, tolerance, angularTolerance);
4507
4569
  }
4508
4570
  importSTEP(data) {
4509
4571
  return importSTEP(this.k, data);
@@ -4952,6 +5014,18 @@ Object.defineProperty(exports, "DEFAULT_CAPABILITIES", {
4952
5014
  return DEFAULT_CAPABILITIES;
4953
5015
  }
4954
5016
  });
5017
+ Object.defineProperty(exports, "DEFAULT_STL_ANGULAR_TOLERANCE", {
5018
+ enumerable: true,
5019
+ get: function() {
5020
+ return DEFAULT_STL_ANGULAR_TOLERANCE;
5021
+ }
5022
+ });
5023
+ Object.defineProperty(exports, "DEFAULT_STL_TOLERANCE", {
5024
+ enumerable: true,
5025
+ get: function() {
5026
+ return DEFAULT_STL_TOLERANCE;
5027
+ }
5028
+ });
4955
5029
  Object.defineProperty(exports, "EXACT_BREP_CAPABILITIES", {
4956
5030
  enumerable: true,
4957
5031
  get: function() {
@@ -4970,6 +5044,18 @@ Object.defineProperty(exports, "addCurveToBBox", {
4970
5044
  return addCurveToBBox;
4971
5045
  }
4972
5046
  });
5047
+ Object.defineProperty(exports, "buildAsciiSTL", {
5048
+ enumerable: true,
5049
+ get: function() {
5050
+ return buildAsciiSTL;
5051
+ }
5052
+ });
5053
+ Object.defineProperty(exports, "buildBinarySTL", {
5054
+ enumerable: true,
5055
+ get: function() {
5056
+ return buildBinarySTL;
5057
+ }
5058
+ });
4973
5059
  Object.defineProperty(exports, "createBBox2d", {
4974
5060
  enumerable: true,
4975
5061
  get: function() {
@@ -1004,6 +1004,111 @@ function evaluateBSpline2d(c, t) {
1004
1004
  return d[p];
1005
1005
  }
1006
1006
  //#endregion
1007
+ //#region src/kernel/stlBuilder.ts
1008
+ /**
1009
+ * Kernel-agnostic STL serializers.
1010
+ *
1011
+ * Both writers take a triangle soup (positions + indices) and emit STL. Facet
1012
+ * normals are derived from triangle winding (right-hand rule) rather than the
1013
+ * mesh's per-vertex normals, matching the per-facet STL format.
1014
+ * @module
1015
+ */
1016
+ /**
1017
+ * Default tessellation tolerances for STL export, shared by every kernel
1018
+ * adapter so per-adapter defaults can't drift. Callers normally pass explicit
1019
+ * values (the public `exportSTL` derives them from the active quality level);
1020
+ * these apply only to direct kernel-level calls made without arguments.
1021
+ */
1022
+ var DEFAULT_STL_TOLERANCE = .001;
1023
+ var DEFAULT_STL_ANGULAR_TOLERANCE = .1;
1024
+ var scratch = {
1025
+ nx: 0,
1026
+ ny: 0,
1027
+ nz: 0,
1028
+ ax: 0,
1029
+ ay: 0,
1030
+ az: 0,
1031
+ bx: 0,
1032
+ by: 0,
1033
+ bz: 0,
1034
+ cx: 0,
1035
+ cy: 0,
1036
+ cz: 0
1037
+ };
1038
+ function facetAt(vertices, triangles, i) {
1039
+ const ia = (triangles[i * 3] ?? 0) * 3;
1040
+ const ib = (triangles[i * 3 + 1] ?? 0) * 3;
1041
+ const ic = (triangles[i * 3 + 2] ?? 0) * 3;
1042
+ const ax = vertices[ia] ?? 0, ay = vertices[ia + 1] ?? 0, az = vertices[ia + 2] ?? 0;
1043
+ const bx = vertices[ib] ?? 0, by = vertices[ib + 1] ?? 0, bz = vertices[ib + 2] ?? 0;
1044
+ const cx = vertices[ic] ?? 0, cy = vertices[ic + 1] ?? 0, cz = vertices[ic + 2] ?? 0;
1045
+ const ux = bx - ax, uy = by - ay, uz = bz - az;
1046
+ const vx = cx - ax, vy = cy - ay, vz = cz - az;
1047
+ let nx = uy * vz - uz * vy;
1048
+ let ny = uz * vx - ux * vz;
1049
+ let nz = ux * vy - uy * vx;
1050
+ const len = Math.hypot(nx, ny, nz) || 1;
1051
+ nx /= len;
1052
+ ny /= len;
1053
+ nz /= len;
1054
+ scratch.nx = nx;
1055
+ scratch.ny = ny;
1056
+ scratch.nz = nz;
1057
+ scratch.ax = ax;
1058
+ scratch.ay = ay;
1059
+ scratch.az = az;
1060
+ scratch.bx = bx;
1061
+ scratch.by = by;
1062
+ scratch.bz = bz;
1063
+ scratch.cx = cx;
1064
+ scratch.cy = cy;
1065
+ scratch.cz = cz;
1066
+ return scratch;
1067
+ }
1068
+ /** Serialize a triangle soup as a binary STL (80-byte header + uint32 count + 50B/tri). */
1069
+ function buildBinarySTL(vertices, triangles) {
1070
+ const triCount = Math.floor(triangles.length / 3);
1071
+ const buffer = /* @__PURE__ */ new ArrayBuffer(84 + triCount * 50);
1072
+ const view = new DataView(buffer);
1073
+ view.setUint32(80, triCount, true);
1074
+ let offset = 84;
1075
+ for (let i = 0; i < triCount; i++) {
1076
+ const f = facetAt(vertices, triangles, i);
1077
+ view.setFloat32(offset, f.nx, true);
1078
+ view.setFloat32(offset + 4, f.ny, true);
1079
+ view.setFloat32(offset + 8, f.nz, true);
1080
+ view.setFloat32(offset + 12, f.ax, true);
1081
+ view.setFloat32(offset + 16, f.ay, true);
1082
+ view.setFloat32(offset + 20, f.az, true);
1083
+ view.setFloat32(offset + 24, f.bx, true);
1084
+ view.setFloat32(offset + 28, f.by, true);
1085
+ view.setFloat32(offset + 32, f.bz, true);
1086
+ view.setFloat32(offset + 36, f.cx, true);
1087
+ view.setFloat32(offset + 40, f.cy, true);
1088
+ view.setFloat32(offset + 44, f.cz, true);
1089
+ view.setUint16(offset + 48, 0, true);
1090
+ offset += 50;
1091
+ }
1092
+ return buffer;
1093
+ }
1094
+ /** Serialize a triangle soup as an ASCII STL. */
1095
+ function buildAsciiSTL(vertices, triangles) {
1096
+ const triCount = Math.floor(triangles.length / 3);
1097
+ const lines = ["solid brepjs"];
1098
+ for (let i = 0; i < triCount; i++) {
1099
+ const f = facetAt(vertices, triangles, i);
1100
+ lines.push(`facet normal ${f.nx} ${f.ny} ${f.nz}`);
1101
+ lines.push("outer loop");
1102
+ lines.push(`vertex ${f.ax} ${f.ay} ${f.az}`);
1103
+ lines.push(`vertex ${f.bx} ${f.by} ${f.bz}`);
1104
+ lines.push(`vertex ${f.cx} ${f.cy} ${f.cz}`);
1105
+ lines.push("endloop");
1106
+ lines.push("endfacet");
1107
+ }
1108
+ lines.push("endsolid brepjs");
1109
+ return lines.join("\n") + "\n";
1110
+ }
1111
+ //#endregion
1007
1112
  //#region src/kernel/occtWasm/helpers.ts
1008
1113
  var noop = () => {};
1009
1114
  /** Build an opaque kernel handle for an arena-allocated WASM shape. */
@@ -2671,56 +2776,13 @@ function exportSTEP(k, makeCompound, shapes) {
2671
2776
  const compound = makeCompound(shapes);
2672
2777
  return k.exportStep(unwrap(compound));
2673
2778
  }
2674
- function exportSTL(k, mesh, shape, binary, tolerance = .001, angularTolerance = .1) {
2675
- if (binary) {
2676
- const { vertices, triangles } = mesh(shape, {
2677
- tolerance,
2678
- angularTolerance,
2679
- skipNormals: true
2680
- });
2681
- return buildBinarySTL(vertices, triangles);
2682
- }
2683
- return k.exportStl(unwrap(shape), tolerance, true);
2684
- }
2685
- /** Serialize a triangle soup as a binary STL (80-byte header + uint32 count + 50B/tri). */
2686
- function buildBinarySTL(vertices, triangles) {
2687
- const triCount = Math.floor(triangles.length / 3);
2688
- const buffer = /* @__PURE__ */ new ArrayBuffer(84 + triCount * 50);
2689
- const view = new DataView(buffer);
2690
- view.setUint32(80, triCount, true);
2691
- let offset = 84;
2692
- for (let i = 0; i < triCount; i++) {
2693
- const ia = (triangles[i * 3] ?? 0) * 3;
2694
- const ib = (triangles[i * 3 + 1] ?? 0) * 3;
2695
- const ic = (triangles[i * 3 + 2] ?? 0) * 3;
2696
- const ax = vertices[ia] ?? 0, ay = vertices[ia + 1] ?? 0, az = vertices[ia + 2] ?? 0;
2697
- const bx = vertices[ib] ?? 0, by = vertices[ib + 1] ?? 0, bz = vertices[ib + 2] ?? 0;
2698
- const cx = vertices[ic] ?? 0, cy = vertices[ic + 1] ?? 0, cz = vertices[ic + 2] ?? 0;
2699
- const ux = bx - ax, uy = by - ay, uz = bz - az;
2700
- const vx = cx - ax, vy = cy - ay, vz = cz - az;
2701
- let nx = uy * vz - uz * vy;
2702
- let ny = uz * vx - ux * vz;
2703
- let nz = ux * vy - uy * vx;
2704
- const len = Math.hypot(nx, ny, nz) || 1;
2705
- nx /= len;
2706
- ny /= len;
2707
- nz /= len;
2708
- view.setFloat32(offset, nx, true);
2709
- view.setFloat32(offset + 4, ny, true);
2710
- view.setFloat32(offset + 8, nz, true);
2711
- view.setFloat32(offset + 12, ax, true);
2712
- view.setFloat32(offset + 16, ay, true);
2713
- view.setFloat32(offset + 20, az, true);
2714
- view.setFloat32(offset + 24, bx, true);
2715
- view.setFloat32(offset + 28, by, true);
2716
- view.setFloat32(offset + 32, bz, true);
2717
- view.setFloat32(offset + 36, cx, true);
2718
- view.setFloat32(offset + 40, cy, true);
2719
- view.setFloat32(offset + 44, cz, true);
2720
- view.setUint16(offset + 48, 0, true);
2721
- offset += 50;
2722
- }
2723
- return buffer;
2779
+ function exportSTL(mesh, shape, binary, tolerance = DEFAULT_STL_TOLERANCE, angularTolerance = DEFAULT_STL_ANGULAR_TOLERANCE) {
2780
+ const { vertices, triangles } = mesh(shape, {
2781
+ tolerance,
2782
+ angularTolerance,
2783
+ skipNormals: true
2784
+ });
2785
+ return binary ? buildBinarySTL(vertices, triangles) : buildAsciiSTL(vertices, triangles);
2724
2786
  }
2725
2787
  function importSTEP(k, data) {
2726
2788
  const str = typeof data === "string" ? data : new TextDecoder().decode(data);
@@ -4503,7 +4565,7 @@ var OcctWasmAdapter = class OcctWasmAdapter {
4503
4565
  return exportSTEP(this.k, this.makeCompound.bind(this), shapes);
4504
4566
  }
4505
4567
  exportSTL(shape, binary, tolerance, angularTolerance) {
4506
- return exportSTL(this.k, this.mesh.bind(this), shape, binary, tolerance, angularTolerance);
4568
+ return exportSTL(this.mesh.bind(this), shape, binary, tolerance, angularTolerance);
4507
4569
  }
4508
4570
  importSTEP(data) {
4509
4571
  return importSTEP(this.k, data);
@@ -4946,4 +5008,4 @@ var OcctWasmAdapter = class OcctWasmAdapter {
4946
5008
  }
4947
5009
  };
4948
5010
  //#endregion
4949
- export { EXACT_BREP_CAPABILITIES as S, serializeCurve2d$1 as _, curveTypeName as a, quickHull as b, intersectCurves2dFn as c, makeEllipse2d$1 as d, makeLine2d$1 as f, scaleCurve2d$1 as g, rotateCurve2d$1 as h, curveBounds as i, makeBezier2d$1 as l, mirrorAtPoint as m, addCurveToBBox as n, deserializeCurve2d$1 as o, mirrorAcrossAxis as p, createBBox2d as r, evaluateCurve2d$1 as s, OcctWasmAdapter as t, makeCircle2d$1 as u, tangentCurve2d as v, DEFAULT_CAPABILITIES as x, translateCurve2d$1 as y };
5011
+ export { translateCurve2d$1 as C, EXACT_BREP_CAPABILITIES as E, tangentCurve2d as S, DEFAULT_CAPABILITIES as T, mirrorAcrossAxis as _, buildBinarySTL as a, scaleCurve2d$1 as b, curveBounds as c, evaluateCurve2d$1 as d, intersectCurves2dFn as f, makeLine2d$1 as g, makeEllipse2d$1 as h, buildAsciiSTL as i, curveTypeName as l, makeCircle2d$1 as m, DEFAULT_STL_ANGULAR_TOLERANCE as n, addCurveToBBox as o, makeBezier2d$1 as p, DEFAULT_STL_TOLERANCE as r, createBBox2d as s, OcctWasmAdapter as t, deserializeCurve2d$1 as u, mirrorAtPoint as v, quickHull as w, serializeCurve2d$1 as x, rotateCurve2d$1 as y };
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_historyFns = require("./historyFns-BzPsKySX.cjs");
3
- const require_extrudeFns = require("./extrudeFns-IvYW5-8y.cjs");
2
+ const require_historyFns = require("./historyFns-mnmeZ0kB.cjs");
3
+ const require_extrudeFns = require("./extrudeFns-C0FsOXev.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-CZ9oNL7j.js";
2
- import { c as sweep, i as complexExtrude, l as twistExtrude, s as supportExtrude } from "./extrudeFns-CMr1tf7I.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-CR0RejKJ.js";
2
+ import { c as sweep, i as complexExtrude, l as twistExtrude, s as supportExtrude } from "./extrudeFns-rnUgev_g.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 };
@@ -1,13 +1,13 @@
1
- const require_shapeTypes = require("./shapeTypes-kAKwccy_.cjs");
1
+ const require_shapeTypes = require("./shapeTypes-BIlZar9m.cjs");
2
2
  const require_errors = require("./errors-CXJtc4I7.cjs");
3
- const require_topologyQueryFns = require("./topologyQueryFns-Ck5trXrW.cjs");
3
+ const require_topologyQueryFns = require("./topologyQueryFns-BuWZAQ_o.cjs");
4
4
  const require_constants = require("./constants-BOVyEYGH.cjs");
5
- const require_faceFns = require("./faceFns-Byt7Vd3F.cjs");
6
- const require_shapeFns = require("./shapeFns-B5JrP5aD.cjs");
5
+ const require_faceFns = require("./faceFns-FAZgMVCx.cjs");
6
+ const require_shapeFns = require("./shapeFns-w1YoIn_p.cjs");
7
7
  const require_arrayAccess = require("./arrayAccess-e4H9cBfh.cjs");
8
- const require_surfaceBuilders = require("./surfaceBuilders-BkvJS8pw.cjs");
9
- const require_booleanFns = require("./booleanFns-aeG4pQmM.cjs");
10
- const require_solidBuilders = require("./solidBuilders-B2IX6Pm8.cjs");
8
+ const require_surfaceBuilders = require("./surfaceBuilders-CzHPZtd3.cjs");
9
+ const require_booleanFns = require("./booleanFns-DvXg6a2Y.cjs");
10
+ const require_solidBuilders = require("./solidBuilders-dNhToZgl.cjs");
11
11
  //#region src/topology/threeHelpers.ts
12
12
  /**
13
13
  * Convert a ShapeMesh into BufferGeometry-compatible typed arrays.
@@ -1,13 +1,13 @@
1
- import { Z as getKernel, _ as isSolid, c as createSolid, h as isShape3D, p as isFace, r as castShapeWithKnownType, t as castShape, x as isClosedWire, y as isWire } from "./shapeTypes-RYLpXWzG.js";
1
+ import { Z as getKernel, _ as isSolid, c as createSolid, h as isShape3D, p as isFace, r as castShapeWithKnownType, t as castShape, x as isClosedWire, y as isWire } from "./shapeTypes-yCQ8z5Hc.js";
2
2
  import { A as ok, T as isOk, b as err, d as validationError, i as kernelError, l as typeCastError, t as BrepErrorCode, v as andThen, w as isErr } from "./errors-DNWJsfVU.js";
3
- import { c as getFaces, i as getCachedIsValid, l as getOrCreateCache, m as invalidateShapeCache, p as getWires, s as getEdges } from "./topologyQueryFns-BtWPlP5v.js";
3
+ import { c as getFaces, i as getCachedIsValid, l as getOrCreateCache, m as invalidateShapeCache, p as getWires, s as getEdges } from "./topologyQueryFns-Bxdnl5Vt.js";
4
4
  import { n as HASH_CODE_MAX, t as DEG2RAD } from "./constants-ITRzCnCp.js";
5
- import { _ as downcast } from "./faceFns-CZp3Y8vi.js";
6
- import { _ as propagateAllMetadata, g as collectInputFaceHashes, h as translate } from "./shapeFns-D63FuB8f.js";
5
+ import { _ as downcast } from "./faceFns-Dreo5ksY.js";
6
+ import { _ as propagateAllMetadata, g as collectInputFaceHashes, h as translate } from "./shapeFns-BnkizFjV.js";
7
7
  import { t as firstOrThrow } from "./arrayAccess-DrUGPADn.js";
8
- import { _ as makeThreePointArc, a as makeNonPlanarFace, c as makeBSplineApproximation, d as makeCircle, f as makeEllipse, g as makeTangentArc, h as makeLine, i as makeNewFaceWithinFace, m as makeHelix, o as makePolygon, p as makeEllipseArc, r as makeFace, s as assembleWire, t as addHolesInFace, u as makeBezierCurve } from "./surfaceBuilders-jx81G_YJ.js";
9
- import { a as fuseAll, i as fuse, n as cut, r as cutAll } from "./booleanFns-CaKngiuu.js";
10
- import { a as makeOffset, c as makeTorus, i as makeEllipsoid, l as makeVertex, n as makeCone, o as makeSolid, r as makeCylinder, s as makeSphere, t as makeCompound, u as weldShellsAndFaces } from "./solidBuilders-0SgkQ386.js";
8
+ import { _ as makeThreePointArc, a as makeNonPlanarFace, c as makeBSplineApproximation, d as makeCircle, f as makeEllipse, g as makeTangentArc, h as makeLine, i as makeNewFaceWithinFace, m as makeHelix, o as makePolygon, p as makeEllipseArc, r as makeFace, s as assembleWire, t as addHolesInFace, u as makeBezierCurve } from "./surfaceBuilders-CS1QccDv.js";
9
+ import { a as fuseAll, i as fuse, n as cut, r as cutAll } from "./booleanFns-0jDBFjAv.js";
10
+ import { a as makeOffset, c as makeTorus, i as makeEllipsoid, l as makeVertex, n as makeCone, o as makeSolid, r as makeCylinder, s as makeSphere, t as makeCompound, u as weldShellsAndFaces } from "./solidBuilders-CPOTKI5i.js";
11
11
  //#region src/topology/threeHelpers.ts
12
12
  /**
13
13
  * Convert a ShapeMesh into BufferGeometry-compatible typed arrays.
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_cameraFns = require("./cameraFns-Bk8frXwa.cjs");
2
+ const require_cameraFns = require("./cameraFns-CsGSVYgb.cjs");
3
3
  exports.PROJECTION_PLANES = require_cameraFns.PROJECTION_PLANES;
4
4
  exports.cameraFromPlane = require_cameraFns.cameraFromPlane;
5
5
  exports.cameraLookAt = require_cameraFns.cameraLookAt;
@@ -1,2 +1,2 @@
1
- import { a as makeProjectedEdges, i as projectEdges, n as cameraLookAt, o as PROJECTION_PLANES, r as createCamera, s as isProjectionPlane, t as cameraFromPlane } from "./cameraFns-k787od3u.js";
1
+ import { a as makeProjectedEdges, i as projectEdges, n as cameraLookAt, o as PROJECTION_PLANES, r as createCamera, s as isProjectionPlane, t as cameraFromPlane } from "./cameraFns-Bwxq0IDz.js";
2
2
  export { PROJECTION_PLANES, cameraFromPlane, cameraLookAt, createCamera, isProjectionPlane, makeProjectedEdges, projectEdges };
package/dist/query.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_helpers = require("./helpers-wFts3ttt.cjs");
3
- const require_cornerFinder = require("./cornerFinder-tTS3ny7e.cjs");
2
+ const require_helpers = require("./helpers-D8ycrNeD.cjs");
3
+ const require_cornerFinder = require("./cornerFinder-ChltJ_ur.cjs");
4
4
  exports.cornerFinder = require_cornerFinder.cornerFinder;
5
5
  exports.edgeFinder = require_helpers.edgeFinder;
6
6
  exports.faceFinder = require_helpers.faceFinder;
package/dist/query.js CHANGED
@@ -1,3 +1,3 @@
1
- import { n as edgeFinder, r as faceFinder, t as getSingleFace } from "./helpers-BX-0e71G.js";
2
- import { t as cornerFinder } from "./cornerFinder-B8GvvW0U.js";
1
+ import { n as edgeFinder, r as faceFinder, t as getSingleFace } from "./helpers--BMa_zB7.js";
2
+ import { t as cornerFinder } from "./cornerFinder-fMf9-El_.js";
3
3
  export { cornerFinder, edgeFinder, faceFinder, getSingleFace };
@@ -1,6 +1,6 @@
1
- import { Z as getKernel, t as castShape } from "./shapeTypes-RYLpXWzG.js";
1
+ import { Z as getKernel, t as castShape } from "./shapeTypes-yCQ8z5Hc.js";
2
2
  import { A as ok, b as err, d as validationError, t as BrepErrorCode } from "./errors-DNWJsfVU.js";
3
- import { C as kernelCall, c as getFaces, l as getOrCreateCache, r as getCacheEntry, w as kernelCallRaw } from "./topologyQueryFns-BtWPlP5v.js";
3
+ import { C as kernelCall, c as getFaces, l as getOrCreateCache, r as getCacheEntry, w as kernelCallRaw } from "./topologyQueryFns-Bxdnl5Vt.js";
4
4
  import { n as HASH_CODE_MAX, t as DEG2RAD } from "./constants-ITRzCnCp.js";
5
5
  //#region src/topology/metadata/originTrackingFns.ts
6
6
  /**
@@ -1,6 +1,6 @@
1
- const require_shapeTypes = require("./shapeTypes-kAKwccy_.cjs");
1
+ const require_shapeTypes = require("./shapeTypes-BIlZar9m.cjs");
2
2
  const require_errors = require("./errors-CXJtc4I7.cjs");
3
- const require_topologyQueryFns = require("./topologyQueryFns-Ck5trXrW.cjs");
3
+ const require_topologyQueryFns = require("./topologyQueryFns-BuWZAQ_o.cjs");
4
4
  const require_constants = require("./constants-BOVyEYGH.cjs");
5
5
  //#region src/topology/metadata/originTrackingFns.ts
6
6
  /**
package/dist/shapeRef.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_shapeRefFns = require("./shapeRefFns-H_O8zyAx.cjs");
2
+ const require_shapeRefFns = require("./shapeRefFns-B3myHs0D.cjs");
3
3
  exports.assignRoles = require_shapeRefFns.assignRoles;
4
4
  exports.captureHint = require_shapeRefFns.captureHint;
5
5
  exports.createRef = require_shapeRefFns.createRef;
package/dist/shapeRef.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as updateRoles, i as resolveRef, n as captureHint, o as defaultScorer, r as createRef, t as assignRoles } from "./shapeRefFns-DjGKujf0.js";
1
+ import { a as updateRoles, i as resolveRef, n as captureHint, o as defaultScorer, r as createRef, t as assignRoles } from "./shapeRefFns-OVWdFOAC.js";
2
2
  export { assignRoles, captureHint, createRef, defaultScorer, resolveRef, updateRoles };
@@ -1,8 +1,8 @@
1
1
  const require_vec3 = require("./vec3-CFwOI0ZI.cjs");
2
- const require_topologyQueryFns = require("./topologyQueryFns-Ck5trXrW.cjs");
3
- const require_faceFns = require("./faceFns-Byt7Vd3F.cjs");
4
- const require_shapeFns = require("./shapeFns-B5JrP5aD.cjs");
5
- const require_measureFns = require("./measureFns-CrSEblGG.cjs");
2
+ const require_topologyQueryFns = require("./topologyQueryFns-BuWZAQ_o.cjs");
3
+ const require_faceFns = require("./faceFns-FAZgMVCx.cjs");
4
+ const require_shapeFns = require("./shapeFns-w1YoIn_p.cjs");
5
+ const require_measureFns = require("./measureFns-CT0XaSOt.cjs");
6
6
  //#region src/topology/shapeRef/scoring.ts
7
7
  /**
8
8
  * Default face scorer combining surface type, normal alignment, centroid proximity,
@@ -1,8 +1,8 @@
1
1
  import { n as wasmIndex } from "./vec3-Dpha8d5k.js";
2
- import { c as getFaces } from "./topologyQueryFns-BtWPlP5v.js";
3
- import { c as normalAt, n as faceCenter, r as faceGeomType } from "./faceFns-CZp3Y8vi.js";
4
- import { n as getHashCode } from "./shapeFns-D63FuB8f.js";
5
- import { n as measureArea } from "./measureFns-CvvenWkS.js";
2
+ import { c as getFaces } from "./topologyQueryFns-Bxdnl5Vt.js";
3
+ import { c as normalAt, n as faceCenter, r as faceGeomType } from "./faceFns-Dreo5ksY.js";
4
+ import { n as getHashCode } from "./shapeFns-BnkizFjV.js";
5
+ import { n as measureArea } from "./measureFns-BLEx4ZU3.js";
6
6
  //#region src/topology/shapeRef/scoring.ts
7
7
  /**
8
8
  * Default face scorer combining surface type, normal alignment, centroid proximity,