brepjs 18.68.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 +147 -0
- package/dist/brepjs.js +143 -4
- package/dist/implicit/index.d.ts +4 -2
- package/dist/implicit/sdfFns.d.ts +78 -1
- package/dist/index.d.ts +2 -2
- package/dist/voxel/engine.d.ts +53 -0
- package/package.json +1 -1
package/dist/brepjs.cjs
CHANGED
|
@@ -729,6 +729,23 @@ function sdfDeletable(raw) {
|
|
|
729
729
|
}
|
|
730
730
|
};
|
|
731
731
|
}
|
|
732
|
+
/** The position-modulated operator methods, split out to keep {@link makeSdfHandle}
|
|
733
|
+
* under the per-function line cap. `this` binds to the owning {@link SdfHandle} when
|
|
734
|
+
* spread into its object literal. */
|
|
735
|
+
var MODULATED_FIELD_METHODS = {
|
|
736
|
+
offsetField(field) {
|
|
737
|
+
return makeSdfHandle(this.value.offset_field(field.value));
|
|
738
|
+
},
|
|
739
|
+
roundField(field) {
|
|
740
|
+
return makeSdfHandle(this.value.round_field(field.value));
|
|
741
|
+
},
|
|
742
|
+
shellField(field) {
|
|
743
|
+
return makeSdfHandle(this.value.shell_field(field.value));
|
|
744
|
+
},
|
|
745
|
+
smoothUnionField(other, field) {
|
|
746
|
+
return makeSdfHandle(this.value.smooth_union_field(other.value, field.value));
|
|
747
|
+
}
|
|
748
|
+
};
|
|
732
749
|
function makeSdfHandle(raw) {
|
|
733
750
|
const inner = require_shapeTypes.createKernelHandle(sdfDeletable(raw));
|
|
734
751
|
return {
|
|
@@ -771,6 +788,7 @@ function makeSdfHandle(raw) {
|
|
|
771
788
|
onion(thickness) {
|
|
772
789
|
return makeSdfHandle(this.value.onion(thickness));
|
|
773
790
|
},
|
|
791
|
+
...MODULATED_FIELD_METHODS,
|
|
774
792
|
translate(x, y, z) {
|
|
775
793
|
return makeSdfHandle(this.value.translate(x, y, z));
|
|
776
794
|
},
|
|
@@ -857,6 +875,127 @@ function torus(major, minor, id) {
|
|
|
857
875
|
function plane(n, h, id) {
|
|
858
876
|
return build((e) => e.Sdf.plane(n[0], n[1], n[2], h), id);
|
|
859
877
|
}
|
|
878
|
+
function flattenSpine(spine) {
|
|
879
|
+
if (spine.length < 2) return require_errors.err(require_errors.validationError("SDF_INVALID_SPINE", "sweep spine needs at least 2 points."));
|
|
880
|
+
const flat = new Float64Array(spine.length * 3);
|
|
881
|
+
for (let i = 0; i < spine.length; i++) {
|
|
882
|
+
const pt = spine[i];
|
|
883
|
+
if (!pt.every((c) => Number.isFinite(c))) return require_errors.err(require_errors.validationError("SDF_INVALID_SPINE", "sweep spine coordinates must be finite."));
|
|
884
|
+
flat[i * 3] = pt[0];
|
|
885
|
+
flat[i * 3 + 1] = pt[1];
|
|
886
|
+
flat[i * 3 + 2] = pt[2];
|
|
887
|
+
}
|
|
888
|
+
return require_errors.ok(flat);
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
* Sweep an in-plane `profile` along a `spine` polyline using rotation-minimizing
|
|
892
|
+
* frames (no 180° flip at inflections). The profile is sampled in its own
|
|
893
|
+
* `(normal, binormal)` plane at every station; `opts.closed` loops the spine and
|
|
894
|
+
* skips the open-end caps. The result is a pseudo-SDF (exact distance only near
|
|
895
|
+
* the swept wall), which contours cleanly. `spine` needs at least 2 finite points.
|
|
896
|
+
*/
|
|
897
|
+
function sweep(spine, profile, opts, id) {
|
|
898
|
+
const flat = flattenSpine(spine);
|
|
899
|
+
if (require_errors.isErr(flat)) return flat;
|
|
900
|
+
const closed = opts?.closed ?? false;
|
|
901
|
+
return build((e) => e.Sdf.sweep(flat.value, profile.value, closed), id);
|
|
902
|
+
}
|
|
903
|
+
var LATTICE_TAGS$1 = {
|
|
904
|
+
gyroid: 0,
|
|
905
|
+
schwarzP: 1,
|
|
906
|
+
diamond: 2
|
|
907
|
+
};
|
|
908
|
+
/**
|
|
909
|
+
* A graded/conformal TPMS lattice: `|f(p)| − ½·thickness(p)` for the chosen `kind`
|
|
910
|
+
* (negative = strut material), with `period` and `thickness` GRADED per-position via
|
|
911
|
+
* {@link ScalarFieldHandle}. A {@link fieldConst} period/thickness reproduces a
|
|
912
|
+
* uniform lattice. The field is Lipschitz and APPROXIMATE (not a true SDF).
|
|
913
|
+
*
|
|
914
|
+
* The lattice is INFINITE/periodic, so it must be clipped to a bounded region
|
|
915
|
+
* (`lattice.intersection(region)`) before rasterizing — that conformal clip is what
|
|
916
|
+
* frames a finite grid. NOTE: grading the PERIOD is an approximation (a
|
|
917
|
+
* spatially-varying period isn't strictly periodic); grading THICKNESS is the
|
|
918
|
+
* well-behaved primary knob.
|
|
919
|
+
*/
|
|
920
|
+
function lattice(kind, period, thickness, id) {
|
|
921
|
+
const tag = LATTICE_TAGS$1[kind];
|
|
922
|
+
if (tag === void 0) return require_errors.err(require_errors.validationError("SDF_INVALID_LATTICE_KIND", `unknown lattice kind: ${kind}`));
|
|
923
|
+
return build((e) => e.Sdf.lattice(tag, period.value, thickness.value), id);
|
|
924
|
+
}
|
|
925
|
+
/**
|
|
926
|
+
* A cubic beam/strut lattice: axis-aligned cylindrical struts on a `period`-spaced
|
|
927
|
+
* cubic grid, with the strut `radius` GRADED per-position via
|
|
928
|
+
* {@link ScalarFieldHandle}. Periodic/infinite — clip to a bounded region
|
|
929
|
+
* (`strut.intersection(region)`) before rasterizing.
|
|
930
|
+
*/
|
|
931
|
+
function strutLattice(period, radius, id) {
|
|
932
|
+
return build((e) => e.Sdf.strut_lattice(period, radius.value), id);
|
|
933
|
+
}
|
|
934
|
+
function scalarFieldDeletable(raw) {
|
|
935
|
+
return {
|
|
936
|
+
raw,
|
|
937
|
+
delete() {
|
|
938
|
+
raw.free();
|
|
939
|
+
}
|
|
940
|
+
};
|
|
941
|
+
}
|
|
942
|
+
function makeScalarFieldHandle(raw) {
|
|
943
|
+
const inner = require_shapeTypes.createKernelHandle(scalarFieldDeletable(raw));
|
|
944
|
+
return {
|
|
945
|
+
get value() {
|
|
946
|
+
return inner.value.raw;
|
|
947
|
+
},
|
|
948
|
+
get disposed() {
|
|
949
|
+
return inner.disposed;
|
|
950
|
+
},
|
|
951
|
+
[Symbol.dispose]() {
|
|
952
|
+
inner[Symbol.dispose]();
|
|
953
|
+
}
|
|
954
|
+
};
|
|
955
|
+
}
|
|
956
|
+
function buildField(make, id) {
|
|
957
|
+
const engine = resolveEngine(id);
|
|
958
|
+
if (require_errors.isErr(engine)) return engine;
|
|
959
|
+
try {
|
|
960
|
+
return require_errors.ok(makeScalarFieldHandle(make(engine.value)));
|
|
961
|
+
} catch (cause) {
|
|
962
|
+
return require_errors.err(require_errors.computationError("SDF_FIELD_BUILD_FAILED", cause instanceof Error ? cause.message : "scalar field construction failed.", cause));
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
/** A spatially constant field — reproduces a constant operator parameter exactly. */
|
|
966
|
+
function fieldConst(c, id) {
|
|
967
|
+
return buildField((e) => e.ScalarField.constant(c), id);
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* A field that ramps `lo → hi` as `coord[axis]` goes `a → b`, clamped to the
|
|
971
|
+
* endpoint band outside `[a, b]`. `axis` is 0 (x), 1 (y), or 2 (z).
|
|
972
|
+
*/
|
|
973
|
+
function fieldAxialRamp(axis, a, b, lo, hi, id) {
|
|
974
|
+
return buildField((e) => e.ScalarField.axial_ramp(axis, a, b, lo, hi), id);
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* A field by radial distance from the line through `center` along `axis`: `lo → hi`
|
|
978
|
+
* as that distance goes `r0 → r1`, clamped. `axis` is 0 (x), 1 (y), or 2 (z).
|
|
979
|
+
*/
|
|
980
|
+
function fieldRadialRamp(center, axis, r0, r1, lo, hi, id) {
|
|
981
|
+
return buildField((e) => e.ScalarField.radial_ramp(center[0], center[1], center[2], axis, r0, r1, lo, hi), id);
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* A field from an {@link SdfHandle}'s signed distance, affinely remapped to
|
|
985
|
+
* `sdf.eval(p) * scale + offset`. UNBOUNDED — drive a bounds-affecting op
|
|
986
|
+
* (`offsetField`/`shellField`) with it only via `rasterizeIn` or wrapped in
|
|
987
|
+
* {@link fieldClamp}.
|
|
988
|
+
*/
|
|
989
|
+
function fieldFromSdf(sdf, scale, offset, id) {
|
|
990
|
+
return buildField((e) => e.ScalarField.from_sdf(sdf.value, scale, offset), id);
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* Clamp another field's value to `[min, max]` — bounds an otherwise unbounded
|
|
994
|
+
* {@link fieldFromSdf} so it can safely drive offset/shell.
|
|
995
|
+
*/
|
|
996
|
+
function fieldClamp(field, min, max, id) {
|
|
997
|
+
return buildField((e) => e.ScalarField.clamp(field.value, min, max), id);
|
|
998
|
+
}
|
|
860
999
|
//#endregion
|
|
861
1000
|
//#region src/lattice/latticeFns.ts
|
|
862
1001
|
var LATTICE_TAGS = {
|
|
@@ -6472,9 +6611,17 @@ exports.sdfBox = box$1;
|
|
|
6472
6611
|
exports.sdfCapsule = capsule;
|
|
6473
6612
|
exports.sdfCone = cone$1;
|
|
6474
6613
|
exports.sdfCylinder = cylinder$1;
|
|
6614
|
+
exports.sdfFieldAxialRamp = fieldAxialRamp;
|
|
6615
|
+
exports.sdfFieldClamp = fieldClamp;
|
|
6616
|
+
exports.sdfFieldConst = fieldConst;
|
|
6617
|
+
exports.sdfFieldFromSdf = fieldFromSdf;
|
|
6618
|
+
exports.sdfFieldRadialRamp = fieldRadialRamp;
|
|
6619
|
+
exports.sdfLattice = lattice;
|
|
6475
6620
|
exports.sdfPlane = plane;
|
|
6476
6621
|
exports.sdfRoundedBox = roundedBox;
|
|
6477
6622
|
exports.sdfSphere = sphere;
|
|
6623
|
+
exports.sdfStrutLattice = strutLattice;
|
|
6624
|
+
exports.sdfSweep = sweep;
|
|
6478
6625
|
exports.sdfTorus = torus;
|
|
6479
6626
|
exports.section = section;
|
|
6480
6627
|
exports.sectionToFace = sectionToFace;
|
package/dist/brepjs.js
CHANGED
|
@@ -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";
|
|
@@ -740,6 +740,23 @@ function sdfDeletable(raw) {
|
|
|
740
740
|
}
|
|
741
741
|
};
|
|
742
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
|
+
};
|
|
743
760
|
function makeSdfHandle(raw) {
|
|
744
761
|
const inner = createKernelHandle(sdfDeletable(raw));
|
|
745
762
|
return {
|
|
@@ -782,6 +799,7 @@ function makeSdfHandle(raw) {
|
|
|
782
799
|
onion(thickness) {
|
|
783
800
|
return makeSdfHandle(this.value.onion(thickness));
|
|
784
801
|
},
|
|
802
|
+
...MODULATED_FIELD_METHODS,
|
|
785
803
|
translate(x, y, z) {
|
|
786
804
|
return makeSdfHandle(this.value.translate(x, y, z));
|
|
787
805
|
},
|
|
@@ -868,6 +886,127 @@ function torus(major, minor, id) {
|
|
|
868
886
|
function plane(n, h, id) {
|
|
869
887
|
return build((e) => e.Sdf.plane(n[0], n[1], n[2], h), id);
|
|
870
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
|
+
}
|
|
871
1010
|
//#endregion
|
|
872
1011
|
//#region src/lattice/latticeFns.ts
|
|
873
1012
|
var LATTICE_TAGS = {
|
|
@@ -3496,7 +3635,7 @@ function createWrappedCurve(val) {
|
|
|
3496
3635
|
isClosed: () => curveIsClosed(val),
|
|
3497
3636
|
sweep(spine, opts) {
|
|
3498
3637
|
if (!isWire(val)) throw new Error("sweep requires a Wire");
|
|
3499
|
-
const result = unwrapOrThrow(sweep(asClosedWire(val), resolve(spine), opts));
|
|
3638
|
+
const result = unwrapOrThrow(sweep$1(asClosedWire(val), resolve(spine), opts));
|
|
3500
3639
|
return wrap3D(Array.isArray(result) ? result[0] : result);
|
|
3501
3640
|
}
|
|
3502
3641
|
};
|
|
@@ -4309,7 +4448,7 @@ var construction_exports = /* @__PURE__ */ __exportAll({
|
|
|
4309
4448
|
supportExtrude: () => supportExtrude,
|
|
4310
4449
|
surfaceFromGrid: () => surfaceFromGrid,
|
|
4311
4450
|
surfaceFromImage: () => surfaceFromImage,
|
|
4312
|
-
sweep: () => sweep,
|
|
4451
|
+
sweep: () => sweep$1,
|
|
4313
4452
|
twistExtrude: () => twistExtrude
|
|
4314
4453
|
});
|
|
4315
4454
|
//#endregion
|
|
@@ -6000,4 +6139,4 @@ var csg_exports = /* @__PURE__ */ __exportAll({
|
|
|
6000
6139
|
withEvaluator: () => withEvaluator
|
|
6001
6140
|
});
|
|
6002
6141
|
//#endregion
|
|
6003
|
-
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, plane as sdfPlane, roundedBox as sdfRoundedBox, sphere as sdfSphere, 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, 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 };
|
|
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 };
|
package/dist/implicit/index.d.ts
CHANGED
|
@@ -7,5 +7,7 @@
|
|
|
7
7
|
* combinators into an {@link SdfHandle}, which rasterizes to a banded-SDF
|
|
8
8
|
* {@link VoxelFieldHandle} for contour / offset / shell.
|
|
9
9
|
*/
|
|
10
|
-
export type { SdfHandle, SdfBounds } from './sdfFns.js';
|
|
11
|
-
export { sphere, box, roundedBox, cylinder, cone, capsule, torus, plane } from './sdfFns.js';
|
|
10
|
+
export type { SdfHandle, SdfBounds, SdfSweepOptions, ScalarFieldHandle, LatticeKind, } from './sdfFns.js';
|
|
11
|
+
export { sphere, box, roundedBox, cylinder, cone, capsule, torus, plane, sweep } from './sdfFns.js';
|
|
12
|
+
export { fieldConst, fieldAxialRamp, fieldRadialRamp, fieldFromSdf, fieldClamp } from './sdfFns.js';
|
|
13
|
+
export { lattice, strutLattice } from './sdfFns.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Result } from '../core/result.js';
|
|
2
|
-
import { WasmSdf } from '../voxel/engine.js';
|
|
2
|
+
import { WasmSdf, WasmScalarField } from '../voxel/engine.js';
|
|
3
3
|
import { VoxelFieldHandle, VoxelFieldOptions } from '../voxel/fieldFns.js';
|
|
4
4
|
/** Explicit world bounds `[min..max]` for {@link SdfHandle.rasterizeIn}. */
|
|
5
5
|
export interface SdfBounds {
|
|
@@ -33,6 +33,10 @@ export interface SdfHandle {
|
|
|
33
33
|
round(radius: number): SdfHandle;
|
|
34
34
|
shell(thickness: number): SdfHandle;
|
|
35
35
|
onion(thickness: number): SdfHandle;
|
|
36
|
+
offsetField(field: ScalarFieldHandle): SdfHandle;
|
|
37
|
+
roundField(field: ScalarFieldHandle): SdfHandle;
|
|
38
|
+
shellField(field: ScalarFieldHandle): SdfHandle;
|
|
39
|
+
smoothUnionField(other: SdfHandle, field: ScalarFieldHandle): SdfHandle;
|
|
36
40
|
translate(x: number, y: number, z: number): SdfHandle;
|
|
37
41
|
rotate(ax: number, ay: number, az: number, angle: number): SdfHandle;
|
|
38
42
|
scale(s: number): SdfHandle;
|
|
@@ -57,3 +61,76 @@ export declare function capsule(a: [number, number, number], b: [number, number,
|
|
|
57
61
|
export declare function torus(major: number, minor: number, id?: string): Result<SdfHandle>;
|
|
58
62
|
/** A half-space: the plane through `h·n` with outward normal `n` (normalized). */
|
|
59
63
|
export declare function plane(n: [number, number, number], h: number, id?: string): Result<SdfHandle>;
|
|
64
|
+
/** Options for {@link sweep}. */
|
|
65
|
+
export interface SdfSweepOptions {
|
|
66
|
+
/** Close the spine into a loop, skipping the open-end caps. Default `false`. */
|
|
67
|
+
closed?: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Sweep an in-plane `profile` along a `spine` polyline using rotation-minimizing
|
|
71
|
+
* frames (no 180° flip at inflections). The profile is sampled in its own
|
|
72
|
+
* `(normal, binormal)` plane at every station; `opts.closed` loops the spine and
|
|
73
|
+
* skips the open-end caps. The result is a pseudo-SDF (exact distance only near
|
|
74
|
+
* the swept wall), which contours cleanly. `spine` needs at least 2 finite points.
|
|
75
|
+
*/
|
|
76
|
+
export declare function sweep(spine: [number, number, number][], profile: SdfHandle, opts?: SdfSweepOptions, id?: string): Result<SdfHandle>;
|
|
77
|
+
/** TPMS family selector for {@link lattice}. */
|
|
78
|
+
export type LatticeKind = 'gyroid' | 'schwarzP' | 'diamond';
|
|
79
|
+
/**
|
|
80
|
+
* A graded/conformal TPMS lattice: `|f(p)| − ½·thickness(p)` for the chosen `kind`
|
|
81
|
+
* (negative = strut material), with `period` and `thickness` GRADED per-position via
|
|
82
|
+
* {@link ScalarFieldHandle}. A {@link fieldConst} period/thickness reproduces a
|
|
83
|
+
* uniform lattice. The field is Lipschitz and APPROXIMATE (not a true SDF).
|
|
84
|
+
*
|
|
85
|
+
* The lattice is INFINITE/periodic, so it must be clipped to a bounded region
|
|
86
|
+
* (`lattice.intersection(region)`) before rasterizing — that conformal clip is what
|
|
87
|
+
* frames a finite grid. NOTE: grading the PERIOD is an approximation (a
|
|
88
|
+
* spatially-varying period isn't strictly periodic); grading THICKNESS is the
|
|
89
|
+
* well-behaved primary knob.
|
|
90
|
+
*/
|
|
91
|
+
export declare function lattice(kind: LatticeKind, period: ScalarFieldHandle, thickness: ScalarFieldHandle, id?: string): Result<SdfHandle>;
|
|
92
|
+
/**
|
|
93
|
+
* A cubic beam/strut lattice: axis-aligned cylindrical struts on a `period`-spaced
|
|
94
|
+
* cubic grid, with the strut `radius` GRADED per-position via
|
|
95
|
+
* {@link ScalarFieldHandle}. Periodic/infinite — clip to a bounded region
|
|
96
|
+
* (`strut.intersection(region)`) before rasterizing.
|
|
97
|
+
*/
|
|
98
|
+
export declare function strutLattice(period: number, radius: ScalarFieldHandle, id?: string): Result<SdfHandle>;
|
|
99
|
+
/**
|
|
100
|
+
* A disposable handle around a position-varying scalar field (brepjs-implicit Phase
|
|
101
|
+
* 2b). Fed to the {@link SdfHandle} modulated operators (`offsetField`, `shellField`,
|
|
102
|
+
* …) to vary an operator parameter per voxel. Like {@link SdfHandle} it is a value —
|
|
103
|
+
* the constructors return fresh fields — and dispose is mandatory (`using`, or
|
|
104
|
+
* `[Symbol.dispose]()`) to free the WASM allocation.
|
|
105
|
+
*/
|
|
106
|
+
export interface ScalarFieldHandle {
|
|
107
|
+
/** The wrapped WASM field. Throws if the handle has been disposed. */
|
|
108
|
+
readonly value: WasmScalarField;
|
|
109
|
+
/** Whether the backing WASM field has been freed. */
|
|
110
|
+
readonly disposed: boolean;
|
|
111
|
+
[Symbol.dispose](): void;
|
|
112
|
+
}
|
|
113
|
+
/** A spatially constant field — reproduces a constant operator parameter exactly. */
|
|
114
|
+
export declare function fieldConst(c: number, id?: string): Result<ScalarFieldHandle>;
|
|
115
|
+
/**
|
|
116
|
+
* A field that ramps `lo → hi` as `coord[axis]` goes `a → b`, clamped to the
|
|
117
|
+
* endpoint band outside `[a, b]`. `axis` is 0 (x), 1 (y), or 2 (z).
|
|
118
|
+
*/
|
|
119
|
+
export declare function fieldAxialRamp(axis: number, a: number, b: number, lo: number, hi: number, id?: string): Result<ScalarFieldHandle>;
|
|
120
|
+
/**
|
|
121
|
+
* A field by radial distance from the line through `center` along `axis`: `lo → hi`
|
|
122
|
+
* as that distance goes `r0 → r1`, clamped. `axis` is 0 (x), 1 (y), or 2 (z).
|
|
123
|
+
*/
|
|
124
|
+
export declare function fieldRadialRamp(center: [number, number, number], axis: number, r0: number, r1: number, lo: number, hi: number, id?: string): Result<ScalarFieldHandle>;
|
|
125
|
+
/**
|
|
126
|
+
* A field from an {@link SdfHandle}'s signed distance, affinely remapped to
|
|
127
|
+
* `sdf.eval(p) * scale + offset`. UNBOUNDED — drive a bounds-affecting op
|
|
128
|
+
* (`offsetField`/`shellField`) with it only via `rasterizeIn` or wrapped in
|
|
129
|
+
* {@link fieldClamp}.
|
|
130
|
+
*/
|
|
131
|
+
export declare function fieldFromSdf(sdf: SdfHandle, scale: number, offset: number, id?: string): Result<ScalarFieldHandle>;
|
|
132
|
+
/**
|
|
133
|
+
* Clamp another field's value to `[min, max]` — bounds an otherwise unbounded
|
|
134
|
+
* {@link fieldFromSdf} so it can safely drive offset/shell.
|
|
135
|
+
*/
|
|
136
|
+
export declare function fieldClamp(field: ScalarFieldHandle, min: number, max: number, id?: string): Result<ScalarFieldHandle>;
|
package/dist/index.d.ts
CHANGED
|
@@ -40,8 +40,8 @@ export { importSVGPathD, importSVG, type SVGImportOptions } from './io/svgImport
|
|
|
40
40
|
export { exportSTEPConfigured, type StepExportOptions, type StepExportPart, } from './io/stepConfigFns.js';
|
|
41
41
|
export { initVoxel, registerVoxel, getVoxel, getActiveVoxelId, windingNumbers, pointsInside, repairMesh, offsetMesh, shellMesh, voxelBoolean, offsetShape, shellShape, voxelBooleanShapes, voxelField, voxelBooleanField, fieldBoolean, fieldOffset, fieldShell, fieldReinit, fieldContour, voxelFieldFromShape, voxelBooleanFieldShapes, shapeToMeshInput, } from './voxel/index.js';
|
|
42
42
|
export type { VoxelEngine, VoxelMeshInput, VoxelRepairResult, RepairOptions, VoxelOpOptions, VoxelFieldHandle, VoxelFieldOptions, VoxelBooleanOp, } from './voxel/index.js';
|
|
43
|
-
export { sphere as sdfSphere, box as sdfBox, roundedBox as sdfRoundedBox, cylinder as sdfCylinder, cone as sdfCone, capsule as sdfCapsule, torus as sdfTorus, plane as sdfPlane, } from './implicit/index.js';
|
|
44
|
-
export type { SdfHandle, SdfBounds } from './implicit/index.js';
|
|
43
|
+
export { sphere as sdfSphere, box as sdfBox, roundedBox as sdfRoundedBox, cylinder as sdfCylinder, cone as sdfCone, capsule as sdfCapsule, torus as sdfTorus, plane as sdfPlane, sweep as sdfSweep, fieldConst as sdfFieldConst, fieldAxialRamp as sdfFieldAxialRamp, fieldRadialRamp as sdfFieldRadialRamp, fieldFromSdf as sdfFieldFromSdf, fieldClamp as sdfFieldClamp, lattice as sdfLattice, strutLattice as sdfStrutLattice, } from './implicit/index.js';
|
|
44
|
+
export type { SdfHandle, SdfBounds, SdfSweepOptions, ScalarFieldHandle, LatticeKind as SdfLatticeKind, } from './implicit/index.js';
|
|
45
45
|
export { latticeInfill, latticeInfillShape, tpmsLattice } from './lattice/index.js';
|
|
46
46
|
export type { LatticeType, LatticeOptions, LatticeBounds } from './lattice/index.js';
|
|
47
47
|
export { default as Sketcher } from './sketching/sketcher.js';
|
package/dist/voxel/engine.d.ts
CHANGED
|
@@ -36,9 +36,40 @@ export interface VoxelEngine {
|
|
|
36
36
|
* satisfied by the generated `Sdf` wasm-bindgen class.
|
|
37
37
|
*/
|
|
38
38
|
Sdf: WasmSdfConstructor;
|
|
39
|
+
/**
|
|
40
|
+
* Position-varying scalar fields (brepjs-implicit Phase 2b). Static constructors
|
|
41
|
+
* compose an opaque field that the `Sdf` modulated operators sample per voxel.
|
|
42
|
+
* Structurally satisfied by the generated `ScalarField` wasm-bindgen class.
|
|
43
|
+
*/
|
|
44
|
+
ScalarField: WasmScalarFieldConstructor;
|
|
39
45
|
/** Engine artifact version, for loader/artifact compatibility checks. */
|
|
40
46
|
version(): string;
|
|
41
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Static surface of the wasm `ScalarField` class: the constructors that seed a
|
|
50
|
+
* position-varying field. Each returns a fresh {@link WasmScalarField}; the ramp
|
|
51
|
+
* constructors throw (as a JS exception) on an out-of-range axis. Structurally
|
|
52
|
+
* satisfied by the generated `ScalarField` class.
|
|
53
|
+
*/
|
|
54
|
+
export interface WasmScalarFieldConstructor {
|
|
55
|
+
constant(c: number): WasmScalarField;
|
|
56
|
+
axial_ramp(axis: number, a: number, b: number, lo: number, hi: number): WasmScalarField;
|
|
57
|
+
radial_ramp(cx: number, cy: number, cz: number, axis: number, r0: number, r1: number, lo: number, hi: number): WasmScalarField;
|
|
58
|
+
from_sdf(sdf: WasmSdf, scale: number, offset: number): WasmScalarField;
|
|
59
|
+
clamp(field: WasmScalarField, min: number, max: number): WasmScalarField;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* An opaque position-varying scalar field. A value, not a builder (each constructor
|
|
63
|
+
* returns a fresh field). Fed to the `Sdf` modulated operators
|
|
64
|
+
* ({@link WasmSdf.offset_field} et al.) to vary an operator parameter per voxel.
|
|
65
|
+
* `free()` releases the backing WASM allocation. Structurally satisfied by the
|
|
66
|
+
* generated `ScalarField` wasm-bindgen class.
|
|
67
|
+
*/
|
|
68
|
+
export interface WasmScalarField {
|
|
69
|
+
/** Release the backing WASM allocation (wasm-bindgen lifecycle). */
|
|
70
|
+
free(): void;
|
|
71
|
+
[Symbol.dispose](): void;
|
|
72
|
+
}
|
|
42
73
|
/**
|
|
43
74
|
* Static surface of the wasm `Sdf` class: the primitive constructors that seed an
|
|
44
75
|
* expression tree (centered at the origin unless noted). Each returns a fresh
|
|
@@ -53,6 +84,24 @@ export interface WasmSdfConstructor {
|
|
|
53
84
|
capsule(ax: number, ay: number, az: number, bx: number, by: number, bz: number, r: number): WasmSdf;
|
|
54
85
|
torus(major: number, minor: number): WasmSdf;
|
|
55
86
|
plane(nx: number, ny: number, nz: number, h: number): WasmSdf;
|
|
87
|
+
/**
|
|
88
|
+
* Sweep an in-plane `profile` along `spine` (flat xyz, length 3·N, N >= 2)
|
|
89
|
+
* using rotation-minimizing frames. `closed` skips the end caps. Throws (as a
|
|
90
|
+
* JS exception) on fewer than two stations or a degenerate spine.
|
|
91
|
+
*/
|
|
92
|
+
sweep(spine: Float64Array, profile: WasmSdf, closed: boolean): WasmSdf;
|
|
93
|
+
/**
|
|
94
|
+
* A graded/conformal TPMS lattice node (`kind_tag`: 0=Gyroid, 1=SchwarzP,
|
|
95
|
+
* 2=Diamond) with per-position `period`/`thickness`. Periodic/infinite — clip via
|
|
96
|
+
* `intersection` before rasterize. Throws (as a JS exception) on a bad `kind_tag`.
|
|
97
|
+
*/
|
|
98
|
+
lattice(kind_tag: number, period: WasmScalarField, thickness: WasmScalarField): WasmSdf;
|
|
99
|
+
/**
|
|
100
|
+
* A cubic beam/strut lattice node with per-position `radius`. Periodic/infinite —
|
|
101
|
+
* clip via `intersection` before rasterize. Throws (as a JS exception) on a
|
|
102
|
+
* non-positive `period`.
|
|
103
|
+
*/
|
|
104
|
+
strut_lattice(period: number, radius: WasmScalarField): WasmSdf;
|
|
56
105
|
}
|
|
57
106
|
/**
|
|
58
107
|
* An opaque analytic SDF expression. Every combinator CLONES into a new node and
|
|
@@ -72,6 +121,10 @@ export interface WasmSdf {
|
|
|
72
121
|
round(r: number): WasmSdf;
|
|
73
122
|
shell(t: number): WasmSdf;
|
|
74
123
|
onion(t: number): WasmSdf;
|
|
124
|
+
offset_field(f: WasmScalarField): WasmSdf;
|
|
125
|
+
round_field(f: WasmScalarField): WasmSdf;
|
|
126
|
+
shell_field(f: WasmScalarField): WasmSdf;
|
|
127
|
+
smooth_union_field(other: WasmSdf, k: WasmScalarField): WasmSdf;
|
|
75
128
|
translate(x: number, y: number, z: number): WasmSdf;
|
|
76
129
|
rotate(ax: number, ay: number, az: number, angle: number): WasmSdf;
|
|
77
130
|
scale(s: number): WasmSdf;
|