fast-mesh-wasm 0.7.0 → 0.8.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 +43 -3
- package/dist/client-CJWOKQMM.d.ts +664 -0
- package/dist/{client-DFgvktkT.js → client-DQADH6KL.js} +1753 -123
- package/dist/{engine-BL5_sWAf.js → engine-D2124Vml.js} +983 -51
- package/dist/io.d.ts +7 -2
- package/dist/io.js +6 -6
- package/dist/{mesh-DIWD2F5-.js → mesh-BtWBMRMO.js} +2 -1
- package/dist/{mesh-BHTFxsXc.d.ts → mesh-DTm2Fnqa.d.ts} +3 -2
- package/dist/node.d.ts +4 -2
- package/dist/node.js +4 -4
- package/dist/primitives-6T0eQiSm.d.ts +157 -0
- package/dist/{scene-DUsj6uJD.js → primitives-wasm-C30Bk4ut.js} +1359 -64
- package/dist/primitives-wasm-d9m2vikb.d.ts +43 -0
- package/dist/{protocol-Ci9LLiwO.js → protocol-Bvjmvlb3.js} +38 -3
- package/dist/{protocol-DFR0JDAS.d.ts → protocol-Da0kmXuF.d.ts} +417 -3
- package/dist/r3f.d.ts +3 -3
- package/dist/r3f.js +3 -3
- package/dist/{react-DzrtrzZy.js → react-DIuy5dyR.js} +12 -3
- package/dist/react.d.ts +6 -3
- package/dist/react.js +1 -1
- package/dist/scene-like-Bx7lZKif.d.ts +4808 -0
- package/dist/{store-BAzHRRkt.js → store-BxzcXy9y.js} +415 -65
- package/dist/{store-8HWG90Jg.d.ts → store-LM3iU8E4.d.ts} +98 -10
- package/dist/store.d.ts +3 -3
- package/dist/store.js +1 -1
- package/dist/three.d.ts +13 -11
- package/dist/three.js +63 -18
- package/dist/views-DPMbo0Sl.js +3147 -0
- package/dist/wasm/fast_mesh_wasm.d.ts +541 -8
- package/dist/wasm/fast_mesh_wasm.js +2083 -93
- package/dist/wasm/fast_mesh_wasm_bg.wasm +0 -0
- package/dist/wasm/fast_mesh_wasm_bg.wasm.d.ts +94 -0
- package/dist/wasm-threads/fast_mesh_wasm.d.ts +541 -8
- package/dist/wasm-threads/fast_mesh_wasm.js +2084 -94
- package/dist/wasm-threads/fast_mesh_wasm_bg.wasm +0 -0
- package/dist/wasm-threads/fast_mesh_wasm_bg.wasm.d.ts +94 -0
- package/dist/wave6-wasm-Bt4vTlKz.js +146 -0
- package/dist/web.d.ts +4 -2
- package/dist/web.js +4 -4
- package/dist/worker-engine.d.ts +20 -2
- 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/dist/api-4kz45-Mq.js +0 -63
- package/dist/client-nvmbhtn-.d.ts +0 -398
- package/dist/scene-like-CR_Dpohm.d.ts +0 -2511
- package/dist/views-BSy-Qeg8.js +0 -584
|
@@ -0,0 +1,664 @@
|
|
|
1
|
+
import { $a as ExtrudeBaseOptions, $i as FaceSelectionNormalCone, $t as DeviationOptions, A as WorkerRemeshDomain, Ai as ConvexHullPoints, An as LandmarkPair, Ca as PlaceMeshOptions, Ct as WorkerAlignDomain, Dn as JoinOptions, Dt as AnalyzeOptions, Ei as LatticePreview, Et as Analysis, Fa as SplitFacesReport, Fi as ArapOptions, Fn as MeshChange, Fr as SurfacePathPoint, Gn as QualityMetric, Hi as CollisionRule, Hn as OverhangOptions, Hr as TrimCurveOptions, Ht as ClosestPointOptions, I as WorkerInspectDomain, It as BridgeStats, Ja as HeightMapOptions, Jn as RaycastOptions, Jt as CsgNode, Ka as HeightMap, Kn as QualityReport, Kr as VertexProtection, Kt as Contact, La as SurfaceReconstructOptions, Ln as MeshDistance, Ma as ScreenSelectOptions, Mi as AdjacencyKind, Na as ScreenSelectionShape, Nt as BooleanOptions, Oi as LatticeReport, On as JoinReport, Pn as MeasureResult, Pr as SurfacePathOptions, Qi as FaceEditReport, Qn as RegisterResult, So as Vec3, Ti as LatticePlan, Tt as AddMeshOptions, U as WorkerDeformDomain, Ua as AddHeightfieldOptions, Ui as CollisionRuleInput, Un as OverhangReport, Ur as TrimReport, Vr as TriangleQualityOptions, Vt as ClosestHit, Wi as CollisionStepReport, Wn as PartialBridgeOptions, Wt as ColorRule, Xa as HeightfieldResult, Xi as DrainHoleOptions, Xt as CutOptions, Ya as Heightfield, Zi as DrainHoleReport, Zn as RegisterOptions, Zt as CutReport, _ as WorkerRepairDomain, _a as KelvinletOptions, _i as WrapGridOptions, _n as FindContactsOptions, _o as PlacementInput, _r as SectionDesc, _t as WorkerBooleanDomain, aa as FfdOptions, ao as DelaunayFlipReport, bi as WrapResult, br as SectionResult, ca as FittedPrimitive, cn as EditOp, da as FreeformReport, di as HistoryEntry, dn as FieldStatus, do as SectionHandle, en as DeviationStats, eo as ExtrudeBaseResult, er as RegistrationOptions, fi as PermanentListener, fo as Bounds, fr as SculptBrushOp, go as Placement, ha as HollowReport, ia as FfdLatticeData, in as DyntopoDabReport, io as DelaunayFlipOptions, ir as RemoveMeshOptions, ji as ConvexHullResult, ki as ConvexHullOptions, kn as LandmarkAlignment, la as FittedPrimitiveReport, lo as FieldHandle, lt as WorkerSculptDomain, ma as HollowOptions, mn as FillHolesContinuityOptions, n as SceneLike, ni as SceneMeshViews, no as ExtrudeFacesOptions, on as DyntopoOptions, oo as DenoiseOptions, pn as FillContinuityStats, po as Indices, qa as HeightMapFrame, qi as ContourSlice, qn as RayHit, rn as DragSession, ro as ExtrudeFacesResult, sa as FitPrimitiveOptions, sn as DyntopoReport, so as DenoiseReport, ta as FfdBasisInput, tn as DistanceFieldDesc, tr as RegistrationReport, un as EditResult, uo as MeshHandle, vi as WrapOptions, vr as SectionGap, wa as PlaceMeshReport, wi as LatticeOptions, xa as PackedPointCloud, xn as GeodesicOptions, yi as WrapPlan, yo as Positions64, yr as SectionPlane, za as XpbdOptions, zr as SymmetryPlaneReport } from "./scene-like-Bx7lZKif.js";
|
|
2
|
+
import { l as PrimitiveMesh, u as PrimitiveShape } from "./primitives-6T0eQiSm.js";
|
|
3
|
+
import { t as FastMeshError } from "./core-CJ9D6U5A.js";
|
|
4
|
+
import "./protocol-Da0kmXuF.js";
|
|
5
|
+
/** What {@link WorkerScene} needs of a Worker; a browser `Worker` fits. */
|
|
6
|
+
interface WorkerLike {
|
|
7
|
+
postMessage(msg: unknown, transfer?: Transferable[]): void;
|
|
8
|
+
/** `"message"` events carry the message in `data`. */
|
|
9
|
+
addEventListener(type: "message" | "error" | "messageerror", cb: (e: any) => void): void;
|
|
10
|
+
terminate(): void;
|
|
11
|
+
}
|
|
12
|
+
/** Options of {@link createWorkerScene}. */
|
|
13
|
+
interface WorkerSceneOptions {
|
|
14
|
+
/**
|
|
15
|
+
* The Worker script, loaded as a module Worker. Defaults to the package's
|
|
16
|
+
* `worker-entry.js` next to this module, which bundlers pick up from the
|
|
17
|
+
* `new Worker(new URL(...), { type: "module" })` pattern.
|
|
18
|
+
*/
|
|
19
|
+
workerUrl?: string | URL;
|
|
20
|
+
/** Creates the Worker instead (overrides `workerUrl`). */
|
|
21
|
+
createWorker?: () => WorkerLike;
|
|
22
|
+
/**
|
|
23
|
+
* Development checks, off by default: render views are then `Proxy`
|
|
24
|
+
* objects that warn once when read after a mirror they view was replaced
|
|
25
|
+
* (a mesh's slot count changed, a buffer turned on or off, the mesh was
|
|
26
|
+
* removed). See {@link MeshViews}. Also logs, once per scene, why the
|
|
27
|
+
* engine runs single-threaded when more threads were asked for (as in
|
|
28
|
+
* development builds, where `import.meta.env.DEV` is set).
|
|
29
|
+
*/
|
|
30
|
+
debug?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The threads the engine computes with: its WebAssembly runs on a pool of
|
|
33
|
+
* this many Workers sharing its memory. Defaults to the logical cores
|
|
34
|
+
* (`navigator.hardwareConcurrency`), at most 8; `1` runs the
|
|
35
|
+
* single-threaded engine. Threads need a cross-origin isolated page
|
|
36
|
+
* (COOP/COEP headers); elsewhere, or when the threaded engine fails to
|
|
37
|
+
* start, the scene runs single-threaded. {@link WorkerScene.threads} tells
|
|
38
|
+
* which. An integer, clamped to 1 to {@link MAX_THREADS}.
|
|
39
|
+
*/
|
|
40
|
+
threads?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Meshes of at least this many triangles are added in the background:
|
|
43
|
+
* the Worker builds them in steps while the requests sent after them
|
|
44
|
+
* that do not need them run (toggles, edits, drags, queries of other
|
|
45
|
+
* meshes), so those do not wait for a large add. A request that names
|
|
46
|
+
* the new mesh (or a field measured to it), adds or removes a mesh, or
|
|
47
|
+
* queries every mesh waits for it, so the engine's state is the same as
|
|
48
|
+
* in arrival order; but a reply to an unrelated request sent after the
|
|
49
|
+
* add can arrive before the mesh, whose status reads `"computing"` (and
|
|
50
|
+
* whose views are empty) until it lands. Defaults to 65,536; `Infinity`
|
|
51
|
+
* turns background adds off, so every add comes back with its own
|
|
52
|
+
* batch's result. A number, 0 or more.
|
|
53
|
+
*/
|
|
54
|
+
backgroundAddTriangles?: number;
|
|
55
|
+
/**
|
|
56
|
+
* The most bytes the undo history may hold, as `Scene`'s `historyBudget`:
|
|
57
|
+
* 256 MiB by default. Change it later with
|
|
58
|
+
* {@link WorkerScene.setHistoryBudget}.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* const scene = await createWorkerScene({ historyBudget: 1024 ** 3 });
|
|
63
|
+
* scene.onPermanent(({ lost }) => {
|
|
64
|
+
* if (lost === "undo") {
|
|
65
|
+
* notify("That cannot be undone.");
|
|
66
|
+
* }
|
|
67
|
+
* });
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
historyBudget?: number;
|
|
71
|
+
}
|
|
72
|
+
/** The state of a request key, from {@link WorkerScene.status}. */
|
|
73
|
+
interface KeyStatus {
|
|
74
|
+
/**
|
|
75
|
+
* `"computing"` while a request with this key is queued or running,
|
|
76
|
+
* `"ready"` or `"error"` once the latest one finished, `"idle"` for a key
|
|
77
|
+
* never used, or one of a removed mesh, field or section once its removal
|
|
78
|
+
* has settled (its state is then forgotten).
|
|
79
|
+
*/
|
|
80
|
+
status: "idle" | "computing" | "ready" | "error";
|
|
81
|
+
/** The revision of the request the status is about (0 when idle). */
|
|
82
|
+
revision: number;
|
|
83
|
+
error?: FastMeshError;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Starts a Worker running the scene engine and resolves once it is ready.
|
|
87
|
+
* Rejects with `INSTANCE_POISONED` when the Worker could not load fast-mesh.
|
|
88
|
+
*/
|
|
89
|
+
declare function createWorkerScene(options?: WorkerSceneOptions): Promise<WorkerScene>;
|
|
90
|
+
/** The most threads {@link WorkerSceneOptions.threads} asks for; more are clamped. */
|
|
91
|
+
declare const MAX_THREADS = 64;
|
|
92
|
+
/**
|
|
93
|
+
* A scene whose engine runs in a Worker, from {@link createWorkerScene}. It
|
|
94
|
+
* mirrors `Scene` (always `"eager"`) with these differences:
|
|
95
|
+
*
|
|
96
|
+
* - Handles are returned synchronously; the Worker catches up in order.
|
|
97
|
+
* - State changes return `void` and are tracked by key through
|
|
98
|
+
* {@link WorkerScene.status}; calls that return data return promises.
|
|
99
|
+
* - Requests are sent once per frame by {@link WorkerScene.commitFrame},
|
|
100
|
+
* in call order, and "last wins" changes (colouring, section
|
|
101
|
+
* plane/meshes/fill, drag moves) superseded within the batch are dropped.
|
|
102
|
+
* Calls returning a promise wait for the next `commitFrame()` too, or are
|
|
103
|
+
* sent on their own after 100 ms when no frame comes;
|
|
104
|
+
* before the first `commitFrame()` (no frame loop) they are sent on the
|
|
105
|
+
* next microtask.
|
|
106
|
+
* - `views`, `placement`, `matrix4`, `section` and `sectionPlane` read
|
|
107
|
+
* main-thread mirrors, updated as results arrive and reported by the next
|
|
108
|
+
* `commitFrame()`. Views follow the same fresh-view rule as `Scene`: get
|
|
109
|
+
* them right before use. A mesh has 0 slots until its add is processed.
|
|
110
|
+
* - Drags are optimistic: `move` shows the pose at once, `end` and `cancel`
|
|
111
|
+
* are synchronous here, and the pose is held until the Worker has the drag.
|
|
112
|
+
* - {@link WorkerScene.restart} replaces the Worker and replays the scene
|
|
113
|
+
* into it (the way back from `INSTANCE_POISONED`); handles keep working.
|
|
114
|
+
* Unlike other promise calls, its replay is sent at once, not with the
|
|
115
|
+
* next `commitFrame()`.
|
|
116
|
+
*/
|
|
117
|
+
declare class WorkerScene implements SceneLike {
|
|
118
|
+
#private;
|
|
119
|
+
/**
|
|
120
|
+
* Callable async repair domain (`worker.repair(mesh, op)` and `worker.repair.<method>(...)`).
|
|
121
|
+
*/
|
|
122
|
+
readonly repair: WorkerRepairDomain;
|
|
123
|
+
/**
|
|
124
|
+
* Callable async sculpt domain (`worker.sculpt(mesh, op)` and `worker.sculpt.<method>(...)`).
|
|
125
|
+
*/
|
|
126
|
+
readonly sculpt: WorkerSculptDomain;
|
|
127
|
+
/** Async remesh, simplification, subdivision, and volumetric reconstruction domain. */
|
|
128
|
+
readonly remesh: WorkerRemeshDomain;
|
|
129
|
+
/** Callable async boolean, CSG batch, cut, curve-trim, offset, and shell domain. */
|
|
130
|
+
readonly boolean: WorkerBooleanDomain;
|
|
131
|
+
/** Async surface deformation and vertex-protection domain. */
|
|
132
|
+
readonly deform: WorkerDeformDomain;
|
|
133
|
+
/** Async defect analysis, printability/quality inspection, metrology, geodesics, queries, fields, and section domain. */
|
|
134
|
+
readonly inspect: WorkerInspectDomain;
|
|
135
|
+
/** Async rigid registration, multi-stage alignment, landmark SVD, and symmetry domain. */
|
|
136
|
+
readonly align: WorkerAlignDomain;
|
|
137
|
+
/** Use {@link createWorkerScene}. */
|
|
138
|
+
private constructor();
|
|
139
|
+
/**
|
|
140
|
+
* Adds a mesh from world positions and returns its handle at once. The
|
|
141
|
+
* origin defaults to the bounding-box centre, computed here. The mesh has
|
|
142
|
+
* no slots until the Worker has added it; a failed add shows as an error
|
|
143
|
+
* on `status("mesh:<id>")`, and later calls on it fail with `UNKNOWN_MESH`.
|
|
144
|
+
*
|
|
145
|
+
* A mesh of {@link WorkerSceneOptions.backgroundAddTriangles} triangles or
|
|
146
|
+
* more (65,536 by default) is added in the background: requests sent after
|
|
147
|
+
* it that do not need it run meanwhile, so a reply to one of them can
|
|
148
|
+
* arrive before the mesh. Until it lands, `status("mesh:<id>")` reads
|
|
149
|
+
* `"computing"` and its views are empty; its buffers arrive with that
|
|
150
|
+
* status turning `"ready"`. An `undoable` add is never in the background:
|
|
151
|
+
* it lands in the step it was made in, and undo removes the mesh again.
|
|
152
|
+
*/
|
|
153
|
+
addMesh(positions: Positions64, indices: Indices, options?: Pick<AddMeshOptions, "origin" | "normals" | "uvs" | "undoable">): MeshHandle;
|
|
154
|
+
/**
|
|
155
|
+
* Removes a mesh, ending an active drag of it first. Later calls on it give
|
|
156
|
+
* `UNKNOWN_MESH`; its mirrors stay readable until the removal is delivered
|
|
157
|
+
* by `commitFrame()`.
|
|
158
|
+
*
|
|
159
|
+
* With `undoable` the removal is an undo step (or part of the open one):
|
|
160
|
+
* {@link WorkerScene.undo} brings the mesh back with the same handle, as
|
|
161
|
+
* `Scene.removeMesh` does. A {@link WorkerScene.restart} clears the history,
|
|
162
|
+
* so it makes the removal permanent, and so does one larger than the
|
|
163
|
+
* history budget: {@link WorkerScene.onPermanent} tells once the result is
|
|
164
|
+
* in, and {@link WorkerScene.removalBytes} before.
|
|
165
|
+
*/
|
|
166
|
+
removeMesh(mesh: MeshHandle, options?: RemoveMeshOptions): void;
|
|
167
|
+
/**
|
|
168
|
+
* Whether the scene has `mesh`: `false` once its removal is requested, or
|
|
169
|
+
* a result says that the undo of its add (or the redo of its removal) took
|
|
170
|
+
* it out.
|
|
171
|
+
*/
|
|
172
|
+
has(mesh: MeshHandle): boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Whether undo or redo can still bring back a removed `mesh`, as of the
|
|
175
|
+
* latest result (see `Scene.isRestorable`).
|
|
176
|
+
*/
|
|
177
|
+
isRestorable(mesh: MeshHandle): boolean;
|
|
178
|
+
/** About the bytes of history an undoable removal of `mesh` takes; see `Scene.removalBytes`. */
|
|
179
|
+
removalBytes(mesh: MeshHandle): Promise<number>;
|
|
180
|
+
/**
|
|
181
|
+
* Joins `source` into `target`; see `Scene.join`. The source stays usable
|
|
182
|
+
* until the join lands: only a successful result removes it (a failed join
|
|
183
|
+
* changes nothing, engine-side or here), as part of the join's undo step.
|
|
184
|
+
* {@link WorkerScene.undo} brings it back.
|
|
185
|
+
*
|
|
186
|
+
* @deprecated Use `workerScene.repair.join()` instead.
|
|
187
|
+
*/
|
|
188
|
+
join(target: MeshHandle, source: MeshHandle, options: JoinOptions): Promise<JoinReport>;
|
|
189
|
+
/**
|
|
190
|
+
* Rigidly aligns `moving` to `fixed` by ICP from their placements as the
|
|
191
|
+
* Worker has them when the request runs; see `Scene.register`. An applied
|
|
192
|
+
* result reaches `placement()` with its batch, like a `setPlacement`.
|
|
193
|
+
* Not replayed by a restart: an unanswered one rejects with
|
|
194
|
+
* `INSTANCE_POISONED`, like an edit.
|
|
195
|
+
*
|
|
196
|
+
* @deprecated Use `workerScene.align.register()` instead.
|
|
197
|
+
*/
|
|
198
|
+
register(moving: MeshHandle, fixed: MeshHandle, options?: RegisterOptions): Promise<RegisterResult>;
|
|
199
|
+
/**
|
|
200
|
+
* Aligns `moving` to `fixed` using corresponding world-space landmark pairs
|
|
201
|
+
* via Umeyama N-point SVD (see `Scene.alignByLandmarks`).
|
|
202
|
+
*/
|
|
203
|
+
alignByLandmarks(moving: MeshHandle, fixed: MeshHandle, pairs: readonly LandmarkPair[], allowScaling?: boolean): Promise<LandmarkAlignment>;
|
|
204
|
+
/**
|
|
205
|
+
* Runs multi-stage coarse + fine ICP registration from `moving` to `fixed`
|
|
206
|
+
* (see `Scene.registerMultistage`).
|
|
207
|
+
*/
|
|
208
|
+
registerMultistage(moving: MeshHandle, fixed: MeshHandle, options?: RegistrationOptions): Promise<RegistrationReport>;
|
|
209
|
+
/** Detects the dominant world-space reflection symmetry plane of `mesh`. */
|
|
210
|
+
detectSymmetryPlane(mesh: MeshHandle): Promise<SymmetryPlaneReport>;
|
|
211
|
+
/** Evaluates an N-ary CSG boolean tree in the Worker and returns the new mesh handle. */
|
|
212
|
+
booleanBatch(meshes: readonly MeshHandle[], tree: CsgNode, options?: BooleanOptions): Promise<MeshHandle>;
|
|
213
|
+
booleanBatch(tree: CsgNode, options?: BooleanOptions): Promise<MeshHandle>;
|
|
214
|
+
/** Cuts `mesh` by `plane` in the Worker (see `Scene.cutByPlane`). */
|
|
215
|
+
cutByPlane(mesh: MeshHandle, plane: SectionPlane, options?: CutOptions): Promise<CutReport>;
|
|
216
|
+
/**
|
|
217
|
+
* Conformatively imprints a world-space polyline onto `mesh` and optionally
|
|
218
|
+
* deletes one side of the loop from the component it lies on: see
|
|
219
|
+
* `Scene.trimByCurve`.
|
|
220
|
+
*/
|
|
221
|
+
trimByCurve(mesh: MeshHandle, options: TrimCurveOptions): Promise<TrimReport>;
|
|
222
|
+
trimByCurve(mesh: MeshHandle, curve: readonly (Readonly<Vec3> | SurfacePathPoint)[], options?: Omit<TrimCurveOptions, "points">): Promise<TrimReport>;
|
|
223
|
+
/** Fills a single boundary loop with selectable G0/G1/G2 continuity. */
|
|
224
|
+
fillHoleContinuity(mesh: MeshHandle, loopIndex: number, options?: FillHolesContinuityOptions): Promise<FillContinuityStats>;
|
|
225
|
+
/** Fills all eligible holes with selectable G0/G1/G2 continuity. */
|
|
226
|
+
fillAllHolesContinuity(mesh: MeshHandle, options?: FillHolesContinuityOptions): Promise<FillContinuityStats>;
|
|
227
|
+
/** Bridges two boundary vertex arcs or index ranges. */
|
|
228
|
+
bridgePartialArcs(mesh: MeshHandle, loopA?: Indices, loopB?: Indices, options?: PartialBridgeOptions): Promise<BridgeStats>;
|
|
229
|
+
/** Runs localized dynamic topology remeshing inside sphere `(center, radius)`. */
|
|
230
|
+
applyDyntopo(mesh: MeshHandle, center: Readonly<Vec3>, radius: number, options?: DyntopoOptions, pinned?: Indices): Promise<DyntopoReport>;
|
|
231
|
+
/** Applies localized dynamic topology remeshing followed by a brush dab. */
|
|
232
|
+
dyntopoDab(mesh: MeshHandle, dab: SculptBrushOp, options?: DyntopoOptions, protection?: VertexProtection): Promise<DyntopoDabReport>;
|
|
233
|
+
/**
|
|
234
|
+
* Sets a mesh's placement (one undo step), scale included (`[1, 1, 1]`
|
|
235
|
+
* when omitted); `placement()` follows when the result arrives.
|
|
236
|
+
*/
|
|
237
|
+
setPlacement(mesh: MeshHandle, placement: PlacementInput): void;
|
|
238
|
+
/** The mesh's placement as mirrored, scale always present (a drag's pose while it is held). */
|
|
239
|
+
placement(mesh: MeshHandle): Placement;
|
|
240
|
+
/** The column-major world matrix of the mesh's local render coordinates, as mirrored. */
|
|
241
|
+
matrix4(mesh: MeshHandle): Float64Array;
|
|
242
|
+
/**
|
|
243
|
+
* The box around the vertices the live triangles use, in the mesh's local
|
|
244
|
+
* render coordinates, mirrored from the Worker. `null` without live triangles.
|
|
245
|
+
*/
|
|
246
|
+
bounds(mesh: MeshHandle): Bounds | null;
|
|
247
|
+
/**
|
|
248
|
+
* The mirrors of the mesh's render buffers, at full slot length. Each
|
|
249
|
+
* getter returns the current mirror; a mirror is replaced when the slot
|
|
250
|
+
* count changes or a buffer turns on or off, so get views right before use.
|
|
251
|
+
*/
|
|
252
|
+
/**
|
|
253
|
+
* The mesh's origin. `views(mesh).positions()` are relative to it, while
|
|
254
|
+
* `edit`'s `setPositions` and `addVertices` take positions with it added.
|
|
255
|
+
*/
|
|
256
|
+
origin(mesh: MeshHandle): Vec3;
|
|
257
|
+
views(mesh: MeshHandle): SceneMeshViews;
|
|
258
|
+
/**
|
|
259
|
+
* The rule the mirrored colours and values are made by (a frozen copy of
|
|
260
|
+
* the one given to `setColoring`, the same object until another rule is
|
|
261
|
+
* applied), or `null` without colouring. It follows the
|
|
262
|
+
* results: a new rule shows with the batch that applies it, a rejected one
|
|
263
|
+
* never, and a removed field's colouring goes when the removal is applied.
|
|
264
|
+
*/
|
|
265
|
+
coloring(mesh: MeshHandle): ColorRule | null;
|
|
266
|
+
/**
|
|
267
|
+
* Starts an optimistic drag. `move` shows the pose here at once and sends
|
|
268
|
+
* at most one move per batch; `end` and `cancel` are synchronous here.
|
|
269
|
+
* `cancel` puts the start pose back and records nothing.
|
|
270
|
+
*/
|
|
271
|
+
drag(mesh: MeshHandle): DragSession;
|
|
272
|
+
/** Edits a mesh's geometry (one undo step); resolves with the ids added. */
|
|
273
|
+
edit(mesh: MeshHandle, ops: readonly EditOp[]): Promise<EditResult>;
|
|
274
|
+
/** Compacts a mesh's slots (its slot counts change). */
|
|
275
|
+
compact(mesh: MeshHandle): void;
|
|
276
|
+
/**
|
|
277
|
+
* A report of the mesh's defects; see `Scene.analyze`.
|
|
278
|
+
*
|
|
279
|
+
* @deprecated Use `workerScene.inspect.analyze()` or `workerScene.repair.analyze()` instead.
|
|
280
|
+
*/
|
|
281
|
+
analyze(mesh: MeshHandle, options?: AnalyzeOptions): Promise<Analysis>;
|
|
282
|
+
/**
|
|
283
|
+
* Scalar measurements of a mesh; see `Scene.measure`.
|
|
284
|
+
*
|
|
285
|
+
* @deprecated Use `workerScene.inspect.measure()` instead.
|
|
286
|
+
*/
|
|
287
|
+
measure(mesh: MeshHandle): Promise<MeasureResult>;
|
|
288
|
+
/**
|
|
289
|
+
* Live triangle-used vertex ids of `mesh` inside the closed local-space
|
|
290
|
+
* sphere `(center, radius)`, in ascending order; see `Scene.verticesInSphere`.
|
|
291
|
+
*
|
|
292
|
+
* @deprecated Use `workerScene.sculpt.verticesInSphere()` instead.
|
|
293
|
+
*/
|
|
294
|
+
verticesInSphere(mesh: MeshHandle, center: Readonly<Vec3>, radius: number): Promise<Uint32Array>;
|
|
295
|
+
/** Evaluates world-space printability overhangs against `buildDirection` (see `Scene.overhangs`). */
|
|
296
|
+
overhangs(mesh: MeshHandle, options?: OverhangOptions): Promise<OverhangReport>;
|
|
297
|
+
/** Computes per-triangle geometric quality and worst-incident vertex quality (see `Scene.triangleQuality`). */
|
|
298
|
+
triangleQuality(mesh: MeshHandle, metricOrOptions?: QualityMetric | TriangleQualityOptions, sliverThreshold?: number): Promise<QualityReport>;
|
|
299
|
+
/** Computes vertex-wise Hausdorff or signed distance deviation from `source` to `target`. */
|
|
300
|
+
meshDeviation(source: MeshHandle, target: MeshHandle, options?: DeviationOptions): Promise<DeviationStats>;
|
|
301
|
+
/**
|
|
302
|
+
* Computes geodesic surface distances from `sources` on `mesh` (`"dijkstra"`
|
|
303
|
+
* or `"heatMethod"`), in steps on the Worker: `options.signal` cancels the
|
|
304
|
+
* query. Other requests wait for it.
|
|
305
|
+
*/
|
|
306
|
+
geodesicDistances(mesh: MeshHandle, sources: number | readonly number[], options?: GeodesicOptions): Promise<Float32Array>;
|
|
307
|
+
/** Frees what `"heatMethod"` queries keep in the Worker for the next one of the same mesh. */
|
|
308
|
+
releaseGeodesics(): Promise<void>;
|
|
309
|
+
/**
|
|
310
|
+
* Traces an intrinsic shortest path along the surface of `mesh` to
|
|
311
|
+
* `targetVertex`. Without `options.distances` it computes them first, like
|
|
312
|
+
* {@link WorkerScene.geodesicDistances}: `options.signal` cancels that.
|
|
313
|
+
*/
|
|
314
|
+
shortestSurfacePath(mesh: MeshHandle, sources: number | readonly number[], targetVertex: number, options?: SurfacePathOptions): Promise<SurfacePathPoint[]>;
|
|
315
|
+
selectFacesScreen(mesh: MeshHandle, shape: ScreenSelectionShape, options: ScreenSelectOptions): Promise<Uint32Array>;
|
|
316
|
+
selectFacesInSphere(mesh: MeshHandle, center: Readonly<Vec3>, radius: number, normalCone?: FaceSelectionNormalCone): Promise<Uint32Array>;
|
|
317
|
+
selectByCreaseAngle(mesh: MeshHandle, seedTri: number, maxDihedralRad: number): Promise<Uint32Array>;
|
|
318
|
+
selectConnectedShell(mesh: MeshHandle, seedTri: number): Promise<Uint32Array>;
|
|
319
|
+
selectSmallFaceIslands(mesh: MeshHandle, maxFaceCount: number, maxArea?: number): Promise<Uint32Array>;
|
|
320
|
+
growFaceSelection(mesh: MeshHandle, selectedTris: Indices, rings?: number, adjacency?: AdjacencyKind): Promise<Uint32Array>;
|
|
321
|
+
shrinkFaceSelection(mesh: MeshHandle, selectedTris: Indices, rings?: number, adjacency?: AdjacencyKind): Promise<Uint32Array>;
|
|
322
|
+
fillSelectionHoles(mesh: MeshHandle, selectedTris: Indices, maxHoleTris: number): Promise<Uint32Array>;
|
|
323
|
+
smoothSelectionBoundary(mesh: MeshHandle, selectedTris: Indices, iterations?: number): Promise<Uint32Array>;
|
|
324
|
+
faceSelectionToVertexMask(mesh: MeshHandle, selectedTris: Indices): Promise<Float32Array>;
|
|
325
|
+
vertexMaskToFaceSelection(mesh: MeshHandle, mask: Float32Array | ArrayLike<number>, threshold?: number, requireAllVertices?: boolean): Promise<Uint32Array>;
|
|
326
|
+
deleteSelectedFaces(mesh: MeshHandle, selectedTris: Indices): Promise<FaceEditReport>;
|
|
327
|
+
/** Extrudes a face selection in the Worker, one undo step (see `Scene.extrudeFaces`). */
|
|
328
|
+
extrudeFaces(mesh: MeshHandle, triangles: Indices, options: ExtrudeFacesOptions): Promise<ExtrudeFacesResult>;
|
|
329
|
+
/** Extrudes a mesh's boundary to a flat base in the Worker, one undo step (see `Scene.extrudeBase`). */
|
|
330
|
+
extrudeBase(mesh: MeshHandle, options: ExtrudeBaseOptions): Promise<ExtrudeBaseResult>;
|
|
331
|
+
extractSelectedFaces(mesh: MeshHandle, selectedTris: Indices, options?: {
|
|
332
|
+
normals?: boolean;
|
|
333
|
+
}): Promise<MeshHandle>;
|
|
334
|
+
splitSelectedFaces(mesh: MeshHandle, selectedTris: Indices, options?: {
|
|
335
|
+
normals?: boolean;
|
|
336
|
+
}): Promise<SplitFacesReport>;
|
|
337
|
+
buildFfdLattice(mesh: MeshHandle, dims: readonly [number, number, number], basis?: FfdBasisInput, padding?: number): Promise<FfdLatticeData>;
|
|
338
|
+
applyFfd(mesh: MeshHandle, options: FfdOptions): Promise<FreeformReport>;
|
|
339
|
+
applyArap(mesh: MeshHandle, options: ArapOptions): Promise<FreeformReport>;
|
|
340
|
+
applyKelvinlet(mesh: MeshHandle, options: KelvinletOptions): Promise<FreeformReport>;
|
|
341
|
+
applyXpbd(mesh: MeshHandle, options: XpbdOptions): Promise<FreeformReport>;
|
|
342
|
+
setDefaultCollisionRule(rule: CollisionRuleInput): void;
|
|
343
|
+
defaultCollisionRule(): CollisionRule;
|
|
344
|
+
setCollisionRule(a: MeshHandle, b: MeshHandle, rule: CollisionRuleInput): void;
|
|
345
|
+
clearCollisionRule(a: MeshHandle, b: MeshHandle): boolean;
|
|
346
|
+
collisionRule(a: MeshHandle, b: MeshHandle): CollisionRule;
|
|
347
|
+
hasActiveCollisionResponse(mesh: MeshHandle): boolean;
|
|
348
|
+
moveWithCollision(mesh: MeshHandle, placement: PlacementInput, isRelease?: boolean): Promise<CollisionStepReport>;
|
|
349
|
+
commitCollisionInteraction(mesh: MeshHandle): Promise<CollisionStepReport>;
|
|
350
|
+
fitPrimitive(mesh: MeshHandle, options?: FitPrimitiveOptions): Promise<FittedPrimitiveReport>;
|
|
351
|
+
alignToFittedPrimitive(mesh: MeshHandle, primitive: FittedPrimitive, targetAxis: Readonly<Vec3>, targetOrigin: Readonly<Vec3>): Promise<Placement>;
|
|
352
|
+
sliceContours(mesh: MeshHandle, origin: Readonly<Vec3>, normal: Readonly<Vec3>): Promise<ContourSlice>;
|
|
353
|
+
sliceContourStack(mesh: MeshHandle, origin: Readonly<Vec3>, normal: Readonly<Vec3>, spacing: number, count: number): Promise<ContourSlice[]>;
|
|
354
|
+
/**
|
|
355
|
+
* Adds the convex hull of `meshes` (one mesh or several) in the Worker as a
|
|
356
|
+
* new mesh, one undo step (see `Scene.convexHull`).
|
|
357
|
+
*/
|
|
358
|
+
convexHull(meshes: MeshHandle | readonly MeshHandle[], options?: ConvexHullOptions): Promise<ConvexHullResult>;
|
|
359
|
+
/**
|
|
360
|
+
* Adds the convex hull of world `points` in the Worker as a new mesh, one
|
|
361
|
+
* undo step (see `Scene.convexHullOfPoints`). The points are copied.
|
|
362
|
+
*/
|
|
363
|
+
convexHullOfPoints(points: ConvexHullPoints, options?: ConvexHullOptions): Promise<ConvexHullResult>;
|
|
364
|
+
/** Fits a height map's frame to `meshes` (one mesh or several) in the Worker (see `Scene.heightMapFrame`). */
|
|
365
|
+
heightMapFrame(meshes: MeshHandle | readonly MeshHandle[], options?: HeightMapOptions): Promise<HeightMapFrame>;
|
|
366
|
+
/**
|
|
367
|
+
* An orthographic depth image of `meshes` (one mesh or several), sampled in
|
|
368
|
+
* the Worker and transferred (see `Scene.heightMap`). Asking for bands of
|
|
369
|
+
* `rows` lets other requests run in between them.
|
|
370
|
+
*/
|
|
371
|
+
heightMap(meshes: MeshHandle | readonly MeshHandle[], frame?: HeightMapFrame | HeightMapOptions, rows?: readonly [number, number]): Promise<HeightMap>;
|
|
372
|
+
/**
|
|
373
|
+
* Adds the relief of a grid of heights in the Worker as a new mesh, one undo
|
|
374
|
+
* step (see `Scene.addHeightfield`). The heights are copied here and
|
|
375
|
+
* transferred; the mesh itself comes back only as the mirror's buffers.
|
|
376
|
+
*/
|
|
377
|
+
addHeightfield(field: Heightfield, options?: AddHeightfieldOptions): Promise<HeightfieldResult>;
|
|
378
|
+
/** Smooths noise out of `mesh` in the Worker, one undo step (see `Scene.denoise`). */
|
|
379
|
+
denoise(mesh: MeshHandle, options?: DenoiseOptions): Promise<DenoiseReport>;
|
|
380
|
+
/** Flips `mesh`'s edges towards Delaunay in the Worker, one undo step (see `Scene.delaunayFlips`). */
|
|
381
|
+
delaunayFlips(mesh: MeshHandle, options?: DelaunayFlipOptions): Promise<DelaunayFlipReport>;
|
|
382
|
+
/**
|
|
383
|
+
* Plans the voxel grid of {@link WorkerScene.wrap} for the same meshes and
|
|
384
|
+
* options without running it (see `Scene.wrapPlan`).
|
|
385
|
+
*/
|
|
386
|
+
wrapPlan(meshes: MeshHandle | readonly MeshHandle[], options?: WrapGridOptions): Promise<WrapPlan>;
|
|
387
|
+
/**
|
|
388
|
+
* Wraps `meshes` (one mesh or several) in one closed, manifold envelope in
|
|
389
|
+
* the Worker, added as a new mesh, one undo step (see `Scene.wrap`). The
|
|
390
|
+
* page stays live while it runs.
|
|
391
|
+
*/
|
|
392
|
+
wrap(meshes: MeshHandle | readonly MeshHandle[], options?: WrapOptions): Promise<WrapResult>;
|
|
393
|
+
reconstructPointCloud(cloud: PackedPointCloud | Float32Array, options?: SurfaceReconstructOptions): Promise<MeshHandle>;
|
|
394
|
+
hollowMesh(mesh: MeshHandle, options: HollowOptions): Promise<HollowReport>;
|
|
395
|
+
/**
|
|
396
|
+
* Plans the voxel grid of {@link WorkerScene.latticeFill} for the same mesh
|
|
397
|
+
* and options without running it (see `Scene.latticePlan`).
|
|
398
|
+
*/
|
|
399
|
+
latticePlan(mesh: MeshHandle, options: LatticeOptions): Promise<LatticePlan>;
|
|
400
|
+
/**
|
|
401
|
+
* Fills the inside of a closed mesh, or the cavity of a hollowed one, with a
|
|
402
|
+
* lattice in the Worker, one undo step (see `Scene.latticeFill`). The page
|
|
403
|
+
* stays live while it runs.
|
|
404
|
+
*/
|
|
405
|
+
latticeFill(mesh: MeshHandle, options: LatticeOptions): Promise<LatticeReport>;
|
|
406
|
+
/**
|
|
407
|
+
* The walls of a lattice on a small grid, built in the Worker without
|
|
408
|
+
* changing the mesh (see `Scene.latticePreview`).
|
|
409
|
+
*/
|
|
410
|
+
latticePreview(mesh: MeshHandle, options: LatticeOptions): Promise<LatticePreview>;
|
|
411
|
+
punchDrainHole(mesh: MeshHandle, options: DrainHoleOptions): Promise<DrainHoleReport>;
|
|
412
|
+
placeMesh(target: MeshHandle, stamp: MeshHandle, options: PlaceMeshOptions): Promise<PlaceMeshReport>;
|
|
413
|
+
/** Undoes the latest step; an active drag is ended first. */
|
|
414
|
+
undo(): void;
|
|
415
|
+
/** Redoes the latest undone step; an active drag is ended first. */
|
|
416
|
+
redo(): void;
|
|
417
|
+
/** Closes an open step and drops every undo and redo step. */
|
|
418
|
+
clearHistory(): void;
|
|
419
|
+
/**
|
|
420
|
+
* Records an entry of the application's own in the history, after the
|
|
421
|
+
* requests before it; see `Scene.recordEntry`. Its functions run here, on
|
|
422
|
+
* this thread, as the result that undid, redid or dropped it is applied:
|
|
423
|
+
* after the mirrors and before the promises the result settles and the
|
|
424
|
+
* change records of the next {@link WorkerScene.commitFrame}.
|
|
425
|
+
*
|
|
426
|
+
* The history's order is that of the calls, whatever is in flight: an
|
|
427
|
+
* `undo()` undoes what was recorded last when it was called, and the engine
|
|
428
|
+
* says what that was. An entry recorded while an `undo()` or `redo()` is in
|
|
429
|
+
* flight comes after it, and the undone entries' functions then run around
|
|
430
|
+
* it (its `undo` before them, its `redo` after), so that every function
|
|
431
|
+
* finds the application as the history has it. An entry that could not be
|
|
432
|
+
* recorded is dropped, and so is every entry by a
|
|
433
|
+
* {@link WorkerScene.restart}, which clears the history.
|
|
434
|
+
*
|
|
435
|
+
* @throws `INVALID_ARGUMENT` for an entry without `undo` and `redo`, or with
|
|
436
|
+
* bytes below 0.
|
|
437
|
+
*/
|
|
438
|
+
recordEntry(entry: HistoryEntry): void;
|
|
439
|
+
/** The most bytes the history may hold, as last set here. */
|
|
440
|
+
get historyBudget(): number;
|
|
441
|
+
/**
|
|
442
|
+
* Changes the most bytes the history may hold, after the requests before
|
|
443
|
+
* it; see `Scene.setHistoryBudget`. A {@link WorkerScene.restart} keeps it.
|
|
444
|
+
*
|
|
445
|
+
* @throws `INVALID_ARGUMENT` for anything but a number, 0 or more.
|
|
446
|
+
*/
|
|
447
|
+
setHistoryBudget(bytes: number): void;
|
|
448
|
+
/** The bytes the history holds, as of the latest result. */
|
|
449
|
+
get historyBytes(): number;
|
|
450
|
+
/**
|
|
451
|
+
* Registers a listener called with each step the history could not keep
|
|
452
|
+
* (an action that is permanent, or one that cannot be redone), as its
|
|
453
|
+
* result is applied, before the promises it settles; see
|
|
454
|
+
* `Scene.onPermanent`. Returns the function that removes it.
|
|
455
|
+
*/
|
|
456
|
+
onPermanent(listener: PermanentListener): () => void;
|
|
457
|
+
/**
|
|
458
|
+
* Opens a history step, or one more nesting level of the open one. Edits,
|
|
459
|
+
* repairs, and placement changes until the matching {@link WorkerScene.endStep}
|
|
460
|
+
* are coalesced into a single undo entry.
|
|
461
|
+
*/
|
|
462
|
+
beginStep(): void;
|
|
463
|
+
/** Ends one nesting level of the open step. Throws `STEP_NOT_OPEN` when none is open. */
|
|
464
|
+
endStep(): void;
|
|
465
|
+
/** Reverts and discards the open step, however deeply nested. Throws `STEP_NOT_OPEN` when none is open. */
|
|
466
|
+
cancelStep(): void;
|
|
467
|
+
/**
|
|
468
|
+
* The threads the engine computes with: more than 1 when the threaded
|
|
469
|
+
* engine runs (see {@link WorkerSceneOptions.threads}), 1 when
|
|
470
|
+
* single-threaded. As of the current Worker's start (1 until it is ready).
|
|
471
|
+
*/
|
|
472
|
+
get threads(): number;
|
|
473
|
+
/** Whether there is a step to undo, as of the latest result. */
|
|
474
|
+
get canUndo(): boolean;
|
|
475
|
+
/** Whether there is a step to redo, as of the latest result. */
|
|
476
|
+
get canRedo(): boolean;
|
|
477
|
+
/**
|
|
478
|
+
* Generates a primitive shape in the Worker, as the standalone
|
|
479
|
+
* `generatePrimitive` does on a thread with the module initialised; the
|
|
480
|
+
* buffers are transferred back, and the scene is not touched. The shape is
|
|
481
|
+
* checked by type here, its ranges in the Worker.
|
|
482
|
+
*
|
|
483
|
+
* @throws (rejects) `INVALID_ARGUMENT` for an unknown kind or a parameter
|
|
484
|
+
* out of range; `OUT_OF_MEMORY` when the buffers cannot be allocated.
|
|
485
|
+
*/
|
|
486
|
+
generatePrimitive(shape: PrimitiveShape): Promise<PrimitiveMesh>;
|
|
487
|
+
/**
|
|
488
|
+
* Generates the relief of a grid of heights in the Worker, as the standalone
|
|
489
|
+
* `generateHeightfield` does on a thread with the module initialised; the
|
|
490
|
+
* buffers are transferred back, and the scene is not touched.
|
|
491
|
+
*
|
|
492
|
+
* @throws (rejects) `INVALID_ARGUMENT` for a grid out of range;
|
|
493
|
+
* `OUT_OF_MEMORY` when the buffers cannot be allocated.
|
|
494
|
+
*/
|
|
495
|
+
generateHeightfield(field: Heightfield): Promise<PrimitiveMesh>;
|
|
496
|
+
/**
|
|
497
|
+
* Adds a signed distance field; see `Scene.addDistanceField`.
|
|
498
|
+
*
|
|
499
|
+
* @deprecated Use `workerScene.inspect.addDistanceField()` instead.
|
|
500
|
+
*/
|
|
501
|
+
addDistanceField(desc: DistanceFieldDesc): FieldHandle;
|
|
502
|
+
/** Removes a field, and a colouring by it. */
|
|
503
|
+
removeField(field: FieldHandle): void;
|
|
504
|
+
/**
|
|
505
|
+
* Colours a mesh from one of its fields, or turns colouring off with
|
|
506
|
+
* `null`. Last wins: of several calls for a mesh in one frame, only the
|
|
507
|
+
* last is sent. Tracked by `status("display:<id>")`.
|
|
508
|
+
*/
|
|
509
|
+
setColoring(mesh: MeshHandle, rule: ColorRule | null): void;
|
|
510
|
+
/** A copy of the field's values as of its last update, one per vertex slot. */
|
|
511
|
+
fetchFieldValues(field: FieldHandle): Promise<Float32Array>;
|
|
512
|
+
/**
|
|
513
|
+
* The field's nearest-target indices as of its last update (the index in
|
|
514
|
+
* its `to`, `0xffffffff` for none); see `Scene.fieldNearest`. A target
|
|
515
|
+
* removed since shifts the later indices down.
|
|
516
|
+
*/
|
|
517
|
+
fetchFieldNearest(field: FieldHandle): Promise<Uint32Array>;
|
|
518
|
+
/** What the sign data found out about each of the field's targets; see `Scene.fieldTargetStatus`. */
|
|
519
|
+
fieldTargetStatus(field: FieldHandle): Promise<FieldStatus["sign"][]>;
|
|
520
|
+
/**
|
|
521
|
+
* Whether the field is current, and what its sign data found out about the
|
|
522
|
+
* targets together; see `Scene.fieldStatus`.
|
|
523
|
+
*/
|
|
524
|
+
fieldStatus(field: FieldHandle): Promise<FieldStatus>;
|
|
525
|
+
/** Adds a plane section; its results arrive with the next results. */
|
|
526
|
+
addSection(desc: SectionDesc): SectionHandle;
|
|
527
|
+
/** Moves a section's plane; `sectionPlane()` returns it at once. Last wins per frame. */
|
|
528
|
+
setSectionPlane(section: SectionHandle, plane: SectionPlane): void;
|
|
529
|
+
/**
|
|
530
|
+
* Starts (`points`) or ends (`null`) an interaction; see
|
|
531
|
+
* {@link Scene.setFieldInteraction}. A recompute under way when it changes
|
|
532
|
+
* is dropped and starts over under the new setting.
|
|
533
|
+
*/
|
|
534
|
+
setFieldInteraction(points: number | null): void;
|
|
535
|
+
/** Changes the meshes a section cuts. Last wins per frame. */
|
|
536
|
+
setSectionMeshes(section: SectionHandle, meshes: readonly MeshHandle[]): void;
|
|
537
|
+
/** Turns a section's fill on or off. Last wins per frame. */
|
|
538
|
+
setSectionFill(section: SectionHandle, fill: boolean): void;
|
|
539
|
+
/** Removes a section. Its handle then gives `UNKNOWN_SECTION`. */
|
|
540
|
+
removeSection(section: SectionHandle): void;
|
|
541
|
+
/**
|
|
542
|
+
* The section's latest result for a mesh as mirrored (empty and `"stale"`
|
|
543
|
+
* until the first arrives). Do not modify it.
|
|
544
|
+
*
|
|
545
|
+
* @throws `INVALID_ARGUMENT` when the section does not cut `mesh`.
|
|
546
|
+
*/
|
|
547
|
+
section(section: SectionHandle, mesh: MeshHandle): SectionResult;
|
|
548
|
+
/** The section's plane as last set here, the normal normalised. */
|
|
549
|
+
sectionPlane(section: SectionHandle): SectionPlane;
|
|
550
|
+
/** The closest pair between two meshes' contours in a section; see `Scene.sectionGap`. */
|
|
551
|
+
sectionGap(section: SectionHandle, a: MeshHandle, b: MeshHandle): Promise<SectionGap | null>;
|
|
552
|
+
/**
|
|
553
|
+
* The nearest hit of a world ray over every mesh, or `null`; see `Scene.raycast`.
|
|
554
|
+
*
|
|
555
|
+
* @deprecated Use `workerScene.inspect.raycast()` instead.
|
|
556
|
+
*/
|
|
557
|
+
raycast(origin: Readonly<Vec3>, direction: Readonly<Vec3>, options?: RaycastOptions): Promise<RayHit | null>;
|
|
558
|
+
/**
|
|
559
|
+
* The surface point nearest to a world point, or `null`; see `Scene.closestPoint`.
|
|
560
|
+
*
|
|
561
|
+
* @deprecated Use `workerScene.inspect.closestPoint()` instead.
|
|
562
|
+
*/
|
|
563
|
+
closestPoint(point: Readonly<Vec3>, options?: ClosestPointOptions): Promise<ClosestHit | null>;
|
|
564
|
+
/**
|
|
565
|
+
* The distance between two meshes' surfaces, or `null`; see `Scene.meshDistance`.
|
|
566
|
+
*
|
|
567
|
+
* @deprecated Use `workerScene.inspect.meshDistance()` instead.
|
|
568
|
+
*/
|
|
569
|
+
meshDistance(a: MeshHandle, b: MeshHandle, options?: {
|
|
570
|
+
maxDistance?: number;
|
|
571
|
+
}): Promise<MeshDistance | null>;
|
|
572
|
+
/**
|
|
573
|
+
* Whether two meshes intersect or touch as placed.
|
|
574
|
+
*
|
|
575
|
+
* @deprecated Use `workerScene.inspect.intersects()` instead.
|
|
576
|
+
*/
|
|
577
|
+
intersects(a: MeshHandle, b: MeshHandle): Promise<boolean>;
|
|
578
|
+
/**
|
|
579
|
+
* The live triangle slots of `mesh` that intersect or touch another of its
|
|
580
|
+
* own triangles, ascending; see `Scene.selfIntersectingTriangles`.
|
|
581
|
+
*/
|
|
582
|
+
selfIntersectingTriangles(mesh: MeshHandle): Promise<Uint32Array>;
|
|
583
|
+
/**
|
|
584
|
+
* Every mesh pair (or every pair of `pairs`) within `margin`; see `Scene.findContacts`.
|
|
585
|
+
*
|
|
586
|
+
* @deprecated Use `workerScene.inspect.findContacts()` instead.
|
|
587
|
+
*/
|
|
588
|
+
findContacts(options?: FindContactsOptions): Promise<Contact[]>;
|
|
589
|
+
/** Registers a listener for {@link WorkerScene.commitFrame}; returns the function that removes it. */
|
|
590
|
+
onChanges(listener: (changes: MeshChange[]) => void): () => void;
|
|
591
|
+
/**
|
|
592
|
+
* Call once per animation frame. Sends this frame's requests to the Worker
|
|
593
|
+
* as one batch, then delivers to every listener, and returns, the change
|
|
594
|
+
* records of the results received since the last call (already applied to
|
|
595
|
+
* the mirrors) plus the drags' pose changes made here. Every listener runs
|
|
596
|
+
* even if one throws; the first error is rethrown afterwards.
|
|
597
|
+
*/
|
|
598
|
+
commitFrame(): MeshChange[];
|
|
599
|
+
/**
|
|
600
|
+
* The state of a request key: `mesh:<id>`, `placement:<id>`, `edit:<id>`,
|
|
601
|
+
* `display:<id>`, `field:<id>`, `section:<id>` (add and remove),
|
|
602
|
+
* `section:<id>:plane` / `:meshes` / `:fill`, `history`. A result sets
|
|
603
|
+
* `"ready"` or `"error"` only when no newer request for the key is pending.
|
|
604
|
+
* A status covers only requests made under its key: a drag or edit does
|
|
605
|
+
* not mark the `display:` or `section:` keys of the colours and sections
|
|
606
|
+
* that catch up after it. Returns a copy.
|
|
607
|
+
*/
|
|
608
|
+
status(key: string): KeyStatus;
|
|
609
|
+
/**
|
|
610
|
+
* Registers a listener called (on a microtask) when any status or the
|
|
611
|
+
* undo/redo state changes; returns the function that removes it.
|
|
612
|
+
*/
|
|
613
|
+
onStatus(listener: () => void): () => void;
|
|
614
|
+
/** The client id behind a handle, as used in status keys. */
|
|
615
|
+
idOf(handle: MeshHandle | FieldHandle | SectionHandle): number;
|
|
616
|
+
/**
|
|
617
|
+
* Stops the Worker, starts a new one and replays the scene into it; this
|
|
618
|
+
* is how a scene recovers after `INSTANCE_POISONED`. Resolves once the
|
|
619
|
+
* replay's results are applied (reported by the next `commitFrame()`).
|
|
620
|
+
*
|
|
621
|
+
* The replay is built here, from what the main thread has:
|
|
622
|
+
* - every mesh the engine had, re-added from its mirrors: live triangles
|
|
623
|
+
* only, compacted (slot ids change; handles do not), with its origin;
|
|
624
|
+
* - meshes whose add was never sent (still queued, or failed here after a
|
|
625
|
+
* poisoning), from their own data;
|
|
626
|
+
* - placements: the engine's, or, when the scene was not poisoned, the
|
|
627
|
+
* latest requested one (a `setPlacement` or drag not acknowledged yet);
|
|
628
|
+
* - fields, colourings and sections as last requested (removed ones are
|
|
629
|
+
* not re-created).
|
|
630
|
+
*
|
|
631
|
+
* History is cleared (`canUndo`/`canRedo` are false), and the meshes it
|
|
632
|
+
* could have brought back are gone for good. The replay is sent
|
|
633
|
+
* at once, not with the next frame. Every replayed key is `"computing"`
|
|
634
|
+
* until the replay's results arrive, and so is the key of every pending
|
|
635
|
+
* declarative request (placement, drag, colouring, field, section), also
|
|
636
|
+
* one that failed after a poisoning (its call was rejected then): it
|
|
637
|
+
* settles with the replay (`"ready"`, or `"error"` when the replay failed
|
|
638
|
+
* for it), which applies the newest value; after a poisoning, placements
|
|
639
|
+
* replay the engine's pose. A colouring whose field cannot be replayed
|
|
640
|
+
* (its mesh was lost) is dropped, with `UNKNOWN_FIELD` on its display key.
|
|
641
|
+
* Removals count as done: field and section removal keys read `"idle"`
|
|
642
|
+
* at once (their state is forgotten), mesh removal keys after the next
|
|
643
|
+
* `commitFrame()` delivers the removal. When the replay fails as a whole
|
|
644
|
+
* (no Worker, it could not be posted, a trap), the scene is poisoned and
|
|
645
|
+
* the next `restart()` replays the same intent and settles those keys.
|
|
646
|
+
*
|
|
647
|
+
* What cannot be replayed surfaces as errors (`INSTANCE_POISONED`): edits,
|
|
648
|
+
* repairs, compaction, undo/redo and queries sent and not answered, or not
|
|
649
|
+
* sent yet (their promises reject), and meshes whose add was sent but
|
|
650
|
+
* never acknowledged (their buffers went to the old Worker: they stay
|
|
651
|
+
* failed, and calls on them give `UNKNOWN_MESH`). An active drag ends.
|
|
652
|
+
* Mirrors, section results included, stay readable throughout. Calling it
|
|
653
|
+
* again before it settles returns the same promise. When no Worker can be
|
|
654
|
+
* created, the promise rejects and the scene stays poisoned (a later
|
|
655
|
+
* `restart()` tries again).
|
|
656
|
+
*/
|
|
657
|
+
restart(): Promise<void>;
|
|
658
|
+
/**
|
|
659
|
+
* Stops the Worker. Pending promises reject with `INVALID_ARGUMENT`; later
|
|
660
|
+
* calls throw it. Calling it again does nothing.
|
|
661
|
+
*/
|
|
662
|
+
terminate(): void;
|
|
663
|
+
}
|
|
664
|
+
export { WorkerSceneOptions as a, WorkerScene as i, MAX_THREADS as n, createWorkerScene as o, WorkerLike as r, KeyStatus as t };
|