brepjs 18.6.0 → 18.6.1

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 (159) hide show
  1. package/dist/2d/blueprints/blueprintOffset.d.ts.map +1 -1
  2. package/dist/2d/blueprints/intersectionSegments.d.ts.map +1 -1
  3. package/dist/2d/blueprints/segmentAssembly.d.ts.map +1 -1
  4. package/dist/2d/lib/curve2D.d.ts.map +1 -1
  5. package/dist/2d/lib/customCorners.d.ts.map +1 -1
  6. package/dist/2d/lib/stitching.d.ts.map +1 -1
  7. package/dist/2d/lib/svgPath.d.ts.map +1 -1
  8. package/dist/2d.cjs +6 -6
  9. package/dist/2d.js +6 -6
  10. package/dist/{blueprint-CscZ0-wr.cjs → blueprint-C5LxqHCa.cjs} +16 -15
  11. package/dist/{blueprint-BCoJbaQN.js → blueprint-CBairprN.js} +16 -15
  12. package/dist/{blueprintFns-DQP4KQHE.cjs → blueprintFns-CwbDuLxf.cjs} +3 -3
  13. package/dist/{blueprintFns-BZlx6BjG.js → blueprintFns-D8ST0Cf4.js} +3 -3
  14. package/dist/{boolean2D-JvgjbESt.js → boolean2D-A5u9tJYl.js} +26 -24
  15. package/dist/{boolean2D-k1AJmCMp.cjs → boolean2D-DxZ3Kwlq.cjs} +26 -24
  16. package/dist/{booleanFns-DQW4lt7H.cjs → booleanFns-DWQMtFDN.cjs} +9 -9
  17. package/dist/{booleanFns-D13Pb-NO.js → booleanFns-DjZF4MJ5.js} +9 -9
  18. package/dist/brepjs.cjs +51 -41
  19. package/dist/brepjs.js +51 -41
  20. package/dist/core/errors.d.ts.map +1 -1
  21. package/dist/core.cjs +6 -6
  22. package/dist/core.js +6 -6
  23. package/dist/{cornerFinder-5BYE2cbd.cjs → cornerFinder-B2CpcVV9.cjs} +3 -3
  24. package/dist/{cornerFinder-Zg7pf2s0.js → cornerFinder-DGvOt2ab.js} +3 -3
  25. package/dist/{curveFns-DrT54cm8.cjs → curveFns-B8KJKr8-.cjs} +2 -2
  26. package/dist/{curveFns-DhqUp0EI.js → curveFns-DZYE3BGO.js} +2 -2
  27. package/dist/{drawFns-lUXjhTYL.js → drawFns-Bl865kUL.js} +21 -20
  28. package/dist/{drawFns-DmP2o1oF.cjs → drawFns-h8gJBx-H.cjs} +21 -20
  29. package/dist/{errors-DboJwVCf.js → errors-0fYW_YnO.js} +2 -1
  30. package/dist/{errors-CXRNVCec.cjs → errors-Dv6pfNct.cjs} +2 -1
  31. package/dist/{extrudeFns-BtblHdaJ.cjs → extrudeFns-BlJKAnW8.cjs} +3 -3
  32. package/dist/{extrudeFns-B9bVCt3C.js → extrudeFns-O2s-SFf-.js} +3 -3
  33. package/dist/{faceFns-22idS-ht.cjs → faceFns-B1H43mZ_.cjs} +3 -3
  34. package/dist/{faceFns-NbWd8-iR.js → faceFns-acz86gqR.js} +3 -3
  35. package/dist/{helpers-BpXNcxuJ.cjs → helpers-C3smxDtp.cjs} +8 -8
  36. package/dist/{helpers-S_Ht6gwX.js → helpers-DL1f3xp0.js} +8 -8
  37. package/dist/{historyFns-B01hrkcJ.js → historyFns-CD9qXw5j.js} +6 -6
  38. package/dist/{historyFns-RHO-QvEZ.cjs → historyFns-DBdWeo7Y.cjs} +6 -6
  39. package/dist/{importFns-CG49lyTm.cjs → importFns-5tcN3-fK.cjs} +11 -19
  40. package/dist/{importFns-C0tUyeiW.js → importFns-B1p3FiGS.js} +11 -19
  41. package/dist/io/gltfExportFns.d.ts.map +1 -1
  42. package/dist/io/objExportFns.d.ts.map +1 -1
  43. package/dist/io.cjs +2 -2
  44. package/dist/io.js +2 -2
  45. package/dist/kernel/brepkit/booleanOps.d.ts.map +1 -1
  46. package/dist/kernel/brepkit/evolutionOps.d.ts.map +1 -1
  47. package/dist/kernel/brepkit/geometryOps.d.ts.map +1 -1
  48. package/dist/kernel/brepkit/helpers.d.ts.map +1 -1
  49. package/dist/kernel/brepkit/internalOps.d.ts.map +1 -1
  50. package/dist/kernel/brepkit/ioOps.d.ts.map +1 -1
  51. package/dist/kernel/brepkit/kernel2dOps.d.ts.map +1 -1
  52. package/dist/kernel/brepkit/measureOps.d.ts.map +1 -1
  53. package/dist/kernel/brepkit/meshOps.d.ts.map +1 -1
  54. package/dist/kernel/brepkit/modifierOps.d.ts.map +1 -1
  55. package/dist/kernel/brepkit/topologyOps.d.ts.map +1 -1
  56. package/dist/kernel/occt/advancedOps.d.ts.map +1 -1
  57. package/dist/kernel/occt/booleanOps.d.ts.map +1 -1
  58. package/dist/kernel/occt/extendedConstructorOps.d.ts.map +1 -1
  59. package/dist/kernel/occt/kernel2dOps.d.ts.map +1 -1
  60. package/dist/kernel/occtWasm/adapterShims.d.ts +5 -0
  61. package/dist/kernel/occtWasm/adapterShims.d.ts.map +1 -0
  62. package/dist/kernel/occtWasm/booleanOps.d.ts +12 -0
  63. package/dist/kernel/occtWasm/booleanOps.d.ts.map +1 -0
  64. package/dist/kernel/occtWasm/constructionOps.d.ts +37 -0
  65. package/dist/kernel/occtWasm/constructionOps.d.ts.map +1 -0
  66. package/dist/kernel/occtWasm/curveOps.d.ts +24 -0
  67. package/dist/kernel/occtWasm/curveOps.d.ts.map +1 -0
  68. package/dist/kernel/occtWasm/evolutionOps.d.ts +18 -0
  69. package/dist/kernel/occtWasm/evolutionOps.d.ts.map +1 -0
  70. package/dist/kernel/occtWasm/helpers.d.ts +32 -0
  71. package/dist/kernel/occtWasm/helpers.d.ts.map +1 -0
  72. package/dist/kernel/occtWasm/hullOps.d.ts +13 -0
  73. package/dist/kernel/occtWasm/hullOps.d.ts.map +1 -0
  74. package/dist/kernel/occtWasm/ioOps.d.ts +53 -0
  75. package/dist/kernel/occtWasm/ioOps.d.ts.map +1 -0
  76. package/dist/kernel/occtWasm/kernel2dOps.d.ts +91 -0
  77. package/dist/kernel/occtWasm/kernel2dOps.d.ts.map +1 -0
  78. package/dist/kernel/occtWasm/measureOps.d.ts +32 -0
  79. package/dist/kernel/occtWasm/measureOps.d.ts.map +1 -0
  80. package/dist/kernel/occtWasm/meshOps.d.ts +7 -0
  81. package/dist/kernel/occtWasm/meshOps.d.ts.map +1 -0
  82. package/dist/kernel/occtWasm/modifierOps.d.ts +15 -0
  83. package/dist/kernel/occtWasm/modifierOps.d.ts.map +1 -0
  84. package/dist/kernel/occtWasm/occtWasmAdapter.cjs +1 -1
  85. package/dist/kernel/occtWasm/occtWasmAdapter.d.ts +30 -30
  86. package/dist/kernel/occtWasm/occtWasmAdapter.d.ts.map +1 -1
  87. package/dist/kernel/occtWasm/occtWasmAdapter.js +1 -1
  88. package/dist/kernel/occtWasm/primitiveOps.d.ts +11 -0
  89. package/dist/kernel/occtWasm/primitiveOps.d.ts.map +1 -0
  90. package/dist/kernel/occtWasm/repairOps.d.ts +11 -0
  91. package/dist/kernel/occtWasm/repairOps.d.ts.map +1 -0
  92. package/dist/kernel/occtWasm/surfaceOps.d.ts +29 -0
  93. package/dist/kernel/occtWasm/surfaceOps.d.ts.map +1 -0
  94. package/dist/kernel/occtWasm/sweepOps.d.ts +39 -0
  95. package/dist/kernel/occtWasm/sweepOps.d.ts.map +1 -0
  96. package/dist/kernel/occtWasm/topologyOps.d.ts +15 -0
  97. package/dist/kernel/occtWasm/topologyOps.d.ts.map +1 -0
  98. package/dist/kernel/occtWasm/transformOps.d.ts +28 -0
  99. package/dist/kernel/occtWasm/transformOps.d.ts.map +1 -0
  100. package/dist/{measureFns-C751QGI1.cjs → measureFns-CHmy_Inq.cjs} +3 -3
  101. package/dist/{measureFns-B8C85hbT.js → measureFns-CJi8erDL.js} +3 -3
  102. package/dist/measurement/interferenceFns.d.ts.map +1 -1
  103. package/dist/measurement.cjs +1 -1
  104. package/dist/measurement.js +1 -1
  105. package/dist/{meshFns-BgvsA-xA.js → meshFns-BkY1RAoC.js} +3 -3
  106. package/dist/{meshFns-Cdhtbrhm.cjs → meshFns-t2lR4BDS.cjs} +3 -3
  107. package/dist/occtWasmAdapter--TZGP9DX.js +4606 -0
  108. package/dist/occtWasmAdapter-C2VW-uYg.cjs +4719 -0
  109. package/dist/operations/compoundOpsFns.d.ts.map +1 -1
  110. package/dist/operations.cjs +2 -2
  111. package/dist/operations.js +2 -2
  112. package/dist/{planeOps-sTrM3dcQ.js → planeOps-4i2qEraD.js} +4 -4
  113. package/dist/{planeOps-BJOIbn4K.cjs → planeOps-CH4ruLuj.cjs} +4 -4
  114. package/dist/{primitiveFns-BLxaJ40A.cjs → primitiveFns-DwhN--zB.cjs} +7 -7
  115. package/dist/{primitiveFns-fR9sWOEb.js → primitiveFns-Emvge_71.js} +7 -7
  116. package/dist/query.cjs +2 -2
  117. package/dist/query.js +2 -2
  118. package/dist/result.cjs +1 -1
  119. package/dist/result.js +1 -1
  120. package/dist/{shapeFns-183zCtMc.cjs → shapeFns-CObBAJoQ.cjs} +4 -4
  121. package/dist/{shapeFns-2X3VOi1a.js → shapeFns-DThjHtJI.js} +4 -4
  122. package/dist/shapeRef.cjs +1 -1
  123. package/dist/shapeRef.js +1 -1
  124. package/dist/{shapeRefFns-CFyv5cdW.cjs → shapeRefFns-I0MHjRAq.cjs} +5 -4
  125. package/dist/{shapeRefFns-CU1Jwq9C.js → shapeRefFns-WMhIFuGW.js} +5 -4
  126. package/dist/{shapeTypes-C0MDggKf.cjs → shapeTypes-8vB31RfA.cjs} +260 -400
  127. package/dist/{shapeTypes-CN0GUoHr.js → shapeTypes-AyL8vv_O.js} +239 -379
  128. package/dist/sketching.cjs +2 -2
  129. package/dist/sketching.js +2 -2
  130. package/dist/{solidBuilders-BuS5ByIl.js → solidBuilders-C7Xp_ikW.js} +3 -3
  131. package/dist/{solidBuilders-DACzFqvX.cjs → solidBuilders-Djwgx2mj.cjs} +3 -3
  132. package/dist/{surfaceBuilders-CbH4FIW5.cjs → surfaceBuilders-BEnsewN9.cjs} +3 -3
  133. package/dist/{surfaceBuilders-BVH2SL-z.js → surfaceBuilders-Con0IpLf.js} +3 -3
  134. package/dist/topology/minkowskiFns.d.ts.map +1 -1
  135. package/dist/topology/shapeRef/shapeRefFns.d.ts.map +1 -1
  136. package/dist/topology/wrapperFns.d.ts.map +1 -1
  137. package/dist/topology.cjs +6 -6
  138. package/dist/topology.js +6 -6
  139. package/dist/utils/vec3.d.ts +8 -0
  140. package/dist/utils/vec3.d.ts.map +1 -1
  141. package/dist/vec3-BRj3eI54.js +25 -0
  142. package/dist/vec3-S4Oh59IX.cjs +36 -0
  143. package/dist/vectors.cjs +4 -4
  144. package/dist/vectors.js +4 -4
  145. package/dist/worker.cjs +1 -1
  146. package/dist/worker.js +1 -1
  147. package/package.json +2 -2
  148. package/dist/occtWasmAdapter-CuZRRioz.cjs +0 -3947
  149. package/dist/occtWasmAdapter-DIhUXubY.js +0 -3834
  150. /package/dist/{arrayAccess-tCIbjLs5.js → arrayAccess-2G0pRoaC.js} +0 -0
  151. /package/dist/{arrayAccess-DsnQpdSD.cjs → arrayAccess-Br-m2PP7.cjs} +0 -0
  152. /package/dist/{constants-csSEYddm.js → constants-Ci5CA3aZ.js} +0 -0
  153. /package/dist/{constants-BNP_xnBN.cjs → constants-DTorLmes.cjs} +0 -0
  154. /package/dist/{types--GD-LVc6.js → types-BIdk_GJY.js} +0 -0
  155. /package/dist/{types-gLi9wL0N.cjs → types-CDkxah-M.cjs} +0 -0
  156. /package/dist/{vecOps-CODplJp3.cjs → vecOps-D7xplSx8.cjs} +0 -0
  157. /package/dist/{vecOps-B-PCHgyB.js → vecOps-DVROrqTV.js} +0 -0
  158. /package/dist/{workerHandler-Dm0_0F8Z.js → workerHandler-BndMJVx6.js} +0 -0
  159. /package/dist/{workerHandler-C-3cFcsQ.cjs → workerHandler-sCf818XJ.cjs} +0 -0
