brepjs 18.103.0 → 18.105.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.
package/dist/brepjs.cjs CHANGED
@@ -12,11 +12,11 @@ const require_planeOps = require("./planeOps-BA4HfgQu.cjs");
12
12
  const require_faceFns = require("./faceFns-DKg2St8b.cjs");
13
13
  const require_shapeFns = require("./shapeFns-L4a8kH_A.cjs");
14
14
  const require_curveFns = require("./curveFns-Dx7_wMut.cjs");
15
- const require_meshFns = require("./meshFns-DeKdpmu7.cjs");
15
+ const require_meshFns = require("./meshFns-DNDsv2vH.cjs");
16
16
  const require_arrayAccess = require("./arrayAccess-e4H9cBfh.cjs");
17
17
  const require_surfaceBuilders = require("./surfaceBuilders-FLnYYA70.cjs");
18
18
  const require_solidBuilders = require("./solidBuilders-CgRmJEdn.cjs");
19
- const require_healingFns = require("./healingFns-CM5mVMow.cjs");
19
+ const require_healingFns = require("./healingFns-OL0bBSSY.cjs");
20
20
  const require_threadFns = require("./threadFns-DGYdomjN.cjs");
21
21
  const require_blueprintSketcher = require("./blueprintSketcher-DCttG3KS.cjs");
22
22
  const require_helpers = require("./helpers-8zxf2gkc.cjs");
@@ -30,7 +30,7 @@ const require_loftFns = require("./loftFns-DaRDYpfB.cjs");
30
30
  const require_cameraFns = require("./cameraFns-S7YbAxfg.cjs");
31
31
  const require_textMetrics = require("./textMetrics-W-H6jUDj.cjs");
32
32
  const require_shapeRefFns = require("./shapeRefFns-Dij41NuC.cjs");
33
- const require_workerHandler = require("./workerHandler-CdlOTwJg.cjs");
33
+ const require_workerPool = require("./workerPool-edtPrfHM.cjs");
34
34
  const require_primitiveFns = require("./primitiveFns-BAWtMd9H.cjs");
35
35
  //#region src/topology/shapeBooleans.ts
36
36
  var BOPAlgo_GlueShift = 1;
@@ -6802,17 +6802,18 @@ exports.createHistory = require_threadFns.createHistory;
6802
6802
  exports.createKernelHandle = require_shapeTypes.createKernelHandle;
6803
6803
  exports.createMeshCache = require_meshFns.createMeshCache;
6804
6804
  exports.createNamedPlane = require_planeOps.createNamedPlane;
6805
- exports.createOperationRegistry = require_workerHandler.createOperationRegistry;
6805
+ exports.createOperationRegistry = require_workerPool.createOperationRegistry;
6806
6806
  exports.createPlane = require_planeOps.createPlane;
6807
6807
  exports.createRef = require_shapeRefFns.createRef;
6808
6808
  exports.createRegistry = require_threadFns.createRegistry;
6809
6809
  exports.createShell = require_shapeTypes.createShell;
6810
6810
  exports.createSolid = require_shapeTypes.createSolid;
6811
- exports.createTaskQueue = require_workerHandler.createTaskQueue;
6811
+ exports.createTaskQueue = require_workerPool.createTaskQueue;
6812
6812
  exports.createVertex = require_shapeTypes.createVertex;
6813
6813
  exports.createWire = require_shapeTypes.createWire;
