fast-mesh-wasm 0.4.0 → 0.5.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.
Files changed (47) hide show
  1. package/README.md +51 -3
  2. package/dist/{api-BUy7FRx7.js → api-4kz45-Mq.js} +2 -3
  3. package/dist/{client-Bpjy-eFY.js → client-C61Kku4i.js} +102 -24
  4. package/dist/{client-D-O5-tAg.d.ts → client-tP6R9foI.d.ts} +19 -8
  5. package/dist/{colormap-DxGMYVfs.js → colormap-Dr5V3bvs.js} +1 -2
  6. package/dist/{core-Cke_kZ2e.js → core-4OcWKu3r.js} +2 -2
  7. package/dist/{core-D2X9GPfK.d.ts → core-CJ9D6U5A.d.ts} +1 -3
  8. package/dist/{engine-D6MpGb9i.js → engine-X1Awlc5y.js} +58 -28
  9. package/dist/io.d.ts +294 -0
  10. package/dist/io.js +1395 -0
  11. package/dist/{mesh-zj7-wJBw.js → mesh-CWvrjO8S.js} +3 -4
  12. package/dist/{mesh-BUVxv3jo.d.ts → mesh-D3fv56nF.d.ts} +1 -3
  13. package/dist/node.d.ts +3 -5
  14. package/dist/node.js +4 -5
  15. package/dist/{protocol-CK6_3aqo.d.ts → protocol-BGQAB0op.d.ts} +16 -3
  16. package/dist/{protocol-CAUYm1gd.js → protocol-Ci9LLiwO.js} +7 -6
  17. package/dist/r3f.d.ts +22 -6
  18. package/dist/r3f.js +28 -19
  19. package/dist/{react-CTADh3NN.js → react-DzrtrzZy.js} +4 -6
  20. package/dist/react.d.ts +4 -6
  21. package/dist/react.js +1 -1
  22. package/dist/{scene-D6m9XM3O.js → scene-BnkCS0sv.js} +668 -14
  23. package/dist/{scene-like-DJKQP5uf.d.ts → scene-like-BzkDNHCy.d.ts} +502 -42
  24. package/dist/{snapshot-Cf6NgDl7.js → snapshot-BkbGPspK.js} +1 -2
  25. package/dist/{store-QWRDXlAn.d.ts → store-BKFzSykN.d.ts} +3 -9
  26. package/dist/{store-Ml3TQGsR.js → store-CEd2y2KS.js} +7 -9
  27. package/dist/store.d.ts +2 -4
  28. package/dist/store.js +4 -5
  29. package/dist/three.d.ts +2 -6
  30. package/dist/three.js +4 -6
  31. package/dist/{views-Dh3aWc2q.js → views-CUBMOK0U.js} +5 -8
  32. package/dist/wasm/fast_mesh_wasm.d.ts +86 -6
  33. package/dist/wasm/fast_mesh_wasm.js +192 -6
  34. package/dist/wasm/fast_mesh_wasm_bg.wasm +0 -0
  35. package/dist/wasm/fast_mesh_wasm_bg.wasm.d.ts +9 -1
  36. package/dist/wasm-threads/fast_mesh_wasm.d.ts +86 -6
  37. package/dist/wasm-threads/fast_mesh_wasm.js +192 -6
  38. package/dist/wasm-threads/fast_mesh_wasm_bg.wasm +0 -0
  39. package/dist/wasm-threads/fast_mesh_wasm_bg.wasm.d.ts +9 -1
  40. package/dist/web.d.ts +3 -5
  41. package/dist/web.js +4 -5
  42. package/dist/worker-engine.d.ts +1 -7
  43. package/dist/worker-engine.js +1 -1
  44. package/dist/worker-entry.js +2 -3
  45. package/dist/worker.d.ts +2 -2
  46. package/dist/worker.js +1 -1
  47. package/package.json +16 -4
@@ -1,5 +1,4 @@
1
1
  import { InitInput, WasmScene } from "./wasm/fast_mesh_wasm.js";
2
- //#region src/api.d.ts
3
2
  /** A 3D vector `[x, y, z]`. */
4
3
  type Vec3 = [x: number, y: number, z: number];
5
4
  /**
@@ -28,17 +27,27 @@ type Mat3 = readonly number[];
28
27
  * `update(mesh)` (`"manual"`).
29
28
  */
30
29
  type UpdateMode = "eager" | "lazy" | "manual";
31
- /** A placement to set: a rotation (row-major matrix or quaternion) and a translation. */
30
+ /** A placement to set: a rotation (row-major matrix or quaternion), a per-axis scale and a translation. */
32
31
  interface PlacementInput {
33
32
  /** A proper rotation: 9 numbers row-major, or a quaternion `[x, y, z, w]`. */
34
33
  rotation: Mat3 | Quat;
35
34
  translation: Readonly<Vec3>;
35
+ /**
36
+ * Per-axis scale: 3 finite positive numbers. Defaults to `[1, 1, 1]`
37
+ * (rigid). Both uniform and non-uniform scales are supported.
38
+ */
39
+ scale?: Readonly<Vec3>;
36
40
  }
