fast-mesh-wasm 0.5.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.
- package/README.md +51 -3
- package/dist/{api-BUy7FRx7.js → api-4kz45-Mq.js} +2 -3
- package/dist/{client-CE6RvmvB.js → client-C61Kku4i.js} +62 -18
- package/dist/{client-pv0Fwvl4.d.ts → client-tP6R9foI.d.ts} +13 -8
- package/dist/{colormap-DxGMYVfs.js → colormap-Dr5V3bvs.js} +1 -2
- package/dist/{core-Cke_kZ2e.js → core-4OcWKu3r.js} +2 -2
- package/dist/{core-D2X9GPfK.d.ts → core-CJ9D6U5A.d.ts} +1 -3
- package/dist/{engine-DLQAL9GT.js → engine-X1Awlc5y.js} +13 -8
- package/dist/io.d.ts +294 -0
- package/dist/io.js +1395 -0
- package/dist/{mesh-zj7-wJBw.js → mesh-CWvrjO8S.js} +3 -4
- package/dist/{mesh-RtPVmPQy.d.ts → mesh-D3fv56nF.d.ts} +1 -3
- package/dist/node.d.ts +3 -5
- package/dist/node.js +4 -5
- package/dist/{protocol-z-jeCUGO.d.ts → protocol-BGQAB0op.d.ts} +6 -3
- package/dist/{protocol-DkhGNP0h.js → protocol-Ci9LLiwO.js} +1 -2
- package/dist/r3f.d.ts +22 -6
- package/dist/r3f.js +28 -19
- package/dist/{react-CTADh3NN.js → react-DzrtrzZy.js} +4 -6
- package/dist/react.d.ts +4 -6
- package/dist/react.js +1 -1
- package/dist/{scene-DyYdEQdy.js → scene-BnkCS0sv.js} +592 -16
- package/dist/{scene-like-YcY08oii.d.ts → scene-like-BzkDNHCy.d.ts} +410 -42
- package/dist/{snapshot-Cf6NgDl7.js → snapshot-BkbGPspK.js} +1 -2
- package/dist/{store-C5nzCpxy.d.ts → store-BKFzSykN.d.ts} +3 -9
- package/dist/{store-Z6A2HPih.js → store-CEd2y2KS.js} +7 -9
- package/dist/store.d.ts +2 -4
- package/dist/store.js +4 -5
- package/dist/three.d.ts +2 -6
- package/dist/three.js +4 -6
- package/dist/{views-Dh3aWc2q.js → views-CUBMOK0U.js} +5 -8
- package/dist/wasm/fast_mesh_wasm.d.ts +77 -6
- package/dist/wasm/fast_mesh_wasm.js +167 -6
- package/dist/wasm/fast_mesh_wasm_bg.wasm +0 -0
- package/dist/wasm/fast_mesh_wasm_bg.wasm.d.ts +8 -1
- package/dist/wasm-threads/fast_mesh_wasm.d.ts +77 -6
- package/dist/wasm-threads/fast_mesh_wasm.js +167 -6
- package/dist/wasm-threads/fast_mesh_wasm_bg.wasm +0 -0
- package/dist/wasm-threads/fast_mesh_wasm_bg.wasm.d.ts +8 -1
- package/dist/web.d.ts +3 -5
- package/dist/web.js +4 -5
- package/dist/worker-engine.d.ts +1 -7
- package/dist/worker-engine.js +1 -1
- package/dist/worker-entry.js +2 -3
- package/dist/worker.d.ts +2 -2
- package/dist/worker.js +1 -1
- package/package.json +16 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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
|
-
|
|
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 {
|
|
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
|
|
2
|
-
import { n as FastMeshErrorCode, t as FastMeshError } from "./core-
|
|
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
|
-
|
|
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 };
|
|
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
|
|
2
|
-
import {
|
|
3
|
-
import { t as Scene } from "./scene-
|
|
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
|
-
|
|
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 { $ as
|
|
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";
|
|
@@ -199,6 +202,7 @@ interface Result {
|
|
|
199
202
|
id: ClientId;
|
|
200
203
|
rotation: number[];
|
|
201
204
|
translation: number[];
|
|
205
|
+
scale: number[];
|
|
202
206
|
matrix4: number[];
|
|
203
207
|
}[];
|
|
204
208
|
/**
|
|
@@ -299,5 +303,4 @@ type WorkerMessage = Result | {
|
|
|
299
303
|
kind: "fatal";
|
|
300
304
|
error: ErrorWire;
|
|
301
305
|
};
|
|
302
|
-
//#endregion
|
|
303
306
|
export { WorkerMessage as a, Result as i, InitMessage as n, Request as r, ClientId as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
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";
|
|
@@ -66,5 +66,4 @@ function supersedes(later, earlier) {
|
|
|
66
66
|
default: return false;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
//#endregion
|
|
70
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 {
|
|
2
|
-
import { t as SceneStore } from "./store-
|
|
3
|
-
import { n as BoundMesh, t as BindMeshOptions } from "./mesh-
|
|
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
|
-
|
|
59
|
-
|
|
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-
|
|
2
|
-
import { t as
|
|
3
|
-
import { s as meshState } from "./snapshot-
|
|
4
|
-
import { r as setFrameLoop } from "./store-
|
|
5
|
-
import {
|
|
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
|
-
|
|
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-
|
|
2
|
-
import { l as sectionState, n as EMPTY_SNAPSHOT, s as meshState } from "./snapshot-
|
|
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
|
-
|
|
4
|
+
// src/react/context.ts
|
|
5
5
|
/** The store a `SceneProvider` provides, or `null` outside one. */
|
|
6
6
|
const StoreContext = createContext(null);
|
|
7
|
-
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import { a as DisplayState, c as MeshState, d as SceneSnapshot, n as SectionPatch, p as SectionState, t as SceneStore } from "./store-
|
|
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-
|
|
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";
|