fast-mesh-wasm 0.4.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +51 -3
  2. package/dist/{api-BUy7FRx7.js → api-4kz45-Mq.js} +2 -3
  3. package/dist/{client-Bpjy-eFY.js → client-C61Kku4i.js} +102 -24
  4. package/dist/{client-D-O5-tAg.d.ts → client-tP6R9foI.d.ts} +19 -8
  5. package/dist/{colormap-DxGMYVfs.js → colormap-Dr5V3bvs.js} +1 -2
  6. package/dist/{core-Cke_kZ2e.js → core-4OcWKu3r.js} +2 -2
  7. package/dist/{core-D2X9GPfK.d.ts → core-CJ9D6U5A.d.ts} +1 -3
  8. package/dist/{engine-D6MpGb9i.js → engine-X1Awlc5y.js} +58 -28
  9. package/dist/io.d.ts +294 -0
  10. package/dist/io.js +1395 -0
  11. package/dist/{mesh-zj7-wJBw.js → mesh-CWvrjO8S.js} +3 -4
  12. package/dist/{mesh-BUVxv3jo.d.ts → mesh-D3fv56nF.d.ts} +1 -3
  13. package/dist/node.d.ts +3 -5
  14. package/dist/node.js +4 -5
  15. package/dist/{protocol-CK6_3aqo.d.ts → protocol-BGQAB0op.d.ts} +16 -3
  16. package/dist/{protocol-CAUYm1gd.js → protocol-Ci9LLiwO.js} +7 -6
  17. package/dist/r3f.d.ts +22 -6
  18. package/dist/r3f.js +28 -19
  19. package/dist/{react-CTADh3NN.js → react-DzrtrzZy.js} +4 -6
  20. package/dist/react.d.ts +4 -6
  21. package/dist/react.js +1 -1
  22. package/dist/{scene-D6m9XM3O.js → scene-BnkCS0sv.js} +668 -14
  23. package/dist/{scene-like-DJKQP5uf.d.ts → scene-like-BzkDNHCy.d.ts} +502 -42
  24. package/dist/{snapshot-Cf6NgDl7.js → snapshot-BkbGPspK.js} +1 -2
  25. package/dist/{store-QWRDXlAn.d.ts → store-BKFzSykN.d.ts} +3 -9
  26. package/dist/{store-Ml3TQGsR.js → store-CEd2y2KS.js} +7 -9
  27. package/dist/store.d.ts +2 -4
  28. package/dist/store.js +4 -5
  29. package/dist/three.d.ts +2 -6
  30. package/dist/three.js +4 -6
  31. package/dist/{views-Dh3aWc2q.js → views-CUBMOK0U.js} +5 -8
  32. package/dist/wasm/fast_mesh_wasm.d.ts +86 -6
  33. package/dist/wasm/fast_mesh_wasm.js +192 -6
  34. package/dist/wasm/fast_mesh_wasm_bg.wasm +0 -0
  35. package/dist/wasm/fast_mesh_wasm_bg.wasm.d.ts +9 -1
  36. package/dist/wasm-threads/fast_mesh_wasm.d.ts +86 -6
  37. package/dist/wasm-threads/fast_mesh_wasm.js +192 -6
  38. package/dist/wasm-threads/fast_mesh_wasm_bg.wasm +0 -0
  39. package/dist/wasm-threads/fast_mesh_wasm_bg.wasm.d.ts +9 -1
  40. package/dist/web.d.ts +3 -5
  41. package/dist/web.js +4 -5
  42. package/dist/worker-engine.d.ts +1 -7
  43. package/dist/worker-engine.js +1 -1
  44. package/dist/worker-entry.js +2 -3
  45. package/dist/worker.d.ts +2 -2
  46. package/dist/worker.js +1 -1
  47. package/package.json +16 -4
@@ -1,7 +1,7 @@
1
- import { t as FastMeshError } from "./core-Cke_kZ2e.js";
2
- import { a as SRGB_TO_LINEAR16, i as SHADING_VERTEX, o as encodeValues, r as SHADING_FRAGMENT, s as shadingOf } from "./colormap-DxGMYVfs.js";
1
+ import { a as SRGB_TO_LINEAR16, i as SHADING_VERTEX, o as encodeValues, r as SHADING_FRAGMENT, s as shadingOf } from "./colormap-Dr5V3bvs.js";
2
+ import { t as FastMeshError } from "./core-4OcWKu3r.js";
3
3
  import * as THREE from "three";
