fast-mesh-wasm 0.3.0 → 0.4.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.
- package/README.md +7 -2
- package/dist/{client-Bp9FRd70.js → client-Bpjy-eFY.js} +1 -1
- package/dist/{client-m2zSdFlu.d.ts → client-D-O5-tAg.d.ts} +2 -2
- package/dist/{colormap-D_xH5hI5.js → colormap-DxGMYVfs.js} +1 -1
- package/dist/{engine-B-ZEzR1c.js → engine-D6MpGb9i.js} +155 -20
- package/dist/{mesh-B16gV3oX.d.ts → mesh-BUVxv3jo.d.ts} +8 -1
- package/dist/{mesh-B8pae8WA.js → mesh-zj7-wJBw.js} +52 -5
- package/dist/node.d.ts +2 -2
- package/dist/node.js +1 -1
- package/dist/{protocol-W9R-iGl5.d.ts → protocol-CK6_3aqo.d.ts} +1 -1
- package/dist/r3f.d.ts +3 -3
- package/dist/r3f.js +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/{scene-BG3EEyfw.js → scene-D6m9XM3O.js} +111 -12
- package/dist/{scene-like-B_3qm0u6.d.ts → scene-like-DJKQP5uf.d.ts} +46 -5
- package/dist/{store-D3ErV6o-.js → store-Ml3TQGsR.js} +2 -2
- package/dist/{store-DNnHN33A.d.ts → store-QWRDXlAn.d.ts} +2 -2
- package/dist/store.d.ts +2 -2
- package/dist/store.js +1 -1
- package/dist/three.d.ts +7 -6
- package/dist/three.js +7 -2
- package/dist/{views-BaZqBxlX.js → views-Dh3aWc2q.js} +1 -1
- package/dist/wasm/fast_mesh_wasm.d.ts +61 -12
- package/dist/wasm/fast_mesh_wasm.js +116 -20
- package/dist/wasm/fast_mesh_wasm_bg.wasm +0 -0
- package/dist/wasm/fast_mesh_wasm_bg.wasm.d.ts +7 -1
- package/dist/wasm-threads/fast_mesh_wasm.d.ts +61 -12
- package/dist/wasm-threads/fast_mesh_wasm.js +116 -20
- package/dist/wasm-threads/fast_mesh_wasm_bg.wasm +0 -0
- package/dist/wasm-threads/fast_mesh_wasm_bg.wasm.d.ts +7 -1
- package/dist/web.d.ts +2 -2
- package/dist/web.js +1 -1
- package/dist/worker-engine.d.ts +16 -7
- package/dist/worker-engine.js +1 -1
- package/dist/worker-entry.js +1 -1
- package/dist/worker.d.ts +1 -1
- package/dist/worker.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
Fast triangle mesh utilities for JavaScript and TypeScript, written in Rust and compiled to WebAssembly.
|
|
8
8
|
|
|
9
|
+
**[Live demo](https://yoondonggeun.github.io/fast-mesh-wasm/)**: the [showcase app](examples/showcase) in your browser.
|
|
10
|
+
|
|
9
11
|
- Works in browsers (Vite, webpack, Next.js), Node.js and Bun
|
|
10
12
|
- Installs the same way with npm, pnpm and bun. No native build step, no install scripts, zero dependencies
|
|
11
13
|
- Full TypeScript types and inline docs, generated from the Rust source
|
|
@@ -104,6 +106,9 @@ requestAnimationFrame(frame);
|
|
|
104
106
|
- The engine's colour maps are sRGB-encoded bytes. The adapter converts them to three's linear working space as it copies them (a normalized `Uint16` colour attribute), so they look the same as in a renderer that passes the bytes through to a non-sRGB canvas.
|
|
105
107
|
- A material you pass to `bindMesh` is used as given and must not be shared between bound meshes (the adapter controls its `color`, `vertexColors`, `opacity`, `transparent` and `depthWrite`). With `shading: "fragment"` it also patches the material's shaders and disposes its compiled program on bind and on restore (see [Fragment shading](#fragment-shading)).
|
|
106
108
|
- The adapter only reads `scene.onChanges`; it never calls `takeChanges`.
|
|
109
|
+
- Bound meshes take their bounding box and sphere from the scene's live-vertex bounds (see `Scene.bounds`), recomputed only when positions or indices change; on a host without them the adapter walks the mirrors instead.
|
|
110
|
+
- Bound objects (and section groups) must sit under an untransformed parent: their matrices are driven as world matrices, so a transformed ancestor offsets them and is warned about once.
|
|
111
|
+
- With `new Scene({ debug: true })`, the views the adapter copies from are checked `Proxy` objects (see the Scene API section for their cost); the mirrors it uploads are always plain typed arrays.
|
|
107
112
|
|
|
108
113
|
#### Fragment shading
|
|
109
114
|
|
|
@@ -147,7 +152,7 @@ colour(gap);
|
|
|
147
152
|
|
|
148
153
|
// Drag the lower mesh. The whole drag is one undo step. Each `move`
|
|
149
154
|
// recomputes the eager fields, so coalesce pointer events to one `move` per
|
|
150
|
-
// animation frame.
|
|
155
|
+
// animation frame (`scene.drag(mesh, { coalesce: true })` does that for you).
|
|
151
156
|
const drag = scene.drag(lower);
|
|
152
157
|
let pending: { rotation: Quat; translation: Vec3 } | undefined;
|
|
153
158
|
function onPointerMove(rotation: Quat, translation: Vec3) {
|
|
@@ -292,7 +297,7 @@ const values = await scene.fetchFieldValues(gap); // `fieldValues` on Scene
|
|
|
292
297
|
- **Errors.** A failed state change shows on its key (`status(key).error`, a `FastMeshError` with the same `code` as on `Scene`); a failed promise rejects with it. After a trap inside the Worker every call fails with `INSTANCE_POISONED`, also when it happens on one of the multithreaded engine's pool threads (a panic or a trap in work split across threads); a few kinds of pool-thread failure still cannot be detected (see [Multithreading (COOP/COEP)](#multithreading-coopcoep)). `await scene.restart()` starts a new Worker and replays the scene from the main thread's mirrors: meshes (compacted: slot ids change, handles do not), placements, fields, colourings and sections. History is cleared, and edits or queries that had not finished fail and must be re-issued.
|
|
293
298
|
- **Not in the Worker scene:** user-opened steps (`beginStep`/`endStep`/`cancelStep`), Lazy and Manual modes (it is always eager) and `takeChanges` (use `onChanges` or the return value of `commitFrame()`). `terminate()` stops the Worker.
|
|
294
299
|
- **Large meshes.** `addMesh` copies its inputs on the main thread (they are then transferred to the Worker) and, without an `origin` option, scans the positions for the bounding-box centre. That takes about 9 ms for 1M triangles and about 63 ms for 10M (see [docs/benchmarks.md](docs/benchmarks.md)); passing `origin` skips the scan.
|
|
295
|
-
- **Large meshes are added in the background.** A mesh of 65,536 triangles or more is built in steps inside the Worker (about 1.1 s at 1M and 12 s at 10M, single-threaded) while the requests sent after it that do not need it run: toggles, edits, drags and queries of other meshes are answered within milliseconds instead of waiting. A request that names the new mesh (or a field not built yet that is measured on or to it), adds or removes a mesh, or queries every mesh (`raycast`, `closestPoint` without a mesh, `findContacts` without pairs) waits for it and finishes it first (in one call on a threaded engine, in steps that still yield on a single-threaded one), so the engine's state is the same as running the requests in order. Replies can come in another order, though: until the mesh lands, `status("mesh:<id>")` reads `"computing"` and its views are empty; its buffers arrive with that status turning `"ready"`, so a reply to an unrelated request sent after the add can arrive first. `createWorkerScene({ backgroundAddTriangles })` sets the threshold; `Infinity` turns background adds off (every add then comes back with its own batch's result).
|
|
300
|
+
- **Large meshes are added in the background.** A mesh of 65,536 triangles or more is built in steps inside the Worker, its upload, store build, normals and the copy of its buffers for the main thread included (about 1.1 s at 1M and 12 s at 10M, single-threaded) while the requests sent after it that do not need it run: toggles, edits, drags and queries of other meshes are answered within milliseconds instead of waiting. A request that names the new mesh (or a field not built yet that is measured on or to it), adds or removes a mesh, or queries every mesh (`raycast`, `closestPoint` without a mesh, `findContacts` without pairs) waits for it and finishes it first (in one call on a threaded engine, in steps that still yield on a single-threaded one), so the engine's state is the same as running the requests in order. Replies can come in another order, though: until the mesh lands, `status("mesh:<id>")` reads `"computing"` and its views are empty; its buffers arrive with that status turning `"ready"`, so a reply to an unrelated request sent after the add can arrive first. `createWorkerScene({ backgroundAddTriangles })` sets the threshold; `Infinity` turns background adds off (every add then comes back with its own batch's result).
|
|
296
301
|
|
|
297
302
|
**Bundlers.** The Worker script is a separate file, `worker-entry.js`, loaded with `new Worker(new URL("./worker-entry.js", import.meta.url), { type: "module" })`. Vite and other bundlers that understand this pattern pick it up and emit it with the `.wasm` it loads: [`examples/webgpu`](examples/webgpu) uses the default with Vite, in both `vite build` and `vite dev` (open it with `?worker`). If your setup does not handle the pattern, serve the package's `dist/` folder (the Worker script loads the files next to it) and pass the script's URL, or create the Worker yourself:
|
|
298
303
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as reportListenerError, t as FastMeshError } from "./core-Cke_kZ2e.js";
|
|
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-
|
|
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
3
|
import { a as supersedes, n as isLastWins, r as keyOf } from "./protocol-CAUYm1gd.js";
|
|
4
4
|
//#region src/worker/client.ts
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $ as
|
|
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";
|
|
2
2
|
import { t as FastMeshError } from "./core-D2X9GPfK.js";
|
|
3
|
-
import "./protocol-
|
|
3
|
+
import "./protocol-CK6_3aqo.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 {
|
|
@@ -36,7 +36,7 @@ const SRGB_TO_LINEAR16 = (() => {
|
|
|
36
36
|
* engine). Grayscale is `(i, i, i)`.
|
|
37
37
|
*/
|
|
38
38
|
const TABLES = {
|
|
39
|
-
turbo: "
|
|
39
|
+
turbo: "MBI7MhVDMxhKNBtRNR5YNiFfNyRmOCdtOSpzOi15Oy+APDKGPTWLPjiRPzuXPz6cQECiQUOnQUasQkmxQku1Q066RFG/RFTDRFbHRVnLRVzPRV7TRmHWRmTaRmbdRmngRmvjR27mR3HpR3PrR3buR3jwR3vyRn30RoD2RoL4RoX6Rof7RYr8RYz9RI/+Q5H+QpT/QZb/QJn/Ppv+PZ7+O6D9OqP8OKX7N6j6Nav4M633Ma/1L7L0LrTyLLfwKrnuKLzrJ77pJcDnI8PkIsXiIMffH8ndHsvaHM3YG9DVGtLSGtTQGdXNGNfKGNnIGNvFGN3CGN7AGOC9GeK7GeO5GuS2HOa0HeeyH+mvIOqsIuuqJeynJ+6kKu+hLPCeL/GbMvKYNfOUOPSRPPWOP/aKQ/eHRviESviATvl9Uvp6Vfp2WftzXfxvYfxsZf1paf1mbf5icf5fdf5cef5Zff9WgP9ThP9RiP9Oi/9Lj/9Jkv9Hlv5Emf5CnP5An/0/of09pPw8p/w6qfs5rPs4r/o3sfk2tPg2t/c1ufY1vPU0vvQ0wfM0w/E0xvA0yO80y+00zew00Oo00uk11Oc11+U12eQ22+I23eA339834d0349s45dk459c56dU569M57NE67s8678068cs68sk69Mc69cU69sM698E6+L45+bw5+ro5+7g4+7Y3/LM2/LE2/a41/aw0/qkz/qcy/qQx/qEw/p4v/pst/pks/pYr/pMq/pAp/Y0n/Yom/Icl/IQj+4Ei+34h+nsf+Xge+XUd+HIc928a9mwZ9WkY9GYX82MV8mAU8V0T8FsS71gR7VUQ7FMP61AO6k4N6EsM50kM5UcL5EUK4kMK4UEJ3z8I3T0I3DsH2jkH2DcG1jUG1DMF0jEF0C8Fzi0EzCsEyioEyCgDxSYDwyUDwSMCviECvCACuR4Ctx0CtBsBshoBrxgBrBcBqRYBpxQBpBMBoRIBnhABmw8BmA4BlQ0BkgsBjgoBiwkCiAgChQcCgQYCfgUCegQD",
|
|
40
40
|
viridis: "RwFVRwNXRwRYRwZZRwdbRwhcRwpdRwtfSA1gSA5hSA9jSBFkSBJlSBRnSBVoSBZpSBhqSBlsSBptSBxuSB1vSB9wSCBxSCFySCN0SCR1SCV2SCd3Ryh4Ryl5Ryp5Ryx6Ry17Ry58RzB9RjF+RjJ/RjN/RjWARjaBRTeBRTiCRTqDRTuDRDyERD2FRD6FRD+GQ0GGQ0KHQ0OHQkSIQkWIQUaIQUiJQUmJQEqKQEuKP0yKP02LP06LPk+LPlCLPVGMPVKMPFSMPFWMO1aMO1eNOliNOlmNOVqNOVuNOFyNOF2NN16ONl+ONmCONWGONWKONGOONGSOM2WOMmaOMmeOMWiOMWmOMGqOMGuOL2yOLm2OLm6OLW+OLXCOLHGOLHKOK3OOK3SOKnSOKXWOKXaOKHeOKHiOJ3mOJ3qOJnuOJnyNJX2NJX6NJX+NJICNJIGNI4KNI4ONIoSNIoWNIoaNIYaNIYeMIYiMIYmMIIqMIIuMIIyMII2MH46MH4+LH5CLH5GLH5KLH5OLH5SLH5SKH5WKH5aKH5eKH5iJH5mJH5qJH5uJIJyIIJ2IIJ6IIJ+IIaCHIaGHIaKHIqKGIqOGI6SFI6WFJKaFJaeEJaiEJqmDJ6qDJ6uCKKyCKayBKq2AK66AK69/LLB/LbF+LrJ9MLN9MbR8MrR7M7V6NLZ6Nbd5N7h4OLl3Orp2O7p1PLt0PrxzP71yQb5xQ79wRL9vRsBuSMFtSsJsS8NrTcNpT8RoUcVnU8ZmVcZkV8djWchiW8lgXslfYMpeYstcZMxbZ8xZac1Ya85Wbs5VcM9Tc9BSddBQeNFOetJNfdJLf9NKgtNIhNRGh9VFitVDjdZBj9ZAktc+ldc9mNg7mtk5ndk4oNo2o9o0ptszqNsxq9wwrtwusdwttN0rt90qut4pvN4nv98mwt8lxd8kyOAjyuAhzeEg0OEg0uEf1eIe2OId2uId3eMc4OMc4uMb5OQb5+Qb6eQb7OUb7uUb8OUc8uYc9OYd9uYe+Ocf+ucg/Och",
|
|
41
41
|
coolwarm: "O0zAPE7CPVDDPlHFQFPGQVXIQlbJQ1jLRFrMRVzOR13PSF/RSWHSSmPTS2TVTWbWTmjXT2nZUGvaUm3bU27dVHDeVXLfV3PgWHXhWXfiWnjkXHrlXXzmXn3nX3/oYYDpYoLqY4TrZYXsZoftZ4juaYrvaovva43wbY7xbpDyb5HzcZPzcpT0c5b1dZf2dpn2d5r3eZz4ep34e5/5faD5fqH6gKP6gaT7gqb7hKf8haj8h6r8iKv9iaz9i639jK/+jbD+j7H+kLL+krT+k7X/lLb/lrf/l7j/mLn/mrv/m7z/nb3/nr7/n7//ocD/osH/o8L+pcP+psT+qMX+qcb+qsf9rMj9rcn9rsn8sMr8scv8ssz7s837tc76ts76t8/5udD5utH4u9H4vNL3vtP2v9P2wNT1wdT0w9X0xNbzxdbyxtfxyNfxydjwytjvy9juzNntzdnsztrr0Nrq0drp0tvo09vn1Nvm1dvl1tzk19zj2Nzi2dzh2tzg293e3N3d3dzc3tzb39zZ4dvY4trW49rV5NnT5dnS5djR5tjP59fO6NbM6dbL6tXJ69TI69PG7NPF7dLD7tHC7tDA78+/78698M688c268cy48su38sq188m088iy9Mex9Mav9MWu9cSs9cOq9cGp9sCn9r+m9r6k9r2i97yh97qf97me97ic97eb97WZ97SX97OW97KU97CT96+R962Q96yO96uM96mL96iJ96aI9qWG9qOF9qKD9qCB9Z+A9Z1+9Zx99Jp79Jl69Jd485V385R18pJ08pBy8Y9x8Y1v8Itu8Ips74hr74Zp7oVo7YNm7YFl7H9j631i6nxg6npf6Xhd6HZc53Ra5nJZ5XBY5W9W5G1V42tT4mlS4WdR4GVP32NO3mFN3V9L3F1K21tJ2llH2FZG11RF1lJD1VBC1E5B00xA0Uk+0Ec9z0U8zkM7zEA5yz44yjs3yDk2xzY0xjQzxDEywy4xwSswwCgvvyUuvSIsvB4ruhoquRYptxEotgsntAQm"
|
|
42
42
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
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-
|
|
2
|
+
import { i as useWasmScene, n as fieldSteps, r as meshAdds, t as Scene } from "./scene-D6m9XM3O.js";
|
|
3
3
|
import { a as supersedes, n as isLastWins, r as keyOf, t as isInit } from "./protocol-CAUYm1gd.js";
|
|
4
4
|
/**
|
|
5
5
|
* A module importing a shared memory `e.m` (1 page, at most 2), exporting
|
|
@@ -340,6 +340,10 @@ const BACKGROUND_ADD_TRIANGLES = 65536;
|
|
|
340
340
|
const ADD_STEP_WORK = 1e5;
|
|
341
341
|
/** A step budget that computes a whole unit at once. */
|
|
342
342
|
const ALL_POINTS = 4294967295;
|
|
343
|
+
/** Bytes of a background add's render buffers copied per unit of {@link EngineOptions.addStepWork}. */
|
|
344
|
+
const PACK_BYTES_PER_UNIT = 64;
|
|
345
|
+
/** Bytes of a background add's positions and indices uploaded per unit of {@link EngineOptions.addStepWork}. */
|
|
346
|
+
const UPLOAD_BYTES_PER_UNIT = 64;
|
|
343
347
|
const now = typeof performance !== "undefined" && typeof performance.now === "function" ? () => performance.now() : () => Date.now();
|
|
344
348
|
/**
|
|
345
349
|
* Runs the engine on `port` until the instance traps. The WebAssembly module
|
|
@@ -518,6 +522,8 @@ var Batch = class {
|
|
|
518
522
|
};
|
|
519
523
|
/** Marks the end of a received batch in the queue: its result is posted there. */
|
|
520
524
|
const END = Symbol("end of batch");
|
|
525
|
+
/** Whether every byte of a {@link Packed} copy is copied. */
|
|
526
|
+
const packedAll = (p) => p !== void 0 && p.done === p.positions.byteLength + (p.normals?.byteLength ?? 0) + p.indices.byteLength;
|
|
521
527
|
/**
|
|
522
528
|
* Yields to the message loop, so batches sent meanwhile are received:
|
|
523
529
|
* `setImmediate` where there is one (Node: a chain of `MessageChannel` ticks
|
|
@@ -548,10 +554,17 @@ var Engine = class {
|
|
|
548
554
|
#meshAdds = meshAdds(this.#scene);
|
|
549
555
|
/** Meshes being added in the background, in arrival order. */
|
|
550
556
|
#adds = [];
|
|
557
|
+
/**
|
|
558
|
+
* Landed background adds whose render buffers were copied out before:
|
|
559
|
+
* their record in the next frame sends these copies, unless a request
|
|
560
|
+
* changed the mesh since (see {@link Engine.#unpack}).
|
|
561
|
+
*/
|
|
562
|
+
#packed = /* @__PURE__ */ new Map();
|
|
551
563
|
#backgroundAdd;
|
|
552
564
|
#addStepWork;
|
|
553
565
|
/** More than one thread: a waiting request finishes adds in one call. */
|
|
554
566
|
#threaded;
|
|
567
|
+
#keepCopies;
|
|
555
568
|
/** The revision of the last result posted, for `update` messages. */
|
|
556
569
|
#lastRev = 0;
|
|
557
570
|
/** A received batch is being run: its first request started, its result is not posted yet. */
|
|
@@ -636,6 +649,7 @@ var Engine = class {
|
|
|
636
649
|
const work = Math.floor(options.addStepWork ?? 1e5);
|
|
637
650
|
this.#addStepWork = work >= 1 ? Math.min(work, ALL_POINTS) : ADD_STEP_WORK;
|
|
638
651
|
this.#threaded = (options.threads ?? 1) > 1;
|
|
652
|
+
this.#keepCopies = options.keepCopies ?? false;
|
|
639
653
|
this.#steps.setDefer(true);
|
|
640
654
|
}
|
|
641
655
|
/**
|
|
@@ -743,9 +757,10 @@ var Engine = class {
|
|
|
743
757
|
const key = keyOf(req);
|
|
744
758
|
if (this.#superseded(req, key) || this.#abandoned(req, key)) return true;
|
|
745
759
|
if (this.#adds.length > 0 && this.#dependsOnAdds(req) && !await this.#finishAdds(req)) return false;
|
|
760
|
+
this.#unpack(req);
|
|
746
761
|
try {
|
|
747
762
|
if (req.kind === "addMesh" && this.#inBackground(req)) {
|
|
748
|
-
this.#beginAdd(req);
|
|
763
|
+
await this.#beginAdd(req);
|
|
749
764
|
this.#onChunk?.({
|
|
750
765
|
kind: "addMeshBegin",
|
|
751
766
|
id: req.id
|
|
@@ -785,20 +800,44 @@ var Engine = class {
|
|
|
785
800
|
return this.#port.postUpdate !== void 0 && req.inline !== true && req.indices.byteLength / 12 >= this.#backgroundAdd;
|
|
786
801
|
}
|
|
787
802
|
/**
|
|
788
|
-
* Starts adding a mesh in the background:
|
|
789
|
-
*
|
|
790
|
-
*
|
|
791
|
-
*
|
|
792
|
-
*
|
|
793
|
-
*
|
|
803
|
+
* Starts adding a mesh in the background: its inputs upload into wasm
|
|
804
|
+
* memory in chunks, yielding between them, then the mesh, its BVH and
|
|
805
|
+
* its normals are built outside the scene, a step at a time between
|
|
806
|
+
* other chunks and while the Worker is idle, and it lands in the scene
|
|
807
|
+
* when built, in arrival order with the other background adds. Until
|
|
808
|
+
* then its status is held, and a request that depends on it
|
|
809
|
+
* ({@link Engine.#dependsOnAdds}) first finishes every background add;
|
|
810
|
+
* other requests run meanwhile.
|
|
794
811
|
*/
|
|
795
|
-
#beginAdd(req) {
|
|
812
|
+
async #beginAdd(req) {
|
|
796
813
|
if (this.#meshes.has(req.id) || this.#adds.some((a) => a.id === req.id)) throw invalid(`mesh client id ${req.id} is already in use`);
|
|
797
814
|
const positions = req.f64 ? new Float64Array(req.positions) : new Float32Array(req.positions);
|
|
798
|
-
const
|
|
815
|
+
const indices = new Uint32Array(req.indices);
|
|
816
|
+
if (positions.length % 3 !== 0) throw invalid("positions length must be a multiple of 3");
|
|
817
|
+
if (indices.length % 3 !== 0) throw invalid("indices length must be a multiple of 3");
|
|
818
|
+
const token = this.#meshAdds.beginUpload(positions.length / 3, indices.length / 3, {
|
|
799
819
|
...req.options,
|
|
800
820
|
mode: "eager"
|
|
801
821
|
});
|
|
822
|
+
try {
|
|
823
|
+
const bytes = this.#addStepWork * UPLOAD_BYTES_PER_UNIT;
|
|
824
|
+
const p = Math.max(1, Math.floor(bytes / positions.BYTES_PER_ELEMENT));
|
|
825
|
+
const n = Math.max(1, Math.floor(bytes / indices.BYTES_PER_ELEMENT));
|
|
826
|
+
for (let at = 0; at < positions.length; at += p) {
|
|
827
|
+
const chunk = positions.subarray(at, at + p);
|
|
828
|
+
this.#meshAdds.pushPositions(token, chunk instanceof Float64Array ? chunk : Float64Array.from(chunk));
|
|
829
|
+
await this.#maybeYield();
|
|
830
|
+
}
|
|
831
|
+
for (let at = 0; at < indices.length; at += n) {
|
|
832
|
+
this.#meshAdds.pushIndices(token, indices.subarray(at, at + n));
|
|
833
|
+
await this.#maybeYield();
|
|
834
|
+
}
|
|
835
|
+
} catch (e) {
|
|
836
|
+
try {
|
|
837
|
+
this.#meshAdds.drop(token);
|
|
838
|
+
} catch {}
|
|
839
|
+
throw e;
|
|
840
|
+
}
|
|
802
841
|
this.#adds.push({
|
|
803
842
|
id: req.id,
|
|
804
843
|
token,
|
|
@@ -858,15 +897,22 @@ var Engine = class {
|
|
|
858
897
|
}
|
|
859
898
|
}
|
|
860
899
|
/**
|
|
861
|
-
* Advances the oldest background add by one step
|
|
862
|
-
*
|
|
863
|
-
*
|
|
864
|
-
*
|
|
865
|
-
*
|
|
900
|
+
* Advances the oldest background add by one step: of its build (BVH and
|
|
901
|
+
* normals), or once built, of the copy of its render buffers
|
|
902
|
+
* ({@link Engine.#pack}); with `land`, lands it once copied (landing
|
|
903
|
+
* changes the scene, which would drop an open field step unit: the
|
|
904
|
+
* unit's loop steps without landing; copying changes nothing). A build
|
|
905
|
+
* that fails is dropped, with an error status for its add. Without
|
|
906
|
+
* `copy`, a built add lands at once and the frame copies its buffers.
|
|
907
|
+
* `false` once poisoned.
|
|
866
908
|
*/
|
|
867
|
-
async #advanceAdd(land = true, failed) {
|
|
909
|
+
async #advanceAdd(land = true, failed, copy = true) {
|
|
868
910
|
const a = this.#adds[0];
|
|
869
911
|
if (a === void 0) return true;
|
|
912
|
+
if (a.built && (!copy || a.uncopied === true) && land) {
|
|
913
|
+
a.packed = void 0;
|
|
914
|
+
return this.#land(a, failed);
|
|
915
|
+
}
|
|
870
916
|
if (!a.built) {
|
|
871
917
|
try {
|
|
872
918
|
a.built = this.#meshAdds.step(a.token, this.#addStepWork);
|
|
@@ -877,8 +923,83 @@ var Engine = class {
|
|
|
877
923
|
kind: "addMeshStep",
|
|
878
924
|
id: a.id
|
|
879
925
|
});
|
|
926
|
+
} else if (!packedAll(a.packed) && a.uncopied !== true) {
|
|
927
|
+
try {
|
|
928
|
+
this.#pack(a);
|
|
929
|
+
} catch (e) {
|
|
930
|
+
if (isPoison(e)) return this.#addFailed(a, e, false, failed);
|
|
931
|
+
a.packed = void 0;
|
|
932
|
+
a.uncopied = true;
|
|
933
|
+
}
|
|
934
|
+
this.#onChunk?.({
|
|
935
|
+
kind: "addMeshPack",
|
|
936
|
+
id: a.id
|
|
937
|
+
});
|
|
880
938
|
}
|
|
881
|
-
return a.
|
|
939
|
+
return (packedAll(a.packed) || a.uncopied === true) && land ? this.#land(a, failed) : true;
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* 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.
|
|
945
|
+
*/
|
|
946
|
+
#changesMesh(req, id) {
|
|
947
|
+
switch (req.kind) {
|
|
948
|
+
case "edit":
|
|
949
|
+
case "repair":
|
|
950
|
+
case "compact":
|
|
951
|
+
case "removeMesh": return req.id === id;
|
|
952
|
+
case "undo":
|
|
953
|
+
case "redo": return true;
|
|
954
|
+
default: return false;
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* Copies about {@link EngineOptions.addStepWork} × 64 more bytes of a
|
|
959
|
+
* built add's render buffers (positions, normals, indices) out of wasm
|
|
960
|
+
* memory, so that the frame it lands in sends them instead of copying
|
|
961
|
+
* the whole mesh then. The build's buffers are the added mesh's, moved
|
|
962
|
+
* into the scene unchanged, so the copies are what the frame would copy,
|
|
963
|
+
* bit for bit, unless a request changes the mesh first
|
|
964
|
+
* ({@link Engine.#unpack}).
|
|
965
|
+
*/
|
|
966
|
+
#pack(a) {
|
|
967
|
+
const views = this.#meshAdds.buffers(a.token);
|
|
968
|
+
const p = a.packed ??= {
|
|
969
|
+
positions: new ArrayBuffer(views.positions.byteLength),
|
|
970
|
+
normals: views.normals === null ? null : new ArrayBuffer(views.normals.byteLength),
|
|
971
|
+
indices: new ArrayBuffer(views.indices.byteLength),
|
|
972
|
+
done: 0
|
|
973
|
+
};
|
|
974
|
+
const parts = [
|
|
975
|
+
[views.positions, p.positions],
|
|
976
|
+
[views.normals, p.normals],
|
|
977
|
+
[views.indices, p.indices]
|
|
978
|
+
];
|
|
979
|
+
let budget = this.#addStepWork * PACK_BYTES_PER_UNIT;
|
|
980
|
+
let start = 0;
|
|
981
|
+
for (const [view, out] of parts) {
|
|
982
|
+
if (view === null || out === null) continue;
|
|
983
|
+
const end = start + out.byteLength;
|
|
984
|
+
if (budget > 0 && p.done < end) {
|
|
985
|
+
const from = p.done - start;
|
|
986
|
+
const n = Math.min(out.byteLength - from, budget);
|
|
987
|
+
new Uint8Array(out, from, n).set(new Uint8Array(view.buffer, view.byteOffset + from, n));
|
|
988
|
+
p.done += n;
|
|
989
|
+
budget -= n;
|
|
990
|
+
}
|
|
991
|
+
start = end;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* Forgets the copied-out buffers of a landed mesh that `req` may change
|
|
996
|
+
* (an edit, repair or compaction of it, an undo or redo), to free them
|
|
997
|
+
* early. Correctness does not depend on it: the copies are sent only
|
|
998
|
+
* while the mesh's content stamp is the one it landed with.
|
|
999
|
+
*/
|
|
1000
|
+
#unpack(req) {
|
|
1001
|
+
if (this.#packed.size === 0 || this.#keepCopies) return;
|
|
1002
|
+
for (const h of [...this.#packed.keys()]) if (this.#changesMesh(req, this.#meshId(h))) this.#packed.delete(h);
|
|
882
1003
|
}
|
|
883
1004
|
/**
|
|
884
1005
|
* Finishes every background add, in arrival order, for `failed`, the
|
|
@@ -887,7 +1008,9 @@ var Engine = class {
|
|
|
887
1008
|
* what is left of its BVH at once with the parallel one-call build
|
|
888
1009
|
* (several times faster than steps). Single-threaded the two cost the
|
|
889
1010
|
* same, so it keeps stepping, yielding (to receive only) between steps,
|
|
890
|
-
* so that newer batches still arrive and coalesce
|
|
1011
|
+
* so that newer batches still arrive and coalesce; it skips the copy of
|
|
1012
|
+
* an add's buffers when `failed` changes that mesh (the frame copies
|
|
1013
|
+
* them anyway).
|
|
891
1014
|
*/
|
|
892
1015
|
async #finishAdds(failed) {
|
|
893
1016
|
while (this.#adds.length > 0) {
|
|
@@ -895,7 +1018,8 @@ var Engine = class {
|
|
|
895
1018
|
if (!this.#land(this.#adds[0], failed)) return false;
|
|
896
1019
|
continue;
|
|
897
1020
|
}
|
|
898
|
-
|
|
1021
|
+
const copy = failed === void 0 || !this.#changesMesh(failed, this.#adds[0].id);
|
|
1022
|
+
if (!await this.#advanceAdd(true, failed, copy)) return false;
|
|
899
1023
|
if (this.#adds.length > 0) await this.#maybeYield();
|
|
900
1024
|
}
|
|
901
1025
|
return true;
|
|
@@ -915,6 +1039,12 @@ var Engine = class {
|
|
|
915
1039
|
}
|
|
916
1040
|
this.#meshes.set(a.id, h);
|
|
917
1041
|
this.#meshIds.set(h, a.id);
|
|
1042
|
+
if (packedAll(a.packed)) try {
|
|
1043
|
+
a.packed.stamp = this.#meshAdds.stamp(h);
|
|
1044
|
+
this.#packed.set(h, a.packed);
|
|
1045
|
+
} catch (e) {
|
|
1046
|
+
if (isPoison(e)) return this.#addFailed(a, e, true, failed);
|
|
1047
|
+
}
|
|
918
1048
|
this.#onChunk?.({
|
|
919
1049
|
kind: "addMesh",
|
|
920
1050
|
id: a.id
|
|
@@ -1724,6 +1854,7 @@ var Engine = class {
|
|
|
1724
1854
|
canUndo: s.canUndo(),
|
|
1725
1855
|
canRedo: s.canRedo()
|
|
1726
1856
|
};
|
|
1857
|
+
this.#packed.clear();
|
|
1727
1858
|
for (const h of this.#removed.splice(0)) this.#meshIds.delete(h);
|
|
1728
1859
|
for (const h of this.#removedFields.splice(0)) this.#fieldIds.delete(h);
|
|
1729
1860
|
for (const h of this.#removedSections.splice(0)) this.#sectionIds.delete(h);
|
|
@@ -1802,11 +1933,15 @@ var Engine = class {
|
|
|
1802
1933
|
if (c.removed) return wire;
|
|
1803
1934
|
wire.vertexSlots = this.#scene.vertexSlots(c.mesh);
|
|
1804
1935
|
wire.triangleSlots = this.#scene.triangleSlots(c.mesh);
|
|
1936
|
+
let packed = c.added ? this.#packed.get(c.mesh) : void 0;
|
|
1937
|
+
if (packed !== void 0 && packed.stamp !== this.#meshAdds.stamp(c.mesh)) packed = void 0;
|
|
1805
1938
|
const views = this.#scene.views(c.mesh);
|
|
1806
1939
|
for (const name of Object.keys(STRIDE)) {
|
|
1807
1940
|
const view = name === "values" && !this.#mirrorValues ? null : views[name]?.() ?? null;
|
|
1808
1941
|
if (view !== null) {
|
|
1809
|
-
const
|
|
1942
|
+
const ranges = rangesOf(c, name);
|
|
1943
|
+
const copy = name === "positions" || name === "normals" || name === "indices" ? packed?.[name] : void 0;
|
|
1944
|
+
const bytes = ranges === "all" && copy != null && copy.byteLength === view.byteLength ? copy : copyRanges(view, ranges, STRIDE[name]);
|
|
1810
1945
|
wire.bytes[name] = bytes;
|
|
1811
1946
|
b.transfer.push(bytes);
|
|
1812
1947
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { G as MeshHandle, t as SceneLike } from "./scene-like-DJKQP5uf.js";
|
|
2
2
|
import * as THREE from "three";
|
|
3
3
|
//#region src/three/mesh.d.ts
|
|
4
4
|
/** Options of {@link bindMesh}. */
|
|
@@ -122,6 +122,13 @@ type MeshBinding = Pick<BoundMesh, "mesh" | "object">;
|
|
|
122
122
|
* the scene and leaves the object as it was (remove it from your THREE.Scene
|
|
123
123
|
* and call {@link BoundMesh.dispose}).
|
|
124
124
|
*
|
|
125
|
+
* The object must sit under an untransformed parent (its `matrix` is a world
|
|
126
|
+
* matrix); a transformed ancestor is detected and warned about once.
|
|
127
|
+
*
|
|
128
|
+
* With a debug scene (`new Scene({ debug: true })`), the views the binding
|
|
129
|
+
* copies from are checked `Proxy` objects (see `SceneOptions.debug` for
|
|
130
|
+
* their cost); the mirrors it uploads are always plain typed arrays.
|
|
131
|
+
*
|
|
125
132
|
* The adapter only listens through {@link SceneLike.onChanges}: call
|
|
126
133
|
* `scene.commitFrame()` once per animation frame, before rendering.
|
|
127
134
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
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-
|
|
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";
|
|
3
3
|
import * as THREE from "three";
|
|
4
4
|
//#region src/three/mesh.ts
|
|
5
5
|
const DEFAULT_COLOR = 13421772;
|
|
@@ -74,6 +74,13 @@ const BUFFERS = {
|
|
|
74
74
|
* the scene and leaves the object as it was (remove it from your THREE.Scene
|
|
75
75
|
* and call {@link BoundMesh.dispose}).
|
|
76
76
|
*
|
|
77
|
+
* The object must sit under an untransformed parent (its `matrix` is a world
|
|
78
|
+
* matrix); a transformed ancestor is detected and warned about once.
|
|
79
|
+
*
|
|
80
|
+
* With a debug scene (`new Scene({ debug: true })`), the views the binding
|
|
81
|
+
* copies from are checked `Proxy` objects (see `SceneOptions.debug` for
|
|
82
|
+
* their cost); the mirrors it uploads are always plain typed arrays.
|
|
83
|
+
*
|
|
77
84
|
* The adapter only listens through {@link SceneLike.onChanges}: call
|
|
78
85
|
* `scene.commitFrame()` once per animation frame, before rendering.
|
|
79
86
|
*/
|
|
@@ -179,19 +186,36 @@ function bindMesh(scene, mesh, options = {}) {
|
|
|
179
186
|
if (shading !== void 0) setShadingUniforms(uniforms, shading);
|
|
180
187
|
return true;
|
|
181
188
|
};
|
|
182
|
-
/**
|
|
189
|
+
/**
|
|
190
|
+
* Live triangles' vertices only: dead slots keep stale positions. From the
|
|
191
|
+
* scene's bounds when the host has them (one engine pass instead of two
|
|
192
|
+
* walks over every slot), else walked from the mirrors.
|
|
193
|
+
*/
|
|
183
194
|
const computeBounds = () => {
|
|
184
195
|
const position = attributeOf("positions");
|
|
185
196
|
const index = attributeOf("indices");
|
|
186
197
|
if (position === void 0 || index === void 0) return;
|
|
198
|
+
const box = geometry.boundingBox ??= new THREE.Box3();
|
|
199
|
+
const sphere = geometry.boundingSphere ??= new THREE.Sphere();
|
|
200
|
+
const fromScene = typeof scene.bounds === "function" ? scene.bounds(mesh) : void 0;
|
|
201
|
+
if (fromScene !== void 0) {
|
|
202
|
+
if (fromScene === null) {
|
|
203
|
+
box.makeEmpty();
|
|
204
|
+
sphere.set(new THREE.Vector3(), -1);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
box.min.fromArray(fromScene.min);
|
|
208
|
+
box.max.fromArray(fromScene.max);
|
|
209
|
+
box.getCenter(sphere.center);
|
|
210
|
+
sphere.radius = box.min.distanceTo(box.max) / 2;
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
187
213
|
const p = position.array;
|
|
188
214
|
const t = index.array;
|
|
189
|
-
const box = geometry.boundingBox ??= new THREE.Box3();
|
|
190
215
|
box.makeEmpty();
|
|
191
216
|
const point = new THREE.Vector3();
|
|
192
217
|
const live = (k) => t[k] !== 0 || t[k + 1] !== 0 || t[k + 2] !== 0;
|
|
193
218
|
for (let k = 0; k < t.length; k += 3) if (live(k)) for (let c = 0; c < 3; c++) box.expandByPoint(point.fromArray(p, 3 * t[k + c]));
|
|
194
|
-
const sphere = geometry.boundingSphere ??= new THREE.Sphere();
|
|
195
219
|
if (box.isEmpty()) {
|
|
196
220
|
sphere.set(new THREE.Vector3(), -1);
|
|
197
221
|
return;
|
|
@@ -264,12 +288,14 @@ function bindMesh(scene, mesh, options = {}) {
|
|
|
264
288
|
apply(void 0);
|
|
265
289
|
computeBounds();
|
|
266
290
|
updateMatrix();
|
|
291
|
+
checkUntransformedParent(object);
|
|
267
292
|
let unsubscribe;
|
|
268
293
|
const detach = () => {
|
|
269
294
|
unsubscribe?.();
|
|
270
295
|
unsubscribe = void 0;
|
|
271
296
|
};
|
|
272
297
|
unsubscribe = scene.onChanges((changes) => {
|
|
298
|
+
checkUntransformedParent(object);
|
|
273
299
|
for (const c of changes) {
|
|
274
300
|
if (c.mesh !== mesh) continue;
|
|
275
301
|
if (c.removed) {
|
|
@@ -310,6 +336,27 @@ function bindMesh(scene, mesh, options = {}) {
|
|
|
310
336
|
if (options.opacity !== void 0) bound.setOpacity(options.opacity);
|
|
311
337
|
return bound;
|
|
312
338
|
}
|
|
339
|
+
/** Objects already warned about a transformed ancestor. */
|
|
340
|
+
const warnedParents = /* @__PURE__ */ new WeakSet();
|
|
341
|
+
/** Whether the object's own transform is the identity. */
|
|
342
|
+
function isIdentityTransform(o) {
|
|
343
|
+
if (!o.matrixAutoUpdate) return o.matrix.elements.every((v, i) => v === (i % 5 === 0 ? 1 : 0));
|
|
344
|
+
const { position: p, quaternion: q, scale: s } = o;
|
|
345
|
+
return p.x === 0 && p.y === 0 && p.z === 0 && q.x === 0 && q.y === 0 && q.z === 0 && q.w === 1 && s.x === 1 && s.y === 1 && s.z === 1;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Warns once per object when it sits under a transformed ancestor: the
|
|
349
|
+
* adapter drives its matrix as a world matrix, so a transformed parent
|
|
350
|
+
* offsets it. Internal: shared with the controls and section bindings.
|
|
351
|
+
*/
|
|
352
|
+
function checkUntransformedParent(object) {
|
|
353
|
+
if (warnedParents.has(object)) return;
|
|
354
|
+
for (let p = object.parent; p !== null; p = p.parent) if (!isIdentityTransform(p)) {
|
|
355
|
+
warnedParents.add(object);
|
|
356
|
+
console.warn("fast-mesh-wasm/three: the bound object has a transformed ancestor; its matrix is driven as a world matrix, so add it under the scene or an untransformed group.");
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
313
360
|
/** `INVALID_ARGUMENT` unless `width` is a finite number `>= 0`. */
|
|
314
361
|
function checkSoftness(width) {
|
|
315
362
|
if (typeof width !== "number" || !Number.isFinite(width) || width < 0) throw new FastMeshError("INVALID_ARGUMENT", "edgeSoftness must be a finite number >= 0");
|
|
@@ -425,4 +472,4 @@ function patchMaterial(material, uniforms) {
|
|
|
425
472
|
};
|
|
426
473
|
}
|
|
427
474
|
//#endregion
|
|
428
|
-
export { bindMesh as t };
|
|
475
|
+
export { checkUntransformedParent as n, bindMesh as t };
|
package/dist/node.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
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
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 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 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 };
|
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-
|
|
3
|
+
import { t as Scene } from "./scene-D6m9XM3O.js";
|
|
4
4
|
import { initSync } from "./wasm/fast_mesh_wasm.js";
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
6
6
|
//#region src/node.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as
|
|
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
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;
|
package/dist/r3f.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as SceneStore } from "./store-
|
|
3
|
-
import { n as BoundMesh, t as BindMeshOptions } from "./mesh-
|
|
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";
|
|
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
|
-
import { t as bindMesh } from "./mesh-
|
|
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-
|
|
4
|
+
import { r as setFrameLoop } from "./store-Ml3TQGsR.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
|
|
1
|
+
import { G as MeshHandle, K as SectionHandle } from "./scene-like-DJKQP5uf.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-
|
|
3
|
+
import { a as DisplayState, c as MeshState, d as SceneSnapshot, n as SectionPatch, p as SectionState, t as SceneStore } from "./store-QWRDXlAn.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. */
|