brepjs 12.11.1 → 12.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/2d.cjs +3 -3
  2. package/dist/2d.js +3 -3
  3. package/dist/{Blueprint-Cum4_uL5.js → Blueprint-B_jo065X.js} +5 -5
  4. package/dist/{Blueprint-C5t_ioHD.cjs → Blueprint-C2znXaaZ.cjs} +5 -5
  5. package/dist/{blueprintFns-DlPl1rL5.cjs → blueprintFns-CxfjtauU.cjs} +2 -2
  6. package/dist/{blueprintFns-CNXZX0L2.js → blueprintFns-bpyUa_XY.js} +2 -2
  7. package/dist/{boolean2D-Cdom7nvT.cjs → boolean2D-Bu1v9M_m.cjs} +7 -7
  8. package/dist/{boolean2D-BGepppR1.js → boolean2D-yyAQW-Rw.js} +7 -7
  9. package/dist/{booleanFns-COWSvOdh.js → booleanFns-ZBHOH5IJ.js} +3 -3
  10. package/dist/{booleanFns-D-EsiGSc.cjs → booleanFns-hPtsWvKU.cjs} +3 -3
  11. package/dist/brepjs.cjs +149 -26
  12. package/dist/brepjs.js +149 -26
  13. package/dist/core.cjs +1 -1
  14. package/dist/core.js +1 -1
  15. package/dist/{cornerFinder-Dcn6Pszu.js → cornerFinder-Bhpxe2GK.js} +1 -1
  16. package/dist/{cornerFinder-sCGPP3pR.cjs → cornerFinder-D1iNCBMe.cjs} +1 -1
  17. package/dist/{curveFns-BykTeig7.cjs → curveFns-C_MUV5Nj.cjs} +1 -1
  18. package/dist/{curveFns-CDMrLZb5.js → curveFns-D1LG7v0s.js} +1 -1
  19. package/dist/{drawFns-CJ6o-Rn9.cjs → drawFns-CgtSyuBg.cjs} +11 -11
  20. package/dist/{drawFns-CuIz-ZQN.js → drawFns-DWfKZyed.js} +11 -11
  21. package/dist/{extrudeFns-D2FqeRzF.cjs → extrudeFns-C2Pmhe-R.cjs} +1 -1
  22. package/dist/{extrudeFns-CLo8iDP0.js → extrudeFns-GVLc2cLp.js} +1 -1
  23. package/dist/{faceFns-BKPKUXhS.js → faceFns-C-HZ3rFB.js} +1 -1
  24. package/dist/{faceFns-DesFj_h_.cjs → faceFns-KUsSM65w.cjs} +1 -1
  25. package/dist/{helpers-B1hjqUWs.cjs → helpers-C5QjF_x8.cjs} +5 -5
  26. package/dist/{helpers-BB6nGmGK.js → helpers-CPw-TkjO.js} +5 -5
  27. package/dist/{historyFns-dtGToyya.cjs → historyFns-9JUnw1_O.cjs} +4 -4
  28. package/dist/{historyFns-DhQH3It2.js → historyFns-C-HhJKjF.js} +4 -4
  29. package/dist/{importFns-DbCS95Ae.cjs → importFns-CyPkUA_N.cjs} +78 -9
  30. package/dist/{importFns-CxR4aYOY.js → importFns-beNdL_tU.js} +78 -9
  31. package/dist/index.d.ts +1 -1
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/io/threemfExportFns.d.ts +11 -0
  34. package/dist/io/threemfExportFns.d.ts.map +1 -1
  35. package/dist/io/threemfImportFns.d.ts.map +1 -1
  36. package/dist/io.cjs +2 -2
  37. package/dist/io.d.ts +1 -1
  38. package/dist/io.d.ts.map +1 -1
  39. package/dist/io.js +2 -2
  40. package/dist/kernel/brepkit/evolutionOps.d.ts.map +1 -1
  41. package/dist/kernel/brepkit/geometryOps.d.ts.map +1 -1
  42. package/dist/kernel/brepkit/sweepOps.d.ts.map +1 -1
  43. package/dist/kernel/brepkitAdapter.d.ts +1 -1
  44. package/dist/kernel/brepkitAdapter.d.ts.map +1 -1
  45. package/dist/kernel/brepkitWasmTypes.d.ts +88 -85
  46. package/dist/kernel/brepkitWasmTypes.d.ts.map +1 -1
  47. package/dist/{measureFns-55tkotVP.js → measureFns-BVKhgZAe.js} +2 -2
  48. package/dist/{measureFns-ClqawNo9.cjs → measureFns-Gmok6h3t.cjs} +2 -2
  49. package/dist/measurement.cjs +1 -1
  50. package/dist/measurement.js +1 -1
  51. package/dist/{meshFns-Bb5jCTgk.cjs → meshFns-CW1EUdGe.cjs} +2 -2
  52. package/dist/{meshFns-CKftHxBm.js → meshFns-D5CPzlWP.js} +2 -2
  53. package/dist/operations.cjs +2 -2
  54. package/dist/operations.js +2 -2
  55. package/dist/{primitiveFns-CnGoApUZ.cjs → primitiveFns-Bc6T6M50.cjs} +5 -5
  56. package/dist/{primitiveFns-B8CYl7Cv.js → primitiveFns-CpVWHp6V.js} +5 -5
  57. package/dist/query.cjs +2 -2
  58. package/dist/query.js +2 -2
  59. package/dist/{shapeFns-I30BnkwE.cjs → shapeFns-csbO4RSU.cjs} +2 -2
  60. package/dist/{shapeFns-Z6i88yCe.js → shapeFns-glO_2u3k.js} +2 -2
  61. package/dist/{shapeTypes-CIo8EfS5.cjs → shapeTypes-DQiNnWj0.cjs} +5 -5
  62. package/dist/{shapeTypes-BG8KMjzV.js → shapeTypes-DkpaETrw.js} +5 -5
  63. package/dist/sketching.cjs +2 -2
  64. package/dist/sketching.js +2 -2
  65. package/dist/{solidBuilders-BoktzxPl.cjs → solidBuilders-CroCRISt.cjs} +2 -2
  66. package/dist/{solidBuilders-DJQzmxGl.js → solidBuilders-j86aJBNd.js} +2 -2
  67. package/dist/{surfaceBuilders-_HmVsIUu.js → surfaceBuilders-BZWDla4x.js} +2 -2
  68. package/dist/{surfaceBuilders-D7bmpcp0.cjs → surfaceBuilders-DVRuWItl.cjs} +2 -2
  69. package/dist/topology.cjs +6 -6
  70. package/dist/topology.js +6 -6
  71. package/package.json +2 -1
package/dist/2d.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_Blueprint = require("./Blueprint-C5t_ioHD.cjs");
3
- const require_boolean2D = require("./boolean2D-Cdom7nvT.cjs");
4
- const require_blueprintFns = require("./blueprintFns-DlPl1rL5.cjs");
2
+ const require_Blueprint = require("./Blueprint-C2znXaaZ.cjs");
3
+ const require_boolean2D = require("./boolean2D-Bu1v9M_m.cjs");
4
+ const require_blueprintFns = require("./blueprintFns-CxfjtauU.cjs");
5
5
  exports.Blueprint = require_Blueprint.Blueprint;
6
6
  exports.Blueprints = require_boolean2D.Blueprints;
7
7
  exports.BoundingBox2d = require_Blueprint.BoundingBox2d;
