fast-mesh-wasm 0.5.3 → 0.6.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.
Files changed (39) hide show
  1. package/README.md +2 -1
  2. package/dist/{client-f895H_yB.js → client-BrTp2eMp.js} +20 -1
  3. package/dist/{client-D7yfPOyU.d.ts → client-Ds09vLkN.d.ts} +13 -2
  4. package/dist/{engine-BcJ5W6kS.js → engine-DjdY3GxK.js} +7 -3
  5. package/dist/io.d.ts +19 -4
  6. package/dist/io.js +64 -9
  7. package/dist/{mesh-B3QP93wx.d.ts → mesh-BsqIofgT.d.ts} +5 -2
  8. package/dist/{mesh-hPWBQPaN.js → mesh-DIWD2F5-.js} +51 -2
  9. package/dist/node.d.ts +2 -2
  10. package/dist/node.js +1 -1
  11. package/dist/{protocol-Dt0zgang.d.ts → protocol-Cb23HelE.d.ts} +7 -1
  12. package/dist/r3f.d.ts +3 -3
  13. package/dist/r3f.js +2 -2
  14. package/dist/react.d.ts +2 -2
  15. package/dist/{scene-CXtM_bxV.js → scene-D0HNTwoo.js} +82 -6
  16. package/dist/{scene-like-Dq9_SaUL.d.ts → scene-like-CADk1vfb.d.ts} +118 -8
  17. package/dist/{store-CIW19oCh.d.ts → store-BfC6kkf5.d.ts} +2 -2
  18. package/dist/{store-C9h7GFFl.js → store-DIQmxF_s.js} +2 -2
  19. package/dist/store.d.ts +2 -2
  20. package/dist/store.js +1 -1
  21. package/dist/three.d.ts +2 -2
  22. package/dist/three.js +1 -1
  23. package/dist/{views-mp7Mf8CQ.js → views-B00kdV0R.js} +6 -1
  24. package/dist/wasm/fast_mesh_wasm.d.ts +14 -1
  25. package/dist/wasm/fast_mesh_wasm.js +29 -1
  26. package/dist/wasm/fast_mesh_wasm_bg.wasm +0 -0
  27. package/dist/wasm/fast_mesh_wasm_bg.wasm.d.ts +2 -0
  28. package/dist/wasm-threads/fast_mesh_wasm.d.ts +14 -1
  29. package/dist/wasm-threads/fast_mesh_wasm.js +29 -1
  30. package/dist/wasm-threads/fast_mesh_wasm_bg.wasm +0 -0
  31. package/dist/wasm-threads/fast_mesh_wasm_bg.wasm.d.ts +2 -0
  32. package/dist/web.d.ts +2 -2
  33. package/dist/web.js +1 -1
  34. package/dist/worker-engine.d.ts +5 -3
  35. package/dist/worker-engine.js +1 -1
  36. package/dist/worker-entry.js +1 -1
  37. package/dist/worker.d.ts +1 -1
  38. package/dist/worker.js +1 -1
  39. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { a as FieldHandle, c as rotationMatrix, i as encodeRule, l as targetsOf, n as meshViews, o as MeshHandle, r as copyRule, s as SectionHandle, t as ViewGuard, u as checkRegisterOptions } from "./views-mp7Mf8CQ.js";
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-B00kdV0R.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
@@ -314,6 +314,8 @@ function useWasmScene(ctor) {
314
314
  }
315
315
  const meshIds = /* @__PURE__ */ new WeakMap();
316
316
  const rawIds = /* @__PURE__ */ new WeakMap();
