brepjs 18.106.0 → 18.108.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 +49 -1
- package/dist/brepjs.js +50 -3
- package/dist/csg/evaluate.d.ts +25 -0
- package/dist/index.d.ts +1 -1
- package/dist/io.cjs +1 -1
- package/dist/io.js +1 -1
- package/dist/{meshFns-DoVH8EPW.js → meshFns-DeGn7mQ4.js} +75 -14
- package/dist/{meshFns-DNDsv2vH.cjs → meshFns-JwMEfMvC.cjs} +86 -13
- package/dist/topology/meshFns.d.ts +31 -0
- package/dist/topology.cjs +1 -1
- package/dist/topology.js +1 -1
- package/package.json +1 -1
package/dist/brepjs.cjs
CHANGED
|
@@ -12,7 +12,7 @@ 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-
|
|
15
|
+
const require_meshFns = require("./meshFns-JwMEfMvC.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");
|
|
@@ -5807,6 +5807,8 @@ var Evaluator = class {
|
|
|
5807
5807
|
kernelId;
|
|
5808
5808
|
defaultTolerance;
|
|
5809
5809
|
maxCacheEntries;
|
|
5810
|
+
maxMeshCacheEntries;
|
|
5811
|
+
meshCache = /* @__PURE__ */ new Map();
|
|
5810
5812
|
onStep;
|
|
5811
5813
|
hits = 0;
|
|
5812
5814
|
misses = 0;
|
|
@@ -5818,6 +5820,9 @@ var Evaluator = class {
|
|
|
5818
5820
|
const max = options.maxCacheEntries;
|
|
5819
5821
|
if (max !== void 0 && (!Number.isInteger(max) || max < 1)) throw new RangeError(`Evaluator: maxCacheEntries must be a positive integer, got ${String(max)}`);
|
|
5820
5822
|
this.maxCacheEntries = max;
|
|
5823
|
+
const meshMax = options.maxMeshCacheEntries;
|
|
5824
|
+
if (meshMax !== void 0 && (!Number.isInteger(meshMax) || meshMax < 1)) throw new RangeError(`Evaluator: maxMeshCacheEntries must be a positive integer, got ${String(meshMax)}`);
|
|
5825
|
+
this.maxMeshCacheEntries = meshMax;
|
|
5821
5826
|
}
|
|
5822
5827
|
/**
|
|
5823
5828
|
* Materialize a CSG IR tree against the given parameter environment.
|
|
@@ -5846,6 +5851,40 @@ var Evaluator = class {
|
|
|
5846
5851
|
}
|
|
5847
5852
|
});
|
|
5848
5853
|
}
|
|
5854
|
+
/**
|
|
5855
|
+
* Materialize a node and mesh it, caching the mesh by the shape's content key
|
|
5856
|
+
* plus the mesh parameters. The mesh cache is independent of the shape cache:
|
|
5857
|
+
* a hit returns the cached mesh without evaluating or meshing — even after the
|
|
5858
|
+
* shape was LRU-evicted (a mesh is plain data, not a kernel handle). The
|
|
5859
|
+
* returned mesh is borrowed (do not mutate it); it stays valid for the
|
|
5860
|
+
* Evaluator's lifetime, or until `maxMeshCacheEntries` evicts it.
|
|
5861
|
+
*/
|
|
5862
|
+
evaluateMesh(node, env = {}, meshOpts = {}) {
|
|
5863
|
+
meshOpts.signal?.throwIfAborted();
|
|
5864
|
+
const useCache = meshOpts.cache ?? true;
|
|
5865
|
+
const quality = require_shapeTypes.qualityDeflection();
|
|
5866
|
+
const tolerance = meshOpts.tolerance ?? quality.tolerance;
|
|
5867
|
+
const angularTolerance = meshOpts.angularTolerance ?? quality.angularTolerance;
|
|
5868
|
+
const meshKey = `${cacheKey(node, env, this.kernelId, this.defaultTolerance)}|${require_meshFns.buildMeshCacheKey(tolerance, angularTolerance, meshOpts.skipNormals ?? false, meshOpts.includeUVs ?? false)}`;
|
|
5869
|
+
if (useCache) {
|
|
5870
|
+
const cached = this.meshCache.get(meshKey);
|
|
5871
|
+
if (cached !== void 0) {
|
|
5872
|
+
if (this.maxMeshCacheEntries !== void 0) {
|
|
5873
|
+
this.meshCache.delete(meshKey);
|
|
5874
|
+
this.meshCache.set(meshKey, cached);
|
|
5875
|
+
}
|
|
5876
|
+
return require_errors.ok(cached);
|
|
5877
|
+
}
|
|
5878
|
+
}
|
|
5879
|
+
const shape = this.evaluate(node, env);
|
|
5880
|
+
if (!shape.ok) return shape;
|
|
5881
|
+
const built = require_shapeTypes.withKernel(this.kernelId, () => require_meshFns.mesh(shape.value, meshOpts));
|
|
5882
|
+
if (useCache) {
|
|
5883
|
+
this.meshCache.set(meshKey, built);
|
|
5884
|
+
if (this.maxMeshCacheEntries !== void 0) this.trimMeshCache(this.maxMeshCacheEntries);
|
|
5885
|
+
}
|
|
5886
|
+
return require_errors.ok(built);
|
|
5887
|
+
}
|
|
5849
5888
|
evaluateInner(node, env) {
|
|
5850
5889
|
const key = cacheKey(node, env, this.kernelId, this.defaultTolerance);
|
|
5851
5890
|
const cached = this.cache.get(key);
|
|
@@ -5898,6 +5937,13 @@ var Evaluator = class {
|
|
|
5898
5937
|
if (shape !== void 0) this.releaseShape(shape);
|
|
5899
5938
|
}
|
|
5900
5939
|
}
|
|
5940
|
+
trimMeshCache(max) {
|
|
5941
|
+
while (this.meshCache.size > max) {
|
|
5942
|
+
const oldest = this.meshCache.keys().next();
|
|
5943
|
+
if (oldest.done) break;
|
|
5944
|
+
this.meshCache.delete(oldest.value);
|
|
5945
|
+
}
|
|
5946
|
+
}
|
|
5901
5947
|
rollbackPending() {
|
|
5902
5948
|
for (const key of this.pendingKeys) {
|
|
5903
5949
|
const shape = this.cache.get(key);
|
|
@@ -5923,6 +5969,7 @@ var Evaluator = class {
|
|
|
5923
5969
|
for (const shape of this.refCounts.keys()) shape[Symbol.dispose]();
|
|
5924
5970
|
this.refCounts.clear();
|
|
5925
5971
|
this.cache.clear();
|
|
5972
|
+
this.meshCache.clear();
|
|
5926
5973
|
}
|
|
5927
5974
|
};
|
|
5928
5975
|
/**
|
|
@@ -7098,6 +7145,7 @@ exports.mechanismDOF = require_threadFns.mechanismDOF;
|
|
|
7098
7145
|
exports.mesh = mesh;
|
|
7099
7146
|
exports.meshEdges = meshEdges;
|
|
7100
7147
|
exports.meshLODs = require_meshFns.meshLODs;
|
|
7148
|
+
exports.meshLODsProgressive = require_meshFns.meshLODsProgressive;
|
|
7101
7149
|
exports.meshMultiLOD = require_meshFns.meshMultiLOD;
|
|
7102
7150
|
exports.minkowski = minkowski;
|
|
7103
7151
|
exports.mirror = mirror;
|
package/dist/brepjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as getKernelCapabilities, A as planarWire, B as createKernelHandle, C as isOrientedFace, D as manifoldShell, E as isValidSolid, F as as3D, H as isLive, I as is2D, J as withScopeResultAsync, K as withScope, L as is3D, M as getShapeKind, O as orientedFace, P as as2D, R as DisposalScope, S as isManifoldShell, T as isPlanarWire, V as getDisposalStats, W as resetDisposalStats, X as getActiveKernelId, Y as _usingCtx, Z as getKernel, _ as isSolid, a as createEdge, at as registerKernel, b as closedWire, c as createSolid, ct as withQuality, d as isCompound, dt as supportsProjection, et as getKernelTier, f as isEdge, ft as BrepkitAdapter, g as isShell, h as isShape3D, ht as currentQuality, i as createCompound, it as prewarm, j as validSolid, k as planarFace, l as createVertex, lt as withTier, m as isShape1D, mt as resetPerformanceStats, n as castShape3D, nt as initFromManifold, o as createFace, ot as registerKernelTier, p as isFace, pt as getPerformanceStats, q as withScopeResult, rt as initFromOC, s as createShell, st as withKernel, t as castShape, tt as init, u as createWire, ut as supportsConstraintSketch, v as isVertex, w as isPlanarFace, x as isClosedWire, y as isWire, z as createHandle } from "./shapeTypes-C4lPfrc2.js";
|
|
1
|
+
import { $ as getKernelCapabilities, A as planarWire, B as createKernelHandle, C as isOrientedFace, D as manifoldShell, E as isValidSolid, F as as3D, H as isLive, I as is2D, J as withScopeResultAsync, K as withScope, L as is3D, M as getShapeKind, O as orientedFace, P as as2D, R as DisposalScope, S as isManifoldShell, T as isPlanarWire, V as getDisposalStats, W as resetDisposalStats, X as getActiveKernelId, Y as _usingCtx, Z as getKernel, _ as isSolid, a as createEdge, at as registerKernel, b as closedWire, c as createSolid, ct as withQuality, d as isCompound, dt as supportsProjection, et as getKernelTier, f as isEdge, ft as BrepkitAdapter, g as isShell, gt as qualityDeflection, h as isShape3D, ht as currentQuality, i as createCompound, it as prewarm, j as validSolid, k as planarFace, l as createVertex, lt as withTier, m as isShape1D, mt as resetPerformanceStats, n as castShape3D, nt as initFromManifold, o as createFace, ot as registerKernelTier, p as isFace, pt as getPerformanceStats, q as withScopeResult, rt as initFromOC, s as createShell, st as withKernel, t as castShape, tt as init, u as createWire, ut as supportsConstraintSketch, v as isVertex, w as isPlanarFace, x as isClosedWire, y as isWire, z as createHandle } from "./shapeTypes-C4lPfrc2.js";
|
|
2
2
|
import { D as DEFAULT_CAPABILITIES, O as EXACT_BREP_CAPABILITIES, t as OcctWasmAdapter } from "./occtWasmAdapter-BDEPveZs.js";
|
|
3
3
|
import { n as wasmIndex } from "./vec3-Dpha8d5k.js";
|
|
4
4
|
import { A as ok, B as unwrapOr, C as fromNullable, D as mapBoth, E as map, F as tapErr, H as zip, I as tryCatch, L as tryCatchAsync, M as orElse, N as pipeline, O as mapErr, P as tap, R as unwrap, S as flatten, T as isOk, V as unwrapOrElse, _ as all, a as moduleInitError, b as err, c as sketcherStateError, d as validationError, g as OK, h as bug, i as kernelError, j as or, k as match, l as typeCastError, m as BrepBugError, n as computationError, o as queryError, r as ioError, t as BrepErrorCode, u as unsupportedError, v as andThen, w as isErr, x as flatMap, y as collect, z as unwrapErr } from "./errors-DNWJsfVU.js";
|
|
@@ -10,7 +10,7 @@ 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
|
|
13
|
+
import { a as meshEdges$1, c as meshMultiLOD, d as createMeshCache, i as mesh$1, l as buildMeshCacheKey, n as exportSTEP, o as meshLODs, r as exportSTL, s as meshLODsProgressive, t as exportIGES, u as clearMeshCache } from "./meshFns-DeGn7mQ4.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";
|
|
@@ -5810,6 +5810,8 @@ var Evaluator = class {
|
|
|
5810
5810
|
kernelId;
|
|
5811
5811
|
defaultTolerance;
|
|
5812
5812
|
maxCacheEntries;
|
|
5813
|
+
maxMeshCacheEntries;
|
|
5814
|
+
meshCache = /* @__PURE__ */ new Map();
|
|
5813
5815
|
onStep;
|
|
5814
5816
|
hits = 0;
|
|
5815
5817
|
misses = 0;
|
|
@@ -5821,6 +5823,9 @@ var Evaluator = class {
|
|
|
5821
5823
|
const max = options.maxCacheEntries;
|
|
5822
5824
|
if (max !== void 0 && (!Number.isInteger(max) || max < 1)) throw new RangeError(`Evaluator: maxCacheEntries must be a positive integer, got ${String(max)}`);
|
|
5823
5825
|
this.maxCacheEntries = max;
|
|
5826
|
+
const meshMax = options.maxMeshCacheEntries;
|
|
5827
|
+
if (meshMax !== void 0 && (!Number.isInteger(meshMax) || meshMax < 1)) throw new RangeError(`Evaluator: maxMeshCacheEntries must be a positive integer, got ${String(meshMax)}`);
|
|
5828
|
+
this.maxMeshCacheEntries = meshMax;
|
|
5824
5829
|
}
|
|
5825
5830
|
/**
|
|
5826
5831
|
* Materialize a CSG IR tree against the given parameter environment.
|
|
@@ -5849,6 +5854,40 @@ var Evaluator = class {
|
|
|
5849
5854
|
}
|
|
5850
5855
|
});
|
|
5851
5856
|
}
|
|
5857
|
+
/**
|
|
5858
|
+
* Materialize a node and mesh it, caching the mesh by the shape's content key
|
|
5859
|
+
* plus the mesh parameters. The mesh cache is independent of the shape cache:
|
|
5860
|
+
* a hit returns the cached mesh without evaluating or meshing — even after the
|
|
5861
|
+
* shape was LRU-evicted (a mesh is plain data, not a kernel handle). The
|
|
5862
|
+
* returned mesh is borrowed (do not mutate it); it stays valid for the
|
|
5863
|
+
* Evaluator's lifetime, or until `maxMeshCacheEntries` evicts it.
|
|
5864
|
+
*/
|
|
5865
|
+
evaluateMesh(node, env = {}, meshOpts = {}) {
|
|
5866
|
+
meshOpts.signal?.throwIfAborted();
|
|
5867
|
+
const useCache = meshOpts.cache ?? true;
|
|
5868
|
+
const quality = qualityDeflection();
|
|
5869
|
+
const tolerance = meshOpts.tolerance ?? quality.tolerance;
|
|
5870
|
+
const angularTolerance = meshOpts.angularTolerance ?? quality.angularTolerance;
|
|
5871
|
+
const meshKey = `${cacheKey(node, env, this.kernelId, this.defaultTolerance)}|${buildMeshCacheKey(tolerance, angularTolerance, meshOpts.skipNormals ?? false, meshOpts.includeUVs ?? false)}`;
|
|
5872
|
+
if (useCache) {
|
|
5873
|
+
const cached = this.meshCache.get(meshKey);
|
|
5874
|
+
if (cached !== void 0) {
|
|
5875
|
+
if (this.maxMeshCacheEntries !== void 0) {
|
|
5876
|
+
this.meshCache.delete(meshKey);
|
|
5877
|
+
this.meshCache.set(meshKey, cached);
|
|
5878
|
+
}
|
|
5879
|
+
return ok(cached);
|
|
5880
|
+
}
|
|
5881
|
+
}
|
|
5882
|
+
const shape = this.evaluate(node, env);
|
|
5883
|
+
if (!shape.ok) return shape;
|
|
5884
|
+
const built = withKernel(this.kernelId, () => mesh$1(shape.value, meshOpts));
|
|
5885
|
+
if (useCache) {
|
|
5886
|
+
this.meshCache.set(meshKey, built);
|
|
5887
|
+
if (this.maxMeshCacheEntries !== void 0) this.trimMeshCache(this.maxMeshCacheEntries);
|
|
5888
|
+
}
|
|
5889
|
+
return ok(built);
|
|
5890
|
+
}
|
|
5852
5891
|
evaluateInner(node, env) {
|
|
5853
5892
|
const key = cacheKey(node, env, this.kernelId, this.defaultTolerance);
|
|
5854
5893
|
const cached = this.cache.get(key);
|
|
@@ -5901,6 +5940,13 @@ var Evaluator = class {
|
|
|
5901
5940
|
if (shape !== void 0) this.releaseShape(shape);
|
|
5902
5941
|
}
|
|
5903
5942
|
}
|
|
5943
|
+
trimMeshCache(max) {
|
|
5944
|
+
while (this.meshCache.size > max) {
|
|
5945
|
+
const oldest = this.meshCache.keys().next();
|
|
5946
|
+
if (oldest.done) break;
|
|
5947
|
+
this.meshCache.delete(oldest.value);
|
|
5948
|
+
}
|
|
5949
|
+
}
|
|
5904
5950
|
rollbackPending() {
|
|
5905
5951
|
for (const key of this.pendingKeys) {
|
|
5906
5952
|
const shape = this.cache.get(key);
|
|
@@ -5926,6 +5972,7 @@ var Evaluator = class {
|
|
|
5926
5972
|
for (const shape of this.refCounts.keys()) shape[Symbol.dispose]();
|
|
5927
5973
|
this.refCounts.clear();
|
|
5928
5974
|
this.cache.clear();
|
|
5975
|
+
this.meshCache.clear();
|
|
5929
5976
|
}
|
|
5930
5977
|
};
|
|
5931
5978
|
/**
|
|
@@ -6702,4 +6749,4 @@ var csg_exports = /* @__PURE__ */ __exportAll({
|
|
|
6702
6749
|
withEvaluator: () => withEvaluator
|
|
6703
6750
|
});
|
|
6704
6751
|
//#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, 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, isBatchRequest, 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 };
|
|
6752
|
+
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, isBatchRequest, 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, meshLODsProgressive, 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 };
|
package/dist/csg/evaluate.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Result } from '../core/result.js';
|
|
2
2
|
import { AnyShape, Dimension } from '../core/shapeTypes.js';
|
|
3
|
+
import { ShapeMesh, MeshOptions } from '../topology/meshFns.js';
|
|
3
4
|
import { Env } from './expressions.js';
|
|
4
5
|
import { IRNode } from './types.js';
|
|
5
6
|
export interface EvaluatorOptions {
|
|
@@ -21,6 +22,14 @@ export interface EvaluatorOptions {
|
|
|
21
22
|
* (calling it from an onStep callback throws). Must be a positive integer.
|
|
22
23
|
*/
|
|
23
24
|
readonly maxCacheEntries?: number | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Upper bound on entries in the {@link Evaluator.evaluateMesh} content cache,
|
|
27
|
+
* which is independent of the shape cache. Defaults to unbounded. Bounding it
|
|
28
|
+
* separately is what lets a mesh outlive its (evicted) kernel shape, so a
|
|
29
|
+
* re-`evaluateMesh` is a pure data hit with no re-materialization. Must be a
|
|
30
|
+
* positive integer.
|
|
31
|
+
*/
|
|
32
|
+
readonly maxMeshCacheEntries?: number | undefined;
|
|
24
33
|
}
|
|
25
34
|
export interface StepInfo {
|
|
26
35
|
readonly node: IRNode;
|
|
@@ -42,6 +51,8 @@ export declare class Evaluator implements Disposable {
|
|
|
42
51
|
private readonly kernelId;
|
|
43
52
|
private readonly defaultTolerance;
|
|
44
53
|
private readonly maxCacheEntries;
|
|
54
|
+
private readonly maxMeshCacheEntries;
|
|
55
|
+
private readonly meshCache;
|
|
45
56
|
private readonly onStep?;
|
|
46
57
|
private hits;
|
|
47
58
|
private misses;
|
|
@@ -58,9 +69,23 @@ export declare class Evaluator implements Disposable {
|
|
|
58
69
|
* throws.
|
|
59
70
|
*/
|
|
60
71
|
evaluate(node: IRNode, env?: Env): Result<AnyShape<Dimension>>;
|
|
72
|
+
/**
|
|
73
|
+
* Materialize a node and mesh it, caching the mesh by the shape's content key
|
|
74
|
+
* plus the mesh parameters. The mesh cache is independent of the shape cache:
|
|
75
|
+
* a hit returns the cached mesh without evaluating or meshing — even after the
|
|
76
|
+
* shape was LRU-evicted (a mesh is plain data, not a kernel handle). The
|
|
77
|
+
* returned mesh is borrowed (do not mutate it); it stays valid for the
|
|
78
|
+
* Evaluator's lifetime, or until `maxMeshCacheEntries` evicts it.
|
|
79
|
+
*/
|
|
80
|
+
evaluateMesh(node: IRNode, env?: Env, meshOpts?: MeshOptions & {
|
|
81
|
+
skipNormals?: boolean;
|
|
82
|
+
includeUVs?: boolean;
|
|
83
|
+
cache?: boolean;
|
|
84
|
+
}): Result<ShapeMesh>;
|
|
61
85
|
private evaluateInner;
|
|
62
86
|
private releaseShape;
|
|
63
87
|
private trimCache;
|
|
88
|
+
private trimMeshCache;
|
|
64
89
|
private rollbackPending;
|
|
65
90
|
cacheStats(): CacheStats;
|
|
66
91
|
resetStats(): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -92,7 +92,7 @@ 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, meshLODs, type ShapeMesh, type EdgeMesh, type MeshOptions, type MultiLODMesh, type LODMesh, type MeshLODsOptions, } from './topology/meshFns.js';
|
|
95
|
+
export { exportSTEP, exportSTL, exportIGES, meshMultiLOD, meshLODs, meshLODsProgressive, type ShapeMesh, type EdgeMesh, type MeshOptions, type MultiLODMesh, type LODMesh, type MeshLODsOptions, type MeshLODsProgressiveOptions, type MeshLevelFn, } from './topology/meshFns.js';
|
|
96
96
|
export { clearMeshCache, createMeshCache, type MeshCacheContext } from './topology/meshCache.js';
|
|
97
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';
|
package/dist/io.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_meshFns = require("./meshFns-
|
|
2
|
+
const require_meshFns = require("./meshFns-JwMEfMvC.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-
|
|
1
|
+
import { n as exportSTEP, r as exportSTL, t as exportIGES } from "./meshFns-DeGn7mQ4.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 };
|
|
@@ -321,6 +321,24 @@ function boundsDiagonal(shape) {
|
|
|
321
321
|
const dz = b.zMax - b.zMin;
|
|
322
322
|
return Math.sqrt(dx * dx + dy * dy + dz * dz) || 1;
|
|
323
323
|
}
|
|
324
|
+
/** Per-level linear tolerances for a LOD ladder, coarse (large) → fine (small). */
|
|
325
|
+
function lodTolerances(shape, options) {
|
|
326
|
+
let tolerances;
|
|
327
|
+
if (options.tolerances && options.tolerances.length > 0) tolerances = [...options.tolerances];
|
|
328
|
+
else {
|
|
329
|
+
const levels = Math.max(1, Math.floor(options.levels ?? 3));
|
|
330
|
+
const spacing = options.spacing ?? 4;
|
|
331
|
+
const finest = (options.relativeTolerance ?? 5e-4) * boundsDiagonal(shape) || Number.EPSILON;
|
|
332
|
+
tolerances = [];
|
|
333
|
+
for (let i = levels - 1; i >= 0; i--) tolerances.push(finest * spacing ** i);
|
|
334
|
+
}
|
|
335
|
+
tolerances.sort((a, b) => b - a);
|
|
336
|
+
return tolerances;
|
|
337
|
+
}
|
|
338
|
+
/** A level's angular deflection scales with how much coarser it is than the finest (capped at 1 rad). */
|
|
339
|
+
function levelAngular(tolerance, finestTol, finestAngular) {
|
|
340
|
+
return Math.min(finestAngular * (tolerance / finestTol), 1);
|
|
341
|
+
}
|
|
324
342
|
/**
|
|
325
343
|
* Mesh a shape at several levels of detail, coarse → fine.
|
|
326
344
|
*
|
|
@@ -334,22 +352,12 @@ function boundsDiagonal(shape) {
|
|
|
334
352
|
* @see toLODGeometryLevels — convert to THREE.LOD geometry data
|
|
335
353
|
*/
|
|
336
354
|
function meshLODs(shape, options = {}) {
|
|
337
|
-
const
|
|
338
|
-
const finestAngular = options.angularTolerance ?? quality.angularTolerance;
|
|
355
|
+
const finestAngular = options.angularTolerance ?? qualityDeflection().angularTolerance;
|
|
339
356
|
const cache = options.cache ?? true;
|
|
340
|
-
|
|
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);
|
|
357
|
+
const tolerances = lodTolerances(shape, options);
|
|
350
358
|
const finestTol = Math.min(...tolerances);
|
|
351
359
|
return tolerances.map((tolerance) => {
|
|
352
|
-
const angularTolerance =
|
|
360
|
+
const angularTolerance = levelAngular(tolerance, finestTol, finestAngular);
|
|
353
361
|
return {
|
|
354
362
|
tolerance,
|
|
355
363
|
angularTolerance,
|
|
@@ -362,5 +370,58 @@ function meshLODs(shape, options = {}) {
|
|
|
362
370
|
};
|
|
363
371
|
});
|
|
364
372
|
}
|
|
373
|
+
function nextTick() {
|
|
374
|
+
return new Promise((resolve) => {
|
|
375
|
+
setTimeout(resolve, 0);
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Mesh a shape at several levels of detail, delivering them over time coarse →
|
|
380
|
+
* fine instead of all at once — so a viewer paints the coarse preview first and
|
|
381
|
+
* refines as finer levels land.
|
|
382
|
+
*
|
|
383
|
+
* The coarsest level is meshed first and reported via `onLevel`; control then
|
|
384
|
+
* yields to the event loop before each finer (heavier) level so the UI stays
|
|
385
|
+
* responsive. Each level is meshed synchronously on the calling thread by
|
|
386
|
+
* default; pass `meshLevel` to offload finer levels (e.g. to a worker). An
|
|
387
|
+
* aborted `signal` stops refinement and resolves with the levels produced so far.
|
|
388
|
+
*
|
|
389
|
+
* @returns the delivered LOD levels, coarsest → finest.
|
|
390
|
+
* @see meshLODs — the synchronous, all-at-once variant
|
|
391
|
+
*/
|
|
392
|
+
async function meshLODsProgressive(shape, options = {}) {
|
|
393
|
+
const finestAngular = options.angularTolerance ?? qualityDeflection().angularTolerance;
|
|
394
|
+
const cache = options.cache ?? true;
|
|
395
|
+
const meshLevel = options.meshLevel ?? ((s, tolerance, angularTolerance) => mesh(s, {
|
|
396
|
+
tolerance,
|
|
397
|
+
angularTolerance,
|
|
398
|
+
cache,
|
|
399
|
+
...options.signal ? { signal: options.signal } : {}
|
|
400
|
+
}));
|
|
401
|
+
const tolerances = lodTolerances(shape, options);
|
|
402
|
+
const finestTol = Math.min(...tolerances);
|
|
403
|
+
const results = [];
|
|
404
|
+
for (const [index, tolerance] of tolerances.entries()) {
|
|
405
|
+
if (options.signal?.aborted) break;
|
|
406
|
+
const angularTolerance = levelAngular(tolerance, finestTol, finestAngular);
|
|
407
|
+
let levelMesh;
|
|
408
|
+
try {
|
|
409
|
+
levelMesh = await meshLevel(shape, tolerance, angularTolerance);
|
|
410
|
+
} catch (e) {
|
|
411
|
+
if (options.signal?.aborted) break;
|
|
412
|
+
throw e;
|
|
413
|
+
}
|
|
414
|
+
const level = {
|
|
415
|
+
tolerance,
|
|
416
|
+
angularTolerance,
|
|
417
|
+
mesh: levelMesh
|
|
418
|
+
};
|
|
419
|
+
results.push(level);
|
|
420
|
+
options.onLevel?.(level, index);
|
|
421
|
+
if (options.signal?.aborted || index === tolerances.length - 1) break;
|
|
422
|
+
await nextTick();
|
|
423
|
+
}
|
|
424
|
+
return results;
|
|
425
|
+
}
|
|
365
426
|
//#endregion
|
|
366
|
-
export { meshEdges as a,
|
|
427
|
+
export { meshEdges as a, meshMultiLOD as c, createMeshCache as d, mesh as i, buildMeshCacheKey as l, exportSTEP as n, meshLODs as o, exportSTL as r, meshLODsProgressive as s, exportIGES as t, clearMeshCache as u };
|
|
@@ -321,6 +321,24 @@ function boundsDiagonal(shape) {
|
|
|
321
321
|
const dz = b.zMax - b.zMin;
|
|
322
322
|
return Math.sqrt(dx * dx + dy * dy + dz * dz) || 1;
|
|
323
323
|
}
|
|
324
|
+
/** Per-level linear tolerances for a LOD ladder, coarse (large) → fine (small). */
|
|
325
|
+
function lodTolerances(shape, options) {
|
|
326
|
+
let tolerances;
|
|
327
|
+
if (options.tolerances && options.tolerances.length > 0) tolerances = [...options.tolerances];
|
|
328
|
+
else {
|
|
329
|
+
const levels = Math.max(1, Math.floor(options.levels ?? 3));
|
|
330
|
+
const spacing = options.spacing ?? 4;
|
|
331
|
+
const finest = (options.relativeTolerance ?? 5e-4) * boundsDiagonal(shape) || Number.EPSILON;
|
|
332
|
+
tolerances = [];
|
|
333
|
+
for (let i = levels - 1; i >= 0; i--) tolerances.push(finest * spacing ** i);
|
|
334
|
+
}
|
|
335
|
+
tolerances.sort((a, b) => b - a);
|
|
336
|
+
return tolerances;
|
|
337
|
+
}
|
|
338
|
+
/** A level's angular deflection scales with how much coarser it is than the finest (capped at 1 rad). */
|
|
339
|
+
function levelAngular(tolerance, finestTol, finestAngular) {
|
|
340
|
+
return Math.min(finestAngular * (tolerance / finestTol), 1);
|
|
341
|
+
}
|
|
324
342
|
/**
|
|
325
343
|
* Mesh a shape at several levels of detail, coarse → fine.
|
|
326
344
|
*
|
|
@@ -334,22 +352,12 @@ function boundsDiagonal(shape) {
|
|
|
334
352
|
* @see toLODGeometryLevels — convert to THREE.LOD geometry data
|
|
335
353
|
*/
|
|
336
354
|
function meshLODs(shape, options = {}) {
|
|
337
|
-
const
|
|
338
|
-
const finestAngular = options.angularTolerance ?? quality.angularTolerance;
|
|
355
|
+
const finestAngular = options.angularTolerance ?? require_shapeTypes.qualityDeflection().angularTolerance;
|
|
339
356
|
const cache = options.cache ?? true;
|
|
340
|
-
|
|
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);
|
|
357
|
+
const tolerances = lodTolerances(shape, options);
|
|
350
358
|
const finestTol = Math.min(...tolerances);
|
|
351
359
|
return tolerances.map((tolerance) => {
|
|
352
|
-
const angularTolerance =
|
|
360
|
+
const angularTolerance = levelAngular(tolerance, finestTol, finestAngular);
|
|
353
361
|
return {
|
|
354
362
|
tolerance,
|
|
355
363
|
angularTolerance,
|
|
@@ -362,7 +370,66 @@ function meshLODs(shape, options = {}) {
|
|
|
362
370
|
};
|
|
363
371
|
});
|
|
364
372
|
}
|
|
373
|
+
function nextTick() {
|
|
374
|
+
return new Promise((resolve) => {
|
|
375
|
+
setTimeout(resolve, 0);
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Mesh a shape at several levels of detail, delivering them over time coarse →
|
|
380
|
+
* fine instead of all at once — so a viewer paints the coarse preview first and
|
|
381
|
+
* refines as finer levels land.
|
|
382
|
+
*
|
|
383
|
+
* The coarsest level is meshed first and reported via `onLevel`; control then
|
|
384
|
+
* yields to the event loop before each finer (heavier) level so the UI stays
|
|
385
|
+
* responsive. Each level is meshed synchronously on the calling thread by
|
|
386
|
+
* default; pass `meshLevel` to offload finer levels (e.g. to a worker). An
|
|
387
|
+
* aborted `signal` stops refinement and resolves with the levels produced so far.
|
|
388
|
+
*
|
|
389
|
+
* @returns the delivered LOD levels, coarsest → finest.
|
|
390
|
+
* @see meshLODs — the synchronous, all-at-once variant
|
|
391
|
+
*/
|
|
392
|
+
async function meshLODsProgressive(shape, options = {}) {
|
|
393
|
+
const finestAngular = options.angularTolerance ?? require_shapeTypes.qualityDeflection().angularTolerance;
|
|
394
|
+
const cache = options.cache ?? true;
|
|
395
|
+
const meshLevel = options.meshLevel ?? ((s, tolerance, angularTolerance) => mesh(s, {
|
|
396
|
+
tolerance,
|
|
397
|
+
angularTolerance,
|
|
398
|
+
cache,
|
|
399
|
+
...options.signal ? { signal: options.signal } : {}
|
|
400
|
+
}));
|
|
401
|
+
const tolerances = lodTolerances(shape, options);
|
|
402
|
+
const finestTol = Math.min(...tolerances);
|
|
403
|
+
const results = [];
|
|
404
|
+
for (const [index, tolerance] of tolerances.entries()) {
|
|
405
|
+
if (options.signal?.aborted) break;
|
|
406
|
+
const angularTolerance = levelAngular(tolerance, finestTol, finestAngular);
|
|
407
|
+
let levelMesh;
|
|
408
|
+
try {
|
|
409
|
+
levelMesh = await meshLevel(shape, tolerance, angularTolerance);
|
|
410
|
+
} catch (e) {
|
|
411
|
+
if (options.signal?.aborted) break;
|
|
412
|
+
throw e;
|
|
413
|
+
}
|
|
414
|
+
const level = {
|
|
415
|
+
tolerance,
|
|
416
|
+
angularTolerance,
|
|
417
|
+
mesh: levelMesh
|
|
418
|
+
};
|
|
419
|
+
results.push(level);
|
|
420
|
+
options.onLevel?.(level, index);
|
|
421
|
+
if (options.signal?.aborted || index === tolerances.length - 1) break;
|
|
422
|
+
await nextTick();
|
|
423
|
+
}
|
|
424
|
+
return results;
|
|
425
|
+
}
|
|
365
426
|
//#endregion
|
|
427
|
+
Object.defineProperty(exports, "buildMeshCacheKey", {
|
|
428
|
+
enumerable: true,
|
|
429
|
+
get: function() {
|
|
430
|
+
return buildMeshCacheKey;
|
|
431
|
+
}
|
|
432
|
+
});
|
|
366
433
|
Object.defineProperty(exports, "clearMeshCache", {
|
|
367
434
|
enumerable: true,
|
|
368
435
|
get: function() {
|
|
@@ -411,6 +478,12 @@ Object.defineProperty(exports, "meshLODs", {
|
|
|
411
478
|
return meshLODs;
|
|
412
479
|
}
|
|
413
480
|
});
|
|
481
|
+
Object.defineProperty(exports, "meshLODsProgressive", {
|
|
482
|
+
enumerable: true,
|
|
483
|
+
get: function() {
|
|
484
|
+
return meshLODsProgressive;
|
|
485
|
+
}
|
|
486
|
+
});
|
|
414
487
|
Object.defineProperty(exports, "meshMultiLOD", {
|
|
415
488
|
enumerable: true,
|
|
416
489
|
get: function() {
|
|
@@ -139,3 +139,34 @@ export interface MeshLODsOptions {
|
|
|
139
139
|
* @see toLODGeometryLevels — convert to THREE.LOD geometry data
|
|
140
140
|
*/
|
|
141
141
|
export declare function meshLODs(shape: AnyShape<Dimension>, options?: MeshLODsOptions): LODMesh[];
|
|
142
|
+
/**
|
|
143
|
+
* Mesh one LOD level. Defaults to the synchronous main-thread {@link mesh}; pass
|
|
144
|
+
* an async implementation (e.g. one that serializes the shape with `toBREP` and
|
|
145
|
+
* meshes it on a worker) to refine finer levels off the main thread.
|
|
146
|
+
*/
|
|
147
|
+
export type MeshLevelFn = (shape: AnyShape<Dimension>, tolerance: number, angularTolerance: number) => ShapeMesh | Promise<ShapeMesh>;
|
|
148
|
+
/** Options for {@link meshLODsProgressive}. */
|
|
149
|
+
export interface MeshLODsProgressiveOptions extends MeshLODsOptions {
|
|
150
|
+
/**
|
|
151
|
+
* Called as each level finishes, coarsest first, so a viewer can show the
|
|
152
|
+
* coarse preview immediately and swap in finer meshes as they arrive.
|
|
153
|
+
*/
|
|
154
|
+
readonly onLevel?: (level: LODMesh, index: number) => void;
|
|
155
|
+
/** How to mesh one level. Defaults to the synchronous main-thread {@link mesh}. */
|
|
156
|
+
readonly meshLevel?: MeshLevelFn;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Mesh a shape at several levels of detail, delivering them over time coarse →
|
|
160
|
+
* fine instead of all at once — so a viewer paints the coarse preview first and
|
|
161
|
+
* refines as finer levels land.
|
|
162
|
+
*
|
|
163
|
+
* The coarsest level is meshed first and reported via `onLevel`; control then
|
|
164
|
+
* yields to the event loop before each finer (heavier) level so the UI stays
|
|
165
|
+
* responsive. Each level is meshed synchronously on the calling thread by
|
|
166
|
+
* default; pass `meshLevel` to offload finer levels (e.g. to a worker). An
|
|
167
|
+
* aborted `signal` stops refinement and resolves with the levels produced so far.
|
|
168
|
+
*
|
|
169
|
+
* @returns the delivered LOD levels, coarsest → finest.
|
|
170
|
+
* @see meshLODs — the synchronous, all-at-once variant
|
|
171
|
+
*/
|
|
172
|
+
export declare function meshLODsProgressive(shape: AnyShape<Dimension>, options?: MeshLODsProgressiveOptions): Promise<LODMesh[]>;
|
package/dist/topology.cjs
CHANGED
|
@@ -3,7 +3,7 @@ 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-
|
|
6
|
+
const require_meshFns = require("./meshFns-JwMEfMvC.cjs");
|
|
7
7
|
const require_solidBuilders = require("./solidBuilders-CgRmJEdn.cjs");
|
|
8
8
|
const require_healingFns = require("./healingFns-OL0bBSSY.cjs");
|
|
9
9
|
const require_primitiveFns = require("./primitiveFns-BAWtMd9H.cjs");
|
package/dist/topology.js
CHANGED
|
@@ -2,7 +2,7 @@ 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 {
|
|
5
|
+
import { d as createMeshCache, n as exportSTEP, r as exportSTL, t as exportIGES, u as clearMeshCache } from "./meshFns-DeGn7mQ4.js";
|
|
6
6
|
import { h as fuseAll, p as cutAll } from "./solidBuilders-Biwv2cW3.js";
|
|
7
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";
|