fast-mesh-wasm 0.5.0 → 0.5.2
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 +91 -3
- package/dist/{api-BUy7FRx7.js → api-4kz45-Mq.js} +2 -3
- package/dist/{client-CE6RvmvB.js → client-BIPPznBZ.js} +108 -24
- package/dist/{client-pv0Fwvl4.d.ts → client-Uo7hHvD8.d.ts} +25 -11
- 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-BS8i5U8J.js} +41 -11
- package/dist/io.d.ts +306 -0
- package/dist/io.js +1479 -0
- package/dist/{mesh-RtPVmPQy.d.ts → mesh-CqAIuOxU.d.ts} +15 -6
- package/dist/{mesh-zj7-wJBw.js → mesh-hPWBQPaN.js} +31 -8
- package/dist/node.d.ts +3 -5
- package/dist/node.js +4 -5
- package/dist/{protocol-z-jeCUGO.d.ts → protocol-BHAI0xiA.d.ts} +25 -7
- 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-like-YcY08oii.d.ts → scene-like-CavrKbpQ.d.ts} +590 -47
- package/dist/{scene-DyYdEQdy.js → scene-rsfM06St.js} +711 -21
- package/dist/{snapshot-Cf6NgDl7.js → snapshot-BkbGPspK.js} +1 -2
- package/dist/{store-C5nzCpxy.d.ts → store-CZwml1K3.d.ts} +5 -10
- package/dist/{store-Z6A2HPih.js → store-m9l0Al-m.js} +9 -12
- 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-CdOArjcB.js} +6 -8
- package/dist/wasm/fast_mesh_wasm.d.ts +113 -8
- package/dist/wasm/fast_mesh_wasm.js +267 -8
- package/dist/wasm/fast_mesh_wasm_bg.wasm +0 -0
- package/dist/wasm/fast_mesh_wasm_bg.wasm.d.ts +13 -1
- package/dist/wasm-threads/fast_mesh_wasm.d.ts +113 -8
- package/dist/wasm-threads/fast_mesh_wasm.js +268 -9
- package/dist/wasm-threads/fast_mesh_wasm_bg.wasm +0 -0
- package/dist/wasm-threads/fast_mesh_wasm_bg.wasm.d.ts +13 -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
package/README.md
CHANGED
|
@@ -8,6 +8,8 @@ Fast triangle mesh utilities for JavaScript and TypeScript, written in Rust and
|
|
|
8
8
|
|
|
9
9
|
**[Live demo](https://yoondonggeun.github.io/fast-mesh-wasm/)**: the [showcase app](examples/showcase) in your browser.
|
|
10
10
|
|
|
11
|
+
**[API reference](https://yoondonggeun.github.io/fast-mesh-wasm/api/)**: the [TypeScript API](https://yoondonggeun.github.io/fast-mesh-wasm/api/js/) of the `fast-mesh-wasm` package and the [Rust API](https://yoondonggeun.github.io/fast-mesh-wasm/api/rust/) of the workspace crates, rebuilt from `main` on every push. Task-oriented recipes live in the [cookbook](docs/cookbook).
|
|
12
|
+
|
|
11
13
|
- Works in browsers (Vite, webpack, Next.js), Node.js and Bun
|
|
12
14
|
- Installs the same way with npm, pnpm and bun. No native build step, no install scripts, zero dependencies
|
|
13
15
|
- Full TypeScript types and inline docs, generated from the Rust source
|
|
@@ -110,6 +112,17 @@ requestAnimationFrame(frame);
|
|
|
110
112
|
- 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
113
|
- 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.
|
|
112
114
|
|
|
115
|
+
#### Textures
|
|
116
|
+
|
|
117
|
+
Add a mesh with `{ uvs }` (2 floats per vertex, read back zero-copy with `scene.views(mesh).uvs()`) and pass the texture to `bindMesh`:
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
const mesh = scene.addMesh(positions, indices, { uvs });
|
|
121
|
+
const bound = bindMesh(scene, mesh, { map: texture });
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`importGLTF` returns `uvs` from `TEXCOORD_0` and `exportGLTF` writes them. Every mesh operation keeps UVs aligned or drops them, undoably: `weld` keeps seams apart, `simplify`, `subdivide`, `remesh`, `fillHoles` and `cutByPlane` interpolate, and `boolean` drops them. See [docs/uv-channel.md](docs/uv-channel.md) for the table.
|
|
125
|
+
|
|
113
126
|
#### Fragment shading
|
|
114
127
|
|
|
115
128
|
Vertex colours interpolate across each triangle, so the edge between coloured and base-coloured vertices blurs over a triangle's width. `bindMesh(scene, mesh, { shading: "fragment", edgeSoftness })` colours every pixel from the interpolated field value through the colouring's rule instead (a lookup texture and a shader chunk added with `onBeforeCompile`): range edges and colour steps, such as a contact heatmap's tolerance band, are crisp iso-lines, and at a vertex the colour equals its vertex colour. Far (`Infinity`) and NaN values never tint their neighbours.
|
|
@@ -202,7 +215,7 @@ const closest = scene.meshDistance(upper, lower); // { distance, a, b, ... }
|
|
|
202
215
|
scene.free(); // or `using scene = new Scene()`
|
|
203
216
|
```
|
|
204
217
|
|
|
205
|
-
Errors are `FastMeshError`s with a `code` (`UNKNOWN_MESH`, `INVALID_ARGUMENT`, `STALE_BVH`, ...). After a trap inside the WebAssembly module every later call throws `INSTANCE_POISONED`. A view is only valid until the next scene call that may allocate or move buffers: a kept view may read other data or be empty, so re-acquire views after any scene call. `new Scene({ debug: true })` makes views warn when they are read after such a call. Mesh edits (`scene.edit`), `analyze`, `repair`, sections (`addSection`, `section`, `sectionGap`) and `findContacts` are documented in the types.
|
|
218
|
+
Errors are `FastMeshError`s with a `code` (`UNKNOWN_MESH`, `INVALID_ARGUMENT`, `STALE_BVH`, ...). After a trap inside the WebAssembly module every later call throws `INSTANCE_POISONED`. A view is only valid until the next scene call that may allocate or move buffers: a kept view may read other data or be empty, so re-acquire views after any scene call. `new Scene({ debug: true })` makes views warn when they are read after such a call. Mesh edits (`scene.edit`), `analyze`, `measure`, `repair`, `register` (rigid ICP alignment of two meshes), sections (`addSection`, `section`, `sectionGap`) and `findContacts` are documented in the types.
|
|
206
219
|
|
|
207
220
|
### Contact groups: fields to several meshes
|
|
208
221
|
|
|
@@ -293,7 +306,7 @@ const values = await scene.fetchFieldValues(gap); // `fieldValues` on Scene
|
|
|
293
306
|
- **Requests run in order.** A newer colouring, section plane/meshes/fill or drag move drops the older one if it has not started yet, so fast toggling settles on the last state without doing the steps in between. Edits, repairs, `setPlacement`, adds, removals and undo/redo are never dropped. Each `setPlacement` is an undo step: for pointer-rate updates use a drag. Long work runs in steps: the Worker yields every few milliseconds during a field build, a field update or a large add, so newer batches are received (and coalesced) meanwhile.
|
|
294
307
|
- **Drags are optimistic.** `scene.drag(mesh).move(pose)` moves the placement mirror at once, so the object follows the pointer; colours and sections catch up when the Worker's result arrives. In 9a a key's status covers only requests made under that key: a drag, `setPlacement` or edit puts its own key (`placement:<id>`, `edit:<id>`) into `"computing"`, not the `display:<id>` or `section:<id>:*` keys of the state that catches up after it. `end()` and `cancel()` return at once; `cancel()` restores the start pose and records nothing.
|
|
295
308
|
- **Wide-range colouring during a drag.** After each batch the Worker recomputes the fields the batch made due in small steps, and drops the recompute when a newer move, `setPlacement`, edit, repair, compact, undo/redo or removal of either mesh is already queued; other requests wait for it. A pose's colours are applied all at once, never partly. So while the pointer keeps moving and one recompute takes longer than a frame, newer moves drop the recompute, until 200 ms have passed since the last colours were applied: then the recompute under way finishes and is shown, and the newest pose follows. During a sustained drag the colours therefore update about every 200 ms plus one recompute, each update exactly one pose, and when the drag ends (`end()`) the last pose's colours arrive within about one recompute (measured: one at 1M, but about 1.5 at 10M when most of the mesh is in range): the end drops a recompute kept for an older pose. A pointer that only pauses, without ending the drag, may wait up to two recomputes. Edits, undo/redo, removals and cancels always drop a stale recompute. `fetchFieldValues()` and `fieldStatus()` first bring every due field up to date in one go, which cannot be dropped, so do not poll them during a drag. On two touching 1M-triangle meshes with `maxDistance` 8, a recompute takes from about 0.07 s to 0.7 s depending on how much of the mesh is in range, and about ten times that at 10M; the Worker is never blocked for long, since a recompute runs in steps: about 12 ms at a time at 1M, and 14 to 18 ms for field builds and edits at 10M (see [docs/benchmarks.md](docs/benchmarks.md)). These are single-threaded figures; on a cross-origin isolated page the threaded engine makes a recompute 1.4 to 4.5 times faster (see [Multithreading (COOP/COEP)](#multithreading-coopcoep)). A contact range (a small `maxDistance`) keeps up with the pointer.
|
|
296
|
-
- **Queries and anything that returns data** (`raycast`, `closestPoint`, `meshDistance`, `intersects`, `findContacts`, `analyze`, `edit`, `repair`, `fetchFieldValues`, `fieldStatus`, `sectionGap`) return promises. Once a frame loop runs they go out with the next `commitFrame()` (or after 100 ms if no frame comes); before the first `commitFrame()` they are sent on a microtask. For latency-critical picking, keep a light picking copy in a main-thread `Scene`.
|
|
309
|
+
- **Queries and anything that returns data** (`raycast`, `closestPoint`, `meshDistance`, `intersects`, `findContacts`, `analyze`, `measure`, `register`, `edit`, `repair`, `fetchFieldValues`, `fieldStatus`, `sectionGap`) return promises. Once a frame loop runs they go out with the next `commitFrame()` (or after 100 ms if no frame comes); before the first `commitFrame()` they are sent on a microtask. For latency-critical picking, keep a light picking copy in a main-thread `Scene`.
|
|
297
310
|
- **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.
|
|
298
311
|
- **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.
|
|
299
312
|
- **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.
|
|
@@ -307,7 +320,53 @@ const scene = await createWorkerScene({ workerUrl: "/fast-mesh-wasm/worker-entry
|
|
|
307
320
|
const scene = await createWorkerScene({ createWorker: () => new Worker(myUrl, { type: "module" }) });
|
|
308
321
|
```
|
|
309
322
|
|
|
310
|
-
`fast-mesh-wasm/worker`
|
|
323
|
+
**Node.js.** `fast-mesh-wasm/worker` has no zero-config Node entry: `createWorkerScene()` with no
|
|
324
|
+
arguments creates a browser `Worker`. In Node use the synchronous `Scene` instead — each call blocks
|
|
325
|
+
until it returns, which is fine for a batch pipeline with no frame budget (repair, distance checks):
|
|
326
|
+
|
|
327
|
+
```ts
|
|
328
|
+
import { Scene } from "fast-mesh-wasm"; // Node entry: the .wasm loads from disk on import
|
|
329
|
+
|
|
330
|
+
const scene = new Scene(); // no init() needed, as in browsers
|
|
331
|
+
const upper = scene.addMesh(upperPositions, upperIndices);
|
|
332
|
+
const lower = scene.addMesh(lowerPositions, lowerIndices);
|
|
333
|
+
scene.repair(upper, { kind: "auto" }); // weld, remove degenerate, orient, remove small pieces, fill holes
|
|
334
|
+
const gap = scene.addDistanceField({ name: "gap", on: upper, to: lower, maxDistance: 2 });
|
|
335
|
+
scene.setColoring(upper, { field: gap, map: "turbo", range: [-0.5, 1] });
|
|
336
|
+
const distance = scene.meshDistance(upper, lower)?.distance ?? Infinity;
|
|
337
|
+
const colors = scene.views(upper).colors(); // RGBA8, 4 bytes per vertex slot (null when uncoloured)
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
`WorkerScene` still runs in Node through the `createWorker` option with a small `node:worker_threads`
|
|
341
|
+
adapter. It is always single-threaded there: Node reports no `crossOriginIsolated`, so `threads` is
|
|
342
|
+
ignored and `scene.threads` reads `1`. The bench and test harnesses do this
|
|
343
|
+
(`packages/fast-mesh-wasm/bench/worker-harness.mjs`, `test/harness/node-worker.mjs`); the shape is:
|
|
344
|
+
|
|
345
|
+
```ts
|
|
346
|
+
import { Worker } from "node:worker_threads";
|
|
347
|
+
import { createWorkerScene } from "fast-mesh-wasm/worker";
|
|
348
|
+
|
|
349
|
+
const scene = await createWorkerScene({
|
|
350
|
+
createWorker: () => {
|
|
351
|
+
const worker = new Worker(workerUrl, { workerData: { serve: true } });
|
|
352
|
+
const listeners: ((e: { data: unknown }) => void)[] = [];
|
|
353
|
+
worker.on("message", (data) => {
|
|
354
|
+
for (const cb of listeners) cb({ data });
|
|
355
|
+
});
|
|
356
|
+
return {
|
|
357
|
+
postMessage: (msg: unknown, transfer?: Transferable[]) => worker.postMessage(msg, transfer),
|
|
358
|
+
addEventListener: (type: string, cb: (e: { data: unknown }) => void) => {
|
|
359
|
+
if (type === "message") listeners.push(cb);
|
|
360
|
+
},
|
|
361
|
+
terminate: () => worker.terminate(),
|
|
362
|
+
};
|
|
363
|
+
},
|
|
364
|
+
});
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
where the worker script serves the engine on `parentPort` (see `bench/worker-harness.mjs`). Prefer
|
|
368
|
+
the synchronous `Scene` above unless a headless pipeline needs `WorkerScene` parity (status keys,
|
|
369
|
+
background adds).
|
|
311
370
|
|
|
312
371
|
## Multithreading (COOP/COEP)
|
|
313
372
|
|
|
@@ -554,6 +613,35 @@ Meshes must be added through the store (`store.addMesh`). A mesh added straight
|
|
|
554
613
|
|
|
555
614
|
All functions throw an `Error` with a readable message when a buffer length is not a multiple of 3 or an index is out of range, and when called before `init()` has finished in the browser.
|
|
556
615
|
|
|
616
|
+
## Command line
|
|
617
|
+
|
|
618
|
+
`fast-mesh` is a native binary for batch jobs and CI steps. It calls the Rust engine crates directly, with no WebAssembly or Node.js, and is not part of the npm package:
|
|
619
|
+
|
|
620
|
+
```sh
|
|
621
|
+
cargo install --path crates/fast-mesh-cli # add --features parallel for multithreading
|
|
622
|
+
|
|
623
|
+
fast-mesh repair in.stl -o out.stl --auto # weld, remove degenerate, orient, remove small components, fill holes
|
|
624
|
+
fast-mesh measure in.stl --format json # counts, area, volume when watertight, defects
|
|
625
|
+
fast-mesh boolean a.stl b.stl --op union -o out.stl # union, intersection or difference (a minus b)
|
|
626
|
+
fast-mesh convert in.ply -o out.glb
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
Files are `.stl` (binary or ASCII), `.obj`, `.ply` (ASCII or binary little-endian) and `.glb`, chosen by extension. `--ascii` writes the text form of `.stl` and `.ply`. `repair` takes `--weld-tolerance <d>`, `--min-triangles <n>`, `--max-edges <n|any>` and `--no-fair`, with the defaults of `AutoRepairOptions`. `fast-mesh <command> --help` lists a command's options.
|
|
630
|
+
|
|
631
|
+
| Exit code | Meaning |
|
|
632
|
+
| --- | --- |
|
|
633
|
+
| `0` | Success. |
|
|
634
|
+
| `1` | The operation or a file failed: malformed or truncated input, I/O, inputs a boolean refuses, an empty result. |
|
|
635
|
+
| `2` | Usage error: bad arguments, an unsupported extension, or an output that names an input without `--force`. |
|
|
636
|
+
|
|
637
|
+
Reports go to stdout and diagnostics to stderr. With `--format json`, stdout holds one JSON object on success and nothing on failure, so a script can check the exit code and then parse. A hole `repair` leaves open is not a failure: it exits `0`, counts the hole in the report (`skipped`, `failed`) and warns on stderr.
|
|
638
|
+
|
|
639
|
+
The output appears whole or not at all: it is written beside the target and renamed over it when complete, so a failed run leaves any existing file untouched.
|
|
640
|
+
|
|
641
|
+
`boolean` refuses what the engine cannot resolve with `invalid input: boolean intersection too complex` (exit `1`); at present that includes many overlaps of curved surfaces, so check it on your data. Its report says whether the result is `closed`, and it warns on stderr when not.
|
|
642
|
+
|
|
643
|
+
Limits: a `.glb` becomes one mesh, with its node placements baked and its primitives merged. Draco and meshopt compression, GPU instancing, sparse accessors and buffers outside the GLB body are refused with an error. JSON `.gltf`, big-endian PLY and UVs are not supported. Other attributes (normals, colors, materials) are not carried across a conversion.
|
|
644
|
+
|
|
557
645
|
## Supported environments
|
|
558
646
|
|
|
559
647
|
| Environment | Entry | Notes |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as call, r as ensureInitialized, s as setMemory } from "./core-
|
|
1
|
+
import { n as call, r as ensureInitialized, s as setMemory } from "./core-4OcWKu3r.js";
|
|
2
2
|
import * as wasm from "./wasm/fast_mesh_wasm.js";
|
|
3
|
-
|
|
3
|
+
// src/api.ts
|
|
4
4
|
/**
|
|
5
5
|
* Called by the entry point once the WebAssembly module is instantiated, with
|
|
6
6
|
* what `initSync` / the default init returned; keeps its memory for views.
|
|
@@ -60,5 +60,4 @@ function computeBounds(positions) {
|
|
|
60
60
|
]
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
-
//#endregion
|
|
64
63
|
export { computeVertexNormals as n, markInitialized as r, computeBounds as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { o as reportListenerError, t as FastMeshError } from "./core-
|
|
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-
|
|
3
|
-
import { a as supersedes, n as isLastWins, r as keyOf } from "./protocol-
|
|
4
|
-
|
|
1
|
+
import { o as reportListenerError, t as FastMeshError } from "./core-4OcWKu3r.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-CdOArjcB.js";
|
|
3
|
+
import { a as supersedes, n as isLastWins, r as keyOf } from "./protocol-Ci9LLiwO.js";
|
|
4
|
+
// src/worker/client.ts
|
|
5
5
|
/**
|
|
6
6
|
* Starts a Worker running the scene engine and resolves once it is ready.
|
|
7
7
|
* Rejects with `INSTANCE_POISONED` when the Worker could not load fast-mesh.
|
|
@@ -33,6 +33,8 @@ async function createWorkerScene(options = {}) {
|
|
|
33
33
|
if (skipped && debug) console.warn(THREADS_UNAVAILABLE);
|
|
34
34
|
return scene;
|
|
35
35
|
}
|
|
36
|
+
/** The most threads {@link WorkerSceneOptions.threads} asks for; more are clamped. */
|
|
37
|
+
const MAX_THREADS = 64;
|
|
36
38
|
/**
|
|
37
39
|
* Set by `WorkerScene`'s static block: makes a scene (the constructor is
|
|
38
40
|
* private) and returns it with its first Worker's start.
|
|
@@ -44,6 +46,7 @@ const STRIDE = {
|
|
|
44
46
|
normals: 3,
|
|
45
47
|
colors: 4,
|
|
46
48
|
values: 1,
|
|
49
|
+
uvs: 2,
|
|
47
50
|
indices: 3
|
|
48
51
|
};
|
|
49
52
|
const BUFFERS = Object.keys(STRIDE);
|
|
@@ -52,6 +55,7 @@ const MAKE = {
|
|
|
52
55
|
normals: (b) => new Float32Array(b),
|
|
53
56
|
colors: (b) => new Uint8Array(b),
|
|
54
57
|
values: (b) => new Float32Array(b),
|
|
58
|
+
uvs: (b) => new Float32Array(b),
|
|
55
59
|
indices: (b) => new Uint32Array(b)
|
|
56
60
|
};
|
|
57
61
|
const IDENTITY = [
|
|
@@ -68,29 +72,53 @@ const IDENTITY = [
|
|
|
68
72
|
/** The buffers a batch transfers: those of its mesh adds. */
|
|
69
73
|
function transferOf(batch) {
|
|
70
74
|
const transfer = [];
|
|
71
|
-
for (const req of batch) if (req.kind === "addMesh")
|
|
75
|
+
for (const req of batch) if (req.kind === "addMesh") {
|
|
76
|
+
transfer.push(req.positions, req.indices);
|
|
77
|
+
if (req.uvs !== void 0) transfer.push(req.uvs);
|
|
78
|
+
}
|
|
72
79
|
return transfer;
|
|
73
80
|
}
|
|
74
81
|
/** The most failed requests kept for `restart()`. */
|
|
75
82
|
const FAILED_LOG_LIMIT = 1e4;
|
|
76
|
-
/**
|
|
77
|
-
|
|
83
|
+
/**
|
|
84
|
+
* `placement · translate(origin)`, column-major, as `Scene.matrix4`: the
|
|
85
|
+
* rotation columns carry the scale and the last column is
|
|
86
|
+
* `rotation · (scale · origin) + translation`, in the same operation order
|
|
87
|
+
* as the engine, so the mirrors stay bit-identical to it.
|
|
88
|
+
*/
|
|
89
|
+
function poseOf(rotation, translation, origin, scale) {
|
|
78
90
|
const r = rotation;
|
|
79
91
|
const o = origin;
|
|
92
|
+
const s = scale;
|
|
80
93
|
const m = /* @__PURE__ */ new Float64Array(16);
|
|
81
94
|
for (let row = 0; row < 3; row++) {
|
|
82
|
-
for (let col = 0; col < 3; col++) m[4 * col + row] = r[3 * row + col];
|
|
83
|
-
m[12 + row] = r[3 * row] * o[0] + r[3 * row + 1] * o[1] + r[3 * row + 2] * o[2] + translation[row];
|
|
95
|
+
for (let col = 0; col < 3; col++) m[4 * col + row] = s[col] * r[3 * row + col];
|
|
96
|
+
m[12 + row] = r[3 * row] * (s[0] * o[0]) + r[3 * row + 1] * (s[1] * o[1]) + r[3 * row + 2] * (s[2] * o[2]) + translation[row];
|
|
84
97
|
}
|
|
85
98
|
m[15] = 1;
|
|
86
99
|
return {
|
|
87
100
|
rotation,
|
|
88
101
|
translation,
|
|
102
|
+
scale,
|
|
89
103
|
matrix4: m
|
|
90
104
|
};
|
|
91
105
|
}
|
|
92
106
|
function samePose(a, b) {
|
|
93
|
-
return a.matrix4.every((v, k) => v === b.matrix4[k]) && a.translation.every((v, k) => v === b.translation[k]);
|
|
107
|
+
return a.matrix4.every((v, k) => v === b.matrix4[k]) && a.translation.every((v, k) => v === b.translation[k]) && a.scale.every((v, k) => v === b.scale[k]);
|
|
108
|
+
}
|
|
109
|
+
/** A placement input's scale as a `Vec3`: `[1, 1, 1]` when omitted, as the engine defaults it. */
|
|
110
|
+
function scaleOf(scale) {
|
|
111
|
+
if (scale === void 0) return [
|
|
112
|
+
1,
|
|
113
|
+
1,
|
|
114
|
+
1
|
|
115
|
+
];
|
|
116
|
+
if (scale.length !== 3) throw invalid("scale must be 3 numbers");
|
|
117
|
+
return [
|
|
118
|
+
scale[0],
|
|
119
|
+
scale[1],
|
|
120
|
+
scale[2]
|
|
121
|
+
];
|
|
94
122
|
}
|
|
95
123
|
/**
|
|
96
124
|
* The engine's default origin, the bounding-box centre, or `undefined` when
|
|
@@ -754,6 +782,7 @@ var WorkerScene = class WorkerScene {
|
|
|
754
782
|
if (st !== void 0) st.pose = {
|
|
755
783
|
rotation: p.rotation,
|
|
756
784
|
translation: p.translation,
|
|
785
|
+
scale: p.scale,
|
|
757
786
|
matrix4: Float64Array.from(p.matrix4)
|
|
758
787
|
};
|
|
759
788
|
}
|
|
@@ -826,6 +855,7 @@ var WorkerScene = class WorkerScene {
|
|
|
826
855
|
normals: c.normals,
|
|
827
856
|
colors: c.colors,
|
|
828
857
|
indices: c.indices,
|
|
858
|
+
...c.uvs === void 0 ? {} : { uvs: c.uvs },
|
|
829
859
|
fieldsChanged: c.fields.flatMap((id) => this.#fields.get(id)?.handle ?? []),
|
|
830
860
|
sectionsChanged: c.sections.flatMap((id) => this.#sections.get(id)?.handle ?? [])
|
|
831
861
|
};
|
|
@@ -838,14 +868,15 @@ var WorkerScene = class WorkerScene {
|
|
|
838
868
|
st.normals = null;
|
|
839
869
|
st.colors = null;
|
|
840
870
|
st.values = null;
|
|
871
|
+
st.uvs = null;
|
|
841
872
|
st.shown = null;
|
|
842
873
|
this.#guard?.bump();
|
|
843
874
|
}
|
|
844
875
|
#applyBuffer(st, name, c) {
|
|
845
|
-
const bytes = c.bytes[name];
|
|
846
|
-
const ranges = c[name === "values" ? "colors" : name];
|
|
876
|
+
const bytes = c.bytes[name] ?? null;
|
|
877
|
+
const ranges = c[name === "values" ? "colors" : name] ?? [];
|
|
847
878
|
if (bytes === null) {
|
|
848
|
-
if ((name === "normals" || name === "colors" || name === "values") && st[name] !== null) {
|
|
879
|
+
if ((name === "normals" || name === "colors" || name === "values" || name === "uvs") && st[name] !== null) {
|
|
849
880
|
st[name] = null;
|
|
850
881
|
this.#guard?.bump();
|
|
851
882
|
}
|
|
@@ -970,6 +1001,7 @@ var WorkerScene = class WorkerScene {
|
|
|
970
1001
|
this.#alive();
|
|
971
1002
|
const p = copyArray(positions, "positions", (x) => x instanceof Float32Array ? x.slice() : Float64Array.from(x));
|
|
972
1003
|
const i = copyArray(indices, "indices", (x) => Uint32Array.from(x));
|
|
1004
|
+
const uvs = options.uvs === void 0 ? void 0 : copyArray(options.uvs, "uvs", (x) => Float32Array.from(x));
|
|
973
1005
|
const origin = options.origin === void 0 ? boxCentre(p) : [
|
|
974
1006
|
options.origin[0],
|
|
975
1007
|
options.origin[1],
|
|
@@ -990,6 +1022,7 @@ var WorkerScene = class WorkerScene {
|
|
|
990
1022
|
normals: null,
|
|
991
1023
|
colors: null,
|
|
992
1024
|
values: null,
|
|
1025
|
+
uvs: null,
|
|
993
1026
|
shown: null,
|
|
994
1027
|
pendingRules: /* @__PURE__ */ new Map(),
|
|
995
1028
|
indices: /* @__PURE__ */ new Uint32Array(0),
|
|
@@ -997,7 +1030,11 @@ var WorkerScene = class WorkerScene {
|
|
|
997
1030
|
0,
|
|
998
1031
|
0,
|
|
999
1032
|
0
|
|
1000
|
-
], known
|
|
1033
|
+
], known, [
|
|
1034
|
+
1,
|
|
1035
|
+
1,
|
|
1036
|
+
1
|
|
1037
|
+
]),
|
|
1001
1038
|
local: void 0,
|
|
1002
1039
|
localUntil: 0,
|
|
1003
1040
|
requested: void 0,
|
|
@@ -1019,6 +1056,7 @@ var WorkerScene = class WorkerScene {
|
|
|
1019
1056
|
positions: p.buffer,
|
|
1020
1057
|
f64: !(p instanceof Float32Array),
|
|
1021
1058
|
indices: i.buffer,
|
|
1059
|
+
...uvs === void 0 ? {} : { uvs: uvs.buffer },
|
|
1022
1060
|
options: {
|
|
1023
1061
|
origin,
|
|
1024
1062
|
normals: st.normalsOn
|
|
@@ -1086,7 +1124,31 @@ var WorkerScene = class WorkerScene {
|
|
|
1086
1124
|
}
|
|
1087
1125
|
for (const s of this.#sections.values()) if (!s.removed) s.meshes = s.meshes.filter((m) => m !== st);
|
|
1088
1126
|
}
|
|
1089
|
-
/**
|
|
1127
|
+
/**
|
|
1128
|
+
* Rigidly aligns `moving` to `fixed` by ICP from their placements as the
|
|
1129
|
+
* Worker has them when the request runs; see `Scene.register`. An applied
|
|
1130
|
+
* result reaches `placement()` with its batch, like a `setPlacement`.
|
|
1131
|
+
* Not replayed by a restart: an unanswered one rejects with
|
|
1132
|
+
* `INSTANCE_POISONED`, like an edit.
|
|
1133
|
+
*/
|
|
1134
|
+
register(moving, fixed, options = {}) {
|
|
1135
|
+
const m = this.#live(moving);
|
|
1136
|
+
const f = this.#live(fixed);
|
|
1137
|
+
if (this.#drag?.mesh === m || this.#drag?.mesh === f) this.#drag.end();
|
|
1138
|
+
const payload = copyInput(options, "options");
|
|
1139
|
+
return this.#ask((rev, qid) => ({
|
|
1140
|
+
kind: "register",
|
|
1141
|
+
rev,
|
|
1142
|
+
moving: m.id,
|
|
1143
|
+
fixed: f.id,
|
|
1144
|
+
payload,
|
|
1145
|
+
qid
|
|
1146
|
+
}), (v) => v);
|
|
1147
|
+
}
|
|
1148
|
+
/**
|
|
1149
|
+
* Sets a mesh's placement (one undo step), scale included (`[1, 1, 1]`
|
|
1150
|
+
* when omitted); `placement()` follows when the result arrives.
|
|
1151
|
+
*/
|
|
1090
1152
|
setPlacement(mesh, placement) {
|
|
1091
1153
|
const st = this.#live(mesh);
|
|
1092
1154
|
const rotation = rotationMatrix(placement.rotation);
|
|
@@ -1097,22 +1159,25 @@ var WorkerScene = class WorkerScene {
|
|
|
1097
1159
|
t[1],
|
|
1098
1160
|
t[2]
|
|
1099
1161
|
];
|
|
1100
|
-
|
|
1162
|
+
const scale = scaleOf(placement.scale);
|
|
1163
|
+
st.requested = poseOf(rotation, translation, st.origin, scale);
|
|
1101
1164
|
st.requestedUntil = this.#push({
|
|
1102
1165
|
kind: "setPlacement",
|
|
1103
1166
|
rev: ++this.#rev,
|
|
1104
1167
|
id: st.id,
|
|
1105
1168
|
rotation,
|
|
1106
1169
|
translation,
|
|
1170
|
+
scale,
|
|
1107
1171
|
key: `placement:${st.id}`
|
|
1108
1172
|
});
|
|
1109
1173
|
}
|
|
1110
|
-
/** The mesh's placement as mirrored (a drag's pose while it is held). */
|
|
1174
|
+
/** The mesh's placement as mirrored, scale always present (a drag's pose while it is held). */
|
|
1111
1175
|
placement(mesh) {
|
|
1112
1176
|
const p = this.#shown(this.#mirrored(mesh));
|
|
1113
1177
|
return {
|
|
1114
1178
|
rotation: [...p.rotation],
|
|
1115
|
-
translation: [...p.translation]
|
|
1179
|
+
translation: [...p.translation],
|
|
1180
|
+
scale: [...p.scale]
|
|
1116
1181
|
};
|
|
1117
1182
|
}
|
|
1118
1183
|
/** The column-major world matrix of the mesh's local render coordinates, as mirrored. */
|
|
@@ -1136,6 +1201,7 @@ var WorkerScene = class WorkerScene {
|
|
|
1136
1201
|
this.#wantValues();
|
|
1137
1202
|
return st.values === null ? null : wrap(st.values);
|
|
1138
1203
|
},
|
|
1204
|
+
uvs: () => st.uvs === null ? null : wrap(st.uvs),
|
|
1139
1205
|
indices: () => wrap(st.indices)
|
|
1140
1206
|
};
|
|
1141
1207
|
}
|
|
@@ -1219,7 +1285,8 @@ var WorkerScene = class WorkerScene {
|
|
|
1219
1285
|
t[1],
|
|
1220
1286
|
t[2]
|
|
1221
1287
|
];
|
|
1222
|
-
|
|
1288
|
+
const scale = scaleOf(placement.scale);
|
|
1289
|
+
st.local = poseOf(rotation, translation, st.origin, scale);
|
|
1223
1290
|
this.#optimistic.add(st);
|
|
1224
1291
|
this.#push({
|
|
1225
1292
|
kind: "drag",
|
|
@@ -1228,6 +1295,7 @@ var WorkerScene = class WorkerScene {
|
|
|
1228
1295
|
phase: "move",
|
|
1229
1296
|
rotation,
|
|
1230
1297
|
translation,
|
|
1298
|
+
scale,
|
|
1231
1299
|
key
|
|
1232
1300
|
});
|
|
1233
1301
|
},
|
|
@@ -1266,6 +1334,10 @@ var WorkerScene = class WorkerScene {
|
|
|
1266
1334
|
options
|
|
1267
1335
|
}), (v) => v);
|
|
1268
1336
|
}
|
|
1337
|
+
/** Scalar measurements of a mesh; see `Scene.measure`. */
|
|
1338
|
+
measure(mesh) {
|
|
1339
|
+
return this.#query("measure", () => ({ mesh: this.#live(mesh).id }), (v) => v);
|
|
1340
|
+
}
|
|
1269
1341
|
repair(mesh, op) {
|
|
1270
1342
|
return this.#ask((rev, qid) => ({
|
|
1271
1343
|
kind: "repair",
|
|
@@ -1956,7 +2028,7 @@ var WorkerScene = class WorkerScene {
|
|
|
1956
2028
|
continue;
|
|
1957
2029
|
}
|
|
1958
2030
|
if (st.live) {
|
|
1959
|
-
const { positions, indices } = liveGeometry(st);
|
|
2031
|
+
const { positions, indices, uvs } = liveGeometry(st);
|
|
1960
2032
|
this.#push({
|
|
1961
2033
|
kind: "addMesh",
|
|
1962
2034
|
rev: ++this.#rev,
|
|
@@ -1964,6 +2036,7 @@ var WorkerScene = class WorkerScene {
|
|
|
1964
2036
|
positions: positions.buffer,
|
|
1965
2037
|
f64: true,
|
|
1966
2038
|
indices: indices.buffer,
|
|
2039
|
+
...uvs === null ? {} : { uvs: uvs.buffer },
|
|
1967
2040
|
options: {
|
|
1968
2041
|
origin: st.origin,
|
|
1969
2042
|
normals: st.normalsOn
|
|
@@ -1995,7 +2068,11 @@ var WorkerScene = class WorkerScene {
|
|
|
1995
2068
|
0,
|
|
1996
2069
|
0,
|
|
1997
2070
|
0
|
|
1998
|
-
], st.origin
|
|
2071
|
+
], st.origin, [
|
|
2072
|
+
1,
|
|
2073
|
+
1,
|
|
2074
|
+
1
|
|
2075
|
+
]))) continue;
|
|
1999
2076
|
st.requested = pose;
|
|
2000
2077
|
st.requestedUntil = ++this.#rev;
|
|
2001
2078
|
if (!samePose(pose, st.pose)) {
|
|
@@ -2008,6 +2085,7 @@ var WorkerScene = class WorkerScene {
|
|
|
2008
2085
|
id: st.id,
|
|
2009
2086
|
rotation: pose.rotation,
|
|
2010
2087
|
translation: pose.translation,
|
|
2088
|
+
scale: pose.scale,
|
|
2011
2089
|
key: `placement:${st.id}`
|
|
2012
2090
|
});
|
|
2013
2091
|
}
|
|
@@ -2211,6 +2289,7 @@ function liveGeometry(st) {
|
|
|
2211
2289
|
let vertices = 0;
|
|
2212
2290
|
for (let v = 0; v < slots; v++) if (index[v] === 0) index[v] = vertices++;
|
|
2213
2291
|
const positions = new Float64Array(3 * vertices);
|
|
2292
|
+
const uvs = st.uvs === null ? null : new Float32Array(2 * vertices);
|
|
2214
2293
|
const [ox, oy, oz] = st.origin;
|
|
2215
2294
|
for (let v = 0; v < slots; v++) {
|
|
2216
2295
|
const k = index[v];
|
|
@@ -2218,6 +2297,10 @@ function liveGeometry(st) {
|
|
|
2218
2297
|
positions[3 * k] = p[3 * v] + ox;
|
|
2219
2298
|
positions[3 * k + 1] = p[3 * v + 1] + oy;
|
|
2220
2299
|
positions[3 * k + 2] = p[3 * v + 2] + oz;
|
|
2300
|
+
if (uvs !== null && st.uvs !== null) {
|
|
2301
|
+
uvs[2 * k] = st.uvs[2 * v];
|
|
2302
|
+
uvs[2 * k + 1] = st.uvs[2 * v + 1];
|
|
2303
|
+
}
|
|
2221
2304
|
}
|
|
2222
2305
|
}
|
|
2223
2306
|
const indices = new Uint32Array(3 * triangles);
|
|
@@ -2233,7 +2316,8 @@ function liveGeometry(st) {
|
|
|
2233
2316
|
}
|
|
2234
2317
|
return {
|
|
2235
2318
|
positions,
|
|
2236
|
-
indices
|
|
2319
|
+
indices,
|
|
2320
|
+
uvs
|
|
2237
2321
|
};
|
|
2238
2322
|
}
|
|
2239
2323
|
/** Merges a later record into an earlier one of the same mesh. */
|
|
@@ -2258,6 +2342,7 @@ function merge(a, b) {
|
|
|
2258
2342
|
normals: mergeRanges(a.normals, b.normals),
|
|
2259
2343
|
colors: mergeRanges(a.colors, b.colors),
|
|
2260
2344
|
indices: mergeRanges(a.indices, b.indices),
|
|
2345
|
+
...a.uvs === void 0 && b.uvs === void 0 ? {} : { uvs: mergeRanges(a.uvs ?? [], b.uvs ?? []) },
|
|
2261
2346
|
fieldsChanged: union(a.fieldsChanged, b.fieldsChanged),
|
|
2262
2347
|
sectionsChanged: union(a.sectionsChanged, b.sectionsChanged)
|
|
2263
2348
|
};
|
|
@@ -2308,5 +2393,4 @@ function normalised(plane) {
|
|
|
2308
2393
|
]
|
|
2309
2394
|
};
|
|
2310
2395
|
}
|
|
2311
|
-
|
|
2312
|
-
export { watchStatusKeys as i, addFieldKeyed as n, createWorkerScene as r, WorkerScene as t };
|
|
2396
|
+
export { watchStatusKeys as a, createWorkerScene as i, WorkerScene as n, addFieldKeyed as r, MAX_THREADS as t };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as FastMeshError } from "./core-
|
|
3
|
-
import "./protocol-
|
|
4
|
-
//#region src/worker/client.d.ts
|
|
1
|
+
import { At as PlacementInput, Ct as MeshHandle, Et as Indices, F as MeshChange, Ft as Vec3, H as RaycastOptions, L as MeshDistance, M as JoinReport, Mt as Positions64, O as FindContactsOptions, P as MeasureResult, S as EditOp, St as FieldHandle, T as FieldStatus, U as RegisterOptions, V as RayHit, W as RegisterResult, Y as RepairOp, Z as RepairReportOf, a as AutoRepairReport, at as SectionResult, d as ClosestPointOptions, f as ColorRule, i as AnalyzeOptions, it as SectionPlane, j as JoinOptions, kt as Placement, m as Contact, n as AddMeshOptions, nt as SectionDesc, o as AutoRepairRequest, r as Analysis, rt as SectionGap, t as SceneLike, u as ClosestHit, w as EditResult, wt as SectionHandle, x as DragSession, xt as SceneMeshViews, y as DistanceFieldDesc } from "./scene-like-CavrKbpQ.js";
|
|
2
|
+
import { t as FastMeshError } from "./core-CJ9D6U5A.js";
|
|
3
|
+
import "./protocol-BHAI0xiA.js";
|
|
5
4
|
/** What {@link WorkerScene} needs of a Worker; a browser `Worker` fits. */
|
|
6
5
|
interface WorkerLike {
|
|
7
6
|
postMessage(msg: unknown, transfer?: Transferable[]): void;
|
|
@@ -71,6 +70,8 @@ interface KeyStatus {
|
|
|
71
70
|
* Rejects with `INSTANCE_POISONED` when the Worker could not load fast-mesh.
|
|
72
71
|
*/
|
|
73
72
|
declare function createWorkerScene(options?: WorkerSceneOptions): Promise<WorkerScene>;
|
|
73
|
+
/** The most threads {@link WorkerSceneOptions.threads} asks for; more are clamped. */
|
|
74
|
+
declare const MAX_THREADS = 64;
|
|
74
75
|
/**
|
|
75
76
|
* A scene whose engine runs in a Worker, from {@link createWorkerScene}. It
|
|
76
77
|
* mirrors `Scene` (always `"eager"`) with these differences:
|
|
@@ -113,7 +114,7 @@ declare class WorkerScene implements SceneLike {
|
|
|
113
114
|
* `"computing"` and its views are empty; its buffers arrive with that
|
|
114
115
|
* status turning `"ready"`.
|
|
115
116
|
*/
|
|
116
|
-
addMesh(positions: Positions64, indices: Indices, options?: Pick<AddMeshOptions, "origin" | "normals">): MeshHandle;
|
|
117
|
+
addMesh(positions: Positions64, indices: Indices, options?: Pick<AddMeshOptions, "origin" | "normals" | "uvs">): MeshHandle;
|
|
117
118
|
/**
|
|
118
119
|
* Removes a mesh, ending an active drag of it first. Later calls on it give
|
|
119
120
|
* `UNKNOWN_MESH`; its mirrors stay readable until the removal is delivered
|
|
@@ -126,9 +127,20 @@ declare class WorkerScene implements SceneLike {
|
|
|
126
127
|
* changes nothing, engine-side or here).
|
|
127
128
|
*/
|
|
128
129
|
join(target: MeshHandle, source: MeshHandle, options: JoinOptions): Promise<JoinReport>;
|
|
129
|
-
/**
|
|
130
|
+
/**
|
|
131
|
+
* Rigidly aligns `moving` to `fixed` by ICP from their placements as the
|
|
132
|
+
* Worker has them when the request runs; see `Scene.register`. An applied
|
|
133
|
+
* result reaches `placement()` with its batch, like a `setPlacement`.
|
|
134
|
+
* Not replayed by a restart: an unanswered one rejects with
|
|
135
|
+
* `INSTANCE_POISONED`, like an edit.
|
|
136
|
+
*/
|
|
137
|
+
register(moving: MeshHandle, fixed: MeshHandle, options?: RegisterOptions): Promise<RegisterResult>;
|
|
138
|
+
/**
|
|
139
|
+
* Sets a mesh's placement (one undo step), scale included (`[1, 1, 1]`
|
|
140
|
+
* when omitted); `placement()` follows when the result arrives.
|
|
141
|
+
*/
|
|
130
142
|
setPlacement(mesh: MeshHandle, placement: PlacementInput): void;
|
|
131
|
-
/** The mesh's placement as mirrored (a drag's pose while it is held). */
|
|
143
|
+
/** The mesh's placement as mirrored, scale always present (a drag's pose while it is held). */
|
|
132
144
|
placement(mesh: MeshHandle): Placement;
|
|
133
145
|
/** The column-major world matrix of the mesh's local render coordinates, as mirrored. */
|
|
134
146
|
matrix4(mesh: MeshHandle): Float64Array;
|
|
@@ -137,7 +149,7 @@ declare class WorkerScene implements SceneLike {
|
|
|
137
149
|
* getter returns the current mirror; a mirror is replaced when the slot
|
|
138
150
|
* count changes or a buffer turns on or off, so get views right before use.
|
|
139
151
|
*/
|
|
140
|
-
views(mesh: MeshHandle):
|
|
152
|
+
views(mesh: MeshHandle): SceneMeshViews;
|
|
141
153
|
/**
|
|
142
154
|
* The rule the mirrored colours and values are made by (a frozen copy of
|
|
143
155
|
* the one given to `setColoring`, the same object until another rule is
|
|
@@ -158,7 +170,10 @@ declare class WorkerScene implements SceneLike {
|
|
|
158
170
|
compact(mesh: MeshHandle): void;
|
|
159
171
|
/** A report of the mesh's defects; see `Scene.analyze`. */
|
|
160
172
|
analyze(mesh: MeshHandle, options?: AnalyzeOptions): Promise<Analysis>;
|
|
161
|
-
/**
|
|
173
|
+
/** Scalar measurements of a mesh; see `Scene.measure`. */
|
|
174
|
+
measure(mesh: MeshHandle): Promise<MeasureResult>;
|
|
175
|
+
/** Runs one repair operation, a list as one transaction, or the auto pipeline; see `Scene.repair`. */
|
|
176
|
+
repair(mesh: MeshHandle, request: AutoRepairRequest): Promise<AutoRepairReport>;
|
|
162
177
|
repair<const O extends RepairOp>(mesh: MeshHandle, op: O): Promise<RepairReportOf<O>>;
|
|
163
178
|
repair<const O extends readonly RepairOp[]>(mesh: MeshHandle, ops: O): Promise<{ -readonly [K in keyof O]: RepairReportOf<O[K]>; }>;
|
|
164
179
|
/** Undoes the latest step; an active drag is ended first. */
|
|
@@ -307,5 +322,4 @@ declare class WorkerScene implements SceneLike {
|
|
|
307
322
|
*/
|
|
308
323
|
terminate(): void;
|
|
309
324
|
}
|
|
310
|
-
|
|
311
|
-
export { createWorkerScene as a, WorkerSceneOptions as i, WorkerLike as n, WorkerScene as r, KeyStatus as t };
|
|
325
|
+
export { WorkerSceneOptions as a, WorkerScene as i, MAX_THREADS as n, createWorkerScene as o, WorkerLike as r, KeyStatus as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/colormap.ts
|
|
2
2
|
/** The rule's `base` colour when it gives none. */
|
|
3
3
|
const DEFAULT_BASE = [
|
|
4
4
|
200,
|
|
@@ -299,5 +299,4 @@ vec4 fmShade(vec4 a) {
|
|
|
299
299
|
return fmLinear(fmFar(a.w));
|
|
300
300
|
}
|
|
301
301
|
`;
|
|
302
|
-
//#endregion
|
|
303
302
|
export { SRGB_TO_LINEAR16 as a, SHADING_VERTEX as i, DEFAULT_NAN as n, encodeValues as o, SHADING_FRAGMENT as r, shadingOf as s, DEFAULT_BASE as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/core.ts
|
|
2
2
|
const CODES = /* @__PURE__ */ new Set([
|
|
3
3
|
"UNKNOWN_MESH",
|
|
4
4
|
"UNKNOWN_FIELD",
|
|
@@ -10,6 +10,7 @@ const CODES = /* @__PURE__ */ new Set([
|
|
|
10
10
|
"CORRUPTED",
|
|
11
11
|
"OUT_OF_MEMORY",
|
|
12
12
|
"STALE_LOOPS",
|
|
13
|
+
"STALE_SELECTION",
|
|
13
14
|
"INSTANCE_POISONED"
|
|
14
15
|
]);
|
|
15
16
|
/** An error thrown by fast-mesh, with a machine-readable `code`. */
|
|
@@ -109,5 +110,4 @@ const finalizer = new FinalizationRegistry((obj) => {
|
|
|
109
110
|
release(obj);
|
|
110
111
|
} catch {}
|
|
111
112
|
});
|
|
112
|
-
//#endregion
|
|
113
113
|
export { release as a, wasmMemory as c, finalizer as i, call as n, reportListenerError as o, ensureInitialized as r, setMemory as s, FastMeshError as t };
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
//#region src/core.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Error codes of {@link FastMeshError}.
|
|
4
3
|
* `INSTANCE_POISONED` means an earlier call panicked: the WebAssembly instance
|
|
5
4
|
* is unusable and every later call throws it. Reload the module to recover.
|
|
6
5
|
*/
|
|
7
|
-
type FastMeshErrorCode = "UNKNOWN_MESH" | "UNKNOWN_FIELD" | "UNKNOWN_SECTION" | "INVALID_ARGUMENT" | "INVALID_INDEX" | "STALE_BVH" | "STEP_NOT_OPEN" | "CORRUPTED" | "OUT_OF_MEMORY" | "STALE_LOOPS" | "INSTANCE_POISONED";
|
|
6
|
+
type FastMeshErrorCode = "UNKNOWN_MESH" | "UNKNOWN_FIELD" | "UNKNOWN_SECTION" | "INVALID_ARGUMENT" | "INVALID_INDEX" | "STALE_BVH" | "STEP_NOT_OPEN" | "CORRUPTED" | "OUT_OF_MEMORY" | "STALE_LOOPS" | "STALE_SELECTION" | "INSTANCE_POISONED";
|
|
8
7
|
/** An error thrown by fast-mesh, with a machine-readable `code`. */
|
|
9
8
|
declare class FastMeshError extends Error {
|
|
10
9
|
/** What went wrong; see {@link FastMeshErrorCode}. */
|
|
11
10
|
readonly code: FastMeshErrorCode;
|
|
12
11
|
constructor(code: FastMeshErrorCode, message: string);
|
|
13
12
|
}
|
|
14
|
-
//#endregion
|
|
15
13
|
export { FastMeshErrorCode as n, FastMeshError as t };
|