package/dist/2d.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as Curve2D, t as Blueprint, y as BoundingBox2d } from "./Blueprint-Cum4_uL5.js";
2
- import { a as fuseBlueprints, c as roundedRectangleBlueprint, g as CompoundBlueprint, h as Blueprints, i as cutBlueprints, m as organiseBlueprints, n as fuse2D, o as intersectBlueprints, r as intersect2D, s as polysidesBlueprint, t as cut2D } from "./boolean2D-BGepppR1.js";
3
- import { S as reverseCurve, _ as curve2dIsOnCurve, a as isInside2D, b as curve2dSplitAt, c as scale2D, d as stretch2D, f as toSVGPathD, g as curve2dFirstPoint, h as curve2dDistanceFrom, i as getOrientation2D, l as sketchOnFace2D, m as curve2dBoundingBox, o as mirror2D, p as translate2D, r as getBounds2D, s as rotate2D, t as createBlueprint, u as sketchOnPlane2D, v as curve2dLastPoint, x as curve2dTangentAt, y as curve2dParameter } from "./blueprintFns-CNXZX0L2.js";
1
+ import { _ as Curve2D, t as Blueprint, y as BoundingBox2d } from "./Blueprint-B_jo065X.js";
2
+ import { a as fuseBlueprints, c as roundedRectangleBlueprint, g as CompoundBlueprint, h as Blueprints, i as cutBlueprints, m as organiseBlueprints, n as fuse2D, o as intersectBlueprints, r as intersect2D, s as polysidesBlueprint, t as cut2D } from "./boolean2D-yyAQW-Rw.js";
3
+ import { S as reverseCurve, _ as curve2dIsOnCurve, a as isInside2D, b as curve2dSplitAt, c as scale2D, d as stretch2D, f as toSVGPathD, g as curve2dFirstPoint, h as curve2dDistanceFrom, i as getOrientation2D, l as sketchOnFace2D, m as curve2dBoundingBox, o as mirror2D, p as translate2D, r as getBounds2D, s as rotate2D, t as createBlueprint, u as sketchOnPlane2D, v as curve2dLastPoint, x as curve2dTangentAt, y as curve2dParameter } from "./blueprintFns-bpyUa_XY.js";
4
4
  export { Blueprint, Blueprints, BoundingBox2d, CompoundBlueprint, Curve2D, createBlueprint, curve2dBoundingBox, curve2dDistanceFrom, curve2dFirstPoint, curve2dIsOnCurve, curve2dLastPoint, curve2dParameter, curve2dSplitAt, curve2dTangentAt, cut2D, cutBlueprints, fuse2D, fuseBlueprints, getBounds2D, getOrientation2D, intersect2D, intersectBlueprints, isInside2D, mirror2D, organiseBlueprints, polysidesBlueprint, reverseCurve, rotate2D, roundedRectangleBlueprint, scale2D, sketchOnFace2D, sketchOnPlane2D, stretch2D, toSVGPathD, translate2D };
@@ -1,12 +1,12 @@
1
- import { G as getKernel2D, L as registerForCleanup, W as getKernel, i as createEdge, l as createWire, z as unregisterFromCleanup } from "./shapeTypes-BG8KMjzV.js";
1
+ import { G as getKernel2D, L as registerForCleanup, W as getKernel, i as createEdge, l as createWire, z as unregisterFromCleanup } from "./shapeTypes-DkpaETrw.js";
2
2
  import { L as unwrap, d as validationError, k as ok, m as bug, n as computationError, y as err } from "./errors-B2qrBS1S.js";
3
3
  import { _ as DEG2RAD, y as RAD2DEG } from "./vecOps-B9-MTeC8.js";
4
4
  import { r as toVec3 } from "./types-Bb4KK_iG.js";
5
5
  import { r as makePlane } from "./planeOps-PYHm_Q9z.js";
6
- import { g as cast, m as uvCoordinates, n as faceCenter, p as uvBounds, r as faceGeomType } from "./faceFns-BKPKUXhS.js";
7
- import { f as getOrientation } from "./curveFns-CDMrLZb5.js";
8
- import { r as makeFace } from "./surfaceBuilders-_HmVsIUu.js";
9
- import { _ as samePoint, b as subtract2d, l as add2d, o as normalize2d, p as distance2d, t as getSingleFace, v as scalarMultiply2d } from "./helpers-BB6nGmGK.js";
6
+ import { g as cast, m as uvCoordinates, n as faceCenter, p as uvBounds, r as faceGeomType } from "./faceFns-C-HZ3rFB.js";
7
+ import { f as getOrientation } from "./curveFns-D1LG7v0s.js";
8
+ import { r as makeFace } from "./surfaceBuilders-BZWDla4x.js";
9
+ import { _ as samePoint, b as subtract2d, l as add2d, o as normalize2d, p as distance2d, t as getSingleFace, v as scalarMultiply2d } from "./helpers-CPw-TkjO.js";
10
10
  //#region src/2d/lib/definitions.ts
11
11
  /** Type guard that checks whether a value is a `Point2D`. */