4
- //#region src/three/mesh.ts
4
+ // src/three/mesh.ts
5
5
  const DEFAULT_COLOR = 13421772;
6
6
  const WHITE = new THREE.Color(16777215);
7
7
  /**
@@ -471,5 +471,4 @@ function patchMaterial(material, uniforms) {
471
471
  material.needsUpdate = true;
472
472
  };
473
473
  }
474
- //#endregion
475
474
  export { checkUntransformedParent as n, bindMesh as t };
@@ -1,6 +1,5 @@
1
- import { G as MeshHandle, t as SceneLike } from "./scene-like-DJKQP5uf.js";
1
+ import { _t as MeshHandle, t as SceneLike } from "./scene-like-BzkDNHCy.js";
2
2
  import * as THREE from "three";
3
- //#region src/three/mesh.d.ts
4
3
  /** Options of {@link bindMesh}. */
5
4
  interface BindMeshOptions {
6
5
  /**
@@ -133,5 +132,4 @@ type MeshBinding = Pick<BoundMesh, "mesh" | "object">;
133
132
  * `scene.commitFrame()` once per animation frame, before rendering.
134
133
  */
135
134
  declare function bindMesh(scene: SceneLike, mesh: MeshHandle, options?: BindMeshOptions): BoundMesh;
136
- //#endregion
137
135
  export { bindMesh as i, BoundMesh as n, MeshBinding as r, BindMeshOptions as t };
package/dist/node.d.ts CHANGED
@@ -1,11 +1,9 @@
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";
2
- import { n as FastMeshErrorCode, t as FastMeshError } from "./core-D2X9GPfK.js";
3
- //#region src/node.d.ts
1
+ import { $ as SectionPlane, A as JoinReport, At as computeBounds, B as RaycastOptions, C as FieldStatus, Ct as Placement, D as GrabReport, Dt as Quat, E as FindContactsOptions, Et as Positions64, F as MeshDistance, G as RepairReport, H as RemeshReport, I as OffsetReport, J as Scene, K as RepairReportOf, L as OrientReport, M as MeasureResult, N as MeshChange, O as InflateReport, Ot as UpdateMode, P as MeshComponent, Q as SectionGap, R as OutOfRange, S as EditResult, St as Mat3, T as FilledLoop, Tt as Positions, U as RemoveReport, V as RelaxReport, W as RepairOp, X as SectionContour, Y as SceneOptions, Z as SectionDesc, _ as DistanceFieldDesc, _t as MeshHandle, a as BooleanOp, at as SubdivideReport, b as EditOp, bt as Indices, c as ClosestHit, ct as BrushSelect, d as Colormap, dt as LassoSelect, et as SectionResult, f as Contact, ft as SelectSpec, g as DegenerateReport, gt as FieldHandle, h as CutReport, ht as MeshViews, i as AnalyzeOptions, it as SmoothReport, j as LoopId, jt as computeVertexNormals, k as JoinOptions, kt as Vec3, l as ClosestPointOptions, lt as ComponentSelect, m as CutOptions, mt as Range, n as AddMeshOptions, nt as SignMode, o as BoundaryLoop, ot as ThicknessFieldDesc, p as CurvatureFieldDesc, pt as VertexSelection, q as Rgba, r as Analysis, rt as SimplifyReport, s as BridgeReport, st as WeldReport, t as SceneLike, tt as ShellReport, u as ColorRule, ut as IsolateReport, v as DragOptions, vt as SectionHandle, w as FillReport, wt as PlacementInput, x as EditRef, xt as InitInput, y as DragSession, yt as Bounds, z as RayHit } from "./scene-like-BzkDNHCy.js";
2
+ import { n as FastMeshErrorCode, t as FastMeshError } from "./core-CJ9D6U5A.js";
4
3
  /**
5
4
  * Resolves immediately: in Node.js and Bun the module is ready as soon as it is imported.
6
5
  * Accepts the same argument as the browser `init()` so the same code runs everywhere;
7
6
  * the argument is ignored.
8
7
  */
9
8
  export declare function init(_input?: InitInput | Promise<InitInput>): Promise<void>;
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 };
9
+ export { type AddMeshOptions, type Analysis, type AnalyzeOptions, type BooleanOp, type BoundaryLoop, type Bounds, type BridgeReport, type BrushSelect, type ClosestHit, type ClosestPointOptions, type ColorRule, type Colormap, type ComponentSelect, type Contact, type CurvatureFieldDesc, type CutOptions, type CutReport, 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 GrabReport, type Indices, type InflateReport, type InitInput, type IsolateReport, type JoinOptions, type JoinReport, type LassoSelect, type LoopId, type Mat3, type MeasureResult, type MeshChange, type MeshComponent, type MeshDistance, type MeshHandle, type MeshViews, type OffsetReport, type OrientReport, type OutOfRange, type Placement, type PlacementInput, type Positions, type Positions64, type Quat, type Range, type RayHit, type RaycastOptions, type RelaxReport, 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 SelectSpec, type ShellReport, type SignMode, type SimplifyReport, type SmoothReport, type SubdivideReport, type ThicknessFieldDesc, type UpdateMode, type Vec3, type VertexSelection, type WeldReport, computeBounds, computeVertexNormals };
package/dist/node.js CHANGED
@@ -1,9 +1,9 @@
1
- import { t as FastMeshError } from "./core-Cke_kZ2e.js";
2
- import { n as computeVertexNormals, r as markInitialized, t as computeBounds } from "./api-BUy7FRx7.js";
3
- import { t as Scene } from "./scene-D6m9XM3O.js";
1
+ import { n as computeVertexNormals, r as markInitialized, t as computeBounds } from "./api-4kz45-Mq.js";
2
+ import { t as FastMeshError } from "./core-4OcWKu3r.js";
3
+ import { t as Scene } from "./scene-BnkCS0sv.js";
4
4
  import { initSync } from "./wasm/fast_mesh_wasm.js";
