fast-mesh-wasm 0.4.0 → 0.5.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 (34) hide show
  1. package/dist/{client-Bpjy-eFY.js → client-CE6RvmvB.js} +41 -7
  2. package/dist/{client-D-O5-tAg.d.ts → client-pv0Fwvl4.d.ts} +8 -2
  3. package/dist/{engine-D6MpGb9i.js → engine-DLQAL9GT.js} +47 -22
  4. package/dist/{mesh-BUVxv3jo.d.ts → mesh-RtPVmPQy.d.ts} +1 -1
  5. package/dist/node.d.ts +2 -2
  6. package/dist/node.js +1 -1
  7. package/dist/{protocol-CAUYm1gd.js → protocol-DkhGNP0h.js} +6 -4
  8. package/dist/{protocol-CK6_3aqo.d.ts → protocol-z-jeCUGO.d.ts} +11 -1
  9. package/dist/r3f.d.ts +3 -3
  10. package/dist/r3f.js +1 -1
  11. package/dist/react.d.ts +2 -2
  12. package/dist/{scene-D6m9XM3O.js → scene-DyYdEQdy.js} +79 -1
  13. package/dist/{scene-like-DJKQP5uf.d.ts → scene-like-YcY08oii.d.ts} +95 -3
  14. package/dist/{store-QWRDXlAn.d.ts → store-C5nzCpxy.d.ts} +2 -2
  15. package/dist/{store-Ml3TQGsR.js → store-Z6A2HPih.js} +2 -2
  16. package/dist/store.d.ts +2 -2
  17. package/dist/store.js +1 -1
  18. package/dist/three.d.ts +2 -2
  19. package/dist/wasm/fast_mesh_wasm.d.ts +9 -0
  20. package/dist/wasm/fast_mesh_wasm.js +25 -0
  21. package/dist/wasm/fast_mesh_wasm_bg.wasm +0 -0
  22. package/dist/wasm/fast_mesh_wasm_bg.wasm.d.ts +1 -0
  23. package/dist/wasm-threads/fast_mesh_wasm.d.ts +9 -0
  24. package/dist/wasm-threads/fast_mesh_wasm.js +25 -0
  25. package/dist/wasm-threads/fast_mesh_wasm_bg.wasm +0 -0
  26. package/dist/wasm-threads/fast_mesh_wasm_bg.wasm.d.ts +1 -0
  27. package/dist/web.d.ts +2 -2
  28. package/dist/web.js +1 -1
  29. package/dist/worker-engine.d.ts +1 -1
  30. package/dist/worker-engine.js +1 -1
  31. package/dist/worker-entry.js +1 -1
  32. package/dist/worker.d.ts +1 -1
  33. package/dist/worker.js +1 -1
  34. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import { o as reportListenerError, t as FastMeshError } from "./core-Cke_kZ2e.js";
2
2
  import { a as FieldHandle, c as rotationMatrix, l as targetsOf, o as MeshHandle, r as copyRule, s as SectionHandle, t as ViewGuard } from "./views-Dh3aWc2q.js";
3
- import { a as supersedes, n as isLastWins, r as keyOf } from "./protocol-CAUYm1gd.js";
3
+ import { a as supersedes, n as isLastWins, r as keyOf } from "./protocol-DkhGNP0h.js";
4
4
  //#region src/worker/client.ts
5
5
  /**
6
6
  * Starts a Worker running the scene engine and resolves once it is ready.
@@ -1035,8 +1035,47 @@ var WorkerScene = class WorkerScene {
1035
1035
  removeMesh(mesh) {
1036
1036
  const st = this.#live(mesh);
1037
1037
  if (this.#drag?.mesh === st) this.#drag.end();
1038
- st.removed = true;
1039
1038
  const rev = ++this.#rev;
1039
+ this.#noteRemoved(st, rev);
1040
+ this.#push({
1041
+ kind: "removeMesh",
1042
+ rev,
1043
+ id: st.id
1044
+ });
1045
+ }
1046
+ /**
1047
+ * Joins `source` into `target`; see `Scene.join`. The source stays usable
1048
+ * until the join lands: only a successful result removes it (a failed join
1049
+ * changes nothing, engine-side or here).
1050
+ */
1051
+ join(target, source, options) {
1052
+ const ta = this.#live(target);
1053
+ const st = this.#live(source);
1054
+ if (this.#drag?.mesh === st) this.#drag.end();
1055
+ const payload = copyInput(options, "options");
1056
+ let rev = 0;
1057
+ return this.#ask((r, qid) => {
1058
+ rev = r;
1059
+ return {
1060
+ kind: "join",
1061
+ rev: r,
1062
+ target: ta.id,
1063
+ source: st.id,
1064
+ payload,
1065
+ qid
1066
+ };
1067
+ }, (v) => v).then((report) => {
1068
+ this.#noteRemoved(st, rev);
1069
+ return report;
1070
+ });
1071
+ }
1072
+ /**
1073
+ * Notes a mesh as removed at `rev`: later calls on it give `UNKNOWN_MESH`,
1074
+ * fields on it (or only to it) are dropped and its section entries go. The
1075
+ * engine does the same when the removal lands.
1076
+ */
1077
+ #noteRemoved(st, rev) {
1078
+ st.removed = true;
1040
1079
  for (const f of this.#fields.values()) {
1041
1080
  if (f.removed) continue;
1042
1081
  if (f.desc.on === st.id || f.desc.to.length === 1 && f.desc.to[0] === st.id) this.#fieldRemoved(f, rev);
@@ -1046,11 +1085,6 @@ var WorkerScene = class WorkerScene {
1046
1085
  };
1047
1086
  }
1048
1087
  for (const s of this.#sections.values()) if (!s.removed) s.meshes = s.meshes.filter((m) => m !== st);
1049
- this.#push({
1050
- kind: "removeMesh",
1051
- rev,
1052
- id: st.id
1053
- });
1054
1088
  }
1055
1089
  /** Sets a mesh's placement (one undo step); `placement()` follows when the result arrives. */