12
12
  function isPoint2D(point) {
@@ -1,12 +1,12 @@
1
- const require_shapeTypes = require("./shapeTypes-CIo8EfS5.cjs");
1
+ const require_shapeTypes = require("./shapeTypes-DQiNnWj0.cjs");
2
2
  const require_errors = require("./errors-Bkxm3vs2.cjs");
3
3
  const require_vecOps = require("./vecOps-4iBMiet9.cjs");
4
4
  const require_types = require("./types-BD-VVaWB.cjs");
5
5
  const require_planeOps = require("./planeOps-CXJOsSMJ.cjs");
6
- const require_faceFns = require("./faceFns-DesFj_h_.cjs");
7
- const require_curveFns = require("./curveFns-BykTeig7.cjs");
8
- const require_surfaceBuilders = require("./surfaceBuilders-D7bmpcp0.cjs");
9
- const require_helpers = require("./helpers-B1hjqUWs.cjs");
6
+ const require_faceFns = require("./faceFns-KUsSM65w.cjs");
7
+ const require_curveFns = require("./curveFns-C_MUV5Nj.cjs");
8
+ const require_surfaceBuilders = require("./surfaceBuilders-DVRuWItl.cjs");
9
+ const require_helpers = require("./helpers-C5QjF_x8.cjs");
10
10
  //#region src/2d/lib/definitions.ts
11
11
  /** Type guard that checks whether a value is a `Point2D`. */
12
12
  function isPoint2D(point) {
@@ -1,6 +1,6 @@
1
1
  const require_errors = require("./errors-Bkxm3vs2.cjs");
2
- const require_Blueprint = require("./Blueprint-C5t_ioHD.cjs");
3
- const require_boolean2D = require("./boolean2D-Cdom7nvT.cjs");
2
+ const require_Blueprint = require("./Blueprint-C2znXaaZ.cjs");
3
+ const require_boolean2D = require("./boolean2D-Bu1v9M_m.cjs");
4
4
  //#region src/2d/lib/curve2dFns.ts
5
5
  /**
6
6
  * Return a reversed copy of the curve (non-mutating).
@@ -1,6 +1,6 @@
1
1
  import { d as validationError, k as ok, t as BrepErrorCode, y as err } from "./errors-B2qrBS1S.js";
2
- import { t as Blueprint } from "./Blueprint-Cum4_uL5.js";
3
- import { g as CompoundBlueprint } from "./boolean2D-BGepppR1.js";
2
+ import { t as Blueprint } from "./Blueprint-B_jo065X.js";
3
+ import { g as CompoundBlueprint } from "./boolean2D-yyAQW-Rw.js";
4
4
  //#region src/2d/lib/curve2dFns.ts
5
5
  /**
6
6
  * Return a reversed copy of the curve (non-mutating).
@@ -1,14 +1,14 @@
1
- const require_shapeTypes = require("./shapeTypes-CIo8EfS5.cjs");
1
+ const require_shapeTypes = require("./shapeTypes-DQiNnWj0.cjs");
2
2
  const require_errors = require("./errors-Bkxm3vs2.cjs");
3
3
  const require_vecOps = require("./vecOps-4iBMiet9.cjs");
4
4
  const require_types = require("./types-BD-VVaWB.cjs");
5
5
  const require_planeOps = require("./planeOps-CXJOsSMJ.cjs");
6
- const require_faceFns = require("./faceFns-DesFj_h_.cjs");
7
- const require_curveFns = require("./curveFns-BykTeig7.cjs");
8
- const require_surfaceBuilders = require("./surfaceBuilders-D7bmpcp0.cjs");
9
- const require_helpers = require("./helpers-B1hjqUWs.cjs");
10
- const require_Blueprint = require("./Blueprint-C5t_ioHD.cjs");
11
- const require_extrudeFns = require("./extrudeFns-D2FqeRzF.cjs");
6
+ const require_faceFns = require("./faceFns-KUsSM65w.cjs");
7
+ const require_curveFns = require("./curveFns-C_MUV5Nj.cjs");
8
+ const require_surfaceBuilders = require("./surfaceBuilders-DVRuWItl.cjs");
9
+ const require_helpers = require("./helpers-C5QjF_x8.cjs");
10
+ const require_Blueprint = require("./Blueprint-C2znXaaZ.cjs");
11
+ const require_extrudeFns = require("./extrudeFns-C2Pmhe-R.cjs");
12
12
  //#region src/2d/lib/intersections.ts
13
13
  /**
14
14
  * Compute intersection points and common segments between two 2D curves.
@@ -1,14 +1,14 @@
1
- import { G as getKernel2D, M as DisposalScope, U as _usingCtx, W as getKernel, a as createFace, i as createEdge, l as createWire, m as isShape3D, t as castShape } from "./shapeTypes-BG8KMjzV.js";
1
+ import { G as getKernel2D, M as DisposalScope, U as _usingCtx, W as getKernel, a as createFace, i as createEdge, l as createWire, m as isShape3D, t as castShape } from "./shapeTypes-DkpaETrw.js";
2
2
  import { L as unwrap, d as validationError, i as kernelError, k as ok, l as typeCastError, m as bug, n as computationError, s as safeIndex, w as isOk, y as err } from "./errors-B2qrBS1S.js";
3
3
  import { _ as DEG2RAD, d as vecNormalize, h as vecScale, r as vecCross, y as RAD2DEG } from "./vecOps-B9-MTeC8.js";
4
4
  import { r as toVec3 } from "./types-Bb4KK_iG.js";
5
5
  import { n as createPlane } from "./planeOps-PYHm_Q9z.js";
6
- import { _ as downcast, c as normalAt, p as uvBounds, u as pointOnSurface } from "./faceFns-BKPKUXhS.js";
7
- import { c as curveStartPoint, l as curveTangentAt, r as curveIsClosed } from "./curveFns-CDMrLZb5.js";
8
- import { _ as zip, i as makeNewFaceWithinFace, r as makeFace, s as assembleWire } from "./surfaceBuilders-_HmVsIUu.js";
9
- import { _ as samePoint$1, b as subtract2d, d as cartesianToPolar, f as crossProduct2d, g as rotate2d, h as polarToCartesian, l as add2d, m as polarAngle2d, o as normalize2d, p as distance2d, s as PRECISION_INTERSECTION, v as scalarMultiply2d } from "./helpers-BB6nGmGK.js";
10
- import { _ as Curve2D, b as removeDuplicatePoints, c as make2dCircle, f as make2dSegmentCurve, h as approximateAsBSpline, m as make2dThreePointArc, n as asSVG, o as make2dArcFromCenter, p as make2dTangentArc, r as viewbox, s as make2dBezierCurve, t as Blueprint, u as make2dEllipseArc, x as isPoint2D, y as BoundingBox2d } from "./Blueprint-Cum4_uL5.js";
11
- import { c as twistExtrude, n as revolve, r as complexExtrude, s as sweep, t as extrude } from "./extrudeFns-CLo8iDP0.js";
6
+ import { _ as downcast, c as normalAt, p as uvBounds, u as pointOnSurface } from "./faceFns-C-HZ3rFB.js";
7
+ import { c as curveStartPoint, l as curveTangentAt, r as curveIsClosed } from "./curveFns-D1LG7v0s.js";
8
+ import { _ as zip, i as makeNewFaceWithinFace, r as makeFace, s as assembleWire } from "./surfaceBuilders-BZWDla4x.js";
9
+ import { _ as samePoint$1, b as subtract2d, d as cartesianToPolar, f as crossProduct2d, g as rotate2d, h as polarToCartesian, l as add2d, m as polarAngle2d, o as normalize2d, p as distance2d, s as PRECISION_INTERSECTION, v as scalarMultiply2d } from "./helpers-CPw-TkjO.js";
10
+ import { _ as Curve2D, b as removeDuplicatePoints, c as make2dCircle, f as make2dSegmentCurve, h as approximateAsBSpline, m as make2dThreePointArc, n as asSVG, o as make2dArcFromCenter, p as make2dTangentArc, r as viewbox, s as make2dBezierCurve, t as Blueprint, u as make2dEllipseArc, x as isPoint2D, y as BoundingBox2d } from "./Blueprint-B_jo065X.js";
11
+ import { c as twistExtrude, n as revolve, r as complexExtrude, s as sweep, t as extrude } from "./extrudeFns-GVLc2cLp.js";
12
12
  //#region src/2d/lib/intersections.ts
13
13
  /**
14
14
  * Compute intersection points and common segments between two 2D curves.
@@ -1,9 +1,9 @@
1
- import { W as getKernel, m as isShape3D, t as castShape } from "./shapeTypes-BG8KMjzV.js";
1
+ import { W as getKernel, m as isShape3D, t as castShape } from "./shapeTypes-DkpaETrw.js";
2
2
  import { C as isErr, d as validationError, i as kernelError, k as ok, l as typeCastError, t as BrepErrorCode, y as err } from "./errors-B2qrBS1S.js";
3
3
  import { h as vecScale, t as vecAdd, v as HASH_CODE_MAX } from "./vecOps-B9-MTeC8.js";
4
4
  import { o as resolvePlane } from "./planeOps-PYHm_Q9z.js";
5
- import { F as getWires, M as getEdges, P as getVertices, _ as propagateAllMetadata, g as collectInputFaceHashes, v as propagateMetadataByHash } from "./shapeFns-Z6i88yCe.js";
6
- import { r as makeFace } from "./surfaceBuilders-_HmVsIUu.js";
5
+ import { F as getWires, M as getEdges, P as getVertices, _ as propagateAllMetadata, g as collectInputFaceHashes, v as propagateMetadataByHash } from "./shapeFns-glO_2u3k.js";
6
+ import { r as makeFace } from "./surfaceBuilders-BZWDla4x.js";
7
7
  //#region src/topology/booleanFns.ts
8
8
  /**
9
9
  * Boolean and compound operations — functional replacements for _3DShape boolean methods.
@@ -1,9 +1,9 @@
1
- const require_shapeTypes = require("./shapeTypes-CIo8EfS5.cjs");
1
+ const require_shapeTypes = require("./shapeTypes-DQiNnWj0.cjs");
2
2
  const require_errors = require("./errors-Bkxm3vs2.cjs");
3
3
  const require_vecOps = require("./vecOps-4iBMiet9.cjs");
4
4
  const require_planeOps = require("./planeOps-CXJOsSMJ.cjs");
5
- const require_shapeFns = require("./shapeFns-I30BnkwE.cjs");
6
- const require_surfaceBuilders = require("./surfaceBuilders-D7bmpcp0.cjs");
5
+ const require_shapeFns = require("./shapeFns-csbO4RSU.cjs");
6
+ const require_surfaceBuilders = require("./surfaceBuilders-DVRuWItl.cjs");
7
7
  //#region src/topology/booleanFns.ts
8
8
  /**
9
9
  * Boolean and compound operations — functional replacements for _3DShape boolean methods.
package/dist/brepjs.cjs CHANGED
@@ -1,27 +1,27 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_drawFns = require("./drawFns-CJ6o-Rn9.cjs");
3
- const require_shapeTypes = require("./shapeTypes-CIo8EfS5.cjs");
2
+ const require_drawFns = require("./drawFns-CgtSyuBg.cjs");
3
+ const require_shapeTypes = require("./shapeTypes-DQiNnWj0.cjs");
4
4
  const require_errors = require("./errors-Bkxm3vs2.cjs");
5
5
  const require_vecOps = require("./vecOps-4iBMiet9.cjs");
6
6
  const require_types = require("./types-BD-VVaWB.cjs");
7
7
  const require_planeOps = require("./planeOps-CXJOsSMJ.cjs");
8
- const require_faceFns = require("./faceFns-DesFj_h_.cjs");
9
- const require_shapeFns = require("./shapeFns-I30BnkwE.cjs");
10
- const require_curveFns = require("./curveFns-BykTeig7.cjs");
11
- const require_meshFns = require("./meshFns-Bb5jCTgk.cjs");
12
- const require_surfaceBuilders = require("./surfaceBuilders-D7bmpcp0.cjs");
13
- const require_booleanFns = require("./booleanFns-D-EsiGSc.cjs");
14
- const require_primitiveFns = require("./primitiveFns-CnGoApUZ.cjs");
15
- const require_historyFns = require("./historyFns-dtGToyya.cjs");
16
- const require_helpers = require("./helpers-B1hjqUWs.cjs");
17
- const require_Blueprint = require("./Blueprint-C5t_ioHD.cjs");
18
- const require_boolean2D = require("./boolean2D-Cdom7nvT.cjs");
19
- const require_solidBuilders = require("./solidBuilders-BoktzxPl.cjs");
20
- const require_measureFns = require("./measureFns-ClqawNo9.cjs");
21
- const require_cornerFinder = require("./cornerFinder-sCGPP3pR.cjs");
22
- const require_extrudeFns = require("./extrudeFns-D2FqeRzF.cjs");
23
- const require_blueprintFns = require("./blueprintFns-DlPl1rL5.cjs");
24
- const require_importFns = require("./importFns-DbCS95Ae.cjs");
8
+ const require_faceFns = require("./faceFns-KUsSM65w.cjs");
9
+ const require_shapeFns = require("./shapeFns-csbO4RSU.cjs");
10
+ const require_curveFns = require("./curveFns-C_MUV5Nj.cjs");
11
+ const require_meshFns = require("./meshFns-CW1EUdGe.cjs");
12
+ const require_surfaceBuilders = require("./surfaceBuilders-DVRuWItl.cjs");
13
+ const require_booleanFns = require("./booleanFns-hPtsWvKU.cjs");
14
+ const require_primitiveFns = require("./primitiveFns-Bc6T6M50.cjs");
15
+ const require_historyFns = require("./historyFns-9JUnw1_O.cjs");
16
+ const require_helpers = require("./helpers-C5QjF_x8.cjs");
17
+ const require_Blueprint = require("./Blueprint-C2znXaaZ.cjs");
18
+ const require_boolean2D = require("./boolean2D-Bu1v9M_m.cjs");
19
+ const require_solidBuilders = require("./solidBuilders-CroCRISt.cjs");
20
+ const require_measureFns = require("./measureFns-Gmok6h3t.cjs");
21
+ const require_cornerFinder = require("./cornerFinder-D1iNCBMe.cjs");
22
+ const require_extrudeFns = require("./extrudeFns-C2Pmhe-R.cjs");
23
+ const require_blueprintFns = require("./blueprintFns-CxfjtauU.cjs");
24
+ const require_importFns = require("./importFns-CyPkUA_N.cjs");
25
25
  const require_workerHandler = require("./workerHandler-D9sQ2f5u.cjs");
26
26
  //#region src/core/kernelCall.ts
27
27
  var errorFactories = {
@@ -1825,9 +1825,86 @@ function findTags(xml, tagName) {
1825
1825
  }
1826
1826
  return tags;
1827
1827
  }
1828
+ /**
1829
+ * Extract a block `<tagName ...>...</tagName>` from xml.
1830
+ * Returns the full block string including open/close tags, or null if not found.
1831
+ */
1832
+ function findTagBlock(xml, tagName) {
1833
+ const open = xml.indexOf(`<${tagName}`);
1834
+ if (open < 0) return null;
1835
+ const close = xml.indexOf(`</${tagName}>`, open);
1836
+ if (close < 0) return null;
1837
+ return xml.slice(open, close + tagName.length + 3);
1838
+ }
1839
+ /** Parse a hex color string like #RRGGBB or #RRGGBBAA into [r,g,b,a] floats. */
1840
+ function parseHexColor(hex) {
1841
+ const h = hex.startsWith("#") ? hex.slice(1) : hex;
1842
+ return [
1843
+ parseInt(h.slice(0, 2), 16) / 255,
1844
+ parseInt(h.slice(2, 4), 16) / 255,
1845
+ parseInt(h.slice(4, 6), 16) / 255,
1846
+ h.length >= 8 ? parseInt(h.slice(6, 8), 16) / 255 : 1
1847
+ ];
1848
+ }
1849
+ /**
1850
+ * Build a combined resource map from colorgroup and basematerials blocks.
1851
+ * Returns: Map<resourceId, Array<[r,g,b,a]>>
1852
+ */
1853
+ function parseResourceColors(xml) {
1854
+ const resources = /* @__PURE__ */ new Map();
1855
+ let searchPos = 0;
1856
+ while (searchPos < xml.length) {
1857
+ const cgStart = xml.indexOf("<colorgroup", searchPos);
1858
+ if (cgStart < 0) break;
1859
+ const cgClose = xml.indexOf("</colorgroup>", cgStart);
1860
+ if (cgClose < 0) break;
1861
+ const cgBlock = xml.slice(cgStart, cgClose + 13);
1862
+ searchPos = cgClose + 13;
1863
+ const cgTagEnd = xml.indexOf(">", cgStart);
1864
+ if (cgTagEnd < 0) continue;
1865
+ const idStr = parseTagAttrs(xml.slice(cgStart, cgTagEnd + 1))["id"];
1866
+ if (idStr === void 0) continue;
1867
+ const resourceId = parseInt(idStr, 10);
1868
+ const colorArr = [];
1869
+ for (const colorTag of findTags(cgBlock, "color")) {
1870
+ const colorVal = parseTagAttrs(colorTag)["color"];
1871
+ if (colorVal !== void 0) colorArr.push(parseHexColor(colorVal));
1872
+ }
1873
+ resources.set(resourceId, colorArr);
1874
+ }
1875
+ let bmSearchPos = 0;
1876
+ while (bmSearchPos < xml.length) {
1877
+ const bmStart = xml.indexOf("<basematerials", bmSearchPos);
1878
+ if (bmStart < 0) break;
1879
+ const bmClose = xml.indexOf("</basematerials>", bmStart);
1880
+ if (bmClose < 0) break;
1881
+ const bmBlock = xml.slice(bmStart, bmClose + 16);
1882
+ bmSearchPos = bmClose + 16;
1883
+ const bmTagEnd = xml.indexOf(">", bmStart);
1884
+ if (bmTagEnd < 0) continue;
1885
+ const idStr = parseTagAttrs(xml.slice(bmStart, bmTagEnd + 1))["id"];
1886
+ if (idStr === void 0) continue;
1887
+ const resourceId = parseInt(idStr, 10);
1888
+ const colorArr = [];
1889
+ for (const baseTag of findTags(bmBlock, "base")) {
1890
+ const displayColor = parseTagAttrs(baseTag)["displaycolor"];
1891
+ if (displayColor !== void 0) colorArr.push(parseHexColor(displayColor));
1892
+ else colorArr.push([
1893
+ 0,
1894
+ 0,
1895
+ 0,
1896
+ 1
1897
+ ]);
1898
+ }
1899
+ resources.set(resourceId, colorArr);
1900
+ }
1901
+ return resources;
1902
+ }
1828
1903
  function parseModelXml(xml) {
1829
1904
  const vertices = [];
1830
1905
  const triangles = [];
1906
+ const triangleColors = [];
1907
+ const resourceColors = parseResourceColors(xml);
1831
1908
  for (const tag of findTags(xml, "vertex")) {
1832
1909
  const a = parseTagAttrs(tag);
1833
1910
  if (a["x"] !== void 0 && a["y"] !== void 0 && a["z"] !== void 0) vertices.push([
@@ -1836,19 +1913,60 @@ function parseModelXml(xml) {
1836
1913
  parseFloat(a["z"])
1837
1914
  ]);
1838
1915
  }
1916
+ let objectDefaultPid = null;
1917
+ let objectDefaultPindex = null;
1918
+ const objectBlock = findTagBlock(xml, "object");
1919
+ if (objectBlock !== null) {
1920
+ const objTagEnd = objectBlock.indexOf(">");
1921
+ if (objTagEnd >= 0) {
1922
+ const objAttrs = parseTagAttrs(objectBlock.slice(0, objTagEnd + 1));
1923
+ if (objAttrs["pid"] !== void 0) objectDefaultPid = parseInt(objAttrs["pid"], 10);
1924
+ if (objAttrs["pindex"] !== void 0) objectDefaultPindex = parseInt(objAttrs["pindex"], 10);
1925
+ }
1926
+ }
1839
1927
  for (const tag of findTags(xml, "triangle")) {
1840
1928
  const a = parseTagAttrs(tag);
1841
- if (a["v1"] !== void 0 && a["v2"] !== void 0 && a["v3"] !== void 0) triangles.push([
1842
- parseInt(a["v1"], 10),
1843
- parseInt(a["v2"], 10),
1844
- parseInt(a["v3"], 10)
1845
- ]);
1929
+ if (a["v1"] !== void 0 && a["v2"] !== void 0 && a["v3"] !== void 0) {
1930
+ triangles.push([
1931
+ parseInt(a["v1"], 10),
1932
+ parseInt(a["v2"], 10),
1933
+ parseInt(a["v3"], 10)
1934
+ ]);
1935
+ let color = null;
1936
+ const pidStr = a["pid"] ?? (objectDefaultPid !== null ? String(objectDefaultPid) : void 0);
1937
+ const p1Str = a["p1"] ?? (objectDefaultPindex !== null ? String(objectDefaultPindex) : void 0);
1938
+ if (pidStr !== void 0 && p1Str !== void 0) {
1939
+ const pid = parseInt(pidStr, 10);
1940
+ const p1 = parseInt(p1Str, 10);
1941
+ const palette = resourceColors.get(pid);
1942
+ if (palette !== void 0 && p1 < palette.length) color = palette[p1] ?? null;
1943
+ }
1944
+ triangleColors.push(color);
1945
+ }
1846
1946
  }
1847
1947
  return {
1848
1948
  vertices,
1849
- triangles
1949
+ triangles,
1950
+ triangleColors
1850
1951
  };
1851
1952
  }
1953
+ /** Find the most common non-null color across all triangle colors. */
1954
+ function findDominantColor(triangleColors) {
1955
+ const counts = /* @__PURE__ */ new Map();
1956
+ for (const c of triangleColors) {
1957
+ if (c === null) continue;
1958
+ const key = c.join(",");
1959
+ const entry = counts.get(key);
1960
+ if (entry !== void 0) entry.count++;
1961
+ else counts.set(key, {
1962
+ count: 1,
1963
+ color: c
1964
+ });
1965
+ }
1966
+ let best = null;
1967
+ for (const entry of counts.values()) if (best === null || entry.count > best.count) best = entry;
1968
+ return best !== null ? best.color : null;
1969
+ }
1852
1970
  function buildSolidFromMesh(mesh) {
1853
1971
  const kernel = require_shapeTypes.getKernel();
1854
1972
  const points = mesh.vertices.map(([x, y, z]) => ({
@@ -1897,7 +2015,12 @@ async function importThreeMF(blob) {
1897
2015
  if (!modelData) return require_errors.err(require_errors.ioError(require_errors.BrepErrorCode.THREEMF_IMPORT_FAILED, "3MF archive does not contain 3D/3dmodel.model (or uses unsupported compression)"));
1898
2016
  const parsed = parseModelXml(new TextDecoder().decode(modelData));
1899
2017
  if (parsed.vertices.length === 0 || parsed.triangles.length === 0) return require_errors.err(require_errors.ioError(require_errors.BrepErrorCode.THREEMF_IMPORT_FAILED, "3MF model contains no valid geometry"));
1900
- return buildSolidFromMesh(parsed);
2018
+ const solid = buildSolidFromMesh(parsed);
2019
+ if (solid.ok) {
2020
+ const dominantColor = findDominantColor(parsed.triangleColors);
2021
+ if (dominantColor !== null) require_shapeFns.colorShape(solid.value, dominantColor);
2022
+ }
2023
+ return solid;
1901
2024
  } catch (e) {
1902
2025
  const msg = e instanceof Error ? e.message : String(e);
1903
2026
  return require_errors.err(require_errors.ioError(require_errors.BrepErrorCode.THREEMF_IMPORT_FAILED, `3MF import failed: ${msg}`, e));
package/dist/brepjs.js CHANGED
@@ -1,26 +1,26 @@
1
- import { A as is2D, B as withScope, C as isValidSolid, D as getShapeKind, E as validSolid, F as getDisposalStats, H as withScopeResultAsync, I as isLive, J as withKernel, K as initFromOC, M as DisposalScope, N as createHandle, O as as2D, P as createKernelHandle, R as resetDisposalStats, S as isOrientedFace, T as orientedFace, U as _usingCtx, V as withScopeResult, W as getKernel, X as supportsConstraintSketch, Y as BrepkitAdapter, Z as supportsProjection, _ as isVertex, a as createFace, b as isClosedWire, c as createVertex, d as isEdge, f as isFace, g as isSolid, h as isShell, i as createEdge, j as is3D, k as as3D, l as createWire, m as isShape3D, n as castShape3D, o as createShell, p as isShape1D, q as registerKernel, r as createCompound, s as createSolid, t as castShape, u as isCompound, v as isWire, w as manifoldShell, x as isManifoldShell, y as closedWire } from "./shapeTypes-BG8KMjzV.js";
1
+ import { A as is2D, B as withScope, C as isValidSolid, D as getShapeKind, E as validSolid, F as getDisposalStats, H as withScopeResultAsync, I as isLive, J as withKernel, K as initFromOC, M as DisposalScope, N as createHandle, O as as2D, P as createKernelHandle, R as resetDisposalStats, S as isOrientedFace, T as orientedFace, U as _usingCtx, V as withScopeResult, W as getKernel, X as supportsConstraintSketch, Y as BrepkitAdapter, Z as supportsProjection, _ as isVertex, a as createFace, b as isClosedWire, c as createVertex, d as isEdge, f as isFace, g as isSolid, h as isShell, i as createEdge, j as is3D, k as as3D, l as createWire, m as isShape3D, n as castShape3D, o as createShell, p as isShape1D, q as registerKernel, r as createCompound, s as createSolid, t as castShape, u as isCompound, v as isWire, w as manifoldShell, x as isManifoldShell, y as closedWire } from "./shapeTypes-DkpaETrw.js";
2
2
  import { A as or, B as unwrapOrElse, C as isErr, D as mapErr, E as mapBoth, F as tryCatch, I as tryCatchAsync, L as unwrap, M as pipeline, N as tap, O as match, P as tapErr, R as unwrapErr, S as fromNullable, T as map, V as zip, _ as andThen, a as moduleInitError, b as flatMap, c as sketcherStateError, d as validationError, f as translateKernelError, g as all, h as OK, i as kernelError, j as orElse, k as ok, l as typeCastError, m as bug, n as computationError, o as queryError, p as BrepBugError, r as ioError, t as BrepErrorCode, u as unsupportedError, v as collect, w as isOk, x as flatten, y as err, z as unwrapOr } from "./errors-B2qrBS1S.js";
3
3
  import { _ as DEG2RAD, a as vecDot, c as vecLength, d as vecNormalize, f as vecProjectToPlane, g as vecSub, h as vecScale, i as vecDistance, l as vecLengthSq, m as vecRotate, n as vecAngle, o as vecEquals, p as vecRepr, r as vecCross, s as vecIsZero, t as vecAdd, u as vecNegate, v as HASH_CODE_MAX, y as RAD2DEG } from "./vecOps-B9-MTeC8.js";
4
4
  import { n as toVec2, r as toVec3, t as resolveDirection } from "./types-Bb4KK_iG.js";
5
5
  import { i as pivotPlane, n as createPlane, o as resolvePlane, r as makePlane, s as translatePlane, t as createNamedPlane } from "./planeOps-PYHm_Q9z.js";
6
- import { _ as downcast, a as flipFaceOrientation, b as iterTopo, c as normalAt, d as projectPointOnFace, f as removeHolesFromFace, g as cast, h as asTopo, i as faceOrientation, l as outerWire, m as uvCoordinates, n as faceCenter, o as getSurfaceType, p as uvBounds, r as faceGeomType, s as innerWires, t as classifyPointOnFace, u as pointOnSurface, v as fromBREP, x as shapeType, y as isCompSolid } from "./faceFns-BKPKUXhS.js";
7
- import { A as describe$1, B as iterWires, C as findFacesByTag, D as tagFaces, E as setTagMetadata, F as getWires, I as invalidateShapeCache, L as iterEdges, M as getEdges, N as getFaces, O as getFaceOrigins, P as getVertices, R as iterFaces, S as getShapeColor, T as getTagMetadata, V as vertexPosition, _ as propagateAllMetadata, a as isSameShape, b as colorShape, c as applyMatrix$1, d as resize, f as rotate$1, g as collectInputFaceHashes, h as translate$1, i as isEqualShape, j as getBounds, k as setShapeOrigin, l as composeTransforms, m as transformCopy$1, n as getHashCode, o as simplify$1, p as scale$1, r as isEmpty$2, s as toBREP$1, t as clone$1, u as mirror$1, w as getFaceTags, x as getFaceColor, y as colorFaces, z as iterVertices } from "./shapeFns-Z6i88yCe.js";
8
- import { a as curveLength, c as curveStartPoint, d as getCurveType, f as getOrientation, i as curveIsPeriodic, l as curveTangentAt, m as offsetWire2D, n as curveEndPoint, o as curvePeriod, p as interpolateCurve, r as curveIsClosed, s as curvePointAt, t as approximateCurve, u as flipOrientation } from "./curveFns-CDMrLZb5.js";
9
- import { a as meshEdges$1, i as mesh$1, n as exportSTEP, o as clearMeshCache, r as exportSTL, s as createMeshCache, t as exportIGES } from "./meshFns-CKftHxBm.js";
10
- import { n as fill, r as makeFace } from "./surfaceBuilders-_HmVsIUu.js";
11
- import { a as intersect$1, c as slice$1, i as fuseAll, l as split$1, n as cutAll, o as section$1, r as fuse$1, s as sectionToFace$1, t as cut$1 } from "./booleanFns-COWSvOdh.js";
12
- import { A as healFace, B as chamferDistAngle, C as threePointArc, D as wireLoop, E as wire, F as edgesOfFace, H as toGroupedBufferGeometryData, I as facesOfEdge, L as sharedEdges, M as healWire, N as isValid$1, O as autoHeal, P as adjacentFaces, R as verticesOfEdge, S as tangentArc, T as vertex, U as toLineGeometryData, V as toBufferGeometryData, _ as polygon, a as circle, b as sphere, c as cylinder, d as ellipsoid, f as face, g as offsetFace, h as line, i as bsplineApprox, j as healSolid, k as heal$1, l as ellipse, m as helix, n as bezier, o as compound, p as filledFace, r as box, s as cone, t as addHoles, u as ellipseArc, v as sewShells, w as torus, x as subFace, y as solid, z as wiresOfFace } from "./primitiveFns-B8CYl7Cv.js";
13
- import { C as walkAssembly, D as exportAssemblySTEP, E as linearPattern, O as createAssembly, S as updateNode, _ as collectShapes, a as findStep, b as findNode, c as registerOperation, d as replayHistory, f as serializeHistory, g as addChild, h as undoLast, i as deserializeHistory, l as registerShape, m as stepsFrom, n as createHistory, o as getShape, p as stepCount, r as createRegistry, s as modifyStep, t as addStep, u as replayFrom, v as countNodes, w as circularPattern, x as removeChild, y as createAssemblyNode } from "./historyFns-DhQH3It2.js";
14
- import { a as createTypedFinder, i as wireFinder, n as edgeFinder, r as faceFinder, t as getSingleFace } from "./helpers-BB6nGmGK.js";
15
- import { _ as Curve2D, t as Blueprint, y as BoundingBox2d } from "./Blueprint-Cum4_uL5.js";
16
- import { a as fuseBlueprints, c as roundedRectangleBlueprint, d as FaceSketcher, f as Sketch, g as CompoundBlueprint, h as Blueprints, i as cutBlueprints, l as BaseSketcher2d, m as organiseBlueprints, n as fuse2D, o as intersectBlueprints, p as loft$1, r as intersect2D, s as polysidesBlueprint, t as cut2D, u as BlueprintSketcher } from "./boolean2D-BGepppR1.js";
17
- import { $ as sketchFaceOffset, A as DrawingPen, B as drawSingleCircle, C as cameraFromPlane, D as makeProjectedEdges, E as projectEdges, F as drawParametricFunction, G as loadFont, H as drawText, I as drawPointsInterpolation, J as textMetrics, K as sketchText, L as drawPolysides, M as draw, N as drawCircle, O as isProjectionPlane, P as drawEllipse, Q as sketchEllipse, R as drawRectangle, S as drawProjection, T as createCamera, U as fontMetrics, V as drawSingleEllipse, W as getFont, X as polysideInnerRadius, Y as makeBaseBox, Z as sketchCircle, _ as sketchLoft, a as drawingIntersect, at as Sketches, b as sketchWires, c as rotateDrawing, d as compoundSketchExtrude, et as sketchHelix, f as compoundSketchFace, g as sketchFace, h as sketchExtrude, i as drawingFuse, it as sketchRoundedRectangle, j as deserializeDrawing, k as Drawing, l as scaleDrawing, m as compoundSketchRevolve, n as drawingCut, nt as sketchPolysides, o as drawingToSketchOnPlane, ot as CompoundSketch, p as compoundSketchLoft, q as textBlueprints, r as drawingFillet, rt as sketchRectangle, s as mirrorDrawing, st as Sketcher, t as drawingChamfer, tt as sketchParametricFunction, u as translateDrawing, v as sketchRevolve, w as cameraLookAt, x as drawFaceOutline, y as sketchSweep, z as drawRoundedRectangle } from "./drawFns-CuIz-ZQN.js";
18
- import { r as makeCylinder } from "./solidBuilders-DJQzmxGl.js";
19
- import { a as measureDistance, c as measureLinearProps, d as measureVolumeProps, i as measureCurvatureAtMid, l as measureSurfaceProps, n as measureArea, o as measureDistanceProps, r as measureCurvatureAt, s as measureLength, t as createDistanceQuery, u as measureVolume } from "./measureFns-55tkotVP.js";
20
- import { t as cornerFinder } from "./cornerFinder-Dcn6Pszu.js";
21
- import { a as multiSectionSweep, c as twistExtrude, i as guidedSweep, n as revolve$1, o as supportExtrude, r as complexExtrude, s as sweep, t as extrude$1 } from "./extrudeFns-CLo8iDP0.js";
22
- import { S as reverseCurve, _ as curve2dIsOnCurve, a as isInside2D, b as curve2dSplitAt, c as scale2D, d as stretch2D, f as toSVGPathD, g as curve2dFirstPoint, h as curve2dDistanceFrom, i as getOrientation2D, l as sketchOnFace2D, m as curve2dBoundingBox, n as createCompoundBlueprint, o as mirror2D, p as translate2D, r as getBounds2D, s as rotate2D, t as createBlueprint, u as sketchOnPlane2D, v as curve2dLastPoint, x as curve2dTangentAt, y as curve2dParameter } from "./blueprintFns-CNXZX0L2.js";
23
- import { a as importSVGPathD, c as exportDXF, d as exportOBJ, i as importSVG, l as exportGlb, n as importSTEP, o as exportThreeMF, r as importSTL, s as blueprintToDXF, t as importIGES, u as exportGltf } from "./importFns-CxR4aYOY.js";
6
+ import { _ as downcast, a as flipFaceOrientation, b as iterTopo, c as normalAt, d as projectPointOnFace, f as removeHolesFromFace, g as cast, h as asTopo, i as faceOrientation, l as outerWire, m as uvCoordinates, n as faceCenter, o as getSurfaceType, p as uvBounds, r as faceGeomType, s as innerWires, t as classifyPointOnFace, u as pointOnSurface, v as fromBREP, x as shapeType, y as isCompSolid } from "./faceFns-C-HZ3rFB.js";
7
+ import { A as describe$1, B as iterWires, C as findFacesByTag, D as tagFaces, E as setTagMetadata, F as getWires, I as invalidateShapeCache, L as iterEdges, M as getEdges, N as getFaces, O as getFaceOrigins, P as getVertices, R as iterFaces, S as getShapeColor, T as getTagMetadata, V as vertexPosition, _ as propagateAllMetadata, a as isSameShape, b as colorShape, c as applyMatrix$1, d as resize, f as rotate$1, g as collectInputFaceHashes, h as translate$1, i as isEqualShape, j as getBounds, k as setShapeOrigin, l as composeTransforms, m as transformCopy$1, n as getHashCode, o as simplify$1, p as scale$1, r as isEmpty$2, s as toBREP$1, t as clone$1, u as mirror$1, w as getFaceTags, x as getFaceColor, y as colorFaces, z as iterVertices } from "./shapeFns-glO_2u3k.js";
8
+ import { a as curveLength, c as curveStartPoint, d as getCurveType, f as getOrientation, i as curveIsPeriodic, l as curveTangentAt, m as offsetWire2D, n as curveEndPoint, o as curvePeriod, p as interpolateCurve, r as curveIsClosed, s as curvePointAt, t as approximateCurve, u as flipOrientation } from "./curveFns-D1LG7v0s.js";
9
+ import { a as meshEdges$1, i as mesh$1, n as exportSTEP, o as clearMeshCache, r as exportSTL, s as createMeshCache, t as exportIGES } from "./meshFns-D5CPzlWP.js";
10
+ import { n as fill, r as makeFace } from "./surfaceBuilders-BZWDla4x.js";
11
+ import { a as intersect$1, c as slice$1, i as fuseAll, l as split$1, n as cutAll, o as section$1, r as fuse$1, s as sectionToFace$1, t as cut$1 } from "./booleanFns-ZBHOH5IJ.js";
12
+ import { A as healFace, B as chamferDistAngle, C as threePointArc, D as wireLoop, E as wire, F as edgesOfFace, H as toGroupedBufferGeometryData, I as facesOfEdge, L as sharedEdges, M as healWire, N as isValid$1, O as autoHeal, P as adjacentFaces, R as verticesOfEdge, S as tangentArc, T as vertex, U as toLineGeometryData, V as toBufferGeometryData, _ as polygon, a as circle, b as sphere, c as cylinder, d as ellipsoid, f as face, g as offsetFace, h as line, i as bsplineApprox, j as healSolid, k as heal$1, l as ellipse, m as helix, n as bezier, o as compound, p as filledFace, r as box, s as cone, t as addHoles, u as ellipseArc, v as sewShells, w as torus, x as subFace, y as solid, z as wiresOfFace } from "./primitiveFns-CpVWHp6V.js";
13
+ import { C as walkAssembly, D as exportAssemblySTEP, E as linearPattern, O as createAssembly, S as updateNode, _ as collectShapes, a as findStep, b as findNode, c as registerOperation, d as replayHistory, f as serializeHistory, g as addChild, h as undoLast, i as deserializeHistory, l as registerShape, m as stepsFrom, n as createHistory, o as getShape, p as stepCount, r as createRegistry, s as modifyStep, t as addStep, u as replayFrom, v as countNodes, w as circularPattern, x as removeChild, y as createAssemblyNode } from "./historyFns-C-HhJKjF.js";
14
+ import { a as createTypedFinder, i as wireFinder, n as edgeFinder, r as faceFinder, t as getSingleFace } from "./helpers-CPw-TkjO.js";
15
+ import { _ as Curve2D, t as Blueprint, y as BoundingBox2d } from "./Blueprint-B_jo065X.js";
16
+ import { a as fuseBlueprints, c as roundedRectangleBlueprint, d as FaceSketcher, f as Sketch, g as CompoundBlueprint, h as Blueprints, i as cutBlueprints, l as BaseSketcher2d, m as organiseBlueprints, n as fuse2D, o as intersectBlueprints, p as loft$1, r as intersect2D, s as polysidesBlueprint, t as cut2D, u as BlueprintSketcher } from "./boolean2D-yyAQW-Rw.js";
17
+ import { $ as sketchFaceOffset, A as DrawingPen, B as drawSingleCircle, C as cameraFromPlane, D as makeProjectedEdges, E as projectEdges, F as drawParametricFunction, G as loadFont, H as drawText, I as drawPointsInterpolation, J as textMetrics, K as sketchText, L as drawPolysides, M as draw, N as drawCircle, O as isProjectionPlane, P as drawEllipse, Q as sketchEllipse, R as drawRectangle, S as drawProjection, T as createCamera, U as fontMetrics, V as drawSingleEllipse, W as getFont, X as polysideInnerRadius, Y as makeBaseBox, Z as sketchCircle, _ as sketchLoft, a as drawingIntersect, at as Sketches, b as sketchWires, c as rotateDrawing, d as compoundSketchExtrude, et as sketchHelix, f as compoundSketchFace, g as sketchFace, h as sketchExtrude, i as drawingFuse, it as sketchRoundedRectangle, j as deserializeDrawing, k as Drawing, l as scaleDrawing, m as compoundSketchRevolve, n as drawingCut, nt as sketchPolysides, o as drawingToSketchOnPlane, ot as CompoundSketch, p as compoundSketchLoft, q as textBlueprints, r as drawingFillet, rt as sketchRectangle, s as mirrorDrawing, st as Sketcher, t as drawingChamfer, tt as sketchParametricFunction, u as translateDrawing, v as sketchRevolve, w as cameraLookAt, x as drawFaceOutline, y as sketchSweep, z as drawRoundedRectangle } from "./drawFns-DWfKZyed.js";
18
+ import { r as makeCylinder } from "./solidBuilders-j86aJBNd.js";
19
+ import { a as measureDistance, c as measureLinearProps, d as measureVolumeProps, i as measureCurvatureAtMid, l as measureSurfaceProps, n as measureArea, o as measureDistanceProps, r as measureCurvatureAt, s as measureLength, t as createDistanceQuery, u as measureVolume } from "./measureFns-BVKhgZAe.js";
20
+ import { t as cornerFinder } from "./cornerFinder-Bhpxe2GK.js";
21
+ import { a as multiSectionSweep, c as twistExtrude, i as guidedSweep, n as revolve$1, o as supportExtrude, r as complexExtrude, s as sweep, t as extrude$1 } from "./extrudeFns-GVLc2cLp.js";
22
+ import { S as reverseCurve, _ as curve2dIsOnCurve, a as isInside2D, b as curve2dSplitAt, c as scale2D, d as stretch2D, f as toSVGPathD, g as curve2dFirstPoint, h as curve2dDistanceFrom, i as getOrientation2D, l as sketchOnFace2D, m as curve2dBoundingBox, n as createCompoundBlueprint, o as mirror2D, p as translate2D, r as getBounds2D, s as rotate2D, t as createBlueprint, u as sketchOnPlane2D, v as curve2dLastPoint, x as curve2dTangentAt, y as curve2dParameter } from "./blueprintFns-bpyUa_XY.js";
23
+ import { a as importSVGPathD, c as exportDXF, d as exportOBJ, i as importSVG, l as exportGlb, n as importSTEP, o as exportThreeMF, r as importSTL, s as blueprintToDXF, t as importIGES, u as exportGltf } from "./importFns-beNdL_tU.js";
24
24
  import { a as createTaskQueue, c as isEmpty$1, d as isDisposeRequest, f as isErrorResponse, h as isSuccessResponse, i as createWorkerClient, l as pendingCount, m as isOperationRequest, n as createWorkerHandler, o as dequeueTask, p as isInitRequest, r as registerHandler, s as enqueueTask, t as createOperationRegistry, u as rejectAll } from "./workerHandler-Cv_6jKDO.js";
25
25
  //#region src/core/kernelCall.ts
26
26
  var errorFactories = {
@@ -1824,9 +1824,86 @@ function findTags(xml, tagName) {
1824
1824
  }
1825
1825
  return tags;
1826
1826
  }
1827
+ /**
1828
+ * Extract a block `<tagName ...>...</tagName>` from xml.
1829
+ * Returns the full block string including open/close tags, or null if not found.
1830
+ */
1831
+ function findTagBlock(xml, tagName) {
1832
+ const open = xml.indexOf(`<${tagName}`);
1833
+ if (open < 0) return null;
1834
+ const close = xml.indexOf(`</${tagName}>`, open);
1835
+ if (close < 0) return null;
1836
+ return xml.slice(open, close + tagName.length + 3);
1837
+ }
1838
+ /** Parse a hex color string like #RRGGBB or #RRGGBBAA into [r,g,b,a] floats. */
1839
+ function parseHexColor(hex) {
1840
+ const h = hex.startsWith("#") ? hex.slice(1) : hex;
1841
+ return [
1842
+ parseInt(h.slice(0, 2), 16) / 255,
1843
+ parseInt(h.slice(2, 4), 16) / 255,
1844
+ parseInt(h.slice(4, 6), 16) / 255,
1845
+ h.length >= 8 ? parseInt(h.slice(6, 8), 16) / 255 : 1
1846
+ ];
1847
+ }
1848
+ /**
1849
+ * Build a combined resource map from colorgroup and basematerials blocks.
1850
+ * Returns: Map<resourceId, Array<[r,g,b,a]>>
1851
+ */
1852
+ function parseResourceColors(xml) {
1853
+ const resources = /* @__PURE__ */ new Map();
1854
+ let searchPos = 0;
1855
+ while (searchPos < xml.length) {
1856
+ const cgStart = xml.indexOf("<colorgroup", searchPos);
1857
+ if (cgStart < 0) break;
1858
+ const cgClose = xml.indexOf("</colorgroup>", cgStart);
1859
+ if (cgClose < 0) break;
1860
+ const cgBlock = xml.slice(cgStart, cgClose + 13);
1861
+ searchPos = cgClose + 13;
1862
+ const cgTagEnd = xml.indexOf(">", cgStart);
1863
+ if (cgTagEnd < 0) continue;
1864
+ const idStr = parseTagAttrs(xml.slice(cgStart, cgTagEnd + 1))["id"];
1865
+ if (idStr === void 0) continue;
1866
+ const resourceId = parseInt(idStr, 10);
1867
+ const colorArr = [];
1868
+ for (const colorTag of findTags(cgBlock, "color")) {
1869
+ const colorVal = parseTagAttrs(colorTag)["color"];
1870
+ if (colorVal !== void 0) colorArr.push(parseHexColor(colorVal));
1871
+ }
1872
+ resources.set(resourceId, colorArr);
1873
+ }
1874
+ let bmSearchPos = 0;
1875
+ while (bmSearchPos < xml.length) {
1876
+ const bmStart = xml.indexOf("<basematerials", bmSearchPos);
1877
+ if (bmStart < 0) break;
1878
+ const bmClose = xml.indexOf("</basematerials>", bmStart);
1879
+ if (bmClose < 0) break;
1880
+ const bmBlock = xml.slice(bmStart, bmClose + 16);
1881
+ bmSearchPos = bmClose + 16;
1882
+ const bmTagEnd = xml.indexOf(">", bmStart);
1883
+ if (bmTagEnd < 0) continue;
1884
+ const idStr = parseTagAttrs(xml.slice(bmStart, bmTagEnd + 1))["id"];
1885
+ if (idStr === void 0) continue;
1886
+ const resourceId = parseInt(idStr, 10);
1887
+ const colorArr = [];
1888
+ for (const baseTag of findTags(bmBlock, "base")) {
1889
+ const displayColor = parseTagAttrs(baseTag)["displaycolor"];
1890
+ if (displayColor !== void 0) colorArr.push(parseHexColor(displayColor));
1891
+ else colorArr.push([
1892
+ 0,
1893
+ 0,
1894
+ 0,
1895
+ 1
1896
+ ]);
1897
+ }
1898
+ resources.set(resourceId, colorArr);
1899
+ }
1900
+ return resources;
1901
+ }
1827
1902
  function parseModelXml(xml) {
1828
1903
  const vertices = [];
1829
1904
  const triangles = [];
1905
+ const triangleColors = [];
1906
+ const resourceColors = parseResourceColors(xml);
1830
1907
  for (const tag of findTags(xml, "vertex")) {
1831
1908
  const a = parseTagAttrs(tag);
1832
1909
  if (a["x"] !== void 0 && a["y"] !== void 0 && a["z"] !== void 0) vertices.push([
@@ -1835,19 +1912,60 @@ function parseModelXml(xml) {
1835
1912
  parseFloat(a["z"])
1836
1913
  ]);
1837
1914
  }
1915
+ let objectDefaultPid = null;
1916
+ let objectDefaultPindex = null;
1917
+ const objectBlock = findTagBlock(xml, "object");
1918
+ if (objectBlock !== null) {
1919
+ const objTagEnd = objectBlock.indexOf(">");
1920
+ if (objTagEnd >= 0) {
1921
+ const objAttrs = parseTagAttrs(objectBlock.slice(0, objTagEnd + 1));
1922
+ if (objAttrs["pid"] !== void 0) objectDefaultPid = parseInt(objAttrs["pid"], 10);
1923
+ if (objAttrs["pindex"] !== void 0) objectDefaultPindex = parseInt(objAttrs["pindex"], 10);
1924
+ }
1925
+ }
1838
1926
  for (const tag of findTags(xml, "triangle")) {
1839
1927
  const a = parseTagAttrs(tag);
1840
- if (a["v1"] !== void 0 && a["v2"] !== void 0 && a["v3"] !== void 0) triangles.push([
1841
- parseInt(a["v1"], 10),
1842
- parseInt(a["v2"], 10),
1843
- parseInt(a["v3"], 10)
1844
- ]);
1928
+ if (a["v1"] !== void 0 && a["v2"] !== void 0 && a["v3"] !== void 0) {
1929
+ triangles.push([
1930
+ parseInt(a["v1"], 10),
1931
+ parseInt(a["v2"], 10),
1932
+ parseInt(a["v3"], 10)
1933
+ ]);
1934
+ let color = null;
1935
+ const pidStr = a["pid"] ?? (objectDefaultPid !== null ? String(objectDefaultPid) : void 0);
1936
+ const p1Str = a["p1"] ?? (objectDefaultPindex !== null ? String(objectDefaultPindex) : void 0);
1937
+ if (pidStr !== void 0 && p1Str !== void 0) {
1938
+ const pid = parseInt(pidStr, 10);
1939
+ const p1 = parseInt(p1Str, 10);
1940
+ const palette = resourceColors.get(pid);
1941
+ if (palette !== void 0 && p1 < palette.length) color = palette[p1] ?? null;
1942
+ }
1943
+ triangleColors.push(color);
1944
+ }
1845
1945
  }
1846
1946
  return {
1847
1947
  vertices,
1848
- triangles
1948
+ triangles,
1949
+ triangleColors
1849
1950
  };
1850
1951
  }
1952
+ /** Find the most common non-null color across all triangle colors. */
1953
+ function findDominantColor(triangleColors) {
1954
+ const counts = /* @__PURE__ */ new Map();
1955
+ for (const c of triangleColors) {
1956
+ if (c === null) continue;
1957
+ const key = c.join(",");
1958
+ const entry = counts.get(key);
1959
+ if (entry !== void 0) entry.count++;
1960
+ else counts.set(key, {
1961
+ count: 1,
1962
+ color: c
1963
+ });
1964
+ }
1965
+ let best = null;
1966
+ for (const entry of counts.values()) if (best === null || entry.count > best.count) best = entry;
1967
+ return best !== null ? best.color : null;
1968
+ }
1851
1969
  function buildSolidFromMesh(mesh) {
1852
1970
  const kernel = getKernel();
1853
1971
  const points = mesh.vertices.map(([x, y, z]) => ({
@@ -1896,7 +2014,12 @@ async function importThreeMF(blob) {
1896
2014
  if (!modelData) return err(ioError(BrepErrorCode.THREEMF_IMPORT_FAILED, "3MF archive does not contain 3D/3dmodel.model (or uses unsupported compression)"));
1897
2015
  const parsed = parseModelXml(new TextDecoder().decode(modelData));
1898
2016
  if (parsed.vertices.length === 0 || parsed.triangles.length === 0) return err(ioError(BrepErrorCode.THREEMF_IMPORT_FAILED, "3MF model contains no valid geometry"));
1899
- return buildSolidFromMesh(parsed);
2017
+ const solid = buildSolidFromMesh(parsed);
2018
+ if (solid.ok) {
2019
+ const dominantColor = findDominantColor(parsed.triangleColors);
2020
+ if (dominantColor !== null) colorShape(solid.value, dominantColor);
2021
+ }
2022
+ return solid;
1900
2023
  } catch (e) {
1901
2024
  const msg = e instanceof Error ? e.message : String(e);
1902
2025
  return err(ioError(BrepErrorCode.THREEMF_IMPORT_FAILED, `3MF import failed: ${msg}`, e));
package/dist/core.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_shapeTypes = require("./shapeTypes-CIo8EfS5.cjs");
2
+ const require_shapeTypes = require("./shapeTypes-DQiNnWj0.cjs");
3
3
  const require_errors = require("./errors-Bkxm3vs2.cjs");
4
4
  const require_vecOps = require("./vecOps-4iBMiet9.cjs");
5
5
  const require_types = require("./types-BD-VVaWB.cjs");
package/dist/core.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as is2D, B as withScope, C as isValidSolid, D as getShapeKind, E as validSolid, H as withScopeResultAsync, I as isLive, M as DisposalScope, N as createHandle, P as createKernelHandle, S as isOrientedFace, T as orientedFace, V as withScopeResult, _ as isVertex, b as isClosedWire, d as isEdge, f as isFace, g as isSolid, h as isShell, j as is3D, m as isShape3D, p as isShape1D, t as castShape, u as isCompound, v as isWire, w as manifoldShell, x as isManifoldShell, y as closedWire } from "./shapeTypes-BG8KMjzV.js";
1
+ import { A as is2D, B as withScope, C as isValidSolid, D as getShapeKind, E as validSolid, H as withScopeResultAsync, I as isLive, M as DisposalScope, N as createHandle, P as createKernelHandle, S as isOrientedFace, T as orientedFace, V as withScopeResult, _ as isVertex, b as isClosedWire, d as isEdge, f as isFace, g as isSolid, h as isShell, j as is3D, m as isShape3D, p as isShape1D, t as castShape, u as isCompound, v as isWire, w as manifoldShell, x as isManifoldShell, y as closedWire } from "./shapeTypes-DkpaETrw.js";
2
2
  import { B as unwrapOrElse, C as isErr, D as mapErr, F as tryCatch, I as tryCatchAsync, L as unwrap, O as match, R as unwrapErr, T as map, _ as andThen, a as moduleInitError, b as flatMap, c as sketcherStateError, d as validationError, h as OK, i as kernelError, k as ok, l as typeCastError, m as bug, n as computationError, o as queryError, p as BrepBugError, r as ioError, u as unsupportedError, v as collect, w as isOk, y as err, z as unwrapOr } from "./errors-B2qrBS1S.js";
3
3
  import { _ as DEG2RAD, a as vecDot, c as vecLength, d as vecNormalize, f as vecProjectToPlane, g as vecSub, h as vecScale, i as vecDistance, l as vecLengthSq, m as vecRotate, n as vecAngle, o as vecEquals, p as vecRepr, r as vecCross, s as vecIsZero, t as vecAdd, u as vecNegate, v as HASH_CODE_MAX, y as RAD2DEG } from "./vecOps-B9-MTeC8.js";
4
4
  import { n as toVec2, r as toVec3, t as resolveDirection } from "./types-Bb4KK_iG.js";