@@ -1,5 +1,6 @@
1
- import { _ as serializeCurve2d$2, a as curveTypeName, c as intersectCurves2dFn, d as makeEllipse2d$2, f as makeLine2d$2, g as scaleCurve2d$2, h as rotateCurve2d$2, i as curveBounds, l as makeBezier2d$2, m as mirrorAtPoint, n as addCurveToBBox, o as deserializeCurve2d$2, p as mirrorAcrossAxis, r as createBBox2d, s as evaluateCurve2d$2, u as makeCircle2d$2, v as tangentCurve2d, y as translateCurve2d$2 } from "./occtWasmAdapter-DIhUXubY.js";
2
- import { A as ok, b as err } from "./errors-DboJwVCf.js";
1
+ import { n as wasmIndex, t as vec3At } from "./vec3-BRj3eI54.js";
2
+ import { _ as serializeCurve2d$2, a as curveTypeName, c as intersectCurves2dFn, d as makeEllipse2d$2, f as makeLine2d$2, g as scaleCurve2d$2, h as rotateCurve2d$2, i as curveBounds, l as makeBezier2d$2, m as mirrorAtPoint, n as addCurveToBBox, o as deserializeCurve2d$2, p as mirrorAcrossAxis, r as createBBox2d, s as evaluateCurve2d$2, u as makeCircle2d$2, v as tangentCurve2d, y as translateCurve2d$2 } from "./occtWasmAdapter--TZGP9DX.js";
3
+ import { A as ok, b as err } from "./errors-0fYW_YnO.js";
3
4
  //#region src/kernel/kernel2dTypes.ts
4
5
  /** Check if the kernel supports 2D geometry operations. */