1056
1090
  setPlacement(mesh, placement) {
@@ -1,6 +1,6 @@
1
- import { $ as Placement, B as SectionPlane, C as MeshChange, G as MeshHandle, J as MeshViews, K as SectionHandle, N as RepairReportOf, O as RayHit, R as SectionDesc, T as MeshDistance, V as SectionResult, W as FieldHandle, X as Indices, _ as EditResult, at as Vec3, c as ColorRule, et as PlacementInput, f as DistanceFieldDesc, h as EditOp, i as AnalyzeOptions, j as RepairOp, k as RaycastOptions, m as DragSession, n as AddMeshOptions, nt as Positions64, o as ClosestHit, r as Analysis, s as ClosestPointOptions, t as SceneLike, u as Contact, v as FieldStatus, x as FindContactsOptions, z as SectionGap } from "./scene-like-DJKQP5uf.js";
1
+ import { D as MeshChange, G as SectionPlane, I as RepairOp, K as SectionResult, M as RayHit, N as RaycastOptions, Q as SectionHandle, R as RepairReportOf, S as FindContactsOptions, T as JoinReport, U as SectionDesc, W as SectionGap, X as FieldHandle, Z as MeshHandle, at as Placement, c as ClosestPointOptions, ct as Positions64, d as Contact, dt as Vec3, et as MeshViews, g as EditOp, h as DragSession, i as AnalyzeOptions, k as MeshDistance, l as ColorRule, n as AddMeshOptions, nt as Indices, ot as PlacementInput, p as DistanceFieldDesc, r as Analysis, s as ClosestHit, t as SceneLike, v as EditResult, w as JoinOptions, y as FieldStatus } from "./scene-like-YcY08oii.js";
2
2
  import { t as FastMeshError } from "./core-D2X9GPfK.js";
3
- import "./protocol-CK6_3aqo.js";
3
+ import "./protocol-z-jeCUGO.js";
4
4
  //#region src/worker/client.d.ts
5
5
  /** What {@link WorkerScene} needs of a Worker; a browser `Worker` fits. */
6
6
  interface WorkerLike {
@@ -120,6 +120,12 @@ declare class WorkerScene implements SceneLike {
120
120
  * by `commitFrame()`.
121
121
  */
122
122
  removeMesh(mesh: MeshHandle): void;
123
+ /**
124
+ * Joins `source` into `target`; see `Scene.join`. The source stays usable
125
+ * until the join lands: only a successful result removes it (a failed join
126
+ * changes nothing, engine-side or here).
127
+ */
128
+ join(target: MeshHandle, source: MeshHandle, options: JoinOptions): Promise<JoinReport>;
123
129
  /** Sets a mesh's placement (one undo step); `placement()` follows when the result arrives. */
124
130
  setPlacement(mesh: MeshHandle, placement: PlacementInput): void;
125
131
  /** The mesh's placement as mirrored (a drag's pose while it is held). */
@@ -1,6 +1,6 @@
1
1
  import { s as setMemory, t as FastMeshError } from "./core-Cke_kZ2e.js";
2
- import { i as useWasmScene, n as fieldSteps, r as meshAdds, t as Scene } from "./scene-D6m9XM3O.js";
3
- import { a as supersedes, n as isLastWins, r as keyOf, t as isInit } from "./protocol-CAUYm1gd.js";
2
+ import { i as useWasmScene, n as fieldSteps, r as meshAdds, t as Scene } from "./scene-DyYdEQdy.js";
3
+ import { a as supersedes, n as isLastWins, r as keyOf, t as isInit } from "./protocol-DkhGNP0h.js";
4
4
  /**
5
5
  * A module importing a shared memory `e.m` (1 page, at most 2), exporting
6
6
  * `grow(pages)` (`memory.grow`: the old size in pages, or -1),
@@ -874,6 +874,7 @@ var Engine = class {
874
874
  case "drag":
875
875
  case "edit":
876
876
  case "repair": return this.#pending(req.id);
877
+ case "join": return this.#pending(req.target, req.source);
877
878
  case "coloring": return this.#pending(req.id) || req.rule !== null && this.#fieldPending(req.rule?.field);
878
879
  case "fetchFieldValues": return this.#fieldPending(req.field);
879
880
  case "field": return req.desc !== void 0 ? this.#pending(req.desc.on, ...req.desc.to) : this.#fieldPending(req.field);
@@ -940,8 +941,8 @@ var Engine = class {
940
941
  }
941
942
  /**
942
943
  * Whether `req` may change the positions, normals or triangles of the
943
- * mesh `id`: an edit, repair, compaction or removal of it, or any undo
944
- * or redo.
944
+ * mesh `id`: an edit, repair, compaction, join or removal of it, or any
945
+ * undo or redo.
945
946
  */
946
947
  #changesMesh(req, id) {
947
948
  switch (req.kind) {
@@ -949,6 +950,7 @@ var Engine = class {
949
950
  case "repair":
950
951
  case "compact":
951
952
  case "removeMesh": return req.id === id;
953
+ case "join": return req.target === id || req.source === id;
952
954
  case "undo":
953
955
  case "redo": return true;
954
956
  default: return false;
@@ -1184,8 +1186,8 @@ var Engine = class {
1184
1186
  * Whether the queued `req` makes a field step unit over `meshes` (the
1185
1187
  * meshes its fields are on and measured to) stale (§6.1): a drag move
1186
1188
  * (only with `moves`: within the starvation guard), a drag cancel or a
1187
- * placement, an edit, repair, compaction or removal of one of them, an
1188
- * undo or redo, or the removal of a field between two of them.
1189
+ * placement, an edit, repair, compaction, join or removal of one of them,
1190
+ * an undo or redo, or the removal of a field between two of them.
1189
1191
  */
1190
1192
  #makesStale(req, meshes, moves) {
1191
1193
  switch (req.kind) {
@@ -1195,6 +1197,7 @@ var Engine = class {
1195
1197
  case "repair":
1196
1198
  case "compact":
1197
1199
  case "removeMesh": return meshes.has(req.id);
1200
+ case "join": return meshes.has(req.target) || meshes.has(req.source);
1198
1201
  case "undo":
1199
1202
  case "redo": return true;
1200
1203
  case "field": {
@@ -1506,6 +1509,28 @@ var Engine = class {
1506
1509
  #meshId(h) {
1507
1510
  return this.#meshIds.get(h);
1508
1511
  }
1512
+ /**
1513
+ * Drops engine-side references of a removed mesh: fields on it (or only
1514
+ * to it) and its section entries. The scene did the same with the mesh.
1515
+ */
1516
+ #dropMeshRefs(id) {
1517
+ for (const [field, [on, ...to]] of this.#fieldMeshes) if (on === id || to.length === 1 && to[0] === id) this.#dropField(field);
1518
+ else if (to.includes(id)) {
1519
+ this.#fieldMeshes.set(field, [on, ...to.filter((m) => m !== id)]);
1520
+ const desc = this.#deferred.get(field);
1521
+ if (desc !== void 0) this.#deferred.set(field, {
1522
+ ...desc,
1523
+ to: desc.to.filter((m) => m !== id)
1524
+ });
1525
+ }
1526
+ for (const [section, meshes] of this.#sectionMeshes) if (meshes.includes(id)) {
1527
+ this.#sectionMeshes.set(section, meshes.filter((m) => m !== id));
1528
+ this.#goneEntries.push({
1529
+ section,
1530
+ mesh: id
1531
+ });
1532
+ }
1533
+ }
1509
1534
  #run(req, b) {
1510
1535
  const s = this.#scene;
1511
1536
  switch (req.kind) {
@@ -1526,22 +1551,22 @@ var Engine = class {
1526
1551
  this.#meshes.delete(req.id);
1527
1552
  this.#removed.push(h);
1528
1553
  if (this.#drag?.id === req.id) this.#drag = void 0;
1529
- for (const [field, [on, ...to]] of this.#fieldMeshes) if (on === req.id || to.length === 1 && to[0] === req.id) this.#dropField(field);
1530
- else if (to.includes(req.id)) {
1531
- this.#fieldMeshes.set(field, [on, ...to.filter((m) => m !== req.id)]);
1532
- const desc = this.#deferred.get(field);
1533
- if (desc !== void 0) this.#deferred.set(field, {
1534
- ...desc,
1535
- to: desc.to.filter((m) => m !== req.id)
1536
- });
1537
- }
1538
- for (const [section, meshes] of this.#sectionMeshes) if (meshes.includes(req.id)) {
1539
- this.#sectionMeshes.set(section, meshes.filter((m) => m !== req.id));
1540
- this.#goneEntries.push({
1541
- section,
1542
- mesh: req.id
1543
- });
1544
- }
1554
+ this.#dropMeshRefs(req.id);
1555
+ return;
1556
+ }
1557
+ case "join": {
1558
+ const target = this.#mesh(req.target);
1559
+ const source = this.#mesh(req.source);
1560
+ const value = s.join(target, source, req.payload);
1561
+ this.#meshes.delete(req.source);
1562
+ this.#removed.push(source);
1563
+ if (this.#drag?.id === req.source) this.#drag = void 0;
1564
+ this.#dropMeshRefs(req.source);
1565
+ if (req.qid !== void 0) b.replies.push({
1566
+ qid: req.qid,
1567
+ ok: true,
1568
+ value
1569
+ });
1545
1570
  return;
1546
1571
  }
1547
1572
  case "compact":
@@ -1,4 +1,4 @@
1
- import { G as MeshHandle, t as SceneLike } from "./scene-like-DJKQP5uf.js";
1
+ import { Z as MeshHandle, t as SceneLike } from "./scene-like-YcY08oii.js";
2
2
  import * as THREE from "three";
3
3
  //#region src/three/mesh.d.ts
4
4
  /** Options of {@link bindMesh}. */
package/dist/node.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as Placement, A as RemoveReport, B as SectionPlane, C as MeshChange, D as OutOfRange, E as OrientReport, F as Scene, G as MeshHandle, H as SignMode, I as SceneOptions, J as MeshViews, K as SectionHandle, L as SectionContour, M as RepairReport, N as RepairReportOf, O as RayHit, P as Rgba, Q as Mat3, R as SectionDesc, S as LoopId, T as MeshDistance, U as WeldReport, V as SectionResult, W as FieldHandle, X as Indices, Y as Bounds, Z as InitInput, _ as EditResult, a as BoundaryLoop, at as Vec3, b as FilledLoop, c as ColorRule, d as DegenerateReport, et as PlacementInput, f as DistanceFieldDesc, g as EditRef, h as EditOp, i as AnalyzeOptions, it as UpdateMode, j as RepairOp, k as RaycastOptions, l as Colormap, m as DragSession, n as AddMeshOptions, nt as Positions64, o as ClosestHit, ot as computeBounds, p as DragOptions, q as Range, r as Analysis, rt as Quat, s as ClosestPointOptions, st as computeVertexNormals, t as SceneLike, tt as Positions, u as Contact, v as FieldStatus, w as MeshComponent, x as FindContactsOptions, y as FillReport, z as SectionGap } from "./scene-like-DJKQP5uf.js";
1
+ import { $ as Range, A as OrientReport, B as Scene, C as InflateReport, D as MeshChange, E as LoopId, F as RemoveReport, G as SectionPlane, H as SectionContour, I as RepairOp, J as SmoothReport, K as SectionResult, L as RepairReport, M as RayHit, N as RaycastOptions, O as MeshComponent, P as RemeshReport, Q as SectionHandle, R as RepairReportOf, S as FindContactsOptions, T as JoinReport, U as SectionDesc, V as SceneOptions, W as SectionGap, X as FieldHandle, Y as WeldReport, Z as MeshHandle, _ as EditRef, a as BoundaryLoop, at as Placement, b as FillReport, c as ClosestPointOptions, ct as Positions64, d as Contact, dt as Vec3, et as MeshViews, f as DegenerateReport, ft as computeBounds, g as EditOp, h as DragSession, i as AnalyzeOptions, it as Mat3, j as OutOfRange, k as MeshDistance, l as ColorRule, lt as Quat, m as DragOptions, n as AddMeshOptions, nt as Indices, o as BridgeReport, ot as PlacementInput, p as DistanceFieldDesc, pt as computeVertexNormals, q as SignMode, r as Analysis, rt as InitInput, s as ClosestHit, st as Positions, t as SceneLike, tt as Bounds, u as Colormap, ut as UpdateMode, v as EditResult, w as JoinOptions, x as FilledLoop, y as FieldStatus, z as Rgba } from "./scene-like-YcY08oii.js";
2
2
  import { n as FastMeshErrorCode, t as FastMeshError } from "./core-D2X9GPfK.js";
3
3
  //#region src/node.d.ts
4
4
  /**
@@ -8,4 +8,4 @@ import { n as FastMeshErrorCode, t as FastMeshError } from "./core-D2X9GPfK.js";
8
8
  */
9
9
  export declare function init(_input?: InitInput | Promise<InitInput>): Promise<void>;
10
10
  //#endregion
11
- export { type AddMeshOptions, type Analysis, type AnalyzeOptions, type BoundaryLoop, type Bounds, type ClosestHit, type ClosestPointOptions, type ColorRule, type Colormap, type Contact, type DegenerateReport, type DistanceFieldDesc, type DragOptions, type DragSession, type EditOp, type EditRef, type EditResult, FastMeshError, type FastMeshErrorCode, type FieldHandle, type FieldStatus, type FillReport, type FilledLoop, type FindContactsOptions, type Indices, type InitInput, type LoopId, type Mat3, type MeshChange, type MeshComponent, type MeshDistance, type MeshHandle, type MeshViews, type OrientReport, type OutOfRange, type Placement, type PlacementInput, type Positions, type Positions64, type Quat, type Range, type RayHit, type RaycastOptions, type RemoveReport, type RepairOp, type RepairReport, type RepairReportOf, type Rgba, Scene, type SceneLike, type SceneOptions, type SectionContour, type SectionDesc, type SectionGap, type SectionHandle, type SectionPlane, type SectionResult, type SignMode, type UpdateMode, type Vec3, type WeldReport, computeBounds, computeVertexNormals };
11
+ export { type AddMeshOptions, type Analysis, type AnalyzeOptions, type BoundaryLoop, type Bounds, type BridgeReport, type ClosestHit, type ClosestPointOptions, type ColorRule, type Colormap, type Contact, type DegenerateReport, type DistanceFieldDesc, type DragOptions, type DragSession, type EditOp, type EditRef, type EditResult, FastMeshError, type FastMeshErrorCode, type FieldHandle, type FieldStatus, type FillReport, type FilledLoop, type FindContactsOptions, type Indices, type InflateReport, type InitInput, type JoinOptions, type JoinReport, type LoopId, type Mat3, type MeshChange, type MeshComponent, type MeshDistance, type MeshHandle, type MeshViews, type OrientReport, type OutOfRange, type Placement, type PlacementInput, type Positions, type Positions64, type Quat, type Range, type RayHit, type RaycastOptions, type RemeshReport, type RemoveReport, type RepairOp, type RepairReport, type RepairReportOf, type Rgba, Scene, type SceneLike, type SceneOptions, type SectionContour, type SectionDesc, type SectionGap, type SectionHandle, type SectionPlane, type SectionResult, type SignMode, type SmoothReport, type UpdateMode, type Vec3, type WeldReport, computeBounds, computeVertexNormals };
package/dist/node.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { t as FastMeshError } from "./core-Cke_kZ2e.js";
2
2
  import { n as computeVertexNormals, r as markInitialized, t as computeBounds } from "./api-BUy7FRx7.js";
3
- import { t as Scene } from "./scene-D6m9XM3O.js";
3
+ import { t as Scene } from "./scene-DyYdEQdy.js";
4
4
  import { initSync } from "./wasm/fast_mesh_wasm.js";
5
5
  import { readFileSync } from "node:fs";
6
6
  //#region src/node.ts
@@ -5,10 +5,11 @@ function isInit(data) {
5
5
  }
6
6
  /**
7
7
  * The key of a request: its own `key`, or a default naming what it targets
8
- * (`mesh:<id>` for add and remove, `edit:<id>` for edits, repairs and
9
- * compaction, `field:<id>`, `section:<id>` for section add and remove,
10
- * `section:<id>:<aspects>` for a section `set`, such as `section:3:plane` or
11
- * `section:3:plane+fill`, `history`). Queries have none.
8
+ * (`mesh:<id>` for add and remove, `edit:<id>` for edits, repairs,
9
+ * compaction and joins (the join's target), `field:<id>`,
10
+ * `section:<id>` for section add and remove, `section:<id>:<aspects>` for
11
+ * a section `set`, such as `section:3:plane` or `section:3:plane+fill`,
12
+ * `history`). Queries have none.
12
13
  */
13
14
  function keyOf(req) {
14
15
  if ("key" in req && req.key !== void 0) return req.key;
@@ -18,6 +19,7 @@ function keyOf(req) {
18
19
  case "compact":
19
20
  case "edit":
20
21
  case "repair": return `edit:${req.id}`;
22
+ case "join": return `edit:${req.target}`;
21
23
  case "undo":
22
24
  case "redo":
23
25
  case "clearHistory": return "history";
@@ -1,4 +1,4 @@
1
- import { B as SectionPlane, V as SectionResult, c as ColorRule, f as DistanceFieldDesc, n as AddMeshOptions, q as Range } from "./scene-like-DJKQP5uf.js";
1
+ import { $ as Range, G as SectionPlane, K as SectionResult, l as ColorRule, n as AddMeshOptions, p as DistanceFieldDesc } from "./scene-like-YcY08oii.js";
2
2
  //#region src/worker/protocol.d.ts
3
3
  /** A mesh, field or section id allocated on the main side. Unique per kind. */
4
4
  type ClientId = number;
@@ -77,6 +77,16 @@ type Request = {
77
77
  /** When set, the result (an `EditResult` or the repair report(s)) is replied under it. */
78
78
  qid?: number;
79
79
  key?: string;
80
+ } | {
81
+ kind: "join";
82
+ rev: number;
83
+ target: ClientId;
84
+ source: ClientId;
85
+ /** `JoinOptions`. */
86
+ payload: unknown;
87
+ /** When set, the `JoinReport` is replied under it. */
88
+ qid?: number;
89
+ key?: string;
80
90
  } | {
81
91
  kind: "undo" | "redo";
82
92
  rev: number;
package/dist/r3f.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { G as MeshHandle } from "./scene-like-DJKQP5uf.js";
2
- import { t as SceneStore } from "./store-QWRDXlAn.js";
3
- import { n as BoundMesh, t as BindMeshOptions } from "./mesh-BUVxv3jo.js";
1
+ import { Z as MeshHandle } from "./scene-like-YcY08oii.js";
2
+ import { t as SceneStore } from "./store-C5nzCpxy.js";
3
+ import { n as BoundMesh, t as BindMeshOptions } from "./mesh-RtPVmPQy.js";
4
4
  import * as THREE from "three";
5
5
  import { JSX } from "react";
6
6
  import { EventHandlers } from "@react-three/fiber";
package/dist/r3f.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { t as FastMeshError } from "./core-Cke_kZ2e.js";
2
2
  import { t as bindMesh } from "./mesh-zj7-wJBw.js";
3
3
  import { s as meshState } from "./snapshot-Cf6NgDl7.js";
4
- import { r as setFrameLoop } from "./store-Ml3TQGsR.js";
4
+ import { r as setFrameLoop } from "./store-Z6A2HPih.js";
5
5
  import { c as useStoreSelector, i as useScene, l as StoreContext, t as SceneProvider } from "./react-CTADh3NN.js";
6
6
  import * as THREE from "three";
7
7
  import { createElement, useCallback, useContext, useLayoutEffect, useRef, useState } from "react";
package/dist/react.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { G as MeshHandle, K as SectionHandle } from "./scene-like-DJKQP5uf.js";
1
+ import { Q as SectionHandle, Z as MeshHandle } from "./scene-like-YcY08oii.js";
2
2
  import { t as FastMeshError } from "./core-D2X9GPfK.js";
3
- import { a as DisplayState, c as MeshState, d as SceneSnapshot, n as SectionPatch, p as SectionState, t as SceneStore } from "./store-QWRDXlAn.js";
3
+ import { a as DisplayState, c as MeshState, d as SceneSnapshot, n as SectionPatch, p as SectionState, t as SceneStore } from "./store-C5nzCpxy.js";
4
4
  import { ReactElement, ReactNode } from "react";
5
5
  //#region src/react/index.d.ts
6
6
  /** Provides `store` to the hooks below it. */
@@ -202,7 +202,15 @@ const REPAIR_CODES = {
202
202
  removeDegenerate: 1,
203
203
  removeSmallComponents: 2,
204
204
  orient: 3,
205
- fillHoles: 4
205
+ fillHoles: 4,
206
+ inflate: 5,
207
+ smooth: 6,
208
+ remesh: 7,
209
+ bridgeLoops: 8
210
+ };
211
+ const FALLOFF_CODES = {
212
+ linear: 0,
213
+ smooth: 1
206
214
  };
207
215
  /** An optional number for the binding: NaN when unset; an explicit NaN is rejected. */
208
216
  function optional(v, what) {
@@ -213,6 +221,16 @@ function optional(v, what) {
213
221
  function flagOf(v, fallback) {
214
222
  return v ?? fallback ? 1 : 0;
215
223
  }
224
+ /** A brush center as 3 values; anything else is `INVALID_ARGUMENT`. */
225
+ function centerOf(center, values) {
226
+ const c = center;
227
+ if (c?.length !== 3 || ![
228
+ c[0],
229
+ c[1],
230
+ c[2]
231
+ ].every(Number.isFinite)) throw invalid("center must be 3 finite numbers");
232
+ values.push(c[0], c[1], c[2]);
233
+ }
216
234
  /** A loop id as the binding's `minVertex, len, hash low, hash high`. */
217
235
  function encodeLoopId(id, out) {
218
236
  const { minVertex, len, hash } = id ?? {};
@@ -247,6 +265,22 @@ function encodeRepair(ops) {
247
265
  values.push(optional(o.maxEdges, "maxEdges"), optional(o.maxPerimeter, "maxPerimeter"), optional(o.maxArea, "maxArea"), count, flagOf(o.allowUnclean, false), flagOf(o.fair, true), optional(o.dpLimit, "dpLimit"), optional(o.maxDihedral, "maxDihedral"), optional(o.maxRefineVertices, "maxRefineVertices"));
248
266
  break;
249
267
  }
268
+ case "inflate":
269
+ centerOf(o.center, values);
270
+ values.push(optional(o.radius, "radius"), codeIn(FALLOFF_CODES, o.falloff, "falloff"), optional(o.strength, "strength"));
271
+ break;
272
+ case "smooth":
273
+ centerOf(o.center, values);
274
+ values.push(optional(o.radius, "radius"), codeIn(FALLOFF_CODES, o.falloff, "falloff"), optional(o.strength, "strength"), optional(o.cycles, "cycles"));
275
+ break;
276
+ case "remesh":
277
+ centerOf(o.center, values);
278
+ values.push(optional(o.radius, "radius"), optional(o.targetLength, "targetLength"), optional(o.maxRounds, "maxRounds"));
279
+ break;
280
+ case "bridgeLoops":
281
+ if (!Array.isArray(o.loops) || o.loops.length !== 2) throw invalid("loops must be an array of two loop ids");
282
+ values.push(optional(o.maxEdges, "maxEdges"));
283
+ for (const id of o.loops) encodeLoopId(id, loops);
250
284
  }
251
285
  }
252
286
  return {
@@ -343,6 +377,21 @@ function decodeReport(op, r) {
343
377
  reason: FAIL_REASONS[r.next()]
344
378
  }))
345
379
  };
380
+ case "inflate": return {
381
+ moved: r.next(),
382
+ maxDisplacement: r.next()
383
+ };
384
+ case "smooth": return {
385
+ moved: r.next(),
386
+ maxDisplacement: r.next()
387
+ };
388
+ case "remesh": return {
389
+ splits: r.next(),
390
+ collapses: r.next(),
391
+ flips: r.next(),
392
+ rounds: r.next()
393
+ };
394
+ case "bridgeLoops": return { trianglesAdded: r.next() };
346
395
  }
347
396
  }
348
397
  /** An analysis result; see `encode_analysis` in the Rust crate. */
@@ -565,6 +614,35 @@ var Scene = class {
565
614
  this.#removed.set(key, mesh);
566
615
  }
567
616
  /**
617
+ * Joins `source` into `target`: copies the source's geometry into the
618
+ * target (keeping its world shape), bridges `options.loopA` to the copied
619
+ * `options.loopB`, and removes the source. The copy and the bridge undo as
620
+ * one step; the removal is permanent. A drag of the source ends first,
621
+ * recording its moves as one step, so they survive a failed join.
622
+ *
623
+ * @throws `UNKNOWN_MESH` for a removed handle; `INVALID_ARGUMENT` for one
624
+ * mesh twice or loops that cannot bridge; `STALE_LOOPS` for a loop that is
625
+ * not there. A failed join changes nothing.
626
+ */
627
+ join(target, source, options) {
628
+ const ta = this.#id(target);
629
+ const sb = this.#id(source);
630
+ const loops = [];
631
+ encodeLoopId(options.loopA, loops);
632
+ encodeLoopId(options.loopB, loops);
633
+ const maxEdges = optional(options.maxEdges, "maxEdges");
634
+ if (this.#drag?.mesh === source) this.#drag.end();
635
+ const r = call(() => this.#scene().join(ta.index, ta.generation, sb.index, sb.generation, Uint32Array.from(loops), maxEdges));
636
+ const key = `${sb.index}:${sb.generation}`;
637
+ this.#meshes.delete(key);
638
+ this.#removed.set(key, source);
639
+ return {
640
+ verticesAdded: r[0],
641
+ trianglesAdded: r[1],
642
+ bridgeTrianglesAdded: r[2]
643
+ };
644
+ }
645
+ /**
568
646
  * Sets a mesh's placement: world = rotation · local + translation, where
569
647
  * local is relative to the mesh origin. A quaternion is normalised and
570
648
  * converted in double precision.
@@ -573,6 +573,39 @@ type RepairOp = {
573
573
  maxDihedral?: number;
574
574
  /** Stop refining a patch once it has this many new vertices. */
575
575
  maxRefineVertices?: number;
576
+ } | {
577
+ op: "inflate";
578
+ /** Brush center in local mesh coordinates, as in `views(mesh).positions()`. */
579
+ center: Readonly<Vec3>;
580
+ radius: number;
581
+ falloff: "linear" | "smooth";
582
+ /** Displacement scale; negative pulls instead of pushing. */
583
+ strength: number;
584
+ } | {
585
+ op: "smooth";
586
+ /** Brush center in local mesh coordinates, as in `views(mesh).positions()`. */
587
+ center: Readonly<Vec3>;
588
+ radius: number;
589
+ falloff: "linear" | "smooth";
590
+ /** Displacement scale; the per-vertex weight is `strength * falloff`. */
591
+ strength: number;
592
+ /** How many Taubin λ/μ cycles to run; 0 moves nothing. */
593
+ cycles: number;
594
+ } | {
595
+ op: "remesh";
596
+ /** Region center in local mesh coordinates, as in `views(mesh).positions()`. */
597
+ center: Readonly<Vec3>;
598
+ radius: number;
599
+ /** Target edge length; unset means the mesh-wide mean edge length. */
600
+ targetLength?: number;
601
+ /** Maximum split/collapse/flip rounds; unset means the default (10). */
602
+ maxRounds?: number;
603
+ } | {
604
+ op: "bridgeLoops";
605
+ /** The two loops to connect, from `analyze(mesh).loops`. Order is insignificant. */
606
+ loops: readonly [LoopId, LoopId];
607
+ /** Maximum vertices per loop; unset means the default (128). */
608
+ maxEdges?: number;
576
609
  };
577
610
  /** What `weld` did. */
578
611
  interface WeldReport {
@@ -625,8 +658,47 @@ interface FillReport {
625
658
  reason: "projectionFolds" | "noValidTriangulation" | "solver";
626
659
  }[];
627
660
  }
661
+ /** What `inflate` did. */
662
+ interface InflateReport {
663
+ moved: number;
664
+ maxDisplacement: number;
665
+ }
666
+ /** What `smooth` did. */
667
+ interface SmoothReport {
668
+ moved: number;
669
+ maxDisplacement: number;
670
+ }
671
+ /** What `remesh` did. */
672
+ interface RemeshReport {
673
+ splits: number;
674
+ collapses: number;
675
+ flips: number;
676
+ rounds: number;
677
+ }
678
+ /** What `bridgeLoops` did. */
679
+ interface BridgeReport {
680
+ trianglesAdded: number;
681
+ }
682
+ /** Options of {@link Scene.join}. */
683
+ interface JoinOptions {
684
+ /** The loop on the target, from `analyze(target).loops`. */
685
+ loopA: LoopId;
686
+ /** The loop on the source, from `analyze(source).loops`. */
687
+ loopB: LoopId;
688
+ /** Maximum vertices per loop; unset means the default (128). */
689
+ maxEdges?: number;
690
+ }
691
+ /** What {@link Scene.join} did. */
692
+ interface JoinReport {
693
+ /** Source vertices copied into the target. */
694
+ verticesAdded: number;
695
+ /** Source triangles copied into the target. */
696
+ trianglesAdded: number;
697
+ /** Bridge triangles between the two loops. */
698
+ bridgeTrianglesAdded: number;
699
+ }
628
700
  /** The report of a {@link RepairOp}. */
629
- type RepairReport = WeldReport | DegenerateReport | RemoveReport | OrientReport | FillReport;
701
+ type RepairReport = WeldReport | DegenerateReport | RemoveReport | OrientReport | FillReport | InflateReport | SmoothReport | RemeshReport | BridgeReport;
630
702
  /** The report type of a repair op. */
631
703
  type RepairReportOf<O extends RepairOp> = O extends {
632
704
  op: "weld";
@@ -638,7 +710,15 @@ type RepairReportOf<O extends RepairOp> = O extends {
638
710
  op: "orient";
639
711
  } ? OrientReport : O extends {
640
712
  op: "fillHoles";
641
- } ? FillReport : RepairReport;
713
+ } ? FillReport : O extends {
714
+ op: "inflate";
715
+ } ? InflateReport : O extends {
716
+ op: "smooth";
717
+ } ? SmoothReport : O extends {
718
+ op: "remesh";
719
+ } ? RemeshReport : O extends {
720
+ op: "bridgeLoops";
721
+ } ? BridgeReport : RepairReport;
642
722
  /**
643
723
  * A scene of editable meshes. Create it after `await init()`; release it with
644
724
  * {@link Scene.free} or a `using` declaration (otherwise it is freed when
@@ -671,6 +751,18 @@ declare class Scene implements SceneLike {
671
751
  * (the drag's included) are then dropped with it.
672
752
  */
673
753
  removeMesh(mesh: MeshHandle): void;
754
+ /**
755
+ * Joins `source` into `target`: copies the source's geometry into the
756
+ * target (keeping its world shape), bridges `options.loopA` to the copied
757
+ * `options.loopB`, and removes the source. The copy and the bridge undo as
758
+ * one step; the removal is permanent. A drag of the source ends first,
759
+ * recording its moves as one step, so they survive a failed join.
760
+ *
761
+ * @throws `UNKNOWN_MESH` for a removed handle; `INVALID_ARGUMENT` for one
762
+ * mesh twice or loops that cannot bridge; `STALE_LOOPS` for a loop that is
763
+ * not there. A failed join changes nothing.
764
+ */
765
+ join(target: MeshHandle, source: MeshHandle, options: JoinOptions): JoinReport;
674
766
  /**
675
767
  * Sets a mesh's placement: world = rotation · local + translation, where
676
768
  * local is relative to the mesh origin. A quaternion is normalised and
@@ -963,4 +1055,4 @@ interface SceneLike {
963
1055
  bounds?(mesh: MeshHandle): Bounds | null;
964
1056
  }
965
1057
  //#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 };
1058
+ export { Range as $, OrientReport as A, Scene as B, InflateReport as C, MeshChange as D, LoopId as E, RemoveReport as F, SectionPlane as G, SectionContour as H, RepairOp as I, SmoothReport as J, SectionResult as K, RepairReport as L, RayHit as M, RaycastOptions as N, MeshComponent as O, RemeshReport as P, SectionHandle as Q, RepairReportOf as R, FindContactsOptions as S, JoinReport as T, SectionDesc as U, SceneOptions as V, SectionGap as W, FieldHandle as X, WeldReport as Y, MeshHandle as Z, EditRef as _, BoundaryLoop as a, Placement as at, FillReport as b, ClosestPointOptions as c, Positions64 as ct, Contact as d, Vec3 as dt, MeshViews as et, DegenerateReport as f, computeBounds as ft, EditOp as g, DragSession as h, AnalyzeOptions as i, Mat3 as it, OutOfRange as j, MeshDistance as k, ColorRule as l, Quat as lt, DragOptions as m, AddMeshOptions as n, Indices as nt, BridgeReport as o, PlacementInput as ot, DistanceFieldDesc as p, computeVertexNormals as pt, SignMode as q, Analysis as r, InitInput as rt, ClosestHit as s, Positions as st, SceneLike as t, Bounds as tt, Colormap as u, UpdateMode as ut, EditResult as v, JoinOptions as w, FilledLoop as x, FieldStatus as y, Rgba as z };
@@ -1,6 +1,6 @@
1
- import { B as SectionPlane, C as MeshChange, D as OutOfRange, F as Scene, G as MeshHandle, H as SignMode, K as SectionHandle, M as RepairReport, P as Rgba, R as SectionDesc, X as Indices, _ as EditResult, et as PlacementInput, h as EditOp, j as RepairOp, l as Colormap, m as DragSession, n as AddMeshOptions, nt as Positions64, t as SceneLike } from "./scene-like-DJKQP5uf.js";
1
+ import { B as Scene, D as MeshChange, G as SectionPlane, I as RepairOp, L as RepairReport, Q as SectionHandle, U as SectionDesc, Z as MeshHandle, ct as Positions64, g as EditOp, h as DragSession, j as OutOfRange, n as AddMeshOptions, nt as Indices, ot as PlacementInput, q as SignMode, t as SceneLike, u as Colormap, v as EditResult, z as Rgba } from "./scene-like-YcY08oii.js";
2
2
  import { t as FastMeshError } from "./core-D2X9GPfK.js";
3
- import { r as WorkerScene } from "./client-D-O5-tAg.js";
3
+ import { r as WorkerScene } from "./client-pv0Fwvl4.js";
4
4
  //#region src/store/host.d.ts
5
5
  /** Options of `SceneStore.addMesh`: those both scenes take (a store mesh is always eager). */
6
6
  type StoreAddMeshOptions = Pick<AddMeshOptions, "origin" | "normals">;
@@ -1,7 +1,7 @@
1
1
  import { o as reportListenerError, t as FastMeshError } from "./core-Cke_kZ2e.js";
2
2
  import { l as targetsOf } from "./views-Dh3aWc2q.js";
3
- import { i as sectionAspects } from "./protocol-CAUYm1gd.js";
4
- import { i as watchStatusKeys, n as addFieldKeyed } from "./client-Bpjy-eFY.js";
3
+ import { i as sectionAspects } from "./protocol-DkhGNP0h.js";
4
+ import { i as watchStatusKeys, n as addFieldKeyed } from "./client-CE6RvmvB.js";
5
5
  import { a as combine, c as sameData, n as EMPTY_SNAPSHOT, o as frozenCopy, t as DEFAULT_DISPLAY } from "./snapshot-Cf6NgDl7.js";
6
6
  //#region 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 { H as SignMode, P as Rgba } from "./scene-like-DJKQP5uf.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-QWRDXlAn.js";
1
+ import { q as SignMode, z as Rgba } from "./scene-like-YcY08oii.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-C5nzCpxy.js";
3
3
  //#region src/store/heatmap.d.ts
4
4
  /** Options of {@link contactHeatmap}. Distances are in the meshes' units. */
5
5
  interface ContactHeatmapOptions {
package/dist/store.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { t as FastMeshError } from "./core-Cke_kZ2e.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-Cf6NgDl7.js";
3
- import { n as createSceneStore, t as SceneStore } from "./store-Ml3TQGsR.js";
3
+ import { n as createSceneStore, t as SceneStore } from "./store-Z6A2HPih.js";
4
4
  //#region 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 { K as SectionHandle, t as SceneLike } from "./scene-like-DJKQP5uf.js";
2
- import { i as bindMesh, n as BoundMesh, r as MeshBinding, t as BindMeshOptions } from "./mesh-BUVxv3jo.js";
1
+ import { Q as SectionHandle, t as SceneLike } from "./scene-like-YcY08oii.js";
2
+ import { i as bindMesh, n as BoundMesh, r as MeshBinding, t as BindMeshOptions } from "./mesh-RtPVmPQy.js";
3
3
  import * as THREE from "three";
4
4
  //#region src/three/controls.d.ts
5
5
  /**
@@ -250,6 +250,14 @@ export class WasmScene {
250
250
  * Whether two meshes intersect or touch as placed.
251
251
  */
252
252
  intersects(a_index: number, a_generation: number, b_index: number, b_generation: number): boolean;
253
+ /**
254
+ * Joins mesh B into mesh A: copies B's geometry into A, bridges the two
255
+ * loops and removes B; see [`Scene::join`]. `loops` holds the two loop
256
+ * ids (`min_vertex, len, hash low, hash high` each, A's first) and
257
+ * `max_edges` is NaN for the default. Returns `[vertices_added,
258
+ * triangles_added, bridge_triangles_added]`.
259
+ */
260
+ join(a_index: number, a_generation: number, b_index: number, b_generation: number, loops: Uint32Array, max_edges: number): Float64Array;
253
261
  /**
254
262
  * The world matrix of the local render coordinates,
255
263
  * `placement · translate(origin)`, column-major (16 values).
@@ -489,6 +497,7 @@ export interface InitOutput {
489
497
  readonly wasmscene_indices_len: (a: number, b: number, c: number) => [number, number, number];
490
498
  readonly wasmscene_indices_ptr: (a: number, b: number, c: number) => [number, number, number];
491
499
  readonly wasmscene_intersects: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
500
+ readonly wasmscene_join: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
492
501
  readonly wasmscene_matrix4: (a: number, b: number, c: number) => [number, number, number, number];
493
502
  readonly wasmscene_mesh_distance: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
494
503
  readonly wasmscene_mode: (a: number, b: number, c: number) => [number, number, number];
@@ -649,6 +649,31 @@ export class WasmScene {
649
649
  }
650
650
  return ret[0] !== 0;
651
651
  }
652
+ /**
653
+ * Joins mesh B into mesh A: copies B's geometry into A, bridges the two
654
+ * loops and removes B; see [`Scene::join`]. `loops` holds the two loop
655
+ * ids (`min_vertex, len, hash low, hash high` each, A's first) and
656
+ * `max_edges` is NaN for the default. Returns `[vertices_added,
657
+ * triangles_added, bridge_triangles_added]`.
658
+ * @param {number} a_index
659
+ * @param {number} a_generation
660
+ * @param {number} b_index
661
+ * @param {number} b_generation
662
+ * @param {Uint32Array} loops
663
+ * @param {number} max_edges
664
+ * @returns {Float64Array}
665
+ */
666
+ join(a_index, a_generation, b_index, b_generation, loops, max_edges) {
667
+ const ptr0 = passArray32ToWasm0(loops, wasm.__wbindgen_malloc);
668
+ const len0 = WASM_VECTOR_LEN;
669
+ const ret = wasm.wasmscene_join(this.__wbg_ptr, a_index, a_generation, b_index, b_generation, ptr0, len0, max_edges);
670
+ if (ret[3]) {
671
+ throw takeFromExternrefTable0(ret[2]);
672
+ }
673
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
674
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
675
+ return v2;
676
+ }
652
677
  /**
653
678
  * The world matrix of the local render coordinates,
654
679
  * `placement · translate(origin)`, column-major (16 values).
Binary file
@@ -46,6 +46,7 @@ export const wasmscene_flush: (a: number) => [number, number];
46
46
  export const wasmscene_indices_len: (a: number, b: number, c: number) => [number, number, number];
47
47
  export const wasmscene_indices_ptr: (a: number, b: number, c: number) => [number, number, number];
48
48
  export const wasmscene_intersects: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
49
+ export const wasmscene_join: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
49
50
  export const wasmscene_matrix4: (a: number, b: number, c: number) => [number, number, number, number];
50
51
  export const wasmscene_mesh_distance: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
51
52
  export const wasmscene_mode: (a: number, b: number, c: number) => [number, number, number];
@@ -250,6 +250,14 @@ export class WasmScene {
250
250
  * Whether two meshes intersect or touch as placed.
251
251
  */
252
252
  intersects(a_index: number, a_generation: number, b_index: number, b_generation: number): boolean;
253
+ /**
254
+ * Joins mesh B into mesh A: copies B's geometry into A, bridges the two
255
+ * loops and removes B; see [`Scene::join`]. `loops` holds the two loop
256
+ * ids (`min_vertex, len, hash low, hash high` each, A's first) and
257
+ * `max_edges` is NaN for the default. Returns `[vertices_added,
258
+ * triangles_added, bridge_triangles_added]`.
259
+ */
260
+ join(a_index: number, a_generation: number, b_index: number, b_generation: number, loops: Uint32Array, max_edges: number): Float64Array;
253
261
  /**
254
262
  * The world matrix of the local render coordinates,
255
263
  * `placement · translate(origin)`, column-major (16 values).
@@ -512,6 +520,7 @@ export interface InitOutput {
512
520
  readonly wasmscene_indices_len: (a: number, b: number, c: number) => [number, number, number];
513
521
  readonly wasmscene_indices_ptr: (a: number, b: number, c: number) => [number, number, number];
514
522
  readonly wasmscene_intersects: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
523
+ readonly wasmscene_join: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
515
524
  readonly wasmscene_matrix4: (a: number, b: number, c: number) => [number, number, number, number];
516
525
  readonly wasmscene_mesh_distance: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
517
526
  readonly wasmscene_mode: (a: number, b: number, c: number) => [number, number, number];
@@ -652,6 +652,31 @@ export class WasmScene {
652
652
  }
653
653
  return ret[0] !== 0;
654
654
  }
655
+ /**
656
+ * Joins mesh B into mesh A: copies B's geometry into A, bridges the two
657
+ * loops and removes B; see [`Scene::join`]. `loops` holds the two loop
658
+ * ids (`min_vertex, len, hash low, hash high` each, A's first) and
659
+ * `max_edges` is NaN for the default. Returns `[vertices_added,
660
+ * triangles_added, bridge_triangles_added]`.
661
+ * @param {number} a_index
662
+ * @param {number} a_generation
663
+ * @param {number} b_index
664
+ * @param {number} b_generation
665
+ * @param {Uint32Array} loops
666
+ * @param {number} max_edges
667
+ * @returns {Float64Array}
668
+ */
669
+ join(a_index, a_generation, b_index, b_generation, loops, max_edges) {
670
+ const ptr0 = passArray32ToWasm0(loops, wasm.__wbindgen_malloc);
671
+ const len0 = WASM_VECTOR_LEN;
672
+ const ret = wasm.wasmscene_join(this.__wbg_ptr, a_index, a_generation, b_index, b_generation, ptr0, len0, max_edges);
673
+ if (ret[3]) {
674
+ throw takeFromExternrefTable0(ret[2]);
675
+ }
676
+ var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
677
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
678
+ return v2;
679
+ }
655
680
  /**
656
681
  * The world matrix of the local render coordinates,
657
682
  * `placement · translate(origin)`, column-major (16 values).
@@ -47,6 +47,7 @@ export const wasmscene_flush: (a: number) => [number, number];
47
47
  export const wasmscene_indices_len: (a: number, b: number, c: number) => [number, number, number];
48
48
  export const wasmscene_indices_ptr: (a: number, b: number, c: number) => [number, number, number];
49
49
  export const wasmscene_intersects: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
50
+ export const wasmscene_join: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number, number];
50
51
  export const wasmscene_matrix4: (a: number, b: number, c: number) => [number, number, number, number];
51
52
  export const wasmscene_mesh_distance: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
52
53
  export const wasmscene_mode: (a: number, b: number, c: number) => [number, number, number];
package/dist/web.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as Placement, A as RemoveReport, B as SectionPlane, C as MeshChange, D as OutOfRange, E as OrientReport, F as Scene, G as MeshHandle, H as SignMode, I as SceneOptions, J as MeshViews, K as SectionHandle, L as SectionContour, M as RepairReport, N as RepairReportOf, O as RayHit, P as Rgba, Q as Mat3, R as SectionDesc, S as LoopId, T as MeshDistance, U as WeldReport, V as SectionResult, W as FieldHandle, X as Indices, Y as Bounds, Z as InitInput, _ as EditResult, a as BoundaryLoop, at as Vec3, b as FilledLoop, c as ColorRule, d as DegenerateReport, et as PlacementInput, f as DistanceFieldDesc, g as EditRef, h as EditOp, i as AnalyzeOptions, it as UpdateMode, j as RepairOp, k as RaycastOptions, l as Colormap, m as DragSession, n as AddMeshOptions, nt as Positions64, o as ClosestHit, ot as computeBounds, p as DragOptions, q as Range, r as Analysis, rt as Quat, s as ClosestPointOptions, st as computeVertexNormals, t as SceneLike, tt as Positions, u as Contact, v as FieldStatus, w as MeshComponent, x as FindContactsOptions, y as FillReport, z as SectionGap } from "./scene-like-DJKQP5uf.js";
1
+ import { $ as Range, A as OrientReport, B as Scene, C as InflateReport, D as MeshChange, E as LoopId, F as RemoveReport, G as SectionPlane, H as SectionContour, I as RepairOp, J as SmoothReport, K as SectionResult, L as RepairReport, M as RayHit, N as RaycastOptions, O as MeshComponent, P as RemeshReport, Q as SectionHandle, R as RepairReportOf, S as FindContactsOptions, T as JoinReport, U as SectionDesc, V as SceneOptions, W as SectionGap, X as FieldHandle, Y as WeldReport, Z as MeshHandle, _ as EditRef, a as BoundaryLoop, at as Placement, b as FillReport, c as ClosestPointOptions, ct as Positions64, d as Contact, dt as Vec3, et as MeshViews, f as DegenerateReport, ft as computeBounds, g as EditOp, h as DragSession, i as AnalyzeOptions, it as Mat3, j as OutOfRange, k as MeshDistance, l as ColorRule, lt as Quat, m as DragOptions, n as AddMeshOptions, nt as Indices, o as BridgeReport, ot as PlacementInput, p as DistanceFieldDesc, pt as computeVertexNormals, q as SignMode, r as Analysis, rt as InitInput, s as ClosestHit, st as Positions, t as SceneLike, tt as Bounds, u as Colormap, ut as UpdateMode, v as EditResult, w as JoinOptions, x as FilledLoop, y as FieldStatus, z as Rgba } from "./scene-like-YcY08oii.js";
2
2
  import { n as FastMeshErrorCode, t as FastMeshError } from "./core-D2X9GPfK.js";
3
3
  //#region src/web.d.ts
4
4
  /**
@@ -10,4 +10,4 @@ import { n as FastMeshErrorCode, t as FastMeshError } from "./core-D2X9GPfK.js";
10
10
  */
11
11
  export declare function init(input?: InitInput | Promise<InitInput>): Promise<void>;
12
12
  //#endregion
13
- export { type AddMeshOptions, type Analysis, type AnalyzeOptions, type BoundaryLoop, type Bounds, type ClosestHit, type ClosestPointOptions, type ColorRule, type Colormap, type Contact, type DegenerateReport, type DistanceFieldDesc, type DragOptions, type DragSession, type EditOp, type EditRef, type EditResult, FastMeshError, type FastMeshErrorCode, type FieldHandle, type FieldStatus, type FillReport, type FilledLoop, type FindContactsOptions, type Indices, type InitInput, type LoopId, type Mat3, type MeshChange, type MeshComponent, type MeshDistance, type MeshHandle, type MeshViews, type OrientReport, type OutOfRange, type Placement, type PlacementInput, type Positions, type Positions64, type Quat, type Range, type RayHit, type RaycastOptions, type RemoveReport, type RepairOp, type RepairReport, type RepairReportOf, type Rgba, Scene, type SceneLike, type SceneOptions, type SectionContour, type SectionDesc, type SectionGap, type SectionHandle, type SectionPlane, type SectionResult, type SignMode, type UpdateMode, type Vec3, type WeldReport, computeBounds, computeVertexNormals };
13
+ export { type AddMeshOptions, type Analysis, type AnalyzeOptions, type BoundaryLoop, type Bounds, type BridgeReport, type ClosestHit, type ClosestPointOptions, type ColorRule, type Colormap, type Contact, type DegenerateReport, type DistanceFieldDesc, type DragOptions, type DragSession, type EditOp, type EditRef, type EditResult, FastMeshError, type FastMeshErrorCode, type FieldHandle, type FieldStatus, type FillReport, type FilledLoop, type FindContactsOptions, type Indices, type InflateReport, type InitInput, type JoinOptions, type JoinReport, type LoopId, type Mat3, type MeshChange, type MeshComponent, type MeshDistance, type MeshHandle, type MeshViews, type OrientReport, type OutOfRange, type Placement, type PlacementInput, type Positions, type Positions64, type Quat, type Range, type RayHit, type RaycastOptions, type RemeshReport, type RemoveReport, type RepairOp, type RepairReport, type RepairReportOf, type Rgba, Scene, type SceneLike, type SceneOptions, type SectionContour, type SectionDesc, type SectionGap, type SectionHandle, type SectionPlane, type SectionResult, type SignMode, type SmoothReport, type UpdateMode, type Vec3, type WeldReport, computeBounds, computeVertexNormals };
package/dist/web.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { t as FastMeshError } from "./core-Cke_kZ2e.js";
2
2
  import { n as computeVertexNormals, r as markInitialized, t as computeBounds } from "./api-BUy7FRx7.js";
3
- import { t as Scene } from "./scene-D6m9XM3O.js";
3
+ import { t as Scene } from "./scene-DyYdEQdy.js";
4
4
  import wasmInit from "./wasm/fast_mesh_wasm.js";
5
5
  //#region src/web.ts
6
6
  let ready;
@@ -1,4 +1,4 @@
1
- import { a as WorkerMessage, i as Result, n as InitMessage, r as Request, t as ClientId } from "./protocol-CK6_3aqo.js";
1
+ import { a as WorkerMessage, i as Result, n as InitMessage, r as Request, t as ClientId } from "./protocol-z-jeCUGO.js";
2
2
  import { WasmScene } from "./wasm/fast_mesh_wasm.js";
3
3
  //#region src/worker/load.d.ts
4
4
  /** What the engine needs of a wasm-bindgen glue module. */
@@ -1 +1 @@
1
- export { t as ADD_STEP_WORK, n as BACKGROUND_ADD_TRIANGLES, r as STALE_GUARD_MS, i as STEP_POINTS, a as YIELD_MS, c as loadEngine, u as probeSharedGrowth, o as runEngine, s as serveEngine, l as startEngine } from "./engine-D6MpGb9i.js";
1
+ export { t as ADD_STEP_WORK, n as BACKGROUND_ADD_TRIANGLES, r as STALE_GUARD_MS, i as STEP_POINTS, a as YIELD_MS, c as loadEngine, u as probeSharedGrowth, o as runEngine, s as serveEngine, l as startEngine } from "./engine-DLQAL9GT.js";
@@ -1,4 +1,4 @@
1
- import { l as startEngine, s as serveEngine } from "./engine-D6MpGb9i.js";
1
+ import { l as startEngine, s as serveEngine } from "./engine-DLQAL9GT.js";
2
2
  //#region src/worker/entry.ts
3
3
  const scope = globalThis;
4
4
  serveEngine({
package/dist/worker.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as createWorkerScene, i as WorkerSceneOptions, n as WorkerLike, r as WorkerScene, t as KeyStatus } from "./client-D-O5-tAg.js";
1
+ import { a as createWorkerScene, i as WorkerSceneOptions, n as WorkerLike, r as WorkerScene, t as KeyStatus } from "./client-pv0Fwvl4.js";
2
2
  export { type KeyStatus, type WorkerLike, WorkerScene, type WorkerSceneOptions, createWorkerScene };
package/dist/worker.js CHANGED
@@ -1 +1 @@
1
- export { t as WorkerScene, r as createWorkerScene } from "./client-Bpjy-eFY.js";
1
+ export { t as WorkerScene, r as createWorkerScene } from "./client-CE6RvmvB.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fast-mesh-wasm",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Fast triangle mesh utilities for JavaScript, written in Rust and compiled to WebAssembly",
5
5
  "keywords": [
6
6
  "mesh",