fast-mesh-wasm 0.6.0 → 0.7.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/{client-BrTp2eMp.js → client-DFgvktkT.js} +164 -10
- package/dist/{client-Ds09vLkN.d.ts → client-nvmbhtn-.d.ts} +76 -14
- package/dist/{engine-DjdY3GxK.js → engine-BL5_sWAf.js} +15 -4
- package/dist/io.d.ts +200 -2
- package/dist/io.js +3057 -3
- package/dist/{mesh-BsqIofgT.d.ts → mesh-BHTFxsXc.d.ts} +1 -1
- package/dist/node.d.ts +2 -2
- package/dist/node.js +3 -2
- package/dist/{protocol-Cb23HelE.d.ts → protocol-DFR0JDAS.d.ts} +3 -1
- package/dist/r3f.d.ts +3 -3
- package/dist/r3f.js +1 -1
- package/dist/react.d.ts +2 -2
- package/dist/{scene-D0HNTwoo.js → scene-DUsj6uJD.js} +346 -30
- package/dist/{scene-like-CADk1vfb.d.ts → scene-like-CR_Dpohm.d.ts} +902 -146
- package/dist/{store-BfC6kkf5.d.ts → store-8HWG90Jg.d.ts} +14 -3
- package/dist/{store-DIQmxF_s.js → store-BAzHRRkt.js} +18 -2
- package/dist/store.d.ts +3 -3
- package/dist/store.js +1 -1
- package/dist/three.d.ts +2 -2
- package/dist/views-BSy-Qeg8.js +584 -0
- package/dist/wasm/fast_mesh_wasm.d.ts +7 -0
- package/dist/wasm/fast_mesh_wasm.js +21 -0
- package/dist/wasm/fast_mesh_wasm_bg.wasm +0 -0
- package/dist/wasm/fast_mesh_wasm_bg.wasm.d.ts +1 -0
- package/dist/wasm-threads/fast_mesh_wasm.d.ts +7 -0
- package/dist/wasm-threads/fast_mesh_wasm.js +21 -0
- package/dist/wasm-threads/fast_mesh_wasm_bg.wasm +0 -0
- package/dist/wasm-threads/fast_mesh_wasm_bg.wasm.d.ts +1 -0
- package/dist/web.d.ts +2 -2
- package/dist/web.js +3 -2
- package/dist/worker-engine.d.ts +1 -1
- package/dist/worker-engine.js +1 -1
- package/dist/worker-entry.js +1 -1
- package/dist/worker.d.ts +1 -1
- package/dist/worker.js +1 -1
- package/package.json +1 -1
- package/dist/views-B00kdV0R.js +0 -214
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as encodeRule, c as SectionHandle, d as checkRegisterOptions, i as copyRule, l as rotationMatrix, n as meshViews, o as FieldHandle, r as checkInteractionPoints, s as MeshHandle, t as ViewGuard, u as targetsOf } from "./views-
|
|
1
|
+
import { _ as createBooleanDomain, a as encodeRule, c as SectionHandle, d as checkRegisterOptions, f as createSculptDomain, g as createDeformDomain, h as createInspectDomain, i as copyRule, l as rotationMatrix, m as createRemeshDomain, n as meshViews, o as FieldHandle, p as createRepairDomain, r as checkInteractionPoints, s as MeshHandle, t as ViewGuard, u as targetsOf, v as createAlignDomain } from "./views-BSy-Qeg8.js";
|
|
2
2
|
import { a as release, c as wasmMemory, i as finalizer, n as call, r as ensureInitialized, t as FastMeshError } from "./core-4OcWKu3r.js";
|
|
3
3
|
import { WasmScene } from "./wasm/fast_mesh_wasm.js";
|
|
4
4
|
// src/changes.ts
|
|
@@ -316,6 +316,8 @@ const meshIds = /* @__PURE__ */ new WeakMap();
|
|
|
316
316
|
const rawIds = /* @__PURE__ */ new WeakMap();
|
|
317
317
|
/** The repair list's prefix code for a {@link VertexProtection}. */
|
|
318
318
|
const PROTECT_CODE = 32;
|
|
319
|
+
/** The repair list's prefix code for {@link Symmetry} and {@link SurfaceFilter}. */
|
|
320
|
+
const BRUSH_MODIFIERS_CODE = 33;
|
|
319
321
|
const MODES = {
|
|
320
322
|
eager: 0,
|
|
321
323
|
lazy: 1,
|
|
@@ -478,14 +480,86 @@ const REPAIR_CODES = {
|
|
|
478
480
|
simplify: 13,
|
|
479
481
|
subdivide: 14,
|
|
480
482
|
splitStretched: 16,
|
|
481
|
-
captureRestSizes: 17
|
|
483
|
+
captureRestSizes: 17,
|
|
484
|
+
captureStrokeState: 18,
|
|
485
|
+
flatten: 19,
|
|
486
|
+
crease: 20,
|
|
487
|
+
clay: 21,
|
|
488
|
+
twist: 22,
|
|
489
|
+
makeManifold: 23,
|
|
490
|
+
resolveSelfIntersections: 24,
|
|
491
|
+
cleanupSlivers: 25
|
|
482
492
|
};
|
|
483
|
-
/** The op code of
|
|
493
|
+
/** The op code of a legacy {@link AutoRepairRequest}; see `crate::edit` in the Rust crate. */
|
|
484
494
|
const AUTO_REPAIR_CODE = 15;
|
|
495
|
+
/** The op code of an extended preset {@link AutoRepairRequest}; see `crate::edit` in the Rust crate. */
|
|
496
|
+
const AUTO_REPAIR_PRESET_CODE = 26;
|
|
497
|
+
const AUTO_STAGE_OPS = {
|
|
498
|
+
0: "weld",
|
|
499
|
+
1: "removeDegenerate",
|
|
500
|
+
2: "removeSmallComponents",
|
|
501
|
+
3: "orient",
|
|
502
|
+
4: "fillHoles",
|
|
503
|
+
23: "makeManifold",
|
|
504
|
+
24: "resolveSelfIntersections",
|
|
505
|
+
25: "cleanupSlivers"
|
|
506
|
+
};
|
|
507
|
+
const PRESET_CODES = {
|
|
508
|
+
general: 0,
|
|
509
|
+
scan3d: 1,
|
|
510
|
+
print3d: 2,
|
|
511
|
+
cadImport: 3
|
|
512
|
+
};
|
|
513
|
+
const SELF_INTERSECTION_MODES = [
|
|
514
|
+
"none",
|
|
515
|
+
"deleteAndFill",
|
|
516
|
+
"cutAndStitch",
|
|
517
|
+
"voxelHeal"
|
|
518
|
+
];
|
|
519
|
+
const SELF_INTERSECTION_MODE_CODES = {
|
|
520
|
+
none: 0,
|
|
521
|
+
deleteAndFill: 1,
|
|
522
|
+
cutAndStitch: 2,
|
|
523
|
+
voxelHeal: 3
|
|
524
|
+
};
|
|
485
525
|
const FALLOFF_CODES = {
|
|
486
526
|
linear: 0,
|
|
487
527
|
smooth: 1
|
|
488
528
|
};
|
|
529
|
+
const INFLATE_METHOD_CODES = {
|
|
530
|
+
vertexNormal: 0,
|
|
531
|
+
averageNormal: 1,
|
|
532
|
+
strokeNormal: 2
|
|
533
|
+
};
|
|
534
|
+
const SMOOTH_METHOD_CODES = {
|
|
535
|
+
taubin: 0,
|
|
536
|
+
laplacian: 1,
|
|
537
|
+
hcLaplacian: 2,
|
|
538
|
+
cotangent: 3
|
|
539
|
+
};
|
|
540
|
+
const GRAB_METHOD_CODES = {
|
|
541
|
+
sphere: 0,
|
|
542
|
+
geodesic: 1,
|
|
543
|
+
kelvinlet: 2
|
|
544
|
+
};
|
|
545
|
+
const FLATTEN_MODE_CODES = {
|
|
546
|
+
both: 0,
|
|
547
|
+
peaks: 1,
|
|
548
|
+
valleys: 2
|
|
549
|
+
};
|
|
550
|
+
const CLAY_PROFILE_CODES = {
|
|
551
|
+
round: 0,
|
|
552
|
+
strips: 1
|
|
553
|
+
};
|
|
554
|
+
const TWIST_METHOD_CODES = {
|
|
555
|
+
vortex: 0,
|
|
556
|
+
kelvinlet: 1
|
|
557
|
+
};
|
|
558
|
+
const OFFSET_ALGORITHM_CODES = {
|
|
559
|
+
normal: 0,
|
|
560
|
+
fhEdt: 1,
|
|
561
|
+
bvhSdf: 2
|
|
562
|
+
};
|
|
489
563
|
const SUBDIVIDE_METHOD_CODES = { loop: 0 };
|
|
490
564
|
/** An optional number for the binding: NaN when unset; an explicit NaN is rejected. */
|
|
491
565
|
/** The `status` codes of `WasmScene.register`, in order. */
|
|
@@ -512,6 +586,16 @@ function optional(v, what) {
|
|
|
512
586
|
function flagOf(v, fallback) {
|
|
513
587
|
return v ?? fallback ? 1 : 0;
|
|
514
588
|
}
|
|
589
|
+
function optVoxelSize(v) {
|
|
590
|
+
if (v === void 0) return NaN;
|
|
591
|
+
if (typeof v !== "number" || !Number.isFinite(v) || v <= 0) throw invalid("voxelSize must be positive and finite");
|
|
592
|
+
return v;
|
|
593
|
+
}
|
|
594
|
+
function optMaxVoxels(v) {
|
|
595
|
+
if (v === void 0) return NaN;
|
|
596
|
+
if (typeof v !== "number" || !Number.isInteger(v) || v < 64 || v > Number.MAX_SAFE_INTEGER) throw invalid("maxVoxels must be an integer of at least 64");
|
|
597
|
+
return v;
|
|
598
|
+
}
|
|
515
599
|
/** A brush center as 3 values; anything else is `INVALID_ARGUMENT`. */
|
|
516
600
|
function centerOf(center, values) {
|
|
517
601
|
const c = center;
|
|
@@ -532,24 +616,76 @@ function encodeLoopId(id, out) {
|
|
|
532
616
|
function isAutoRepair(op) {
|
|
533
617
|
return op?.kind === "auto";
|
|
534
618
|
}
|
|
619
|
+
function optionalVec3(v, what, values) {
|
|
620
|
+
if (v === void 0) {
|
|
621
|
+
values.push(0, 0, 0, 0);
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
const c = v;
|
|
625
|
+
if (c?.length !== 3 || ![
|
|
626
|
+
c[0],
|
|
627
|
+
c[1],
|
|
628
|
+
c[2]
|
|
629
|
+
].every((x) => typeof x === "number" && Number.isFinite(x))) throw invalid(`${what} must be 3 finite numbers`);
|
|
630
|
+
values.push(1, c[0], c[1], c[2]);
|
|
631
|
+
}
|
|
535
632
|
/** The prefix that wraps the op after it in a {@link VertexProtection}; see `crate::edit` in the Rust crate. */
|
|
536
633
|
function encodeProtect(protect, values) {
|
|
537
|
-
const { vertices, weights } = protect;
|
|
634
|
+
const { vertices, weights, band } = protect;
|
|
538
635
|
if (vertices?.length === void 0) throw invalid("protect.vertices must be an array of vertex ids");
|
|
539
636
|
const n = vertices.length;
|
|
540
637
|
if (weights !== void 0 && weights.length !== n) throw invalid("protect.weights must have one weight per vertex");
|
|
541
|
-
values.push(PROTECT_CODE, n);
|
|
638
|
+
values.push(PROTECT_CODE, n, optional(band, "protect.band"));
|
|
542
639
|
for (let k = 0; k < n; k++) values.push(vertices[k]);
|
|
543
640
|
for (let k = 0; k < n; k++) values.push(weights === void 0 ? 0 : weights[k]);
|
|
544
641
|
}
|
|
642
|
+
/** Encodes prefix `33` (`brushModifiers`: symmetry + surface filter) before a brush op. */
|
|
643
|
+
function encodeBrushModifiers(symmetry, filter, values) {
|
|
644
|
+
if (symmetry === void 0 && filter === void 0) return;
|
|
645
|
+
let symMask = 0;
|
|
646
|
+
if (symmetry !== void 0) {
|
|
647
|
+
if (typeof symmetry !== "object" || symmetry === null) throw invalid("symmetry must be an object");
|
|
648
|
+
if (symmetry.x) symMask |= 1;
|
|
649
|
+
if (symmetry.y) symMask |= 2;
|
|
650
|
+
if (symmetry.z) symMask |= 4;
|
|
651
|
+
}
|
|
652
|
+
let filterKind = 0;
|
|
653
|
+
let p0 = NaN;
|
|
654
|
+
let p1 = NaN;
|
|
655
|
+
let normal;
|
|
656
|
+
if (filter !== void 0) {
|
|
657
|
+
if (typeof filter !== "object" || filter === null) throw invalid("filter must be an object");
|
|
658
|
+
switch (filter.kind) {
|
|
659
|
+
case "none": break;
|
|
660
|
+
case "peaksOnly":
|
|
661
|
+
case "valleysOnly":
|
|
662
|
+
filterKind = filter.kind === "peaksOnly" ? 1 : 2;
|
|
663
|
+
p0 = optional(filter.threshold, "filter.threshold");
|
|
664
|
+
p1 = optional(filter.contrast, "filter.contrast");
|
|
665
|
+
break;
|
|
666
|
+
case "normalAngle":
|
|
667
|
+
filterKind = 3;
|
|
668
|
+
p0 = optional(filter.maxAngleDeg, "filter.maxAngleDeg");
|
|
669
|
+
normal = filter.normal;
|
|
670
|
+
break;
|
|
671
|
+
default: throw invalid("filter.kind must be \"none\", \"peaksOnly\", \"valleysOnly\" or \"normalAngle\"");
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
values.push(BRUSH_MODIFIERS_CODE, symMask, filterKind, p0, p1);
|
|
675
|
+
optionalVec3(normal, "filter.normal", values);
|
|
676
|
+
}
|
|
545
677
|
/** A repair op list as the binding's `(ops, loops)`; see `crate::edit` in the Rust crate. */
|
|
546
678
|
function encodeRepair(ops) {
|
|
547
679
|
const values = [];
|
|
548
680
|
const loops = [];
|
|
549
681
|
for (const o of ops) {
|
|
682
|
+
const code = codeIn(REPAIR_CODES, o?.op, "repair op");
|
|
550
683
|
const protect = o?.protect;
|
|
551
684
|
if (protect !== void 0) encodeProtect(protect, values);
|
|
552
|
-
|
|
685
|
+
const symmetry = o?.symmetry;
|
|
686
|
+
const filter = o?.filter;
|
|
687
|
+
encodeBrushModifiers(symmetry, filter, values);
|
|
688
|
+
values.push(code);
|
|
553
689
|
switch (o.op) {
|
|
554
690
|
case "weld":
|
|
555
691
|
values.push(optional(o.tolerance, "tolerance"));
|
|
@@ -573,9 +709,12 @@ function encodeRepair(ops) {
|
|
|
573
709
|
}
|
|
574
710
|
case "inflate":
|
|
575
711
|
centerOf(o.center, values);
|
|
576
|
-
values.push(optional(o.radius, "radius"), codeIn(FALLOFF_CODES, o.falloff, "falloff"), optional(o.strength, "strength"));
|
|
712
|
+
values.push(optional(o.radius, "radius"), codeIn(FALLOFF_CODES, o.falloff, "falloff"), optional(o.strength, "strength"), o.method === void 0 ? NaN : codeIn(INFLATE_METHOD_CODES, o.method, "inflate method"));
|
|
577
713
|
break;
|
|
578
714
|
case "smooth":
|
|
715
|
+
centerOf(o.center, values);
|
|
716
|
+
values.push(optional(o.radius, "radius"), codeIn(FALLOFF_CODES, o.falloff, "falloff"), optional(o.strength, "strength"), optional(o.cycles, "cycles"), o.method === void 0 ? NaN : codeIn(SMOOTH_METHOD_CODES, o.method, "smooth method"));
|
|
717
|
+
break;
|
|
579
718
|
case "relax":
|
|
580
719
|
centerOf(o.center, values);
|
|
581
720
|
values.push(optional(o.radius, "radius"), codeIn(FALLOFF_CODES, o.falloff, "falloff"), optional(o.strength, "strength"), optional(o.cycles, "cycles"));
|
|
@@ -598,12 +737,35 @@ function encodeRepair(ops) {
|
|
|
598
737
|
d[1],
|
|
599
738
|
d[2]
|
|
600
739
|
].every(Number.isFinite)) throw invalid("direction must be 3 finite numbers");
|
|
601
|
-
values.push(d[0], d[1], d[2]);
|
|
740
|
+
values.push(d[0], d[1], d[2], o.method === void 0 ? NaN : codeIn(GRAB_METHOD_CODES, o.method, "grab method"), optional(o.poisson, "poisson"), flagOf(o.fromStroke, false), flagOf(o.adaptiveReach, false));
|
|
602
741
|
break;
|
|
603
742
|
}
|
|
604
|
-
case "
|
|
605
|
-
|
|
743
|
+
case "flatten":
|
|
744
|
+
centerOf(o.center, values);
|
|
745
|
+
values.push(optional(o.radius, "radius"), codeIn(FALLOFF_CODES, o.falloff, "falloff"), optional(o.strength, "strength"), o.mode === void 0 ? NaN : codeIn(FLATTEN_MODE_CODES, o.mode, "flatten mode"));
|
|
746
|
+
optionalVec3(o.planeOrigin, "planeOrigin", values);
|
|
747
|
+
optionalVec3(o.planeNormal, "planeNormal", values);
|
|
748
|
+
break;
|
|
749
|
+
case "crease":
|
|
750
|
+
centerOf(o.center, values);
|
|
751
|
+
values.push(optional(o.radius, "radius"), codeIn(FALLOFF_CODES, o.falloff, "falloff"), optional(o.strength, "strength"), optional(o.pinch, "pinch"));
|
|
606
752
|
break;
|
|
753
|
+
case "clay":
|
|
754
|
+
centerOf(o.center, values);
|
|
755
|
+
values.push(optional(o.radius, "radius"), codeIn(FALLOFF_CODES, o.falloff, "falloff"), optional(o.strength, "strength"), o.profile === void 0 ? NaN : codeIn(CLAY_PROFILE_CODES, o.profile, "clay profile"));
|
|
756
|
+
optionalVec3(o.tangent, "tangent", values);
|
|
757
|
+
break;
|
|
758
|
+
case "twist":
|
|
759
|
+
centerOf(o.center, values);
|
|
760
|
+
values.push(optional(o.radius, "radius"), codeIn(FALLOFF_CODES, o.falloff, "falloff"), optional(o.strength, "strength"), o.method === void 0 ? NaN : codeIn(TWIST_METHOD_CODES, o.method, "twist method"));
|
|
761
|
+
optionalVec3(o.axis, "axis", values);
|
|
762
|
+
break;
|
|
763
|
+
case "offset": {
|
|
764
|
+
const distance = optional(o.distance, "distance");
|
|
765
|
+
const alg = o.algorithm === void 0 ? NaN : codeIn(OFFSET_ALGORITHM_CODES, o.algorithm, "algorithm");
|
|
766
|
+
values.push(distance, alg, optVoxelSize(o.voxelSize), optMaxVoxels(o.maxVoxels));
|
|
767
|
+
break;
|
|
768
|
+
}
|
|
607
769
|
case "shell":
|
|
608
770
|
values.push(optional(o.thickness, "thickness"));
|
|
609
771
|
break;
|
|
@@ -615,9 +777,19 @@ function encodeRepair(ops) {
|
|
|
615
777
|
break;
|
|
616
778
|
case "splitStretched":
|
|
617
779
|
centerOf(o.center, values);
|
|
618
|
-
values.push(optional(o.radius, "radius"), optional(o.limit, "limit"), optional(o.maxSplits, "maxSplits"), flagOf(o.smooth, true));
|
|
780
|
+
values.push(optional(o.radius, "radius"), optional(o.limit, "limit"), optional(o.maxSplits, "maxSplits"), flagOf(o.smooth, true), optional(o.sharpAngle, "sharpAngle"));
|
|
781
|
+
break;
|
|
782
|
+
case "captureRestSizes":
|
|
783
|
+
case "captureStrokeState":
|
|
784
|
+
values.push(flagOf(o.onlyIfMissing, false));
|
|
785
|
+
break;
|
|
786
|
+
case "makeManifold":
|
|
787
|
+
values.push(flagOf(o.removeDuplicates, true), flagOf(o.pruneFins, true), flagOf(o.splitNonManifoldEdges, true), flagOf(o.splitPinchVertices, true));
|
|
619
788
|
break;
|
|
620
|
-
case "
|
|
789
|
+
case "resolveSelfIntersections":
|
|
790
|
+
values.push(o.mode === void 0 ? NaN : codeIn(SELF_INTERSECTION_MODE_CODES, o.mode, "mode"), optional(o.ringExpansion, "ringExpansion"), optVoxelSize(o.voxelSize), optMaxVoxels(o.maxVoxels), optional(o.maxHoleEdges, "maxHoleEdges"), flagOf(o.fair, true), optional(o.stitchTolerance, "stitchTolerance"));
|
|
791
|
+
break;
|
|
792
|
+
case "cleanupSlivers": values.push(optional(o.maxAspectRatio, "maxAspectRatio"), optional(o.minAngleDeg, "minAngleDeg"), optional(o.maxAngleDeg, "maxAngleDeg"), optional(o.maxIterations, "maxIterations"));
|
|
621
793
|
}
|
|
622
794
|
}
|
|
623
795
|
return {
|
|
@@ -718,12 +890,14 @@ function decodeReport(op, r) {
|
|
|
718
890
|
reason: FAIL_REASONS[r.next()]
|
|
719
891
|
}))
|
|
720
892
|
};
|
|
721
|
-
case "inflate":
|
|
722
|
-
moved: r.next(),
|
|
723
|
-
maxDisplacement: r.next()
|
|
724
|
-
};
|
|
893
|
+
case "inflate":
|
|
725
894
|
case "smooth":
|
|
726
|
-
case "relax":
|
|
895
|
+
case "relax":
|
|
896
|
+
case "grab":
|
|
897
|
+
case "flatten":
|
|
898
|
+
case "crease":
|
|
899
|
+
case "clay":
|
|
900
|
+
case "twist": return {
|
|
727
901
|
moved: r.next(),
|
|
728
902
|
maxDisplacement: r.next()
|
|
729
903
|
};
|
|
@@ -734,15 +908,16 @@ function decodeReport(op, r) {
|
|
|
734
908
|
rounds: r.next()
|
|
735
909
|
};
|
|
736
910
|
case "bridgeLoops": return { trianglesAdded: r.next() };
|
|
737
|
-
case "grab": return {
|
|
738
|
-
moved: r.next(),
|
|
739
|
-
maxDisplacement: r.next()
|
|
740
|
-
};
|
|
741
911
|
case "offset": return {
|
|
742
912
|
moved: r.next(),
|
|
743
913
|
maxDisplacement: r.next(),
|
|
744
914
|
degenerateRemoved: r.next(),
|
|
745
|
-
verticesRemoved: r.next()
|
|
915
|
+
verticesRemoved: r.next(),
|
|
916
|
+
verticesAdded: r.next(),
|
|
917
|
+
trianglesAdded: r.next(),
|
|
918
|
+
trianglesRemoved: r.next(),
|
|
919
|
+
voxelSize: r.next(),
|
|
920
|
+
uvsDropped: r.flag()
|
|
746
921
|
};
|
|
747
922
|
case "shell": return {
|
|
748
923
|
verticesAdded: r.next(),
|
|
@@ -771,15 +946,39 @@ function decodeReport(op, r) {
|
|
|
771
946
|
vertices
|
|
772
947
|
};
|
|
773
948
|
}
|
|
774
|
-
case "captureRestSizes":
|
|
949
|
+
case "captureRestSizes":
|
|
950
|
+
case "captureStrokeState": return {};
|
|
951
|
+
case "makeManifold": return {
|
|
952
|
+
removedDuplicateTriangles: r.next(),
|
|
953
|
+
prunedFinTriangles: r.next(),
|
|
954
|
+
splitNonManifoldEdges: r.next(),
|
|
955
|
+
splitPinchVertices: r.next(),
|
|
956
|
+
verticesAdded: r.next(),
|
|
957
|
+
removedVertices: r.next()
|
|
958
|
+
};
|
|
959
|
+
case "resolveSelfIntersections": return {
|
|
960
|
+
initialPairs: r.next(),
|
|
961
|
+
remainingPairs: r.next(),
|
|
962
|
+
removedTriangles: r.next(),
|
|
963
|
+
addedTriangles: r.next(),
|
|
964
|
+
modeUsed: SELF_INTERSECTION_MODES[r.next()],
|
|
965
|
+
uvsDropped: r.flag()
|
|
966
|
+
};
|
|
967
|
+
case "cleanupSlivers": return {
|
|
968
|
+
collapsedNeedles: r.next(),
|
|
969
|
+
flippedCaps: r.next(),
|
|
970
|
+
removedDegenerate: r.next(),
|
|
971
|
+
removedVertices: r.next()
|
|
972
|
+
};
|
|
775
973
|
}
|
|
776
974
|
}
|
|
777
975
|
/** An auto repair's result, stage by stage in the order they ran; see `crate::edit` in the Rust crate. */
|
|
778
976
|
function decodeAutoReport(r) {
|
|
779
|
-
const ops = Object.keys(REPAIR_CODES);
|
|
780
977
|
const stages = {};
|
|
781
978
|
while (r.at < r.data.length) {
|
|
782
|
-
const
|
|
979
|
+
const code = r.next();
|
|
980
|
+
const op = AUTO_STAGE_OPS[code];
|
|
981
|
+
if (op === void 0) throw invalid(`unknown auto repair stage code ${code}`);
|
|
783
982
|
stages[op] = decodeReport(op, r);
|
|
784
983
|
}
|
|
785
984
|
return stages;
|
|
@@ -876,6 +1075,67 @@ var Scene = class {
|
|
|
876
1075
|
/** History step nesting depth, mirrored from the calls made through this class. */
|
|
877
1076
|
#stepDepth = 0;
|
|
878
1077
|
#drag;
|
|
1078
|
+
/**
|
|
1079
|
+
* Callable repair domain (`scene.repair(mesh, op)` and `scene.repair.<method>(...)`).
|
|
1080
|
+
*/
|
|
1081
|
+
repair = createRepairDomain({
|
|
1082
|
+
repair: ((mesh, op) => this.#runRepair(mesh, op)),
|
|
1083
|
+
analyze: (mesh, options) => this.analyze(mesh, options),
|
|
1084
|
+
join: (target, source, options) => this.join(target, source, options)
|
|
1085
|
+
});
|
|
1086
|
+
/**
|
|
1087
|
+
* Callable sculpt domain (`scene.sculpt(mesh, op)` and `scene.sculpt.<method>(...)`).
|
|
1088
|
+
*/
|
|
1089
|
+
sculpt = createSculptDomain({
|
|
1090
|
+
sculpt: ((mesh, op) => this.#runRepair(mesh, op)),
|
|
1091
|
+
verticesInSphere: (mesh, center, radius) => this.verticesInSphere(mesh, center, radius),
|
|
1092
|
+
beginStep: () => this.beginStep(),
|
|
1093
|
+
endStep: () => this.endStep(),
|
|
1094
|
+
cancelStep: () => this.cancelStep()
|
|
1095
|
+
});
|
|
1096
|
+
/** Remesh, simplification, subdivision, and volumetric reconstruction domain. */
|
|
1097
|
+
remesh = createRemeshDomain({ repair: ((mesh, op) => this.#runRepair(mesh, op)) });
|
|
1098
|
+
/** Callable boolean, cutting, offsetting, and shell domain. */
|
|
1099
|
+
boolean = createBooleanDomain({
|
|
1100
|
+
isAsync: false,
|
|
1101
|
+
repair: ((mesh, op) => this.#runRepair(mesh, op)),
|
|
1102
|
+
boolean: (target, source, op) => this.#runBoolean(target, source, op),
|
|
1103
|
+
cutByPlane: (mesh, plane, options) => this.cutByPlane(mesh, plane, options)
|
|
1104
|
+
});
|
|
1105
|
+
/** Surface deformation and vertex-protection domain. */
|
|
1106
|
+
deform = createDeformDomain({ sculpt: ((mesh, op) => this.#runRepair(mesh, op)) });
|
|
1107
|
+
/** Defect analysis, metrology, queries, fields, and section inspection domain. */
|
|
1108
|
+
inspect = createInspectDomain({
|
|
1109
|
+
analyze: (mesh, options) => this.analyze(mesh, options),
|
|
1110
|
+
measure: (mesh) => this.measure(mesh),
|
|
1111
|
+
bounds: (mesh) => this.bounds(mesh),
|
|
1112
|
+
raycast: (origin, direction, options) => this.raycast(origin, direction, options),
|
|
1113
|
+
closestPoint: (point, options) => this.closestPoint(point, options),
|
|
1114
|
+
meshDistance: (a, b, options) => this.meshDistance(a, b, options),
|
|
1115
|
+
intersects: (a, b) => this.intersects(a, b),
|
|
1116
|
+
findContacts: (options) => this.findContacts(options),
|
|
1117
|
+
addDistanceField: (desc) => this.addDistanceField(desc),
|
|
1118
|
+
addThicknessField: (desc) => this.addThicknessField(desc),
|
|
1119
|
+
addCurvatureField: (desc) => this.addCurvatureField(desc),
|
|
1120
|
+
removeField: (field) => this.removeField(field),
|
|
1121
|
+
fieldValues: (field) => this.fieldValues(field),
|
|
1122
|
+
fieldNearest: (field) => this.fieldNearest(field),
|
|
1123
|
+
fieldStatus: (field) => this.fieldStatus(field),
|
|
1124
|
+
fieldTargetStatus: (field) => this.fieldTargetStatus(field),
|
|
1125
|
+
setColoring: (mesh, rule) => this.setColoring(mesh, rule),
|
|
1126
|
+
coloring: (mesh) => this.coloring(mesh),
|
|
1127
|
+
addSection: (desc) => this.addSection(desc),
|
|
1128
|
+
setSectionPlane: (section, plane) => this.setSectionPlane(section, plane),
|
|
1129
|
+
sectionPlane: (section) => this.sectionPlane(section),
|
|
1130
|
+
setSectionMeshes: (section, meshes) => this.setSectionMeshes(section, meshes),
|
|
1131
|
+
setSectionFill: (section, fill) => this.setSectionFill(section, fill),
|
|
1132
|
+
removeSection: (section) => this.removeSection(section),
|
|
1133
|
+
section: (section, mesh) => this.section(section, mesh),
|
|
1134
|
+
sectionGap: (section, a, b) => this.sectionGap(section, a, b),
|
|
1135
|
+
updateSections: () => this.updateSections()
|
|
1136
|
+
});
|
|
1137
|
+
/** Rigid registration and alignment domain. */
|
|
1138
|
+
align = createAlignDomain({ register: (moving, fixed, options) => this.register(moving, fixed, options) });
|
|
879
1139
|
constructor(options = {}) {
|
|
880
1140
|
ensureInitialized("new Scene()");
|
|
881
1141
|
this.#raw = call(() => new RawScene());
|
|
@@ -1017,6 +1277,7 @@ var Scene = class {
|
|
|
1017
1277
|
* one step; the removal is permanent. A drag of the source ends first,
|
|
1018
1278
|
* recording its moves as one step, so they survive a failed join.
|
|
1019
1279
|
*
|
|
1280
|
+
* @deprecated Use `scene.repair.join()` instead.
|
|
1020
1281
|
* @throws `UNKNOWN_MESH` for a removed handle; `INVALID_ARGUMENT` for one
|
|
1021
1282
|
* mesh twice or loops that cannot bridge; `STALE_LOOPS` for a loop that is
|
|
1022
1283
|
* not there. A failed join changes nothing.
|
|
@@ -1053,6 +1314,7 @@ var Scene = class {
|
|
|
1053
1314
|
* The cut undoes in one step; the added mesh stays, like the removed
|
|
1054
1315
|
* source of {@link Scene.join}.
|
|
1055
1316
|
*
|
|
1317
|
+
* @deprecated Use `scene.boolean.cut()` instead.
|
|
1056
1318
|
* @throws `UNKNOWN_MESH` for a removed handle; `INVALID_ARGUMENT` when
|
|
1057
1319
|
* the plane does not cut the mesh or a rim cannot be capped, as listed in
|
|
1058
1320
|
* `docs/uv-channel.md`, for example a rim that closes by position with its
|
|
@@ -1083,7 +1345,7 @@ var Scene = class {
|
|
|
1083
1345
|
* input that is not closed, manifold and consistently wound. A failed
|
|
1084
1346
|
* boolean changes nothing.
|
|
1085
1347
|
*/
|
|
1086
|
-
|
|
1348
|
+
#runBoolean(target, source, op) {
|
|
1087
1349
|
const ta = this.#id(target);
|
|
1088
1350
|
const sb = this.#id(source);
|
|
1089
1351
|
const code = codeIn({
|
|
@@ -1122,6 +1384,7 @@ var Scene = class {
|
|
|
1122
1384
|
* followed exactly on a copy baked through it, so each such call costs a BVH
|
|
1123
1385
|
* build. All distances are in world units.
|
|
1124
1386
|
*
|
|
1387
|
+
* @deprecated Use `scene.align.register()` instead.
|
|
1125
1388
|
* @throws `UNKNOWN_MESH` for a removed handle; `INVALID_ARGUMENT` for one
|
|
1126
1389
|
* mesh twice, a mesh without triangles or an invalid option; `STALE_BVH` for
|
|
1127
1390
|
* a stale Manual `fixed`. Bad options and one mesh twice change nothing,
|
|
@@ -1605,6 +1868,7 @@ var Scene = class {
|
|
|
1605
1868
|
* triangles, non-manifold edges and vertices, components, orientation
|
|
1606
1869
|
* conflicts and, on request, self-intersection.
|
|
1607
1870
|
*
|
|
1871
|
+
* @deprecated Use `scene.inspect.analyze()` or `scene.repair.analyze()` instead.
|
|
1608
1872
|
* @throws `INVALID_ARGUMENT` for a negative or non-finite `weldTolerance`; `STALE_BVH`, see {@link AnalyzeOptions.selfIntersection}.
|
|
1609
1873
|
*/
|
|
1610
1874
|
analyze(mesh, options = {}) {
|
|
@@ -1621,6 +1885,8 @@ var Scene = class {
|
|
|
1621
1885
|
* non-manifold mesh still gets its area; only `volume` is `null`, with
|
|
1622
1886
|
* `volumeReason` saying why. A read-only call: it leaves every view
|
|
1623
1887
|
* valid.
|
|
1888
|
+
*
|
|
1889
|
+
* @deprecated Use `scene.inspect.measure()` instead.
|
|
1624
1890
|
*/
|
|
1625
1891
|
measure(mesh) {
|
|
1626
1892
|
const { index, generation } = this.#id(mesh);
|
|
@@ -1636,11 +1902,24 @@ var Scene = class {
|
|
|
1636
1902
|
orientationConflicts: r[6]
|
|
1637
1903
|
};
|
|
1638
1904
|
}
|
|
1639
|
-
|
|
1905
|
+
/**
|
|
1906
|
+
* Runs one repair operation and returns its report, or a list of them in
|
|
1907
|
+
* order and returns their reports. A list is one transaction: one undo step,
|
|
1908
|
+
* and when any operation fails nothing changes and nothing is recorded.
|
|
1909
|
+
* `{ kind: "auto" }` runs the standard cleanup pipeline the same way and
|
|
1910
|
+
* returns a report per stage; see {@link AutoRepairRequest}.
|
|
1911
|
+
*/
|
|
1912
|
+
#runRepair(mesh, op) {
|
|
1640
1913
|
const { index, generation } = this.#id(mesh);
|
|
1641
1914
|
if (isAutoRepair(op)) {
|
|
1642
|
-
const values = Float64Array.of(AUTO_REPAIR_CODE, optional(op.weldTolerance, "weldTolerance"), optional(op.minTriangles, "minTriangles"), optional(op.maxEdges, "maxEdges"), op.fair === void 0 ? NaN : flagOf(op.fair, true));
|
|
1643
1915
|
const noLoops = /* @__PURE__ */ new Uint32Array();
|
|
1916
|
+
if (op.preset === void 0 && op.selfIntersectionMode === void 0 && op.voxelSize === void 0 && op.maxVoxels === void 0) {
|
|
1917
|
+
const values = Float64Array.of(AUTO_REPAIR_CODE, optional(op.weldTolerance, "weldTolerance"), optional(op.minTriangles, "minTriangles"), optional(op.maxEdges, "maxEdges"), op.fair === void 0 ? NaN : flagOf(op.fair, true));
|
|
1918
|
+
return decodeAutoReport(new Reader(call(() => this.#scene().repair(index, generation, values, noLoops))));
|
|
1919
|
+
}
|
|
1920
|
+
const preset = op.preset === void 0 ? NaN : codeIn(PRESET_CODES, op.preset, "preset");
|
|
1921
|
+
const siMode = op.selfIntersectionMode === void 0 ? NaN : codeIn(SELF_INTERSECTION_MODE_CODES, op.selfIntersectionMode, "selfIntersectionMode");
|
|
1922
|
+
const values = Float64Array.of(AUTO_REPAIR_PRESET_CODE, preset, siMode, optional(op.weldTolerance, "weldTolerance"), optional(op.minTriangles, "minTriangles"), optional(op.maxEdges, "maxEdges"), op.fair === void 0 ? NaN : flagOf(op.fair, true), optVoxelSize(op.voxelSize), optMaxVoxels(op.maxVoxels));
|
|
1644
1923
|
return decodeAutoReport(new Reader(call(() => this.#scene().repair(index, generation, values, noLoops))));
|
|
1645
1924
|
}
|
|
1646
1925
|
const ops = Array.isArray(op) ? op : [op];
|
|
@@ -1650,10 +1929,32 @@ var Scene = class {
|
|
|
1650
1929
|
return Array.isArray(op) ? reports : reports[0];
|
|
1651
1930
|
}
|
|
1652
1931
|
/**
|
|
1932
|
+
* Live triangle-used vertex ids of `mesh` inside the closed local-space
|
|
1933
|
+
* sphere `(center, radius)`, in ascending order. Brings a `"lazy"` BVH up
|
|
1934
|
+
* to date first; throws `STALE_BVH` on a stale `"manual"` mesh.
|
|
1935
|
+
*
|
|
1936
|
+
* @deprecated Use `scene.sculpt.verticesInSphere()` instead.
|
|
1937
|
+
* @throws `UNKNOWN_MESH` for a removed handle; `INVALID_ARGUMENT` when
|
|
1938
|
+
* `center` is not 3 finite numbers or `radius` is negative or non-finite;
|
|
1939
|
+
* `STALE_BVH` for a stale `"manual"` mesh.
|
|
1940
|
+
*/
|
|
1941
|
+
verticesInSphere(mesh, center, radius) {
|
|
1942
|
+
const { index, generation } = this.#id(mesh);
|
|
1943
|
+
const c = center;
|
|
1944
|
+
if (c?.length !== 3 || ![
|
|
1945
|
+
c[0],
|
|
1946
|
+
c[1],
|
|
1947
|
+
c[2]
|
|
1948
|
+
].every((x) => typeof x === "number" && Number.isFinite(x))) throw invalid("center must be 3 finite numbers");
|
|
1949
|
+
if (typeof radius !== "number" || !Number.isFinite(radius) || radius < 0) throw invalid("radius must be a finite non-negative number");
|
|
1950
|
+
return call(() => this.#scene().vertices_in_sphere(index, generation, c[0], c[1], c[2], radius));
|
|
1951
|
+
}
|
|
1952
|
+
/**
|
|
1653
1953
|
* The nearest hit of a world ray over every mesh, or `null`. `direction`
|
|
1654
1954
|
* need not be unit length; `distance` is in world units. Lazy meshes are
|
|
1655
1955
|
* brought up to date first.
|
|
1656
1956
|
*
|
|
1957
|
+
* @deprecated Use `scene.inspect.raycast()` instead.
|
|
1657
1958
|
* @throws `INVALID_ARGUMENT` for a non-finite origin or a zero direction; `STALE_BVH` for a stale `"manual"` mesh.
|
|
1658
1959
|
*/
|
|
1659
1960
|
raycast(origin, direction, options = {}) {
|
|
@@ -1676,6 +1977,8 @@ var Scene = class {
|
|
|
1676
1977
|
/**
|
|
1677
1978
|
* The surface point nearest to a world point, over every mesh or one, or
|
|
1678
1979
|
* `null` when none is within `maxDistance`.
|
|
1980
|
+
*
|
|
1981
|
+
* @deprecated Use `scene.inspect.closestPoint()` instead.
|
|
1679
1982
|
*/
|
|
1680
1983
|
closestPoint(point, options = {}) {
|
|
1681
1984
|
const s = this.#scene();
|
|
@@ -1699,6 +2002,8 @@ var Scene = class {
|
|
|
1699
2002
|
* The distance between two meshes' surfaces as placed, with a closest pair
|
|
1700
2003
|
* of points, or `null` when it exceeds `maxDistance` (default `Infinity`)
|
|
1701
2004
|
* or a mesh has no triangle.
|
|
2005
|
+
*
|
|
2006
|
+
* @deprecated Use `scene.inspect.meshDistance()` instead.
|
|
1702
2007
|
*/
|
|
1703
2008
|
meshDistance(a, b, options = {}) {
|
|
1704
2009
|
const ia = this.#id(a);
|
|
@@ -1714,13 +2019,21 @@ var Scene = class {
|
|
|
1714
2019
|
triangleB: d[8]
|
|
1715
2020
|
};
|
|
1716
2021
|
}
|
|
1717
|
-
/**
|
|
2022
|
+
/**
|
|
2023
|
+
* Whether two meshes intersect or touch as placed.
|
|
2024
|
+
*
|
|
2025
|
+
* @deprecated Use `scene.inspect.intersects()` instead.
|
|
2026
|
+
*/
|
|
1718
2027
|
intersects(a, b) {
|
|
1719
2028
|
const ia = this.#id(a);
|
|
1720
2029
|
const ib = this.#id(b);
|
|
1721
2030
|
return call(() => this.#scene().intersects(ia.index, ia.generation, ib.index, ib.generation));
|
|
1722
2031
|
}
|
|
1723
|
-
/**
|
|
2032
|
+
/**
|
|
2033
|
+
* Every mesh pair (or every pair of `pairs`) within `margin`, sorted by mesh id.
|
|
2034
|
+
*
|
|
2035
|
+
* @deprecated Use `scene.inspect.findContacts()` instead.
|
|
2036
|
+
*/
|
|
1724
2037
|
findContacts(options = {}) {
|
|
1725
2038
|
const s = this.#scene();
|
|
1726
2039
|
const pairs = options.pairs === void 0 ? void 0 : this.#flatIds(options.pairs.flat());
|
|
@@ -1899,6 +2212,7 @@ var Scene = class {
|
|
|
1899
2212
|
* edits and placements by the mesh modes, like normals. Removing a mesh of
|
|
1900
2213
|
* `to` removes it from the field, or the field with its last target.
|
|
1901
2214
|
*
|
|
2215
|
+
* @deprecated Use `scene.inspect.addDistanceField()` instead.
|
|
1902
2216
|
* @throws `INVALID_ARGUMENT` when `to` is empty, holds `on` or a mesh twice, `maxDistance` is negative or NaN, or the name is taken.
|
|
1903
2217
|
*/
|
|
1904
2218
|
addDistanceField(desc) {
|
|
@@ -1911,6 +2225,7 @@ var Scene = class {
|
|
|
1911
2225
|
* `maxDistance` read `Infinity`. It follows edits and placements by the
|
|
1912
2226
|
* mesh modes, like normals, and colours like any field.
|
|
1913
2227
|
*
|
|
2228
|
+
* @deprecated Use `scene.inspect.addThicknessField()` instead.
|
|
1914
2229
|
* @throws `INVALID_ARGUMENT` when `maxDistance` is negative or NaN, or the name is taken.
|
|
1915
2230
|
*/
|
|
1916
2231
|
addThicknessField(desc) {
|
|
@@ -1926,6 +2241,7 @@ var Scene = class {
|
|
|
1926
2241
|
* negative in bowls, zero on flats). It follows edits and placements by
|
|
1927
2242
|
* the mesh modes, like normals, and colours like any field.
|
|
1928
2243
|
*
|
|
2244
|
+
* @deprecated Use `scene.inspect.addCurvatureField()` instead.
|
|
1929
2245
|
* @throws `INVALID_ARGUMENT` when the name is taken.
|
|
1930
2246
|
*/
|
|
1931
2247
|
addCurvatureField(desc) {
|