brepjs 18.69.1 → 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 (82) 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-8zgPWa83.cjs → importFns-4mi5Ih46.cjs} +2 -2
  34. package/dist/{importFns-BAJm4qfD.js → importFns-DRPQExAD.js} +2 -2
  35. package/dist/io.cjs +2 -2
  36. package/dist/io.js +2 -2
  37. package/dist/kernel/brepkit/ioOps.d.ts +2 -2
  38. package/dist/kernel/occtWasm/ioOps.d.ts +1 -1
  39. package/dist/kernel/occtWasm/occtWasmAdapter.cjs +1 -1
  40. package/dist/kernel/occtWasm/occtWasmAdapter.js +1 -1
  41. package/dist/kernel/stlBuilder.d.ts +20 -0
  42. package/dist/{measureFns-CvvenWkS.js → measureFns-BLEx4ZU3.js} +3 -3
  43. package/dist/{measureFns-CrSEblGG.cjs → measureFns-CT0XaSOt.cjs} +3 -3
  44. package/dist/measurement.cjs +1 -1
  45. package/dist/measurement.js +1 -1
  46. package/dist/{meshFns-0RHalM3t.js → meshFns-B3MjIqk1.js} +3 -3
  47. package/dist/{meshFns-DwHAYqRN.cjs → meshFns-lwgHYQ79.cjs} +3 -3
  48. package/dist/{occtWasmAdapter-BPu07Zxg.cjs → occtWasmAdapter-BH7r2nTq.cjs} +137 -51
  49. package/dist/{occtWasmAdapter-Ctfykwr2.js → occtWasmAdapter-C7FDeTaw.js} +114 -52
  50. package/dist/operations.cjs +2 -2
  51. package/dist/operations.js +2 -2
  52. package/dist/{primitiveFns-CKCALTVe.cjs → primitiveFns-DZmgvzvk.cjs} +7 -7
  53. package/dist/{primitiveFns-ecKWNC5k.js → primitiveFns-DcZDTQ_R.js} +7 -7
  54. package/dist/projection.cjs +1 -1
  55. package/dist/projection.js +1 -1
  56. package/dist/query.cjs +2 -2
  57. package/dist/query.js +2 -2
  58. package/dist/{shapeFns-D63FuB8f.js → shapeFns-BnkizFjV.js} +2 -2
  59. package/dist/{shapeFns-B5JrP5aD.cjs → shapeFns-w1YoIn_p.cjs} +2 -2
  60. package/dist/shapeRef.cjs +1 -1
  61. package/dist/shapeRef.js +1 -1
  62. package/dist/{shapeRefFns-H_O8zyAx.cjs → shapeRefFns-B3myHs0D.cjs} +4 -4
  63. package/dist/{shapeRefFns-DjGKujf0.js → shapeRefFns-OVWdFOAC.js} +4 -4
  64. package/dist/{shapeTypes-kAKwccy_.cjs → shapeTypes-BIlZar9m.cjs} +174 -172
  65. package/dist/{shapeTypes-RYLpXWzG.js → shapeTypes-yCQ8z5Hc.js} +174 -172
  66. package/dist/sketching.cjs +3 -3
  67. package/dist/sketching.js +3 -3
  68. package/dist/{solidBuilders-0SgkQ386.js → solidBuilders-CPOTKI5i.js} +2 -2
  69. package/dist/{solidBuilders-B2IX6Pm8.cjs → solidBuilders-dNhToZgl.cjs} +2 -2
  70. package/dist/{surfaceBuilders-jx81G_YJ.js → surfaceBuilders-CS1QccDv.js} +2 -2
  71. package/dist/{surfaceBuilders-BkvJS8pw.cjs → surfaceBuilders-CzHPZtd3.cjs} +2 -2
  72. package/dist/text.cjs +2 -2
  73. package/dist/text.js +2 -2
  74. package/dist/{textBlueprints-BXGrW7Ak.js → textBlueprints-B57ej88L.js} +7 -7
  75. package/dist/{textBlueprints-Q2gxuZd1.cjs → textBlueprints-TG6AH06v.cjs} +7 -7
  76. package/dist/{textMetrics-V7TXOETY.js → textMetrics-BxtB3sjj.js} +1 -1
  77. package/dist/{textMetrics-CnCjqf59.cjs → textMetrics-Dag-YREs.cjs} +1 -1
  78. package/dist/topology.cjs +7 -7
  79. package/dist/topology.js +7 -7
  80. package/dist/{topologyQueryFns-Ck5trXrW.cjs → topologyQueryFns-BuWZAQ_o.cjs} +1 -1
  81. package/dist/{topologyQueryFns-BtWPlP5v.js → topologyQueryFns-Bxdnl5Vt.js} +1 -1
  82. package/package.json +1 -1
