fast-mesh-wasm 0.2.0 → 0.3.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 +490 -1
- package/dist/{api-D0o2HjaU.js → api-BUy7FRx7.js} +11 -11
- package/dist/client-Bp9FRd70.js +2278 -0
- package/dist/client-m2zSdFlu.d.ts +305 -0
- package/dist/colormap-D_xH5hI5.js +303 -0
- package/dist/core-Cke_kZ2e.js +113 -0
- package/dist/core-D2X9GPfK.d.ts +15 -0
- package/dist/engine-BpnthBYQ.js +1927 -0
- package/dist/mesh-B16gV3oX.d.ts +130 -0
- package/dist/mesh-B8pae8WA.js +428 -0
- package/dist/node.d.ts +3 -2
- package/dist/node.js +5 -4
- package/dist/protocol-CAUYm1gd.js +68 -0
- package/dist/protocol-W9R-iGl5.d.ts +293 -0
- package/dist/r3f.d.ts +59 -0
- package/dist/r3f.js +165 -0
- package/dist/react-CTADh3NN.js +124 -0
- package/dist/react.d.ts +65 -0
- package/dist/react.js +1 -0
- package/dist/scene-BFd6nYRe.js +1256 -0
- package/dist/scene-like-B_3qm0u6.d.ts +925 -0
- package/dist/snapshot-Cf6NgDl7.js +104 -0
- package/dist/store-D3ErV6o-.js +1379 -0
- package/dist/store-DNnHN33A.d.ts +285 -0
- package/dist/store.d.ts +61 -0
- package/dist/store.js +105 -0
- package/dist/three.d.ts +118 -0
- package/dist/three.js +390 -0
- package/dist/views-BaZqBxlX.js +189 -0
- package/dist/wasm/fast_mesh_wasm.d.ts +475 -0
- package/dist/wasm/fast_mesh_wasm.js +1184 -0
- package/dist/wasm/fast_mesh_wasm_bg.wasm +0 -0
- package/dist/wasm/fast_mesh_wasm_bg.wasm.d.ts +76 -0
- package/dist/wasm-threads/fast_mesh_wasm.d.ts +557 -0
- package/dist/wasm-threads/fast_mesh_wasm.js +1547 -0
- package/dist/wasm-threads/fast_mesh_wasm_bg.wasm +0 -0
- package/dist/wasm-threads/fast_mesh_wasm_bg.wasm.d.ts +95 -0
- package/dist/wasm-threads/package.json +7 -0
- package/dist/wasm-threads/snippets/fast-mesh-wasm-ae14781a92c2789e/inline0.js +16 -0
- package/dist/wasm-threads/snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.js +107 -0
- package/dist/web.d.ts +3 -2
- package/dist/web.js +4 -2
- package/dist/worker-engine.d.ts +255 -0
- package/dist/worker-engine.js +1 -0
- package/dist/worker-entry.d.ts +1 -0
- package/dist/worker-entry.js +11 -0
- package/dist/worker.d.ts +2 -0
- package/dist/worker.js +1 -0
- package/package.json +53 -4
- package/dist/api-HcskOwd7.d.ts +0 -43
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
//#region src/store/snapshot.ts
|
|
2
|
+
/** A plain-data value deep-copied and deep-frozen; handles and other class instances are kept as they are. */
|
|
3
|
+
function frozenCopy(value) {
|
|
4
|
+
if (typeof value !== "object" || value === null) return value;
|
|
5
|
+
if (Array.isArray(value)) return Object.freeze(value.map((v) => frozenCopy(v)));
|
|
6
|
+
if (Object.getPrototypeOf(value) !== Object.prototype) return value;
|
|
7
|
+
const out = {};
|
|
8
|
+
for (const [k, v] of Object.entries(value)) if (v !== void 0) out[k] = frozenCopy(v);
|
|
9
|
+
return Object.freeze(out);
|
|
10
|
+
}
|
|
11
|
+
/** Deep equality of plain data (arrays, plain objects, primitives); class instances compare by identity. */
|
|
12
|
+
function sameData(a, b) {
|
|
13
|
+
if (Object.is(a, b)) return true;
|
|
14
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
|
|
15
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
16
|
+
if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;
|
|
17
|
+
return a.every((v, k) => sameData(v, b[k]));
|
|
18
|
+
}
|
|
19
|
+
if (Object.getPrototypeOf(a) !== Object.prototype || Object.getPrototypeOf(b) !== Object.prototype) return false;
|
|
20
|
+
const ka = Object.keys(a).filter((k) => a[k] !== void 0);
|
|
21
|
+
const kb = Object.keys(b).filter((k) => b[k] !== void 0);
|
|
22
|
+
if (ka.length !== kb.length) return false;
|
|
23
|
+
return ka.every((k) => sameData(a[k], b[k]));
|
|
24
|
+
}
|
|
25
|
+
/** The default display: no colouring, opaque, visible. */
|
|
26
|
+
const DEFAULT_DISPLAY = Object.freeze({
|
|
27
|
+
coloring: null,
|
|
28
|
+
opacity: 1,
|
|
29
|
+
visible: true
|
|
30
|
+
});
|
|
31
|
+
/** The state of a mesh not in a snapshot (removed, or never added): `"idle"`, default display. */
|
|
32
|
+
const REMOVED_MESH_STATE = Object.freeze({
|
|
33
|
+
display: DEFAULT_DISPLAY,
|
|
34
|
+
desired: DEFAULT_DISPLAY,
|
|
35
|
+
status: "idle",
|
|
36
|
+
revision: 0
|
|
37
|
+
});
|
|
38
|
+
/** The snapshot of an empty scene; what the server renders (SSR). */
|
|
39
|
+
const EMPTY_SNAPSHOT = Object.freeze({
|
|
40
|
+
revision: 0,
|
|
41
|
+
meshes: Object.freeze(/* @__PURE__ */ new Map()),
|
|
42
|
+
history: Object.freeze({
|
|
43
|
+
canUndo: false,
|
|
44
|
+
canRedo: false
|
|
45
|
+
}),
|
|
46
|
+
sections: Object.freeze(/* @__PURE__ */ new Map()),
|
|
47
|
+
selection: null,
|
|
48
|
+
status: "idle"
|
|
49
|
+
});
|
|
50
|
+
/** A mesh's state in `snap`, or {@link REMOVED_MESH_STATE} when it is not there. */
|
|
51
|
+
function meshState(snap, mesh) {
|
|
52
|
+
return snap.meshes.get(mesh) ?? REMOVED_MESH_STATE;
|
|
53
|
+
}
|
|
54
|
+
const NO_SECTION_PARTS = Object.freeze({
|
|
55
|
+
plane: Object.freeze({
|
|
56
|
+
origin: Object.freeze([
|
|
57
|
+
0,
|
|
58
|
+
0,
|
|
59
|
+
0
|
|
60
|
+
]),
|
|
61
|
+
normal: Object.freeze([
|
|
62
|
+
0,
|
|
63
|
+
0,
|
|
64
|
+
1
|
|
65
|
+
])
|
|
66
|
+
}),
|
|
67
|
+
meshes: Object.freeze([]),
|
|
68
|
+
fill: false
|
|
69
|
+
});
|
|
70
|
+
/**
|
|
71
|
+
* The state of a section not in a snapshot (removed, never added, or on the
|
|
72
|
+
* server): `"idle"`, no meshes, no fill, a placeholder plane through the
|
|
73
|
+
* origin facing +z.
|
|
74
|
+
*/
|
|
75
|
+
const REMOVED_SECTION_STATE = Object.freeze({
|
|
76
|
+
...NO_SECTION_PARTS,
|
|
77
|
+
desired: NO_SECTION_PARTS,
|
|
78
|
+
status: "idle",
|
|
79
|
+
revision: 0
|
|
80
|
+
});
|
|
81
|
+
/** A section's state in `snap`, or {@link REMOVED_SECTION_STATE} when it is not there. */
|
|
82
|
+
function sectionState(snap, section) {
|
|
83
|
+
return snap.sections.get(section) ?? REMOVED_SECTION_STATE;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Combines statuses: `"error"` wins over `"computing"`, which wins over
|
|
87
|
+
* `"ready"`, which wins over `"idle"`. The first error is kept.
|
|
88
|
+
*/
|
|
89
|
+
function combine(parts) {
|
|
90
|
+
let out = { status: "idle" };
|
|
91
|
+
const rank = {
|
|
92
|
+
idle: 0,
|
|
93
|
+
ready: 1,
|
|
94
|
+
computing: 2,
|
|
95
|
+
error: 3
|
|
96
|
+
};
|
|
97
|
+
for (const p of parts) if (rank[p.status] > rank[out.status]) out = p.status === "error" ? {
|
|
98
|
+
status: "error",
|
|
99
|
+
error: p.error
|
|
100
|
+
} : { status: p.status };
|
|
101
|
+
return out;
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
export { combine as a, sameData as c, REMOVED_SECTION_STATE as i, sectionState as l, EMPTY_SNAPSHOT as n, frozenCopy as o, REMOVED_MESH_STATE as r, meshState as s, DEFAULT_DISPLAY as t };
|