brepjs 18.68.0 → 18.69.1
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 +148 -1
- package/dist/brepjs.js +144 -5
- package/dist/implicit/index.d.ts +4 -2
- package/dist/implicit/sdfFns.d.ts +78 -1
- package/dist/{importFns-CwILDYiQ.cjs → importFns-8zgPWa83.cjs} +30 -11
- package/dist/{importFns-1SHLSNtG.js → importFns-BAJm4qfD.js} +30 -11
- package/dist/index.d.ts +3 -3
- package/dist/io/gltfExportFns.d.ts +25 -0
- package/dist/io.cjs +1 -1
- package/dist/io.d.ts +1 -1
- package/dist/io.js +1 -1
- package/dist/voxel/engine.d.ts +53 -0
- package/package.json +1 -1
package/dist/brepjs.cjs
CHANGED
|
@@ -26,7 +26,7 @@ const require_measureFns = require("./measureFns-CrSEblGG.cjs");
|
|
|
26
26
|
const require_cornerFinder = require("./cornerFinder-tTS3ny7e.cjs");
|
|
27
27
|
const require_boolean2D = require("./boolean2D-xDBZQH_n.cjs");
|
|
28
28
|
const require_blueprintFns = require("./blueprintFns-DULa6FpG.cjs");
|
|
29
|
-
const require_importFns = require("./importFns-
|
|
29
|
+
const require_importFns = require("./importFns-8zgPWa83.cjs");
|
|
30
30
|
const require_extrudeFns = require("./extrudeFns-IvYW5-8y.cjs");
|
|
31
31
|
const require_cameraFns = require("./cameraFns-Bk8frXwa.cjs");
|
|
32
32
|
const require_textMetrics = require("./textMetrics-CnCjqf59.cjs");
|
|
@@ -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
|
@@ -24,8 +24,8 @@ import { a as measureDistance, c as measureLinearProps, d as measureVolumeProps,
|
|
|
24
24
|
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
|
-
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-
|
|
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";
|
|
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-BAJm4qfD.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>;
|
|
@@ -61,6 +61,24 @@ var FLOAT = 5126;
|
|
|
61
61
|
var UNSIGNED_INT = 5125;
|
|
62
62
|
var ARRAY_BUFFER = 34962;
|
|
63
63
|
var ELEMENT_ARRAY_BUFFER = 34963;
|
|
64
|
+
var Y_UP_QUAT = [
|
|
65
|
+
-Math.SQRT1_2,
|
|
66
|
+
0,
|
|
67
|
+
0,
|
|
68
|
+
Math.SQRT1_2
|
|
69
|
+
];
|
|
70
|
+
/**
|
|
71
|
+
* Scene-graph nodes for the single mesh. For Y-up (default) the mesh node is
|
|
72
|
+
* parented under a rotation node so the Z-up vertices display upright in glTF
|
|
73
|
+
* viewers; for Z-up the mesh node is the root with no transform.
|
|
74
|
+
*/
|
|
75
|
+
function sceneNodes(upAxis) {
|
|
76
|
+
return upAxis === "Z" ? [{ mesh: 0 }] : [{
|
|
77
|
+
name: "Z_up_to_Y_up",
|
|
78
|
+
rotation: Y_UP_QUAT,
|
|
79
|
+
children: [1]
|
|
80
|
+
}, { mesh: 0 }];
|
|
81
|
+
}
|
|
64
82
|
function computeMinMax(data) {
|
|
65
83
|
const min = [
|
|
66
84
|
Infinity,
|
|
@@ -209,7 +227,7 @@ function buildSingleBufferViews(indicesByteLength, verticesByteLength, normalsBy
|
|
|
209
227
|
function buildGltfDocument(mesh, mode, options) {
|
|
210
228
|
const { vertices, normals, triangles } = mesh;
|
|
211
229
|
const materialMap = options?.materials;
|
|
212
|
-
if (materialMap && materialMap.size > 0 && mesh.faceGroups.length > 0) return buildGltfDocumentWithMaterials(mesh, mode, materialMap);
|
|
230
|
+
if (materialMap && materialMap.size > 0 && mesh.faceGroups.length > 0) return buildGltfDocumentWithMaterials(mesh, mode, materialMap, options.upAxis ?? "Y");
|
|
213
231
|
const indicesByteLength = triangles.byteLength;
|
|
214
232
|
const verticesByteLength = vertices.byteLength;
|
|
215
233
|
const normalsByteLength = normals.byteLength;
|
|
@@ -222,7 +240,7 @@ function buildGltfDocument(mesh, mode, options) {
|
|
|
222
240
|
},
|
|
223
241
|
scene: 0,
|
|
224
242
|
scenes: [{ nodes: [0] }],
|
|
225
|
-
nodes:
|
|
243
|
+
nodes: sceneNodes(options?.upAxis ?? "Y"),
|
|
226
244
|
meshes: [{ primitives: [{
|
|
227
245
|
attributes: {
|
|
228
246
|
POSITION: 1,
|
|
@@ -250,14 +268,14 @@ function buildGltfDocument(mesh, mode, options) {
|
|
|
250
268
|
function buildGlbData(mesh, options) {
|
|
251
269
|
const materialMap = options?.materials;
|
|
252
270
|
if (materialMap && materialMap.size > 0 && mesh.faceGroups.length > 0) {
|
|
253
|
-
const { doc, binBuffer } = buildGltfDocumentAndBufferWithMaterials(mesh, materialMap);
|
|
271
|
+
const { doc, binBuffer } = buildGltfDocumentAndBufferWithMaterials(mesh, materialMap, options.upAxis ?? "Y");
|
|
254
272
|
return {
|
|
255
273
|
doc,
|
|
256
274
|
binBuffer
|
|
257
275
|
};
|
|
258
276
|
}
|
|
259
277
|
return {
|
|
260
|
-
doc: buildGltfDocument(mesh, "glb"),
|
|
278
|
+
doc: buildGltfDocument(mesh, "glb", options),
|
|
261
279
|
binBuffer: buildBinaryBuffer(mesh)
|
|
262
280
|
};
|
|
263
281
|
}
|
|
@@ -413,11 +431,12 @@ function appendIndexPrimitives(primitiveData, indexBufferInfos, verticesAccIdx,
|
|
|
413
431
|
/**
|
|
414
432
|
* Build a glTF document from material layout.
|
|
415
433
|
*/
|
|
416
|
-
function buildGltfDocFromLayout(mesh, layout) {
|
|
434
|
+
function buildGltfDocFromLayout(mesh, layout, upAxis = "Y") {
|
|
417
435
|
const { primitiveData, indexBufferInfos, verticesOffset, totalByteLength, uniqueMaterials } = layout;
|
|
418
436
|
const accessors = [];
|
|
419
437
|
const bufferViews = [];
|
|
420
438
|
const { verticesAccIdx, normalsAccIdx } = appendVertexNormalSections(mesh, verticesOffset, accessors, bufferViews);
|
|
439
|
+
const primitives = appendIndexPrimitives(primitiveData, indexBufferInfos, verticesAccIdx, normalsAccIdx, accessors, bufferViews);
|
|
421
440
|
return {
|
|
422
441
|
asset: {
|
|
423
442
|
version: "2.0",
|
|
@@ -425,8 +444,8 @@ function buildGltfDocFromLayout(mesh, layout) {
|
|
|
425
444
|
},
|
|
426
445
|
scene: 0,
|
|
427
446
|
scenes: [{ nodes: [0] }],
|
|
428
|
-
nodes:
|
|
429
|
-
meshes: [{ primitives
|
|
447
|
+
nodes: sceneNodes(upAxis),
|
|
448
|
+
meshes: [{ primitives }],
|
|
430
449
|
accessors,
|
|
431
450
|
bufferViews,
|
|
432
451
|
buffers: [{ byteLength: totalByteLength }],
|
|
@@ -453,9 +472,9 @@ function buildBinaryBufferFromLayout(mesh, layout) {
|
|
|
453
472
|
/**
|
|
454
473
|
* Build a glTF document with per-material primitives (base64 mode).
|
|
455
474
|
*/
|
|
456
|
-
function buildGltfDocumentWithMaterials(mesh, _mode, materialMap) {
|
|
475
|
+
function buildGltfDocumentWithMaterials(mesh, _mode, materialMap, upAxis = "Y") {
|
|
457
476
|
const layout = computeMaterialLayout(mesh, materialMap);
|
|
458
|
-
const doc = buildGltfDocFromLayout(mesh, layout);
|
|
477
|
+
const doc = buildGltfDocFromLayout(mesh, layout, upAxis);
|
|
459
478
|
if (_mode === "base64") {
|
|
460
479
|
const buffer = buildBinaryBufferFromLayout(mesh, layout);
|
|
461
480
|
doc.buffers[0] = {
|
|
@@ -468,10 +487,10 @@ function buildGltfDocumentWithMaterials(mesh, _mode, materialMap) {
|
|
|
468
487
|
/**
|
|
469
488
|
* Build both glTF document and binary buffer for GLB with materials.
|
|
470
489
|
*/
|
|
471
|
-
function buildGltfDocumentAndBufferWithMaterials(mesh, materialMap) {
|
|
490
|
+
function buildGltfDocumentAndBufferWithMaterials(mesh, materialMap, upAxis = "Y") {
|
|
472
491
|
const layout = computeMaterialLayout(mesh, materialMap);
|
|
473
492
|
return {
|
|
474
|
-
doc: buildGltfDocFromLayout(mesh, layout),
|
|
493
|
+
doc: buildGltfDocFromLayout(mesh, layout, upAxis),
|
|
475
494
|
binBuffer: buildBinaryBufferFromLayout(mesh, layout)
|
|
476
495
|
};
|
|
477
496
|
}
|
|
@@ -61,6 +61,24 @@ var FLOAT = 5126;
|
|
|
61
61
|
var UNSIGNED_INT = 5125;
|
|
62
62
|
var ARRAY_BUFFER = 34962;
|
|
63
63
|
var ELEMENT_ARRAY_BUFFER = 34963;
|
|
64
|
+
var Y_UP_QUAT = [
|
|
65
|
+
-Math.SQRT1_2,
|
|
66
|
+
0,
|
|
67
|
+
0,
|
|
68
|
+
Math.SQRT1_2
|
|
69
|
+
];
|
|
70
|
+
/**
|
|
71
|
+
* Scene-graph nodes for the single mesh. For Y-up (default) the mesh node is
|
|
72
|
+
* parented under a rotation node so the Z-up vertices display upright in glTF
|
|
73
|
+
* viewers; for Z-up the mesh node is the root with no transform.
|
|
74
|
+
*/
|
|
75
|
+
function sceneNodes(upAxis) {
|
|
76
|
+
return upAxis === "Z" ? [{ mesh: 0 }] : [{
|
|
77
|
+
name: "Z_up_to_Y_up",
|
|
78
|
+
rotation: Y_UP_QUAT,
|
|
79
|
+
children: [1]
|
|
80
|
+
}, { mesh: 0 }];
|
|
81
|
+
}
|
|
64
82
|
function computeMinMax(data) {
|
|
65
83
|
const min = [
|
|
66
84
|
Infinity,
|
|
@@ -209,7 +227,7 @@ function buildSingleBufferViews(indicesByteLength, verticesByteLength, normalsBy
|
|
|
209
227
|
function buildGltfDocument(mesh, mode, options) {
|
|
210
228
|
const { vertices, normals, triangles } = mesh;
|
|
211
229
|
const materialMap = options?.materials;
|
|
212
|
-
if (materialMap && materialMap.size > 0 && mesh.faceGroups.length > 0) return buildGltfDocumentWithMaterials(mesh, mode, materialMap);
|
|
230
|
+
if (materialMap && materialMap.size > 0 && mesh.faceGroups.length > 0) return buildGltfDocumentWithMaterials(mesh, mode, materialMap, options.upAxis ?? "Y");
|
|
213
231
|
const indicesByteLength = triangles.byteLength;
|
|
214
232
|
const verticesByteLength = vertices.byteLength;
|
|
215
233
|
const normalsByteLength = normals.byteLength;
|
|
@@ -222,7 +240,7 @@ function buildGltfDocument(mesh, mode, options) {
|
|
|
222
240
|
},
|
|
223
241
|
scene: 0,
|
|
224
242
|
scenes: [{ nodes: [0] }],
|
|
225
|
-
nodes:
|
|
243
|
+
nodes: sceneNodes(options?.upAxis ?? "Y"),
|
|
226
244
|
meshes: [{ primitives: [{
|
|
227
245
|
attributes: {
|
|
228
246
|
POSITION: 1,
|
|
@@ -250,14 +268,14 @@ function buildGltfDocument(mesh, mode, options) {
|
|
|
250
268
|
function buildGlbData(mesh, options) {
|
|
251
269
|
const materialMap = options?.materials;
|
|
252
270
|
if (materialMap && materialMap.size > 0 && mesh.faceGroups.length > 0) {
|
|
253
|
-
const { doc, binBuffer } = buildGltfDocumentAndBufferWithMaterials(mesh, materialMap);
|
|
271
|
+
const { doc, binBuffer } = buildGltfDocumentAndBufferWithMaterials(mesh, materialMap, options.upAxis ?? "Y");
|
|
254
272
|
return {
|
|
255
273
|
doc,
|
|
256
274
|
binBuffer
|
|
257
275
|
};
|
|
258
276
|
}
|
|
259
277
|
return {
|
|
260
|
-
doc: buildGltfDocument(mesh, "glb"),
|
|
278
|
+
doc: buildGltfDocument(mesh, "glb", options),
|
|
261
279
|
binBuffer: buildBinaryBuffer(mesh)
|
|
262
280
|
};
|
|
263
281
|
}
|
|
@@ -413,11 +431,12 @@ function appendIndexPrimitives(primitiveData, indexBufferInfos, verticesAccIdx,
|
|
|
413
431
|
/**
|
|
414
432
|
* Build a glTF document from material layout.
|
|
415
433
|
*/
|
|
416
|
-
function buildGltfDocFromLayout(mesh, layout) {
|
|
434
|
+
function buildGltfDocFromLayout(mesh, layout, upAxis = "Y") {
|
|
417
435
|
const { primitiveData, indexBufferInfos, verticesOffset, totalByteLength, uniqueMaterials } = layout;
|
|
418
436
|
const accessors = [];
|
|
419
437
|
const bufferViews = [];
|
|
420
438
|
const { verticesAccIdx, normalsAccIdx } = appendVertexNormalSections(mesh, verticesOffset, accessors, bufferViews);
|
|
439
|
+
const primitives = appendIndexPrimitives(primitiveData, indexBufferInfos, verticesAccIdx, normalsAccIdx, accessors, bufferViews);
|
|
421
440
|
return {
|
|
422
441
|
asset: {
|
|
423
442
|
version: "2.0",
|
|
@@ -425,8 +444,8 @@ function buildGltfDocFromLayout(mesh, layout) {
|
|
|
425
444
|
},
|
|
426
445
|
scene: 0,
|
|
427
446
|
scenes: [{ nodes: [0] }],
|
|
428
|
-
nodes:
|
|
429
|
-
meshes: [{ primitives
|
|
447
|
+
nodes: sceneNodes(upAxis),
|
|
448
|
+
meshes: [{ primitives }],
|
|
430
449
|
accessors,
|
|
431
450
|
bufferViews,
|
|
432
451
|
buffers: [{ byteLength: totalByteLength }],
|
|
@@ -453,9 +472,9 @@ function buildBinaryBufferFromLayout(mesh, layout) {
|
|
|
453
472
|
/**
|
|
454
473
|
* Build a glTF document with per-material primitives (base64 mode).
|
|
455
474
|
*/
|
|
456
|
-
function buildGltfDocumentWithMaterials(mesh, _mode, materialMap) {
|
|
475
|
+
function buildGltfDocumentWithMaterials(mesh, _mode, materialMap, upAxis = "Y") {
|
|
457
476
|
const layout = computeMaterialLayout(mesh, materialMap);
|
|
458
|
-
const doc = buildGltfDocFromLayout(mesh, layout);
|
|
477
|
+
const doc = buildGltfDocFromLayout(mesh, layout, upAxis);
|
|
459
478
|
if (_mode === "base64") {
|
|
460
479
|
const buffer = buildBinaryBufferFromLayout(mesh, layout);
|
|
461
480
|
doc.buffers[0] = {
|
|
@@ -468,10 +487,10 @@ function buildGltfDocumentWithMaterials(mesh, _mode, materialMap) {
|
|
|
468
487
|
/**
|
|
469
488
|
* Build both glTF document and binary buffer for GLB with materials.
|
|
470
489
|
*/
|
|
471
|
-
function buildGltfDocumentAndBufferWithMaterials(mesh, materialMap) {
|
|
490
|
+
function buildGltfDocumentAndBufferWithMaterials(mesh, materialMap, upAxis = "Y") {
|
|
472
491
|
const layout = computeMaterialLayout(mesh, materialMap);
|
|
473
492
|
return {
|
|
474
|
-
doc: buildGltfDocFromLayout(mesh, layout),
|
|
493
|
+
doc: buildGltfDocFromLayout(mesh, layout, upAxis),
|
|
475
494
|
binBuffer: buildBinaryBufferFromLayout(mesh, layout)
|
|
476
495
|
};
|
|
477
496
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -33,15 +33,15 @@ export { reverseCurve, curve2dBoundingBox, curve2dFirstPoint, curve2dLastPoint,
|
|
|
33
33
|
export { createBlueprint, createCompoundBlueprint, getBounds2D, getOrientation2D, isInside2D, toSVGPathD, translate2D, rotate2D, scale2D, mirror2D, stretch2D, sketchOnPlane2D, sketchOnFace2D, } from './2d/blueprints/blueprintFns.js';
|
|
34
34
|
export { getSingleFace, type SingleFace } from './query/helpers.js';
|
|
35
35
|
export { exportOBJ } from './io/objExportFns.js';
|
|
36
|
-
export { exportGltf, exportGlb, type GltfMaterial, type GltfExportOptions, } from './io/gltfExportFns.js';
|
|
36
|
+
export { exportGltf, exportGlb, type GltfMaterial, type GltfExportOptions, type GltfFace, type MaterialFn, } from './io/gltfExportFns.js';
|
|
37
37
|
export { exportDXF, blueprintToDXF, type DXFEntity, type DXFExportOptions, } from './io/dxfExportFns.js';
|
|
38
38
|
export { exportThreeMF, type ThreeMFExportOptions, type ThreeMFMaterial, } from './io/threemfExportFns.js';
|
|
39
39
|
export { importSVGPathD, importSVG, type SVGImportOptions } from './io/svgImportFns.js';
|
|
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';
|
|
@@ -14,6 +14,23 @@ export interface GltfMaterial {
|
|
|
14
14
|
/** Roughness factor 0–1. Default: 0.5 */
|
|
15
15
|
roughness?: number;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* A meshed face as presented to a {@link MaterialFn} — its stable id and the
|
|
19
|
+
* centroid of its triangles in part coordinates (Z-up, mm).
|
|
20
|
+
*/
|
|
21
|
+
export interface GltfFace {
|
|
22
|
+
/** Stable face identifier — matches ShapeMesh.faceGroups[].faceId. */
|
|
23
|
+
faceId: number;
|
|
24
|
+
/** Centroid of the face's vertices, in part (Z-up, mm) coordinates. */
|
|
25
|
+
center: [number, number, number];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Per-face material selector. Called once per face group; return a material to
|
|
29
|
+
* paint that face, or `undefined` to leave it at the glTF default. Consumed by
|
|
30
|
+
* tooling (e.g. brepjs-verify's `export const materials`) that has the mesh and
|
|
31
|
+
* builds the faceId→material map passed to {@link GltfExportOptions.materials}.
|
|
32
|
+
*/
|
|
33
|
+
export type MaterialFn = (face: GltfFace) => GltfMaterial | undefined;
|
|
17
34
|
/**
|
|
18
35
|
* Options for glTF/GLB export.
|
|
19
36
|
*
|
|
@@ -23,6 +40,14 @@ export interface GltfMaterial {
|
|
|
23
40
|
export interface GltfExportOptions {
|
|
24
41
|
/** Map of faceId → material. FaceIds come from ShapeMesh.faceGroups[].faceId. */
|
|
25
42
|
materials?: Map<number, GltfMaterial>;
|
|
43
|
+
/**
|
|
44
|
+
* Up-axis of the emitted document. brepjs geometry is Z-up (CAD convention),
|
|
45
|
+
* but glTF 2.0 mandates Y-up. With `'Y'` (the default) a root node carrying a
|
|
46
|
+
* −90° rotation about X is emitted so the part stands upright in standard glTF
|
|
47
|
+
* viewers (three.js, model-viewer, Blender); vertex data stays Z-up, matching
|
|
48
|
+
* the STEP/STL exports. Use `'Z'` to emit raw Z-up coordinates with no root node.
|
|
49
|
+
*/
|
|
50
|
+
upAxis?: 'Y' | 'Z';
|
|
26
51
|
}
|
|
27
52
|
/**
|
|
28
53
|
* Export a ShapeMesh to a glTF 2.0 JSON string with an embedded base64 buffer.
|
package/dist/io.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_meshFns = require("./meshFns-DwHAYqRN.cjs");
|
|
3
|
-
const require_importFns = require("./importFns-
|
|
3
|
+
const require_importFns = require("./importFns-8zgPWa83.cjs");
|
|
4
4
|
exports.blueprintToDXF = require_importFns.blueprintToDXF;
|
|
5
5
|
exports.exportDXF = require_importFns.exportDXF;
|
|
6
6
|
exports.exportGlb = require_importFns.exportGlb;
|
package/dist/io.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
export { importSTEP, importSTL, importIGES } from './io/importFns.js';
|
|
10
10
|
export { exportSTEP, exportSTL, exportIGES } from './topology/meshFns.js';
|
|
11
11
|
export { exportOBJ } from './io/objExportFns.js';
|
|
12
|
-
export { exportGltf, exportGlb, type GltfMaterial, type GltfExportOptions, } from './io/gltfExportFns.js';
|
|
12
|
+
export { exportGltf, exportGlb, type GltfMaterial, type GltfExportOptions, type GltfFace, type MaterialFn, } from './io/gltfExportFns.js';
|
|
13
13
|
export { exportDXF, blueprintToDXF, type DXFEntity, type DXFExportOptions, } from './io/dxfExportFns.js';
|
|
14
14
|
export { exportThreeMF, type ThreeMFExportOptions, type ThreeMFMaterial, } from './io/threemfExportFns.js';
|
|
15
15
|
export { importSVGPathD, importSVG, type SVGImportOptions } from './io/svgImportFns.js';
|
package/dist/io.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { n as exportSTEP, r as exportSTL, t as exportIGES } from "./meshFns-0RHalM3t.js";
|
|
2
|
-
import { a as importSVG, c as blueprintToDXF, d as exportGltf, f as exportOBJ, i as exportSTEPConfigured, l as exportDXF, n as importSTEP, o as importSVGPathD, r as importSTL, s as exportThreeMF, t as importIGES, u as exportGlb } from "./importFns-
|
|
2
|
+
import { a as importSVG, c as blueprintToDXF, d as exportGltf, f as exportOBJ, i as exportSTEPConfigured, l as exportDXF, n as importSTEP, o as importSVGPathD, r as importSTL, s as exportThreeMF, t as importIGES, u as exportGlb } from "./importFns-BAJm4qfD.js";
|
|
3
3
|
export { blueprintToDXF, exportDXF, exportGlb, exportGltf, exportIGES, exportOBJ, exportSTEP, exportSTEPConfigured, exportSTL, exportThreeMF, importIGES, importSTEP, importSTL, importSVG, importSVGPathD };
|
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;
|