5
6
  function supportsKernel2D(kernel) {
@@ -812,7 +813,7 @@ function fuseAllNative(oc, shapes, options = {}) {
812
813
  function fuseAllPairwiseRange(oc, shapes, start, end, options) {
813
814
  options.signal?.throwIfAborted();
814
815
  const count = end - start;
815
- if (count === 1) return shapes[start];
816
+ if (count === 1) return wasmIndex(shapes, start);
816
817
  if (count === 2) return fuse$1(oc, shapes[start], shapes[start + 1], {
817
818
  ...options,
818
819
  simplify: false
@@ -842,7 +843,7 @@ function fuseAllPairwise(oc, shapes, options = {}) {
842
843
  */
843
844
  function fuseAll$1(oc, shapes, options = {}) {
844
845
  if (shapes.length === 0) throw new Error("fuseAll requires at least one shape");
845
- if (shapes.length === 1) return shapes[0];
846
+ if (shapes.length === 1) return wasmIndex(shapes, 0);
846
847
  const { strategy = "native" } = options;
847
848
  if (strategy === "pairwise") return fuseAllPairwise(oc, shapes, options);
848
849
  return fuseAllNative(oc, shapes, options);
@@ -2841,7 +2842,7 @@ function makeEllipseArc$1(oc, center, normal, majorRadius, minorRadius, startAng
2841
2842
  function makeBezierEdge$1(oc, points) {
2842
2843
  const arr = new oc.TColgp_Array1OfPnt_2(1, points.length);
2843
2844
  for (let i = 0; i < points.length; i++) {
2844
- const p = points[i];
2845
+ const p = wasmIndex(points, i);
2845
2846
  const pnt = new oc.gp_Pnt_3(p[0], p[1], p[2]);
2846
2847
  arr.SetValue_1(i + 1, pnt);
2847
2848
  pnt.delete();
@@ -3430,7 +3431,7 @@ function createAffinityGTrsf2d$1(ox, oy, dx, dy, ratio) {
3430
3431
  0,
3431
3432
  1
3432
3433
  ];
3433
- return _gtrsf$1(m, ox - m[0] * ox - m[1] * oy, oy - m[3] * ox - m[4] * oy);
3434
+ return _gtrsf$1(m, ox - wasmIndex(m, 0) * ox - wasmIndex(m, 1) * oy, oy - wasmIndex(m, 3) * ox - wasmIndex(m, 4) * oy);
3434
3435
  }
3435
3436
  function createTranslationGTrsf2d$1(dx, dy) {
3436
3437
  return _gtrsf$1([
@@ -3461,7 +3462,7 @@ function createMirrorGTrsf2d$1(cx, cy, mode, ox, oy, dx, dy) {
3461
3462
  1
3462
3463
  ];
3463
3464
  const apx = ox ?? cx, apy = oy ?? cy;
3464
- return _gtrsf$1(m, apx - m[0] * apx - m[1] * apy, apy - m[3] * apx - m[4] * apy);
3465
+ return _gtrsf$1(m, apx - wasmIndex(m, 0) * apx - wasmIndex(m, 1) * apy, apy - wasmIndex(m, 3) * apx - wasmIndex(m, 4) * apy);
3465
3466
  }
3466
3467
  return _gtrsf$1([
3467
3468
  -1,
@@ -3508,21 +3509,23 @@ function setGTrsf2dTranslationPart$1(gtrsf, dx, dy) {
3508
3509
  }
3509
3510
  function multiplyGTrsf2d$1(base, other) {
3510
3511
  const a = base.m, b = other.m;
3512
+ const ai = (i) => wasmIndex(a, i);
3513
+ const bi = (i) => wasmIndex(b, i);
3511
3514
  base.m = [
3512
- a[0] * b[0] + a[1] * b[3] + a[2] * b[6],
3513
- a[0] * b[1] + a[1] * b[4] + a[2] * b[7],
3514
- a[0] * b[2] + a[1] * b[5] + a[2] * b[8],
3515
- a[3] * b[0] + a[4] * b[3] + a[5] * b[6],
3516
- a[3] * b[1] + a[4] * b[4] + a[5] * b[7],
3517
- a[3] * b[2] + a[4] * b[5] + a[5] * b[8],
3518
- a[6] * b[0] + a[7] * b[3] + a[8] * b[6],
3519
- a[6] * b[1] + a[7] * b[4] + a[8] * b[7],
3520
- a[6] * b[2] + a[7] * b[5] + a[8] * b[8]
3515
+ ai(0) * bi(0) + ai(1) * bi(3) + ai(2) * bi(6),
3516
+ ai(0) * bi(1) + ai(1) * bi(4) + ai(2) * bi(7),
3517
+ ai(0) * bi(2) + ai(1) * bi(5) + ai(2) * bi(8),
3518
+ ai(3) * bi(0) + ai(4) * bi(3) + ai(5) * bi(6),
3519
+ ai(3) * bi(1) + ai(4) * bi(4) + ai(5) * bi(7),
3520
+ ai(3) * bi(2) + ai(4) * bi(5) + ai(5) * bi(8),
3521
+ ai(6) * bi(0) + ai(7) * bi(3) + ai(8) * bi(6),
3522
+ ai(6) * bi(1) + ai(7) * bi(4) + ai(8) * bi(7),
3523
+ ai(6) * bi(2) + ai(7) * bi(5) + ai(8) * bi(8)
3521
3524
  ];
3522
3525
  const oldTx = base.tx, oldTy = base.ty;
3523
3526
  const otx = Number(other.tx) || 0, oty = Number(other.ty) || 0;
3524
- base.tx = a[0] * otx + a[1] * oty + oldTx;
3525
- base.ty = a[3] * otx + a[4] * oty + oldTy;
3527
+ base.tx = ai(0) * otx + ai(1) * oty + oldTx;
3528
+ base.ty = ai(3) * otx + ai(4) * oty + oldTy;
3526
3529
  }
3527
3530
  function transformCurve2dGeneral$1(curve, gtrsf) {
3528
3531
  const c = c2d$1(curve);
@@ -3538,13 +3541,14 @@ function transformCurve2dGeneral$1(curve, gtrsf) {
3538
3541
  1
3539
3542
  ];
3540
3543
  const tx = Number(gtrsf.tx) || 0, ty = Number(gtrsf.ty) || 0;
3541
- if (Math.abs(m[0] - 1) < 1e-12 && Math.abs(m[4] - 1) < 1e-12 && Math.abs(m[1]) < 1e-12 && Math.abs(m[3]) < 1e-12) return translateCurve2d$2(c, tx, ty);
3544
+ const m0 = wasmIndex(m, 0), m1 = wasmIndex(m, 1), m3 = wasmIndex(m, 3), m4 = wasmIndex(m, 4);
3545
+ if (Math.abs(m0 - 1) < 1e-12 && Math.abs(m4 - 1) < 1e-12 && Math.abs(m1) < 1e-12 && Math.abs(m3) < 1e-12) return translateCurve2d$2(c, tx, ty);
3542
3546
  const bounds = curveBounds(c);
3543
3547
  const N = 20;
3544
3548
  const pts = [];
3545
3549
  for (let i = 0; i <= N; i++) {
3546
3550
  const [px, py] = evaluateCurve2d$2(c, bounds.first + (bounds.last - bounds.first) * i / N);
3547
- pts.push([m[0] * px + m[1] * py + tx, m[3] * px + m[4] * py + ty]);
3551
+ pts.push([m0 * px + m1 * py + tx, m3 * px + m4 * py + ty]);
3548
3552
  }
3549
3553
  return makeBezier2d$2(pts);
3550
3554
  }
@@ -3677,8 +3681,8 @@ function approximateCurve2dAsBSpline$1(curve, tol, cont, maxSeg) {
3677
3681
  maxErr = 0;
3678
3682
  for (let i = 0; i < curN; i++) {
3679
3683
  const [ex, ey] = evaluateCurve2d$2(c, bounds.first + (bounds.last - bounds.first) * (i + .5) / curN);
3680
- const p0 = poles[i];
3681
- const p1 = poles[i + 1];
3684
+ const p0 = wasmIndex(poles, i);
3685
+ const p1 = wasmIndex(poles, i + 1);
3682
3686
  const mx = (p0[0] + p1[0]) / 2;
3683
3687
  const my = (p0[1] + p1[1]) / 2;
3684
3688
  const err = Math.sqrt((ex - mx) ** 2 + (ey - my) ** 2);
@@ -3704,8 +3708,8 @@ function decomposeBSpline2dToBeziers$1(curve) {
3704
3708
  ];
3705
3709
  const result = [];
3706
3710
  for (let i = 0; i < breakpoints.length - 1; i++) {
3707
- const t0 = breakpoints[i];
3708
- const t1 = breakpoints[i + 1];
3711
+ const t0 = wasmIndex(breakpoints, i);
3712
+ const t1 = wasmIndex(breakpoints, i + 1);
3709
3713
  const span = t1 - t0;
3710
3714
  if (span < 1e-15) continue;
3711
3715
  const p0 = evaluateCurve2d$2(c, t0);
@@ -3852,7 +3856,7 @@ function interpolatePoints3d(oc, points) {
3852
3856
  const pnts = new oc.TColgp_Array1OfPnt_2(1, points.length);
3853
3857
  const reusePnt = new oc.gp_Pnt_1();
3854
3858
  for (let i = 0; i < points.length; i++) {
3855
- const p = points[i];
3859
+ const p = wasmIndex(points, i);
3856
3860
  reusePnt.SetCoord_2(p[0], p[1], p[2]);
3857
3861
  pnts.SetValue_1(i + 1, reusePnt);
3858
3862
  }
@@ -3918,7 +3922,7 @@ function liftCurve2dToPlane$1(oc, curve, planeOrigin, planeZ, planeX) {
3918
3922
  }
3919
3923
  if (c.__bk2d === "bezier" || c.__bk2d === "bspline") {
3920
3924
  const pts3d = c.poles.map(([u, v]) => lift(u, v));
3921
- if (pts3d.length === 2) return makeLineEdge3d(oc, pts3d[0], pts3d[1]);
3925
+ if (pts3d.length === 2) return makeLineEdge3d(oc, wasmIndex(pts3d, 0), wasmIndex(pts3d, 1));
3922
3926
  return interpolatePoints3d(oc, pts3d);
3923
3927
  }
3924
3928
  const bounds = curveBounds(c);
@@ -4461,7 +4465,7 @@ function makeFaceOnSurface$1(oc, surfaceOrFace, wire) {
4461
4465
  function bsplineSurface$1(oc, points, rows, cols) {
4462
4466
  const arr = new oc.TColgp_Array2OfPnt_2(1, rows, 1, cols);
4463
4467
  for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) {
4464
- const pt = points[r * cols + c];
4468
+ const pt = wasmIndex(points, r * cols + c);
4465
4469
  const pnt = new oc.gp_Pnt_3(pt[0], pt[1], pt[2]);
4466
4470
  arr.SetValue_1(r + 1, c + 1, pnt);
4467
4471
  pnt.delete();
@@ -4483,10 +4487,10 @@ function triangulatedSurface$1(oc, points, rows, cols) {
4483
4487
  const i10 = (r + 1) * cols + c;
4484
4488
  const i01 = r * cols + (c + 1);
4485
4489
  const i11 = (r + 1) * cols + (c + 1);
4486
- const p00 = points[i00];
4487
- const p10 = points[i10];
4488
- const p01 = points[i01];
4489
- const p11 = points[i11];
4490
+ const p00 = wasmIndex(points, i00);
4491
+ const p10 = wasmIndex(points, i10);
4492
+ const p01 = wasmIndex(points, i01);
4493
+ const p11 = wasmIndex(points, i11);
4490
4494
  const face1 = makeTriFace(oc, p00, p10, p01);
4491
4495
  sewing.Add(face1);
4492
4496
  const face2 = makeTriFace(oc, p10, p11, p01);
@@ -6161,18 +6165,19 @@ function scaleMatrix(center, factor) {
6161
6165
  }
6162
6166
  /** Build a row-major 4x4 matrix from a 3x3 linear part + translation. */
6163
6167
  function affineMatrix(linear, translation) {
6168
+ const li = (i) => wasmIndex(linear, i);
6164
6169
  return [
6165
- linear[0],
6166
- linear[1],
6167
- linear[2],
6170
+ li(0),
6171
+ li(1),
6172
+ li(2),
6168
6173
  translation[0],
6169
- linear[3],
6170
- linear[4],
6171
- linear[5],
6174
+ li(3),
6175
+ li(4),
6176
+ li(5),
6172
6177
  translation[1],
6173
- linear[6],
6174
- linear[7],
6175
- linear[8],
6178
+ li(6),
6179
+ li(7),
6180
+ li(8),
6176
6181
  translation[2],
6177
6182
  0,
6178
6183
  0,
@@ -6307,13 +6312,13 @@ function iterShapes(bk, shape, type) {
6307
6312
  for (const eid of edgeIds) {
6308
6313
  const verts = bk.getEdgeVertices(eid);
6309
6314
  const coords = [[
6310
- verts[0],
6311
- verts[1],
6312
- verts[2]
6315
+ wasmIndex(verts, 0),
6316
+ wasmIndex(verts, 1),
6317
+ wasmIndex(verts, 2)
6313
6318
  ], [
6314
- verts[3],
6315
- verts[4],
6316
- verts[5]
6319
+ wasmIndex(verts, 3),
6320
+ wasmIndex(verts, 4),
6321
+ wasmIndex(verts, 5)
6317
6322
  ]];
6318
6323
  for (const [x, y, z] of coords) {
6319
6324
  const key = `${x},${y},${z}`;
@@ -6330,8 +6335,8 @@ function iterShapes(bk, shape, type) {
6330
6335
  if (type === "edge") return [shape];
6331
6336
  if (type === "vertex") {
6332
6337
  const verts = bk.getEdgeVertices(h);
6333
- const v1 = bk.makeVertex(verts[0], verts[1], verts[2]);
6334
- const v2 = bk.makeVertex(verts[3], verts[4], verts[5]);
6338
+ const v1 = bk.makeVertex(wasmIndex(verts, 0), wasmIndex(verts, 1), wasmIndex(verts, 2));
6339
+ const v2 = bk.makeVertex(wasmIndex(verts, 3), wasmIndex(verts, 4), wasmIndex(verts, 5));
6335
6340
  return [vertexHandle(v1), vertexHandle(v2)];
6336
6341
  }
6337
6342
  return [];
@@ -6398,12 +6403,7 @@ function sew(bk, shapes, tolerance) {
6398
6403
  //#endregion
6399
6404
  //#region src/kernel/brepkit/geometryOps.ts
6400
6405
  function vertexPosition(bk, vertex) {
6401
- const pos = bk.getVertexPosition(unwrap(vertex, "vertex"));
6402
- return [
6403
- pos[0],
6404
- pos[1],
6405
- pos[2]
6406
- ];
6406
+ return vec3At(bk.getVertexPosition(unwrap(vertex, "vertex")));
6407
6407
  }
6408
6408
  function surfaceType(bk, face) {
6409
6409
  return bk.getSurfaceType(unwrap(face, "face"));
@@ -6411,47 +6411,32 @@ function surfaceType(bk, face) {
6411
6411
  function uvBounds(bk, face) {
6412
6412
  const domain = bk.getSurfaceDomain(unwrap(face, "face"));
6413
6413
  return {
6414
- uMin: domain[0],
6415
- uMax: domain[1],
6416
- vMin: domain[2],
6417
- vMax: domain[3]
6414
+ uMin: wasmIndex(domain, 0),
6415
+ uMax: wasmIndex(domain, 1),
6416
+ vMin: wasmIndex(domain, 2),
6417
+ vMax: wasmIndex(domain, 3)
6418
6418
  };
6419
6419
  }
6420
6420
  function outerWire(bk, face) {
6421
6421
  return wireHandle(bk.getFaceOuterWire(unwrap(face, "face")));
6422
6422
  }
6423
6423
  function surfaceNormal(bk, face, u, v) {
6424
- const n = bk.evaluateSurfaceNormal(unwrap(face, "face"), u, v);
6425
- return [
6426
- n[0],
6427
- n[1],
6428
- n[2]
6429
- ];
6424
+ return vec3At(bk.evaluateSurfaceNormal(unwrap(face, "face"), u, v));
6430
6425
  }
6431
6426
  function pointOnSurface(bk, face, u, v) {
6432
- const p = bk.evaluateSurface(unwrap(face, "face"), u, v);
6433
- return [
6434
- p[0],
6435
- p[1],
6436
- p[2]
6437
- ];
6427
+ return vec3At(bk.evaluateSurface(unwrap(face, "face"), u, v));
6438
6428
  }
6439
6429
  function uvFromPoint(bk, face, point) {
6440
6430
  try {
6441
6431
  const result = bk.projectPointOnSurface(unwrap(face, "face"), point[0], point[1], point[2]);
6442
- return [result[0], result[1]];
6432
+ return [wasmIndex(result, 0), wasmIndex(result, 1)];
6443
6433
  } catch (e) {
6444
6434
  console.warn("brepkit: uvFromPoint failed:", e);
6445
6435
  return null;
6446
6436
  }
6447
6437
  }
6448
6438
  function projectPointOnFace(bk, face, point) {
6449
- const result = bk.projectPointOnSurface(unwrap(face, "face"), point[0], point[1], point[2]);
6450
- return [
6451
- result[2],
6452
- result[3],
6453
- result[4]
6454
- ];
6439
+ return vec3At(bk.projectPointOnSurface(unwrap(face, "face"), point[0], point[1], point[2]), 2);
6455
6440
  }
6456
6441
  function curveTangent(bk, shape, param) {
6457
6442
  const h = shape;
@@ -6459,14 +6444,14 @@ function curveTangent(bk, shape, param) {
6459
6444
  let evalParam = param;
6460
6445
  if (h.type === "wire") {
6461
6446
  const edgeIds = toArray(bk.getWireEdges(h.id));
6462
- edgeId = edgeIds[edgeIds.length - 1];
6447
+ edgeId = wasmIndex(edgeIds, edgeIds.length - 1);
6463
6448
  let cumulative = 0;
6464
6449
  for (const eid of edgeIds) {
6465
6450
  const p = bk.getEdgeCurveParameters(eid);
6466
- const span = p[1] - p[0];
6451
+ const span = wasmIndex(p, 1) - wasmIndex(p, 0);
6467
6452
  if (param <= cumulative + span || eid === edgeId) {
6468
6453
  edgeId = eid;
6469
- evalParam = Math.min(p[0] + (param - cumulative), p[1]);
6454
+ evalParam = Math.min(wasmIndex(p, 0) + (param - cumulative), wasmIndex(p, 1));
6470
6455
  break;
6471
6456
  }
6472
6457
  cumulative += span;
@@ -6474,16 +6459,8 @@ function curveTangent(bk, shape, param) {
6474
6459
  } else edgeId = unwrap(shape, "edge");
6475
6460
  const result = bk.evaluateEdgeCurveD1(edgeId, evalParam);
6476
6461
  return {
6477
- point: [
6478
- result[0],
6479
- result[1],
6480
- result[2]
6481
- ],
6482
- tangent: [
6483
- result[3],
6484
- result[4],
6485
- result[5]
6486
- ]
6462
+ point: vec3At(result, 0),
6463
+ tangent: vec3At(result, 3)
6487
6464
  };
6488
6465
  }
6489
6466
  function curveParameters(bk, shape) {
@@ -6494,13 +6471,12 @@ function curveParameters(bk, shape) {
6494
6471
  let total = 0;
6495
6472
  for (const eid of edgeIds) {
6496
6473
  const p = bk.getEdgeCurveParameters(eid);
6497
- total += p[1] - p[0];
6474
+ total += wasmIndex(p, 1) - wasmIndex(p, 0);
6498
6475
  }
6499
6476
  return [0, total];
6500
6477
  }
6501
- const edgeId = unwrap(shape, "edge");
6502
- const params = bk.getEdgeCurveParameters(edgeId);
6503
- return [params[0], params[1]];
6478
+ const params = bk.getEdgeCurveParameters(unwrap(shape, "edge"));
6479
+ return [wasmIndex(params, 0), wasmIndex(params, 1)];
6504
6480
  }
6505
6481
  function curvePointAtParam(bk, shape, param) {
6506
6482
  const h = shape;
@@ -6509,55 +6485,28 @@ function curvePointAtParam(bk, shape, param) {
6509
6485
  let cumulative = 0;
6510
6486
  for (const eid of edgeIds) {
6511
6487
  const p = bk.getEdgeCurveParameters(eid);
6512
- const span = p[1] - p[0];
6488
+ const span = wasmIndex(p, 1) - wasmIndex(p, 0);
6513
6489
  if (param <= cumulative + span || eid === edgeIds[edgeIds.length - 1]) {
6514
- const localParam = p[0] + (param - cumulative);
6515
- const pt = bk.evaluateEdgeCurve(eid, Math.min(localParam, p[1]));
6516
- return [
6517
- pt[0],
6518
- pt[1],
6519
- pt[2]
6520
- ];
6490
+ const localParam = wasmIndex(p, 0) + (param - cumulative);
6491
+ return vec3At(bk.evaluateEdgeCurve(eid, Math.min(localParam, wasmIndex(p, 1))));
6521
6492
  }
6522
6493
  cumulative += span;
6523
6494
  }
6524
- const pt = bk.evaluateEdgeCurve(edgeIds[0], param);
6525
- return [
6526
- pt[0],
6527
- pt[1],
6528
- pt[2]
6529
- ];
6495
+ return vec3At(bk.evaluateEdgeCurve(wasmIndex(edgeIds, 0), param));
6530
6496
  }
6531
- const edgeId = unwrap(shape, "edge");
6532
- const p = bk.evaluateEdgeCurve(edgeId, param);
6533
- return [
6534
- p[0],
6535
- p[1],
6536
- p[2]
6537
- ];
6497
+ return vec3At(bk.evaluateEdgeCurve(unwrap(shape, "edge"), param));
6538
6498
  }
6539
6499
  function curveIsClosed(bk, shape) {
6540
6500
  const h = shape;
6541
6501
  if (h.type === "wire") {
6542
6502
  const edgeIds = toArray(bk.getWireEdges(h.id));
6543
6503
  if (edgeIds.length === 0) return false;
6544
- if (edgeIds.length === 1) {
6545
- const verts = bk.getEdgeVertices(edgeIds[0]);
6546
- return dist3(verts[0], verts[1], verts[2], verts[3], verts[4], verts[5]) < 1e-7;
6547
- }
6504
+ if (edgeIds.length === 1) return edgeIsClosed(bk.getEdgeVertices(wasmIndex(edgeIds, 0)));
6548
6505
  const endpoints = [];
6549
6506
  for (const eid of edgeIds) {
6550
6507
  const verts = bk.getEdgeVertices(eid);
6551
- endpoints.push([
6552
- verts[0],
6553
- verts[1],
6554
- verts[2]
6555
- ]);
6556
- endpoints.push([
6557
- verts[3],
6558
- verts[4],
6559
- verts[5]
6560
- ]);
6508
+ endpoints.push(vec3At(verts, 0));
6509
+ endpoints.push(vec3At(verts, 3));
6561
6510
  }
6562
6511
  const unmatched = [];
6563
6512
  for (const pt of endpoints) {
@@ -6567,8 +6516,10 @@ function curveIsClosed(bk, shape) {
6567
6516
  }
6568
6517
  return unmatched.length === 0;
6569
6518
  }
6570
- const verts = bk.getEdgeVertices(unwrap(shape, "edge"));
6571
- return dist3(verts[0], verts[1], verts[2], verts[3], verts[4], verts[5]) < 1e-7;
6519
+ return edgeIsClosed(bk.getEdgeVertices(unwrap(shape, "edge")));
6520
+ }
6521
+ function edgeIsClosed(verts) {
6522
+ return dist3(wasmIndex(verts, 0), wasmIndex(verts, 1), wasmIndex(verts, 2), wasmIndex(verts, 3), wasmIndex(verts, 4), wasmIndex(verts, 5)) < 1e-7;
6572
6523
  }
6573
6524
  function curveIsPeriodic(bk, shape) {
6574
6525
  const h = shape;
@@ -6612,7 +6563,7 @@ function curveKnotRemove(bk, edge, knot, tolerance) {
6612
6563
  function curveSplit(bk, edge, param) {
6613
6564
  const edgeId = unwrap(edge, "edge");
6614
6565
  const result = bk.curveSplit(edgeId, param);
6615
- return [edgeHandle(result[0]), edgeHandle(result[1])];
6566
+ return [edgeHandle(wasmIndex(result, 0)), edgeHandle(wasmIndex(result, 1))];
6616
6567
  }
6617
6568
  function approximateSurfaceLspia(bk, coords, rows, cols, degreeU, degreeV, numCpsU, numCpsV, tolerance, maxIterations) {
6618
6569
  return faceHandle(bk.approximateSurfaceLspia(coords, rows, cols, degreeU, degreeV, numCpsU, numCpsV, tolerance, maxIterations));
@@ -6627,12 +6578,7 @@ function createCurveAdaptor(_bk, shape) {
6627
6578
  function getBezierPenultimatePole(bk, edge) {
6628
6579
  const nurbsData = extractNurbsFromEdge(bk, edge);
6629
6580
  if (!nurbsData || nurbsData.controlPoints.length < 6) return null;
6630
- const n = nurbsData.controlPoints.length;
6631
- return [
6632
- nurbsData.controlPoints[n - 6],
6633
- nurbsData.controlPoints[n - 5],
6634
- nurbsData.controlPoints[n - 4]
6635
- ];
6581
+ return vec3At(nurbsData.controlPoints, nurbsData.controlPoints.length - 6);
6636
6582
  }
6637
6583
  function getSurfaceCylinderData(bk, surface) {
6638
6584
  if (isBrepkitHandle(surface) && surface.type === "face") {
@@ -6652,7 +6598,7 @@ function classifyPointOnFace(bk, face, u, v, tolerance) {
6652
6598
  if (tolerance !== void 0) warnOnce("classify-tolerance", "classifyPointOnFace() tolerance parameter is not supported; brepkit uses domain-based classification.");
6653
6599
  const faceId = unwrap(face, "face");
6654
6600
  const domain = bk.getSurfaceDomain(faceId);
6655
- if (u < domain[0] || u > domain[1] || v < domain[2] || v > domain[3]) return "out";
6601
+ if (u < wasmIndex(domain, 0) || u > wasmIndex(domain, 1) || v < wasmIndex(domain, 2) || v > wasmIndex(domain, 3)) return "out";
6656
6602
  return "in";
6657
6603
  }
6658
6604
  function classifyPointRobust(bk, shape, point, tolerance) {
@@ -6845,19 +6791,10 @@ function extractPlaneFromFace(bk, faceShape) {
6845
6791
  }
6846
6792
  faceId = bestId;
6847
6793
  } else faceId = unwrap(faceShape, "face");
6848
- const n = bk.getFaceNormal(faceId);
6849
- const normal = [
6850
- n[0],
6851
- n[1],
6852
- n[2]
6853
- ];
6794
+ const normal = vec3At(bk.getFaceNormal(faceId));
6854
6795
  const positions = bk.tessellateFace(faceId, 1).positions;
6855
6796
  if (positions.length >= 3) return {
6856
- point: [
6857
- positions[0],
6858
- positions[1],
6859
- positions[2]
6860
- ],
6797
+ point: vec3At(positions),
6861
6798
  normal
6862
6799
  };
6863
6800
  return {
@@ -6897,27 +6834,17 @@ function extractNurbsFromEdge(bk, shape) {
6897
6834
  1
6898
6835
  ],
6899
6836
  controlPoints: [
6900
- verts[0],
6901
- verts[1],
6902
- verts[2],
6903
- verts[3],
6904
- verts[4],
6905
- verts[5]
6837
+ wasmIndex(verts, 0),
6838
+ wasmIndex(verts, 1),
6839
+ wasmIndex(verts, 2),
6840
+ wasmIndex(verts, 3),
6841
+ wasmIndex(verts, 4),
6842
+ wasmIndex(verts, 5)
6906
6843
  ],
6907
6844
  weights: [1, 1]
6908
6845
  };
6909
6846
  }
6910
6847
  //#endregion
6911
- //#region src/utils/vec3.ts
6912
- /**
6913
- * Index into a typed/regular array at a position the caller has structurally
6914
- * guaranteed (WASM ABI fixed-length arrays, post-bounds-check loops, etc.).
6915
- * Equivalent to `arr[i]!` but typed as `T` directly — no eslint-disable needed.
6916
- */
6917
- function wasmIndex(arr, i) {
6918
- return arr[i];
6919
- }
6920
- //#endregion
6921
6848
  //#region src/kernel/brepkit/constructionOps.ts
6922
6849
  function makeVertex(bk, x, y, z) {
6923
6850
  return vertexHandle(bk.makeVertex(x, y, z));
@@ -7493,11 +7420,11 @@ function section(bk, shape, plane, _approximation) {
7493
7420
  const solidId = isBrepkitHandle(shape) && shape.type === "solid" ? shape.id : unwrap(shape, "solid");
7494
7421
  const faceIds = toArray(bk.section(solidId, point[0], point[1], point[2], normal[0], normal[1], normal[2]));
7495
7422
  if (faceIds.length === 0) return compoundHandle(bk.makeCompound([]));
7496
- return wireHandle(bk.getFaceOuterWire(faceIds[0]));
7423
+ return wireHandle(bk.getFaceOuterWire(wasmIndex(faceIds, 0)));
7497
7424
  }
7498
7425
  function fuseAll(bk, shapes, options) {
7499
7426
  if (shapes.length === 0) throw new Error("brepkit: fuseAll requires at least one shape");
7500
- if (shapes.length === 1) return shapes[0];
7427
+ if (shapes.length === 1) return wasmIndex(shapes, 0);
7501
7428
  if (bk.compoundFuse) {
7502
7429
  const solidIds = [];
7503
7430
  for (const shape of shapes) {
@@ -7515,7 +7442,7 @@ function fuseAll(bk, shapes, options) {
7515
7442
  else next.push(current[i]);
7516
7443
  current = next;
7517
7444
  }
7518
- return current[0];
7445
+ return wasmIndex(current, 0);
7519
7446
  }
7520
7447
  function cutAll(bk, shape, tools, options) {
7521
7448
  if (tools.length === 0) return shape;
@@ -7594,11 +7521,11 @@ function hull(bk, shapes, _tolerance) {
7594
7521
  const vertIds = toArray(bk.getSolidVertices(h.id));
7595
7522
  for (const vid of vertIds) {
7596
7523
  const pos = bk.getVertexPosition(vid);
7597
- coords.push(pos[0], pos[1], pos[2]);
7524
+ coords.push(wasmIndex(pos, 0), wasmIndex(pos, 1), wasmIndex(pos, 2));
7598
7525
  }
7599
7526
  } else if (h.type === "vertex") {
7600
7527
  const pos = bk.getVertexPosition(h.id);
7601
- coords.push(pos[0], pos[1], pos[2]);
7528
+ coords.push(wasmIndex(pos, 0), wasmIndex(pos, 1), wasmIndex(pos, 2));
7602
7529
  }
7603
7530
  }
7604
7531
  if (coords.length < 12) throw new Error("brepkit: hull requires enough points");
@@ -7613,14 +7540,14 @@ function hullFromPoints(bk, points, _tolerance) {
7613
7540
  function buildSolidFromFaces(bk, points, faces, _tolerance) {
7614
7541
  const positions = new Float64Array(points.length * 3);
7615
7542
  for (let i = 0; i < points.length; i++) {
7616
- const p = points[i];
7543
+ const p = wasmIndex(points, i);
7617
7544
  positions[i * 3] = p.x;
7618
7545
  positions[i * 3 + 1] = p.y;
7619
7546
  positions[i * 3 + 2] = p.z;
7620
7547
  }
7621
7548
  const indices = new Uint32Array(faces.length * 3);
7622
7549
  for (let i = 0; i < faces.length; i++) {
7623
- const f = faces[i];
7550
+ const f = wasmIndex(faces, i);
7624
7551
  indices[i * 3] = f[0];
7625
7552
  indices[i * 3 + 1] = f[1];
7626
7553
  indices[i * 3 + 2] = f[2];
@@ -7918,9 +7845,9 @@ function shell(bk, shape, faces, thickness, tolerance) {
7918
7845
  let ox = 0, oy = 0, oz = 0;
7919
7846
  for (const vid of origVerts) {
7920
7847
  const pos = bk.getVertexPosition(vid);
7921
- ox += pos[0];
7922
- oy += pos[1];
7923
- oz += pos[2];
7848
+ ox += wasmIndex(pos, 0);
7849
+ oy += wasmIndex(pos, 1);
7850
+ oz += wasmIndex(pos, 2);
7924
7851
  }
7925
7852
  const n = origVerts.length;
7926
7853
  ox /= n;
@@ -7934,9 +7861,9 @@ function shell(bk, shape, faces, thickness, tolerance) {
7934
7861
  let sx = 0, sy = 0, sz = 0;
7935
7862
  for (const svid of sv) {
7936
7863
  const spos = bk.getVertexPosition(svid);
7937
- sx += spos[0];
7938
- sy += spos[1];
7939
- sz += spos[2];
7864
+ sx += wasmIndex(spos, 0);
7865
+ sy += wasmIndex(spos, 1);
7866
+ sz += wasmIndex(spos, 2);
7940
7867
  }
7941
7868
  const sn = sv.length;
7942
7869
  sx /= sn;
@@ -7987,12 +7914,12 @@ function offsetWire2D(bk, wire, offsetVal, _joinType) {
7987
7914
  const coords2d = [];
7988
7915
  for (const edge of edges) {
7989
7916
  const verts = bk.getEdgeVertices(unwrap(edge, "edge"));
7990
- coords2d.push(verts[0], verts[1]);
7917
+ coords2d.push(wasmIndex(verts, 0), wasmIndex(verts, 1));
7991
7918
  }
7992
7919
  if (coords2d.length < 6) return wire;
7993
7920
  const result = bk.offsetPolygon2d(coords2d, offsetVal, 1e-10);
7994
7921
  const coords3d = [];
7995
- for (let i = 0; i < result.length; i += 2) coords3d.push(result[i], result[i + 1], 0);
7922
+ for (let i = 0; i < result.length; i += 2) coords3d.push(wasmIndex(result, i), wasmIndex(result, i + 1), 0);
7996
7923
  return wireHandle(bk.makePolygonWire(coords3d));
7997
7924
  }
7998
7925
  function simplify(bk, shape) {
@@ -8129,8 +8056,8 @@ function exportSTEP(bk, shapes) {
8129
8056
  }
8130
8057
  function exportSTL(bk, shape, binary) {
8131
8058
  const solidIds = unwrapSolidsForExport(bk, shape, "exportSTL");
8132
- if (binary) return bk.exportStl(solidIds[0], DEFAULT_DEFLECTION).buffer;
8133
- const bytes = bk.exportStlAscii(solidIds[0], DEFAULT_DEFLECTION);
8059
+ if (binary) return bk.exportStl(wasmIndex(solidIds, 0), DEFAULT_DEFLECTION).buffer;
8060
+ const bytes = bk.exportStlAscii(wasmIndex(solidIds, 0), DEFAULT_DEFLECTION);
8134
8061
  return new TextDecoder().decode(bytes);
8135
8062
  }
8136
8063
  function importSTEP(bk, data) {
@@ -8240,8 +8167,8 @@ function meshEdges(bk, shape, tolerance, angularTolerance) {
8240
8167
  const edgeCount = edgeLines.edgeCount;
8241
8168
  const edgeGroups = [];
8242
8169
  for (let i = 0; i < edgeCount; i++) {
8243
- const startIdx = offsets[i];
8244
- const pointCount = ((i + 1 < edgeCount ? offsets[i + 1] : positions.length) - startIdx) / 3;
8170
+ const startIdx = wasmIndex(offsets, i);
8171
+ const pointCount = ((i + 1 < edgeCount ? wasmIndex(offsets, i + 1) : positions.length) - startIdx) / 3;
8245
8172
  edgeGroups.push({
8246
8173
  start: startIdx / 3,
8247
8174
  count: pointCount,
@@ -8280,8 +8207,8 @@ function meshSolidGrouped(bk, solidId, deflection, includeUVs) {
8280
8207
  if (groupCount !== faceIds.length) throw new Error(`faceOffsets/faceIds length mismatch: ${groupCount} groups vs ${faceIds.length} faces`);
8281
8208
  const faceGroups = [];
8282
8209
  for (let i = 0; i < data.faceOffsets.length - 1; i++) {
8283
- const start = data.faceOffsets[i];
8284
- const count = data.faceOffsets[i + 1] - start;
8210
+ const start = wasmIndex(data.faceOffsets, i);
8211
+ const count = wasmIndex(data.faceOffsets, i + 1) - start;
8285
8212
  if (count === 0) continue;
8286
8213
  faceGroups.push({
8287
8214
  start,
@@ -8400,28 +8327,22 @@ function length(bk, shape) {
8400
8327
  if (h.type === "wire") return bk.wireLength(h.id);
8401
8328
  throw new Error("brepkit: length() requires an edge, wire, or face");
8402
8329
  }
8330
+ function edgeMidpoint(bk, edgeId) {
8331
+ const v = bk.getEdgeVertices(edgeId);
8332
+ return [
8333
+ (wasmIndex(v, 0) + wasmIndex(v, 3)) / 2,
8334
+ (wasmIndex(v, 1) + wasmIndex(v, 4)) / 2,
8335
+ (wasmIndex(v, 2) + wasmIndex(v, 5)) / 2
8336
+ ];
8337
+ }
8403
8338
  function centerOfMass(bk, shape) {
8404
8339
  const h = shape;
8405
- if (h.type === "solid") {
8406
- const result = bk.centerOfMass(unwrap(shape), DEFAULT_DEFLECTION);
8407
- return [
8408
- result[0],
8409
- result[1],
8410
- result[2]
8411
- ];
8412
- }
8340
+ if (h.type === "solid") return vec3At(bk.centerOfMass(unwrap(shape), DEFAULT_DEFLECTION));
8413
8341
  if (h.type === "face") {
8414
8342
  const domain = uvBounds(bk, shape);
8415
8343
  return pointOnSurface(bk, shape, (domain.uMin + domain.uMax) / 2, (domain.vMin + domain.vMax) / 2);
8416
8344
  }
8417
- if (h.type === "edge") {
8418
- const verts = bk.getEdgeVertices(h.id);
8419
- return [
8420
- (verts[0] + verts[3]) / 2,
8421
- (verts[1] + verts[4]) / 2,
8422
- (verts[2] + verts[5]) / 2
8423
- ];
8424
- }
8345
+ if (h.type === "edge") return edgeMidpoint(bk, h.id);
8425
8346
  if (h.type === "vertex") return vertexPosition(bk, shape);
8426
8347
  const vertices = iterShapes(bk, shape, "vertex");
8427
8348
  if (vertices.length > 0) {
@@ -8446,14 +8367,7 @@ function centerOfMass(bk, shape) {
8446
8367
  }
8447
8368
  function linearCenterOfMass(bk, shape) {
8448
8369
  const h = shape;
8449
- if (h.type === "edge") {
8450
- const verts = bk.getEdgeVertices(h.id);
8451
- return [
8452
- (verts[0] + verts[3]) / 2,
8453
- (verts[1] + verts[4]) / 2,
8454
- (verts[2] + verts[5]) / 2
8455
- ];
8456
- }
8370
+ if (h.type === "edge") return edgeMidpoint(bk, h.id);
8457
8371
  return centerOfMass(bk, shape);
8458
8372
  }
8459
8373
  function boundingBox(bk, shape) {
@@ -8461,16 +8375,8 @@ function boundingBox(bk, shape) {
8461
8375
  if (h.type === "solid") {
8462
8376
  const bb = bk.boundingBox(unwrap(shape));
8463
8377
  return {
8464
- min: [
8465
- bb[0],
8466
- bb[1],
8467
- bb[2]
8468
- ],
8469
- max: [
8470
- bb[3],
8471
- bb[4],
8472
- bb[5]
8473
- ]
8378
+ min: vec3At(bb, 0),
8379
+ max: vec3At(bb, 3)
8474
8380
  };
8475
8381
  }
8476
8382
  if (h.type === "vertex") {
@@ -8524,85 +8430,28 @@ function distance(bk, shape1, shape2) {
8524
8430
  if (h1.type === "solid" && h2.type === "solid") {
8525
8431
  const buf = bk.solidToSolidDistance(h1.id, h2.id);
8526
8432
  return {
8527
- value: buf[0],
8528
- point1: [
8529
- buf[1],
8530
- buf[2],
8531
- buf[3]
8532
- ],
8533
- point2: [
8534
- buf[4],
8535
- buf[5],
8536
- buf[6]
8537
- ]
8538
- };
8539
- }
8540
- if (h1.type === "vertex" && h2.type === "solid") {
8541
- const pos = bk.getVertexPosition(h1.id);
8542
- const result = bk.pointToSolidDistance(pos[0], pos[1], pos[2], h2.id);
8543
- return {
8544
- value: result[0],
8545
- point1: [
8546
- pos[0],
8547
- pos[1],
8548
- pos[2]
8549
- ],
8550
- point2: [
8551
- result[1],
8552
- result[2],
8553
- result[3]
8554
- ]
8555
- };
8556
- }
8557
- if (h1.type === "vertex" && h2.type === "face") {
8558
- const pos = bk.getVertexPosition(h1.id);
8559
- const result = bk.pointToFaceDistance(pos[0], pos[1], pos[2], h2.id);
8560
- return {
8561
- value: result[0],
8562
- point1: [
8563
- pos[0],
8564
- pos[1],
8565
- pos[2]
8566
- ],
8567
- point2: [
8568
- result[1],
8569
- result[2],
8570
- result[3]
8571
- ]
8433
+ value: wasmIndex(buf, 0),
8434
+ point1: vec3At(buf, 1),
8435
+ point2: vec3At(buf, 4)
8572
8436
  };
8573
8437
  }
8574
- if (h1.type === "vertex" && h2.type === "edge") {
8575
- const pos = bk.getVertexPosition(h1.id);
8576
- const result = bk.pointToEdgeDistance(pos[0], pos[1], pos[2], h2.id);
8438
+ if (h1.type === "vertex" && (h2.type === "solid" || h2.type === "face" || h2.type === "edge")) {
8439
+ const point1 = vec3At(bk.getVertexPosition(h1.id));
8440
+ const result = h2.type === "solid" ? bk.pointToSolidDistance(point1[0], point1[1], point1[2], h2.id) : h2.type === "face" ? bk.pointToFaceDistance(point1[0], point1[1], point1[2], h2.id) : bk.pointToEdgeDistance(point1[0], point1[1], point1[2], h2.id);
8577
8441
  return {
8578
- value: result[0],
8579
- point1: [
8580
- pos[0],
8581
- pos[1],
8582
- pos[2]
8583
- ],
8584
- point2: [
8585
- result[1],
8586
- result[2],
8587
- result[3]
8588
- ]
8442
+ value: wasmIndex(result, 0),
8443
+ point1,
8444
+ point2: vec3At(result, 1)
8589
8445
  };
8590
8446
  }
8591
8447
  const getPos = (s) => {
8592
- if (s.type === "vertex") {
8593
- const p = bk.getVertexPosition(s.id);
8594
- return [
8595
- p[0],
8596
- p[1],
8597
- p[2]
8598
- ];
8599
- }
8448
+ if (s.type === "vertex") return vec3At(bk.getVertexPosition(s.id));
8600
8449
  if (s.type === "solid") {
8601
8450
  const bb = bk.boundingBox(s.id);
8602
8451
  return [
8603
- (bb[0] + bb[3]) / 2,
8604
- (bb[1] + bb[4]) / 2,
8605
- (bb[2] + bb[5]) / 2
8452
+ (wasmIndex(bb, 0) + wasmIndex(bb, 3)) / 2,
8453
+ (wasmIndex(bb, 1) + wasmIndex(bb, 4)) / 2,
8454
+ (wasmIndex(bb, 2) + wasmIndex(bb, 5)) / 2
8606
8455
  ];
8607
8456
  }
8608
8457
  return [
@@ -8626,23 +8475,15 @@ function surfaceCurvature(bk, face, u, v) {
8626
8475
  const fid = unwrap(face, "face");
8627
8476
  const data = bk.measureCurvatureAtSurface(fid, u, v);
8628
8477
  if (data.length < 8) throw new Error(`brepkit: measureCurvatureAtSurface returned ${data.length} values, expected 8`);
8629
- const k1 = data[0];
8630
- const k2 = data[1];
8478
+ const k1 = wasmIndex(data, 0);
8479
+ const k2 = wasmIndex(data, 1);
8631
8480
  return {
8632
8481
  gaussian: k1 * k2,
8633
8482
  mean: (k1 + k2) / 2,
8634
8483
  max: Math.max(k1, k2),
8635
8484
  min: Math.min(k1, k2),
8636
- maxDirection: [
8637
- data[2],
8638
- data[3],
8639
- data[4]
8640
- ],
8641
- minDirection: [
8642
- data[5],
8643
- data[6],
8644
- data[7]
8645
- ]
8485
+ maxDirection: vec3At(data, 2),
8486
+ minDirection: vec3At(data, 5)
8646
8487
  };
8647
8488
  }
8648
8489
  function surfaceCenterOfMass(bk, face) {
@@ -8651,12 +8492,23 @@ function surfaceCenterOfMass(bk, face) {
8651
8492
  const idx = mesh.indices;
8652
8493
  let cx = 0, cy = 0, cz = 0, totalArea = 0;
8653
8494
  for (let t = 0; t < idx.length; t += 3) {
8654
- const i0 = idx[t] * 3, i1 = idx[t + 1] * 3, i2 = idx[t + 2] * 3;
8655
- const tcx = (pos[i0] + pos[i1] + pos[i2]) / 3;
8656
- const tcy = (pos[i0 + 1] + pos[i1 + 1] + pos[i2 + 1]) / 3;
8657
- const tcz = (pos[i0 + 2] + pos[i1 + 2] + pos[i2 + 2]) / 3;
8658
- const ux = pos[i1] - pos[i0], uy = pos[i1 + 1] - pos[i0 + 1], uz = pos[i1 + 2] - pos[i0 + 2];
8659
- const vx = pos[i2] - pos[i0], vy = pos[i2 + 1] - pos[i0 + 1], vz = pos[i2 + 2] - pos[i0 + 2];
8495
+ const i0 = wasmIndex(idx, t) * 3;
8496
+ const i1 = wasmIndex(idx, t + 1) * 3;
8497
+ const i2 = wasmIndex(idx, t + 2) * 3;
8498
+ const p0x = wasmIndex(pos, i0);
8499
+ const p0y = wasmIndex(pos, i0 + 1);
8500
+ const p0z = wasmIndex(pos, i0 + 2);
8501
+ const p1x = wasmIndex(pos, i1);
8502
+ const p1y = wasmIndex(pos, i1 + 1);
8503
+ const p1z = wasmIndex(pos, i1 + 2);
8504
+ const p2x = wasmIndex(pos, i2);
8505
+ const p2y = wasmIndex(pos, i2 + 1);
8506
+ const p2z = wasmIndex(pos, i2 + 2);
8507
+ const tcx = (p0x + p1x + p2x) / 3;
8508
+ const tcy = (p0y + p1y + p2y) / 3;
8509
+ const tcz = (p0z + p1z + p2z) / 3;
8510
+ const ux = p1x - p0x, uy = p1y - p0y, uz = p1z - p0z;
8511
+ const vx = p2x - p0x, vy = p2y - p0y, vz = p2z - p0z;
8660
8512
  const faceArea = .5 * Math.sqrt((uy * vz - uz * vy) ** 2 + (uz * vx - ux * vz) ** 2 + (ux * vy - uy * vx) ** 2);
8661
8513
  cx += tcx * faceArea;
8662
8514
  cy += tcy * faceArea;
@@ -8744,9 +8596,9 @@ function faceCentroidById(bk, faceId) {
8744
8596
  let cz = 0;
8745
8597
  const nVerts = pos.length / 3;
8746
8598
  for (let i = 0; i < pos.length; i += 3) {
8747
- cx += pos[i];
8748
- cy += pos[i + 1];
8749
- cz += pos[i + 2];
8599
+ cx += wasmIndex(pos, i);
8600
+ cy += wasmIndex(pos, i + 1);
8601
+ cz += wasmIndex(pos, i + 2);
8750
8602
  }
8751
8603
  return [
8752
8604
  cx / nVerts,
@@ -8772,7 +8624,7 @@ function matchFacesGeometrically(bk, originalShape, inputFaceHashes, outputFaceI
8772
8624
  const hashCount = Math.min(inputFaceIds.length, inputFaceHashes.length);
8773
8625
  const inputSigs = [];
8774
8626
  for (let i = 0; i < hashCount; i++) {
8775
- const fid = inputFaceIds[i];
8627
+ const fid = wasmIndex(inputFaceIds, i);
8776
8628
  try {
8777
8629
  const normal = bk.getFaceNormal(fid);
8778
8630
  const centroid = faceCentroidById(bk, fid);
@@ -8820,7 +8672,7 @@ function matchFacesGeometrically(bk, originalShape, inputFaceHashes, outputFaceI
8820
8672
  let bestScore = -Infinity;
8821
8673
  let bestIdx = -1;
8822
8674
  for (let i = 0; i < inputSigs.length; i++) {
8823
- const inp = inputSigs[i];
8675
+ const inp = wasmIndex(inputSigs, i);
8824
8676
  const dot = (out.normal[0] ?? 0) * (inp.normal[0] ?? 0) + (out.normal[1] ?? 0) * (inp.normal[1] ?? 0) + (out.normal[2] ?? 0) * (inp.normal[2] ?? 0);
8825
8677
  if (dot < NORMAL_THRESHOLD) continue;
8826
8678
  const distSq = centroidDistSq(out.centroid, inp.centroid);
@@ -8832,7 +8684,7 @@ function matchFacesGeometrically(bk, originalShape, inputFaceHashes, outputFaceI
8832
8684
  }
8833
8685
  }
8834
8686
  if (bestIdx >= 0) {
8835
- const bestInput = inputSigs[bestIdx];
8687
+ const bestInput = wasmIndex(inputSigs, bestIdx);
8836
8688
  const existing = modified.get(bestInput.hash) ?? [];
8837
8689
  existing.push(out.hash);
8838
8690
  modified.set(bestInput.hash, existing);
@@ -8854,7 +8706,7 @@ function matchFacesGeometrically(bk, originalShape, inputFaceHashes, outputFaceI
8854
8706
  }
8855
8707
  }
8856
8708
  }
8857
- for (let i = 0; i < inputSigs.length; i++) if (!matchedInputIndices.has(i)) deleted.add(inputSigs[i].hash);
8709
+ for (let i = 0; i < inputSigs.length; i++) if (!matchedInputIndices.has(i)) deleted.add(wasmIndex(inputSigs, i).hash);
8858
8710
  }
8859
8711
  /**
8860
8712
  * Build a ShapeEvolution by comparing input face hashes to output face hashes.
@@ -8871,7 +8723,7 @@ function buildEvolution(bk, resultShape, inputFaceHashes, hashUpperBound, isTran
8871
8723
  if (h.type === "solid") {
8872
8724
  const outputFaces = toArray(bk.getSolidFaces(h.id));
8873
8725
  const outputHashes = outputFaces.map((fid) => fid % hashUpperBound);
8874
- if (isTransform) for (let i = 0; i < inputFaceHashes.length && i < outputHashes.length; i++) modified.set(inputFaceHashes[i], [outputHashes[i]]);
8726
+ if (isTransform) for (let i = 0; i < inputFaceHashes.length && i < outputHashes.length; i++) modified.set(wasmIndex(inputFaceHashes, i), [wasmIndex(outputHashes, i)]);
8875
8727
  else {
8876
8728
  const inputSet = new Set(inputFaceHashes);
8877
8729
  let hasOverlap = false;
@@ -8883,12 +8735,12 @@ function buildEvolution(bk, resultShape, inputFaceHashes, hashUpperBound, isTran
8883
8735
  const outputSet = new Set(outputHashes);
8884
8736
  for (const hash of outputHashes) if (inputSet.has(hash)) modified.set(hash, [hash]);
8885
8737
  const newFaces = outputHashes.filter((fh) => !inputSet.has(fh));
8886
- if (newFaces.length > 0 && inputFaceHashes.length > 0) generated.set(inputFaceHashes[0], newFaces);
8738
+ if (newFaces.length > 0 && inputFaceHashes.length > 0) generated.set(wasmIndex(inputFaceHashes, 0), newFaces);
8887
8739
  for (const hash of inputFaceHashes) if (!outputSet.has(hash)) deleted.add(hash);
8888
8740
  } else if (originalShape) matchFacesGeometrically(bk, originalShape, inputFaceHashes, outputFaces, hashUpperBound, modified, generated, deleted);
8889
8741
  else {
8890
- for (let i = 0; i < inputFaceHashes.length && i < outputHashes.length; i++) modified.set(inputFaceHashes[i], [outputHashes[i]]);
8891
- if (outputHashes.length > inputFaceHashes.length && inputFaceHashes.length > 0) generated.set(inputFaceHashes[0], outputHashes.slice(inputFaceHashes.length));
8742
+ for (let i = 0; i < inputFaceHashes.length && i < outputHashes.length; i++) modified.set(wasmIndex(inputFaceHashes, i), [wasmIndex(outputHashes, i)]);
8743
+ if (outputHashes.length > inputFaceHashes.length && inputFaceHashes.length > 0) generated.set(wasmIndex(inputFaceHashes, 0), outputHashes.slice(inputFaceHashes.length));
8892
8744
  }
8893
8745
  }
8894
8746
  }
@@ -9290,7 +9142,7 @@ function createAffinityGTrsf2d(ox, oy, dx, dy, ratio) {
9290
9142
  0,
9291
9143
  1
9292
9144
  ];
9293
- return _gtrsf(m, ox - m[0] * ox - m[1] * oy, oy - m[3] * ox - m[4] * oy);
9145
+ return _gtrsf(m, ox - wasmIndex(m, 0) * ox - wasmIndex(m, 1) * oy, oy - wasmIndex(m, 3) * ox - wasmIndex(m, 4) * oy);
9294
9146
  }
9295
9147
  function createTranslationGTrsf2d(dx, dy) {
9296
9148
  return _gtrsf([
@@ -9321,7 +9173,7 @@ function createMirrorGTrsf2d(cx, cy, mode, ox, oy, dx, dy) {
9321
9173
  1
9322
9174
  ];
9323
9175
  const px = ox ?? cx, py = oy ?? cy;
9324
- return _gtrsf(m, px - m[0] * px - m[1] * py, py - m[3] * px - m[4] * py);
9176
+ return _gtrsf(m, px - wasmIndex(m, 0) * px - wasmIndex(m, 1) * py, py - wasmIndex(m, 3) * px - wasmIndex(m, 4) * py);
9325
9177
  }
9326
9178
  return _gtrsf([
9327
9179
  -1,
@@ -9368,21 +9220,23 @@ function setGTrsf2dTranslationPart(gtrsf, dx, dy) {
9368
9220
  }
9369
9221
  function multiplyGTrsf2d(base, other) {
9370
9222
  const a = base.m, b = other.m;
9223
+ const ai = (i) => wasmIndex(a, i);
9224
+ const bi = (i) => wasmIndex(b, i);
9371
9225
  base.m = [
9372
- a[0] * b[0] + a[1] * b[3] + a[2] * b[6],
9373
- a[0] * b[1] + a[1] * b[4] + a[2] * b[7],
9374
- a[0] * b[2] + a[1] * b[5] + a[2] * b[8],
9375
- a[3] * b[0] + a[4] * b[3] + a[5] * b[6],
9376
- a[3] * b[1] + a[4] * b[4] + a[5] * b[7],
9377
- a[3] * b[2] + a[4] * b[5] + a[5] * b[8],
9378
- a[6] * b[0] + a[7] * b[3] + a[8] * b[6],
9379
- a[6] * b[1] + a[7] * b[4] + a[8] * b[7],
9380
- a[6] * b[2] + a[7] * b[5] + a[8] * b[8]
9226
+ ai(0) * bi(0) + ai(1) * bi(3) + ai(2) * bi(6),
9227
+ ai(0) * bi(1) + ai(1) * bi(4) + ai(2) * bi(7),
9228
+ ai(0) * bi(2) + ai(1) * bi(5) + ai(2) * bi(8),
9229
+ ai(3) * bi(0) + ai(4) * bi(3) + ai(5) * bi(6),
9230
+ ai(3) * bi(1) + ai(4) * bi(4) + ai(5) * bi(7),
9231
+ ai(3) * bi(2) + ai(4) * bi(5) + ai(5) * bi(8),
9232
+ ai(6) * bi(0) + ai(7) * bi(3) + ai(8) * bi(6),
9233
+ ai(6) * bi(1) + ai(7) * bi(4) + ai(8) * bi(7),
9234
+ ai(6) * bi(2) + ai(7) * bi(5) + ai(8) * bi(8)
9381
9235
  ];
9382
9236
  const oldTx = base.tx, oldTy = base.ty;
9383
9237
  const otx = Number(other.tx) || 0, oty = Number(other.ty) || 0;
9384
- base.tx = a[0] * otx + a[1] * oty + oldTx;
9385
- base.ty = a[3] * otx + a[4] * oty + oldTy;
9238
+ base.tx = ai(0) * otx + ai(1) * oty + oldTx;
9239
+ base.ty = ai(3) * otx + ai(4) * oty + oldTy;
9386
9240
  }
9387
9241
  function transformCurve2dGeneral(curve, gtrsf) {
9388
9242
  const c = c2d(curve);
@@ -9398,13 +9252,14 @@ function transformCurve2dGeneral(curve, gtrsf) {
9398
9252
  1
9399
9253
  ];
9400
9254
  const tx = Number(gtrsf.tx) || 0, ty = Number(gtrsf.ty) || 0;
9401
- if (Math.abs(m[0] - 1) < 1e-12 && Math.abs(m[4] - 1) < 1e-12 && Math.abs(m[1]) < 1e-12 && Math.abs(m[3]) < 1e-12) return translateCurve2d$2(c, tx, ty);
9255
+ const m0 = wasmIndex(m, 0), m1 = wasmIndex(m, 1), m3 = wasmIndex(m, 3), m4 = wasmIndex(m, 4);
9256
+ if (Math.abs(m0 - 1) < 1e-12 && Math.abs(m4 - 1) < 1e-12 && Math.abs(m1) < 1e-12 && Math.abs(m3) < 1e-12) return translateCurve2d$2(c, tx, ty);
9402
9257
  const bounds = curveBounds(c);
9403
9258
  const N = 20;
9404
9259
  const pts = [];
9405
9260
  for (let i = 0; i <= N; i++) {
9406
9261
  const [px, py] = evaluateCurve2d$2(c, bounds.first + (bounds.last - bounds.first) * i / N);
9407
- pts.push([m[0] * px + m[1] * py + tx, m[3] * px + m[4] * py + ty]);
9262
+ pts.push([m0 * px + m1 * py + tx, m3 * px + m4 * py + ty]);
9408
9263
  }
9409
9264
  return makeBezier2d$2(pts);
9410
9265
  }
@@ -9537,8 +9392,8 @@ function approximateCurve2dAsBSpline(curve, tol, cont, maxSeg) {
9537
9392
  maxErr = 0;
9538
9393
  for (let i = 0; i < N; i++) {
9539
9394
  const [ex, ey] = evaluateCurve2d$2(c, bounds.first + (bounds.last - bounds.first) * (i + .5) / N);
9540
- const p0 = poles[i];
9541
- const p1 = poles[i + 1];
9395
+ const p0 = wasmIndex(poles, i);
9396
+ const p1 = wasmIndex(poles, i + 1);
9542
9397
  const mx = (p0[0] + p1[0]) / 2;
9543
9398
  const my = (p0[1] + p1[1]) / 2;
9544
9399
  const err = Math.sqrt((ex - mx) ** 2 + (ey - my) ** 2);
@@ -9564,8 +9419,8 @@ function decomposeBSpline2dToBeziers(curve) {
9564
9419
  ];
9565
9420
  const result = [];
9566
9421
  for (let i = 0; i < breakpoints.length - 1; i++) {
9567
- const t0 = breakpoints[i];
9568
- const t1 = breakpoints[i + 1];
9422
+ const t0 = wasmIndex(breakpoints, i);
9423
+ const t1 = wasmIndex(breakpoints, i + 1);
9569
9424
  const span = t1 - t0;
9570
9425
  if (span < 1e-15) continue;
9571
9426
  const p0 = evaluateCurve2d$2(c, t0);
@@ -9716,13 +9571,13 @@ function liftCurve2dToPlane(bk, curve, origin, planeZ, planeX) {
9716
9571
  const [eu, ev] = evaluateCurve2d$2(c, bounds.first + (seg + 1) * segmentSpan);
9717
9572
  edgeIds.push(bk.makeCircleArc3d(...lift(su, sv), ...lift(eu, ev), ...center3d, ...axis));
9718
9573
  }
9719
- if (edgeIds.length === 1) return edgeHandle(edgeIds[0]);
9574
+ if (edgeIds.length === 1) return edgeHandle(wasmIndex(edgeIds, 0));
9720
9575
  return wireHandle(bk.makeWire(edgeIds, false));
9721
9576
  }
9722
9577
  }
9723
9578
  if (c.__bk2d === "bezier" || c.__bk2d === "bspline") {
9724
9579
  const points3d = c.poles.map(([u, v]) => lift(u, v));
9725
- if (points3d.length === 2) return makeLineEdge(bk, points3d[0], points3d[1]);
9580
+ if (points3d.length === 2) return makeLineEdge(bk, wasmIndex(points3d, 0), wasmIndex(points3d, 1));
9726
9581
  const degree = Math.min(3, points3d.length - 1);
9727
9582
  const coords = points3d.flatMap(([px, py, pz]) => [
9728
9583
  px,
@@ -9749,58 +9604,40 @@ function buildEdgeOnSurface(bk, curve, surface) {
9749
9604
  const points = [];
9750
9605
  for (let i = 0; i <= N; i++) {
9751
9606
  const [u, v] = evaluateCurve2d$2(c, bounds.first + (bounds.last - bounds.first) * i / N);
9752
- const p = bk.evaluateSurface(fid, u, v);
9753
- points.push([
9754
- p[0],
9755
- p[1],
9756
- p[2]
9757
- ]);
9607
+ points.push(vec3At(bk.evaluateSurface(fid, u, v)));
9758
9608
  }
9759
9609
  return interpolatePoints(bk, points);
9760
9610
  }
9761
9611
  function extractSurfaceFromFace(face) {
9762
9612
  return face;
9763
9613
  }
9764
- function extractCurve2dFromEdge(bk, edge, face) {
9765
- const eid = unwrap(edge, "edge");
9766
- const fid = unwrap(face, "face");
9767
- const params = bk.getEdgeCurveParameters(eid);
9768
- const tMin = params[0] ?? 0;
9769
- const tMax = params[1] ?? 1;
9770
- const BASE_N = 20;
9771
- const MAX_N = 80;
9772
- const REFINE_THRESHOLD = .05;
9773
- const tValues = [];
9774
- for (let i = 0; i <= BASE_N; i++) tValues.push(tMin + (tMax - tMin) * i / BASE_N);
9775
- const evaluateUV = (t) => {
9776
- const pt = bk.evaluateEdgeCurve(eid, t);
9777
- const uv = bk.projectPointOnSurface(fid, pt[0], pt[1], pt[2]);
9778
- return [uv[0], uv[1]];
9779
- };
9780
- const uvSamples = tValues.map((t) => ({
9781
- t,
9782
- uv: evaluateUV(t)
9783
- }));
9614
+ /**
9615
+ * Adaptively refine a UV sample list by inserting midpoints whenever the
9616
+ * sampled UV midpoint deviates from the linear interpolation of its
9617
+ * neighbors by more than `threshold`. Stops at `maxSamples` or when no
9618
+ * pair exceeds the threshold; cap of 3 refinement passes overall.
9619
+ */
9620
+ function refineUVSamples(uvSamples, evaluateUV, maxSamples, threshold) {
9784
9621
  let refinements = 0;
9785
- while (uvSamples.length < MAX_N) {
9622
+ while (uvSamples.length < maxSamples) {
9786
9623
  const insertions = [];
9787
9624
  for (let i = 0; i < uvSamples.length - 1; i++) {
9788
- const a = uvSamples[i];
9789
- const b = uvSamples[i + 1];
9625
+ const a = wasmIndex(uvSamples, i);
9626
+ const b = wasmIndex(uvSamples, i + 1);
9790
9627
  const tMid = (a.t + b.t) / 2;
9791
9628
  const uvMid = evaluateUV(tMid);
9792
9629
  const interpU = (a.uv[0] + b.uv[0]) / 2;
9793
9630
  const interpV = (a.uv[1] + b.uv[1]) / 2;
9794
- if (Math.sqrt((uvMid[0] - interpU) ** 2 + (uvMid[1] - interpV) ** 2) > REFINE_THRESHOLD) insertions.push({
9631
+ if (Math.sqrt((uvMid[0] - interpU) ** 2 + (uvMid[1] - interpV) ** 2) > threshold) insertions.push({
9795
9632
  index: i + 1,
9796
9633
  t: tMid,
9797
9634
  uv: uvMid
9798
9635
  });
9799
9636
  }
9800
9637
  if (insertions.length === 0) break;
9801
- let budget = MAX_N - uvSamples.length;
9638
+ let budget = maxSamples - uvSamples.length;
9802
9639
  for (let j = insertions.length - 1; j >= 0 && budget > 0; j--) {
9803
- const ins = insertions[j];
9640
+ const ins = wasmIndex(insertions, j);
9804
9641
  uvSamples.splice(ins.index, 0, {
9805
9642
  t: ins.t,
9806
9643
  uv: ins.uv
@@ -9810,13 +9647,35 @@ function extractCurve2dFromEdge(bk, edge, face) {
9810
9647
  refinements++;
9811
9648
  if (refinements > 3) break;
9812
9649
  }
9650
+ }
9651
+ function extractCurve2dFromEdge(bk, edge, face) {
9652
+ const eid = unwrap(edge, "edge");
9653
+ const fid = unwrap(face, "face");
9654
+ const params = bk.getEdgeCurveParameters(eid);
9655
+ const tMin = params[0] ?? 0;
9656
+ const tMax = params[1] ?? 1;
9657
+ const BASE_N = 20;
9658
+ const MAX_N = 80;
9659
+ const REFINE_THRESHOLD = .05;
9660
+ const tValues = [];
9661
+ for (let i = 0; i <= BASE_N; i++) tValues.push(tMin + (tMax - tMin) * i / BASE_N);
9662
+ const evaluateUV = (t) => {
9663
+ const pt = bk.evaluateEdgeCurve(eid, t);
9664
+ const uv = bk.projectPointOnSurface(fid, wasmIndex(pt, 0), wasmIndex(pt, 1), wasmIndex(pt, 2));
9665
+ return [wasmIndex(uv, 0), wasmIndex(uv, 1)];
9666
+ };
9667
+ const uvSamples = tValues.map((t) => ({
9668
+ t,
9669
+ uv: evaluateUV(t)
9670
+ }));
9671
+ refineUVSamples(uvSamples, evaluateUV, MAX_N, REFINE_THRESHOLD);
9813
9672
  const uvPoints = uvSamples.map((s) => s.uv);
9814
9673
  if (uvPoints.length >= 2) return makeBSpline2d(uvPoints);
9815
9674
  const verts = bk.getEdgeVertices(eid);
9816
9675
  if (verts.length >= 6) {
9817
- const uv1 = bk.projectPointOnSurface(fid, verts[0], verts[1], verts[2]);
9818
- const uv2 = bk.projectPointOnSurface(fid, verts[3], verts[4], verts[5]);
9819
- return makeLine2d$2(uv1[0], uv1[1], uv2[0], uv2[1]);
9676
+ const uv1 = bk.projectPointOnSurface(fid, wasmIndex(verts, 0), wasmIndex(verts, 1), wasmIndex(verts, 2));
9677
+ const uv2 = bk.projectPointOnSurface(fid, wasmIndex(verts, 3), wasmIndex(verts, 4), wasmIndex(verts, 5));
9678
+ return makeLine2d$2(wasmIndex(uv1, 0), wasmIndex(uv1, 1), wasmIndex(uv2, 0), wasmIndex(uv2, 1));
9820
9679
  }
9821
9680
  throw new Error(`brepkit: extractCurve2dFromEdge: degenerate edge (${verts.length} coords)`);
9822
9681
  }
@@ -9832,13 +9691,14 @@ function fillSurface(bk, wires, _options) {
9832
9691
  for (const edge of wireEdges) {
9833
9692
  const edgeId = unwrap(edge, "edge");
9834
9693
  const params = bk.getEdgeCurveParameters(edgeId);
9835
- const tMin = params[0], tMax = params[1];
9694
+ const tMin = wasmIndex(params, 0);
9695
+ const tMax = wasmIndex(params, 1);
9836
9696
  const N = 10;
9837
9697
  const pts = [];
9838
9698
  for (let i = 0; i <= N; i++) {
9839
9699
  const t = tMin + (tMax - tMin) * i / N;
9840
9700
  const p = bk.evaluateEdgeCurve(edgeId, t);
9841
- pts.push(p[0], p[1], p[2]);
9701
+ pts.push(wasmIndex(p, 0), wasmIndex(p, 1), wasmIndex(p, 2));
9842
9702
  }
9843
9703
  allCoords.push(...pts);
9844
9704
  curveLengths.push(N + 1);
@@ -10860,7 +10720,7 @@ async function init() {
10860
10720
  throw new Error("brepjs: no kernel package found. Install one of:\n npm install brepjs-opencascade (recommended)\n npm install brepkit-wasm\n npm install occt-wasm (requires manual registerKernel)");
10861
10721
  }
10862
10722
  //#endregion
10863
- //#region \0@oxc-project+runtime@0.127.0/helpers/usingCtx.js
10723
+ //#region \0@oxc-project+runtime@0.128.0/helpers/usingCtx.js
10864
10724
  function _usingCtx() {
10865
10725
  var r = "function" == typeof SuppressedError ? SuppressedError : function(r, e) {
10866
10726
  var n = Error();