fast-mesh-wasm 0.1.0 → 0.3.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 (49) hide show
  1. package/README.md +493 -23
  2. package/dist/api-BUy7FRx7.js +64 -0
  3. package/dist/client-Bp9FRd70.js +2278 -0
  4. package/dist/client-m2zSdFlu.d.ts +305 -0
  5. package/dist/colormap-D_xH5hI5.js +303 -0
  6. package/dist/core-Cke_kZ2e.js +113 -0
  7. package/dist/core-D2X9GPfK.d.ts +15 -0
  8. package/dist/engine-B-ZEzR1c.js +1818 -0
  9. package/dist/mesh-B16gV3oX.d.ts +130 -0
  10. package/dist/mesh-B8pae8WA.js +428 -0
  11. package/dist/node.d.ts +6 -4
  12. package/dist/node.js +9 -5
  13. package/dist/protocol-CAUYm1gd.js +68 -0
  14. package/dist/protocol-W9R-iGl5.d.ts +293 -0
  15. package/dist/r3f.d.ts +59 -0
  16. package/dist/r3f.js +165 -0
  17. package/dist/react-CTADh3NN.js +124 -0
  18. package/dist/react.d.ts +65 -0
  19. package/dist/react.js +1 -0
  20. package/dist/scene-BG3EEyfw.js +1243 -0
  21. package/dist/scene-like-B_3qm0u6.d.ts +925 -0
  22. package/dist/snapshot-Cf6NgDl7.js +104 -0
  23. package/dist/store-D3ErV6o-.js +1379 -0
  24. package/dist/store-DNnHN33A.d.ts +285 -0
  25. package/dist/store.d.ts +61 -0
  26. package/dist/store.js +105 -0
  27. package/dist/three.d.ts +118 -0
  28. package/dist/three.js +390 -0
  29. package/dist/views-BaZqBxlX.js +189 -0
  30. package/dist/wasm/fast_mesh_wasm.d.ts +450 -31
  31. package/dist/wasm/fast_mesh_wasm.js +1122 -49
  32. package/dist/wasm/fast_mesh_wasm_bg.wasm +0 -0
  33. package/dist/wasm/fast_mesh_wasm_bg.wasm.d.ts +76 -7
  34. package/dist/wasm-threads/fast_mesh_wasm.d.ts +540 -0
  35. package/dist/wasm-threads/fast_mesh_wasm.js +1513 -0
  36. package/dist/wasm-threads/fast_mesh_wasm_bg.wasm +0 -0
  37. package/dist/wasm-threads/fast_mesh_wasm_bg.wasm.d.ts +93 -0
  38. package/dist/wasm-threads/package.json +7 -0
  39. package/dist/wasm-threads/snippets/fast-mesh-wasm-ae14781a92c2789e/inline0.js +16 -0
  40. package/dist/wasm-threads/snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.js +107 -0
  41. package/dist/web.d.ts +3 -2
  42. package/dist/web.js +6 -3
  43. package/dist/worker-engine.d.ts +248 -0
  44. package/dist/worker-engine.js +1 -0
  45. package/dist/worker-entry.d.ts +1 -0
  46. package/dist/worker-entry.js +11 -0
  47. package/dist/worker.d.ts +2 -0
  48. package/dist/worker.js +1 -0
  49. package/package.json +55 -4
@@ -0,0 +1,64 @@
1
+ import { n as call, r as ensureInitialized, s as setMemory } from "./core-Cke_kZ2e.js";
2
+ import * as wasm from "./wasm/fast_mesh_wasm.js";
3
+ //#region src/api.ts
4
+ /**
5
+ * Called by the entry point once the WebAssembly module is instantiated, with
6
+ * what `initSync` / the default init returned; keeps its memory for views.
7
+ */
8
+ function markInitialized(output) {
9
+ setMemory(output.memory);
10
+ }
11
+ function toFloat32(values) {
12
+ return values instanceof Float32Array ? values : Float32Array.from(values);
13
+ }
14
+ function toUint32(values) {
15
+ return values instanceof Uint32Array ? values : Uint32Array.from(values);
16
+ }
17
+ /**
18
+ * Computes smooth, area-weighted per-vertex normals.
19
+ *
20
+ * @param positions - Vertex positions. Length must be a multiple of 3.
21
+ * @param indices - Triangle indices. Length must be a multiple of 3.
22
+ * @returns Normals with the same length as `positions`. Vertices not used by any triangle get `[0, 0, 0]`.
23
+ * @throws If a length is not a multiple of 3 or an index is out of range.
24
+ */
25
+ function computeVertexNormals(positions, indices) {
26
+ ensureInitialized("computeVertexNormals()");
27
+ return call(() => wasm.computeVertexNormals(toFloat32(positions), toUint32(indices)));
28
+ }
29
+ /**
30
+ * Computes the axis-aligned bounding box of a mesh.
31
+ *
32
+ * @param positions - Vertex positions. Length must be a non-zero multiple of 3.
33
+ * @throws If `positions` is empty or its length is not a multiple of 3.
34
+ */
35
+ function computeBounds(positions) {
36
+ ensureInitialized("computeBounds()");
37
+ const b = call(() => wasm.computeBounds(toFloat32(positions)));
38
+ const min = [
39
+ b[0],
40
+ b[1],
41
+ b[2]
42
+ ];
43
+ const max = [
44
+ b[3],
45
+ b[4],
46
+ b[5]
47
+ ];
48
+ return {
49
+ min,
50
+ max,
51
+ center: [
52
+ (min[0] + max[0]) / 2,
53
+ (min[1] + max[1]) / 2,
54
+ (min[2] + max[2]) / 2
55
+ ],
56
+ size: [
57
+ max[0] - min[0],
58
+ max[1] - min[1],
59
+ max[2] - min[2]
60
+ ]
61
+ };
62
+ }
63
+ //#endregion
64
+ export { computeVertexNormals as n, markInitialized as r, computeBounds as t };