brepjs 18.67.0 → 18.69.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 +365 -50
- package/dist/brepjs.js +358 -59
- package/dist/implicit/index.d.ts +13 -0
- package/dist/implicit/sdfFns.d.ts +136 -0
- package/dist/index.d.ts +2 -0
- package/dist/voxel/engine.d.ts +104 -0
- package/dist/voxel/fieldFns.d.ts +1 -0
- package/package.json +1 -1
package/dist/brepjs.js
CHANGED
|
@@ -14,7 +14,7 @@ import { a as meshEdges$1, c as createMeshCache, i as mesh$1, n as exportSTEP, o
|
|
|
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-jx81G_YJ.js";
|
|
16
16
|
import { a as fuseAll, c as sectionToFace$1, i as fuse$2, l as slice$1, n as cut$2, o as intersect$2, r as cutAll, s as section$1, t as booleanPipeline, u as split$1 } from "./booleanFns-CaKngiuu.js";
|
|
17
|
-
import { $ as fuseAllBisect, A as fixShape, B as offset$1, C as threePointArc, D as wireLoop, E as wire, F as isValid$1, G as chamferWithEvolution, H as thicken$1, I as solidFromShell, J as fuseWithEvolution, K as cutWithEvolution, L as chamfer$1, M as healFace, N as healSolid, O as autoHeal, P as healWire, Q as cutAllBisect, R as draft$1, S as tangentArc, T as vertex, U as variableFillet, V as shell$1, W as positionOnCurve, X as shellWithEvolution, Y as intersectWithEvolution, Z as checkBoolean, _ as polygon, a as circle, at as sharedEdges, b as sphere, c as cylinder, ct as chamferDistAngle, d as ellipsoid, dt as toLODGeometryData, et as getNurbsCurveData, f as face, ft as toLineGeometryData, g as offsetFace, h as line, i as bsplineApprox, it as facesOfEdge, j as heal$1, k as fixSelfIntersection, l as ellipse, lt as toBufferGeometryData, m as helix, n as bezier, nt as adjacentFaces, o as compound, ot as verticesOfEdge, p as filledFace, q as filletWithEvolution, r as box, rt as edgesOfFace, s as cone, st as wiresOfFace, t as addHoles, tt as getNurbsSurfaceData, u as ellipseArc, ut as toGroupedBufferGeometryData, v as sewShells, w as torus, x as subFace, y as solid, z as fillet$1 } from "./primitiveFns-ecKWNC5k.js";
|
|
17
|
+
import { $ as fuseAllBisect, A as fixShape, B as offset$1, C as threePointArc, D as wireLoop, E as wire, F as isValid$1, G as chamferWithEvolution, H as thicken$1, I as solidFromShell, J as fuseWithEvolution, K as cutWithEvolution, L as chamfer$1, M as healFace, N as healSolid, O as autoHeal, P as healWire, Q as cutAllBisect, R as draft$1, S as tangentArc, T as vertex, U as variableFillet, V as shell$1, W as positionOnCurve, X as shellWithEvolution, Y as intersectWithEvolution, Z as checkBoolean, _ as polygon, a as circle, at as sharedEdges, b as sphere$1, c as cylinder, ct as chamferDistAngle, d as ellipsoid, dt as toLODGeometryData, et as getNurbsCurveData, f as face, ft as toLineGeometryData, g as offsetFace, h as line, i as bsplineApprox, it as facesOfEdge, j as heal$1, k as fixSelfIntersection, l as ellipse, lt as toBufferGeometryData, m as helix, n as bezier, nt as adjacentFaces, o as compound, ot as verticesOfEdge, p as filledFace, q as filletWithEvolution, r as box, rt as edgesOfFace, s as cone, st as wiresOfFace, t as addHoles, tt as getNurbsSurfaceData, u as ellipseArc, ut as toGroupedBufferGeometryData, v as sewShells, w as torus$1, x as subFace, y as solid, z as fillet$1 } from "./primitiveFns-ecKWNC5k.js";
|
|
18
18
|
import { C as walkAssembly, D as exportAssemblySTEP, E as linearPattern, O as createAssembly, S as updateNode, _ as collectShapes, a as findStep, b as findNode, c as registerOperation, d as replayHistory, f as serializeHistory, g as addChild, h as undoLast, i as deserializeHistory, l as registerShape, m as stepsFrom, n as createHistory, o as getShape, p as stepCount, r as createRegistry, s as modifyStep, t as addStep, u as replayFrom, v as countNodes, w as circularPattern, x as removeChild, y as createAssemblyNode } from "./historyFns-CZ9oNL7j.js";
|
|
19
19
|
import { n as BaseSketcher2d, r as organiseBlueprints, t as BlueprintSketcher } from "./blueprintSketcher-0DeTMXwj.js";
|
|
20
20
|
import { a as createTypedFinder, i as wireFinder, n as edgeFinder, r as faceFinder, t as getSingleFace } from "./helpers-BX-0e71G.js";
|
|
@@ -25,7 +25,7 @@ import { t as cornerFinder } from "./cornerFinder-B8GvvW0U.js";
|
|
|
25
25
|
import { a as fuseBlueprints, c as roundedRectangleBlueprint, i as cutBlueprints, n as fuse2D, o as intersectBlueprints, r as intersect2D, s as polysidesBlueprint, t as cut2D } from "./boolean2D-BNWuFXK_.js";
|
|
26
26
|
import { S as reverseCurve, _ as curve2dIsOnCurve, a as isInside2D, b as curve2dSplitAt, c as scale2D, d as stretch2D, f as toSVGPathD, g as curve2dFirstPoint, h as curve2dDistanceFrom, i as getOrientation2D, l as sketchOnFace2D, m as curve2dBoundingBox, n as createCompoundBlueprint, o as mirror2D, p as translate2D, r as getBounds2D, s as rotate2D, t as createBlueprint, u as sketchOnPlane2D, v as curve2dLastPoint, x as curve2dTangentAt, y as curve2dParameter } from "./blueprintFns-BNhsXv6q.js";
|
|
27
27
|
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-1SHLSNtG.js";
|
|
28
|
-
import { a as guidedSweep, c as sweep, i as complexExtrude, l as twistExtrude, n as extrudeAll, o as multiSectionSweep, r as revolve$1, s as supportExtrude, t as extrude$1 } from "./extrudeFns-CMr1tf7I.js";
|
|
28
|
+
import { a as guidedSweep, c as sweep$1, i as complexExtrude, l as twistExtrude, n as extrudeAll, o as multiSectionSweep, r as revolve$1, s as supportExtrude, t as extrude$1 } from "./extrudeFns-CMr1tf7I.js";
|
|
29
29
|
import { a as Sketch, b as loftAll, c as compoundSketchLoft, d as sketchFace, f as sketchLoft, h as sketchWires, i as Sketches, l as compoundSketchRevolve, m as sketchSweep, n as getFont, o as compoundSketchExtrude, p as sketchRevolve, r as loadFont, s as compoundSketchFace, t as textBlueprints, u as sketchExtrude, v as CompoundSketch, y as loft$1 } from "./textBlueprints-BXGrW7Ak.js";
|
|
30
30
|
import { a as makeProjectedEdges, i as projectEdges, n as cameraLookAt, r as createCamera, s as isProjectionPlane, t as cameraFromPlane } from "./cameraFns-k787od3u.js";
|
|
31
31
|
import { n as textMetrics, r as sketchText, t as fontMetrics } from "./textMetrics-V7TXOETY.js";
|
|
@@ -193,7 +193,7 @@ function validateInputs(mesh, queries) {
|
|
|
193
193
|
return null;
|
|
194
194
|
}
|
|
195
195
|
/** Resolve a registered voxel engine, mapping an unregistered id to an error. */
|
|
196
|
-
function resolveEngine(id) {
|
|
196
|
+
function resolveEngine$1(id) {
|
|
197
197
|
try {
|
|
198
198
|
return ok(getVoxel(id));
|
|
199
199
|
} catch (cause) {
|
|
@@ -210,7 +210,7 @@ function resolveEngine(id) {
|
|
|
210
210
|
function windingNumbers(mesh, queries, id) {
|
|
211
211
|
const invalid = validateInputs(mesh, queries);
|
|
212
212
|
if (invalid) return err(invalid);
|
|
213
|
-
const engine = resolveEngine(id);
|
|
213
|
+
const engine = resolveEngine$1(id);
|
|
214
214
|
if (isErr(engine)) return engine;
|
|
215
215
|
return ok(engine.value.winding_numbers(mesh.vertices, mesh.triangles, queries));
|
|
216
216
|
}
|
|
@@ -222,15 +222,15 @@ function windingNumbers(mesh, queries, id) {
|
|
|
222
222
|
function pointsInside(mesh, queries, id) {
|
|
223
223
|
const invalid = validateInputs(mesh, queries);
|
|
224
224
|
if (invalid) return err(invalid);
|
|
225
|
-
const engine = resolveEngine(id);
|
|
225
|
+
const engine = resolveEngine$1(id);
|
|
226
226
|
if (isErr(engine)) return engine;
|
|
227
227
|
const flags = engine.value.points_inside(mesh.vertices, mesh.triangles, queries);
|
|
228
228
|
return ok(Array.from(flags, (flag) => flag === 1));
|
|
229
229
|
}
|
|
230
230
|
//#endregion
|
|
231
231
|
//#region src/voxel/repairFns.ts
|
|
232
|
-
var DEFAULT_RESOLUTION$
|
|
233
|
-
var DEFAULT_PADDING$
|
|
232
|
+
var DEFAULT_RESOLUTION$4 = 48;
|
|
233
|
+
var DEFAULT_PADDING$4 = 2;
|
|
234
234
|
/**
|
|
235
235
|
* Repair a (possibly non-watertight) triangle-soup mesh into a closed surface:
|
|
236
236
|
* voxelize an FWN-signed SDF, then Surface-Nets contour it back to triangles.
|
|
@@ -243,11 +243,11 @@ function repairMesh(mesh, opts, id) {
|
|
|
243
243
|
const invalid = validateMesh(mesh);
|
|
244
244
|
if (invalid) return err(invalid);
|
|
245
245
|
if (mesh.vertices.length === 0 || mesh.triangles.length === 0) return err(validationError("VOXEL_EMPTY_MESH", "repairMesh requires a non-empty triangle mesh."));
|
|
246
|
-
const resolution = opts?.resolution ?? DEFAULT_RESOLUTION$
|
|
247
|
-
const padding = opts?.padding ?? DEFAULT_PADDING$
|
|
246
|
+
const resolution = opts?.resolution ?? DEFAULT_RESOLUTION$4;
|
|
247
|
+
const padding = opts?.padding ?? DEFAULT_PADDING$4;
|
|
248
248
|
if (!Number.isInteger(resolution) || resolution < 1) return err(validationError("VOXEL_INVALID_RESOLUTION", "resolution must be an integer >= 1."));
|
|
249
249
|
if (!Number.isInteger(padding) || padding < 1) return err(validationError("VOXEL_INVALID_PADDING", "padding must be an integer >= 1."));
|
|
250
|
-
const engine = resolveEngine(id);
|
|
250
|
+
const engine = resolveEngine$1(id);
|
|
251
251
|
if (isErr(engine)) return engine;
|
|
252
252
|
try {
|
|
253
253
|
try {
|
|
@@ -297,16 +297,16 @@ function shapeToMeshInput(shape, deflection = DEFAULT_DEFLECTION) {
|
|
|
297
297
|
}
|
|
298
298
|
//#endregion
|
|
299
299
|
//#region src/voxel/meshOpsFns.ts
|
|
300
|
-
var DEFAULT_RESOLUTION$
|
|
301
|
-
var DEFAULT_PADDING$
|
|
300
|
+
var DEFAULT_RESOLUTION$3 = 48;
|
|
301
|
+
var DEFAULT_PADDING$3 = 2;
|
|
302
302
|
var BOOLEAN_OP_CODES$1 = {
|
|
303
303
|
union: 0,
|
|
304
304
|
intersection: 1,
|
|
305
305
|
difference: 2
|
|
306
306
|
};
|
|
307
|
-
function resolveGridParams$
|
|
308
|
-
const resolution = opts?.resolution ?? DEFAULT_RESOLUTION$
|
|
309
|
-
const padding = opts?.padding ?? DEFAULT_PADDING$
|
|
307
|
+
function resolveGridParams$2(opts) {
|
|
308
|
+
const resolution = opts?.resolution ?? DEFAULT_RESOLUTION$3;
|
|
309
|
+
const padding = opts?.padding ?? DEFAULT_PADDING$3;
|
|
310
310
|
if (!Number.isInteger(resolution) || resolution < 1) return err(validationError("VOXEL_INVALID_RESOLUTION", "resolution must be an integer >= 1."));
|
|
311
311
|
if (!Number.isInteger(padding) || padding < 1) return err(validationError("VOXEL_INVALID_PADDING", "padding must be an integer >= 1."));
|
|
312
312
|
return ok({
|
|
@@ -341,9 +341,9 @@ function offsetMesh(mesh, distance, opts, id) {
|
|
|
341
341
|
if (invalid) return err(invalid);
|
|
342
342
|
if (mesh.vertices.length === 0 || mesh.triangles.length === 0) return err(validationError("VOXEL_EMPTY_MESH", "offsetMesh requires a non-empty triangle mesh."));
|
|
343
343
|
if (!Number.isFinite(distance)) return err(validationError("VOXEL_INVALID_DISTANCE", "distance must be a finite number."));
|
|
344
|
-
const params = resolveGridParams$
|
|
344
|
+
const params = resolveGridParams$2(opts);
|
|
345
345
|
if (isErr(params)) return params;
|
|
346
|
-
const engine = resolveEngine(id);
|
|
346
|
+
const engine = resolveEngine$1(id);
|
|
347
347
|
if (isErr(engine)) return engine;
|
|
348
348
|
try {
|
|
349
349
|
try {
|
|
@@ -370,9 +370,9 @@ function shellMesh(mesh, thickness, opts, id) {
|
|
|
370
370
|
if (invalid) return err(invalid);
|
|
371
371
|
if (mesh.vertices.length === 0 || mesh.triangles.length === 0) return err(validationError("VOXEL_EMPTY_MESH", "shellMesh requires a non-empty triangle mesh."));
|
|
372
372
|
if (!Number.isFinite(thickness) || thickness <= 0) return err(validationError("VOXEL_INVALID_THICKNESS", "thickness must be a finite number > 0."));
|
|
373
|
-
const params = resolveGridParams$
|
|
373
|
+
const params = resolveGridParams$2(opts);
|
|
374
374
|
if (isErr(params)) return params;
|
|
375
|
-
const engine = resolveEngine(id);
|
|
375
|
+
const engine = resolveEngine$1(id);
|
|
376
376
|
if (isErr(engine)) return engine;
|
|
377
377
|
try {
|
|
378
378
|
try {
|
|
@@ -402,9 +402,9 @@ function voxelBoolean(a, b, op, opts, id) {
|
|
|
402
402
|
if (a.vertices.length === 0 || a.triangles.length === 0) return err(validationError("VOXEL_EMPTY_MESH", "voxelBoolean requires a non-empty mesh for operand A."));
|
|
403
403
|
if (b.vertices.length === 0 || b.triangles.length === 0) return err(validationError("VOXEL_EMPTY_MESH", "voxelBoolean requires a non-empty mesh for operand B."));
|
|
404
404
|
const opCode = BOOLEAN_OP_CODES$1[op];
|
|
405
|
-
const params = resolveGridParams$
|
|
405
|
+
const params = resolveGridParams$2(opts);
|
|
406
406
|
if (isErr(params)) return params;
|
|
407
|
-
const engine = resolveEngine(id);
|
|
407
|
+
const engine = resolveEngine$1(id);
|
|
408
408
|
if (isErr(engine)) return engine;
|
|
409
409
|
try {
|
|
410
410
|
try {
|
|
@@ -453,16 +453,16 @@ function voxelBooleanShapes(a, b, op, opts, id) {
|
|
|
453
453
|
}
|
|
454
454
|
//#endregion
|
|
455
455
|
//#region src/voxel/fieldFns.ts
|
|
456
|
-
var DEFAULT_RESOLUTION$
|
|
457
|
-
var DEFAULT_PADDING$
|
|
456
|
+
var DEFAULT_RESOLUTION$2 = 48;
|
|
457
|
+
var DEFAULT_PADDING$2 = 2;
|
|
458
458
|
var BOOLEAN_OP_CODES = {
|
|
459
459
|
union: 0,
|
|
460
460
|
intersection: 1,
|
|
461
461
|
difference: 2
|
|
462
462
|
};
|
|
463
|
-
function resolveGridParams(opts) {
|
|
464
|
-
const resolution = opts?.resolution ?? DEFAULT_RESOLUTION$
|
|
465
|
-
const padding = opts?.padding ?? DEFAULT_PADDING$
|
|
463
|
+
function resolveGridParams$1(opts) {
|
|
464
|
+
const resolution = opts?.resolution ?? DEFAULT_RESOLUTION$2;
|
|
465
|
+
const padding = opts?.padding ?? DEFAULT_PADDING$2;
|
|
466
466
|
if (!Number.isInteger(resolution) || resolution < 1) return err(validationError("VOXEL_INVALID_RESOLUTION", "resolution must be an integer >= 1."));
|
|
467
467
|
if (!Number.isInteger(padding) || padding < 1) return err(validationError("VOXEL_INVALID_PADDING", "padding must be an integer >= 1."));
|
|
468
468
|
return ok({
|
|
@@ -512,6 +512,9 @@ function fieldDeletable(raw) {
|
|
|
512
512
|
}
|
|
513
513
|
};
|
|
514
514
|
}
|
|
515
|
+
function makeFieldHandle(raw) {
|
|
516
|
+
return makeHandle(raw);
|
|
517
|
+
}
|
|
515
518
|
function makeHandle(raw) {
|
|
516
519
|
const inner = createKernelHandle(fieldDeletable(raw));
|
|
517
520
|
const handle = {
|
|
@@ -568,9 +571,9 @@ function voxelField(mesh, opts, id) {
|
|
|
568
571
|
const invalid = validateMesh(mesh);
|
|
569
572
|
if (invalid) return err(invalid);
|
|
570
573
|
if (mesh.vertices.length === 0 || mesh.triangles.length === 0) return err(validationError("VOXEL_EMPTY_MESH", "voxelField requires a non-empty triangle mesh."));
|
|
571
|
-
const params = resolveGridParams(opts);
|
|
574
|
+
const params = resolveGridParams$1(opts);
|
|
572
575
|
if (isErr(params)) return params;
|
|
573
|
-
const engine = resolveEngine(id);
|
|
576
|
+
const engine = resolveEngine$1(id);
|
|
574
577
|
if (isErr(engine)) return engine;
|
|
575
578
|
try {
|
|
576
579
|
return ok(makeHandle(new engine.value.VoxelField(mesh.vertices, mesh.triangles, params.value.resolution, params.value.padding)));
|
|
@@ -597,9 +600,9 @@ function voxelBooleanField(a, b, op, opts, id) {
|
|
|
597
600
|
if (invalidB) return err(invalidB);
|
|
598
601
|
if (a.vertices.length === 0 || a.triangles.length === 0) return err(validationError("VOXEL_EMPTY_MESH", "voxelBooleanField requires a non-empty mesh for operand A."));
|
|
599
602
|
if (b.vertices.length === 0 || b.triangles.length === 0) return err(validationError("VOXEL_EMPTY_MESH", "voxelBooleanField requires a non-empty mesh for operand B."));
|
|
600
|
-
const params = resolveGridParams(opts);
|
|
603
|
+
const params = resolveGridParams$1(opts);
|
|
601
604
|
if (isErr(params)) return params;
|
|
602
|
-
const engine = resolveEngine(id);
|
|
605
|
+
const engine = resolveEngine$1(id);
|
|
603
606
|
if (isErr(engine)) return engine;
|
|
604
607
|
try {
|
|
605
608
|
return ok(makeHandle(engine.value.VoxelField.boolean_of(a.vertices, a.triangles, b.vertices, b.triangles, BOOLEAN_OP_CODES[op], params.value.resolution, params.value.padding)));
|
|
@@ -709,6 +712,302 @@ function voxelBooleanFieldShapes(a, b, op, opts, id) {
|
|
|
709
712
|
return voxelBooleanField(meshA.value, meshB.value, op, opts, id);
|
|
710
713
|
}
|
|
711
714
|
//#endregion
|
|
715
|
+
//#region src/implicit/sdfFns.ts
|
|
716
|
+
var DEFAULT_RESOLUTION$1 = 48;
|
|
717
|
+
var DEFAULT_PADDING$1 = 2;
|
|
718
|
+
function resolveEngine(id) {
|
|
719
|
+
try {
|
|
720
|
+
return ok(getVoxel(id));
|
|
721
|
+
} catch (cause) {
|
|
722
|
+
return err(moduleInitError("VOXEL_NOT_INITIALIZED", cause instanceof Error ? cause.message : "voxel engine not initialized", cause));
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
function resolveGridParams(opts) {
|
|
726
|
+
const resolution = opts?.resolution ?? DEFAULT_RESOLUTION$1;
|
|
727
|
+
const padding = opts?.padding ?? DEFAULT_PADDING$1;
|
|
728
|
+
if (!Number.isInteger(resolution) || resolution < 1) return err(validationError("SDF_INVALID_RESOLUTION", "resolution must be an integer >= 1."));
|
|
729
|
+
if (!Number.isInteger(padding) || padding < 1) return err(validationError("SDF_INVALID_PADDING", "padding must be an integer >= 1."));
|
|
730
|
+
return ok({
|
|
731
|
+
resolution,
|
|
732
|
+
padding
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
function sdfDeletable(raw) {
|
|
736
|
+
return {
|
|
737
|
+
raw,
|
|
738
|
+
delete() {
|
|
739
|
+
raw.free();
|
|
740
|
+
}
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
/** The position-modulated operator methods, split out to keep {@link makeSdfHandle}
|
|
744
|
+
* under the per-function line cap. `this` binds to the owning {@link SdfHandle} when
|
|
745
|
+
* spread into its object literal. */
|
|
746
|
+
var MODULATED_FIELD_METHODS = {
|
|
747
|
+
offsetField(field) {
|
|
748
|
+
return makeSdfHandle(this.value.offset_field(field.value));
|
|
749
|
+
},
|
|
750
|
+
roundField(field) {
|
|
751
|
+
return makeSdfHandle(this.value.round_field(field.value));
|
|
752
|
+
},
|
|
753
|
+
shellField(field) {
|
|
754
|
+
return makeSdfHandle(this.value.shell_field(field.value));
|
|
755
|
+
},
|
|
756
|
+
smoothUnionField(other, field) {
|
|
757
|
+
return makeSdfHandle(this.value.smooth_union_field(other.value, field.value));
|
|
758
|
+
}
|
|
759
|
+
};
|
|
760
|
+
function makeSdfHandle(raw) {
|
|
761
|
+
const inner = createKernelHandle(sdfDeletable(raw));
|
|
762
|
+
return {
|
|
763
|
+
get value() {
|
|
764
|
+
return inner.value.raw;
|
|
765
|
+
},
|
|
766
|
+
get disposed() {
|
|
767
|
+
return inner.disposed;
|
|
768
|
+
},
|
|
769
|
+
[Symbol.dispose]() {
|
|
770
|
+
inner[Symbol.dispose]();
|
|
771
|
+
},
|
|
772
|
+
union(other) {
|
|
773
|
+
return makeSdfHandle(this.value.union(other.value));
|
|
774
|
+
},
|
|
775
|
+
intersection(other) {
|
|
776
|
+
return makeSdfHandle(this.value.intersection(other.value));
|
|
777
|
+
},
|
|
778
|
+
difference(other) {
|
|
779
|
+
return makeSdfHandle(this.value.difference(other.value));
|
|
780
|
+
},
|
|
781
|
+
smoothUnion(other, k) {
|
|
782
|
+
return makeSdfHandle(this.value.smooth_union(other.value, k));
|
|
783
|
+
},
|
|
784
|
+
smoothIntersection(other, k) {
|
|
785
|
+
return makeSdfHandle(this.value.smooth_intersection(other.value, k));
|
|
786
|
+
},
|
|
787
|
+
smoothDifference(other, k) {
|
|
788
|
+
return makeSdfHandle(this.value.smooth_difference(other.value, k));
|
|
789
|
+
},
|
|
790
|
+
offset(distance) {
|
|
791
|
+
return makeSdfHandle(this.value.offset(distance));
|
|
792
|
+
},
|
|
793
|
+
round(radius) {
|
|
794
|
+
return makeSdfHandle(this.value.round(radius));
|
|
795
|
+
},
|
|
796
|
+
shell(thickness) {
|
|
797
|
+
return makeSdfHandle(this.value.shell(thickness));
|
|
798
|
+
},
|
|
799
|
+
onion(thickness) {
|
|
800
|
+
return makeSdfHandle(this.value.onion(thickness));
|
|
801
|
+
},
|
|
802
|
+
...MODULATED_FIELD_METHODS,
|
|
803
|
+
translate(x, y, z) {
|
|
804
|
+
return makeSdfHandle(this.value.translate(x, y, z));
|
|
805
|
+
},
|
|
806
|
+
rotate(ax, ay, az, angle) {
|
|
807
|
+
return makeSdfHandle(this.value.rotate(ax, ay, az, angle));
|
|
808
|
+
},
|
|
809
|
+
scale(s) {
|
|
810
|
+
return makeSdfHandle(this.value.scale(s));
|
|
811
|
+
},
|
|
812
|
+
rasterize(opts) {
|
|
813
|
+
return rasterizeField(this.value, opts);
|
|
814
|
+
},
|
|
815
|
+
rasterizeIn(bounds, opts) {
|
|
816
|
+
return rasterizeFieldIn(this.value, bounds, opts);
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
function rasterizeField(sdf, opts) {
|
|
821
|
+
const params = resolveGridParams(opts);
|
|
822
|
+
if (isErr(params)) return params;
|
|
823
|
+
try {
|
|
824
|
+
return ok(makeFieldHandle(sdf.rasterize(params.value.resolution, params.value.padding)));
|
|
825
|
+
} catch (cause) {
|
|
826
|
+
return rasterizeError(cause);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
function rasterizeFieldIn(sdf, bounds, opts) {
|
|
830
|
+
const params = resolveGridParams(opts);
|
|
831
|
+
if (isErr(params)) return params;
|
|
832
|
+
const invalid = validateBounds(bounds);
|
|
833
|
+
if (invalid) return err(invalid);
|
|
834
|
+
try {
|
|
835
|
+
return ok(makeFieldHandle(sdf.rasterize_in(bounds.min[0], bounds.min[1], bounds.min[2], bounds.max[0], bounds.max[1], bounds.max[2], params.value.resolution, params.value.padding)));
|
|
836
|
+
} catch (cause) {
|
|
837
|
+
return rasterizeError(cause);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
function rasterizeError(cause) {
|
|
841
|
+
return err(computationError("SDF_RASTERIZE_FAILED", cause instanceof Error ? cause.message : "SDF rasterization failed (grid too large?).", cause));
|
|
842
|
+
}
|
|
843
|
+
function validateBounds(bounds) {
|
|
844
|
+
if (![...bounds.min, ...bounds.max].every((v) => Number.isFinite(v))) return validationError("SDF_INVALID_BOUNDS", "bounds must be finite numbers.");
|
|
845
|
+
for (let axis = 0; axis < 3; axis++) if (bounds.max[axis] <= bounds.min[axis]) return validationError("SDF_INVALID_BOUNDS", "bounds max must exceed min on every axis.");
|
|
846
|
+
return null;
|
|
847
|
+
}
|
|
848
|
+
function build(make, id) {
|
|
849
|
+
const engine = resolveEngine(id);
|
|
850
|
+
if (isErr(engine)) return engine;
|
|
851
|
+
try {
|
|
852
|
+
return ok(makeSdfHandle(make(engine.value)));
|
|
853
|
+
} catch (cause) {
|
|
854
|
+
return err(computationError("SDF_BUILD_FAILED", cause instanceof Error ? cause.message : "SDF primitive construction failed.", cause));
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
/** A sphere of radius `r`, centered at the origin. */
|
|
858
|
+
function sphere(r, id) {
|
|
859
|
+
return build((e) => e.Sdf.sphere(r), id);
|
|
860
|
+
}
|
|
861
|
+
/** An axis-aligned box of half-extents `(hx, hy, hz)`, centered at the origin. */
|
|
862
|
+
function box$1(hx, hy, hz, id) {
|
|
863
|
+
return build((e) => e.Sdf.box_(hx, hy, hz), id);
|
|
864
|
+
}
|
|
865
|
+
/** A box with rounded edges of radius `r`. */
|
|
866
|
+
function roundedBox(hx, hy, hz, r, id) {
|
|
867
|
+
return build((e) => e.Sdf.rounded_box(hx, hy, hz, r), id);
|
|
868
|
+
}
|
|
869
|
+
/** A capped cylinder, axis +Z, radius `r`, total height `h`, centered at origin. */
|
|
870
|
+
function cylinder$1(r, h, id) {
|
|
871
|
+
return build((e) => e.Sdf.cylinder(r, h), id);
|
|
872
|
+
}
|
|
873
|
+
/** A capped cone centered at the origin: base radius `r` at z = −h/2 tapering to an apex at z = +h/2. */
|
|
874
|
+
function cone$1(r, h, id) {
|
|
875
|
+
return build((e) => e.Sdf.cone(r, h), id);
|
|
876
|
+
}
|
|
877
|
+
/** A capsule: a line segment `a`→`b` of radius `r`. */
|
|
878
|
+
function capsule(a, b, r, id) {
|
|
879
|
+
return build((e) => e.Sdf.capsule(a[0], a[1], a[2], b[0], b[1], b[2], r), id);
|
|
880
|
+
}
|
|
881
|
+
/** A torus in the XY plane (axis +Z): a `minor`-radius tube on a `major` circle. */
|
|
882
|
+
function torus(major, minor, id) {
|
|
883
|
+
return build((e) => e.Sdf.torus(major, minor), id);
|
|
884
|
+
}
|
|
885
|
+
/** A half-space: the plane through `h·n` with outward normal `n` (normalized). */
|
|
886
|
+
function plane(n, h, id) {
|
|
887
|
+
return build((e) => e.Sdf.plane(n[0], n[1], n[2], h), id);
|
|
888
|
+
}
|
|
889
|
+
function flattenSpine(spine) {
|
|
890
|
+
if (spine.length < 2) return err(validationError("SDF_INVALID_SPINE", "sweep spine needs at least 2 points."));
|
|
891
|
+
const flat = new Float64Array(spine.length * 3);
|
|
892
|
+
for (let i = 0; i < spine.length; i++) {
|
|
893
|
+
const pt = spine[i];
|
|
894
|
+
if (!pt.every((c) => Number.isFinite(c))) return err(validationError("SDF_INVALID_SPINE", "sweep spine coordinates must be finite."));
|
|
895
|
+
flat[i * 3] = pt[0];
|
|
896
|
+
flat[i * 3 + 1] = pt[1];
|
|
897
|
+
flat[i * 3 + 2] = pt[2];
|
|
898
|
+
}
|
|
899
|
+
return ok(flat);
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* Sweep an in-plane `profile` along a `spine` polyline using rotation-minimizing
|
|
903
|
+
* frames (no 180° flip at inflections). The profile is sampled in its own
|
|
904
|
+
* `(normal, binormal)` plane at every station; `opts.closed` loops the spine and
|
|
905
|
+
* skips the open-end caps. The result is a pseudo-SDF (exact distance only near
|
|
906
|
+
* the swept wall), which contours cleanly. `spine` needs at least 2 finite points.
|
|
907
|
+
*/
|
|
908
|
+
function sweep(spine, profile, opts, id) {
|
|
909
|
+
const flat = flattenSpine(spine);
|
|
910
|
+
if (isErr(flat)) return flat;
|
|
911
|
+
const closed = opts?.closed ?? false;
|
|
912
|
+
return build((e) => e.Sdf.sweep(flat.value, profile.value, closed), id);
|
|
913
|
+
}
|
|
914
|
+
var LATTICE_TAGS$1 = {
|
|
915
|
+
gyroid: 0,
|
|
916
|
+
schwarzP: 1,
|
|
917
|
+
diamond: 2
|
|
918
|
+
};
|
|
919
|
+
/**
|
|
920
|
+
* A graded/conformal TPMS lattice: `|f(p)| − ½·thickness(p)` for the chosen `kind`
|
|
921
|
+
* (negative = strut material), with `period` and `thickness` GRADED per-position via
|
|
922
|
+
* {@link ScalarFieldHandle}. A {@link fieldConst} period/thickness reproduces a
|
|
923
|
+
* uniform lattice. The field is Lipschitz and APPROXIMATE (not a true SDF).
|
|
924
|
+
*
|
|
925
|
+
* The lattice is INFINITE/periodic, so it must be clipped to a bounded region
|
|
926
|
+
* (`lattice.intersection(region)`) before rasterizing — that conformal clip is what
|
|
927
|
+
* frames a finite grid. NOTE: grading the PERIOD is an approximation (a
|
|
928
|
+
* spatially-varying period isn't strictly periodic); grading THICKNESS is the
|
|
929
|
+
* well-behaved primary knob.
|
|
930
|
+
*/
|
|
931
|
+
function lattice(kind, period, thickness, id) {
|
|
932
|
+
const tag = LATTICE_TAGS$1[kind];
|
|
933
|
+
if (tag === void 0) return err(validationError("SDF_INVALID_LATTICE_KIND", `unknown lattice kind: ${kind}`));
|
|
934
|
+
return build((e) => e.Sdf.lattice(tag, period.value, thickness.value), id);
|
|
935
|
+
}
|
|
936
|
+
/**
|
|
937
|
+
* A cubic beam/strut lattice: axis-aligned cylindrical struts on a `period`-spaced
|
|
938
|
+
* cubic grid, with the strut `radius` GRADED per-position via
|
|
939
|
+
* {@link ScalarFieldHandle}. Periodic/infinite — clip to a bounded region
|
|
940
|
+
* (`strut.intersection(region)`) before rasterizing.
|
|
941
|
+
*/
|
|
942
|
+
function strutLattice(period, radius, id) {
|
|
943
|
+
return build((e) => e.Sdf.strut_lattice(period, radius.value), id);
|
|
944
|
+
}
|
|
945
|
+
function scalarFieldDeletable(raw) {
|
|
946
|
+
return {
|
|
947
|
+
raw,
|
|
948
|
+
delete() {
|
|
949
|
+
raw.free();
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
function makeScalarFieldHandle(raw) {
|
|
954
|
+
const inner = createKernelHandle(scalarFieldDeletable(raw));
|
|
955
|
+
return {
|
|
956
|
+
get value() {
|
|
957
|
+
return inner.value.raw;
|
|
958
|
+
},
|
|
959
|
+
get disposed() {
|
|
960
|
+
return inner.disposed;
|
|
961
|
+
},
|
|
962
|
+
[Symbol.dispose]() {
|
|
963
|
+
inner[Symbol.dispose]();
|
|
964
|
+
}
|
|
965
|
+
};
|
|
966
|
+
}
|
|
967
|
+
function buildField(make, id) {
|
|
968
|
+
const engine = resolveEngine(id);
|
|
969
|
+
if (isErr(engine)) return engine;
|
|
970
|
+
try {
|
|
971
|
+
return ok(makeScalarFieldHandle(make(engine.value)));
|
|
972
|
+
} catch (cause) {
|
|
973
|
+
return err(computationError("SDF_FIELD_BUILD_FAILED", cause instanceof Error ? cause.message : "scalar field construction failed.", cause));
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
/** A spatially constant field — reproduces a constant operator parameter exactly. */
|
|
977
|
+
function fieldConst(c, id) {
|
|
978
|
+
return buildField((e) => e.ScalarField.constant(c), id);
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* A field that ramps `lo → hi` as `coord[axis]` goes `a → b`, clamped to the
|
|
982
|
+
* endpoint band outside `[a, b]`. `axis` is 0 (x), 1 (y), or 2 (z).
|
|
983
|
+
*/
|
|
984
|
+
function fieldAxialRamp(axis, a, b, lo, hi, id) {
|
|
985
|
+
return buildField((e) => e.ScalarField.axial_ramp(axis, a, b, lo, hi), id);
|
|
986
|
+
}
|
|
987
|
+
/**
|
|
988
|
+
* A field by radial distance from the line through `center` along `axis`: `lo → hi`
|
|
989
|
+
* as that distance goes `r0 → r1`, clamped. `axis` is 0 (x), 1 (y), or 2 (z).
|
|
990
|
+
*/
|
|
991
|
+
function fieldRadialRamp(center, axis, r0, r1, lo, hi, id) {
|
|
992
|
+
return buildField((e) => e.ScalarField.radial_ramp(center[0], center[1], center[2], axis, r0, r1, lo, hi), id);
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* A field from an {@link SdfHandle}'s signed distance, affinely remapped to
|
|
996
|
+
* `sdf.eval(p) * scale + offset`. UNBOUNDED — drive a bounds-affecting op
|
|
997
|
+
* (`offsetField`/`shellField`) with it only via `rasterizeIn` or wrapped in
|
|
998
|
+
* {@link fieldClamp}.
|
|
999
|
+
*/
|
|
1000
|
+
function fieldFromSdf(sdf, scale, offset, id) {
|
|
1001
|
+
return buildField((e) => e.ScalarField.from_sdf(sdf.value, scale, offset), id);
|
|
1002
|
+
}
|
|
1003
|
+
/**
|
|
1004
|
+
* Clamp another field's value to `[min, max]` — bounds an otherwise unbounded
|
|
1005
|
+
* {@link fieldFromSdf} so it can safely drive offset/shell.
|
|
1006
|
+
*/
|
|
1007
|
+
function fieldClamp(field, min, max, id) {
|
|
1008
|
+
return buildField((e) => e.ScalarField.clamp(field.value, min, max), id);
|
|
1009
|
+
}
|
|
1010
|
+
//#endregion
|
|
712
1011
|
//#region src/lattice/latticeFns.ts
|
|
713
1012
|
var LATTICE_TAGS = {
|
|
714
1013
|
gyroid: 0,
|
|
@@ -762,7 +1061,7 @@ function latticeInfill(mesh, opts, id) {
|
|
|
762
1061
|
if (mesh.vertices.length === 0 || mesh.triangles.length === 0) return err(validationError("LATTICE_EMPTY_MESH", "latticeInfill requires a non-empty triangle mesh."));
|
|
763
1062
|
const resolved = validateOptions(opts);
|
|
764
1063
|
if (isErr(resolved)) return resolved;
|
|
765
|
-
const engine = resolveEngine(id);
|
|
1064
|
+
const engine = resolveEngine$1(id);
|
|
766
1065
|
if (isErr(engine)) return engine;
|
|
767
1066
|
const { tag, period, thickness, resolution, padding } = resolved.value;
|
|
768
1067
|
try {
|
|
@@ -803,7 +1102,7 @@ function tpmsLattice(bounds, opts, id) {
|
|
|
803
1102
|
}
|
|
804
1103
|
const resolved = validateOptions(opts);
|
|
805
1104
|
if (isErr(resolved)) return resolved;
|
|
806
|
-
const engine = resolveEngine(id);
|
|
1105
|
+
const engine = resolveEngine$1(id);
|
|
807
1106
|
if (isErr(engine)) return engine;
|
|
808
1107
|
const { tag, period, thickness, resolution, padding } = resolved.value;
|
|
809
1108
|
const [minX, minY, minZ] = bounds.min;
|
|
@@ -3336,7 +3635,7 @@ function createWrappedCurve(val) {
|
|
|
3336
3635
|
isClosed: () => curveIsClosed(val),
|
|
3337
3636
|
sweep(spine, opts) {
|
|
3338
3637
|
if (!isWire(val)) throw new Error("sweep requires a Wire");
|
|
3339
|
-
const result = unwrapOrThrow(sweep(asClosedWire(val), resolve(spine), opts));
|
|
3638
|
+
const result = unwrapOrThrow(sweep$1(asClosedWire(val), resolve(spine), opts));
|
|
3340
3639
|
return wrap3D(Array.isArray(result) ? result[0] : result);
|
|
3341
3640
|
}
|
|
3342
3641
|
};
|
|
@@ -4032,11 +4331,11 @@ var primitives_exports = /* @__PURE__ */ __exportAll({
|
|
|
4032
4331
|
polyhedron: () => polyhedron,
|
|
4033
4332
|
sewShells: () => sewShells,
|
|
4034
4333
|
solid: () => solid,
|
|
4035
|
-
sphere: () => sphere,
|
|
4334
|
+
sphere: () => sphere$1,
|
|
4036
4335
|
subFace: () => subFace,
|
|
4037
4336
|
tangentArc: () => tangentArc,
|
|
4038
4337
|
threePointArc: () => threePointArc,
|
|
4039
|
-
torus: () => torus,
|
|
4338
|
+
torus: () => torus$1,
|
|
4040
4339
|
vertex: () => vertex,
|
|
4041
4340
|
wire: () => wire,
|
|
4042
4341
|
wireLoop: () => wireLoop
|
|
@@ -4149,7 +4448,7 @@ var construction_exports = /* @__PURE__ */ __exportAll({
|
|
|
4149
4448
|
supportExtrude: () => supportExtrude,
|
|
4150
4449
|
surfaceFromGrid: () => surfaceFromGrid,
|
|
4151
4450
|
surfaceFromImage: () => surfaceFromImage,
|
|
4152
|
-
sweep: () => sweep,
|
|
4451
|
+
sweep: () => sweep$1,
|
|
4153
4452
|
twistExtrude: () => twistExtrude
|
|
4154
4453
|
});
|
|
4155
4454
|
//#endregion
|
|
@@ -4464,7 +4763,7 @@ function depsOf(...sources) {
|
|
|
4464
4763
|
}
|
|
4465
4764
|
return acc.size === 0 ? EMPTY_DEPS : acc;
|
|
4466
4765
|
}
|
|
4467
|
-
function box$
|
|
4766
|
+
function box$2(x, y, z) {
|
|
4468
4767
|
const xe = asScalarExpr(x);
|
|
4469
4768
|
const ye = asScalarExpr(y);
|
|
4470
4769
|
const ze = asScalarExpr(z);
|
|
@@ -4479,7 +4778,7 @@ function box$1(x, y, z) {
|
|
|
4479
4778
|
freeParams: depsOf(xe, ye, ze)
|
|
4480
4779
|
};
|
|
4481
4780
|
}
|
|
4482
|
-
function sphere$
|
|
4781
|
+
function sphere$2(radius) {
|
|
4483
4782
|
const re = asScalarExpr(radius);
|
|
4484
4783
|
return {
|
|
4485
4784
|
kind: "Sphere",
|
|
@@ -4488,7 +4787,7 @@ function sphere$1(radius) {
|
|
|
4488
4787
|
freeParams: re.freeParams
|
|
4489
4788
|
};
|
|
4490
4789
|
}
|
|
4491
|
-
function cylinder$
|
|
4790
|
+
function cylinder$2(radius, height) {
|
|
4492
4791
|
const re = asScalarExpr(radius);
|
|
4493
4792
|
const he = asScalarExpr(height);
|
|
4494
4793
|
return {
|
|
@@ -4499,7 +4798,7 @@ function cylinder$1(radius, height) {
|
|
|
4499
4798
|
freeParams: depsOf(re, he)
|
|
4500
4799
|
};
|
|
4501
4800
|
}
|
|
4502
|
-
function cone$
|
|
4801
|
+
function cone$2(radius1, radius2, height) {
|
|
4503
4802
|
const r1 = asScalarExpr(radius1);
|
|
4504
4803
|
const r2 = asScalarExpr(radius2);
|
|
4505
4804
|
const he = asScalarExpr(height);
|
|
@@ -4514,7 +4813,7 @@ function cone$1(radius1, radius2, height) {
|
|
|
4514
4813
|
freeParams: depsOf(r1, r2, he)
|
|
4515
4814
|
};
|
|
4516
4815
|
}
|
|
4517
|
-
function torus$
|
|
4816
|
+
function torus$2(majorRadius, minorRadius) {
|
|
4518
4817
|
const ma = asScalarExpr(majorRadius);
|
|
4519
4818
|
const mi = asScalarExpr(minorRadius);
|
|
4520
4819
|
return {
|
|
@@ -4750,7 +5049,7 @@ function evalBox(node, ctx) {
|
|
|
4750
5049
|
function evalSphere(node, ctx) {
|
|
4751
5050
|
const r = evalScalar(node.radius, ctx.env, "Sphere.radius");
|
|
4752
5051
|
if (!r.ok) return r;
|
|
4753
|
-
return ok(sphere(r.value));
|
|
5052
|
+
return ok(sphere$1(r.value));
|
|
4754
5053
|
}
|
|
4755
5054
|
function evalCylinder(node, ctx) {
|
|
4756
5055
|
const r = evalScalar(node.radius, ctx.env, "Cylinder.radius");
|
|
@@ -4773,7 +5072,7 @@ function evalTorus(node, ctx) {
|
|
|
4773
5072
|
if (!ma.ok) return ma;
|
|
4774
5073
|
const mi = evalScalar(node.minorRadius, ctx.env, "Torus.minorRadius");
|
|
4775
5074
|
if (!mi.ok) return mi;
|
|
4776
|
-
return ok(torus(ma.value, mi.value));
|
|
5075
|
+
return ok(torus$1(ma.value, mi.value));
|
|
4777
5076
|
}
|
|
4778
5077
|
function evalPolygon(node, ctx) {
|
|
4779
5078
|
const pts = [];
|
|
@@ -5419,7 +5718,7 @@ function readSingleExpr(j, key, build) {
|
|
|
5419
5718
|
function readPrimitive(kind, j) {
|
|
5420
5719
|
switch (kind) {
|
|
5421
5720
|
case "Box": return readBox(j);
|
|
5422
|
-
case "Sphere": return readSingleExpr(j, "radius", sphere$
|
|
5721
|
+
case "Sphere": return readSingleExpr(j, "radius", sphere$2);
|
|
5423
5722
|
case "Cylinder": return readCylinder(j);
|
|
5424
5723
|
case "Cone": return readCone(j);
|
|
5425
5724
|
case "Torus": return readTorus(j);
|
|
@@ -5438,14 +5737,14 @@ function readBox(j) {
|
|
|
5438
5737
|
if (!y.ok) return y;
|
|
5439
5738
|
const z = readExpr(j["z"]);
|
|
5440
5739
|
if (!z.ok) return z;
|
|
5441
|
-
return ok(box$
|
|
5740
|
+
return ok(box$2(x.value, y.value, z.value));
|
|
5442
5741
|
}
|
|
5443
5742
|
function readCylinder(j) {
|
|
5444
5743
|
const r = readExpr(j["radius"]);
|
|
5445
5744
|
if (!r.ok) return r;
|
|
5446
5745
|
const h = readExpr(j["height"]);
|
|
5447
5746
|
if (!h.ok) return h;
|
|
5448
|
-
return ok(cylinder$
|
|
5747
|
+
return ok(cylinder$2(r.value, h.value));
|
|
5449
5748
|
}
|
|
5450
5749
|
function readCone(j) {
|
|
5451
5750
|
const r1 = readExpr(j["radius1"]);
|
|
@@ -5454,14 +5753,14 @@ function readCone(j) {
|
|
|
5454
5753
|
if (!r2.ok) return r2;
|
|
5455
5754
|
const h = readExpr(j["height"]);
|
|
5456
5755
|
if (!h.ok) return h;
|
|
5457
|
-
return ok(cone$
|
|
5756
|
+
return ok(cone$2(r1.value, r2.value, h.value));
|
|
5458
5757
|
}
|
|
5459
5758
|
function readTorus(j) {
|
|
5460
5759
|
const ma = readExpr(j["majorRadius"]);
|
|
5461
5760
|
if (!ma.ok) return ma;
|
|
5462
5761
|
const mi = readExpr(j["minorRadius"]);
|
|
5463
5762
|
if (!mi.ok) return mi;
|
|
5464
|
-
return ok(torus$
|
|
5763
|
+
return ok(torus$2(ma.value, mi.value));
|
|
5465
5764
|
}
|
|
5466
5765
|
function readPolygon(j) {
|
|
5467
5766
|
const pts = j["points"];
|
|
@@ -5637,11 +5936,11 @@ function foldBuildVec(dim, comps) {
|
|
|
5637
5936
|
}
|
|
5638
5937
|
function optimizeNode(n) {
|
|
5639
5938
|
switch (n.kind) {
|
|
5640
|
-
case "Box": return box$
|
|
5641
|
-
case "Sphere": return sphere$
|
|
5642
|
-
case "Cylinder": return cylinder$
|
|
5643
|
-
case "Cone": return cone$
|
|
5644
|
-
case "Torus": return torus$
|
|
5939
|
+
case "Box": return box$2(foldExpr(n.x), foldExpr(n.y), foldExpr(n.z));
|
|
5940
|
+
case "Sphere": return sphere$2(foldExpr(n.radius));
|
|
5941
|
+
case "Cylinder": return cylinder$2(foldExpr(n.radius), foldExpr(n.height));
|
|
5942
|
+
case "Cone": return cone$2(foldExpr(n.radius1), foldExpr(n.radius2), foldExpr(n.height));
|
|
5943
|
+
case "Torus": return torus$2(foldExpr(n.majorRadius), foldExpr(n.minorRadius));
|
|
5645
5944
|
case "Polygon": return polygon$1(n.points.map(foldExpr));
|
|
5646
5945
|
case "Circle": return circle$1(foldExpr(n.radius));
|
|
5647
5946
|
case "Line": return line$1(foldExpr(n.from), foldExpr(n.to));
|
|
@@ -5799,15 +6098,15 @@ var csg_exports = /* @__PURE__ */ __exportAll({
|
|
|
5799
6098
|
asVec2Expr: () => asVec2Expr,
|
|
5800
6099
|
asVec3Expr: () => asVec3Expr,
|
|
5801
6100
|
binOp: () => binOp,
|
|
5802
|
-
box: () => box$
|
|
6101
|
+
box: () => box$2,
|
|
5803
6102
|
buildVec: () => buildVec,
|
|
5804
6103
|
circle: () => circle$1,
|
|
5805
6104
|
component: () => component,
|
|
5806
6105
|
compound: () => compound$1,
|
|
5807
|
-
cone: () => cone$
|
|
6106
|
+
cone: () => cone$2,
|
|
5808
6107
|
cut: () => cut$1,
|
|
5809
6108
|
cutAll: () => cutAll$1,
|
|
5810
|
-
cylinder: () => cylinder$
|
|
6109
|
+
cylinder: () => cylinder$2,
|
|
5811
6110
|
emptyFace: () => emptyFace,
|
|
5812
6111
|
emptySolid: () => emptySolid,
|
|
5813
6112
|
emptyWire: () => emptyWire,
|
|
@@ -5829,9 +6128,9 @@ var csg_exports = /* @__PURE__ */ __exportAll({
|
|
|
5829
6128
|
replaceNode: () => replaceNode,
|
|
5830
6129
|
rotate: () => rotate$1,
|
|
5831
6130
|
scale: () => scale$1,
|
|
5832
|
-
sphere: () => sphere$
|
|
6131
|
+
sphere: () => sphere$2,
|
|
5833
6132
|
toJSON: () => toJSON,
|
|
5834
|
-
torus: () => torus$
|
|
6133
|
+
torus: () => torus$2,
|
|
5835
6134
|
translate: () => translate$1,
|
|
5836
6135
|
unaryOp: () => unaryOp,
|
|
5837
6136
|
vec2Lit: () => vec2Lit,
|
|
@@ -5840,4 +6139,4 @@ var csg_exports = /* @__PURE__ */ __exportAll({
|
|
|
5840
6139
|
withEvaluator: () => withEvaluator
|
|
5841
6140
|
});
|
|
5842
6141
|
//#endregion
|
|
5843
|
-
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, 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, curveEndPoint, curveIsClosed, curveIsPeriodic, curveLength, curvePeriod, curvePointAt, curveStartPoint, curveTangentAt, cut, cut2D, cutAll, cutAllBisect, cutBlueprints, cutWithEvolution, cylinder, 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, extrude, extrudeAll, face, faceCenter, faceFinder, faceGeomType, faceOrientation, facesOfEdge, fieldBoolean, fieldContour, fieldOffset, fieldReinit, fieldShell, fill, filledFace, fillet, filletWithEvolution, findFacesByTag, findNode, findStep, fixSelfIntersection, fixShape, flatMap, flatten, flipFaceOrientation, flipOrientation, fontMetrics, 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, guidedSweep, heal, healFace, healSolid, healWire, helix, hull, importDXF, importGLB, importIGES, importOBJ, importSTEP, importSTL, importSVG, importSVGPathD, importThreeMF, init, initFromManifold, initFromOC, initVoxel, innerWires, interpolateCurve, intersect, intersect2D, intersectBlueprints, intersectWithEvolution, invalidateShapeCache, ioNs_exports as io, ioError, is2D, is3D, isChamferRadius, isClosedWire, isCompSolid, isCompound, isDisposeRequest, isEdge, isEmpty, isEqualShape, isErr, isErrorResponse, isFace, isFilletRadius, isInitRequest, isInside2D, 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, kernelCall, kernelCallRaw, kernelCallScoped, kernelError, latticeInfill, latticeInfillShape, line, linearPattern, loadFont, loft, loftAll, makeBaseBox, makeExternalGear, makeInternalGear, makePlane, makePlanetaryGear, makeProjectedEdges, manifoldShell, map, mapBoth, mapErr, match, measureArea, measureCurvatureAt, measureCurvatureAtMid, measureDistance, measureDistanceProps, measureLength, measureLinearProps, measureSurfaceProps, measureVolume, measureVolumeProps, measurement_exports as measurement, 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, planarWire, planetPlacements, pocket, pointOnSurface, pointsInside, polygon, polyhedron, polysideInnerRadius, polysidesBlueprint, positionOnCurve, prewarm, primitives_exports as primitives, 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, revolve, roof, rotate, rotate2D, rotateDrawing, roundedRectangleBlueprint, scale, scale2D, scaleDrawing, section, sectionToFace, serializeHistory, 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, split, stepCount, stepsFrom, stretch2D, subFace, supportExtrude, supportsConstraintSketch, supportsProjection, surfaceFromGrid, surfaceFromImage, sweep, tagFaces, tangentArc, tap, tapErr, textBlueprints, textMetrics, thicken, threePointArc, toBREP, toBufferGeometryData, toGroupedBufferGeometryData, toKernelVec, toLODGeometryData, toLineGeometryData, toSVGPathD, toVec2, toVec3, 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 };
|
|
6142
|
+
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, 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, curveEndPoint, curveIsClosed, curveIsPeriodic, curveLength, curvePeriod, curvePointAt, curveStartPoint, curveTangentAt, cut, cut2D, cutAll, cutAllBisect, cutBlueprints, cutWithEvolution, cylinder, 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, extrude, extrudeAll, face, faceCenter, faceFinder, faceGeomType, faceOrientation, facesOfEdge, fieldBoolean, fieldContour, fieldOffset, fieldReinit, fieldShell, fill, filledFace, fillet, filletWithEvolution, findFacesByTag, findNode, findStep, fixSelfIntersection, fixShape, flatMap, flatten, flipFaceOrientation, flipOrientation, fontMetrics, 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, guidedSweep, heal, healFace, healSolid, healWire, helix, hull, importDXF, importGLB, importIGES, importOBJ, importSTEP, importSTL, importSVG, importSVGPathD, importThreeMF, init, initFromManifold, initFromOC, initVoxel, innerWires, interpolateCurve, intersect, intersect2D, intersectBlueprints, intersectWithEvolution, invalidateShapeCache, ioNs_exports as io, ioError, is2D, is3D, isChamferRadius, isClosedWire, isCompSolid, isCompound, isDisposeRequest, isEdge, isEmpty, isEqualShape, isErr, isErrorResponse, isFace, isFilletRadius, isInitRequest, isInside2D, 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, kernelCall, kernelCallRaw, kernelCallScoped, kernelError, latticeInfill, latticeInfillShape, line, linearPattern, loadFont, loft, loftAll, makeBaseBox, makeExternalGear, makeInternalGear, makePlane, makePlanetaryGear, makeProjectedEdges, manifoldShell, map, mapBoth, mapErr, match, measureArea, measureCurvatureAt, measureCurvatureAtMid, measureDistance, measureDistanceProps, measureLength, measureLinearProps, measureSurfaceProps, measureVolume, measureVolumeProps, measurement_exports as measurement, 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, planarWire, planetPlacements, pocket, pointOnSurface, pointsInside, polygon, polyhedron, polysideInnerRadius, polysidesBlueprint, positionOnCurve, prewarm, primitives_exports as primitives, 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, 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, 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, split, stepCount, stepsFrom, stretch2D, subFace, supportExtrude, supportsConstraintSketch, supportsProjection, surfaceFromGrid, surfaceFromImage, sweep$1 as sweep, tagFaces, tangentArc, tap, tapErr, textBlueprints, textMetrics, thicken, 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 };
|