@@ -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,
@@ -1,4 +1,4 @@
1
- const require_occtWasmAdapter = require("./occtWasmAdapter-BPu07Zxg.cjs");
1
+ const require_occtWasmAdapter = require("./occtWasmAdapter-BH7r2nTq.cjs");
2
2
  const require_vec3 = require("./vec3-CFwOI0ZI.cjs");
3
3
  const require_errors = require("./errors-CXJtc4I7.cjs");
4
4
  //#region src/kernel/quality.ts
@@ -7915,6 +7915,171 @@ function makeEvolutionOps$1(bk) {
7915
7915
  };
7916
7916
  }
7917
7917
  //#endregion
7918
+ //#region src/kernel/brepkit/meshOps.ts
7919
+ function mesh$1(bk, shape, options) {
7920
+ const h = unwrap$1(shape);
7921
+ const bkHandle = shape;
7922
+ const deflection = options.tolerance || .01;
7923
+ const angularTol = options.angularTolerance > 0 ? options.angularTolerance : void 0;
7924
+ let result;
7925
+ if (bkHandle.type === "solid") result = meshSolid(bk, h, deflection, !!options.includeUVs, angularTol);
7926
+ else if (bkHandle.type === "face") result = meshSingleFace(bk, h, deflection, 0, angularTol);
7927
+ else throw new Error(`brepkit: cannot mesh shape of type '${bkHandle.type}'`);
7928
+ if (options.skipNormals) result.normals = new Float32Array(0);
7929
+ if (!options.includeUVs) result.uvs = new Float32Array(0);
7930
+ return result;
7931
+ }
7932
+ function meshEdges$1(bk, shape, tolerance, angularTolerance) {
7933
+ if (angularTolerance > 0) warnOnce("mesh-edges-angular", "meshEdges angularTolerance is not supported; only linear deflection is used.");
7934
+ const bkHandle = shape;
7935
+ if (bkHandle.type !== "solid") return {
7936
+ lines: new Float32Array(0),
7937
+ edgeGroups: []
7938
+ };
7939
+ const edgeLines = bk.meshEdgesAll(bkHandle.id, tolerance);
7940
+ const positions = edgeLines.positions;
7941
+ const offsets = edgeLines.offsets;
7942
+ const edgeCount = edgeLines.edgeCount;
7943
+ const edgeGroups = [];
7944
+ for (let i = 0; i < edgeCount; i++) {
7945
+ const startIdx = require_vec3.wasmIndex(offsets, i);
7946
+ const pointCount = ((i + 1 < edgeCount ? require_vec3.wasmIndex(offsets, i + 1) : positions.length) - startIdx) / 3;
7947
+ edgeGroups.push({
7948
+ start: startIdx / 3,
7949
+ count: pointCount,
7950
+ edgeHash: i
7951
+ });
7952
+ }
7953
+ return {
7954
+ lines: new Float32Array(positions),
7955
+ edgeGroups
7956
+ };
7957
+ }
7958
+ function hasTriangulation$1(_bk, _shape) {
7959
+ return false;
7960
+ }
7961
+ /** Tessellate a solid with per-face groups for brepjs mesh format. */
7962
+ function meshSolid(bk, solidId, deflection, includeUVs, angularTolerance) {
7963
+ try {
7964
+ return meshSolidGrouped(bk, solidId, deflection, includeUVs, angularTolerance);
7965
+ } catch (e) {
7966
+ console.warn(`brepkit: tessellateSolidGrouped failed (solidId=${solidId}), falling back to per-face:`, e);
7967
+ return meshSolidPerFace(bk, solidId, deflection, angularTolerance);
7968
+ }
7969
+ }
7970
+ /**
7971
+ * Batch tessellation via `tessellateSolidGrouped` -- single WASM call for
7972
+ * all faces. Falls back to `meshSolidPerFace` on error.
7973
+ *
7974
+ * When `includeUVs` is true, makes an additional `tessellateSolidUV` call
7975
+ * to populate real surface parametrization coordinates.
7976
+ */
7977
+ function meshSolidGrouped(bk, solidId, deflection, includeUVs, angularTolerance) {
7978
+ const json = bk.tessellateSolidGrouped(solidId, deflection, angularTolerance);
7979
+ const data = JSON.parse(json);
7980
+ const faceIds = toArray(bk.getSolidFaces(solidId));
7981
+ const groupCount = data.faceOffsets.length - 1;
7982
+ if (groupCount !== faceIds.length) throw new Error(`faceOffsets/faceIds length mismatch: ${groupCount} groups vs ${faceIds.length} faces`);
7983
+ const faceGroups = [];
7984
+ for (let i = 0; i < data.faceOffsets.length - 1; i++) {
7985
+ const start = require_vec3.wasmIndex(data.faceOffsets, i);
7986
+ const count = require_vec3.wasmIndex(data.faceOffsets, i + 1) - start;
7987
+ if (count === 0) continue;
7988
+ faceGroups.push({
7989
+ start,
7990
+ count,
7991
+ faceHash: faceIds[i] ?? 0
7992
+ });
7993
+ }
7994
+ let uvs = new Float32Array(0);
7995
+ if (includeUVs) {
7996
+ const expectedUvLen = data.positions.length / 3 * 2;
7997
+ try {
7998
+ const uvJson = bk.tessellateSolidUV(solidId, deflection, angularTolerance);
7999
+ const uvData = JSON.parse(uvJson);
8000
+ if (uvData.uvs.length === expectedUvLen) uvs = new Float32Array(uvData.uvs);
8001
+ else uvs = new Float32Array(expectedUvLen);
8002
+ } catch {
8003
+ uvs = new Float32Array(expectedUvLen);
8004
+ }
8005
+ }
8006
+ return {
8007
+ vertices: new Float32Array(data.positions),
8008
+ normals: new Float32Array(data.normals),
8009
+ triangles: new Uint32Array(data.indices),
8010
+ uvs,
8011
+ faceGroups
8012
+ };
8013
+ }
8014
+ /** Per-face tessellation fallback -- N WASM calls, one per face. */
8015
+ function meshSolidPerFace(bk, solidId, deflection, angularTolerance) {
8016
+ const faceIds = toArray(bk.getSolidFaces(solidId));
8017
+ const allVertices = [];
8018
+ const allNormals = [];
8019
+ const allTriangles = [];
8020
+ const allUVs = [];
8021
+ const faceGroups = [];
8022
+ let vertexOffset = 0;
8023
+ for (const faceId of faceIds) try {
8024
+ const faceMesh = bk.tessellateFace(faceId, deflection, angularTolerance);
8025
+ const positions = faceMesh.positions;
8026
+ const normals = faceMesh.normals;
8027
+ const indices = faceMesh.indices;
8028
+ const vertCount = positions.length / 3;
8029
+ if (vertCount === 0) continue;
8030
+ const triStart = allTriangles.length;
8031
+ for (const v of positions) allVertices.push(v);
8032
+ for (const n of normals) allNormals.push(n);
8033
+ for (const idx of indices) allTriangles.push(idx + vertexOffset);
8034
+ for (let i = 0; i < vertCount; i++) allUVs.push(0, 0);
8035
+ faceGroups.push({
8036
+ start: triStart,
8037
+ count: indices.length,
8038
+ faceHash: faceId
8039
+ });
8040
+ vertexOffset += vertCount;
8041
+ } catch (e) {
8042
+ console.warn(`brepkit: face tessellation failed (faceId=${faceId}):`, e);
8043
+ }
8044
+ return {
8045
+ vertices: new Float32Array(allVertices),
8046
+ normals: new Float32Array(allNormals),
8047
+ triangles: new Uint32Array(allTriangles),
8048
+ uvs: new Float32Array(allUVs),
8049
+ faceGroups
8050
+ };
8051
+ }
8052
+ /** Tessellate a single face and return brepjs mesh format. */
8053
+ function meshSingleFace(bk, faceId, deflection, faceHash, angularTolerance) {
8054
+ const faceMesh = bk.tessellateFace(faceId, deflection, angularTolerance);
8055
+ const positions = faceMesh.positions;
8056
+ const normals = faceMesh.normals;
8057
+ const indices = faceMesh.indices;
8058
+ const vertCount = positions.length / 3;
8059
+ const uvs = [];
8060
+ for (let i = 0; i < vertCount; i++) uvs.push(0, 0);
8061
+ return {
8062
+ vertices: new Float32Array(positions),
8063
+ normals: new Float32Array(normals),
8064
+ triangles: new Uint32Array(indices),
8065
+ uvs: new Float32Array(uvs),
8066
+ faceGroups: [{
8067
+ start: 0,
8068
+ count: indices.length,
8069
+ faceHash
8070
+ }]
8071
+ };
8072
+ }
8073
+ /** Co-located factory: returns the mesh slice of {@link KernelAdapter} bound to `bk`. */
8074
+ function makeMeshOps$1(bk) {
8075
+ return {
8076
+ mesh: (shape, options) => mesh$1(bk, shape, options),
8077
+ meshEdges: (shape, tolerance, angularTolerance) => meshEdges$1(bk, shape, tolerance, angularTolerance),
8078
+ hasTriangulation: (shape) => hasTriangulation$1(bk, shape),
8079
+ meshShape: (shape, tolerance, angularTolerance) => {}
8080
+ };
8081
+ }
8082
+ //#endregion
7918
8083
  //#region src/kernel/brepkit/ioOps.ts