317
+ /** The repair list's prefix code for a {@link VertexProtection}. */
318
+ const PROTECT_CODE = 32;
317
319
  const MODES = {
318
320
  eager: 0,
319
321
  lazy: 1,
@@ -474,7 +476,9 @@ const REPAIR_CODES = {
474
476
  offset: 11,
475
477
  shell: 12,
476
478
  simplify: 13,
477
- subdivide: 14
479
+ subdivide: 14,
480
+ splitStretched: 16,
481
+ captureRestSizes: 17
478
482
  };
479
483
  /** The op code of an {@link AutoRepairRequest}; see `crate::edit` in the Rust crate. */
480
484
  const AUTO_REPAIR_CODE = 15;
@@ -528,11 +532,23 @@ function encodeLoopId(id, out) {
528
532
  function isAutoRepair(op) {
529
533
  return op?.kind === "auto";
530
534
  }
535
+ /** The prefix that wraps the op after it in a {@link VertexProtection}; see `crate::edit` in the Rust crate. */
536
+ function encodeProtect(protect, values) {
537
+ const { vertices, weights } = protect;
538
+ if (vertices?.length === void 0) throw invalid("protect.vertices must be an array of vertex ids");
539
+ const n = vertices.length;
540
+ if (weights !== void 0 && weights.length !== n) throw invalid("protect.weights must have one weight per vertex");
541
+ values.push(PROTECT_CODE, n);
542
+ for (let k = 0; k < n; k++) values.push(vertices[k]);
543
+ for (let k = 0; k < n; k++) values.push(weights === void 0 ? 0 : weights[k]);
544
+ }
531
545
  /** A repair op list as the binding's `(ops, loops)`; see `crate::edit` in the Rust crate. */
532
546
  function encodeRepair(ops) {
533
547
  const values = [];
534
548
  const loops = [];
535
549
  for (const o of ops) {
550
+ const protect = o?.protect;
551
+ if (protect !== void 0) encodeProtect(protect, values);
536
552
  values.push(codeIn(REPAIR_CODES, o?.op, "repair op"));
537
553
  switch (o.op) {
538
554
  case "weld":
@@ -594,7 +610,14 @@ function encodeRepair(ops) {
594
610
  case "simplify":
595
611
  values.push(optional(o.targetTriangles, "targetTriangles"), flagOf(o.preserveBoundary, true));
596
612
  break;
597
- case "subdivide": values.push(o.method === void 0 ? NaN : codeIn(SUBDIVIDE_METHOD_CODES, o.method, "method"), optional(o.levels, "levels"));
613
+ case "subdivide":
614
+ values.push(o.method === void 0 ? NaN : codeIn(SUBDIVIDE_METHOD_CODES, o.method, "method"), optional(o.levels, "levels"));
615
+ break;
616
+ case "splitStretched":
617
+ centerOf(o.center, values);
618
+ values.push(optional(o.radius, "radius"), optional(o.limit, "limit"), optional(o.maxSplits, "maxSplits"), flagOf(o.smooth, true));
619
+ break;
620
+ case "captureRestSizes": values.push(flagOf(o.onlyIfMissing, false));
598
621
  }
599
622
  }
600
623
  return {
@@ -737,6 +760,18 @@ function decodeReport(op, r) {
737
760
  verticesAdded: r.next(),
738
761
  trianglesAdded: r.next()
739
762
  };
763
+ case "splitStretched": {
764
+ const splits = r.next();
765
+ const remaining = r.next();
766
+ const vertices = new Uint32Array(3 * splits);
767
+ for (let k = 0; k < vertices.length; k++) vertices[k] = r.next();
768
+ return {
769
+ splits,
770
+ remaining,
771
+ vertices
772
+ };
773
+ }
774
+ case "captureRestSizes": return {};
740
775
  }
741
776
  }
742
777
  /** An auto repair's result, stage by stage in the order they ran; see `crate::edit` in the Rust crate. */
@@ -1009,14 +1044,19 @@ var Scene = class {
1009
1044
  * (`signedDistance >= 0`) stays on the mesh and the `-` side is added as
1010
1045
  * a new mesh with the same placement, so the world shape is kept.
1011
1046
  * Cutting a closed mesh with `cap` (the default) yields two closed
1012
- * meshes, capped with flat, unfaired patches.
1047
+ * meshes, capped with flat, unfaired patches. On a mesh with UVs, closed
1048
+ * means closed by exact position, so seams count as closed: the cap's UVs
1049
+ * come from the rim and blend across a seam. A rim that runs into a real
1050
+ * boundary of an open mesh stays open. A mesh without UVs is read by vertex
1051
+ * index, so its split vertices are such a boundary: weld it first.
1013
1052
  *
1014
1053
  * The cut undoes in one step; the added mesh stays, like the removed
1015
1054
  * source of {@link Scene.join}.
1016
1055
  *
1017
1056
  * @throws `UNKNOWN_MESH` for a removed handle; `INVALID_ARGUMENT` when
1018
- * the plane does not cut the mesh or a rim cannot be capped. A failed cut
1019
- * changes nothing.
1057
+ * the plane does not cut the mesh or a rim cannot be capped, as listed in
1058
+ * `docs/uv-channel.md`, for example a rim that closes by position with its
1059
+ * walls wound against each other. A failed cut changes nothing.
1020
1060
  */
1021
1061
  cutByPlane(mesh, plane, options) {
1022
1062
  const { index, generation } = this.#id(mesh);
@@ -1171,6 +1211,19 @@ var Scene = class {
1171
1211
  };
1172
1212
  }
1173
1213
  /**
1214
+ * The mesh's origin. `views(mesh).positions()` are relative to it, while
1215
+ * `edit`'s `setPositions` and `addVertices` take positions with it added.
1216
+ */
1217
+ origin(mesh) {
1218
+ const { index, generation } = this.#id(mesh);
1219
+ const o = call(() => this.#peek().origin(index, generation));
1220
+ return [
1221
+ o[0],
1222
+ o[1],
1223
+ o[2]
1224
+ ];
1225
+ }
1226
+ /**
1174
1227
  * The column-major world matrix of the local render coordinates,
1175
1228
  * `placement · translate(origin)`, ready for renderers (convert to `f32`
1176
1229
  * yourself). The rotation columns carry the scale; normals need the
@@ -1180,6 +1233,29 @@ var Scene = class {
1180
1233
  const { index, generation } = this.#id(mesh);
1181
1234
  return call(() => this.#peek().matrix4(index, generation));
1182
1235
  }
1236
+ /**
1237
+ * Starts (`points`) or ends (`null`) an interaction: a gesture that changes
1238
+ * a placement or a mesh many times a second (a drag, a brush stroke), during
1239
+ * which a distance field too large to recompute per update stays live near
1240
+ * the contact, and is made exact when the gesture ends.
1241
+ *
1242
+ * While it lasts, a field with more finite values than `points` updates
1243
+ * only the vertices near its moved targets (within a margin that follows
1244
+ * the work, about `points` vertices an update), the vertices an edit moved
1245
+ * and a sweep of a quarter of `points` others. The rest keep their values
1246
+ * and colours, out of date by at most how far the meshes moved since, so
1247
+ * nothing turns far meanwhile. A smaller field updates as usual. Ending it
1248
+ * recomputes the fields it left out of date: their values and colours are
1249
+ * then those of an exact update. A gesture that changed nothing costs
1250
+ * nothing. The results do not depend on the thread count.
1251
+ *
1252
+ * @throws `INVALID_ARGUMENT` unless `points` is `null` or an integer in
1253
+ * `[1, 2^32)`.
1254
+ */
1255
+ setFieldInteraction(points) {
1256
+ const budget = checkInteractionPoints(points);
1257
+ call(() => this.#scene().set_field_interaction(budget ?? void 0));
1258
+ }
1183
1259
  /** Sets when the mesh's derived data follows its edits; see {@link UpdateMode}. */
1184
1260
  setMode(mesh, mode) {
1185
1261
  const { index, generation } = this.#id(mesh);
@@ -731,6 +731,8 @@ type RepairOp = {
731
731
  falloff: "linear" | "smooth";
732
732
  /** Displacement scale; negative pulls instead of pushing. */
733
733
  strength: number;
734
+ /** Vertices this op must hold in place, or move less. */
735
+ protect?: VertexProtection;
734
736
  } | {
735
737
  op: "smooth";
736
738
  /** Brush center in local mesh coordinates, as in `views(mesh).positions()`. */
@@ -741,6 +743,8 @@ type RepairOp = {
741
743
  strength: number;
742
744
  /** How many Taubin λ/μ cycles to run; 0 moves nothing. */
743
745
  cycles: number;
746
+ /** Vertices this op must hold in place, or move less. */
747
+ protect?: VertexProtection;
744
748
  } | {
745
749
  op: "remesh";
746
750
  /** Region center in local mesh coordinates, as in `views(mesh).positions()`. */
@@ -752,6 +756,38 @@ type RepairOp = {
752
756
  maxRounds?: number;
753
757
  /** Split long edges only (no collapses, no flips); unset means a full pass. */
754
758
  splitOnly?: boolean;
759
+ } | {
760
+ /**
761
+ * Records each vertex's longest edge as its rest size, for
762
+ * `splitStretched`. Run it before the deformation starts. Not an edit:
763
+ * no undo step, and it must be the only op of its list. Running it again
764
+ * accepts the mesh as it is then as the new rest shape; `onlyIfMissing`
765
+ * avoids that. The sizes last until a topology edit other than
766
+ * `splitStretched`, or an undo or redo of an edit from before the capture;
767
+ * undoing a topology edit from after it brings them back.
768
+ */
769
+ op: "captureRestSizes";
770
+ /** Keep rest sizes the mesh still holds. Unset means `false`. */
771
+ onlyIfMissing?: boolean;
772
+ } | {
773
+ /**
774
+ * Splits the edges a deformation stretched, and nothing else: an edge
775
+ * splits once it is past `limit` times the smaller rest size of its
776
+ * endpoints, measured by `captureRestSizes`. Existing vertices keep their
777
+ * ids and positions, nothing collapses or flips, and a triangle with no
778
+ * split edge keeps its slot. Fails while the mesh holds no valid rest
779
+ * sizes: see `captureRestSizes`.
780
+ */
781
+ op: "splitStretched";
782
+ /** Region center in local mesh coordinates; edges with an endpoint in the region are checked. */
783
+ center: Readonly<Vec3>;
784
+ radius: number;
785
+ /** Multiple of the rest size an edge may reach, above 1; unset means 4/3. */
786
+ limit?: number;
787
+ /** Most interior splits per call, the longest first; boundary edges do not count. Unset means 2^20. */
788
+ maxSplits?: number;
789
+ /** New interior vertices follow the surface's curvature; `false` uses midpoints. Unset means `true`. */
790
+ smooth?: boolean;
755
791
  } | {
756
792
  op: "bridgeLoops";
757
793
  /** The two loops to connect, from `analyze(mesh).loops`. Order is insignificant. */
@@ -768,6 +804,8 @@ type RepairOp = {
768
804
  strength: number;
769
805
  /** The drag vector in local coordinates; zero moves nothing. */
770
806
  direction: Readonly<Vec3>;
807
+ /** Vertices this op must hold in place, or move less. */
808
+ protect?: VertexProtection;
771
809
  } | {
772
810
  op: "relax";
773
811
  /** Brush center in local mesh coordinates, as in `views(mesh).positions()`. */
@@ -778,6 +816,8 @@ type RepairOp = {
778
816
  strength: number;
779
817
  /** How many plain Laplacian passes to run; 0 moves nothing. */
780
818
  cycles: number;
819
+ /** Vertices this op must hold in place, or move less. */
820
+ protect?: VertexProtection;
781
821
  } | {
782
822
  op: "offset";
783
823
  /**
@@ -868,6 +908,23 @@ interface FillReport {
868
908
  reason: "projectionFolds" | "noValidTriangulation" | "solver";
869
909
  }[];
870
910
  }
911
+ /**
912
+ * Vertices a brush op (`inflate`, `smooth`, `relax`, `grab`) holds back.
913
+ * After the op runs, each listed vertex's move is scaled by its weight: `0`
914
+ * leaves it at exactly the bytes it had, `1` keeps the whole move. The op's
915
+ * report describes its own move, before the scaling, and it stays one undo step;
916
+ * an op alone whose brush holds only vertices at `0` reports 0 and leaves no step.
917
+ * List only what the brush can reach: every listed vertex costs time per call.
918
+ *
919
+ * @throws `INVALID_ARGUMENT` from `repair` when a vertex is not alive, a weight
920
+ * is outside `[0, 1]`, or the lists differ in length.
921
+ */
922
+ interface VertexProtection {
923
+ /** The vertex slots to protect. */
924
+ vertices: Uint32Array | readonly number[];
925
+ /** One weight per vertex, each in `[0, 1]`; unset holds every listed vertex fully (all `0`). */
926
+ weights?: Float32Array | readonly number[];
927
+ }
871
928
  /** What `inflate` did. */
872
929
  interface InflateReport {
873
930
  moved: number;
@@ -885,6 +942,20 @@ interface RemeshReport {
885
942
  flips: number;
886
943
  rounds: number;
887
944
  }
945
+ /** What `splitStretched` did. */
946
+ interface StretchReport {
947
+ splits: number;
948
+ /** Edges still past the limit because `maxSplits` ran out, for a later call. */
949
+ remaining: number;
950
+ /**
951
+ * `new, a, b` per split, in order: the new vertex and its edge's endpoints,
952
+ * which may be new vertices from earlier in the list. For a caller that holds
953
+ * per-vertex state of its own and has to carry it over.
954
+ */
955
+ vertices: Uint32Array;
956
+ }
957
+ /** What `captureRestSizes` did: nothing to report. */
958
+ type CaptureRestReport = Record<string, never>;
888
959
  /** What `bridgeLoops` did. */
889
960
  interface BridgeReport {
890
961
  trianglesAdded: number;
@@ -1075,8 +1146,9 @@ interface RegisterResult {
1075
1146
  /** Options of {@link Scene.cutByPlane}. */
1076
1147
  interface CutOptions {
1077
1148
  /**
1078
- * Close both openings with flat, unfaired patches. Defaults to `true`;
1079
- * without it both parts keep the open rim the cut leaves.
1149
+ * Close both openings with flat, unfaired patches, across UV seams on a
1150
+ * mesh with UVs. Defaults to `true`; without it both parts keep the open
1151
+ * rim the cut leaves.
1080
1152
  */
1081
1153
  cap?: boolean;
1082
1154
  }
@@ -1123,7 +1195,7 @@ interface AutoRepairReport {
1123
1195
  fillHoles: FillReport;
1124
1196
  }
1125
1197
  /** The report of a {@link RepairOp}. */
1126
- type RepairReport = WeldReport | DegenerateReport | RemoveReport | OrientReport | FillReport | InflateReport | SmoothReport | RemeshReport | BridgeReport | GrabReport | RelaxReport | OffsetReport | ShellReport | SimplifyReport | SubdivideReport;
1198
+ type RepairReport = WeldReport | DegenerateReport | RemoveReport | OrientReport | FillReport | InflateReport | SmoothReport | RemeshReport | BridgeReport | GrabReport | RelaxReport | OffsetReport | ShellReport | SimplifyReport | SubdivideReport | StretchReport | CaptureRestReport;
1127
1199
  /** The report type of a repair op. */
1128
1200
  type RepairReportOf<O extends RepairOp> = O extends {
1129
1201
  op: "weld";
@@ -1155,7 +1227,11 @@ type RepairReportOf<O extends RepairOp> = O extends {
1155
1227
  op: "simplify";
1156
1228
  } ? SimplifyReport : O extends {
1157
1229
  op: "subdivide";
1158
- } ? SubdivideReport : RepairReport;
1230
+ } ? SubdivideReport : O extends {
1231
+ op: "splitStretched";
1232
+ } ? StretchReport : O extends {
1233
+ op: "captureRestSizes";
1234
+ } ? CaptureRestReport : RepairReport;
1159
1235
  /**
1160
1236
  * A scene of editable meshes. Create it after `await init()`; release it with
1161
1237
  * {@link Scene.free} or a `using` declaration (otherwise it is freed when
@@ -1206,14 +1282,19 @@ declare class Scene implements SceneLike {
1206
1282
  * (`signedDistance >= 0`) stays on the mesh and the `-` side is added as
1207
1283
  * a new mesh with the same placement, so the world shape is kept.
1208
1284
  * Cutting a closed mesh with `cap` (the default) yields two closed
1209
- * meshes, capped with flat, unfaired patches.
1285
+ * meshes, capped with flat, unfaired patches. On a mesh with UVs, closed
1286
+ * means closed by exact position, so seams count as closed: the cap's UVs
1287
+ * come from the rim and blend across a seam. A rim that runs into a real
1288
+ * boundary of an open mesh stays open. A mesh without UVs is read by vertex
1289
+ * index, so its split vertices are such a boundary: weld it first.
1210
1290
  *
1211
1291
  * The cut undoes in one step; the added mesh stays, like the removed
1212
1292
  * source of {@link Scene.join}.
1213
1293
  *
1214
1294
  * @throws `UNKNOWN_MESH` for a removed handle; `INVALID_ARGUMENT` when
1215
- * the plane does not cut the mesh or a rim cannot be capped. A failed cut
1216
- * changes nothing.
1295
+ * the plane does not cut the mesh or a rim cannot be capped, as listed in
1296
+ * `docs/uv-channel.md`, for example a rim that closes by position with its
1297
+ * walls wound against each other. A failed cut changes nothing.
1217
1298
  */
1218
1299
  cutByPlane(mesh: MeshHandle, plane: SectionPlane, options?: CutOptions): CutReport;
1219
1300
  /**
@@ -1277,6 +1358,11 @@ declare class Scene implements SceneLike {
1277
1358
  setPlacement(mesh: MeshHandle, placement: PlacementInput): void;
1278
1359
  /** A mesh's placement, with the rotation as a row-major matrix. */
1279
1360
  placement(mesh: MeshHandle): Placement;
1361
+ /**
1362
+ * The mesh's origin. `views(mesh).positions()` are relative to it, while
1363
+ * `edit`'s `setPositions` and `addVertices` take positions with it added.
1364
+ */
1365
+ origin(mesh: MeshHandle): Vec3;
1280
1366
  /**
1281
1367
  * The column-major world matrix of the local render coordinates,
1282
1368
  * `placement · translate(origin)`, ready for renderers (convert to `f32`
@@ -1284,6 +1370,26 @@ declare class Scene implements SceneLike {
1284
1370
  * inverse-transpose (three.js' normal matrix does this from the matrix).
1285
1371
  */
1286
1372
  matrix4(mesh: MeshHandle): Float64Array;
1373
+ /**
1374
+ * Starts (`points`) or ends (`null`) an interaction: a gesture that changes
1375
+ * a placement or a mesh many times a second (a drag, a brush stroke), during
1376
+ * which a distance field too large to recompute per update stays live near
1377
+ * the contact, and is made exact when the gesture ends.
1378
+ *
1379
+ * While it lasts, a field with more finite values than `points` updates
1380
+ * only the vertices near its moved targets (within a margin that follows
1381
+ * the work, about `points` vertices an update), the vertices an edit moved
1382
+ * and a sweep of a quarter of `points` others. The rest keep their values
1383
+ * and colours, out of date by at most how far the meshes moved since, so
1384
+ * nothing turns far meanwhile. A smaller field updates as usual. Ending it
1385
+ * recomputes the fields it left out of date: their values and colours are
1386
+ * then those of an exact update. A gesture that changed nothing costs
1387
+ * nothing. The results do not depend on the thread count.
1388
+ *
1389
+ * @throws `INVALID_ARGUMENT` unless `points` is `null` or an integer in
1390
+ * `[1, 2^32)`.
1391
+ */
1392
+ setFieldInteraction(points: number | null): void;
1287
1393
  /** Sets when the mesh's derived data follows its edits; see {@link UpdateMode}. */
1288
1394
  setMode(mesh: MeshHandle, mode: UpdateMode): void;
1289
1395
  /** When the mesh's derived data follows its edits; see {@link UpdateMode}. */
@@ -1408,6 +1514,10 @@ declare class Scene implements SceneLike {
1408
1514
  * `{ kind: "auto" }` runs the standard cleanup pipeline the same way and
1409
1515
  * returns a report per stage; see {@link AutoRepairRequest}.
1410
1516
  *
1517
+ * A single `inflate`, `relax` or `grab` costs by the vertices under the brush, not the
1518
+ * mesh (it uses the BVH, and reaches only vertices a triangle uses); in a list
1519
+ * they scan the mesh, so a sculpt stroke should send its dabs one at a time.
1520
+ *
1411
1521
  * @throws `INVALID_ARGUMENT` for invalid options (`fillHoles` needs a bound or `loops`); `STALE_LOOPS` when a loop id of `fillHoles` no longer matches a loop of the mesh.
1412
1522
  */
1413
1523
  repair(mesh: MeshHandle, request: AutoRepairRequest): AutoRepairReport;
@@ -1642,4 +1752,4 @@ interface SceneLike {
1642
1752
  */
1643
1753
  bounds?(mesh: MeshHandle): Bounds | null;
1644
1754
  }
1645
- export { RepairReportOf as $, InflateReport as A, Mat3 as At, OutOfRange as B, EditRef as C, SceneMeshViews as Ct, FilledLoop as D, Bounds as Dt, FillReport as E, SectionHandle as Et, MeshChange as F, Quat as Ft, RegisterOptions as G, RaycastOptions as H, MeshComponent as I, UpdateMode as It, RelaxReport as J, RegisterResult as K, MeshDistance as L, Vec3 as Lt, JoinReport as M, PlacementInput as Mt, LoopId as N, Positions as Nt, FindContactsOptions as O, Indices as Ot, MeasureResult as P, Positions64 as Pt, RepairReport as Q, OffsetReport as R, computeBounds as Rt, EditOp as S, MeshViews as St, FieldStatus as T, MeshHandle as Tt, RegisterMotion as U, RayHit as V, RegisterNotApplied as W, RemoveReport as X, RemeshReport as Y, RepairOp as Z, CutReport as _, IsolateReport as _t, AutoRepairReport as a, SectionGap as at, DragOptions as b, VertexSelection as bt, BoundaryLoop as c, ShellReport as ct, ClosestPointOptions as d, SmoothReport as dt, Rgba as et, ColorRule as f, SubdivideReport as ft, CutOptions as g, ComponentSelect as gt, CurvatureFieldDesc as h, BrushSelect as ht, AnalyzeOptions as i, SectionDesc as it, JoinOptions as j, Placement as jt, GrabReport as k, InitInput as kt, BridgeReport as l, SignMode as lt, Contact as m, WeldReport as mt, AddMeshOptions as n, SceneOptions as nt, AutoRepairRequest as o, SectionPlane as ot, Colormap as p, ThicknessFieldDesc as pt, RegisterStatus as q, Analysis as r, SectionContour as rt, BooleanOp as s, SectionResult as st, SceneLike as t, Scene as tt, ClosestHit as u, SimplifyReport as ut, DegenerateReport as v, LassoSelect as vt, EditResult as w, FieldHandle as wt, DragSession as x, Range as xt, DistanceFieldDesc as y, SelectSpec as yt, OrientReport as z, computeVertexNormals as zt };
1755
+ export { RepairReport as $, GrabReport as A, Bounds as At, OrientReport as B, Vec3 as Bt, EditOp as C, VertexSelection as Ct, FillReport as D, FieldHandle as Dt, FieldStatus as E, SceneMeshViews as Et, MeasureResult as F, PlacementInput as Ft, RegisterNotApplied as G, RayHit as H, computeVertexNormals as Ht, MeshChange as I, Positions as It, RegisterStatus as J, RegisterOptions as K, MeshComponent as L, Positions64 as Lt, JoinOptions as M, InitInput as Mt, JoinReport as N, Mat3 as Nt, FilledLoop as O, MeshHandle as Ot, LoopId as P, Placement as Pt, RepairOp as Q, MeshDistance as R, Quat as Rt, DragSession as S, SelectSpec as St, EditResult as T, MeshViews as Tt, RaycastOptions as U, OutOfRange as V, computeBounds as Vt, RegisterMotion as W, RemeshReport as X, RelaxReport as Y, RemoveReport as Z, CutOptions as _, WeldReport as _t, AutoRepairReport as a, SectionDesc as at, DistanceFieldDesc as b, IsolateReport as bt, BoundaryLoop as c, SectionResult as ct, ClosestHit as d, SimplifyReport as dt, RepairReportOf as et, ClosestPointOptions as f, SmoothReport as ft, CurvatureFieldDesc as g, VertexProtection as gt, Contact as h, ThicknessFieldDesc as ht, AnalyzeOptions as i, SectionContour as it, InflateReport as j, Indices as jt, FindContactsOptions as k, SectionHandle as kt, BridgeReport as l, ShellReport as lt, Colormap as m, SubdivideReport as mt, AddMeshOptions as n, Scene as nt, AutoRepairRequest as o, SectionGap as ot, ColorRule as p, StretchReport as pt, RegisterResult as q, Analysis as r, SceneOptions as rt, BooleanOp as s, SectionPlane as st, SceneLike as t, Rgba as tt, CaptureRestReport as u, SignMode as ut, CutReport as v, BrushSelect as vt, EditRef as w, Range as wt, DragOptions as x, LassoSelect as xt, DegenerateReport as y, ComponentSelect as yt, OffsetReport as z, UpdateMode as zt };
@@ -1,5 +1,5 @@
1
- import { B as OutOfRange, Et as SectionHandle, F as MeshChange, Mt as PlacementInput, Ot as Indices, Pt as Positions64, Q as RepairReport, S as EditOp, Tt as MeshHandle, Z as RepairOp, a as AutoRepairReport, et as Rgba, it as SectionDesc, lt as SignMode, n as AddMeshOptions, o as AutoRepairRequest, ot as SectionPlane, p as Colormap, t as SceneLike, tt as Scene, w as EditResult, x as DragSession } from "./scene-like-Dq9_SaUL.js";
2
- import { i as WorkerScene } from "./client-D7yfPOyU.js";
1
+ import { $ as RepairReport, C as EditOp, Ft as PlacementInput, I as MeshChange, Lt as Positions64, Ot as MeshHandle, Q as RepairOp, S as DragSession, T as EditResult, V as OutOfRange, a as AutoRepairReport, at as SectionDesc, jt as Indices, kt as SectionHandle, m as Colormap, n as AddMeshOptions, nt as Scene, o as AutoRepairRequest, st as SectionPlane, t as SceneLike, tt as Rgba, ut as SignMode } from "./scene-like-CADk1vfb.js";
2
+ import { i as WorkerScene } from "./client-Ds09vLkN.js";
3
3
  import { t as FastMeshError } from "./core-CJ9D6U5A.js";
4
4
  /** Options of `SceneStore.addMesh`: those both scenes take (a store mesh is always eager). */
5
5
  type StoreAddMeshOptions = Pick<AddMeshOptions, "origin" | "normals" | "uvs">;
@@ -1,7 +1,7 @@
1
1
  import { o as reportListenerError, t as FastMeshError } from "./core-4OcWKu3r.js";
2
- import { l as targetsOf } from "./views-mp7Mf8CQ.js";
2
+ import { u as targetsOf } from "./views-B00kdV0R.js";
3
3
  import { i as sectionAspects } from "./protocol-Ci9LLiwO.js";
4
- import { a as watchStatusKeys, r as addFieldKeyed } from "./client-f895H_yB.js";
4
+ import { a as watchStatusKeys, r as addFieldKeyed } from "./client-BrTp2eMp.js";
5
5
  import { a as combine, c as sameData, n as EMPTY_SNAPSHOT, o as frozenCopy, t as DEFAULT_DISPLAY } from "./snapshot-BkbGPspK.js";
6
6
  // src/store/host.ts
7
7
  /** Whether `scene` is a Worker scene (structurally: it reports key statuses). */
package/dist/store.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { et as Rgba, lt as SignMode } from "./scene-like-Dq9_SaUL.js";
2
- import { _ as StoreAddMeshOptions, a as DisplayState, c as MeshState, d as SceneSnapshot, f as SectionParts, g as sectionState, h as meshState, i as ContactGroup, l as REMOVED_MESH_STATE, m as Status, n as SectionPatch, o as DistanceColoring, p as SectionState, r as createSceneStore, s as EMPTY_SNAPSHOT, t as SceneStore, u as REMOVED_SECTION_STATE } from "./store-CIW19oCh.js";
1
+ import { tt as Rgba, ut as SignMode } from "./scene-like-CADk1vfb.js";
2
+ import { _ as StoreAddMeshOptions, a as DisplayState, c as MeshState, d as SceneSnapshot, f as SectionParts, g as sectionState, h as meshState, i as ContactGroup, l as REMOVED_MESH_STATE, m as Status, n as SectionPatch, o as DistanceColoring, p as SectionState, r as createSceneStore, s as EMPTY_SNAPSHOT, t as SceneStore, u as REMOVED_SECTION_STATE } from "./store-BfC6kkf5.js";
3
3
  /** Options of {@link contactHeatmap}. Distances are in the meshes' units. */
4
4
  interface ContactHeatmapOptions {
5
5
  /** The penetration depth shown darkest (`deep`); deeper clamps to it. `> 0`. */
package/dist/store.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { t as FastMeshError } from "./core-4OcWKu3r.js";
2
2
  import { i as REMOVED_SECTION_STATE, l as sectionState, n as EMPTY_SNAPSHOT, r as REMOVED_MESH_STATE, s as meshState } from "./snapshot-BkbGPspK.js";
3
- import { n as createSceneStore, t as SceneStore } from "./store-C9h7GFFl.js";
3
+ import { n as createSceneStore, t as SceneStore } from "./store-DIQmxF_s.js";
4
4
  // src/store/heatmap.ts
5
5
  /** The default colours: `#7f0000`, `#ff6b6b`, `#ffffff`, `#4caf50`, `#1e3a8a`. */
6
6
  const DEFAULT_COLORS = {
package/dist/three.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Et as SectionHandle, t as SceneLike } from "./scene-like-Dq9_SaUL.js";
2
- import { i as bindMesh, n as BoundMesh, r as MeshBinding, t as BindMeshOptions } from "./mesh-B3QP93wx.js";
1
+ import { kt as SectionHandle, t as SceneLike } from "./scene-like-CADk1vfb.js";
2
+ import { i as bindMesh, n as BoundMesh, r as MeshBinding, t as BindMeshOptions } from "./mesh-BsqIofgT.js";
3
3
  import * as THREE from "three";
4
4
  /**
5
5
  * What {@link attachTransformControls} needs of a TransformControls: its
package/dist/three.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as FastMeshError } from "./core-4OcWKu3r.js";
2
- import { n as checkUntransformedParent, t as bindMesh } from "./mesh-hPWBQPaN.js";
2
+ import { n as checkUntransformedParent, t as bindMesh } from "./mesh-DIWD2F5-.js";
3
3
  import * as THREE from "three";
4
4
  // src/three/controls.ts
5
5
  const defaultSchedule = (callback) => {
@@ -141,6 +141,11 @@ function copyRule(rule) {
141
141
  if (Array.isArray(stops)) copy.map = Object.freeze({ stops: Object.freeze(stops.map((stop) => Array.isArray(stop) ? Object.freeze(stop.map(frozen)) : stop)) });
142
142
  return Object.freeze(copy);
143
143
  }
144
+ /** @internal The argument of `setFieldInteraction`, checked. */
145
+ function checkInteractionPoints(points) {
146
+ if (points !== null && (!Number.isInteger(points) || points < 1 || points >= 2 ** 32)) throw new FastMeshError("INVALID_ARGUMENT", "an interaction's points must be null or an integer in [1, 2^32)");
147
+ return points;
148
+ }
144
149
  // src/views.ts
145
150
  /**
146
151
  * Debug-mode check of kept views. The scene bumps the epoch on every call
@@ -206,4 +211,4 @@ function meshViews(scene, index, generation, guard) {
206
211
  indices: () => build(u32, (s) => s.indices_ptr(index, generation), (s) => s.indices_len(index, generation))
207
212
  };
208
213
  }
209
- export { FieldHandle as a, rotationMatrix as c, encodeRule as i, targetsOf as l, meshViews as n, MeshHandle as o, copyRule as r, SectionHandle as s, ViewGuard as t, checkRegisterOptions as u };
214
+ export { encodeRule as a, SectionHandle as c, checkRegisterOptions as d, copyRule as i, rotationMatrix as l, meshViews as n, FieldHandle as o, checkInteractionPoints as r, MeshHandle as s, ViewGuard as t, targetsOf as u };
@@ -200,7 +200,8 @@ export class WasmScene {
200
200
  * the same placement. Returns `[kept index, kept generation, added
201
201
  * index, added generation, kept triangles, removed triangles, cap
202
202
  * triangles]`. With `cap` (the usual case) both openings are closed
203
- * with flat, unfaired patches; without it both parts keep the open rim.
203
+ * with flat, unfaired patches, across UV seams on a mesh with UVs;
204
+ * without it both parts keep the open rim.
204
205
  * The cut undoes in one step; the added mesh stays, like the removed
205
206
  * source of [`WasmScene::join`].
206
207
  */
@@ -363,6 +364,11 @@ export class WasmScene {
363
364
  * off.
364
365
  */
365
366
  normals_ptr(index: number, generation: number): number;
367
+ /**
368
+ * The mesh's origin: its stored positions are relative to it, and
369
+ * `setPositions` takes positions with it added back.
370
+ */
371
+ origin(index: number, generation: number): Float64Array;
366
372
  /**
367
373
  * The placement: the row-major rotation (9 values), then the
368
374
  * translation (3 values), then the scale (3 values).
@@ -448,6 +454,11 @@ export class WasmScene {
448
454
  * [`Scene::set_defer_fields`].
449
455
  */
450
456
  set_defer_fields(on: boolean): void;
457
+ /**
458
+ * Starts (a budget of `points`) or ends (`undefined`) an interaction; see
459
+ * [`Scene::set_field_interaction`].
460
+ */
461
+ set_field_interaction(points?: number | null): void;
451
462
  /**
452
463
  * Sets when the mesh's BVH, normals, fields and sections follow its
453
464
  * edits: 0 (Eager), 1 (Lazy) or 2 (Manual).
@@ -609,6 +620,7 @@ export interface InitOutput {
609
620
  readonly wasmscene_new: () => number;
610
621
  readonly wasmscene_normals_len: (a: number, b: number, c: number) => [number, number, number];
611
622
  readonly wasmscene_normals_ptr: (a: number, b: number, c: number) => [number, number, number];
623
+ readonly wasmscene_origin: (a: number, b: number, c: number) => [number, number, number, number];
612
624
  readonly wasmscene_placement: (a: number, b: number, c: number) => [number, number, number, number];
613
625
  readonly wasmscene_positions_len: (a: number, b: number, c: number) => [number, number, number];
614
626
  readonly wasmscene_positions_ptr: (a: number, b: number, c: number) => [number, number, number];
@@ -624,6 +636,7 @@ export interface InitOutput {
624
636
  readonly wasmscene_section_gap: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
625
637
  readonly wasmscene_set_coloring: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
626
638
  readonly wasmscene_set_defer_fields: (a: number, b: number) => void;
639
+ readonly wasmscene_set_field_interaction: (a: number, b: number) => [number, number];
627
640
  readonly wasmscene_set_mode: (a: number, b: number, c: number, d: number) => [number, number];
628
641
  readonly wasmscene_set_placement: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
629
642
  readonly wasmscene_set_section_fill: (a: number, b: number, c: number) => [number, number];
@@ -538,7 +538,8 @@ export class WasmScene {
538
538
  * the same placement. Returns `[kept index, kept generation, added
539
539
  * index, added generation, kept triangles, removed triangles, cap
540
540
  * triangles]`. With `cap` (the usual case) both openings are closed
541
- * with flat, unfaired patches; without it both parts keep the open rim.
541
+ * with flat, unfaired patches, across UV seams on a mesh with UVs;
542
+ * without it both parts keep the open rim.
542
543
  * The cut undoes in one step; the added mesh stays, like the removed
543
544
  * source of [`WasmScene::join`].
544
545
  * @param {number} index
@@ -962,6 +963,22 @@ export class WasmScene {
962
963
  }
963
964
  return ret[0] >>> 0;
964
965
  }
966
+ /**
967
+ * The mesh's origin: its stored positions are relative to it, and
968
+ * `setPositions` takes positions with it added back.
969
+ * @param {number} index
970
+ * @param {number} generation
971
+ * @returns {Float64Array}
972
+ */
973
+ origin(index, generation) {
974
+ const ret = wasm.wasmscene_origin(this.__wbg_ptr, index, generation);
975
+ if (ret[3]) {
976
+ throw takeFromExternrefTable0(ret[2]);
977
+ }
978
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
979
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
980
+ return v1;
981
+ }
965
982
  /**
966
983
  * The placement: the row-major rotation (9 values), then the
967
984
  * translation (3 values), then the scale (3 values).
@@ -1208,6 +1225,17 @@ export class WasmScene {
1208
1225
  set_defer_fields(on) {
1209
1226
  wasm.wasmscene_set_defer_fields(this.__wbg_ptr, on);
1210
1227
  }
1228
+ /**
1229
+ * Starts (a budget of `points`) or ends (`undefined`) an interaction; see
1230
+ * [`Scene::set_field_interaction`].
1231
+ * @param {number | null} [points]
1232
+ */
1233
+ set_field_interaction(points) {
1234
+ const ret = wasm.wasmscene_set_field_interaction(this.__wbg_ptr, isLikeNone(points) ? Number.MAX_SAFE_INTEGER : (points) >>> 0);
1235
+ if (ret[1]) {
1236
+ throw takeFromExternrefTable0(ret[0]);
1237
+ }
1238
+ }
1211
1239
  /**
1212
1240
  * Sets when the mesh's BVH, normals, fields and sections follow its
1213
1241
  * edits: 0 (Eager), 1 (Lazy) or 2 (Manual).
Binary file
@@ -62,6 +62,7 @@ export const wasmscene_mode: (a: number, b: number, c: number) => [number, numbe
62
62
  export const wasmscene_new: () => number;
63
63
  export const wasmscene_normals_len: (a: number, b: number, c: number) => [number, number, number];
64
64
  export const wasmscene_normals_ptr: (a: number, b: number, c: number) => [number, number, number];
65
+ export const wasmscene_origin: (a: number, b: number, c: number) => [number, number, number, number];
65
66
  export const wasmscene_placement: (a: number, b: number, c: number) => [number, number, number, number];
66
67
  export const wasmscene_positions_len: (a: number, b: number, c: number) => [number, number, number];
67
68
  export const wasmscene_positions_ptr: (a: number, b: number, c: number) => [number, number, number];
@@ -77,6 +78,7 @@ export const wasmscene_section_desc_plane: (a: number, b: number) => [number, nu
77
78
  export const wasmscene_section_gap: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
78
79
  export const wasmscene_set_coloring: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
79
80
  export const wasmscene_set_defer_fields: (a: number, b: number) => void;
81
+ export const wasmscene_set_field_interaction: (a: number, b: number) => [number, number];
80
82
  export const wasmscene_set_mode: (a: number, b: number, c: number, d: number) => [number, number];
81
83
  export const wasmscene_set_placement: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
82
84
  export const wasmscene_set_section_fill: (a: number, b: number, c: number) => [number, number];
@@ -200,7 +200,8 @@ export class WasmScene {
200
200
  * the same placement. Returns `[kept index, kept generation, added
201
201
  * index, added generation, kept triangles, removed triangles, cap
202
202
  * triangles]`. With `cap` (the usual case) both openings are closed
203
- * with flat, unfaired patches; without it both parts keep the open rim.
203
+ * with flat, unfaired patches, across UV seams on a mesh with UVs;
204
+ * without it both parts keep the open rim.
204
205
  * The cut undoes in one step; the added mesh stays, like the removed
205
206
  * source of [`WasmScene::join`].
206
207
  */
@@ -363,6 +364,11 @@ export class WasmScene {
363
364
  * off.
364
365
  */
365
366
  normals_ptr(index: number, generation: number): number;
367
+ /**
368
+ * The mesh's origin: its stored positions are relative to it, and
369
+ * `setPositions` takes positions with it added back.
370
+ */
371
+ origin(index: number, generation: number): Float64Array;
366
372
  /**
367
373
  * The placement: the row-major rotation (9 values), then the
368
374
  * translation (3 values), then the scale (3 values).
@@ -448,6 +454,11 @@ export class WasmScene {
448
454
  * [`Scene::set_defer_fields`].
449
455
  */
450
456
  set_defer_fields(on: boolean): void;
457
+ /**
458
+ * Starts (a budget of `points`) or ends (`undefined`) an interaction; see
459
+ * [`Scene::set_field_interaction`].
460
+ */
461
+ set_field_interaction(points?: number | null): void;
451
462
  /**
452
463
  * Sets when the mesh's BVH, normals, fields and sections follow its
453
464
  * edits: 0 (Eager), 1 (Lazy) or 2 (Manual).
@@ -632,6 +643,7 @@ export interface InitOutput {
632
643
  readonly wasmscene_new: () => number;
633
644
  readonly wasmscene_normals_len: (a: number, b: number, c: number) => [number, number, number];
634
645
  readonly wasmscene_normals_ptr: (a: number, b: number, c: number) => [number, number, number];
646
+ readonly wasmscene_origin: (a: number, b: number, c: number) => [number, number, number, number];
635
647
  readonly wasmscene_placement: (a: number, b: number, c: number) => [number, number, number, number];
636
648
  readonly wasmscene_positions_len: (a: number, b: number, c: number) => [number, number, number];
637
649
  readonly wasmscene_positions_ptr: (a: number, b: number, c: number) => [number, number, number];
@@ -647,6 +659,7 @@ export interface InitOutput {
647
659
  readonly wasmscene_section_gap: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
648
660
  readonly wasmscene_set_coloring: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
649
661
  readonly wasmscene_set_defer_fields: (a: number, b: number) => void;
662
+ readonly wasmscene_set_field_interaction: (a: number, b: number) => [number, number];
650
663
  readonly wasmscene_set_mode: (a: number, b: number, c: number, d: number) => [number, number];
651
664
  readonly wasmscene_set_placement: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
652
665
  readonly wasmscene_set_section_fill: (a: number, b: number, c: number) => [number, number];