6814
- exports.createWorkerClient = require_workerHandler.createWorkerClient;
6815
- exports.createWorkerHandler = require_workerHandler.createWorkerHandler;
6814
+ exports.createWorkerClient = require_workerPool.createWorkerClient;
6815
+ exports.createWorkerHandler = require_workerPool.createWorkerHandler;
6816
+ exports.createWorkerPool = require_workerPool.createWorkerPool;
6816
6817
  Object.defineProperty(exports, "csg", {
6817
6818
  enumerable: true,
6818
6819
  get: function() {
@@ -6846,7 +6847,7 @@ exports.cutWithEvolution = require_healingFns.cutWithEvolution;
6846
6847
  exports.cylinder = require_primitiveFns.cylinder;
6847
6848
  exports.cylindricalJoint = require_threadFns.cylindricalJoint;
6848
6849
  exports.defaultScorer = require_shapeRefFns.defaultScorer;
6849
- exports.dequeueTask = require_workerHandler.dequeueTask;
6850
+ exports.dequeueTask = require_workerPool.dequeueTask;
6850
6851
  exports.describe = describe;
6851
6852
  exports.deserializeDrawing = require_drawFns.deserializeDrawing;
6852
6853
  exports.deserializeHistory = require_threadFns.deserializeHistory;
@@ -6878,7 +6879,7 @@ exports.edgesOfFace = require_healingFns.edgesOfFace;
6878
6879
  exports.ellipse = require_primitiveFns.ellipse;
6879
6880
  exports.ellipseArc = require_primitiveFns.ellipseArc;
6880
6881
  exports.ellipsoid = require_primitiveFns.ellipsoid;
6881
- exports.enqueueTask = require_workerHandler.enqueueTask;
6882
+ exports.enqueueTask = require_workerPool.enqueueTask;
6882
6883
  exports.err = require_errors.err;
6883
6884
  exports.exportAssemblySTEP = require_threadFns.exportAssemblySTEP;
6884
6885
  exports.exportDXF = require_importFns.exportDXF;
@@ -7011,33 +7012,33 @@ exports.isChamferRadius = isChamferRadius;
7011
7012
  exports.isClosedWire = require_shapeTypes.isClosedWire;
7012
7013
  exports.isCompSolid = require_faceFns.isCompSolid;
7013
7014
  exports.isCompound = require_shapeTypes.isCompound;
7014
- exports.isDisposeRequest = require_workerHandler.isDisposeRequest;
7015
+ exports.isDisposeRequest = require_workerPool.isDisposeRequest;
7015
7016
  exports.isEdge = require_shapeTypes.isEdge;
7016
7017
  exports.isEmpty = isEmpty;
7017
7018
  exports.isEqualShape = require_shapeFns.isEqualShape;
7018
7019
  exports.isErr = require_errors.isErr;
7019
- exports.isErrorResponse = require_workerHandler.isErrorResponse;
7020
+ exports.isErrorResponse = require_workerPool.isErrorResponse;
7020
7021
  exports.isFace = require_shapeTypes.isFace;
7021
7022
  exports.isFilletRadius = isFilletRadius;
7022
- exports.isInitRequest = require_workerHandler.isInitRequest;
7023
+ exports.isInitRequest = require_workerPool.isInitRequest;
7023
7024
  exports.isInside2D = require_blueprintFns.isInside2D;
7024
7025
  exports.isInstanced = isInstanced;
7025
7026
  exports.isLive = require_shapeTypes.isLive;
7026
7027
  exports.isManifoldShell = require_shapeTypes.isManifoldShell;
7027
7028
  exports.isNumber = isNumber;
7028
7029
  exports.isOk = require_errors.isOk;
7029
- exports.isOperationRequest = require_workerHandler.isOperationRequest;
7030
+ exports.isOperationRequest = require_workerPool.isOperationRequest;
7030
7031
  exports.isOrientedFace = require_shapeTypes.isOrientedFace;
7031
7032
  exports.isPlanarFace = require_shapeTypes.isPlanarFace;
7032
7033
  exports.isPlanarWire = require_shapeTypes.isPlanarWire;
7033
7034
  exports.isProjectionPlane = require_cameraFns.isProjectionPlane;
7034
- exports.isQueueEmpty = require_workerHandler.isEmpty;
7035
+ exports.isQueueEmpty = require_workerPool.isEmpty;
7035
7036
  exports.isSameShape = require_shapeFns.isSameShape;
7036
7037
  exports.isShape1D = require_shapeTypes.isShape1D;
7037
7038
  exports.isShape3D = require_shapeTypes.isShape3D;
7038
7039
  exports.isShell = require_shapeTypes.isShell;
7039
7040
  exports.isSolid = require_shapeTypes.isSolid;
7040
- exports.isSuccessResponse = require_workerHandler.isSuccessResponse;
7041
+ exports.isSuccessResponse = require_workerPool.isSuccessResponse;
7041
7042
  exports.isValid = isValid;
7042
7043
  exports.isValidSolid = require_shapeTypes.isValidSolid;
7043
7044
  exports.isVertex = require_shapeTypes.isVertex;
@@ -7095,6 +7096,7 @@ Object.defineProperty(exports, "measurement", {
7095
7096
  exports.mechanismDOF = require_threadFns.mechanismDOF;
7096
7097
  exports.mesh = mesh;
7097
7098
  exports.meshEdges = meshEdges;
7099
+ exports.meshLODs = require_meshFns.meshLODs;
7098
7100
  exports.meshMultiLOD = require_meshFns.meshMultiLOD;
7099
7101
  exports.minkowski = minkowski;
7100
7102
  exports.mirror = mirror;
@@ -7128,7 +7130,7 @@ Object.defineProperty(exports, "patterns", {
7128
7130
  return patterns_exports;
7129
7131
  }
7130
7132
  });
7131
- exports.pendingCount = require_workerHandler.pendingCount;
7133
+ exports.pendingCount = require_workerPool.pendingCount;
7132
7134
  exports.pipeline = require_errors.pipeline;
7133
7135
  exports.pivotPlane = require_planeOps.pivotPlane;
7134
7136
  exports.planarFace = require_shapeTypes.planarFace;
@@ -7161,13 +7163,13 @@ Object.defineProperty(exports, "query", {
7161
7163
  });
7162
7164
  exports.queryError = require_errors.queryError;
7163
7165
  exports.rectangularPattern = rectangularPattern;
7164
- exports.registerHandler = require_workerHandler.registerHandler;
7166
+ exports.registerHandler = require_workerPool.registerHandler;
7165
7167
  exports.registerKernel = require_shapeTypes.registerKernel;
7166
7168
  exports.registerKernelTier = require_shapeTypes.registerKernelTier;
7167
7169
  exports.registerOperation = require_threadFns.registerOperation;
7168
7170
  exports.registerShape = require_threadFns.registerShape;
7169
7171
  exports.registerVoxel = registerVoxel;
7170
- exports.rejectAll = require_workerHandler.rejectAll;
7172
+ exports.rejectAll = require_workerPool.rejectAll;
7171
7173
  exports.removeChild = require_threadFns.removeChild;
7172
7174
  exports.removeHolesFromFace = require_faceFns.removeHolesFromFace;
7173
7175
  exports.repairMesh = repairMesh;
@@ -7274,6 +7276,7 @@ exports.toBufferGeometryData = require_healingFns.toBufferGeometryData;
7274
7276
  exports.toGroupedBufferGeometryData = require_healingFns.toGroupedBufferGeometryData;
7275
7277
  exports.toKernelVec = toKernelVec;
7276
7278
  exports.toLODGeometryData = require_healingFns.toLODGeometryData;
7279
+ exports.toLODGeometryLevels = require_healingFns.toLODGeometryLevels;
7277
7280
  exports.toLineGeometryData = require_healingFns.toLineGeometryData;
7278
7281
  exports.toSVGPathD = require_blueprintFns.toSVGPathD;
7279
7282
  exports.toVec2 = require_types.toVec2;
package/dist/brepjs.js CHANGED
@@ -10,11 +10,11 @@ import { i as pivotPlane, n as createPlane, o as resolvePlane, r as makePlane, s
10
10
  import { S as shapeType, _ as cast, a as faceOrientation, b as isCompSolid, c as innerWires, d as pointOnSurface, f as projectPointOnFace, g as asTopo, h as uvCoordinates, i as faceGeomType, l as normalAt, m as uvBounds, n as faceAxis, o as flipFaceOrientation, p as removeHolesFromFace, r as faceCenter, s as getSurfaceType, t as classifyPointOnFace, u as outerWire, v as downcast, x as iterTopo, y as fromBREP } from "./faceFns-mo4ThIHz.js";
11
11
  import { C as findFacesByTag, D as tagFaces, E as setTagMetadata, O as getFaceOrigins, S as getShapeColor, T as getTagMetadata, a as isSameShape, b as colorShape, c as applyMatrix$1, d as resize, f as rotate$2, h as translate$2, i as isEqualShape, k as setShapeOrigin, l as composeTransforms, m as transformCopy$1, n as getHashCode, o as simplify$1, p as scale$3, r as isEmpty$2, s as toBREP$1, t as clone$1, u as mirror$2, w as getFaceTags, x as getFaceColor, y as colorFaces } from "./shapeFns-DyBbhU30.js";
12
12
  import { a as curveIsPeriodic, c as curvePointAt, d as flipOrientation, f as getCurveType, h as offsetWire2D, i as curveIsClosed, l as curveStartPoint, m as interpolateCurve, n as curveAxis, o as curveLength, p as getOrientation, r as curveEndPoint, s as curvePeriod, t as approximateCurve, u as curveTangentAt } from "./curveFns-CG05Jygr.js";
13
- import { a as meshEdges$1, c as createMeshCache, i as mesh$1, n as exportSTEP, o as meshMultiLOD, r as exportSTL, s as clearMeshCache, t as exportIGES } from "./meshFns-CAAarhVm.js";
13
+ import { a as meshEdges$1, c as clearMeshCache, i as mesh$1, l as createMeshCache, n as exportSTEP, o as meshLODs, r as exportSTL, s as meshMultiLOD, t as exportIGES } from "./meshFns-DoVH8EPW.js";
14
14
  import { n as getAtOrThrow, r as lastOrThrow, t as firstOrThrow } from "./arrayAccess-DrUGPADn.js";
15
15
  import { _ as makeThreePointArc, d as makeCircle, h as makeLine, l as makeBSplineInterpolation, n as fill, r as makeFace, s as assembleWire } from "./surfaceBuilders-Bww4jhBo.js";
16
16
  import { _ as section$1, b as split$1, d as booleanPipeline, f as cut$2, g as intersect$2, h as fuseAll$2, m as fuse$2, p as cutAll$2, r as makeCylinder, t as makeCompound, v as sectionToFace$1, y as slice$1 } from "./solidBuilders-Biwv2cW3.js";
17
- import { A as edgesOfFace, C as shellWithEvolution, D as getNurbsCurveData, E as fuseAllBisect, F as chamferDistAngle, I as toBufferGeometryData, L as toGroupedBufferGeometryData, M as sharedEdges, N as verticesOfEdge, O as getNurbsSurfaceData, P as wiresOfFace, R as toLODGeometryData, S as intersectWithEvolution, T as cutAllBisect, _ as positionOnCurve, a as healFace, b as filletWithEvolution, c as isValid$1, d as draft$1, f as fillet$1, g as variableFillet, h as thicken$1, i as heal$1, j as facesOfEdge, k as adjacentFaces, l as solidFromShell, m as shell$1, n as fixSelfIntersection, o as healSolid, p as offset$1, r as fixShape, s as healWire, t as autoHeal, u as chamfer$1, v as chamferWithEvolution, w as checkBoolean, x as fuseWithEvolution, y as cutWithEvolution, z as toLineGeometryData } from "./healingFns-Bb3eEBNm.js";
17
+ import { A as edgesOfFace, B as toLineGeometryData, C as shellWithEvolution, D as getNurbsCurveData, E as fuseAllBisect, F as chamferDistAngle, I as toBufferGeometryData, L as toGroupedBufferGeometryData, M as sharedEdges, N as verticesOfEdge, O as getNurbsSurfaceData, P as wiresOfFace, R as toLODGeometryData, S as intersectWithEvolution, T as cutAllBisect, _ as positionOnCurve, a as healFace, b as filletWithEvolution, c as isValid$1, d as draft$1, f as fillet$1, g as variableFillet, h as thicken$1, i as heal$1, j as facesOfEdge, k as adjacentFaces, l as solidFromShell, m as shell$1, n as fixSelfIntersection, o as healSolid, p as offset$1, r as fixShape, s as healWire, t as autoHeal, u as chamfer$1, v as chamferWithEvolution, w as checkBoolean, x as fuseWithEvolution, y as cutWithEvolution, z as toLODGeometryLevels } from "./healingFns-C5AomW4j.js";
18
18
  import { A as setJointValue, B as findNode, C as cylindricalJoint, D as planarJoint, E as mechanismDOF, F as quatRotate, G as gridPattern, H as updateNode, I as addChild, J as createAssembly, K as linearPattern, L as collectShapes, M as sphericalJoint, N as quatFromAxisAngle, O as prismaticJoint, P as quatFromTo, R as countNodes, S as addJoint, T as jointTransform, U as walkAssembly, V as removeChild, W as circularPattern, _ as exportURDF, a as deserializeHistory, b as inverseKinematics, c as modifyStep, d as replayFrom, f as replayHistory, g as undoLast, h as stepsFrom, i as createRegistry, j as setJointValues, k as revoluteJoint, l as registerOperation, m as stepCount, n as addStep, o as findStep, p as serializeHistory, q as exportAssemblySTEP, r as createHistory, s as getShape, t as thread, u as registerShape, v as importURDF, w as forwardKinematics, x as jointTrajectory, y as jointsFromDH, z as createAssemblyNode } from "./threadFns-8rKpQXiR.js";
19
19
  import { n as BaseSketcher2d, r as organiseBlueprints, t as BlueprintSketcher } from "./blueprintSketcher-CEQ8s7TD.js";
20
20
  import { a as createTypedFinder, i as wireFinder, n as edgeFinder, r as faceFinder, t as getSingleFace } from "./helpers-DT44wBAD.js";
@@ -29,7 +29,7 @@ import { a as Sketch, c as compoundSketchLoft, d as sketchFace, f as sketchLoft,
29
29
  import { a as makeProjectedEdges, i as projectEdges, n as cameraLookAt, r as createCamera, s as isProjectionPlane, t as cameraFromPlane } from "./cameraFns-Bu6jgTKc.js";
30
30
  import { n as textMetrics, r as sketchText, t as fontMetrics } from "./textMetrics-CBbDQ5QW.js";
31
31
  import { a as updateRoles, i as resolveRef, n as captureHint, o as defaultScorer, r as createRef, t as assignRoles } from "./shapeRefFns-Cn4WNb3q.js";
32
- 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-CFetYgIm.js";
32
+ import { a as createWorkerClient, c as enqueueTask, d as rejectAll, f as isDisposeRequest, g as isSuccessResponse, h as isOperationRequest, i as registerHandler, l as isEmpty$1, m as isInitRequest, n as createOperationRegistry, o as createTaskQueue, p as isErrorResponse, r as createWorkerHandler, s as dequeueTask, t as createWorkerPool, u as pendingCount } from "./workerPool-BxBKpKeI.js";
33
33
  import { C as threePointArc, D as wireLoop, E as wire, S as tangentArc, T as vertex, _ as polygon, a as circle, b as sphere$1, c as cylinder, d as ellipsoid, f as face, g as offsetFace, h as line, i as bsplineApprox, 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$1, x as subFace, y as solid } from "./primitiveFns-62SO4ti5.js";
34
34
  //#region \0rolldown/runtime.js
35
35
  var __defProp = Object.defineProperty;
@@ -6702,4 +6702,4 @@ var csg_exports = /* @__PURE__ */ __exportAll({
6702
6702
  withEvaluator: () => withEvaluator
6703
6703
  });
6704
6704
  //#endregion
6705
- export { BaseSketcher2d, BlueprintSketcher, BrepBugError, BrepErrorCode, BrepWrapperError, BrepkitAdapter, CompoundSketch, DEFAULT_CAPABILITIES, DEG2RAD, DisposalScope, EXACT_BREP_CAPABILITIES, FaceSketcher, HASH_CODE_MAX, OK, OcctWasmAdapter, RAD2DEG, Sketch, Sketcher, Sketches, addChild, addHoles, addJoint, addMate, addStep, adjacentFaces, all, andThen, applyGlue, applyMatrix, approximateCurve, as2D, as3D, asTopo, assignRoles, autoHeal, bezier, blueprintToDXF, booleanPipeline, booleans_exports as booleans, boss, box, bsplineApprox, bug, cameraFromPlane, cameraLookAt, captureHint, cast, castShape, castShape3D, chamfer, chamferDistAngle as chamferDistAngleShape, chamferWithEvolution, checkAllInterferences, checkBoolean, checkInterference, circle, circularPattern, classifyPointOnFace, clearMeshCache, clone, closedWire, collect, collectShapes, colorFaces, colorShape, complexExtrude, composeTransforms, compound, compoundSketchExtrude, compoundSketchFace, compoundSketchLoft, compoundSketchRevolve, computationError, computeStraightSkeleton, cone, construction_exports as construction, convexHull, cornerFinder, countNodes, createAssembly, createAssemblyNode, createBlueprint, createCamera, createCompound, createCompoundBlueprint, createDistanceQuery, createEdge, createFace, createHandle, createHistory, createKernelHandle, createMeshCache, createNamedPlane, createOperationRegistry, createPlane, createRef, createRegistry, createShell, createSolid, createTaskQueue, createVertex, createWire, createWorkerClient, createWorkerHandler, csg_exports as csg, currentQuality, curve2dBoundingBox, curve2dDistanceFrom, curve2dFirstPoint, curve2dIsOnCurve, curve2dLastPoint, curve2dParameter, curve2dSplitAt, curve2dTangentAt, curveAxis, curveEndPoint, curveIsClosed, curveIsPeriodic, curveLength, curvePeriod, curvePointAt, curveStartPoint, curveTangentAt, cut, cut2D, cutAll, cutAllBisect, cutBlueprints, cutWithEvolution, cylinder, cylindricalJoint, defaultScorer, dequeueTask, describe, deserializeDrawing, deserializeHistory, fromBREP as deserializeShape, downcast, draft, draw, drawCircle, drawEllipse, drawFaceOutline, drawParametricFunction, drawPointsInterpolation, drawPolysides, drawProjection, drawRectangle, drawRoundedRectangle, drawSingleCircle, drawSingleEllipse, drawText, drawingChamfer, drawingCut, drawingFillet, drawingFuse, drawingIntersect, drawingToSketchOnPlane, drill, edgeFinder, edgesOfFace, ellipse, ellipseArc, ellipsoid, enqueueTask, err, exportAssemblySTEP, exportDXF, exportGlb, exportGltf, exportIGES, exportOBJ, exportSTEP, exportSTEPConfigured, exportSTL, exportThreeMF, exportURDF, extrude, extrudeAll, face, faceAxis, faceCenter, faceFinder, faceGeomType, faceOrientation, facesOfEdge, fieldBoolean, fieldContour, fieldOffset, fieldReinit, fieldShell, fill, filledFace, fillet, filletWithEvolution, findFacesByTag, findNode, findStep, fixSelfIntersection, fixShape, flatMap, flatten, flipFaceOrientation, flipOrientation, fontMetrics, forwardKinematics, fromBREP$1 as fromBREP, fromKernelDir, fromKernelPnt, fromKernelVec, fromNullable, fuse, fuse2D, fuseAll, fuseAllBisect, fuseBlueprints, fuseWithEvolution, gearGeometry, getActiveVoxelId, getBounds, getBounds2D, getCompSolids, getCurveType, getDisposalStats, getEdges, getFaceColor, getFaceOrigins, getFaceTags, getFaces, getFont, getHashCode, getShape as getHistoryShape, getKernel, getKernelCapabilities, getKernelTier, getNurbsCurveData, getNurbsSurfaceData, getOrientation, getOrientation2D, getPerformanceStats, getShapeColor, getShapeKind, getShells, getSingleFace, getSolids, getSurfaceType, getTagMetadata, getVertices, getVoxel, getWires, gridPattern, guidedSweep, heal, healFace, healSolid, healWire, helix, hull, importDXF, importGLB, importIGES, importOBJ, importSTEP, importSTL, importSVG, importSVGPathD, importThreeMF, importURDF, init, initFromManifold, initFromOC, initVoxel, innerWires, instance, instanceCount, instanceGrid, instancedMesh, interpolateCurve, intersect, intersect2D, intersectBlueprints, intersectWithEvolution, invalidateShapeCache, inverseKinematics, ioNs_exports as io, ioError, is2D, is3D, isChamferRadius, isClosedWire, isCompSolid, isCompound, isDisposeRequest, isEdge, isEmpty, isEqualShape, isErr, isErrorResponse, isFace, isFilletRadius, isInitRequest, isInside2D, isInstanced, isLive, isManifoldShell, isNumber, isOk, isOperationRequest, isOrientedFace, isPlanarFace, isPlanarWire, isProjectionPlane, isEmpty$1 as isQueueEmpty, isSameShape, isShape1D, isShape3D, isShell, isSolid, isSuccessResponse, isValid, isValidSolid, isVertex, isWire, iterCompSolids, iterEdges, iterFaces, iterShells, iterSolids, iterTopo, iterVertices, iterWires, jointTrajectory, jointTransform, jointsFromDH, kernelCall, kernelCallRaw, kernelCallScoped, kernelError, latticeInfill, latticeInfillShape, line, linearPattern, loadFont, loft, loftAll, makeBaseBox, makeExternalGear, makeInternalGear, makePlane, makePlanetaryGear, makeProjectedEdges, manifoldShell, map, mapBoth, mapErr, match, materialize, measureArea, measureCurvatureAt, measureCurvatureAtMid, measureDistance, measureDistanceProps, measureLength, measureLinearProps, measureSurfaceProps, measureVolume, measureVolumeProps, measurement_exports as measurement, mechanismDOF, mesh, meshEdges, meshMultiLOD, minkowski, mirror, mirror2D, mirrorDrawing, mirrorJoin, modifiers_exports as modifiers, modifyStep, moduleInitError, multiSectionSweep, normalAt, offset, offsetFace, offsetMesh, offsetShape, offsetWire2D, ok, or, orElse, organiseBlueprints, orientedFace, outerWire, patterns_exports as patterns, pendingCount, pipeline, pivotPlane, planarFace, planarJoint, planarWire, planetPlacements, pocket, pointOnSurface, pointsInside, polygon, polyhedron, polysideInnerRadius, polysidesBlueprint, positionOnCurve, prewarm, primitives_exports as primitives, prismaticJoint, projectEdges, projectPointOnFace, query_exports as query, queryError, rectangularPattern, registerHandler, registerKernel, registerKernelTier, registerOperation, registerShape, registerVoxel, rejectAll, removeChild, removeHolesFromFace, repairMesh, replayFrom, replayHistory, resetDisposalStats, resetPerformanceStats, resize, resolve, resolve3D, resolveDirection, resolvePlane, resolveRef, reverseCurve, revoluteJoint, revolve, roof, rotate, rotate2D, rotateDrawing, roundedRectangleBlueprint, scale, scale2D, scaleDrawing, box$1 as sdfBox, capsule as sdfCapsule, cone$1 as sdfCone, cylinder$1 as sdfCylinder, fieldAxialRamp as sdfFieldAxialRamp, fieldClamp as sdfFieldClamp, fieldConst as sdfFieldConst, fieldFromSdf as sdfFieldFromSdf, fieldRadialRamp as sdfFieldRadialRamp, lattice as sdfLattice, plane as sdfPlane, roundedBox as sdfRoundedBox, sphere as sdfSphere, strutLattice as sdfStrutLattice, sweep as sdfSweep, torus as sdfTorus, section, sectionToFace, serializeHistory, setJointValue, setJointValues, setShapeOrigin, setTagMetadata, sewShells, shape, shapeToMeshInput, shapeType, sharedEdges, shell, shellMesh, shellShape, shellWithEvolution, simplify, sketchCircle, sketchEllipse, sketchExtrude, sketchFace, sketchFaceOffset, sketchHelix, sketchLoft, sketchOnFace2D, sketchOnPlane2D, sketchParametricFunction, sketchPolysides, sketchRectangle, sketchRevolve, sketchRoundedRectangle, sketchSweep, sketchText, sketchWires, sketcherStateError, slice, solid, solidFromShell, solveAssembly, sphere$1 as sphere, sphericalJoint, split, stepCount, stepsFrom, stretch2D, subFace, supportExtrude, supportsConstraintSketch, supportsProjection, surfaceFromGrid, surfaceFromImage, sweep$1 as sweep, tagFaces, tangentArc, tap, tapErr, textBlueprints, textMetrics, thicken, thread, threePointArc, toBREP, toBufferGeometryData, toGroupedBufferGeometryData, toKernelVec, toLODGeometryData, toLineGeometryData, toSVGPathD, toVec2, toVec3, torus$1 as torus, tpmsLattice, transformCopy, transforms_exports as transforms, translate, translate2D, translateDrawing, translatePlane, tryCatch, tryCatchAsync, twistExtrude, typeCastError, undoLast, unsupportedError, unwrap, unwrapErr, unwrapOr, unwrapOrElse, updateNode, updateRoles, uvBounds, uvCoordinates, validSolid, validatePlanetary, validationError, variableFillet, vecAdd, vecAngle, vecCross, vecDistance, vecDot, vecEquals, vecIsZero, vecLength, vecLengthSq, vecNegate, vecNormalize, vecProjectToPlane, vecRepr, vecRotate, vecScale, vecSub, vertex, vertexFinder, vertexPosition, verticesOfEdge, voxelBoolean, voxelBooleanField, voxelBooleanFieldShapes, voxelBooleanShapes, voxelField, voxelFieldFromShape, walkAssembly, windingNumbers, wire, wireFinder, wireLoop, wiresOfFace, withKernel, withKernelDir, withKernelPnt, withKernelVec, withQuality, withScope, withScopeResult, withScopeResultAsync, withTier, zip as zipResults };
6705
+ export { BaseSketcher2d, BlueprintSketcher, BrepBugError, BrepErrorCode, BrepWrapperError, BrepkitAdapter, CompoundSketch, DEFAULT_CAPABILITIES, DEG2RAD, DisposalScope, EXACT_BREP_CAPABILITIES, FaceSketcher, HASH_CODE_MAX, OK, OcctWasmAdapter, RAD2DEG, Sketch, Sketcher, Sketches, addChild, addHoles, addJoint, addMate, addStep, adjacentFaces, all, andThen, applyGlue, applyMatrix, approximateCurve, as2D, as3D, asTopo, assignRoles, autoHeal, bezier, blueprintToDXF, booleanPipeline, booleans_exports as booleans, boss, box, bsplineApprox, bug, cameraFromPlane, cameraLookAt, captureHint, cast, castShape, castShape3D, chamfer, chamferDistAngle as chamferDistAngleShape, chamferWithEvolution, checkAllInterferences, checkBoolean, checkInterference, circle, circularPattern, classifyPointOnFace, clearMeshCache, clone, closedWire, collect, collectShapes, colorFaces, colorShape, complexExtrude, composeTransforms, compound, compoundSketchExtrude, compoundSketchFace, compoundSketchLoft, compoundSketchRevolve, computationError, computeStraightSkeleton, cone, construction_exports as construction, convexHull, cornerFinder, countNodes, createAssembly, createAssemblyNode, createBlueprint, createCamera, createCompound, createCompoundBlueprint, createDistanceQuery, createEdge, createFace, createHandle, createHistory, createKernelHandle, createMeshCache, createNamedPlane, createOperationRegistry, createPlane, createRef, createRegistry, createShell, createSolid, createTaskQueue, createVertex, createWire, createWorkerClient, createWorkerHandler, createWorkerPool, csg_exports as csg, currentQuality, curve2dBoundingBox, curve2dDistanceFrom, curve2dFirstPoint, curve2dIsOnCurve, curve2dLastPoint, curve2dParameter, curve2dSplitAt, curve2dTangentAt, curveAxis, curveEndPoint, curveIsClosed, curveIsPeriodic, curveLength, curvePeriod, curvePointAt, curveStartPoint, curveTangentAt, cut, cut2D, cutAll, cutAllBisect, cutBlueprints, cutWithEvolution, cylinder, cylindricalJoint, defaultScorer, dequeueTask, describe, deserializeDrawing, deserializeHistory, fromBREP as deserializeShape, downcast, draft, draw, drawCircle, drawEllipse, drawFaceOutline, drawParametricFunction, drawPointsInterpolation, drawPolysides, drawProjection, drawRectangle, drawRoundedRectangle, drawSingleCircle, drawSingleEllipse, drawText, drawingChamfer, drawingCut, drawingFillet, drawingFuse, drawingIntersect, drawingToSketchOnPlane, drill, edgeFinder, edgesOfFace, ellipse, ellipseArc, ellipsoid, enqueueTask, err, exportAssemblySTEP, exportDXF, exportGlb, exportGltf, exportIGES, exportOBJ, exportSTEP, exportSTEPConfigured, exportSTL, exportThreeMF, exportURDF, extrude, extrudeAll, face, faceAxis, faceCenter, faceFinder, faceGeomType, faceOrientation, facesOfEdge, fieldBoolean, fieldContour, fieldOffset, fieldReinit, fieldShell, fill, filledFace, fillet, filletWithEvolution, findFacesByTag, findNode, findStep, fixSelfIntersection, fixShape, flatMap, flatten, flipFaceOrientation, flipOrientation, fontMetrics, forwardKinematics, fromBREP$1 as fromBREP, fromKernelDir, fromKernelPnt, fromKernelVec, fromNullable, fuse, fuse2D, fuseAll, fuseAllBisect, fuseBlueprints, fuseWithEvolution, gearGeometry, getActiveVoxelId, getBounds, getBounds2D, getCompSolids, getCurveType, getDisposalStats, getEdges, getFaceColor, getFaceOrigins, getFaceTags, getFaces, getFont, getHashCode, getShape as getHistoryShape, getKernel, getKernelCapabilities, getKernelTier, getNurbsCurveData, getNurbsSurfaceData, getOrientation, getOrientation2D, getPerformanceStats, getShapeColor, getShapeKind, getShells, getSingleFace, getSolids, getSurfaceType, getTagMetadata, getVertices, getVoxel, getWires, gridPattern, guidedSweep, heal, healFace, healSolid, healWire, helix, hull, importDXF, importGLB, importIGES, importOBJ, importSTEP, importSTL, importSVG, importSVGPathD, importThreeMF, importURDF, init, initFromManifold, initFromOC, initVoxel, innerWires, instance, instanceCount, instanceGrid, instancedMesh, interpolateCurve, intersect, intersect2D, intersectBlueprints, intersectWithEvolution, invalidateShapeCache, inverseKinematics, ioNs_exports as io, ioError, is2D, is3D, isChamferRadius, isClosedWire, isCompSolid, isCompound, isDisposeRequest, isEdge, isEmpty, isEqualShape, isErr, isErrorResponse, isFace, isFilletRadius, isInitRequest, isInside2D, isInstanced, isLive, isManifoldShell, isNumber, isOk, isOperationRequest, isOrientedFace, isPlanarFace, isPlanarWire, isProjectionPlane, isEmpty$1 as isQueueEmpty, isSameShape, isShape1D, isShape3D, isShell, isSolid, isSuccessResponse, isValid, isValidSolid, isVertex, isWire, iterCompSolids, iterEdges, iterFaces, iterShells, iterSolids, iterTopo, iterVertices, iterWires, jointTrajectory, jointTransform, jointsFromDH, kernelCall, kernelCallRaw, kernelCallScoped, kernelError, latticeInfill, latticeInfillShape, line, linearPattern, loadFont, loft, loftAll, makeBaseBox, makeExternalGear, makeInternalGear, makePlane, makePlanetaryGear, makeProjectedEdges, manifoldShell, map, mapBoth, mapErr, match, materialize, measureArea, measureCurvatureAt, measureCurvatureAtMid, measureDistance, measureDistanceProps, measureLength, measureLinearProps, measureSurfaceProps, measureVolume, measureVolumeProps, measurement_exports as measurement, mechanismDOF, mesh, meshEdges, meshLODs, meshMultiLOD, minkowski, mirror, mirror2D, mirrorDrawing, mirrorJoin, modifiers_exports as modifiers, modifyStep, moduleInitError, multiSectionSweep, normalAt, offset, offsetFace, offsetMesh, offsetShape, offsetWire2D, ok, or, orElse, organiseBlueprints, orientedFace, outerWire, patterns_exports as patterns, pendingCount, pipeline, pivotPlane, planarFace, planarJoint, planarWire, planetPlacements, pocket, pointOnSurface, pointsInside, polygon, polyhedron, polysideInnerRadius, polysidesBlueprint, positionOnCurve, prewarm, primitives_exports as primitives, prismaticJoint, projectEdges, projectPointOnFace, query_exports as query, queryError, rectangularPattern, registerHandler, registerKernel, registerKernelTier, registerOperation, registerShape, registerVoxel, rejectAll, removeChild, removeHolesFromFace, repairMesh, replayFrom, replayHistory, resetDisposalStats, resetPerformanceStats, resize, resolve, resolve3D, resolveDirection, resolvePlane, resolveRef, reverseCurve, revoluteJoint, revolve, roof, rotate, rotate2D, rotateDrawing, roundedRectangleBlueprint, scale, scale2D, scaleDrawing, box$1 as sdfBox, capsule as sdfCapsule, cone$1 as sdfCone, cylinder$1 as sdfCylinder, fieldAxialRamp as sdfFieldAxialRamp, fieldClamp as sdfFieldClamp, fieldConst as sdfFieldConst, fieldFromSdf as sdfFieldFromSdf, fieldRadialRamp as sdfFieldRadialRamp, lattice as sdfLattice, plane as sdfPlane, roundedBox as sdfRoundedBox, sphere as sdfSphere, strutLattice as sdfStrutLattice, sweep as sdfSweep, torus as sdfTorus, section, sectionToFace, serializeHistory, setJointValue, setJointValues, setShapeOrigin, setTagMetadata, sewShells, shape, shapeToMeshInput, shapeType, sharedEdges, shell, shellMesh, shellShape, shellWithEvolution, simplify, sketchCircle, sketchEllipse, sketchExtrude, sketchFace, sketchFaceOffset, sketchHelix, sketchLoft, sketchOnFace2D, sketchOnPlane2D, sketchParametricFunction, sketchPolysides, sketchRectangle, sketchRevolve, sketchRoundedRectangle, sketchSweep, sketchText, sketchWires, sketcherStateError, slice, solid, solidFromShell, solveAssembly, sphere$1 as sphere, sphericalJoint, split, stepCount, stepsFrom, stretch2D, subFace, supportExtrude, supportsConstraintSketch, supportsProjection, surfaceFromGrid, surfaceFromImage, sweep$1 as sweep, tagFaces, tangentArc, tap, tapErr, textBlueprints, textMetrics, thicken, thread, threePointArc, toBREP, toBufferGeometryData, toGroupedBufferGeometryData, toKernelVec, toLODGeometryData, toLODGeometryLevels, toLineGeometryData, toSVGPathD, toVec2, toVec3, torus$1 as torus, tpmsLattice, transformCopy, transforms_exports as transforms, translate, translate2D, translateDrawing, translatePlane, tryCatch, tryCatchAsync, twistExtrude, typeCastError, undoLast, unsupportedError, unwrap, unwrapErr, unwrapOr, unwrapOrElse, updateNode, updateRoles, uvBounds, uvCoordinates, validSolid, validatePlanetary, validationError, variableFillet, vecAdd, vecAngle, vecCross, vecDistance, vecDot, vecEquals, vecIsZero, vecLength, vecLengthSq, vecNegate, vecNormalize, vecProjectToPlane, vecRepr, vecRotate, vecScale, vecSub, vertex, vertexFinder, vertexPosition, verticesOfEdge, voxelBoolean, voxelBooleanField, voxelBooleanFieldShapes, voxelBooleanShapes, voxelField, voxelFieldFromShape, walkAssembly, windingNumbers, wire, wireFinder, wireLoop, wiresOfFace, withKernel, withKernelDir, withKernelPnt, withKernelVec, withQuality, withScope, withScopeResult, withScopeResultAsync, withTier, zip as zipResults };
@@ -84,6 +84,29 @@ function toLODGeometryData(multiLOD, distances) {
84
84
  fineDistance: distances?.fine ?? 0
85
85
  };
86
86
  }
87
+ /**
88
+ * Convert N LOD meshes (from `meshLODs`, coarse → fine) into THREE.LOD level
89
+ * data. The finest level gets distance 0 and each coarser level steps out by
90
+ * `step`; pass `distances` (indexed coarse → fine) to set them explicitly.
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * const lod = new THREE.LOD();
95
+ * for (const { geometry, distance } of toLODGeometryLevels(meshLODs(shape))) {
96
+ * lod.addLevel(new THREE.Mesh(toBufferGeometry(geometry), mat), distance);
97
+ * }
98
+ * ```
99
+ */
100
+ function toLODGeometryLevels(lods, options) {
101
+ const step = options?.step ?? 50;
102
+ const distances = options?.distances;
103
+ if (distances && distances.length !== lods.length) throw new Error(`toLODGeometryLevels: distances must have one entry per level (got ${distances.length} for ${lods.length} levels)`);
104
+ const last = lods.length - 1;
105
+ return lods.map((lod, idx) => ({
106
+ geometry: toBufferGeometryData(lod.mesh),
107
+ distance: distances?.[idx] ?? (last - idx) * step
108
+ }));
109
+ }
87
110
  //#endregion
88
111
  //#region src/topology/chamferAngleFns.ts
89
112
  /**
@@ -1353,4 +1376,4 @@ function fixSelfIntersection(wire) {
1353
1376
  }
1354
1377
  }
1355
1378
  //#endregion
1356
- export { edgesOfFace as A, shellWithEvolution as C, getNurbsCurveData as D, fuseAllBisect as E, chamferDistAngle as F, toBufferGeometryData as I, toGroupedBufferGeometryData as L, sharedEdges as M, verticesOfEdge as N, getNurbsSurfaceData as O, wiresOfFace as P, toLODGeometryData as R, intersectWithEvolution as S, cutAllBisect as T, positionOnCurve as _, healFace as a, filletWithEvolution as b, isValid as c, draft as d, fillet as f, variableFillet as g, thicken as h, heal as i, facesOfEdge as j, adjacentFaces as k, solidFromShell as l, shell as m, fixSelfIntersection as n, healSolid as o, offset as p, fixShape as r, healWire as s, autoHeal as t, chamfer as u, chamferWithEvolution as v, checkBoolean as w, fuseWithEvolution as x, cutWithEvolution as y, toLineGeometryData as z };
1379
+ export { edgesOfFace as A, toLineGeometryData as B, shellWithEvolution as C, getNurbsCurveData as D, fuseAllBisect as E, chamferDistAngle as F, toBufferGeometryData as I, toGroupedBufferGeometryData as L, sharedEdges as M, verticesOfEdge as N, getNurbsSurfaceData as O, wiresOfFace as P, toLODGeometryData as R, intersectWithEvolution as S, cutAllBisect as T, positionOnCurve as _, healFace as a, filletWithEvolution as b, isValid as c, draft as d, fillet as f, variableFillet as g, thicken as h, heal as i, facesOfEdge as j, adjacentFaces as k, solidFromShell as l, shell as m, fixSelfIntersection as n, healSolid as o, offset as p, fixShape as r, healWire as s, autoHeal as t, chamfer as u, chamferWithEvolution as v, checkBoolean as w, fuseWithEvolution as x, cutWithEvolution as y, toLODGeometryLevels as z };
@@ -84,6 +84,29 @@ function toLODGeometryData(multiLOD, distances) {
84
84
  fineDistance: distances?.fine ?? 0
85
85
  };
86
86
  }
87
+ /**
88
+ * Convert N LOD meshes (from `meshLODs`, coarse → fine) into THREE.LOD level
89
+ * data. The finest level gets distance 0 and each coarser level steps out by
90
+ * `step`; pass `distances` (indexed coarse → fine) to set them explicitly.
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * const lod = new THREE.LOD();
95
+ * for (const { geometry, distance } of toLODGeometryLevels(meshLODs(shape))) {
96
+ * lod.addLevel(new THREE.Mesh(toBufferGeometry(geometry), mat), distance);
97
+ * }
98
+ * ```
99
+ */
100
+ function toLODGeometryLevels(lods, options) {
101
+ const step = options?.step ?? 50;
102
+ const distances = options?.distances;
103
+ if (distances && distances.length !== lods.length) throw new Error(`toLODGeometryLevels: distances must have one entry per level (got ${distances.length} for ${lods.length} levels)`);
104
+ const last = lods.length - 1;
105
+ return lods.map((lod, idx) => ({
106
+ geometry: toBufferGeometryData(lod.mesh),
107
+ distance: distances?.[idx] ?? (last - idx) * step
108
+ }));
109
+ }
87
110
  //#endregion
88
111
  //#region src/topology/chamferAngleFns.ts
89
112
  /**
@@ -1563,6 +1586,12 @@ Object.defineProperty(exports, "toLODGeometryData", {
1563
1586
  return toLODGeometryData;
1564
1587
  }
1565
1588
  });
1589
+ Object.defineProperty(exports, "toLODGeometryLevels", {
1590
+ enumerable: true,
1591
+ get: function() {
1592
+ return toLODGeometryLevels;
1593
+ }
1594
+ });
1566
1595
  Object.defineProperty(exports, "toLineGeometryData", {
1567
1596
  enumerable: true,
1568
1597
  get: function() {
package/dist/index.d.ts CHANGED
@@ -92,9 +92,9 @@ export { getCurveType, curveStartPoint, curveEndPoint, curvePointAt, curveTangen
92
92
  export { getNurbsCurveData, getNurbsSurfaceData } from './topology/nurbsFns.js';
93
93
  export type { NurbsCurveData, NurbsSurfaceData } from './kernel/types.js';
94
94
  export { getSurfaceType, faceGeomType, faceOrientation, flipFaceOrientation, uvBounds, pointOnSurface, uvCoordinates, normalAt, faceCenter, faceAxis, classifyPointOnFace, outerWire, innerWires, removeHolesFromFace, projectPointOnFace, type UVBounds, type PointProjectionResult, } from './topology/faceFns.js';
95
- export { exportSTEP, exportSTL, exportIGES, meshMultiLOD, type ShapeMesh, type EdgeMesh, type MeshOptions, type MultiLODMesh, } from './topology/meshFns.js';
95
+ export { exportSTEP, exportSTL, exportIGES, meshMultiLOD, meshLODs, type ShapeMesh, type EdgeMesh, type MeshOptions, type MultiLODMesh, type LODMesh, type MeshLODsOptions, } from './topology/meshFns.js';
96
96
  export { clearMeshCache, createMeshCache, type MeshCacheContext } from './topology/meshCache.js';
97
- export { toBufferGeometryData, toLineGeometryData, toGroupedBufferGeometryData, type BufferGeometryData, type LineGeometryData, type GroupedBufferGeometryData, type BufferGeometryGroup, toLODGeometryData, type LODGeometryData, } from './topology/threeHelpers.js';
97
+ export { toBufferGeometryData, toLineGeometryData, toGroupedBufferGeometryData, type BufferGeometryData, type LineGeometryData, type GroupedBufferGeometryData, type BufferGeometryGroup, toLODGeometryData, type LODGeometryData, toLODGeometryLevels, type LODGeometryLevel, } from './topology/threeHelpers.js';
98
98
  export { booleanPipeline, type BooleanOptions, type BooleanPipelineStep, } from './topology/booleanFns.js';
99
99
  export { fuseAllBisect, cutAllBisect, type BatchBisectResult, type BatchBisectTelemetry, } from './topology/booleanBatchFns.js';
100
100
  export { type PipelineOp } from './topology/booleanFns.js';
@@ -137,7 +137,7 @@ export { importGLB } from './io/gltfImportFns.js';
137
137
  export type { DXFImportOptions } from './io/dxfImportFns.js';
138
138
  export { edgeFinder, faceFinder, wireFinder, vertexFinder, cornerFinder, type EdgeFinderFn, type FaceFinderFn, type WireFinderFn, type VertexFinderFn, type CornerFinderFn, type CornerFilter, type ShapeFinder, } from './query/finderFns.js';
139
139
  export { createCamera, cameraLookAt, cameraFromPlane, projectEdges, type Camera, } from './projection/cameraFns.js';
140
- export { type WorkerRequest, type InitRequest, type OperationRequest, type DisposeRequest, type WorkerResponse, type SuccessResponse, type ErrorResponse, isInitRequest, isOperationRequest, isDisposeRequest, isSuccessResponse, isErrorResponse, type PendingTask, type TaskQueue, createTaskQueue, enqueueTask, dequeueTask, pendingCount, isQueueEmpty, rejectAll, createWorkerClient, createOperationRegistry, registerHandler, createWorkerHandler, type WorkerClient, type WorkerClientOptions, type WorkerResult, type OperationHandler, type OperationRegistry, } from './worker/index.js';
140
+ export { type WorkerRequest, type InitRequest, type OperationRequest, type DisposeRequest, type WorkerResponse, type SuccessResponse, type ErrorResponse, isInitRequest, isOperationRequest, isDisposeRequest, isSuccessResponse, isErrorResponse, type PendingTask, type TaskQueue, createTaskQueue, enqueueTask, dequeueTask, pendingCount, isQueueEmpty, rejectAll, createWorkerClient, createOperationRegistry, registerHandler, createWorkerHandler, createWorkerPool, type WorkerClient, type WorkerClientOptions, type WorkerResult, type OperationHandler, type OperationRegistry, type WorkerPool, type WorkerPoolOptions, type WorkerOperation, } from './worker/index.js';
141
141
  export type { Shapeable, WrappedMarker, FinderFn, FilletRadius, ChamferDistance, DraftAngle, DraftOptions, DrawingLike, DrillOptions, PocketOptions, BossOptions, MirrorJoinOptions, RectangularPatternOptions, } from './topology/apiTypes.js';
142
142
  export { resolve, resolve3D } from './topology/apiTypes.js';
143
143
  export { box, cylinder, sphere, cone, torus, ellipsoid, line, circle, ellipse, helix, threePointArc, ellipseArc, bsplineApprox, bezier, tangentArc, wire, wireLoop, face, filledFace, subFace, polygon, vertex, compound, solid, offsetFace, sewShells, addHoles, type BoxOptions, type CylinderOptions, type SphereOptions, type ConeOptions, type TorusOptions, type EllipsoidOptions, type CircleOptions, type EllipseOptions, type HelixOptions, type EllipseArcOptions, } from './topology/primitiveFns.js';
package/dist/io.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_meshFns = require("./meshFns-DeKdpmu7.cjs");
2
+ const require_meshFns = require("./meshFns-DNDsv2vH.cjs");
3
3
  const require_importFns = require("./importFns-B6hw9Nhx.cjs");
4
4
  exports.blueprintToDXF = require_importFns.blueprintToDXF;
5
5
  exports.exportDXF = require_importFns.exportDXF;
package/dist/io.js CHANGED
@@ -1,3 +1,3 @@
1
- import { n as exportSTEP, r as exportSTL, t as exportIGES } from "./meshFns-CAAarhVm.js";
1
+ import { n as exportSTEP, r as exportSTL, t as exportIGES } from "./meshFns-DoVH8EPW.js";
2
2
  import { a as importSVG, c as blueprintToDXF, d as exportGltf, f as exportOBJ, i as exportSTEPConfigured, l as exportDXF, n as importSTEP, o as importSVGPathD, r as importSTL, s as exportThreeMF, t as importIGES, u as exportGlb } from "./importFns-CEczwPdN.js";
3
3
  export { blueprintToDXF, exportDXF, exportGlb, exportGltf, exportIGES, exportOBJ, exportSTEP, exportSTEPConfigured, exportSTL, exportThreeMF, importIGES, importSTEP, importSTL, importSVG, importSVGPathD };
@@ -314,6 +314,54 @@ function meshMultiLOD(shape, options) {
314
314
  })
315
315
  };
316
316
  }
317
+ function boundsDiagonal(shape) {
318
+ const b = require_topologyQueryFns.getBounds(shape);
319
+ const dx = b.xMax - b.xMin;
320
+ const dy = b.yMax - b.yMin;
321
+ const dz = b.zMax - b.zMin;
322
+ return Math.sqrt(dx * dx + dy * dy + dz * dz) || 1;
323
+ }
324
+ /**
325
+ * Mesh a shape at several levels of detail, coarse → fine.
326
+ *
327
+ * Tolerances are **scale-relative** by default: the finest level is a fraction
328
+ * (`relativeTolerance`) of the shape's bounding-box diagonal and each coarser
329
+ * level steps up by `spacing`×, so the same call gives sensible detail whether
330
+ * the part is millimetres or metres. Pass `tolerances` for absolute control.
331
+ * Each level goes through {@link mesh}, so levels are cached individually.
332
+ *
333
+ * @returns LOD levels ordered coarsest → finest.
334
+ * @see toLODGeometryLevels — convert to THREE.LOD geometry data
335
+ */
336
+ function meshLODs(shape, options = {}) {
337
+ const quality = require_shapeTypes.qualityDeflection();
338
+ const finestAngular = options.angularTolerance ?? quality.angularTolerance;
339
+ const cache = options.cache ?? true;
340
+ let tolerances;
341
+ if (options.tolerances && options.tolerances.length > 0) tolerances = [...options.tolerances];
342
+ else {
343
+ const levels = Math.max(1, Math.floor(options.levels ?? 3));
344
+ const spacing = options.spacing ?? 4;
345
+ const finest = (options.relativeTolerance ?? 5e-4) * boundsDiagonal(shape) || Number.EPSILON;
346
+ tolerances = [];
347
+ for (let i = levels - 1; i >= 0; i--) tolerances.push(finest * spacing ** i);
348
+ }
349
+ tolerances.sort((a, b) => b - a);
350
+ const finestTol = Math.min(...tolerances);
351
+ return tolerances.map((tolerance) => {
352
+ const angularTolerance = Math.min(finestAngular * (tolerance / finestTol), 1);
353
+ return {
354
+ tolerance,
355
+ angularTolerance,
356
+ mesh: mesh(shape, {
357
+ tolerance,
358
+ angularTolerance,
359
+ cache,
360
+ ...options.signal ? { signal: options.signal } : {}
361
+ })
362
+ };
363
+ });
364
+ }
317
365
  //#endregion
318
366
  Object.defineProperty(exports, "clearMeshCache", {
319
367
  enumerable: true,
@@ -357,6 +405,12 @@ Object.defineProperty(exports, "meshEdges", {
357
405
  return meshEdges;
358
406
  }
359
407
  });
408
+ Object.defineProperty(exports, "meshLODs", {
409
+ enumerable: true,
410
+ get: function() {
411
+ return meshLODs;
412
+ }
413
+ });
360
414
  Object.defineProperty(exports, "meshMultiLOD", {
361
415
  enumerable: true,
362
416
  get: function() {
@@ -314,5 +314,53 @@ function meshMultiLOD(shape, options) {
314
314
  })
315
315
  };
316
316
  }
317
+ function boundsDiagonal(shape) {
318
+ const b = getBounds(shape);
319
+ const dx = b.xMax - b.xMin;
320
+ const dy = b.yMax - b.yMin;
321
+ const dz = b.zMax - b.zMin;
322
+ return Math.sqrt(dx * dx + dy * dy + dz * dz) || 1;
323
+ }
324
+ /**
325
+ * Mesh a shape at several levels of detail, coarse → fine.
326
+ *
327
+ * Tolerances are **scale-relative** by default: the finest level is a fraction
328
+ * (`relativeTolerance`) of the shape's bounding-box diagonal and each coarser
329
+ * level steps up by `spacing`×, so the same call gives sensible detail whether
330
+ * the part is millimetres or metres. Pass `tolerances` for absolute control.
331
+ * Each level goes through {@link mesh}, so levels are cached individually.
332
+ *
333
+ * @returns LOD levels ordered coarsest → finest.
334
+ * @see toLODGeometryLevels — convert to THREE.LOD geometry data
335
+ */
336
+ function meshLODs(shape, options = {}) {
337
+ const quality = qualityDeflection();
338
+ const finestAngular = options.angularTolerance ?? quality.angularTolerance;
339
+ const cache = options.cache ?? true;
340
+ let tolerances;
341
+ if (options.tolerances && options.tolerances.length > 0) tolerances = [...options.tolerances];
342
+ else {
343
+ const levels = Math.max(1, Math.floor(options.levels ?? 3));
344
+ const spacing = options.spacing ?? 4;
345
+ const finest = (options.relativeTolerance ?? 5e-4) * boundsDiagonal(shape) || Number.EPSILON;
346
+ tolerances = [];
347
+ for (let i = levels - 1; i >= 0; i--) tolerances.push(finest * spacing ** i);
348
+ }
349
+ tolerances.sort((a, b) => b - a);
350
+ const finestTol = Math.min(...tolerances);
351
+ return tolerances.map((tolerance) => {
352
+ const angularTolerance = Math.min(finestAngular * (tolerance / finestTol), 1);
353
+ return {
354
+ tolerance,
355
+ angularTolerance,
356
+ mesh: mesh(shape, {
357
+ tolerance,
358
+ angularTolerance,
359
+ cache,
360
+ ...options.signal ? { signal: options.signal } : {}
361
+ })
362
+ };
363
+ });
364
+ }
317
365
  //#endregion
318
- export { meshEdges as a, createMeshCache as c, mesh as i, exportSTEP as n, meshMultiLOD as o, exportSTL as r, clearMeshCache as s, exportIGES as t };
366
+ export { meshEdges as a, clearMeshCache as c, mesh as i, createMeshCache as l, exportSTEP as n, meshLODs as o, exportSTL as r, meshMultiLOD as s, exportIGES as t };
@@ -93,3 +93,49 @@ export declare function meshMultiLOD(shape: AnyShape<Dimension>, options?: {
93
93
  readonly fineTolerance?: number | undefined;
94
94
  readonly angularTolerance?: number | undefined;
95
95
  }): MultiLODMesh;
96
+ /** One level of a multi-resolution mesh: the geometry plus the tolerances it was meshed at. */
97
+ export interface LODMesh {
98
+ /** Linear deflection (model units) used for this level. */
99
+ readonly tolerance: number;
100
+ /** Angular deflection (radians) used for this level. */
101
+ readonly angularTolerance: number;
102
+ /** The meshed geometry at this level. */
103
+ readonly mesh: ShapeMesh;
104
+ }
105
+ /** Options for {@link meshLODs}. */
106
+ export interface MeshLODsOptions {
107
+ /** Number of levels, coarsest → finest (>= 1). Default 3. Ignored when `tolerances` is given. */
108
+ readonly levels?: number;
109
+ /**
110
+ * The finest level's linear tolerance as a fraction of the shape's bounding-box
111
+ * diagonal, so detail is scale-invariant across part sizes. Default 0.0005
112
+ * (0.05% of the diagonal). Ignored when `tolerances` is given.
113
+ */
114
+ readonly relativeTolerance?: number;
115
+ /**
116
+ * Geometric ratio between successive levels: each coarser level's tolerance is
117
+ * `spacing`× the next finer one. Default 4. Ignored when `tolerances` is given.
118
+ */
119
+ readonly spacing?: number;
120
+ /** Explicit absolute linear tolerances (one per level). Overrides `levels`/`relativeTolerance`/`spacing`; sorted coarse → fine. */
121
+ readonly tolerances?: readonly number[];
122
+ /** The finest level's angular deflection (radians). Defaults to the active quality level; coarser levels scale up with the tolerance ratio (capped at 1 rad). */
123
+ readonly angularTolerance?: number;
124
+ /** Abort signal forwarded to each level's mesh call. */
125
+ readonly signal?: AbortSignal;
126
+ /** Whether to use the mesh cache per level. Default true. */
127
+ readonly cache?: boolean;
128
+ }
129
+ /**
130
+ * Mesh a shape at several levels of detail, coarse → fine.
131
+ *
132
+ * Tolerances are **scale-relative** by default: the finest level is a fraction
133
+ * (`relativeTolerance`) of the shape's bounding-box diagonal and each coarser
134
+ * level steps up by `spacing`×, so the same call gives sensible detail whether
135
+ * the part is millimetres or metres. Pass `tolerances` for absolute control.
136
+ * Each level goes through {@link mesh}, so levels are cached individually.
137
+ *
138
+ * @returns LOD levels ordered coarsest → finest.
139
+ * @see toLODGeometryLevels — convert to THREE.LOD geometry data
140
+ */
141
+ export declare function meshLODs(shape: AnyShape<Dimension>, options?: MeshLODsOptions): LODMesh[];
@@ -1,4 +1,4 @@
1
- import { ShapeMesh, EdgeMesh, MultiLODMesh } from './meshFns.js';
1
+ import { ShapeMesh, EdgeMesh, MultiLODMesh, LODMesh } from './meshFns.js';
2
2
  /** Data ready to be used with THREE.BufferGeometry. */
3
3
  export interface BufferGeometryData {
4
4
  /** Flat float array of vertex positions (x,y,z interleaved). */
@@ -91,3 +91,27 @@ export declare function toLODGeometryData(multiLOD: MultiLODMesh, distances?: {
91
91
  readonly coarse?: number | undefined;
92
92
  readonly fine?: number | undefined;
93
93
  }): LODGeometryData;
94
+ /** One LOD level of THREE.LOD-ready geometry: geometry plus its switch distance. */
95
+ export interface LODGeometryLevel {
96
+ /** Geometry for this level. */
97
+ readonly geometry: BufferGeometryData;
98
+ /** Camera distance at which THREE.LOD switches to this level (finest = 0). */
99
+ readonly distance: number;
100
+ }
101
+ /**
102
+ * Convert N LOD meshes (from `meshLODs`, coarse → fine) into THREE.LOD level
103
+ * data. The finest level gets distance 0 and each coarser level steps out by
104
+ * `step`; pass `distances` (indexed coarse → fine) to set them explicitly.
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * const lod = new THREE.LOD();
109
+ * for (const { geometry, distance } of toLODGeometryLevels(meshLODs(shape))) {
110
+ * lod.addLevel(new THREE.Mesh(toBufferGeometry(geometry), mat), distance);
111
+ * }
112
+ * ```
113
+ */
114
+ export declare function toLODGeometryLevels(lods: ReadonlyArray<LODMesh>, options?: {
115
+ readonly distances?: readonly number[];
116
+ readonly step?: number;
117
+ }): LODGeometryLevel[];
package/dist/topology.cjs CHANGED
@@ -3,9 +3,9 @@ const require_topologyQueryFns = require("./topologyQueryFns-ygBBXxnP.cjs");
3
3
  const require_faceFns = require("./faceFns-DKg2St8b.cjs");
4
4
  const require_shapeFns = require("./shapeFns-L4a8kH_A.cjs");
5
5
  const require_curveFns = require("./curveFns-Dx7_wMut.cjs");
6
- const require_meshFns = require("./meshFns-DeKdpmu7.cjs");
6
+ const require_meshFns = require("./meshFns-DNDsv2vH.cjs");
7
7
  const require_solidBuilders = require("./solidBuilders-CgRmJEdn.cjs");
8
- const require_healingFns = require("./healingFns-CM5mVMow.cjs");
8
+ const require_healingFns = require("./healingFns-OL0bBSSY.cjs");
9
9
  const require_primitiveFns = require("./primitiveFns-BAWtMd9H.cjs");
10
10
  exports.addHoles = require_primitiveFns.addHoles;
11
11
  exports.adjacentFaces = require_healingFns.adjacentFaces;
package/dist/topology.js CHANGED
@@ -2,8 +2,8 @@ import { S as vertexPosition, _ as iterFaces, b as iterVertices, c as getFaces,
2
2
  import { S as shapeType, _ as cast, a as faceOrientation, b as isCompSolid, c as innerWires, d as pointOnSurface, f as projectPointOnFace, g as asTopo, h as uvCoordinates, i as faceGeomType, l as normalAt, m as uvBounds, n as faceAxis, o as flipFaceOrientation, r as faceCenter, s as getSurfaceType, t as classifyPointOnFace, u as outerWire, v as downcast, x as iterTopo, y as fromBREP } from "./faceFns-mo4ThIHz.js";
3
3
  import { a as isSameShape, i as isEqualShape, n as getHashCode } from "./shapeFns-DyBbhU30.js";
4
4
  import { a as curveIsPeriodic, c as curvePointAt, d as flipOrientation, f as getCurveType, h as offsetWire2D, i as curveIsClosed, l as curveStartPoint, m as interpolateCurve, n as curveAxis, o as curveLength, p as getOrientation, r as curveEndPoint, s as curvePeriod, t as approximateCurve, u as curveTangentAt } from "./curveFns-CG05Jygr.js";
5
- import { c as createMeshCache, n as exportSTEP, r as exportSTL, s as clearMeshCache, t as exportIGES } from "./meshFns-CAAarhVm.js";
5
+ import { c as clearMeshCache, l as createMeshCache, n as exportSTEP, r as exportSTL, t as exportIGES } from "./meshFns-DoVH8EPW.js";
6
6
  import { h as fuseAll, p as cutAll } from "./solidBuilders-Biwv2cW3.js";
7
- import { A as edgesOfFace, C as shellWithEvolution, D as getNurbsCurveData, E as fuseAllBisect, F as chamferDistAngle, I as toBufferGeometryData, L as toGroupedBufferGeometryData, M as sharedEdges, N as verticesOfEdge, O as getNurbsSurfaceData, P as wiresOfFace, S as intersectWithEvolution, T as cutAllBisect, _ as positionOnCurve, a as healFace, b as filletWithEvolution, g as variableFillet, j as facesOfEdge, k as adjacentFaces, l as solidFromShell, n as fixSelfIntersection, o as healSolid, r as fixShape, s as healWire, t as autoHeal, v as chamferWithEvolution, w as checkBoolean, x as fuseWithEvolution, y as cutWithEvolution, z as toLineGeometryData } from "./healingFns-Bb3eEBNm.js";
7
+ import { A as edgesOfFace, B as toLineGeometryData, C as shellWithEvolution, D as getNurbsCurveData, E as fuseAllBisect, F as chamferDistAngle, I as toBufferGeometryData, L as toGroupedBufferGeometryData, M as sharedEdges, N as verticesOfEdge, O as getNurbsSurfaceData, P as wiresOfFace, S as intersectWithEvolution, T as cutAllBisect, _ as positionOnCurve, a as healFace, b as filletWithEvolution, g as variableFillet, j as facesOfEdge, k as adjacentFaces, l as solidFromShell, n as fixSelfIntersection, o as healSolid, r as fixShape, s as healWire, t as autoHeal, v as chamferWithEvolution, w as checkBoolean, x as fuseWithEvolution, y as cutWithEvolution } from "./healingFns-C5AomW4j.js";
8
8
  import { C as threePointArc, D as wireLoop, E as wire, S as tangentArc, T as vertex, _ 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, 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 } from "./primitiveFns-62SO4ti5.js";
9
9
  export { addHoles, adjacentFaces, approximateCurve, asTopo, autoHeal, bezier, box, bsplineApprox, cast, chamferDistAngle as chamferDistAngleShape, chamferWithEvolution, checkBoolean, circle, classifyPointOnFace, clearMeshCache, compound, cone, createMeshCache, curveAxis, curveEndPoint, curveIsClosed, curveIsPeriodic, curveLength, curvePeriod, curvePointAt, curveStartPoint, curveTangentAt, cutAll, cutAllBisect, cutWithEvolution, cylinder, fromBREP as deserializeShape, downcast, edgesOfFace, ellipse, ellipseArc, ellipsoid, exportIGES, exportSTEP, exportSTL, face, faceAxis, faceCenter, faceGeomType, faceOrientation, facesOfEdge, filledFace, filletWithEvolution, fixSelfIntersection, fixShape, flipFaceOrientation, flipOrientation, fuseAll, fuseAllBisect, fuseWithEvolution, getBounds, getCurveType, getEdges, getFaces, getHashCode, getNurbsCurveData, getNurbsSurfaceData, getOrientation, getSurfaceType, getVertices, getWires, healFace, healSolid, healWire, helix, innerWires, interpolateCurve, intersectWithEvolution, invalidateShapeCache, isCompSolid, isEqualShape, isSameShape, iterEdges, iterFaces, iterTopo, iterVertices, iterWires, line, normalAt, offsetFace, offsetWire2D, outerWire, pointOnSurface, polygon, positionOnCurve, projectPointOnFace, sewShells, shapeType, sharedEdges, shellWithEvolution, solid, solidFromShell, sphere, subFace, tangentArc, threePointArc, toBufferGeometryData, toGroupedBufferGeometryData, toLineGeometryData, torus, uvBounds, uvCoordinates, variableFillet, vertex, vertexPosition, verticesOfEdge, wire, wireLoop, wiresOfFace };
@@ -8,3 +8,4 @@ export { type WorkerRequest, type InitRequest, type OperationRequest, type Dispo
8
8
  export { type PendingTask, type TaskQueue, createTaskQueue, enqueueTask, dequeueTask, pendingCount, isEmpty as isQueueEmpty, rejectAll, } from './taskQueue.js';
9
9
  export { createWorkerClient, type WorkerClient, type WorkerClientOptions, type WorkerResult, } from './workerClient.js';
10
10
  export { createOperationRegistry, registerHandler, createWorkerHandler, type OperationHandler, type OperationRegistry, } from './workerHandler.js';
11
+ export { createWorkerPool, type WorkerPool, type WorkerPoolOptions, type WorkerOperation, } from './workerPool.js';
@@ -0,0 +1,46 @@
1
+ import { WorkerResult } from './workerClient.js';
2
+ export interface WorkerPoolOptions {
3
+ /** The Worker instances to pool over; each is wrapped in a WorkerClient. */
4
+ workers: Worker[];
5
+ /** Optional URL for the WASM binary, forwarded to every worker on init. */
6
+ wasmUrl?: string;
7
+ }
8
+ /** A single operation for {@link WorkerPool.executeBatch}. */
9
+ export interface WorkerOperation {
10
+ /** Name of the registered operation to invoke. */
11
+ operation: string;
12
+ /** BREP-serialized input shapes. */
13
+ shapesBrep: string[];
14
+ /** Parameters forwarded to the operation handler. */
15
+ params: Record<string, unknown>;
16
+ }
17
+ export interface WorkerPool {
18
+ /** Number of workers in the pool. */
19
+ readonly size: number;
20
+ /**
21
+ * Initialize every worker (load WASM) in parallel. Atomic: if any worker
22
+ * fails, the pool disposes every worker and rejects with the original error,
23
+ * leaving the pool in a terminal disposed state.
24
+ */
25
+ init(): Promise<void>;
26
+ /** Run one operation on the least-loaded worker. */
27
+ execute(operation: string, shapesBrep: string[], params: Record<string, unknown>): Promise<WorkerResult>;
28
+ /**
29
+ * Run a batch of independent operations, fanned across the pool concurrently.
30
+ * Resolves with results in the same order as `operations`.
31
+ */
32
+ executeBatch(operations: ReadonlyArray<WorkerOperation>): Promise<WorkerResult[]>;
33
+ /** In-flight task count per worker, indexed as the pool was constructed. */
34
+ inFlight(): readonly number[];
35
+ /** Dispose every worker, rejecting all pending and future operations. Idempotent. */
36
+ dispose(): void;
37
+ }
38
+ /**
39
+ * Create a worker pool over the given Worker instances.
40
+ *
41
+ * Dispatch is least-loaded: each operation goes to the worker with the fewest
42
+ * in-flight tasks (ties resolve to the first). The count is bumped synchronously
43
+ * at dispatch, so a burst of calls spreads across workers rather than piling
44
+ * onto one. Under uniform op cost this degrades to round-robin.
45
+ */
46
+ export declare function createWorkerPool(options: WorkerPoolOptions): WorkerPool;
package/dist/worker.cjs CHANGED
@@ -1,17 +1,18 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_workerHandler = require("./workerHandler-CdlOTwJg.cjs");
3
- exports.createOperationRegistry = require_workerHandler.createOperationRegistry;
4
- exports.createTaskQueue = require_workerHandler.createTaskQueue;
5
- exports.createWorkerClient = require_workerHandler.createWorkerClient;
6
- exports.createWorkerHandler = require_workerHandler.createWorkerHandler;
7
- exports.dequeueTask = require_workerHandler.dequeueTask;
8
- exports.enqueueTask = require_workerHandler.enqueueTask;
9
- exports.isDisposeRequest = require_workerHandler.isDisposeRequest;
10
- exports.isErrorResponse = require_workerHandler.isErrorResponse;
11
- exports.isInitRequest = require_workerHandler.isInitRequest;
12
- exports.isOperationRequest = require_workerHandler.isOperationRequest;
13
- exports.isQueueEmpty = require_workerHandler.isEmpty;
14
- exports.isSuccessResponse = require_workerHandler.isSuccessResponse;
15
- exports.pendingCount = require_workerHandler.pendingCount;
16
- exports.registerHandler = require_workerHandler.registerHandler;
17
- exports.rejectAll = require_workerHandler.rejectAll;
2
+ const require_workerPool = require("./workerPool-edtPrfHM.cjs");
3
+ exports.createOperationRegistry = require_workerPool.createOperationRegistry;
4
+ exports.createTaskQueue = require_workerPool.createTaskQueue;
5
+ exports.createWorkerClient = require_workerPool.createWorkerClient;
6
+ exports.createWorkerHandler = require_workerPool.createWorkerHandler;
7
+ exports.createWorkerPool = require_workerPool.createWorkerPool;
8
+ exports.dequeueTask = require_workerPool.dequeueTask;
9
+ exports.enqueueTask = require_workerPool.enqueueTask;
10
+ exports.isDisposeRequest = require_workerPool.isDisposeRequest;
11
+ exports.isErrorResponse = require_workerPool.isErrorResponse;
12
+ exports.isInitRequest = require_workerPool.isInitRequest;
13
+ exports.isOperationRequest = require_workerPool.isOperationRequest;
14
+ exports.isQueueEmpty = require_workerPool.isEmpty;
15
+ exports.isSuccessResponse = require_workerPool.isSuccessResponse;
16
+ exports.pendingCount = require_workerPool.pendingCount;
17
+ exports.registerHandler = require_workerPool.registerHandler;
18
+ exports.rejectAll = require_workerPool.rejectAll;
package/dist/worker.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as createTaskQueue, c as isEmpty, 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-CFetYgIm.js";
2
- export { createOperationRegistry, createTaskQueue, createWorkerClient, createWorkerHandler, dequeueTask, enqueueTask, isDisposeRequest, isErrorResponse, isInitRequest, isOperationRequest, isEmpty as isQueueEmpty, isSuccessResponse, pendingCount, registerHandler, rejectAll };
1
+ import { a as createWorkerClient, c as enqueueTask, d as rejectAll, f as isDisposeRequest, g as isSuccessResponse, h as isOperationRequest, i as registerHandler, l as isEmpty, m as isInitRequest, n as createOperationRegistry, o as createTaskQueue, p as isErrorResponse, r as createWorkerHandler, s as dequeueTask, t as createWorkerPool, u as pendingCount } from "./workerPool-BxBKpKeI.js";
2
+ export { createOperationRegistry, createTaskQueue, createWorkerClient, createWorkerHandler, createWorkerPool, dequeueTask, enqueueTask, isDisposeRequest, isErrorResponse, isInitRequest, isOperationRequest, isEmpty as isQueueEmpty, isSuccessResponse, pendingCount, registerHandler, rejectAll };
@@ -205,4 +205,68 @@ function createWorkerHandler(registry, initFn) {
205
205
  };
206
206
  }
207
207
  //#endregion
208
- export { createTaskQueue as a, isEmpty as c, isDisposeRequest as d, isErrorResponse as f, isSuccessResponse as h, createWorkerClient as i, pendingCount as l, isOperationRequest as m, createWorkerHandler as n, dequeueTask as o, isInitRequest as p, registerHandler as r, enqueueTask as s, createOperationRegistry as t, rejectAll as u };
208
+ //#region src/worker/workerPool.ts
209
+ /**
210
+ * Worker pool for spreading CAD operations across several Web Workers.
211
+ *
212
+ * Wraps N {@link WorkerClient}s behind the same promise API and dispatches each
213
+ * operation to the least-loaded worker, so independent work can span cores
214
+ * instead of serializing through a single worker.
215
+ */
216
+ /**
217
+ * Create a worker pool over the given Worker instances.
218
+ *
219
+ * Dispatch is least-loaded: each operation goes to the worker with the fewest
220
+ * in-flight tasks (ties resolve to the first). The count is bumped synchronously
221
+ * at dispatch, so a burst of calls spreads across workers rather than piling
222
+ * onto one. Under uniform op cost this degrades to round-robin.
223
+ */
224
+ function createWorkerPool(options) {
225
+ const { workers, wasmUrl } = options;
226
+ if (workers.length === 0) throw new Error("createWorkerPool requires at least one worker");
227
+ const slots = workers.map((worker) => ({
228
+ client: createWorkerClient({
229
+ worker,
230
+ ...wasmUrl !== void 0 ? { wasmUrl } : {}
231
+ }),
232
+ inFlight: 0
233
+ }));
234
+ let disposed = false;
235
+ function leastLoaded() {
236
+ return slots.reduce((best, slot) => slot.inFlight < best.inFlight ? slot : best);
237
+ }
238
+ function execute(operation, shapesBrep, params) {
239
+ if (disposed) return Promise.reject(/* @__PURE__ */ new Error("WorkerPool has been disposed"));
240
+ const slot = leastLoaded();
241
+ slot.inFlight += 1;
242
+ return slot.client.execute(operation, shapesBrep, params).finally(() => {
243
+ slot.inFlight -= 1;
244
+ });
245
+ }
246
+ function dispose() {
247
+ if (disposed) return;
248
+ disposed = true;
249
+ for (const slot of slots) slot.client.dispose();
250
+ }
251
+ return {
252
+ size: slots.length,
253
+ async init() {
254
+ try {
255
+ await Promise.all(slots.map((slot) => slot.client.init()));
256
+ } catch (err) {
257
+ dispose();
258
+ throw err;
259
+ }
260
+ },
261
+ execute,
262
+ executeBatch(operations) {
263
+ return Promise.all(operations.map((op) => execute(op.operation, op.shapesBrep, op.params)));
264
+ },
265
+ inFlight() {
266
+ return slots.map((slot) => slot.inFlight);
267
+ },
268
+ dispose
269
+ };
270
+ }
271
+ //#endregion
272
+ export { createWorkerClient as a, enqueueTask as c, rejectAll as d, isDisposeRequest as f, isSuccessResponse as g, isOperationRequest as h, registerHandler as i, isEmpty as l, isInitRequest as m, createOperationRegistry as n, createTaskQueue as o, isErrorResponse as p, createWorkerHandler as r, dequeueTask as s, createWorkerPool as t, pendingCount as u };
@@ -205,6 +205,70 @@ function createWorkerHandler(registry, initFn) {
205
205
  };
206
206
  }
207
207
  //#endregion
208
+ //#region src/worker/workerPool.ts
209
+ /**
210
+ * Worker pool for spreading CAD operations across several Web Workers.
211
+ *
212
+ * Wraps N {@link WorkerClient}s behind the same promise API and dispatches each
213
+ * operation to the least-loaded worker, so independent work can span cores
214
+ * instead of serializing through a single worker.
215
+ */
216
+ /**
217
+ * Create a worker pool over the given Worker instances.
218
+ *
219
+ * Dispatch is least-loaded: each operation goes to the worker with the fewest
220
+ * in-flight tasks (ties resolve to the first). The count is bumped synchronously
221
+ * at dispatch, so a burst of calls spreads across workers rather than piling
222
+ * onto one. Under uniform op cost this degrades to round-robin.
223
+ */
224
+ function createWorkerPool(options) {
225
+ const { workers, wasmUrl } = options;
226
+ if (workers.length === 0) throw new Error("createWorkerPool requires at least one worker");
227
+ const slots = workers.map((worker) => ({
228
+ client: createWorkerClient({
229
+ worker,
230
+ ...wasmUrl !== void 0 ? { wasmUrl } : {}
231
+ }),
232
+ inFlight: 0
233
+ }));
234
+ let disposed = false;
235
+ function leastLoaded() {
236
+ return slots.reduce((best, slot) => slot.inFlight < best.inFlight ? slot : best);
237
+ }
238
+ function execute(operation, shapesBrep, params) {
239
+ if (disposed) return Promise.reject(/* @__PURE__ */ new Error("WorkerPool has been disposed"));
240
+ const slot = leastLoaded();
241
+ slot.inFlight += 1;
242
+ return slot.client.execute(operation, shapesBrep, params).finally(() => {
243
+ slot.inFlight -= 1;
244
+ });
245
+ }
246
+ function dispose() {
247
+ if (disposed) return;
248
+ disposed = true;
249
+ for (const slot of slots) slot.client.dispose();
250
+ }
251
+ return {
252
+ size: slots.length,
253
+ async init() {
254
+ try {
255
+ await Promise.all(slots.map((slot) => slot.client.init()));
256
+ } catch (err) {
257
+ dispose();
258
+ throw err;
259
+ }
260
+ },
261
+ execute,
262
+ executeBatch(operations) {
263
+ return Promise.all(operations.map((op) => execute(op.operation, op.shapesBrep, op.params)));
264
+ },
265
+ inFlight() {
266
+ return slots.map((slot) => slot.inFlight);
267
+ },
268
+ dispose
269
+ };
270
+ }
271
+ //#endregion
208
272
  Object.defineProperty(exports, "createOperationRegistry", {
209
273
  enumerable: true,
210
274
  get: function() {
@@ -229,6 +293,12 @@ Object.defineProperty(exports, "createWorkerHandler", {
229
293
  return createWorkerHandler;
230
294
  }
231
295
  });
296
+ Object.defineProperty(exports, "createWorkerPool", {
297
+ enumerable: true,
298
+ get: function() {
299
+ return createWorkerPool;
300
+ }
301
+ });
232
302
  Object.defineProperty(exports, "dequeueTask", {
233
303
  enumerable: true,
234
304
  get: function() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brepjs",
3
- "version": "18.103.0",
3
+ "version": "18.105.0",
4
4
  "description": "Web CAD library with pluggable geometry kernel",
5
5
  "keywords": [
6
6
  "cad",