37
- /** A mesh placement: world = rotation · local + translation. */
41
+ /** A mesh placement: world = rotation · (scale · local) + translation. */
38
42
  interface Placement {
39
43
  /** 9 numbers, row-major. */
40
44
  rotation: number[];
41
45
  translation: Vec3;
46
+ /**
47
+ * 3 numbers; `[1, 1, 1]` for a rigid placement. Always present from
48
+ * {@link Scene} and `WorkerScene`; absent on hosts that do not track scale.
49
+ */
50
+ scale?: Vec3;
42
51
  }
43
52
  /** Axis-aligned bounding box. */
44
53
  interface Bounds {
@@ -67,8 +76,29 @@ declare function computeVertexNormals(positions: Positions, indices: Indices): F
67
76
  * @throws If `positions` is empty or its length is not a multiple of 3.
68
77
  */
69
78
  declare function computeBounds(positions: Positions): Bounds;
70
- //#endregion
71
- //#region src/views.d.ts
79
+ /**
80
+ * A mesh in a {@link Scene}. Opaque: pass it to the scene's methods. The same
81
+ * mesh always gives the same handle object, so handles compare with `===`.
82
+ */
83
+ declare class MeshHandle {
84
+ private readonly brand;
85
+ }
86
+ /**
87
+ * A field in a {@link Scene}. Opaque and deduplicated like {@link MeshHandle}.
88
+ * The scene keeps every field handle it gave out for its own lifetime, even
89
+ * after the field is removed, so a removal in a change record names the same
90
+ * object you hold.
91
+ */
92
+ declare class FieldHandle {
93
+ private readonly brand;
94
+ }
95
+ /**
96
+ * A section in a {@link Scene}. Opaque and deduplicated like {@link MeshHandle},
97
+ * and kept for the scene's lifetime like {@link FieldHandle}.
98
+ */
99
+ declare class SectionHandle {
100
+ private readonly brand;
101
+ }
72
102
  /**
73
103
  * Zero-copy views of one mesh's render buffers, slot-aligned.
74
104
  *
@@ -101,37 +131,58 @@ interface MeshViews {
101
131
  /** 3 vertex indices per triangle slot; a removed triangle reads `0, 0, 0`. */
102
132
  indices(): Uint32Array;
103
133
  }
104
- //#endregion
105
- //#region src/changes.d.ts
106
134
  /** `[start, count]` in elements: vertex slots, or triangle slots for indices. */
107
135
  type Range = readonly [start: number, count: number];