7919
8084
  function exportSTEP(bk, shapes) {
7920
8085
  if (shapes.length === 0) return "";
@@ -7928,11 +8093,13 @@ function exportSTEP(bk, shapes) {
7928
8093
  }
7929
8094
  return parts.join("\n");
7930
8095
  }
7931
- function exportSTL$1(bk, shape, binary) {
7932
- const solidIds = unwrapSolidsForExport(bk, shape, "exportSTL");
7933
- if (binary) return bk.exportStl(require_vec3.wasmIndex(solidIds, 0), DEFAULT_DEFLECTION).buffer;
7934
- const bytes = bk.exportStlAscii(require_vec3.wasmIndex(solidIds, 0), DEFAULT_DEFLECTION);
7935
- return new TextDecoder().decode(bytes);
8096
+ function exportSTL$1(bk, shape, binary, tolerance = require_occtWasmAdapter.DEFAULT_STL_TOLERANCE, angularTolerance = require_occtWasmAdapter.DEFAULT_STL_ANGULAR_TOLERANCE) {
8097
+ const { vertices, triangles } = mesh$1(bk, solidHandle(require_vec3.wasmIndex(unwrapSolidsForExport(bk, shape, "exportSTL"), 0)), {
8098
+ tolerance,
8099
+ angularTolerance,
8100
+ skipNormals: true
8101
+ });
8102
+ return binary ? require_occtWasmAdapter.buildBinarySTL(vertices, triangles) : require_occtWasmAdapter.buildAsciiSTL(vertices, triangles);
7936
8103
  }
7937
8104
  function importSTEP(bk, data) {
7938
8105
  const bytes = typeof data === "string" ? new TextEncoder().encode(data) : new Uint8Array(data);
@@ -8017,7 +8184,7 @@ function exportSTEPConfigured(bk, shapes, _options) {
8017
8184
  function makeIoOps$1(bk) {
8018
8185
  return {
8019
8186
  exportSTEP: (shapes) => exportSTEP(bk, shapes),
8020
- exportSTL: (shape, binary) => exportSTL$1(bk, shape, binary),
8187
+ exportSTL: (shape, binary, tolerance, angularTolerance) => exportSTL$1(bk, shape, binary, tolerance, angularTolerance),
8021
8188
  importSTEP: (data) => importSTEP(bk, data),
8022
8189
  importSTL: (data) => importSTL(bk, data),
8023
8190
  exportIGES: (shapes) => exportIGES(bk, shapes),
@@ -9203,171 +9370,6 @@ function makeMeasureOps$1(bk) {
9203
9370
  };
9204
9371
  }
9205
9372
  //#endregion
9206
- //#region src/kernel/brepkit/meshOps.ts
9207
- function mesh$1(bk, shape, options) {
9208
- const h = unwrap$1(shape);
9209
- const bkHandle = shape;
9210
- const deflection = options.tolerance || .01;
9211
- const angularTol = options.angularTolerance > 0 ? options.angularTolerance : void 0;
9212
- let result;
9213
- if (bkHandle.type === "solid") result = meshSolid(bk, h, deflection, !!options.includeUVs, angularTol);
9214
- else if (bkHandle.type === "face") result = meshSingleFace(bk, h, deflection, 0, angularTol);
9215
- else throw new Error(`brepkit: cannot mesh shape of type '${bkHandle.type}'`);
9216
- if (options.skipNormals) result.normals = new Float32Array(0);
9217
- if (!options.includeUVs) result.uvs = new Float32Array(0);
9218
- return result;
9219
- }
9220
- function meshEdges$1(bk, shape, tolerance, angularTolerance) {
9221
- if (angularTolerance > 0) warnOnce("mesh-edges-angular", "meshEdges angularTolerance is not supported; only linear deflection is used.");
9222
- const bkHandle = shape;
9223
- if (bkHandle.type !== "solid") return {
9224
- lines: new Float32Array(0),
9225
- edgeGroups: []
9226
- };
9227
- const edgeLines = bk.meshEdgesAll(bkHandle.id, tolerance);
9228
- const positions = edgeLines.positions;
9229
- const offsets = edgeLines.offsets;
9230
- const edgeCount = edgeLines.edgeCount;
9231
- const edgeGroups = [];
9232
- for (let i = 0; i < edgeCount; i++) {
9233
- const startIdx = require_vec3.wasmIndex(offsets, i);
9234
- const pointCount = ((i + 1 < edgeCount ? require_vec3.wasmIndex(offsets, i + 1) : positions.length) - startIdx) / 3;
9235
- edgeGroups.push({
9236
- start: startIdx / 3,
9237
- count: pointCount,
9238
- edgeHash: i
9239
- });
9240
- }
9241
- return {
9242
- lines: new Float32Array(positions),
9243
- edgeGroups
9244
- };
9245
- }
9246
- function hasTriangulation$1(_bk, _shape) {
9247
- return false;
9248
- }
9249
- /** Tessellate a solid with per-face groups for brepjs mesh format. */
9250
- function meshSolid(bk, solidId, deflection, includeUVs, angularTolerance) {
9251
- try {
9252
- return meshSolidGrouped(bk, solidId, deflection, includeUVs, angularTolerance);
9253
- } catch (e) {
9254
- console.warn(`brepkit: tessellateSolidGrouped failed (solidId=${solidId}), falling back to per-face:`, e);
9255
- return meshSolidPerFace(bk, solidId, deflection, angularTolerance);
9256
- }
9257
- }
9258
- /**
9259
- * Batch tessellation via `tessellateSolidGrouped` -- single WASM call for
9260
- * all faces. Falls back to `meshSolidPerFace` on error.
9261
- *
9262
- * When `includeUVs` is true, makes an additional `tessellateSolidUV` call
9263
- * to populate real surface parametrization coordinates.
9264
- */
9265
- function meshSolidGrouped(bk, solidId, deflection, includeUVs, angularTolerance) {
9266
- const json = bk.tessellateSolidGrouped(solidId, deflection, angularTolerance);
9267
- const data = JSON.parse(json);
9268
- const faceIds = toArray(bk.getSolidFaces(solidId));
9269
- const groupCount = data.faceOffsets.length - 1;
9270
- if (groupCount !== faceIds.length) throw new Error(`faceOffsets/faceIds length mismatch: ${groupCount} groups vs ${faceIds.length} faces`);
9271
- const faceGroups = [];
9272
- for (let i = 0; i < data.faceOffsets.length - 1; i++) {
9273
- const start = require_vec3.wasmIndex(data.faceOffsets, i);
9274
- const count = require_vec3.wasmIndex(data.faceOffsets, i + 1) - start;
9275
- if (count === 0) continue;
9276
- faceGroups.push({
9277
- start,
9278
- count,
9279
- faceHash: faceIds[i] ?? 0
9280
- });
9281
- }
9282
- let uvs = new Float32Array(0);
9283
- if (includeUVs) {
9284
- const expectedUvLen = data.positions.length / 3 * 2;
9285
- try {
9286
- const uvJson = bk.tessellateSolidUV(solidId, deflection, angularTolerance);
9287
- const uvData = JSON.parse(uvJson);
9288
- if (uvData.uvs.length === expectedUvLen) uvs = new Float32Array(uvData.uvs);
9289
- else uvs = new Float32Array(expectedUvLen);
9290
- } catch {
9291
- uvs = new Float32Array(expectedUvLen);
9292
- }
9293
- }
9294
- return {
9295
- vertices: new Float32Array(data.positions),
9296
- normals: new Float32Array(data.normals),
9297
- triangles: new Uint32Array(data.indices),
9298
- uvs,
9299
- faceGroups
9300
- };
9301
- }
9302
- /** Per-face tessellation fallback -- N WASM calls, one per face. */
9303
- function meshSolidPerFace(bk, solidId, deflection, angularTolerance) {
9304
- const faceIds = toArray(bk.getSolidFaces(solidId));
9305
- const allVertices = [];
9306
- const allNormals = [];
9307
- const allTriangles = [];
9308
- const allUVs = [];
9309
- const faceGroups = [];
9310
- let vertexOffset = 0;
9311
- for (const faceId of faceIds) try {
9312
- const faceMesh = bk.tessellateFace(faceId, deflection, angularTolerance);
9313
- const positions = faceMesh.positions;
9314
- const normals = faceMesh.normals;
9315
- const indices = faceMesh.indices;
9316
- const vertCount = positions.length / 3;
9317
- if (vertCount === 0) continue;
9318
- const triStart = allTriangles.length;
9319
- for (const v of positions) allVertices.push(v);
9320
- for (const n of normals) allNormals.push(n);
9321
- for (const idx of indices) allTriangles.push(idx + vertexOffset);
9322
- for (let i = 0; i < vertCount; i++) allUVs.push(0, 0);
9323
- faceGroups.push({
9324
- start: triStart,
9325
- count: indices.length,
9326
- faceHash: faceId
9327
- });
9328
- vertexOffset += vertCount;
9329
- } catch (e) {
9330
- console.warn(`brepkit: face tessellation failed (faceId=${faceId}):`, e);
9331
- }
9332
- return {
9333
- vertices: new Float32Array(allVertices),
9334
- normals: new Float32Array(allNormals),
9335
- triangles: new Uint32Array(allTriangles),
9336
- uvs: new Float32Array(allUVs),
9337
- faceGroups
9338
- };
9339
- }
9340
- /** Tessellate a single face and return brepjs mesh format. */
9341
- function meshSingleFace(bk, faceId, deflection, faceHash, angularTolerance) {
9342
- const faceMesh = bk.tessellateFace(faceId, deflection, angularTolerance);
9343
- const positions = faceMesh.positions;
9344
- const normals = faceMesh.normals;
9345
- const indices = faceMesh.indices;
9346
- const vertCount = positions.length / 3;
9347
- const uvs = [];
9348
- for (let i = 0; i < vertCount; i++) uvs.push(0, 0);
9349
- return {
9350
- vertices: new Float32Array(positions),
9351
- normals: new Float32Array(normals),
9352
- triangles: new Uint32Array(indices),
9353
- uvs: new Float32Array(uvs),
9354
- faceGroups: [{
9355
- start: 0,
9356
- count: indices.length,
9357
- faceHash
9358
- }]
9359
- };
9360
- }
9361
- /** Co-located factory: returns the mesh slice of {@link KernelAdapter} bound to `bk`. */
9362
- function makeMeshOps$1(bk) {
9363
- return {
9364
- mesh: (shape, options) => mesh$1(bk, shape, options),
9365
- meshEdges: (shape, tolerance, angularTolerance) => meshEdges$1(bk, shape, tolerance, angularTolerance),
9366
- hasTriangulation: (shape) => hasTriangulation$1(bk, shape),
9367
- meshShape: (shape, tolerance, angularTolerance) => {}
9368
- };
9369
- }
9370
- //#endregion
9371
9373
  //#region src/kernel/brepkit/sketchOps.ts
9372
9374
  /** Create a new constraint sketch. Returns an opaque sketch handle. */
9373
9375
  function sketchNew(bk) {