5
5
  import { readFileSync } from "node:fs";
6
- //#region src/node.ts
6
+ // src/node.ts
7
7
  markInitialized(initSync({ module: readFileSync(new URL("./wasm/fast_mesh_wasm_bg.wasm", import.meta.url)) }));
8
8
  /**
9
9
  * Resolves immediately: in Node.js and Bun the module is ready as soon as it is imported.
@@ -13,5 +13,4 @@ markInitialized(initSync({ module: readFileSync(new URL("./wasm/fast_mesh_wasm_b
13
13
  function init(_input) {
14
14
  return Promise.resolve();
15
15
  }
16
- //#endregion
17
16
  export { FastMeshError, Scene, computeBounds, computeVertexNormals, init };
@@ -1,5 +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";
2
- //#region src/worker/protocol.d.ts
1
+ import { $ as SectionPlane, _ as DistanceFieldDesc, et as SectionResult, mt as Range, n as AddMeshOptions, u as ColorRule } from "./scene-like-BzkDNHCy.js";
3
2
  /** A mesh, field or section id allocated on the main side. Unique per kind. */
4
3
  type ClientId = number;
5
4
  /** A {@link ColorRule} naming its field by client id. */
@@ -58,6 +57,8 @@ type Request = {
58
57
  id: ClientId;
59
58
  rotation: number[];
60
59
  translation: number[];
60
+ /** Per-axis scale, 3 numbers; `[1, 1, 1]` when omitted. */
61
+ scale?: number[];
61
62
  key: string;
62
63
  } | {
63
64
  kind: "drag";
@@ -67,6 +68,8 @@ type Request = {
67
68
  /** For `move`, and optionally `end` (a last move before ending). */
68
69
  rotation?: number[];
69
70
  translation?: number[];
71
+ /** The move's per-axis scale, 3 numbers; `[1, 1, 1]` when omitted. */
72
+ scale?: number[];
70
73
  key: string;
71
74
  } | {
72
75
  kind: "edit" | "repair";
@@ -77,6 +80,16 @@ type Request = {
77
80
  /** When set, the result (an `EditResult` or the repair report(s)) is replied under it. */
78
81
  qid?: number;
79
82
  key?: string;
83
+ } | {
84
+ kind: "join";
85
+ rev: number;
86
+ target: ClientId;
87
+ source: ClientId;
88
+ /** `JoinOptions`. */
89
+ payload: unknown;
90
+ /** When set, the `JoinReport` is replied under it. */
91
+ qid?: number;
92
+ key?: string;
80
93
  } | {
81
94
  kind: "undo" | "redo";
82
95
  rev: number;
@@ -189,6 +202,7 @@ interface Result {
189
202
  id: ClientId;
190
203
  rotation: number[];
191
204
  translation: number[];
205
+ scale: number[];
192
206
  matrix4: number[];
193
207
  }[];
194
208
  /**
@@ -289,5 +303,4 @@ type WorkerMessage = Result | {
289
303
  kind: "fatal";
290
304
  error: ErrorWire;
291
305
  };
292
- //#endregion
293
306
  export { WorkerMessage as a, Result as i, InitMessage as n, Request as r, ClientId as t };
@@ -1,14 +1,15 @@
1
- //#region src/worker/protocol.ts
1
+ // src/worker/protocol.ts
2
2
  /** Whether a message to a Worker is its {@link InitMessage} (else a batch). */
3
3
  function isInit(data) {
4
4
  return !Array.isArray(data) && data?.kind === "init";
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";
@@ -64,5 +66,4 @@ function supersedes(later, earlier) {
64
66
  default: return false;
65
67
  }
66
68
  }
67
- //#endregion
68
69
  export { supersedes as a, sectionAspects as i, isLastWins as n, keyOf as r, isInit as t };
package/dist/r3f.d.ts CHANGED
@@ -1,10 +1,9 @@
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 { _t as MeshHandle } from "./scene-like-BzkDNHCy.js";
2
+ import { t as SceneStore } from "./store-BKFzSykN.js";
3
+ import { n as BoundMesh, t as BindMeshOptions } from "./mesh-D3fv56nF.js";
4
4
  import * as THREE from "three";
5
5
  import { JSX } from "react";
6
6
  import { EventHandlers } from "@react-three/fiber";
7
- //#region src/r3f/index.d.ts
8
7
  /**
9
8
  * Calls `store.commitFrame()` once per rendered R3F frame, however many
10
9
  * components call this hook for the same store, and invalidates the canvas
@@ -34,6 +33,12 @@ export interface FastMeshProps extends EventHandlers {
34
33
  material?: BindMeshOptions["material"];
35
34
  /** The colour while the mesh has no colouring (see `BindMeshOptions.color`). */
36
35
  color?: THREE.ColorRepresentation;
36
+ /**
37
+ * A visibility override, ANDed with the store display's `visible` (unset
38
+ * shows). The store still hides the mesh while set; changing it never
39
+ * rebinds.
40
+ */
41
+ visible?: boolean;
37
42
  /**
38
43
  * How a colouring is drawn (see `BindMeshOptions.shading`): `"vertex"` (the
39
44
  * default) or `"fragment"`. Changing it rebinds the mesh.
@@ -55,5 +60,16 @@ export interface FastMeshProps extends EventHandlers {
55
60
  */
56
61
  onBind?: (bound: BoundMesh | null) => void;
57
62
  }
58
- export declare function FastMesh(props: FastMeshProps): JSX.Element;
59
- //#endregion
63
+ /**
64
+ * Draws a scene mesh: binds it with `bindMesh` on mount and disposes the
65
+ * binding on unmount (or when the mesh is removed, after which it renders
66
+ * nothing). The mesh's applied `opacity` and `visible` follow the store in
67
+ * the frame that applies them; colouring follows the scene. Drives the
68
+ * store's frames with {@link useFrameDriver}. Use it inside a `<Canvas>`.
69
+ *
70
+ * The mesh must be added through the store (`store.addMesh`): a mesh added
71
+ * straight to `store.scene` is not in the store, and renders nothing.
72
+ *
73
+ * @throws `INVALID_ARGUMENT` without a `store` outside a `SceneProvider`.
74
+ */
75
+ export declare function FastMesh(props: FastMeshProps): JSX.Element;
package/dist/r3f.js CHANGED
@@ -1,12 +1,12 @@
1
- import { t as FastMeshError } from "./core-Cke_kZ2e.js";
2
- import { t as bindMesh } from "./mesh-zj7-wJBw.js";
3
- import { s as meshState } from "./snapshot-Cf6NgDl7.js";
4
- import { r as setFrameLoop } from "./store-Ml3TQGsR.js";
5
- import { c as useStoreSelector, i as useScene, l as StoreContext, t as SceneProvider } from "./react-CTADh3NN.js";
1
+ import { t as FastMeshError } from "./core-4OcWKu3r.js";
2
+ import { c as useStoreSelector, i as useScene, l as StoreContext, t as SceneProvider } from "./react-DzrtrzZy.js";
3
+ import { s as meshState } from "./snapshot-BkbGPspK.js";
4
+ import { r as setFrameLoop } from "./store-CEd2y2KS.js";
5
+ import { t as bindMesh } from "./mesh-CWvrjO8S.js";
6
6
  import * as THREE from "three";
7
7
  import { createElement, useCallback, useContext, useLayoutEffect, useRef, useState } from "react";
8
8
  import { useFrame, useThree } from "@react-three/fiber";
9
- //#region src/r3f/index.ts
9
+ // src/r3f/index.ts
10
10
  const drivers = /* @__PURE__ */ new WeakMap();
11
11
  /**
12
12
  * Calls `store.commitFrame()` once per rendered R3F frame, however many
@@ -76,6 +76,16 @@ function useFrameDriver(store) {
76
76
  });
77
77
  }
78
78
  /**
79
+ * `width` when it is a finite number `>= 0` (what `setEdgeSoftness` takes),
80
+ * else 0 with a warning: a bad prop (a slider's NaN, say) draws hard edges
81
+ * rather than throwing inside the canvas.
82
+ */
83
+ function usableSoftness(width) {
84
+ if (typeof width === "number" && Number.isFinite(width) && width >= 0) return width;
85
+ console.warn(`fast-mesh-wasm: <FastMesh edgeSoftness={${String(width)}}> is not a finite number >= 0; using 0.`);
86
+ return 0;
87
+ }
88
+ /**
79
89
  * Draws a scene mesh: binds it with `bindMesh` on mount and disposes the
80
90
  * binding on unmount (or when the mesh is removed, after which it renders
81
91
  * nothing). The mesh's applied `opacity` and `visible` follow the store in
@@ -87,22 +97,12 @@ function useFrameDriver(store) {
87
97
  *
88
98
  * @throws `INVALID_ARGUMENT` without a `store` outside a `SceneProvider`.
89
99
  */
90
- /**
91
- * `width` when it is a finite number `>= 0` (what `setEdgeSoftness` takes),
92
- * else 0 with a warning: a bad prop (a slider's NaN, say) draws hard edges
93
- * rather than throwing inside the canvas.
94
- */
95
- function usableSoftness(width) {
96
- if (typeof width === "number" && Number.isFinite(width) && width >= 0) return width;
97
- console.warn(`fast-mesh-wasm: <FastMesh edgeSoftness={${String(width)}}> is not a finite number >= 0; using 0.`);
98
- return 0;
99
- }
100
100
  function FastMesh(props) {
101
101
  const body = createElement(FastMeshBody, props);
102
102
  return props.store === void 0 ? body : createElement(SceneProvider, { store: props.store }, body);
103
103
  }
104
104
  function FastMeshBody(props) {
105
- const { mesh, store: _store, material, color, shading, edgeSoftness = 0, onBind, ...events } = props;
105
+ const { mesh, store: _store, material, color, shading, edgeSoftness = 0, onBind, visible, ...events } = props;
106
106
  const store = useScene();
107
107
  useFrameDriver(store);
108
108
  const present = useStoreSelector(useCallback((s) => s.meshes.has(mesh), [mesh]));
@@ -110,6 +110,8 @@ function FastMeshBody(props) {
110
110
  const [bound, setBound] = useState(null);
111
111
  const onBindRef = useRef(onBind);
112
112
  onBindRef.current = onBind;
113
+ const visibleRef = useRef(visible);
114
+ visibleRef.current = visible;
113
115
  const softness = usableSoftness(edgeSoftness);
114
116
  const softnessRef = useRef(softness);
115
117
  softnessRef.current = softness;
@@ -130,7 +132,7 @@ function FastMeshBody(props) {
130
132
  if (d !== last) {
131
133
  last = d;
132
134
  b.setOpacity(d.opacity);
133
- b.object.visible = d.visible;
135
+ b.object.visible = d.visible && (visibleRef.current ?? true);
134
136
  }
135
137
  };
136
138
  apply();
@@ -154,6 +156,14 @@ function FastMeshBody(props) {
154
156
  useLayoutEffect(() => {
155
157
  bound?.setEdgeSoftness(softness);
156
158
  }, [bound, softness]);
159
+ useLayoutEffect(() => {
160
+ if (bound !== null) bound.object.visible = meshState(store.getSnapshot(), mesh).display.visible && (visible ?? true);
161
+ }, [
162
+ store,
163
+ mesh,
164
+ bound,
165
+ visible
166
+ ]);
157
167
  if (bound === null) return null;
158
168
  return createElement("primitive", {
159
169
  object: bound.object,
@@ -161,5 +171,4 @@ function FastMeshBody(props) {
161
171
  ...events
162
172
  });
163
173
  }
164
- //#endregion
165
174
  export { FastMesh, useFrameDriver };
@@ -1,11 +1,10 @@
1
- import { t as FastMeshError } from "./core-Cke_kZ2e.js";
2
- import { l as sectionState, n as EMPTY_SNAPSHOT, s as meshState } from "./snapshot-Cf6NgDl7.js";
1
+ import { t as FastMeshError } from "./core-4OcWKu3r.js";
2
+ import { l as sectionState, n as EMPTY_SNAPSHOT, s as meshState } from "./snapshot-BkbGPspK.js";
3
3
  import { createContext, createElement, useCallback, useContext, useMemo, useRef, useSyncExternalStore } from "react";
4
- //#region src/react/context.ts
4
+ // src/react/context.ts
5
5
  /** The store a `SceneProvider` provides, or `null` outside one. */
6
6
  const StoreContext = createContext(null);
7
- //#endregion
8
- //#region src/react/index.ts
7
+ // src/react/index.ts
9
8
  /** Provides `store` to the hooks below it. */
10
9
  function SceneProvider(props) {
11
10
  return createElement(StoreContext.Provider, { value: props.store }, props.children);
@@ -120,5 +119,4 @@ function useSelection() {
120
119
  const store = useScene();
121
120
  return [useStoreSelector(selectSelection), useCallback((mesh) => store.select(mesh), [store])];
122
121
  }
123
- //#endregion
124
122
  export { useSceneStatus as a, useStoreSelector as c, useScene as i, StoreContext as l, useHistory as n, useSection as o, useMeshDisplay as r, useSelection as s, SceneProvider as t };
package/dist/react.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import { G as MeshHandle, K as SectionHandle } from "./scene-like-DJKQP5uf.js";
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";
1
+ import { t as FastMeshError } from "./core-CJ9D6U5A.js";
2
+ import { _t as MeshHandle, vt as SectionHandle } from "./scene-like-BzkDNHCy.js";
3
+ import { a as DisplayState, c as MeshState, d as SceneSnapshot, n as SectionPatch, p as SectionState, t as SceneStore } from "./store-BKFzSykN.js";
4
4
  import { ReactElement, ReactNode } from "react";
5
- //#region src/react/index.d.ts
6
5
  /** Provides `store` to the hooks below it. */
7
6
  export declare function SceneProvider(props: {
8
7
  store: SceneStore;
@@ -61,5 +60,4 @@ export interface SceneStatus {
61
60
  /** The overall status: `"error"` (with the first error) when anything failed, else `"computing"` while anything is pending. */
62
61
  export declare function useSceneStatus(): SceneStatus;
63
62
  /** The selected mesh (or `null`) and the function that selects one (`store.select`). */
64
- export declare function useSelection(): [MeshHandle | null, (mesh: MeshHandle | null) => void];
65
- //#endregion
63
+ export declare function useSelection(): [MeshHandle | null, (mesh: MeshHandle | null) => void];
package/dist/react.js CHANGED
@@ -1 +1 @@
1
- export { t as SceneProvider, n as useHistory, r as useMeshDisplay, i as useScene, a as useSceneStatus, o as useSection, s as useSelection, c as useStoreSelector } from "./react-CTADh3NN.js";
1
+ export { t as SceneProvider, n as useHistory, r as useMeshDisplay, i as useScene, a as useSceneStatus, o as useSection, s as useSelection, c as useStoreSelector } from "./react-DzrtrzZy.js";