108
- //#endregion
109
- //#region src/handles.d.ts
110
- /**
111
- * A mesh in a {@link Scene}. Opaque: pass it to the scene's methods. The same
112
- * mesh always gives the same handle object, so handles compare with `===`.
113
- */
114
- declare class MeshHandle {
115
- private readonly brand;
136
+ /** A snapshot of selected vertices of one mesh; see the module docs. */
137
+ interface VertexSelection {
138
+ /** The mesh selected from. */
139
+ mesh: MeshHandle;
140
+ /** The selected vertex slots, ascending. */
141
+ vertices: Uint32Array;
142
+ /** The mesh's content stamp when taken; see `Scene.selectionAlive`. */
143
+ stamp: number;
116
144
  }
117
- /**
118
- * A field in a {@link Scene}. Opaque and deduplicated like {@link MeshHandle}.
119
- * The scene keeps every field handle it gave out for its own lifetime, even
120
- * after the field is removed, so a removal in a change record names the same
121
- * object you hold.
122
- */
123
- declare class FieldHandle {
124
- private readonly brand;
145
+ /** A sphere brush: every used vertex within `radius` of `center`. */
146
+ interface BrushSelect {
147
+ kind: "brush";
148
+ /** Brush centre; `space` says which coordinates it is in. */
149
+ center: Readonly<Vec3>;
150
+ /** Radius in the same units; 0 selects vertices exactly at `center`. */
151
+ radius: number;
152
+ /**
153
+ * `"local"` (mesh render coordinates, as in `views(mesh).positions()`) or
154
+ * `"world"` (converted with the mesh's placement at call time). Defaults
155
+ * to `"local"`.
156
+ */
157
+ space?: "local" | "world";
125
158
  }
126
159
  /**
127
- * A section in a {@link Scene}. Opaque and deduplicated like {@link MeshHandle},
128
- * and kept for the scene's lifetime like {@link FieldHandle}.
160
+ * A 2D polygon: every used vertex whose projection falls inside it.
161
+ * Project your screen-space polygon to mesh-local coordinates with your
162
+ * camera first; `axis` picks the projection plane.
129
163
  */
130
- declare class SectionHandle {
131
- private readonly brand;
164
+ interface LassoSelect {
165
+ kind: "lasso";
166
+ /** Flat `[x0, y0, x1, y1, ...]` polygon corners in local coordinates. */
167
+ polygon: Float32Array | readonly number[];
168
+ /** The local plane projected onto. Defaults to `"xy"`. */
169
+ axis?: "xy" | "xz" | "yz";
170
+ }
171
+ /** The connected component (over shared triangle edges) holding `seed`. */
172
+ interface ComponentSelect {
173
+ kind: "component";
174
+ /** A vertex slot of the component to pick; it must be alive. */
175
+ seed: number;
176
+ }
177
+ /** What `Scene.select` takes. */
178
+ type SelectSpec = BrushSelect | LassoSelect | ComponentSelect;
179
+ /** What `Scene.isolate` did. */
180
+ interface IsolateReport {
181
+ /** Triangles fully outside the selection that were removed. */
182
+ removedTriangles: number;
183
+ /** The same vertex set with the post-edit stamp. */
184
+ selection: VertexSelection;
132
185
  }
133
- //#endregion
134
- //#region src/scene.d.ts
135
186
  /**
136
187
  * What changed in one mesh since the previous {@link Scene.takeChanges}.
137
188
  * Range lists are ascending; `"all"` means re-upload the whole buffer.
@@ -329,6 +380,41 @@ interface DistanceFieldDesc {
329
380
  /** Defaults to `"auto"`. */
330
381
  sign?: SignMode;
331
382
  }
383
+ /**
384
+ * A per-vertex wall-thickness field to add with
385
+ * {@link Scene.addThicknessField}: the distance to the opposite surface
386
+ * along each vertex's smooth normal, in world units (the placement's scale
387
+ * applied, so scaled meshes read scaled).
388
+ *
389
+ * Vertices whose rays escape in both directions (open sheets, the rims of
390
+ * open meshes), dead slots and unused vertices hold NaN; hits beyond
391
+ * `maxDistance` hold `Infinity`. Colour it like any field: NaN takes the
392
+ * rule's `nan` colour, `Infinity` follows `above`.
393
+ */
394
+ interface ThicknessFieldDesc {
395
+ /** Unique among the fields on `on`. */
396
+ name: string;
397
+ /** The mesh whose vertices carry the values. */
398
+ on: MeshHandle;
399
+ /** Largest thickness kept (inclusive); thicker vertices hold `Infinity`. May be `Infinity`. */
400
+ maxDistance: number;
401
+ }
402
+ /**
403
+ * A per-vertex curvature field to add with
404
+ * {@link Scene.addCurvatureField}: the signed mean curvature at each vertex,
405
+ * in 1/world-units (positive on domes, about `1 / r` on a sphere of radius
406
+ * `r` with outward normals; negative in bowls and dents; zero on flat
407
+ * spots; a saddle takes the sign of its dominant bend).
408
+ *
409
+ * Dead slots and vertices no triangle uses hold NaN; colour it like any
410
+ * field: NaN takes the rule's `nan` colour.
411
+ */
412
+ interface CurvatureFieldDesc {
413
+ /** Unique among the fields on `on`. */
414
+ name: string;
415
+ /** The mesh whose vertices carry the values. */
416
+ on: MeshHandle;
417
+ }
332
418
  /** The state of a field, from {@link Scene.fieldStatus}. */
333
419
  interface FieldStatus {
334
420
  /** True when the values match the meshes and placements as they are now. */
@@ -524,8 +610,36 @@ interface Analysis {
524
610
  selfIntersects: boolean | null;
525
611
  }
526
612
  /**
527
- * Options of {@link Scene.analyze}. Distances are in mesh units: placements are
528
- * rigid, so local and world distances agree.
613
+ * Scalar measurements of a mesh, from {@link Scene.measure}. The report is
614
+ * in world coordinates (the placement applied), so scaled meshes measure
615
+ * scaled. Thickness (#116) and curvature (#117) build on this.
616
+ */
617
+ interface MeasureResult {
618
+ /** The total triangle area; always defined. */
619
+ area: number;
620
+ /**
621
+ * The enclosed volume, or `null` when the mesh is not watertight (open
622
+ * or non-manifold), with `volumeReason` saying why. The volume is the
623
+ * absolute signed sum, so inconsistent winding does not fail the call:
624
+ * it only shows up in `orientationConflicts`, while partly cancelling
625
+ * the number. Require `orientationConflicts === 0` for a strict reading.
626
+ */
627
+ volume: number | null;
628
+ /** No boundary loop or open chain and no non-manifold edge. */
629
+ closed: boolean;
630
+ /** Why `volume` is `null`; `null` exactly when `closed`. */
631
+ volumeReason: "open" | "non-manifold" | null;
632
+ /** The boundary loops and open chains, as `analyze` reports them. */
633
+ boundaryLoops: number;
634
+ /** How many edges have three or more triangles. */
635
+ nonManifoldEdges: number;
636
+ /** Interior edges used in the same direction by both their triangles. */
637
+ orientationConflicts: number;
638
+ }
639
+ /**
640
+ * Options of {@link Scene.analyze}. Distances are in mesh units; with a
641
+ * rigid placement local and world distances agree, with a scaled one local
642
+ * distances are in unscaled units.
529
643
  */
530
644
  interface AnalyzeOptions {
531
645
  /**
@@ -573,6 +687,99 @@ type RepairOp = {
573
687
  maxDihedral?: number;
574
688
  /** Stop refining a patch once it has this many new vertices. */
575
689
  maxRefineVertices?: number;
690
+ } | {
691
+ op: "inflate";
692
+ /** Brush center in local mesh coordinates, as in `views(mesh).positions()`. */
693
+ center: Readonly<Vec3>;
694
+ radius: number;
695
+ falloff: "linear" | "smooth";
696
+ /** Displacement scale; negative pulls instead of pushing. */
697
+ strength: number;
698
+ } | {
699
+ op: "smooth";
700
+ /** Brush center in local mesh coordinates, as in `views(mesh).positions()`. */
701
+ center: Readonly<Vec3>;
702
+ radius: number;
703
+ falloff: "linear" | "smooth";
704
+ /** Displacement scale; the per-vertex weight is `strength * falloff`. */
705
+ strength: number;
706
+ /** How many Taubin λ/μ cycles to run; 0 moves nothing. */
707
+ cycles: number;
708
+ } | {
709
+ op: "remesh";
710
+ /** Region center in local mesh coordinates, as in `views(mesh).positions()`. */
711
+ center: Readonly<Vec3>;
712
+ radius: number;
713
+ /** Target edge length; unset means the mesh-wide mean edge length. */
714
+ targetLength?: number;
715
+ /** Maximum split/collapse/flip rounds; unset means the default (10). */
716
+ maxRounds?: number;
717
+ /** Split long edges only (no collapses, no flips); unset means a full pass. */
718
+ splitOnly?: boolean;
719
+ } | {
720
+ op: "bridgeLoops";
721
+ /** The two loops to connect, from `analyze(mesh).loops`. Order is insignificant. */
722
+ loops: readonly [LoopId, LoopId];
723
+ /** Maximum vertices per loop; unset means the default (128). */
724
+ maxEdges?: number;
725
+ } | {
726
+ op: "grab";
727
+ /** Brush center in local mesh coordinates, as in `views(mesh).positions()`. */
728
+ center: Readonly<Vec3>;
729
+ radius: number;
730
+ falloff: "linear" | "smooth";
731
+ /** Displacement scale; the per-vertex offset is `strength * falloff * direction`. */
732
+ strength: number;
733
+ /** The drag vector in local coordinates; zero moves nothing. */
734
+ direction: Readonly<Vec3>;
735
+ } | {
736
+ op: "relax";
737
+ /** Brush center in local mesh coordinates, as in `views(mesh).positions()`. */
738
+ center: Readonly<Vec3>;
739
+ radius: number;
740
+ falloff: "linear" | "smooth";
741
+ /** Displacement scale; the per-vertex weight is `strength * falloff`. */
742
+ strength: number;
743
+ /** How many plain Laplacian passes to run; 0 moves nothing. */
744
+ cycles: number;
745
+ } | {
746
+ op: "offset";
747
+ /**
748
+ * How far to move the surface along its smooth normals, in mesh units
749
+ * (equal to world units). Positive follows the normals (outward on an
750
+ * outward-wound closed mesh); negative sinks inward. Must be finite;
751
+ * 0 moves nothing.
752
+ */
753
+ distance: number;
754
+ } | {
755
+ op: "shell";
756
+ /**
757
+ * Wall thickness in mesh units (equal to world units): the input
758
+ * surface stays and gains a reversed copy one thickness against its
759
+ * smooth normals, with every boundary rim stitched shut. Must be
760
+ * positive and finite.
761
+ */
762
+ thickness: number;
763
+ } | {
764
+ op: "simplify";
765
+ /**
766
+ * Stop once this many triangles are alive; must be at least 1. A target
767
+ * at or above the live count leaves the mesh alone.
768
+ */
769
+ targetTriangles: number;
770
+ /** Keep boundary vertices in place; defaults to `true`. */
771
+ preserveBoundary?: boolean;
772
+ } | {
773
+ op: "subdivide";
774
+ /**
775
+ * Subdivision scheme; only `"loop"` exists. Defaults to `"loop"`.
776
+ */
777
+ method?: "loop";
778
+ /**
779
+ * How many times to split every triangle; must be an integer of at
780
+ * least 1. Each level quadruples the triangle count. Defaults to `1`.
781
+ */
782
+ levels?: number;
576
783
  };
577
784
  /** What `weld` did. */
578
785
  interface WeldReport {
@@ -625,8 +832,118 @@ interface FillReport {
625
832
  reason: "projectionFolds" | "noValidTriangulation" | "solver";
626
833
  }[];
627
834
  }
835
+ /** What `inflate` did. */
836
+ interface InflateReport {
837
+ moved: number;
838
+ maxDisplacement: number;
839
+ }
840
+ /** What `smooth` did. */
841
+ interface SmoothReport {
842
+ moved: number;
843
+ maxDisplacement: number;
844
+ }
845
+ /** What `remesh` did. */
846
+ interface RemeshReport {
847
+ splits: number;
848
+ collapses: number;
849
+ flips: number;
850
+ rounds: number;
851
+ }
852
+ /** What `bridgeLoops` did. */
853
+ interface BridgeReport {
854
+ trianglesAdded: number;
855
+ }
856
+ /** What `grab` did. */
857
+ interface GrabReport {
858
+ moved: number;
859
+ maxDisplacement: number;
860
+ }
861
+ /** What `relax` did. */
862
+ interface RelaxReport {
863
+ moved: number;
864
+ maxDisplacement: number;
865
+ }
866
+ /** What `offset` did. */
867
+ interface OffsetReport {
868
+ moved: number;
869
+ maxDisplacement: number;
870
+ /** Degenerate triangles the cleanup pass removed. */
871
+ degenerateRemoved: number;
872
+ /** Vertices the cleanup pass removed. */
873
+ verticesRemoved: number;
874
+ }
875
+ /** What `shell` did. */
876
+ interface ShellReport {
877
+ /** Copy vertices added. */
878
+ verticesAdded: number;
879
+ /** Copy and wall triangles added. */
880
+ trianglesAdded: number;
881
+ /** Boundary rims stitched to their copy. A closed mesh has none. */
882
+ loopsClosed: number;
883
+ /** Degenerate triangles the cleanup pass removed. */
884
+ degenerateRemoved: number;
885
+ /** Vertices the cleanup pass removed. */
886
+ verticesRemoved: number;
887
+ }
888
+ /** What `simplify` did. */
889
+ interface SimplifyReport {
890
+ /** Edge collapses performed. */
891
+ collapsed: number;
892
+ /** Triangles removed (one per boundary collapse, two per interior one). */
893
+ trianglesRemoved: number;
894
+ /** Vertices removed (one per collapse). */
895
+ verticesRemoved: number;
896
+ }
897
+ /** What `subdivide` did. */
898
+ interface SubdivideReport {
899
+ /** Vertices added, one per subdivided edge per level. */
900
+ verticesAdded: number;
901
+ /** Triangles added: three per subdivided triangle per level. */
902
+ trianglesAdded: number;
903
+ }
904
+ /** Options of {@link Scene.join}. */
905
+ interface JoinOptions {
906
+ /** The loop on the target, from `analyze(target).loops`. */
907
+ loopA: LoopId;
908
+ /** The loop on the source, from `analyze(source).loops`. */
909
+ loopB: LoopId;
910
+ /** Maximum vertices per loop; unset means the default (128). */
911
+ maxEdges?: number;
912
+ }
913
+ /** What {@link Scene.join} did. */
914
+ interface JoinReport {
915
+ /** Source vertices copied into the target. */
916
+ verticesAdded: number;
917
+ /** Source triangles copied into the target. */
918
+ trianglesAdded: number;
919
+ /** Bridge triangles between the two loops. */
920
+ bridgeTrianglesAdded: number;
921
+ }
922
+ /** Options of {@link Scene.cutByPlane}. */
923
+ interface CutOptions {
924
+ /**
925
+ * Close both openings with flat, unfaired patches. Defaults to `true`;
926
+ * without it both parts keep the open rim the cut leaves.
927
+ */
928
+ cap?: boolean;
929
+ }
930
+ /** What {@link Scene.cutByPlane} did. */
931
+ interface CutReport {
932
+ /** The original handle, now holding the `+` side. */
933
+ kept: MeshHandle;
934
+ /** The new handle holding the `-` side. */
935
+ removed: MeshHandle;
936
+ /** Alive triangles of {@link CutReport.kept}, cap included. */
937
+ keptTriangles: number;
938
+ /** Alive triangles of {@link CutReport.removed}, cap included. */
939
+ removedTriangles: number;
940
+ /** Cap triangles added on both sides together. */
941
+ capTriangles: number;
942
+ }
943
+ /** Which boolean for {@link Scene.boolean} to compute. */
944
+ type BooleanOp = "union" | "subtract" | "intersect";
628
945
  /** The report of a {@link RepairOp}. */
629
- type RepairReport = WeldReport | DegenerateReport | RemoveReport | OrientReport | FillReport;
946
+ type RepairReport = WeldReport | DegenerateReport | RemoveReport | OrientReport | FillReport | InflateReport | SmoothReport | RemeshReport | BridgeReport | GrabReport | RelaxReport | OffsetReport | ShellReport | SimplifyReport | SubdivideReport;
630
947
  /** The report type of a repair op. */
631
948
  type RepairReportOf<O extends RepairOp> = O extends {
632
949
  op: "weld";
@@ -638,7 +955,27 @@ type RepairReportOf<O extends RepairOp> = O extends {
638
955
  op: "orient";
639
956
  } ? OrientReport : O extends {
640
957
  op: "fillHoles";
641
- } ? FillReport : RepairReport;
958
+ } ? FillReport : O extends {
959
+ op: "inflate";
960
+ } ? InflateReport : O extends {
961
+ op: "smooth";
962
+ } ? SmoothReport : O extends {
963
+ op: "remesh";
964
+ } ? RemeshReport : O extends {
965
+ op: "bridgeLoops";
966
+ } ? BridgeReport : O extends {
967
+ op: "grab";
968
+ } ? GrabReport : O extends {
969
+ op: "relax";
970
+ } ? RelaxReport : O extends {
971
+ op: "offset";
972
+ } ? OffsetReport : O extends {
973
+ op: "shell";
974
+ } ? ShellReport : O extends {
975
+ op: "simplify";
976
+ } ? SimplifyReport : O extends {
977
+ op: "subdivide";
978
+ } ? SubdivideReport : RepairReport;
642
979
  /**
643
980
  * A scene of editable meshes. Create it after `await init()`; release it with
644
981
  * {@link Scene.free} or a `using` declaration (otherwise it is freed when
@@ -672,11 +1009,54 @@ declare class Scene implements SceneLike {
672
1009
  */
673
1010
  removeMesh(mesh: MeshHandle): void;
674
1011
  /**
675
- * Sets a mesh's placement: world = rotation · local + translation, where
676
- * local is relative to the mesh origin. A quaternion is normalised and
677
- * converted in double precision.
1012
+ * Joins `source` into `target`: copies the source's geometry into the
1013
+ * target (keeping its world shape), bridges `options.loopA` to the copied
1014
+ * `options.loopB`, and removes the source. The copy and the bridge undo as
1015
+ * one step; the removal is permanent. A drag of the source ends first,
1016
+ * recording its moves as one step, so they survive a failed join.
1017
+ *
1018
+ * @throws `UNKNOWN_MESH` for a removed handle; `INVALID_ARGUMENT` for one
1019
+ * mesh twice or loops that cannot bridge; `STALE_LOOPS` for a loop that is
1020
+ * not there. A failed join changes nothing.
1021
+ */
1022
+ join(target: MeshHandle, source: MeshHandle, options: JoinOptions): JoinReport;
1023
+ /**
1024
+ * Cuts `mesh` with a world `plane`: the `+` side
1025
+ * (`signedDistance >= 0`) stays on the mesh and the `-` side is added as
1026
+ * a new mesh with the same placement, so the world shape is kept.
1027
+ * Cutting a closed mesh with `cap` (the default) yields two closed
1028
+ * meshes, capped with flat, unfaired patches.
1029
+ *
1030
+ * The cut undoes in one step; the added mesh stays, like the removed
1031
+ * source of {@link Scene.join}.
1032
+ *
1033
+ * @throws `UNKNOWN_MESH` for a removed handle; `INVALID_ARGUMENT` when
1034
+ * the plane does not cut the mesh or a rim cannot be capped. A failed cut
1035
+ * changes nothing.
1036
+ */
1037
+ cutByPlane(mesh: MeshHandle, plane: SectionPlane, options?: CutOptions): CutReport;
1038
+ /**
1039
+ * Combines `source` into `target` in the world: the union, subtraction
1040
+ * (`target` minus `source`) or intersection. Returns `target`, now
1041
+ * holding the result with its placement; `source` is unchanged.
1042
+ *
1043
+ * Both meshes must be closed and manifold. The boolean undoes in one
1044
+ * step. Combining a mesh with itself is a no-op for `"union"` and
1045
+ * `"intersect"`, and clears it for `"subtract"`.
1046
+ *
1047
+ * @throws `UNKNOWN_MESH` for a removed handle; `INVALID_ARGUMENT` for an
1048
+ * input that is not closed, manifold and consistently wound. A failed
1049
+ * boolean changes nothing.
1050
+ */
1051
+ boolean(target: MeshHandle, source: MeshHandle, op: BooleanOp): MeshHandle;
1052
+ /**
1053
+ * Sets a mesh's placement: world = rotation · (scale · local) + translation,
1054
+ * where local is relative to the mesh origin. A quaternion is normalised
1055
+ * and converted in double precision. The scale defaults to `[1, 1, 1]`
1056
+ * (rigid) and must be 3 finite positive numbers.
678
1057
  *
679
- * @throws `INVALID_ARGUMENT` when the rotation is not a proper rotation or a quaternion is zero.
1058
+ * @throws `INVALID_ARGUMENT` when the rotation is not a proper rotation, the
1059
+ * scale is not 3 finite positive numbers, or a quaternion is zero.
680
1060
  */
681
1061
  setPlacement(mesh: MeshHandle, placement: PlacementInput): void;
682
1062
  /** A mesh's placement, with the rotation as a row-major matrix. */
@@ -684,7 +1064,8 @@ declare class Scene implements SceneLike {
684
1064
  /**
685
1065
  * The column-major world matrix of the local render coordinates,
686
1066
  * `placement · translate(origin)`, ready for renderers (convert to `f32`
687
- * yourself).
1067
+ * yourself). The rotation columns carry the scale; normals need the
1068
+ * inverse-transpose (three.js' normal matrix does this from the matrix).
688
1069
  */
689
1070
  matrix4(mesh: MeshHandle): Float64Array;
690
1071
  /** Sets when the mesh's derived data follows its edits; see {@link UpdateMode}. */
@@ -796,6 +1177,14 @@ declare class Scene implements SceneLike {
796
1177
  * @throws `INVALID_ARGUMENT` for a negative or non-finite `weldTolerance`; `STALE_BVH`, see {@link AnalyzeOptions.selfIntersection}.
797
1178
  */
798
1179
  analyze(mesh: MeshHandle, options?: AnalyzeOptions): Analysis;
1180
+ /**
1181
+ * Scalar measurements of a mesh in world coordinates: its surface area
1182
+ * (always) and, when watertight, its enclosed volume. An open or
1183
+ * non-manifold mesh still gets its area; only `volume` is `null`, with
1184
+ * `volumeReason` saying why. A read-only call: it leaves every view
1185
+ * valid.
1186
+ */
1187
+ measure(mesh: MeshHandle): MeasureResult;
799
1188
  /**
800
1189
  * Runs one repair operation and returns its report, or a list of them in
801
1190
  * order and returns their reports. A list is one transaction: one undo step,
@@ -830,6 +1219,61 @@ declare class Scene implements SceneLike {
830
1219
  intersects(a: MeshHandle, b: MeshHandle): boolean;
831
1220
  /** Every mesh pair (or every pair of `pairs`) within `margin`, sorted by mesh id. */
832
1221
  findContacts(options?: FindContactsOptions): Contact[];
1222
+ /**
1223
+ * Selects vertices of a mesh: a sphere brush, a lasso polygon, or the
1224
+ * connected component holding a seed vertex. The result is a snapshot
1225
+ * (ascending ids plus the mesh's content stamp); any edit, repair, compact,
1226
+ * undo or redo of the mesh invalidates it, and the selection methods then
1227
+ * throw `STALE_SELECTION` instead of silently remapping ids. Placement
1228
+ * changes keep selections valid. Only vertices a live triangle uses can
1229
+ * be selected (dead or never-used slots never are).
1230
+ *
1231
+ * @throws `UNKNOWN_MESH` for a removed mesh; `INVALID_ARGUMENT` for a bad
1232
+ * spec; `INVALID_INDEX` for an out-of-range component seed.
1233
+ */
1234
+ select(mesh: MeshHandle, spec: SelectSpec): VertexSelection;
1235
+ /**
1236
+ * Whether `sel` is still usable: its mesh is alive and no topology edit
1237
+ * landed since it was taken. Never throws.
1238
+ */
1239
+ selectionAlive(sel: VertexSelection): boolean;
1240
+ /**
1241
+ * Grows a selection by `steps` rings of edge neighbours (staying on live
1242
+ * vertices). The result carries the current stamp, so a fresh selection
1243
+ * can be grown right after an edit. `steps` 0 returns an equal copy.
1244
+ *
1245
+ * @throws `STALE_SELECTION` when the mesh changed since the selection;
1246
+ * `UNKNOWN_MESH` for a removed mesh.
1247
+ */
1248
+ selectGrow(sel: VertexSelection, steps?: number): VertexSelection;
1249
+ /**
1250
+ * Shrinks a selection by `steps` rings, dropping the members with a live
1251
+ * neighbour outside the set. Interior selections (no boundary) survive
1252
+ * unchanged; shrinking past the core gives an empty (still valid)
1253
+ * selection.
1254
+ *
1255
+ * @throws `STALE_SELECTION` when the mesh changed since the selection;
1256
+ * `UNKNOWN_MESH` for a removed mesh.
1257
+ */
1258
+ selectShrink(sel: VertexSelection, steps?: number): VertexSelection;
1259
+ /**
1260
+ * Inverts a selection: every live vertex outside it. The result carries
1261
+ * the current stamp.
1262
+ *
1263
+ * @throws `STALE_SELECTION` when the mesh changed since the selection;
1264
+ * `UNKNOWN_MESH` for a removed mesh.
1265
+ */
1266
+ selectInvert(sel: VertexSelection): VertexSelection;
1267
+ /**
1268
+ * Isolates a selection: removes the triangles fully outside it (no
1269
+ * selected vertex), one undo step. Boundary triangles with at least one
1270
+ * selected vertex stay. An empty selection selects nothing to keep and
1271
+ * throws `INVALID_ARGUMENT` rather than clearing the mesh.
1272
+ *
1273
+ * @throws `STALE_SELECTION` when the mesh changed since the selection;
1274
+ * `UNKNOWN_MESH` for a removed mesh.
1275
+ */
1276
+ isolate(mesh: MeshHandle, sel: VertexSelection): IsolateReport;
833
1277
  /**
834
1278
  * Adds a signed distance field: one value per vertex slot of `on`, the
835
1279
  * distance to `to` as placed (negative inside), `Infinity` beyond
@@ -841,6 +1285,25 @@ declare class Scene implements SceneLike {
841
1285
  * @throws `INVALID_ARGUMENT` when `to` is empty, holds `on` or a mesh twice, `maxDistance` is negative or NaN, or the name is taken.
842
1286
  */
843
1287
  addDistanceField(desc: DistanceFieldDesc): FieldHandle;
1288
+ /**
1289
+ * Adds a per-vertex wall-thickness field: one value per vertex slot of
1290
+ * `on`, the distance to the opposite surface along the vertex's smooth
1291
+ * normal, in world units. Open sheets and rims read NaN, hits beyond
1292
+ * `maxDistance` read `Infinity`. It follows edits and placements by the
1293
+ * mesh modes, like normals, and colours like any field.
1294
+ *
1295
+ * @throws `INVALID_ARGUMENT` when `maxDistance` is negative or NaN, or the name is taken.
1296
+ */
1297
+ addThicknessField(desc: ThicknessFieldDesc): FieldHandle;
1298
+ /**
1299
+ * Adds a per-vertex curvature field: one value per vertex slot of `on`,
1300
+ * the signed mean curvature there, in 1/world-units (positive on domes,
1301
+ * negative in bowls, zero on flats). It follows edits and placements by
1302
+ * the mesh modes, like normals, and colours like any field.
1303
+ *
1304
+ * @throws `INVALID_ARGUMENT` when the name is taken.
1305
+ */
1306
+ addCurvatureField(desc: CurvatureFieldDesc): FieldHandle;
844
1307
  /** Removes a field, and a colouring by it. Its handle then gives `UNKNOWN_FIELD`. */
845
1308
  removeField(field: FieldHandle): void;
846
1309
  /**
@@ -923,8 +1386,6 @@ declare class Scene implements SceneLike {
923
1386
  */
924
1387
  sectionGap(section: SectionHandle, a: MeshHandle, b: MeshHandle): SectionGap | null;
925
1388
  }
926
- //#endregion
927
- //#region src/scene-like.d.ts
928
1389
  /**
929
1390
  * What the adapters need from a scene: render buffers, placements, section
930
1391
  * results, change notification and drags. All methods are synchronous.
@@ -962,5 +1423,4 @@ interface SceneLike {
962
1423
  */
963
1424
  bounds?(mesh: MeshHandle): Bounds | null;
964
1425
  }
965
- //#endregion
966
- export { Placement as $, RemoveReport as A, SectionPlane as B, MeshChange as C, OutOfRange as D, OrientReport as E, Scene as F, MeshHandle as G, SignMode as H, SceneOptions as I, MeshViews as J, SectionHandle as K, SectionContour as L, RepairReport as M, RepairReportOf as N, RayHit as O, Rgba as P, Mat3 as Q, SectionDesc as R, LoopId as S, MeshDistance as T, WeldReport as U, SectionResult as V, FieldHandle as W, Indices as X, Bounds as Y, InitInput as Z, EditResult as _, BoundaryLoop as a, Vec3 as at, FilledLoop as b, ColorRule as c, DegenerateReport as d, PlacementInput as et, DistanceFieldDesc as f, EditRef as g, EditOp as h, AnalyzeOptions as i, UpdateMode as it, RepairOp as j, RaycastOptions as k, Colormap as l, DragSession as m, AddMeshOptions as n, Positions64 as nt, ClosestHit as o, computeBounds as ot, DragOptions as p, Range as q, Analysis as r, Quat as rt, ClosestPointOptions as s, computeVertexNormals as st, SceneLike as t, Positions as tt, Contact as u, FieldStatus as v, MeshComponent as w, FindContactsOptions as x, FillReport as y, SectionGap as z };
1426
+ export { SectionPlane as $, JoinReport as A, computeBounds as At, RaycastOptions as B, FieldStatus as C, Placement as Ct, GrabReport as D, Quat as Dt, FindContactsOptions as E, Positions64 as Et, MeshDistance as F, RepairReport as G, RemeshReport as H, OffsetReport as I, Scene as J, RepairReportOf as K, OrientReport as L, MeasureResult as M, MeshChange as N, InflateReport as O, UpdateMode as Ot, MeshComponent as P, SectionGap as Q, OutOfRange as R, EditResult as S, Mat3 as St, FilledLoop as T, Positions as Tt, RemoveReport as U, RelaxReport as V, RepairOp as W, SectionContour as X, SceneOptions as Y, SectionDesc as Z, DistanceFieldDesc as _, MeshHandle as _t, BooleanOp as a, SubdivideReport as at, EditOp as b, Indices as bt, ClosestHit as c, BrushSelect as ct, Colormap as d, LassoSelect as dt, SectionResult as et, Contact as f, SelectSpec as ft, DegenerateReport as g, FieldHandle as gt, CutReport as h, MeshViews as ht, AnalyzeOptions as i, SmoothReport as it, LoopId as j, computeVertexNormals as jt, JoinOptions as k, Vec3 as kt, ClosestPointOptions as l, ComponentSelect as lt, CutOptions as m, Range as mt, AddMeshOptions as n, SignMode as nt, BoundaryLoop as o, ThicknessFieldDesc as ot, CurvatureFieldDesc as p, VertexSelection as pt, Rgba as q, Analysis as r, SimplifyReport as rt, BridgeReport as s, WeldReport as st, SceneLike as t, ShellReport as tt, ColorRule as u, IsolateReport as ut, DragOptions as v, SectionHandle as vt, FillReport as w, PlacementInput as wt, EditRef as x, InitInput as xt, DragSession as y, Bounds as yt, RayHit as z };
@@ -1,4 +1,4 @@
1
- //#region src/store/snapshot.ts
1
+ // src/store/snapshot.ts
2
2
  /** A plain-data value deep-copied and deep-frozen; handles and other class instances are kept as they are. */
3
3
  function frozenCopy(value) {
4
4
  if (typeof value !== "object" || value === null) return value;
@@ -100,5 +100,4 @@ function combine(parts) {
100
100
  } : { status: p.status };
101
101
  return out;
102
102
  }
103
- //#endregion
104
103
  export { combine as a, sameData as c, REMOVED_SECTION_STATE as i, sectionState as l, EMPTY_SNAPSHOT as n, frozenCopy as o, REMOVED_MESH_STATE as r, meshState as s, DEFAULT_DISPLAY as t };