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,4808 @@
|
|
|
1
|
+
import { InitInput, WasmScene } from "./wasm/fast_mesh_wasm.js";
|
|
2
|
+
/** A 3D vector `[x, y, z]`. */
|
|
3
|
+
type Vec3 = [x: number, y: number, z: number];
|
|
4
|
+
/**
|
|
5
|
+
* Flat vertex positions `[x0, y0, z0, x1, y1, z1, ...]`.
|
|
6
|
+
* A `Float32Array` is used as is; any other array is converted once.
|
|
7
|
+
*/
|
|
8
|
+
type Positions = Float32Array | ArrayLike<number>;
|
|
9
|
+
/**
|
|
10
|
+
* Flat vertex positions in world space for `Scene.addMesh`, kept in double
|
|
11
|
+
* precision until the mesh origin is subtracted.
|
|
12
|
+
* A `Float64Array` is used as is; any other array is converted once.
|
|
13
|
+
*/
|
|
14
|
+
type Positions64 = Float32Array | Float64Array | ArrayLike<number>;
|
|
15
|
+
/**
|
|
16
|
+
* Flat triangle indices `[a0, b0, c0, a1, ...]`.
|
|
17
|
+
* A `Uint32Array` is used as is; `Uint16Array` (common in three.js) and plain arrays are converted once.
|
|
18
|
+
*/
|
|
19
|
+
type Indices = Uint32Array | Uint16Array | ArrayLike<number>;
|
|
20
|
+
/** A unit quaternion `[x, y, z, w]`; it is normalised before use. */
|
|
21
|
+
type Quat = readonly [x: number, y: number, z: number, w: number];
|
|
22
|
+
/** A 3×3 rotation matrix as 9 numbers, row-major. */
|
|
23
|
+
type Mat3 = readonly number[];
|
|
24
|
+
/**
|
|
25
|
+
* When a mesh's derived data (BVH, normals, fields, sections) follows its edits:
|
|
26
|
+
* right away (`"eager"`), on the next query or `flush()` (`"lazy"`), or only on
|
|
27
|
+
* `update(mesh)` (`"manual"`).
|
|
28
|
+
*/
|
|
29
|
+
type UpdateMode = "eager" | "lazy" | "manual";
|
|
30
|
+
/** A placement to set: a rotation (row-major matrix or quaternion), a per-axis scale and a translation. */
|
|
31
|
+
interface PlacementInput {
|
|
32
|
+
/** A proper rotation: 9 numbers row-major, or a quaternion `[x, y, z, w]`. */
|
|
33
|
+
rotation: Mat3 | Quat;
|
|
34
|
+
translation: Readonly<Vec3>;
|
|
35
|
+
/**
|
|
36
|
+
* Per-axis scale: 3 finite positive numbers. Defaults to `[1, 1, 1]`
|
|
37
|
+
* (rigid). Both uniform and non-uniform scales are supported.
|
|
38
|
+
*/
|
|
39
|
+
scale?: Readonly<Vec3>;
|
|
40
|
+
}
|
|
41
|
+
/** A mesh placement: world = rotation · (scale · local) + translation. */
|
|
42
|
+
interface Placement {
|
|
43
|
+
/** 9 numbers, row-major. */
|
|
44
|
+
rotation: number[];
|
|
45
|
+
translation: Vec3;
|
|
46
|
+
/**
|
|
47
|
+
* 3 numbers; `[1, 1, 1]` for a rigid placement. Always present from
|
|
48
|
+
* {@link Scene} and `WorkerScene`; absent on hosts that do not track scale.
|
|
49
|
+
*/
|
|
50
|
+
scale?: Vec3;
|
|
51
|
+
}
|
|
52
|
+
/** Axis-aligned bounding box. */
|
|
53
|
+
interface Bounds {
|
|
54
|
+
/** Smallest coordinate on each axis. */
|
|
55
|
+
min: Vec3;
|
|
56
|
+
/** Largest coordinate on each axis. */
|
|
57
|
+
max: Vec3;
|
|
58
|
+
/** Box center. */
|
|
59
|
+
center: Vec3;
|
|
60
|
+
/** Box extent: `[width, height, depth]`. */
|
|
61
|
+
size: Vec3;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Computes smooth, area-weighted per-vertex normals.
|
|
65
|
+
*
|
|
66
|
+
* @param positions - Vertex positions. Length must be a multiple of 3.
|
|
67
|
+
* @param indices - Triangle indices. Length must be a multiple of 3.
|
|
68
|
+
* @returns Normals with the same length as `positions`. Vertices not used by any triangle get `[0, 0, 0]`.
|
|
69
|
+
* @throws If a length is not a multiple of 3 or an index is out of range.
|
|
70
|
+
*/
|
|
71
|
+
declare function computeVertexNormals(positions: Positions, indices: Indices): Float32Array;
|
|
72
|
+
/**
|
|
73
|
+
* Computes the axis-aligned bounding box of a mesh.
|
|
74
|
+
*
|
|
75
|
+
* @param positions - Vertex positions. Length must be a non-zero multiple of 3.
|
|
76
|
+
* @throws If `positions` is empty or its length is not a multiple of 3.
|
|
77
|
+
*/
|
|
78
|
+
declare function computeBounds(positions: Positions): Bounds;
|
|
79
|
+
/**
|
|
80
|
+
* A mesh in a {@link Scene}. Opaque: pass it to the scene's methods. The same
|
|
81
|
+
* mesh always gives the same handle object, so handles compare with `===`.
|
|
82
|
+
*/
|
|
83
|
+
declare class MeshHandle {
|
|
84
|
+
private readonly brand;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* A field in a {@link Scene}. Opaque and deduplicated like {@link MeshHandle}.
|
|
88
|
+
* The scene keeps every field handle it gave out for its own lifetime, even
|
|
89
|
+
* after the field is removed, so a removal in a change record names the same
|
|
90
|
+
* object you hold.
|
|
91
|
+
*/
|
|
92
|
+
declare class FieldHandle {
|
|
93
|
+
private readonly brand;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* A section in a {@link Scene}. Opaque and deduplicated like {@link MeshHandle},
|
|
97
|
+
* and kept for the scene's lifetime like {@link FieldHandle}.
|
|
98
|
+
*/
|
|
99
|
+
declare class SectionHandle {
|
|
100
|
+
private readonly brand;
|
|
101
|
+
}
|
|
102
|
+
/** Options for `denoise`. */
|
|
103
|
+
interface DenoiseOptions {
|
|
104
|
+
/** Rounds of normal filtering and vertex fitting, 0 to 100 (default 5). 0 changes nothing. */
|
|
105
|
+
iterations?: number;
|
|
106
|
+
/**
|
|
107
|
+
* How far each round moves the surface's normals towards their filtered
|
|
108
|
+
* value, in `[0, 1]` (default 0.5). 0 changes nothing.
|
|
109
|
+
*/
|
|
110
|
+
strength?: number;
|
|
111
|
+
/**
|
|
112
|
+
* The angle between two triangles' normals, in degrees in `(0, 180]`, from
|
|
113
|
+
* which they no longer smooth each other (default 45): edges sharper than
|
|
114
|
+
* it are kept.
|
|
115
|
+
*/
|
|
116
|
+
featureAngle?: number;
|
|
117
|
+
/**
|
|
118
|
+
* Triangles to denoise, by id (default: the whole mesh). Only vertices
|
|
119
|
+
* whose triangles are all listed move; an empty list changes nothing.
|
|
120
|
+
*/
|
|
121
|
+
region?: Indices;
|
|
122
|
+
}
|
|
123
|
+
/** Options for `delaunayFlips`. */
|
|
124
|
+
interface DelaunayFlipOptions {
|
|
125
|
+
/**
|
|
126
|
+
* How far, in degrees in `[0, 90]`, the flips may take the surface from the
|
|
127
|
+
* original (default 10): the largest angle across a flipped edge, and
|
|
128
|
+
* between a new triangle's normal and those of the original triangles it
|
|
129
|
+
* replaces. Edges sharper than it never flip.
|
|
130
|
+
*/
|
|
131
|
+
dihedralLimit?: number;
|
|
132
|
+
/**
|
|
133
|
+
* Triangles to work on, by id (default: the whole mesh). Only edges
|
|
134
|
+
* between two listed triangles flip; an empty list changes nothing.
|
|
135
|
+
*/
|
|
136
|
+
region?: Indices;
|
|
137
|
+
}
|
|
138
|
+
/** Readouts of a surface's triangle shape and smoothness, over the region when there is one. */
|
|
139
|
+
interface SurfaceStats {
|
|
140
|
+
/** Triangles measured. */
|
|
141
|
+
triangles: number;
|
|
142
|
+
/** The smallest corner angle, in degrees; 0 when there are no triangles. */
|
|
143
|
+
minAngle: number;
|
|
144
|
+
/**
|
|
145
|
+
* The mean angle between the normals of triangles that share an edge, in
|
|
146
|
+
* degrees; 0 when there are none. Noise raises it; flat faces bring it to
|
|
147
|
+
* 0, apart from the edges along real features.
|
|
148
|
+
*/
|
|
149
|
+
meanNormalDeviation: number;
|
|
150
|
+
}
|
|
151
|
+
/** What `denoise` did. */
|
|
152
|
+
interface DenoiseReport {
|
|
153
|
+
/** Vertices whose position changed. */
|
|
154
|
+
moved: number;
|
|
155
|
+
/** The largest distance a vertex moved, in the mesh's own units (before its placement's scale). */
|
|
156
|
+
maxDisplacement: number;
|
|
157
|
+
/** Rounds run. */
|
|
158
|
+
iterations: number;
|
|
159
|
+
/** Vertices left where they were because a triangle using them would have turned over. */
|
|
160
|
+
reverted: number;
|
|
161
|
+
/** The surface before. */
|
|
162
|
+
before: SurfaceStats;
|
|
163
|
+
/** The surface after. */
|
|
164
|
+
after: SurfaceStats;
|
|
165
|
+
}
|
|
166
|
+
/** What `delaunayFlips` did. */
|
|
167
|
+
interface DelaunayFlipReport {
|
|
168
|
+
/** Edges flipped. */
|
|
169
|
+
flips: number;
|
|
170
|
+
/** Passes over the edges that flipped at least one. */
|
|
171
|
+
passes: number;
|
|
172
|
+
/** `false` when the pass limit (1000) ran out with flips left. */
|
|
173
|
+
converged: boolean;
|
|
174
|
+
/** The surface before. */
|
|
175
|
+
before: SurfaceStats;
|
|
176
|
+
/** The surface after. */
|
|
177
|
+
after: SurfaceStats;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Which way `extrudeFaces` moves the selection:
|
|
181
|
+
* - `"region"`: each region of the selection (its triangles connected through
|
|
182
|
+
* shared edges) moves as one rigid piece along its area-weighted average
|
|
183
|
+
* normal. A flat region gains exactly its area times the distance in volume.
|
|
184
|
+
* - `"vertex"`: each vertex moves along the average normal of its selected
|
|
185
|
+
* triangles, so the faces follow the surface like an offset.
|
|
186
|
+
* - a world vector (any length): everything moves along it.
|
|
187
|
+
*/
|
|
188
|
+
type ExtrudeDirection = "region" | "vertex" | Readonly<Vec3>;
|
|
189
|
+
/** Options for `extrudeFaces`. */
|
|
190
|
+
interface ExtrudeFacesOptions {
|
|
191
|
+
/** How far the faces move, in world units; negative pushes them in. Finite and not zero. */
|
|
192
|
+
distance: number;
|
|
193
|
+
/** Which way they move (default `"region"`). */
|
|
194
|
+
direction?: ExtrudeDirection;
|
|
195
|
+
/** Look for self-intersections the result would have (default `true`). */
|
|
196
|
+
checkSelfIntersections?: boolean;
|
|
197
|
+
}
|
|
198
|
+
/** What `extrudeFaces` did. */
|
|
199
|
+
interface ExtrudeFacesResult {
|
|
200
|
+
/** Regions of the selection, each extruded as one piece with walls of its own. */
|
|
201
|
+
regions: number;
|
|
202
|
+
/** Selected triangles, each counted once. They keep their slots and are the moved faces. */
|
|
203
|
+
capTriangles: number;
|
|
204
|
+
/** Vertices that moved in place: those inside the selection. */
|
|
205
|
+
movedVertices: number;
|
|
206
|
+
/** New vertices: copies of the vertices on the selection's boundary. */
|
|
207
|
+
addedVertices: number;
|
|
208
|
+
/** Triangle slots of the new side walls, ascending. */
|
|
209
|
+
wallTriangles: Uint32Array;
|
|
210
|
+
/**
|
|
211
|
+
* Triangle slots of every pair that touches, crosses or folds flat after
|
|
212
|
+
* the extrusion with a moved or new triangle among them, ascending; `null`
|
|
213
|
+
* with `checkSelfIntersections: false`.
|
|
214
|
+
*/
|
|
215
|
+
selfIntersections: Uint32Array | null;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Options for `extrudeBase`. Give the base plane's place as `height` or as
|
|
219
|
+
* `offset`, not both.
|
|
220
|
+
*/
|
|
221
|
+
interface ExtrudeBaseOptions {
|
|
222
|
+
/** The world direction the walls run in, any length (default `[0, -1, 0]`, down with y up). */
|
|
223
|
+
direction?: Readonly<Vec3>;
|
|
224
|
+
/**
|
|
225
|
+
* The base plane's world height, measured from the world origin along the
|
|
226
|
+
* opposite of `direction`: with the default direction, the plane `y = height`.
|
|
227
|
+
*/
|
|
228
|
+
height?: number;
|
|
229
|
+
/** How far the base plane is past the mesh's furthest vertex along `direction`, in world units. */
|
|
230
|
+
offset?: number;
|
|
231
|
+
/**
|
|
232
|
+
* The boundary loops to extrude: `"largest"` (default) is the one with the
|
|
233
|
+
* longest perimeter in the world, `"all"` every one, where outlines nested on the plane
|
|
234
|
+
* become holes in the cap, or the ids of some, from `analyze(mesh).loops`.
|
|
235
|
+
*/
|
|
236
|
+
loops?: "largest" | "all" | readonly LoopId[];
|
|
237
|
+
/** Refine each cap to the density of its walls, up to 20,000 new vertices (default `true`). */
|
|
238
|
+
refine?: boolean;
|
|
239
|
+
/** Look for self-intersections the result would have (default `true`). */
|
|
240
|
+
checkSelfIntersections?: boolean;
|
|
241
|
+
}
|
|
242
|
+
/** What `extrudeBase` did. */
|
|
243
|
+
interface ExtrudeBaseResult {
|
|
244
|
+
/** The loops extruded, as they were before. */
|
|
245
|
+
loops: LoopId[];
|
|
246
|
+
/** The base plane's world height, as {@link ExtrudeBaseOptions.height} measures it. */
|
|
247
|
+
height: number;
|
|
248
|
+
/** New vertices on the plane's outlines. */
|
|
249
|
+
baseVertices: number;
|
|
250
|
+
/** New vertices inside the caps. */
|
|
251
|
+
capVertices: number;
|
|
252
|
+
/** New side wall triangles. */
|
|
253
|
+
wallTriangles: number;
|
|
254
|
+
/** New cap triangles. */
|
|
255
|
+
capTriangles: number;
|
|
256
|
+
/** Whether a cap's refinement stopped at its vertex budget. */
|
|
257
|
+
capped: boolean;
|
|
258
|
+
/**
|
|
259
|
+
* Whether a surface was turned around: it faced the way the walls run, so
|
|
260
|
+
* its solid would have been inside out.
|
|
261
|
+
*/
|
|
262
|
+
flipped: boolean;
|
|
263
|
+
/**
|
|
264
|
+
* Triangle slots of every pair that touches, crosses or folds flat after
|
|
265
|
+
* the extrusion with a new triangle among them, ascending; `null` with
|
|
266
|
+
* `checkSelfIntersections: false`.
|
|
267
|
+
*/
|
|
268
|
+
selfIntersections: Uint32Array | null;
|
|
269
|
+
}
|
|
270
|
+
/** The most pixels of a height map: 2^28. */
|
|
271
|
+
declare const MAX_HEIGHT_MAP_PIXELS: number;
|
|
272
|
+
/** How `heightMapFrame` (and `heightMap` without a frame) fits an image to the meshes. */
|
|
273
|
+
interface HeightMapOptions {
|
|
274
|
+
/**
|
|
275
|
+
* The world direction the image looks along, of any length; heights are
|
|
276
|
+
* measured against it. Default `[0, 0, -1]`, down the Z axis.
|
|
277
|
+
*/
|
|
278
|
+
direction?: Readonly<Vec3>;
|
|
279
|
+
/**
|
|
280
|
+
* The world direction that is up in the image, made perpendicular to
|
|
281
|
+
* `direction`. By default `+Y`, or looking along the Y axis, `-Z` from above
|
|
282
|
+
* and `+Z` from below (`+X` is right in both).
|
|
283
|
+
*/
|
|
284
|
+
up?: Readonly<Vec3>;
|
|
285
|
+
/**
|
|
286
|
+
* Pixels along the longer side of the image, a whole number of at least 2
|
|
287
|
+
* (default `1024`). Pixels are square, so the other side follows from the
|
|
288
|
+
* meshes' proportions; it has at least 2 pixels.
|
|
289
|
+
*/
|
|
290
|
+
resolution?: number;
|
|
291
|
+
/** The world size of a pixel, instead of `resolution`. */
|
|
292
|
+
pixelSize?: number;
|
|
293
|
+
/** World distance to leave free around the meshes (default `0`). */
|
|
294
|
+
margin?: number;
|
|
295
|
+
/**
|
|
296
|
+
* The heights the image covers, `[low, high]`, as world coordinates along
|
|
297
|
+
* `-direction`: `low` is height 0, and only surfaces between the two are
|
|
298
|
+
* seen. By default the meshes' own range.
|
|
299
|
+
*/
|
|
300
|
+
range?: readonly [number, number];
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Where a height map's pixels are in the world: pixel `(col, row)`, rows from
|
|
304
|
+
* the top, at height `h` is the world point
|
|
305
|
+
* `origin + col * pixelSize * right - row * pixelSize * up + h * normal`.
|
|
306
|
+
*/
|
|
307
|
+
interface HeightMapFrame {
|
|
308
|
+
/** Pixels along a row. */
|
|
309
|
+
width: number;
|
|
310
|
+
/** Rows. */
|
|
311
|
+
height: number;
|
|
312
|
+
/** The centre of the top left pixel, at height 0. */
|
|
313
|
+
origin: Vec3;
|
|
314
|
+
/** The image's right, a unit vector. */
|
|
315
|
+
right: Vec3;
|
|
316
|
+
/** The image's up, a unit vector perpendicular to `right`. */
|
|
317
|
+
up: Vec3;
|
|
318
|
+
/** The direction heights grow in, towards the viewer: `right × up`. */
|
|
319
|
+
normal: Vec3;
|
|
320
|
+
/** The world distance between the centres of neighbouring pixels. */
|
|
321
|
+
pixelSize: number;
|
|
322
|
+
/** The largest height: the image covers heights from 0 to this. */
|
|
323
|
+
range: number;
|
|
324
|
+
}
|
|
325
|
+
/** The heights of a height map, or of a band of its rows. */
|
|
326
|
+
interface HeightMap {
|
|
327
|
+
/** Where the pixels are. */
|
|
328
|
+
frame: HeightMapFrame;
|
|
329
|
+
/** The rows sampled: from the first to before the second. */
|
|
330
|
+
rows: [number, number];
|
|
331
|
+
/**
|
|
332
|
+
* The heights of the rows, `frame.width` to a row from the left, in
|
|
333
|
+
* `[0, frame.range]`; NaN where no surface is seen.
|
|
334
|
+
*/
|
|
335
|
+
heights: Float32Array;
|
|
336
|
+
}
|
|
337
|
+
/** A grid of heights, for `generateHeightfield` and `addHeightfield`. */
|
|
338
|
+
interface Heightfield {
|
|
339
|
+
/** `width * height` heights, row by row from the top left; NaN stands at 0. Each must be above `-base`. */
|
|
340
|
+
heights: Float32Array | ArrayLike<number>;
|
|
341
|
+
/** Samples along a row, at least 2. */
|
|
342
|
+
width: number;
|
|
343
|
+
/** Rows, at least 2. */
|
|
344
|
+
height: number;
|
|
345
|
+
/** The distance between samples: one number, or `[along a row, between rows]`. Default `1`. */
|
|
346
|
+
pixelSize?: number | readonly [number, number];
|
|
347
|
+
/** The thickness of the base below height 0. Default `1`. */
|
|
348
|
+
base?: number;
|
|
349
|
+
}
|
|
350
|
+
/** Options for `addHeightfield`. */
|
|
351
|
+
interface AddHeightfieldOptions {
|
|
352
|
+
/** Where the relief goes (default: the identity). See {@link heightMapPlacement}. */
|
|
353
|
+
placement?: PlacementInput;
|
|
354
|
+
/** Turn on the new mesh's smooth vertex normals, as `addMesh` does (default `true`). */
|
|
355
|
+
normals?: boolean;
|
|
356
|
+
}
|
|
357
|
+
/** What `addHeightfield` added. */
|
|
358
|
+
interface HeightfieldResult {
|
|
359
|
+
/** The new mesh holding the relief: closed, outward-wound, one undo step. */
|
|
360
|
+
mesh: MeshHandle;
|
|
361
|
+
/** Vertices of the relief. */
|
|
362
|
+
vertices: number;
|
|
363
|
+
/** Triangles of the relief. */
|
|
364
|
+
triangles: number;
|
|
365
|
+
}
|
|
366
|
+
/** Internal: {@link Heightfield} checked, with its defaults; `heights` may be the caller's array. */
|
|
367
|
+
interface CheckedHeightfield {
|
|
368
|
+
heights: Float32Array;
|
|
369
|
+
width: number;
|
|
370
|
+
height: number;
|
|
371
|
+
pixelSize: [number, number];
|
|
372
|
+
base: number;
|
|
373
|
+
}
|
|
374
|
+
/** Internal: {@link AddHeightfieldOptions} checked, with their defaults; a plain object, safe to post to a Worker. */
|
|
375
|
+
interface CheckedHeightfieldPlacement {
|
|
376
|
+
rotation: number[];
|
|
377
|
+
translation: Vec3;
|
|
378
|
+
scale?: Vec3;
|
|
379
|
+
normals: boolean;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* The placement that puts a relief of a map's heights (`addHeightfield` with
|
|
383
|
+
* the frame's `pixelSize`) where the map saw them.
|
|
384
|
+
*
|
|
385
|
+
* @example
|
|
386
|
+
* ```ts
|
|
387
|
+
* const map = scene.heightMap(mesh, { resolution: 512 });
|
|
388
|
+
* scene.addHeightfield(
|
|
389
|
+
* { ...map, width: map.frame.width, height: map.frame.height, pixelSize: map.frame.pixelSize },
|
|
390
|
+
* { placement: heightMapPlacement(map.frame) },
|
|
391
|
+
* );
|
|
392
|
+
* ```
|
|
393
|
+
*/
|
|
394
|
+
declare function heightMapPlacement(frame: HeightMapFrame): Placement;
|
|
395
|
+
/** Screen-space face selection shape in normalized device coordinates (`[-1, 1]`). */
|
|
396
|
+
type ScreenSelectionShape = {
|
|
397
|
+
kind: "rect";
|
|
398
|
+
minNdc: readonly [number, number];
|
|
399
|
+
maxNdc: readonly [number, number];
|
|
400
|
+
} | {
|
|
401
|
+
kind: "lasso";
|
|
402
|
+
polygonNdc: readonly (readonly [number, number])[] | Float32Array | Float64Array;
|
|
403
|
+
};
|
|
404
|
+
/** World-space camera and visibility options for {@link Scene.selectFacesScreen}. */
|
|
405
|
+
interface ScreenSelectOptions {
|
|
406
|
+
/**
|
|
407
|
+
* Column-major 4×4 view-projection matrix (16 finite numbers), of world points.
|
|
408
|
+
*
|
|
409
|
+
* It is taken in `f64`. Give it so (an array of numbers or a `Float64Array`, multiplied in `f64`)
|
|
410
|
+
* for a camera far from the world origin: a `Float32Array` holds it only to the steps of `f32`
|
|
411
|
+
* there (0.008 at 1e5).
|
|
412
|
+
*/
|
|
413
|
+
viewProj: ReadonlyArray<number> | Float32Array | Float64Array;
|
|
414
|
+
/** Where the camera is in the world. */
|
|
415
|
+
cameraOrigin: Readonly<Vec3>;
|
|
416
|
+
/** Where it looks in the world, of any length. */
|
|
417
|
+
cameraForward: Readonly<Vec3>;
|
|
418
|
+
isOrthographic?: boolean;
|
|
419
|
+
visibleOnly?: boolean;
|
|
420
|
+
rejectBackfaces?: boolean;
|
|
421
|
+
includeTouching?: boolean;
|
|
422
|
+
}
|
|
423
|
+
/** Optional normal cone filter for spherical face selection. */
|
|
424
|
+
interface FaceSelectionNormalCone {
|
|
425
|
+
normal: Readonly<Vec3>;
|
|
426
|
+
angleRad: number;
|
|
427
|
+
}
|
|
428
|
+
/** Topological adjacency rule for growing/shrinking face selections. */
|
|
429
|
+
type AdjacencyKind = "edge" | "vertex";
|
|
430
|
+
/** Summary of a destructive face deletion or split edit. */
|
|
431
|
+
interface FaceEditReport {
|
|
432
|
+
removedTriangles: number;
|
|
433
|
+
removedVertices: number;
|
|
434
|
+
}
|
|
435
|
+
/** Result of splitting selected faces off into a detached scene mesh. */
|
|
436
|
+
interface SplitFacesReport {
|
|
437
|
+
detached: MeshHandle;
|
|
438
|
+
removedTriangles: number;
|
|
439
|
+
removedVertices: number;
|
|
440
|
+
}
|
|
441
|
+
/** Basis function for Free-Form Deformation lattices. */
|
|
442
|
+
type FfdBasis = "bernstein" | "cubicBSpline";
|
|
443
|
+
type FfdBasisInput = FfdBasis | "bspline";
|
|
444
|
+
type FfdOutsideMode = "ignore" | "clamp";
|
|
445
|
+
type ArapWeights = "cotangent" | "uniform";
|
|
446
|
+
type ArapSolver = "auto" | "direct" | "pcg";
|
|
447
|
+
type KelvinletScale = "single" | "bi" | "tri";
|
|
448
|
+
/** Oriented box frame for an FFD lattice, in local mesh coordinates, as in `views(mesh).positions()`. */
|
|
449
|
+
interface FfdFrameData {
|
|
450
|
+
center: Vec3;
|
|
451
|
+
axes: [Vec3, Vec3, Vec3];
|
|
452
|
+
halfExtents: Vec3;
|
|
453
|
+
}
|
|
454
|
+
/** 3D Free-Form Deformation control lattice and control-point offsets, in local mesh coordinates. */
|
|
455
|
+
interface FfdLatticeData {
|
|
456
|
+
dims: [number, number, number];
|
|
457
|
+
basis: FfdBasis;
|
|
458
|
+
frame: FfdFrameData;
|
|
459
|
+
/** Flat `[dx0, dy0, dz0, ...]` control point displacements (`length === 3 * nx * ny * nz`). */
|
|
460
|
+
offsets: Float64Array;
|
|
461
|
+
}
|
|
462
|
+
/** Alias for {@link FfdLatticeData}. */
|
|
463
|
+
type FfdLattice = FfdLatticeData;
|
|
464
|
+
/**
|
|
465
|
+
* Optional vertex protection weights shielding pinned regions from freeform displacement.
|
|
466
|
+
* Matches `VertexProtection`: weight `0` holds a vertex frozen in place,
|
|
467
|
+
* `1` keeps full displacement, and unset holds all listed vertices frozen (`0`).
|
|
468
|
+
*/
|
|
469
|
+
interface FreeformProtection {
|
|
470
|
+
vertices: Indices;
|
|
471
|
+
weights?: Float32Array | ArrayLike<number>;
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Optional spatial region, vertex subset, and protection filter shared across freeform deformers.
|
|
475
|
+
*
|
|
476
|
+
* Every point, vector and length the deformers take or report is in local mesh coordinates, as in
|
|
477
|
+
* `views(mesh).positions()`: relative to the mesh's origin, before its placement.
|
|
478
|
+
*/
|
|
479
|
+
interface FreeformScope {
|
|
480
|
+
region?: {
|
|
481
|
+
center: Readonly<Vec3>;
|
|
482
|
+
radius: number;
|
|
483
|
+
};
|
|
484
|
+
vertices?: Indices;
|
|
485
|
+
protect?: FreeformProtection;
|
|
486
|
+
}
|
|
487
|
+
/** Options for {@link Scene.applyFfd}. */
|
|
488
|
+
interface FfdOptions extends FreeformScope {
|
|
489
|
+
lattice: FfdLatticeData;
|
|
490
|
+
outsideMode?: FfdOutsideMode;
|
|
491
|
+
}
|
|
492
|
+
/** An anchor vertex constraint for ARAP surface deformation. */
|
|
493
|
+
interface ArapAnchorInput {
|
|
494
|
+
vertex: number;
|
|
495
|
+
position?: Readonly<Vec3>;
|
|
496
|
+
}
|
|
497
|
+
/** A target handle constraint for ARAP surface deformation. */
|
|
498
|
+
interface ArapHandleInput {
|
|
499
|
+
vertex: number;
|
|
500
|
+
target: Readonly<Vec3>;
|
|
501
|
+
}
|
|
502
|
+
/** Options for {@link Scene.applyArap}. */
|
|
503
|
+
interface ArapOptions extends FreeformScope {
|
|
504
|
+
anchors: readonly ArapAnchorInput[];
|
|
505
|
+
handles: readonly ArapHandleInput[];
|
|
506
|
+
weights?: ArapWeights;
|
|
507
|
+
solver?: ArapSolver;
|
|
508
|
+
iterations?: number;
|
|
509
|
+
tolerance?: number;
|
|
510
|
+
}
|
|
511
|
+
/** Load specification for volumetric Kelvinlet brushes. */
|
|
512
|
+
type KelvinletLoad = {
|
|
513
|
+
kind: "grab";
|
|
514
|
+
force: Readonly<Vec3>;
|
|
515
|
+
} | {
|
|
516
|
+
kind: "scale";
|
|
517
|
+
magnitude: number;
|
|
518
|
+
} | {
|
|
519
|
+
kind: "twist";
|
|
520
|
+
torque: Readonly<Vec3>;
|
|
521
|
+
} | {
|
|
522
|
+
kind: "pinch";
|
|
523
|
+
forceDipole: readonly [Readonly<Vec3>, Readonly<Vec3>, Readonly<Vec3>] | ReadonlyArray<number>;
|
|
524
|
+
};
|
|
525
|
+
/** Options for {@link Scene.applyKelvinlet}. */
|
|
526
|
+
interface KelvinletOptions extends FreeformScope {
|
|
527
|
+
center: Readonly<Vec3>;
|
|
528
|
+
load: KelvinletLoad;
|
|
529
|
+
epsilon?: number;
|
|
530
|
+
nu?: number;
|
|
531
|
+
mu?: number;
|
|
532
|
+
scale?: KelvinletScale;
|
|
533
|
+
scaleAlpha?: number;
|
|
534
|
+
symmetry?: {
|
|
535
|
+
x?: boolean;
|
|
536
|
+
y?: boolean;
|
|
537
|
+
z?: boolean;
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
/** Pinned vertex target for XPBD soft-body simulation. */
|
|
541
|
+
interface XpbdPinInput {
|
|
542
|
+
vertex: number;
|
|
543
|
+
target: Readonly<Vec3>;
|
|
544
|
+
}
|
|
545
|
+
/** Compliant handle constraint for XPBD soft-body simulation. */
|
|
546
|
+
interface XpbdHandleInput {
|
|
547
|
+
vertex: number;
|
|
548
|
+
target: Readonly<Vec3>;
|
|
549
|
+
compliance?: number;
|
|
550
|
+
}
|
|
551
|
+
/** Options for {@link Scene.applyXpbd}, in local mesh coordinates and units (see {@link FreeformScope}). */
|
|
552
|
+
interface XpbdOptions {
|
|
553
|
+
substeps?: number;
|
|
554
|
+
iterations?: number;
|
|
555
|
+
dt?: number;
|
|
556
|
+
stretchCompliance?: number;
|
|
557
|
+
bendCompliance?: number;
|
|
558
|
+
volumeCompliance?: number;
|
|
559
|
+
damping?: number;
|
|
560
|
+
gravity?: Readonly<Vec3>;
|
|
561
|
+
pins?: readonly XpbdPinInput[];
|
|
562
|
+
handles?: readonly XpbdHandleInput[];
|
|
563
|
+
selfCollision?: boolean;
|
|
564
|
+
collisionThickness?: number;
|
|
565
|
+
protect?: FreeformProtection;
|
|
566
|
+
}
|
|
567
|
+
/** Outcome statistics returned by all freeform deformation operators. */
|
|
568
|
+
interface FreeformReport {
|
|
569
|
+
verticesEvaluated: number;
|
|
570
|
+
verticesMoved: number;
|
|
571
|
+
maxDisplacement: number;
|
|
572
|
+
iterations: number;
|
|
573
|
+
converged: boolean;
|
|
574
|
+
selfCollisionContactsResolved: number;
|
|
575
|
+
}
|
|
576
|
+
type CollisionMode = "passThrough" | "rigid" | "cut" | "softDeform";
|
|
577
|
+
type CollisionRole = "symmetric" | "movingIsCutter" | "movingIsTarget";
|
|
578
|
+
type CollisionDistanceBackend = "bvhSdf" | "fhEdt";
|
|
579
|
+
type CutTrigger = "onRelease" | "liveStep";
|
|
580
|
+
type SoftDeformSolver = "sdfLaplacian" | "kelvinlet" | "xpbd";
|
|
581
|
+
type MaterialMemory = "elastic" | "plastic";
|
|
582
|
+
/** Collision response configuration for the scene default or an unordered mesh pair. */
|
|
583
|
+
interface CollisionRule {
|
|
584
|
+
mode: CollisionMode;
|
|
585
|
+
role: CollisionRole;
|
|
586
|
+
distanceBackend: CollisionDistanceBackend;
|
|
587
|
+
cutMethod: BooleanMethod;
|
|
588
|
+
cutTrigger: CutTrigger;
|
|
589
|
+
softSolver: SoftDeformSolver;
|
|
590
|
+
materialMemory: MaterialMemory;
|
|
591
|
+
compliance: number;
|
|
592
|
+
stiffness: number;
|
|
593
|
+
recoveryRate: number;
|
|
594
|
+
contactMargin: number;
|
|
595
|
+
selfCollisionGuard: boolean;
|
|
596
|
+
rigidSlide: boolean;
|
|
597
|
+
}
|
|
598
|
+
type CollisionRuleInput = Partial<CollisionRule>;
|
|
599
|
+
declare const DEFAULT_COLLISION_RULE: Readonly<CollisionRule>;
|
|
600
|
+
/** Per-pair collision outcome from a {@link moveWithCollision} or commit step. */
|
|
601
|
+
interface CollisionPairOutcome<M = MeshHandle> {
|
|
602
|
+
other: M;
|
|
603
|
+
mode: CollisionMode;
|
|
604
|
+
role: CollisionRole;
|
|
605
|
+
intersecting: boolean;
|
|
606
|
+
minDistance: number;
|
|
607
|
+
contactBlocked: boolean;
|
|
608
|
+
slidden: boolean;
|
|
609
|
+
cutExecuted: boolean;
|
|
610
|
+
previewOnly: boolean;
|
|
611
|
+
softDeformedVertices: number;
|
|
612
|
+
elasticRecoveredVertices: number;
|
|
613
|
+
selfCollisionGuardTriggered: boolean;
|
|
614
|
+
}
|
|
615
|
+
/** Step-level collision detection and response report. */
|
|
616
|
+
interface CollisionStepReport<M = MeshHandle> {
|
|
617
|
+
appliedPlacement: Placement;
|
|
618
|
+
appliedQuaternion: Quat;
|
|
619
|
+
activePairs: CollisionPairOutcome<M>[];
|
|
620
|
+
modifiedMeshes: M[];
|
|
621
|
+
minClearance: number;
|
|
622
|
+
cutsExecuted: number;
|
|
623
|
+
softVerticesDeformed: number;
|
|
624
|
+
elasticRecoveryCount: number;
|
|
625
|
+
selfIntersectionGuardTriggered: boolean;
|
|
626
|
+
}
|
|
627
|
+
type PrimitiveKind = "plane" | "sphere" | "cylinder" | "cone";
|
|
628
|
+
type PrimitiveKindInput = PrimitiveKind | "auto";
|
|
629
|
+
type ContourExportFormat = "svg" | "json" | "csv";
|
|
630
|
+
type PointCloudFormat = "xyz" | "pcd" | "ply";
|
|
631
|
+
type SurfaceReconstructMethod = "implicitMlsMarchingCubes" | "ballPivoting";
|
|
632
|
+
type FittedPrimitive = {
|
|
633
|
+
kind: "plane";
|
|
634
|
+
origin: Vec3;
|
|
635
|
+
normal: Vec3;
|
|
636
|
+
} | {
|
|
637
|
+
kind: "sphere";
|
|
638
|
+
center: Vec3;
|
|
639
|
+
radius: number;
|
|
640
|
+
} | {
|
|
641
|
+
kind: "cylinder";
|
|
642
|
+
axisOrigin: Vec3;
|
|
643
|
+
axisDir: Vec3;
|
|
644
|
+
radius: number;
|
|
645
|
+
height: number;
|
|
646
|
+
} | {
|
|
647
|
+
kind: "cone";
|
|
648
|
+
apex: Vec3;
|
|
649
|
+
axisDir: Vec3;
|
|
650
|
+
halfAngleRad: number;
|
|
651
|
+
height: number;
|
|
652
|
+
};
|
|
653
|
+
interface FittedPrimitiveReport {
|
|
654
|
+
primitive: FittedPrimitive;
|
|
655
|
+
rmsError: number;
|
|
656
|
+
maxError: number;
|
|
657
|
+
inlierCount: number;
|
|
658
|
+
inlierRatio: number;
|
|
659
|
+
residuals: Float32Array;
|
|
660
|
+
}
|
|
661
|
+
interface FitPrimitiveOptions {
|
|
662
|
+
subsetTris?: Indices;
|
|
663
|
+
kind?: PrimitiveKindInput;
|
|
664
|
+
inlierThreshold?: number;
|
|
665
|
+
ransacIterations?: number;
|
|
666
|
+
lmIterations?: number;
|
|
667
|
+
seed?: number;
|
|
668
|
+
minInlierRatio?: number;
|
|
669
|
+
normalWeight?: number;
|
|
670
|
+
}
|
|
671
|
+
interface ContourLoop {
|
|
672
|
+
closed: boolean;
|
|
673
|
+
perimeter: number;
|
|
674
|
+
enclosedArea: number;
|
|
675
|
+
centroid2d: [number, number];
|
|
676
|
+
centroid3d: Vec3;
|
|
677
|
+
minCaliperDiameter: number;
|
|
678
|
+
maxCaliperDiameter: number;
|
|
679
|
+
/** The points in the plane, `u, v` each: around the slice's `planeOrigin`, along its axes. */
|
|
680
|
+
points2d: Float64Array;
|
|
681
|
+
/**
|
|
682
|
+
* The points in world coordinates, `x, y, z` each, rounded to `f32`: far
|
|
683
|
+
* from the world origin that is by up to half of its steps there (0.004 at
|
|
684
|
+
* 1e5). `points3d64` has them as precise as the mesh.
|
|
685
|
+
*/
|
|
686
|
+
points3d: Float32Array;
|
|
687
|
+
/**
|
|
688
|
+
* The points in world coordinates, `x, y, z` each, as precise as the mesh
|
|
689
|
+
* wherever it is. Every slice the SDK returns has them; without them in a
|
|
690
|
+
* loop of yours, an export takes `points3d`.
|
|
691
|
+
*/
|
|
692
|
+
points3d64?: Float64Array;
|
|
693
|
+
}
|
|
694
|
+
interface ContourSlice {
|
|
695
|
+
/** The plane's point in world coordinates: the one asked for, to a few `f32` steps of the mesh's local positions. */
|
|
696
|
+
planeOrigin: Vec3;
|
|
697
|
+
planeNormal: Vec3;
|
|
698
|
+
uAxis: Vec3;
|
|
699
|
+
vAxis: Vec3;
|
|
700
|
+
totalPerimeter: number;
|
|
701
|
+
totalArea: number;
|
|
702
|
+
loops: ContourLoop[];
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Packed WebAssembly-ready point cloud buffer (`[count, hasNormals, hasColors, ...positions, ...normals, ...colors]`).
|
|
706
|
+
*
|
|
707
|
+
* The positions are `f32`, which far from zero holds them only to its steps
|
|
708
|
+
* there (0.008 at 1e5). Keep a cloud there around an `origin` near it:
|
|
709
|
+
* {@link packPointCloud} takes one, and {@link parsePointCloudText} and
|
|
710
|
+
* {@link parsePointCloudBytes} find one with `center: true`.
|
|
711
|
+
*/
|
|
712
|
+
interface PackedPointCloud {
|
|
713
|
+
readonly data: Float32Array;
|
|
714
|
+
readonly count: number;
|
|
715
|
+
readonly hasNormals: boolean;
|
|
716
|
+
readonly hasColors: boolean;
|
|
717
|
+
/**
|
|
718
|
+
* The world point the positions are relative to (`f64` numbers). Zero when
|
|
719
|
+
* left out: they are then world positions. Everything that takes a cloud
|
|
720
|
+
* counts it in, and what makes one of another keeps it.
|
|
721
|
+
*/
|
|
722
|
+
readonly origin?: Readonly<Vec3>;
|
|
723
|
+
}
|
|
724
|
+
/** Options of {@link parsePointCloudText} and {@link parsePointCloudBytes}. */
|
|
725
|
+
interface ParsePointCloudOptions {
|
|
726
|
+
/**
|
|
727
|
+
* Read the positions in `f64` and keep them around the centre of their
|
|
728
|
+
* bounds, which is the cloud's `origin`, so that points far from zero keep
|
|
729
|
+
* their digits. Defaults to `false`: `f32` world positions.
|
|
730
|
+
*/
|
|
731
|
+
center?: boolean;
|
|
732
|
+
}
|
|
733
|
+
interface OutlierReport {
|
|
734
|
+
keptCount: number;
|
|
735
|
+
removedCount: number;
|
|
736
|
+
meanDistance: number;
|
|
737
|
+
stdDev: number;
|
|
738
|
+
threshold: number;
|
|
739
|
+
}
|
|
740
|
+
interface PointCloudFilterResult {
|
|
741
|
+
cloud: PackedPointCloud;
|
|
742
|
+
report: OutlierReport;
|
|
743
|
+
}
|
|
744
|
+
interface SurfaceReconstructOptions {
|
|
745
|
+
method?: SurfaceReconstructMethod;
|
|
746
|
+
voxelSize?: number;
|
|
747
|
+
ballRadius?: number;
|
|
748
|
+
kNeighbors?: number;
|
|
749
|
+
normals?: boolean;
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* Packs position (and optional normal/color) buffers into a {@link PackedPointCloud}.
|
|
753
|
+
*
|
|
754
|
+
* With `origin`, the positions (world coordinates, in a `Float64Array` or an
|
|
755
|
+
* array to have more than `f32`) are stored relative to it, and it becomes the
|
|
756
|
+
* cloud's `origin`: give a point near a cloud that is far from zero.
|
|
757
|
+
*/
|
|
758
|
+
declare function packPointCloud(positions: Positions, normals?: Positions, colors?: Positions, origin?: Readonly<Vec3>): PackedPointCloud;
|
|
759
|
+
/** Unpacks a {@link PackedPointCloud} into separate typed arrays. The positions are relative to `origin`. */
|
|
760
|
+
declare function unpackPointCloud(cloud: PackedPointCloud | Float32Array): {
|
|
761
|
+
count: number;
|
|
762
|
+
positions: Float32Array;
|
|
763
|
+
normals: Float32Array | null;
|
|
764
|
+
colors: Float32Array | null;
|
|
765
|
+
/** The cloud's `origin`: `[0, 0, 0]` for world positions. */
|
|
766
|
+
origin: Vec3;
|
|
767
|
+
};
|
|
768
|
+
type HollowBackend = "bvhSdf" | "fhEdt";
|
|
769
|
+
type PlaceUpAxis = "negZ" | "posZ" | "posY" | "negY";
|
|
770
|
+
type PlaceMode = "keepSeparate" | "appendShell" | "embedUnion" | "engraveSubtract";
|
|
771
|
+
/** Options for {@link Scene.hollowMesh}; lengths and volumes in the mesh's own units, before its placement's scale. */
|
|
772
|
+
interface HollowOptions {
|
|
773
|
+
wallThickness: number;
|
|
774
|
+
backend?: HollowBackend;
|
|
775
|
+
voxelSize?: number;
|
|
776
|
+
maxVoxels?: number;
|
|
777
|
+
maxCavityTriangles?: number;
|
|
778
|
+
minCavityVolume?: number;
|
|
779
|
+
wallModulation?: {
|
|
780
|
+
vertices: Indices;
|
|
781
|
+
weights: Float32Array | ArrayLike<number>;
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
interface HollowReport {
|
|
785
|
+
cavitiesCreated: number;
|
|
786
|
+
cavityVertices: number;
|
|
787
|
+
cavityTriangles: number;
|
|
788
|
+
cavityVolume: number;
|
|
789
|
+
voxelSize: number;
|
|
790
|
+
uvsDropped: boolean;
|
|
791
|
+
}
|
|
792
|
+
interface DrainHoleOptions {
|
|
793
|
+
surfacePoint: Readonly<Vec3>;
|
|
794
|
+
surfaceNormal: Readonly<Vec3>;
|
|
795
|
+
diameter: number;
|
|
796
|
+
depth?: number;
|
|
797
|
+
outerChamfer?: number;
|
|
798
|
+
taperAngleDeg?: number;
|
|
799
|
+
segments?: number;
|
|
800
|
+
booleanMethod?: BooleanMethod;
|
|
801
|
+
fallbackBvhSdf?: boolean;
|
|
802
|
+
generatePlug?: boolean;
|
|
803
|
+
plugClearance?: number;
|
|
804
|
+
plugNormals?: boolean;
|
|
805
|
+
}
|
|
806
|
+
interface DrainHoleReport {
|
|
807
|
+
holesPunched: number;
|
|
808
|
+
keptTriangles: number;
|
|
809
|
+
usedFallback: boolean;
|
|
810
|
+
plugs: MeshHandle[];
|
|
811
|
+
methodUsed: BooleanMethod;
|
|
812
|
+
uvsDropped: boolean;
|
|
813
|
+
}
|
|
814
|
+
interface PlaceTransform {
|
|
815
|
+
rotation: number[];
|
|
816
|
+
translation: Vec3;
|
|
817
|
+
scale: number;
|
|
818
|
+
}
|
|
819
|
+
interface PlaceMeshOptions {
|
|
820
|
+
hitPoint: Readonly<Vec3>;
|
|
821
|
+
hitNormal: Readonly<Vec3>;
|
|
822
|
+
/**
|
|
823
|
+
* The point of the stamp that goes to the hit point, in the stamp's own
|
|
824
|
+
* coordinates: those it was added with, before its placement (of which only
|
|
825
|
+
* the scale counts). Defaults to their zero; for a stamp more than 1024
|
|
826
|
+
* times its size away from that, such as one modelled far from the world
|
|
827
|
+
* origin, to the middle of its underside (the side of its bounds away from
|
|
828
|
+
* `upAxis`).
|
|
829
|
+
*/
|
|
830
|
+
stampAnchor?: Readonly<Vec3>;
|
|
831
|
+
upAxis?: PlaceUpAxis;
|
|
832
|
+
twistAngleRad?: number;
|
|
833
|
+
uniformScale?: number;
|
|
834
|
+
embedDepth?: number;
|
|
835
|
+
mode?: PlaceMode;
|
|
836
|
+
conformToSurface?: boolean;
|
|
837
|
+
booleanMethod?: BooleanMethod;
|
|
838
|
+
normals?: boolean;
|
|
839
|
+
}
|
|
840
|
+
interface PlaceMeshReport {
|
|
841
|
+
/** Takes the stamp's own coordinates, times its placement's scale, to the world: scaled, then turned, then moved. */
|
|
842
|
+
transform: PlaceTransform;
|
|
843
|
+
keptTriangles: number;
|
|
844
|
+
usedFallback: boolean;
|
|
845
|
+
conformMaxDisplacement: number;
|
|
846
|
+
added: MeshHandle | null;
|
|
847
|
+
uvsDropped: boolean;
|
|
848
|
+
}
|
|
849
|
+
/** Options for `convexHull` and `convexHullOfPoints`. */
|
|
850
|
+
interface ConvexHullOptions {
|
|
851
|
+
/** Turn on the new mesh's smooth vertex normals, as `addMesh` does (default `true`). */
|
|
852
|
+
normals?: boolean;
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* Points for `convexHullOfPoints`: flat world positions `[x0, y0, z0, x1, ...]`
|
|
856
|
+
* (`Float32Array`, `Float64Array` or numbers), or a {@link PackedPointCloud},
|
|
857
|
+
* whose positions are used (its normals and colours are ignored), around its
|
|
858
|
+
* `origin` if it has one. A bare
|
|
859
|
+
* `Float32Array` is always read as flat positions, never as a packed cloud.
|
|
860
|
+
*/
|
|
861
|
+
type ConvexHullPoints = Positions64 | PackedPointCloud;
|
|
862
|
+
/** What `convexHull` or `convexHullOfPoints` added. */
|
|
863
|
+
interface ConvexHullResult {
|
|
864
|
+
/** The new mesh holding the hull: closed, outward-wound, one undo step. */
|
|
865
|
+
mesh: MeshHandle;
|
|
866
|
+
/** Points the hull was built from; for meshes, the vertices their live triangles use. */
|
|
867
|
+
inputPoints: number;
|
|
868
|
+
/** Vertices of the hull: input points, including every corner. */
|
|
869
|
+
vertices: number;
|
|
870
|
+
/** Triangles of the hull. */
|
|
871
|
+
triangles: number;
|
|
872
|
+
}
|
|
873
|
+
/** The default `maxVoxels` of a lattice: 256 x 256 x 256. */
|
|
874
|
+
declare const DEFAULT_LATTICE_MAX_VOXELS = 16777216;
|
|
875
|
+
/** The default `maxVoxels` of a lattice preview: a million. */
|
|
876
|
+
declare const DEFAULT_LATTICE_PREVIEW_VOXELS = 1000000;
|
|
877
|
+
/**
|
|
878
|
+
* The surface a lattice's walls follow:
|
|
879
|
+
* - `"gyroid"`: no straight lines and no mirror planes, about as stiff in
|
|
880
|
+
* every direction.
|
|
881
|
+
* - `"schwarzP"`: a cubic grid of round chambers joined by necks.
|
|
882
|
+
* - `"diamond"`: the most wall of the three for the same cell size and wall
|
|
883
|
+
* thickness.
|
|
884
|
+
*/
|
|
885
|
+
type LatticeKind = "gyroid" | "schwarzP" | "diamond";
|
|
886
|
+
/**
|
|
887
|
+
* What a lattice fills:
|
|
888
|
+
* - `"inside"`: the inside of the mesh, its material.
|
|
889
|
+
* - `"cavity"`: the cavities the mesh encloses, such as that of a hollowed
|
|
890
|
+
* mesh. A cavity that a hole opens to the outside is not enclosed: fill it
|
|
891
|
+
* before making the hole.
|
|
892
|
+
* - `"auto"`: the cavities when they make up at least a tenth of what the
|
|
893
|
+
* surfaces around them enclose (a hollowed mesh), else the inside: a few
|
|
894
|
+
* bubbles do not make a mesh hollow.
|
|
895
|
+
*/
|
|
896
|
+
type LatticeRegion = "auto" | "inside" | "cavity";
|
|
897
|
+
/** Options for `latticeFill`, `latticePlan` and `latticePreview`; lengths in world units. */
|
|
898
|
+
interface LatticeOptions {
|
|
899
|
+
/** The surface the walls follow (default `"gyroid"`). */
|
|
900
|
+
kind?: LatticeKind;
|
|
901
|
+
/** The edge length of one cell. Positive and finite. */
|
|
902
|
+
cellSize: number;
|
|
903
|
+
/** The thickness of the walls. Positive, and at most a third of `cellSize`. */
|
|
904
|
+
wallThickness: number;
|
|
905
|
+
/**
|
|
906
|
+
* How thick a solid shell is left inside the region's boundary before the
|
|
907
|
+
* lattice starts; not negative, default `0`. With a shell the mesh's own
|
|
908
|
+
* surface is kept as it is; without one, filling the inside turns the whole
|
|
909
|
+
* mesh into an open lattice. In a cavity the shell comes on top of the wall
|
|
910
|
+
* that is there.
|
|
911
|
+
*/
|
|
912
|
+
shellThickness?: number;
|
|
913
|
+
/** What is filled (default `"auto"`). */
|
|
914
|
+
region?: LatticeRegion;
|
|
915
|
+
/**
|
|
916
|
+
* The voxel size. Without it, it follows from the lengths: 2.5 voxels to a
|
|
917
|
+
* wall, at least 16 to a cell and 2 to a shell. At least two voxels must
|
|
918
|
+
* make a wall and the shell of an inside, and eight a cell.
|
|
919
|
+
*/
|
|
920
|
+
voxelSize?: number;
|
|
921
|
+
/**
|
|
922
|
+
* The largest voxel grid accepted, a whole number of at least 64. For
|
|
923
|
+
* `latticeFill` and `latticePlan`, default
|
|
924
|
+
* {@link DEFAULT_LATTICE_MAX_VOXELS}: a fill over it is refused before
|
|
925
|
+
* anything is allocated. For `latticePreview`, default
|
|
926
|
+
* {@link DEFAULT_LATTICE_PREVIEW_VOXELS}: the preview gets coarser to fit.
|
|
927
|
+
*/
|
|
928
|
+
maxVoxels?: number;
|
|
929
|
+
/**
|
|
930
|
+
* Connected pieces of the result that enclose less than this share of a
|
|
931
|
+
* cell's volume are left out: loose bits of wall at the surface of an open
|
|
932
|
+
* lattice, and pockets too small to matter in a shell. Not negative,
|
|
933
|
+
* default `0.01`.
|
|
934
|
+
*/
|
|
935
|
+
minFragment?: number;
|
|
936
|
+
}
|
|
937
|
+
/** The voxel grid of a lattice and what to expect of it, known before it runs. */
|
|
938
|
+
interface LatticePlan {
|
|
939
|
+
/** What is filled. */
|
|
940
|
+
region: "inside" | "cavity";
|
|
941
|
+
/** Grid nodes along x, y and z. */
|
|
942
|
+
dims: [number, number, number];
|
|
943
|
+
/** The voxel size in world units. */
|
|
944
|
+
voxelSize: number;
|
|
945
|
+
/** The thickness of the walls: as asked for, except in a preview on a grid too coarse for it. */
|
|
946
|
+
wallThickness: number;
|
|
947
|
+
/** Grid nodes in all. */
|
|
948
|
+
voxels: number;
|
|
949
|
+
/** Estimated triangles of the result. */
|
|
950
|
+
triangles: number;
|
|
951
|
+
/**
|
|
952
|
+
* The estimated peak memory of the grid, the extraction and the result, in
|
|
953
|
+
* bytes. The mesh and its search tree come on top.
|
|
954
|
+
*/
|
|
955
|
+
bytes: number;
|
|
956
|
+
/** The limit the plan was checked against. */
|
|
957
|
+
maxVoxels: number;
|
|
958
|
+
/** Whether `voxels <= maxVoxels`; `latticeFill` refuses the plan otherwise. */
|
|
959
|
+
fits: boolean;
|
|
960
|
+
/** The share of space the walls fill, without any shell, from 0 to 1. */
|
|
961
|
+
solidFraction: number;
|
|
962
|
+
/** The world volume of the region that is filled. */
|
|
963
|
+
regionVolume: number;
|
|
964
|
+
/** Whether the grid covers only the middle of the mesh (a preview of many small cells). */
|
|
965
|
+
cropped: boolean;
|
|
966
|
+
}
|
|
967
|
+
/** What `latticeFill` did. */
|
|
968
|
+
interface LatticeReport {
|
|
969
|
+
/** Vertices added. */
|
|
970
|
+
vertices: number;
|
|
971
|
+
/** Triangles added. */
|
|
972
|
+
triangles: number;
|
|
973
|
+
/** Loose pieces left out (see `minFragment`). */
|
|
974
|
+
fragments: number;
|
|
975
|
+
/**
|
|
976
|
+
* The world volume of material in the region now, walls and shell. Divided
|
|
977
|
+
* by `plan.regionVolume` it is the share that is left.
|
|
978
|
+
*/
|
|
979
|
+
solidVolume: number;
|
|
980
|
+
/** Whether the mesh's UVs were dropped (undo restores them). */
|
|
981
|
+
uvsDropped: boolean;
|
|
982
|
+
/** The voxel grid used. */
|
|
983
|
+
plan: LatticePlan;
|
|
984
|
+
}
|
|
985
|
+
/** What `latticePreview` built. */
|
|
986
|
+
interface LatticePreview {
|
|
987
|
+
/** The walls' positions (xyz per vertex), in the mesh's local frame. */
|
|
988
|
+
positions: Float32Array;
|
|
989
|
+
/** The walls' triangles (3 vertices each), closed and wound outward; empty without walls. */
|
|
990
|
+
indices: Uint32Array;
|
|
991
|
+
/** The grid used, with the thickness the walls are drawn with. */
|
|
992
|
+
plan: LatticePlan;
|
|
993
|
+
}
|
|
994
|
+
/** The default `detail` of a wrap: voxels along the longest side of the meshes' bounds. */
|
|
995
|
+
declare const DEFAULT_WRAP_DETAIL = 128;
|
|
996
|
+
/** The default `maxVoxels` of a wrap: 256 x 256 x 256. */
|
|
997
|
+
declare const DEFAULT_WRAP_MAX_VOXELS = 16777216;
|
|
998
|
+
/** Options for `wrapPlan`: the grid's part of {@link WrapOptions}. */
|
|
999
|
+
interface WrapGridOptions {
|
|
1000
|
+
/**
|
|
1001
|
+
* The widest gap, slot or hole that gets closed, in world units: openings
|
|
1002
|
+
* narrower than this are bridged (at least two voxels are). Finite and not
|
|
1003
|
+
* negative; default `0`.
|
|
1004
|
+
*/
|
|
1005
|
+
gap?: number;
|
|
1006
|
+
/** The voxel size in world units. Without it, `detail` sets it. */
|
|
1007
|
+
voxelSize?: number;
|
|
1008
|
+
/**
|
|
1009
|
+
* Voxels along the longest side of the meshes' bounds when `voxelSize` is
|
|
1010
|
+
* not given: a whole number from 8 to 4096, default
|
|
1011
|
+
* {@link DEFAULT_WRAP_DETAIL}.
|
|
1012
|
+
*/
|
|
1013
|
+
detail?: number;
|
|
1014
|
+
/**
|
|
1015
|
+
* The largest voxel grid accepted, a whole number of at least 64, default
|
|
1016
|
+
* {@link DEFAULT_WRAP_MAX_VOXELS}. A wrap over it is refused before
|
|
1017
|
+
* anything is allocated.
|
|
1018
|
+
*/
|
|
1019
|
+
maxVoxels?: number;
|
|
1020
|
+
}
|
|
1021
|
+
/** Options for `wrap`. */
|
|
1022
|
+
interface WrapOptions extends WrapGridOptions {
|
|
1023
|
+
/**
|
|
1024
|
+
* Move the wrap's vertices that lie within one voxel of the meshes onto
|
|
1025
|
+
* them, wherever that keeps the surface free of self-intersections.
|
|
1026
|
+
* Recovers detail and sharp features the voxels round off. Default `false`.
|
|
1027
|
+
*/
|
|
1028
|
+
project?: boolean;
|
|
1029
|
+
/** Turn on the new mesh's smooth vertex normals, as `addMesh` does (default `true`). */
|
|
1030
|
+
normals?: boolean;
|
|
1031
|
+
}
|
|
1032
|
+
/** The voxel grid of a wrap, known before it runs. */
|
|
1033
|
+
interface WrapPlan {
|
|
1034
|
+
/** Grid nodes along x, y and z. */
|
|
1035
|
+
dims: [number, number, number];
|
|
1036
|
+
/** The voxel size in world units. */
|
|
1037
|
+
voxelSize: number;
|
|
1038
|
+
/** The closing radius in world units: half the gap, at least one voxel. */
|
|
1039
|
+
radius: number;
|
|
1040
|
+
/** Grid nodes in all. */
|
|
1041
|
+
voxels: number;
|
|
1042
|
+
/**
|
|
1043
|
+
* The estimated peak memory of the grid, in bytes. The meshes, what is
|
|
1044
|
+
* extracted from the grid and their search trees come on top.
|
|
1045
|
+
*/
|
|
1046
|
+
bytes: number;
|
|
1047
|
+
/** The limit the plan was checked against. */
|
|
1048
|
+
maxVoxels: number;
|
|
1049
|
+
/** Whether `voxels <= maxVoxels`; `wrap` refuses the plan otherwise. */
|
|
1050
|
+
fits: boolean;
|
|
1051
|
+
}
|
|
1052
|
+
/** What `wrap` added. */
|
|
1053
|
+
interface WrapResult {
|
|
1054
|
+
/** The new mesh holding the wrap: closed, manifold, outward-wound, one undo step. */
|
|
1055
|
+
mesh: MeshHandle;
|
|
1056
|
+
/** Vertices of the wrap. */
|
|
1057
|
+
vertices: number;
|
|
1058
|
+
/** Triangles of the wrap. */
|
|
1059
|
+
triangles: number;
|
|
1060
|
+
/** Vertices of the wrap moved onto the meshes (`0` without `project`). */
|
|
1061
|
+
projected: number;
|
|
1062
|
+
/** The voxel grid used. */
|
|
1063
|
+
plan: WrapPlan;
|
|
1064
|
+
}
|
|
1065
|
+
/** `[start, count]` in elements: vertex slots, or triangle slots for indices. */
|
|
1066
|
+
type Range = readonly [start: number, count: number];
|
|
1067
|
+
/**
|
|
1068
|
+
* The default history budget: 256 MiB. See {@link SceneOptions.historyBudget}.
|
|
1069
|
+
*/
|
|
1070
|
+
declare const DEFAULT_HISTORY_BUDGET: number;
|
|
1071
|
+
/**
|
|
1072
|
+
* A step the undo history could not keep, since it is larger than the whole
|
|
1073
|
+
* budget; from {@link Scene.onPermanent}.
|
|
1074
|
+
*/
|
|
1075
|
+
interface PermanentStep {
|
|
1076
|
+
/**
|
|
1077
|
+
* What can no longer be done with it: `"undo"` for a step just made (or
|
|
1078
|
+
* redone), which is now permanent; `"redo"` for one just undone.
|
|
1079
|
+
*/
|
|
1080
|
+
lost: "undo" | "redo";
|
|
1081
|
+
/**
|
|
1082
|
+
* The meshes the step edited, moved, added or removed, each once (none for
|
|
1083
|
+
* a step of application entries alone). Those in `gone` are out of the
|
|
1084
|
+
* scene, and calls on them give `UNKNOWN_MESH`.
|
|
1085
|
+
*/
|
|
1086
|
+
meshes: readonly MeshHandle[];
|
|
1087
|
+
/** Of those, the meshes that left the scene with the step, for good. */
|
|
1088
|
+
gone: readonly MeshHandle[];
|
|
1089
|
+
/** The bytes the step counted, more than the history budget. */
|
|
1090
|
+
bytes: number;
|
|
1091
|
+
}
|
|
1092
|
+
/** Called with each step the history could not keep. */
|
|
1093
|
+
type PermanentListener = (step: PermanentStep) => void;
|
|
1094
|
+
/**
|
|
1095
|
+
* An entry of the application's own in the undo history, for
|
|
1096
|
+
* {@link Scene.recordEntry}. The object itself can be the payload: its
|
|
1097
|
+
* functions are called as methods of it.
|
|
1098
|
+
*/
|
|
1099
|
+
interface HistoryEntry {
|
|
1100
|
+
/**
|
|
1101
|
+
* Takes the application back to before the entry. Called when undo reaches
|
|
1102
|
+
* it, or its open step is cancelled, once the step's meshes have changed.
|
|
1103
|
+
*/
|
|
1104
|
+
undo(): void;
|
|
1105
|
+
/** Takes the application to after the entry again. Called when redo reaches it. */
|
|
1106
|
+
redo(): void;
|
|
1107
|
+
/**
|
|
1108
|
+
* Called once when the history lets go of the entry: neither `undo` nor
|
|
1109
|
+
* `redo` is called any more, so what they need can be released. That is
|
|
1110
|
+
* when its step is evicted for the budget, its redo branch is dropped by a
|
|
1111
|
+
* newer step, its step was cancelled (after `undo`), the history is
|
|
1112
|
+
* cleared, or the scene is freed, terminated or restarted.
|
|
1113
|
+
*/
|
|
1114
|
+
drop?(): void;
|
|
1115
|
+
/**
|
|
1116
|
+
* About the bytes the entry keeps alive, counted against
|
|
1117
|
+
* {@link SceneOptions.historyBudget} until it is dropped, with a few
|
|
1118
|
+
* hundred for the entry itself. 0 by default.
|
|
1119
|
+
*/
|
|
1120
|
+
readonly bytes?: number;
|
|
1121
|
+
/**
|
|
1122
|
+
* Within an open step, an entry recorded right after one with the same
|
|
1123
|
+
* `coalesce` merges with it, as the moves of a drag do: undo then calls the
|
|
1124
|
+
* first one's `undo`, redo the last one's `redo`, and those in between are
|
|
1125
|
+
* dropped. Anything else recorded in between starts a new run.
|
|
1126
|
+
*/
|
|
1127
|
+
readonly coalesce?: string;
|
|
1128
|
+
}
|
|
1129
|
+
/** What happened to an entry: `what` as `WasmScene.next_entry_event` codes it. */
|
|
1130
|
+
declare const ENTRY_EVENTS: readonly ["undo", "redo", "drop"];
|
|
1131
|
+
/** See {@link ENTRY_EVENTS}. */
|
|
1132
|
+
type EntryEvent = (typeof ENTRY_EVENTS)[number];
|
|
1133
|
+
/** A snapshot of selected vertices of one mesh; see the module docs. */
|
|
1134
|
+
interface VertexSelection {
|
|
1135
|
+
/** The mesh selected from. */
|
|
1136
|
+
mesh: MeshHandle;
|
|
1137
|
+
/** The selected vertex slots, ascending. */
|
|
1138
|
+
vertices: Uint32Array;
|
|
1139
|
+
/** The mesh's content stamp when taken; see `Scene.selectionAlive`. */
|
|
1140
|
+
stamp: number;
|
|
1141
|
+
}
|
|
1142
|
+
/** A sphere brush: every used vertex within `radius` of `center`. */
|
|
1143
|
+
interface BrushSelect {
|
|
1144
|
+
kind: "brush";
|
|
1145
|
+
/** Brush centre; `space` says which coordinates it is in. */
|
|
1146
|
+
center: Readonly<Vec3>;
|
|
1147
|
+
/** Radius in the same units; 0 selects vertices exactly at `center`. */
|
|
1148
|
+
radius: number;
|
|
1149
|
+
/**
|
|
1150
|
+
* `"local"` (mesh render coordinates, as in `views(mesh).positions()`) or
|
|
1151
|
+
* `"world"` (converted with the mesh's placement at call time). Defaults
|
|
1152
|
+
* to `"local"`.
|
|
1153
|
+
*/
|
|
1154
|
+
space?: "local" | "world";
|
|
1155
|
+
}
|
|
1156
|
+
/**
|
|
1157
|
+
* A 2D polygon: every used vertex whose projection falls inside it.
|
|
1158
|
+
* Project your screen-space polygon to mesh-local coordinates with your
|
|
1159
|
+
* camera first; `axis` picks the projection plane.
|
|
1160
|
+
*/
|
|
1161
|
+
interface LassoSelect {
|
|
1162
|
+
kind: "lasso";
|
|
1163
|
+
/** Flat `[x0, y0, x1, y1, ...]` polygon corners in local coordinates. */
|
|
1164
|
+
polygon: Float32Array | readonly number[];
|
|
1165
|
+
/** The local plane projected onto. Defaults to `"xy"`. */
|
|
1166
|
+
axis?: "xy" | "xz" | "yz";
|
|
1167
|
+
}
|
|
1168
|
+
/** The connected component (over shared triangle edges) holding `seed`. */
|
|
1169
|
+
interface ComponentSelect {
|
|
1170
|
+
kind: "component";
|
|
1171
|
+
/** A vertex slot of the component to pick; it must be alive. */
|
|
1172
|
+
seed: number;
|
|
1173
|
+
}
|
|
1174
|
+
/** What `Scene.select` takes. */
|
|
1175
|
+
type SelectSpec = BrushSelect | LassoSelect | ComponentSelect;
|
|
1176
|
+
/** What `Scene.isolate` did. */
|
|
1177
|
+
interface IsolateReport {
|
|
1178
|
+
/** Triangles fully outside the selection that were removed. */
|
|
1179
|
+
removedTriangles: number;
|
|
1180
|
+
/** The same vertex set with the post-edit stamp. */
|
|
1181
|
+
selection: VertexSelection;
|
|
1182
|
+
}
|
|
1183
|
+
/**
|
|
1184
|
+
* Zero-copy views of one mesh's render buffers, slot-aligned.
|
|
1185
|
+
*
|
|
1186
|
+
* Each getter builds a fresh view over the current wasm memory. A view is
|
|
1187
|
+
* only valid until the next scene call that may allocate or move buffers
|
|
1188
|
+
* (any edit, add, undo, query, ...): the buffer may have moved, so a kept
|
|
1189
|
+
* view may read other data, or be empty once the memory grew. Re-acquire
|
|
1190
|
+
* views after every scene call and do not keep them. With
|
|
1191
|
+
* `new Scene({ debug: true })` reading a kept view warns.
|
|
1192
|
+
*/
|
|
1193
|
+
interface MeshViews {
|
|
1194
|
+
/** Local positions, 3 floats per vertex slot; dead slots hold stale data. */
|
|
1195
|
+
positions(): Float32Array;
|
|
1196
|
+
/**
|
|
1197
|
+
* Vertex normals, 3 floats per vertex slot, or `null` when normals are off.
|
|
1198
|
+
* For a `"lazy"` or `"manual"` mesh it can be shorter than 3 · vertex slots
|
|
1199
|
+
* after a growth, until the mesh is updated ({@link Scene.update}).
|
|
1200
|
+
*/
|
|
1201
|
+
normals(): Float32Array | null;
|
|
1202
|
+
/** RGBA8 colours, 4 bytes per vertex slot, or `null` without colouring. */
|
|
1203
|
+
colors(): Uint8Array | null;
|
|
1204
|
+
/**
|
|
1205
|
+
* The values the colours are made from (the colouring field's values), 1
|
|
1206
|
+
* float per vertex slot, or `null` without colouring. They change only at
|
|
1207
|
+
* the colours' dirty slots, so they follow the `colors` change ranges.
|
|
1208
|
+
* Optional for other {@link SceneLike} hosts; `Scene` and `WorkerScene`
|
|
1209
|
+
* provide it.
|
|
1210
|
+
*/
|
|
1211
|
+
values?(): Float32Array | null;
|
|
1212
|
+
/**
|
|
1213
|
+
* Texture coordinates, 2 floats per vertex slot, or `null` for a mesh
|
|
1214
|
+
* without them (never given, or dropped by an operation: see
|
|
1215
|
+
* `docs/uv-channel.md`). Optional for other {@link SceneLike} hosts; `Scene`
|
|
1216
|
+
* and `WorkerScene` provide it ({@link SceneMeshViews}).
|
|
1217
|
+
*/
|
|
1218
|
+
uvs?(): Float32Array | null;
|
|
1219
|
+
/** 3 vertex indices per triangle slot; a removed triangle reads `0, 0, 0`. */
|
|
1220
|
+
indices(): Uint32Array;
|
|
1221
|
+
}
|
|
1222
|
+
/** {@link MeshViews} of `Scene` and `WorkerScene`, which always provide `uvs`. */
|
|
1223
|
+
interface SceneMeshViews extends MeshViews {
|
|
1224
|
+
uvs(): Float32Array | null;
|
|
1225
|
+
}
|
|
1226
|
+
/** Serializes contour slices to SVG, JSON, or CSV. */
|
|
1227
|
+
declare function sliceContoursExport(slices: ContourSlice | readonly ContourSlice[], format: ContourExportFormat): string;
|
|
1228
|
+
/**
|
|
1229
|
+
* Parses ASCII point cloud text (`"xyz"`, `"pcd"`, or `"ply"`). Positions are
|
|
1230
|
+
* read in `f32`, which far from zero loses digits (0.004 at 1e5);
|
|
1231
|
+
* `options.center` keeps them.
|
|
1232
|
+
*/
|
|
1233
|
+
declare function parsePointCloudText(text: string, format?: PointCloudFormat, options?: ParsePointCloudOptions): PackedPointCloud;
|
|
1234
|
+
/** Parses binary/ASCII `.ply` point cloud bytes, as {@link parsePointCloudText} reads text. */
|
|
1235
|
+
declare function parsePointCloudBytes(bytes: Uint8Array, options?: ParsePointCloudOptions): PackedPointCloud;
|
|
1236
|
+
/** Runs Statistical Outlier Removal (SOR) on a point cloud. */
|
|
1237
|
+
declare function pointCloudSor(cloud: PackedPointCloud | Float32Array, kNeighbors?: number, stdRatio?: number): PointCloudFilterResult;
|
|
1238
|
+
/** Runs Radius Outlier Removal (ROR) on a point cloud. */
|
|
1239
|
+
declare function pointCloudRor(cloud: PackedPointCloud | Float32Array, radius: number, minNeighbors?: number): PointCloudFilterResult;
|
|
1240
|
+
/** Voxel-grid downsamples a point cloud. */
|
|
1241
|
+
declare function pointCloudVoxelDownsample(cloud: PackedPointCloud | Float32Array, voxelSize: number): PackedPointCloud;
|
|
1242
|
+
/** Estimates and orients normals on a point cloud; `cameraHint` is a world point they face. */
|
|
1243
|
+
declare function pointCloudEstimateNormals(cloud: PackedPointCloud | Float32Array, kNeighbors?: number, cameraHint?: Readonly<Vec3>): PackedPointCloud;
|
|
1244
|
+
/**
|
|
1245
|
+
* What changed in one mesh since the previous {@link Scene.takeChanges}.
|
|
1246
|
+
* Range lists are ascending; `"all"` means re-upload the whole buffer.
|
|
1247
|
+
*/
|
|
1248
|
+
interface MeshChange {
|
|
1249
|
+
mesh: MeshHandle;
|
|
1250
|
+
/**
|
|
1251
|
+
* The mesh was added, or is back (an undone removal, a redone add); every
|
|
1252
|
+
* buffer is `"all"`. A mesh that is back has the handle it had.
|
|
1253
|
+
*/
|
|
1254
|
+
added: boolean;
|
|
1255
|
+
/**
|
|
1256
|
+
* The mesh was removed (by a call, by the undo of its add or by the redo
|
|
1257
|
+
* of its removal); drop its GPU buffers. Nothing else is set but
|
|
1258
|
+
* {@link MeshChange.restorable}.
|
|
1259
|
+
*/
|
|
1260
|
+
removed: boolean;
|
|
1261
|
+
/**
|
|
1262
|
+
* Only on a removal: undo or redo can bring the mesh back, as `added` with
|
|
1263
|
+
* the same handle (see {@link Scene.isRestorable}). Keep what shows it.
|
|
1264
|
+
*/
|
|
1265
|
+
restorable?: true;
|
|
1266
|
+
/** Its placement changed: read {@link Scene.matrix4} again. */
|
|
1267
|
+
placementChanged: boolean;
|
|
1268
|
+
/**
|
|
1269
|
+
* Its vertex or triangle slot count changed: recreate its GPU buffers. Every
|
|
1270
|
+
* buffer is then `"all"`, so upload each one whole.
|
|
1271
|
+
*/
|
|
1272
|
+
capacityChanged: boolean;
|
|
1273
|
+
/** Vertex slots. */
|
|
1274
|
+
positions: Range[] | "all";
|
|
1275
|
+
/** Vertex slots. */
|
|
1276
|
+
normals: Range[] | "all";
|
|
1277
|
+
/** Vertex slots. */
|
|
1278
|
+
colors: Range[] | "all";
|
|
1279
|
+
/** Triangle slots. */
|
|
1280
|
+
indices: Range[] | "all";
|
|
1281
|
+
/**
|
|
1282
|
+
* Vertex slots. Only on a record of a mesh that has UVs or just lost them:
|
|
1283
|
+
* `"all"` with `views(mesh).uvs()` reading `null` means an operation dropped
|
|
1284
|
+
* them, and `"all"` after `undo` that they came back.
|
|
1285
|
+
*/
|
|
1286
|
+
uvs?: Range[] | "all";
|
|
1287
|
+
fieldsChanged: FieldHandle[];
|
|
1288
|
+
sectionsChanged: SectionHandle[];
|
|
1289
|
+
}
|
|
1290
|
+
/**
|
|
1291
|
+
* A drag of one mesh: every {@link DragSession.move} until
|
|
1292
|
+
* {@link DragSession.end} is one undo step.
|
|
1293
|
+
*
|
|
1294
|
+
* The drag is over once it is ended or cancelled, and also when its step goes
|
|
1295
|
+
* away without it: an `undo()`, `redo()`, `clearHistory()` or `removeMesh()` of
|
|
1296
|
+
* the dragged mesh ends it first, and a `cancelStep()` (or an `endStep()` that closes the drag's step) abandons it.
|
|
1297
|
+
* An `endStep()` lands a pending coalesced pose in the closing step first; a
|
|
1298
|
+
* `cancelStep()` drops it with the step.
|
|
1299
|
+
*/
|
|
1300
|
+
interface DragSession {
|
|
1301
|
+
/**
|
|
1302
|
+
* Sets the mesh's placement. Throws `INVALID_ARGUMENT` once the drag is over.
|
|
1303
|
+
*
|
|
1304
|
+
* Each move recomputes the eager fields that depend on the mesh, so
|
|
1305
|
+
* coalesce pointer events to one move per animation frame (keep the latest
|
|
1306
|
+
* pose and apply it before {@link Scene.commitFrame}), or start the drag
|
|
1307
|
+
* with {@link DragOptions.coalesce}.
|
|
1308
|
+
*/
|
|
1309
|
+
move(placement: PlacementInput): void;
|
|
1310
|
+
/**
|
|
1311
|
+
* False once the drag is over: ended, cancelled, or ended or abandoned by
|
|
1312
|
+
* the scene (`undo()`, `redo()`, `clearHistory()`, `endStep()`,
|
|
1313
|
+
* `cancelStep()`, `removeMesh()` of the dragged mesh).
|
|
1314
|
+
*/
|
|
1315
|
+
readonly active: boolean;
|
|
1316
|
+
/**
|
|
1317
|
+
* Finishes the drag, recording it as one undo step (closing any step levels
|
|
1318
|
+
* opened inside it too). A no-op once it is over.
|
|
1319
|
+
*/
|
|
1320
|
+
end(): void;
|
|
1321
|
+
/**
|
|
1322
|
+
* Puts the placement back to where the drag started and records nothing. A
|
|
1323
|
+
* no-op once it is over.
|
|
1324
|
+
*
|
|
1325
|
+
* When no step was open at `drag()`, this reverts the drag's whole step, so
|
|
1326
|
+
* edits made during the drag (including in steps opened inside it) are
|
|
1327
|
+
* reverted too. Inside a caller's step, it restores the placement and closes
|
|
1328
|
+
* the drag's levels, leaving the caller's step open.
|
|
1329
|
+
*/
|
|
1330
|
+
cancel(): void;
|
|
1331
|
+
}
|
|
1332
|
+
/** Options of {@link Scene.drag}. */
|
|
1333
|
+
interface DragOptions {
|
|
1334
|
+
/**
|
|
1335
|
+
* Coalesce moves: each {@link DragSession.move} only remembers its pose,
|
|
1336
|
+
* and the latest one is applied once at the next {@link Scene.commitFrame}
|
|
1337
|
+
* (or {@link DragSession.end}). For pointer events at 120–250 Hz: without
|
|
1338
|
+
* it, every move recomputes the eager fields. Until the frame,
|
|
1339
|
+
* {@link Scene.placement} and {@link Scene.matrix4} show the last applied
|
|
1340
|
+
* pose. `WorkerScene` drags always coalesce. Defaults to `false`.
|
|
1341
|
+
*/
|
|
1342
|
+
coalesce?: boolean;
|
|
1343
|
+
}
|
|
1344
|
+
/** Options of {@link Scene.addMesh}. */
|
|
1345
|
+
interface AddMeshOptions {
|
|
1346
|
+
/**
|
|
1347
|
+
* The point subtracted from every position before it is stored as `f32`.
|
|
1348
|
+
* Defaults to the bounding-box centre, which keeps local coordinates small.
|
|
1349
|
+
*/
|
|
1350
|
+
origin?: Readonly<Vec3>;
|
|
1351
|
+
/** Defaults to `"eager"`. */
|
|
1352
|
+
mode?: UpdateMode;
|
|
1353
|
+
/** Keep vertex normals up to date. Defaults to `true`. */
|
|
1354
|
+
normals?: boolean;
|
|
1355
|
+
/**
|
|
1356
|
+
* Texture coordinates: 2 finite values per vertex, stored as `f32` and read
|
|
1357
|
+
* back with `views(mesh).uvs()`. Without them the mesh has no UV channel and
|
|
1358
|
+
* pays nothing. Every operation keeps them aligned or drops them, undoably;
|
|
1359
|
+
* see `docs/uv-channel.md`. Weld keeps seams apart.
|
|
1360
|
+
*/
|
|
1361
|
+
uvs?: Float32Array | readonly number[];
|
|
1362
|
+
/**
|
|
1363
|
+
* Record the add in the history, in the open step or as a step of its own:
|
|
1364
|
+
* undo removes the mesh, redo brings it back with the same handle. Defaults
|
|
1365
|
+
* to `false` (the add is permanent).
|
|
1366
|
+
*/
|
|
1367
|
+
undoable?: boolean;
|
|
1368
|
+
}
|
|
1369
|
+
/** Options of {@link Scene.removeMesh}. */
|
|
1370
|
+
interface RemoveMeshOptions {
|
|
1371
|
+
/**
|
|
1372
|
+
* Remove the mesh as an undo step, or as part of the open one: undo brings
|
|
1373
|
+
* it back with the same handle. Defaults to `false` (removed for good, and
|
|
1374
|
+
* its history entries with it).
|
|
1375
|
+
*/
|
|
1376
|
+
undoable?: boolean;
|
|
1377
|
+
}
|
|
1378
|
+
/** Options of the {@link Scene} constructor. */
|
|
1379
|
+
interface SceneOptions {
|
|
1380
|
+
/**
|
|
1381
|
+
* Development checks, off by default. Render views ({@link Scene.views},
|
|
1382
|
+
* {@link Scene.fieldValues}) are then `Proxy` objects that warn once per
|
|
1383
|
+
* scene (`console.warn`, no throw) when read after a scene call that may
|
|
1384
|
+
* have moved or freed their buffer. Read-only calls (slot counts,
|
|
1385
|
+
* `placement`, `matrix4`, `canUndo`, ...) keep views valid. Proxies are
|
|
1386
|
+
* slower and are not genuine typed arrays: pass `view.subarray()` (a plain
|
|
1387
|
+
* typed array) to APIs that need one, such as `queue.writeBuffer`. Without
|
|
1388
|
+
* `debug`, views are plain typed arrays with no overhead.
|
|
1389
|
+
*/
|
|
1390
|
+
debug?: boolean;
|
|
1391
|
+
/**
|
|
1392
|
+
* The most bytes the undo history may hold: {@link DEFAULT_HISTORY_BUDGET}
|
|
1393
|
+
* (256 MiB) by default. What counts are the patches of edits, placement
|
|
1394
|
+
* changes, meshes out of the scene that undo or redo can bring back (about
|
|
1395
|
+
* 60 bytes a triangle), and what the application's entries say they hold
|
|
1396
|
+
* ({@link HistoryEntry.bytes}). Past it the oldest steps go. A step larger
|
|
1397
|
+
* than the whole budget goes as soon as it closes: the action is then
|
|
1398
|
+
* permanent, and {@link Scene.onPermanent} tells. A number, 0 or more;
|
|
1399
|
+
* at most 4 GiB, so `Infinity` means that. Change it later with
|
|
1400
|
+
* {@link Scene.setHistoryBudget}.
|
|
1401
|
+
*
|
|
1402
|
+
* @example
|
|
1403
|
+
* ```ts
|
|
1404
|
+
* // Removing a mesh of 10M triangles stays undoable.
|
|
1405
|
+
* const scene = new Scene({ historyBudget: 1024 ** 3 });
|
|
1406
|
+
* ```
|
|
1407
|
+
*/
|
|
1408
|
+
historyBudget?: number;
|
|
1409
|
+
}
|
|
1410
|
+
/** A ray hit from {@link Scene.raycast}, in world coordinates. */
|
|
1411
|
+
interface RayHit {
|
|
1412
|
+
mesh: MeshHandle;
|
|
1413
|
+
/** The triangle slot hit. */
|
|
1414
|
+
triangle: number;
|
|
1415
|
+
point: Vec3;
|
|
1416
|
+
/** The world distance from the ray origin. */
|
|
1417
|
+
distance: number;
|
|
1418
|
+
/** Barycentric coordinates of `point` in the triangle. */
|
|
1419
|
+
barycentric: Vec3;
|
|
1420
|
+
}
|
|
1421
|
+
/** Options of {@link Scene.raycast}, in world units. */
|
|
1422
|
+
interface RaycastOptions {
|
|
1423
|
+
/** Smallest distance that counts as a hit (inclusive). Defaults to 0. */
|
|
1424
|
+
minDistance?: number;
|
|
1425
|
+
/** Largest distance that counts as a hit (inclusive). Defaults to `Infinity`. */
|
|
1426
|
+
maxDistance?: number;
|
|
1427
|
+
/** Faces to ignore, by the triangle winding. Defaults to `"none"`. */
|
|
1428
|
+
cull?: "none" | "back" | "front";
|
|
1429
|
+
}
|
|
1430
|
+
/** The nearest surface point from {@link Scene.closestPoint}, in world coordinates. */
|
|
1431
|
+
interface ClosestHit {
|
|
1432
|
+
mesh: MeshHandle;
|
|
1433
|
+
/** The triangle slot the point lies on. */
|
|
1434
|
+
triangle: number;
|
|
1435
|
+
point: Vec3;
|
|
1436
|
+
distance: number;
|
|
1437
|
+
}
|
|
1438
|
+
/** Options of {@link Scene.closestPoint}, in world units. */
|
|
1439
|
+
interface ClosestPointOptions {
|
|
1440
|
+
/** Largest distance that counts as found (inclusive). Defaults to `Infinity`. */
|
|
1441
|
+
maxDistance?: number;
|
|
1442
|
+
/** Search this mesh only. Defaults to every mesh. */
|
|
1443
|
+
mesh?: MeshHandle;
|
|
1444
|
+
}
|
|
1445
|
+
/** The closest pair between two meshes from {@link Scene.meshDistance}, in world coordinates. */
|
|
1446
|
+
interface MeshDistance {
|
|
1447
|
+
/** 0 when the surfaces touch or intersect. */
|
|
1448
|
+
distance: number;
|
|
1449
|
+
/** The point on the first mesh. */
|
|
1450
|
+
a: Vec3;
|
|
1451
|
+
/** The point on the second mesh. */
|
|
1452
|
+
b: Vec3;
|
|
1453
|
+
/** The first mesh's triangle slot that `a` lies on. */
|
|
1454
|
+
triangleA: number;
|
|
1455
|
+
/** The second mesh's triangle slot that `b` lies on. */
|
|
1456
|
+
triangleB: number;
|
|
1457
|
+
}
|
|
1458
|
+
/** Two meshes within the margin of {@link Scene.findContacts}. */
|
|
1459
|
+
interface Contact {
|
|
1460
|
+
/** The mesh with the lower id. */
|
|
1461
|
+
a: MeshHandle;
|
|
1462
|
+
b: MeshHandle;
|
|
1463
|
+
/** Whether the meshes intersect or touch, decided exactly. */
|
|
1464
|
+
intersecting: boolean;
|
|
1465
|
+
/** The distance between the surfaces; 0 when `intersecting`. */
|
|
1466
|
+
distance: number;
|
|
1467
|
+
/** Triangle slots of `a` within the margin of `b`, ascending. */
|
|
1468
|
+
trianglesA: Uint32Array;
|
|
1469
|
+
/** Triangle slots of `b` within the margin of `a`, ascending. */
|
|
1470
|
+
trianglesB: Uint32Array;
|
|
1471
|
+
}
|
|
1472
|
+
/** Options of {@link Scene.findContacts}. */
|
|
1473
|
+
interface FindContactsOptions {
|
|
1474
|
+
/** Report pairs whose surfaces are at most this far apart (world units). Defaults to 0. */
|
|
1475
|
+
margin?: number;
|
|
1476
|
+
/** Only these pairs, either way round. Defaults to every pair of meshes. */
|
|
1477
|
+
pairs?: readonly (readonly [MeshHandle, MeshHandle])[];
|
|
1478
|
+
}
|
|
1479
|
+
/** How a distance field decides which side of the target surface is inside. */
|
|
1480
|
+
type SignMode = "auto" | "pseudonormal" | "winding";
|
|
1481
|
+
/** A signed distance field to add with {@link Scene.addDistanceField}. */
|
|
1482
|
+
interface DistanceFieldDesc {
|
|
1483
|
+
/** Unique among the fields on `on`. */
|
|
1484
|
+
name: string;
|
|
1485
|
+
/** The mesh whose vertices carry the values. */
|
|
1486
|
+
on: MeshHandle;
|
|
1487
|
+
/**
|
|
1488
|
+
* The mesh the distances are measured to, or several (at least one, all
|
|
1489
|
+
* different, not `on`): a vertex then holds the smallest signed distance
|
|
1490
|
+
* over them (the nearest surface, or the deepest penetration), and
|
|
1491
|
+
* {@link Scene.fieldNearest} tells which one it came from.
|
|
1492
|
+
*/
|
|
1493
|
+
to: MeshHandle | readonly MeshHandle[];
|
|
1494
|
+
/** Largest distance computed (inclusive); farther vertices hold `Infinity`. May be `Infinity`. */
|
|
1495
|
+
maxDistance: number;
|
|
1496
|
+
/** Defaults to `"auto"`. */
|
|
1497
|
+
sign?: SignMode;
|
|
1498
|
+
}
|
|
1499
|
+
/**
|
|
1500
|
+
* A per-vertex wall-thickness field to add with
|
|
1501
|
+
* {@link Scene.addThicknessField}: the distance to the opposite surface
|
|
1502
|
+
* along each vertex's smooth normal, in world units (the placement's scale
|
|
1503
|
+
* applied, so scaled meshes read scaled).
|
|
1504
|
+
*
|
|
1505
|
+
* Vertices whose rays escape in both directions (open sheets, the rims of
|
|
1506
|
+
* open meshes), dead slots and unused vertices hold NaN; hits beyond
|
|
1507
|
+
* `maxDistance` hold `Infinity`. Colour it like any field: NaN takes the
|
|
1508
|
+
* rule's `nan` colour, `Infinity` follows `above`.
|
|
1509
|
+
*/
|
|
1510
|
+
interface ThicknessFieldDesc {
|
|
1511
|
+
/** Unique among the fields on `on`. */
|
|
1512
|
+
name: string;
|
|
1513
|
+
/** The mesh whose vertices carry the values. */
|
|
1514
|
+
on: MeshHandle;
|
|
1515
|
+
/** Largest thickness kept (inclusive); thicker vertices hold `Infinity`. May be `Infinity`. */
|
|
1516
|
+
maxDistance: number;
|
|
1517
|
+
}
|
|
1518
|
+
/**
|
|
1519
|
+
* A per-vertex curvature field to add with
|
|
1520
|
+
* {@link Scene.addCurvatureField}: the signed mean curvature at each vertex,
|
|
1521
|
+
* in 1/world-units (positive on domes, about `1 / r` on a sphere of radius
|
|
1522
|
+
* `r` with outward normals; negative in bowls and dents; zero on flat
|
|
1523
|
+
* spots; a saddle takes the sign of its dominant bend).
|
|
1524
|
+
*
|
|
1525
|
+
* Dead slots and vertices no triangle uses hold NaN; colour it like any
|
|
1526
|
+
* field: NaN takes the rule's `nan` colour.
|
|
1527
|
+
*/
|
|
1528
|
+
interface CurvatureFieldDesc {
|
|
1529
|
+
/** Unique among the fields on `on`. */
|
|
1530
|
+
name: string;
|
|
1531
|
+
/** The mesh whose vertices carry the values. */
|
|
1532
|
+
on: MeshHandle;
|
|
1533
|
+
}
|
|
1534
|
+
/** The state of a field, from {@link Scene.fieldStatus}. */
|
|
1535
|
+
interface FieldStatus {
|
|
1536
|
+
/** True when the values match the meshes and placements as they are now. */
|
|
1537
|
+
current: boolean;
|
|
1538
|
+
/**
|
|
1539
|
+
* What the latest sign data builds found out about the target meshes,
|
|
1540
|
+
* together: `closed` and `consistentOrientation` when every target is, the
|
|
1541
|
+
* counts summed, and the first target's `mode`. See
|
|
1542
|
+
* {@link Scene.fieldTargetStatus} for each target.
|
|
1543
|
+
*/
|
|
1544
|
+
sign: {
|
|
1545
|
+
/** The mode in use (never `"auto"`). */
|
|
1546
|
+
mode: Exclude<SignMode, "auto">;
|
|
1547
|
+
/** No boundary or non-manifold edge. */
|
|
1548
|
+
closed: boolean;
|
|
1549
|
+
consistentOrientation: boolean;
|
|
1550
|
+
nonManifoldVertices: number;
|
|
1551
|
+
degenerateTriangles: number;
|
|
1552
|
+
};
|
|
1553
|
+
}
|
|
1554
|
+
/** An RGBA8 colour, each channel an integer in 0..255. */
|
|
1555
|
+
type Rgba = readonly [r: number, g: number, b: number, a: number];
|
|
1556
|
+
/**
|
|
1557
|
+
* A colormap: a built-in one, or colour stops `[t, rgba]` (at least two, `t`
|
|
1558
|
+
* in [0, 1] strictly increasing) interpolated linearly.
|
|
1559
|
+
*/
|
|
1560
|
+
type Colormap = "turbo" | "viridis" | "coolwarm" | "grayscale" | {
|
|
1561
|
+
stops: readonly (readonly [t: number, color: Rgba])[];
|
|
1562
|
+
};
|
|
1563
|
+
/** What to show for a value outside the colour range. */
|
|
1564
|
+
type OutOfRange = "clamp" | "base";
|
|
1565
|
+
/** How {@link Scene.setColoring} turns a field into vertex colours. */
|
|
1566
|
+
interface ColorRule {
|
|
1567
|
+
/** A field on the coloured mesh. */
|
|
1568
|
+
field: FieldHandle;
|
|
1569
|
+
map: Colormap;
|
|
1570
|
+
/** `[lo, hi]` mapped onto the colormap; finite, `lo < hi`. */
|
|
1571
|
+
range: readonly [lo: number, hi: number];
|
|
1572
|
+
/** Values below `lo`: the colormap's end colour or `base`. Defaults to `"clamp"`. */
|
|
1573
|
+
below?: OutOfRange;
|
|
1574
|
+
/** Values above `hi`, including far (`Infinity`): defaults to `"base"`. */
|
|
1575
|
+
above?: OutOfRange;
|
|
1576
|
+
/** A value within `range` pinned to the middle of the colormap. */
|
|
1577
|
+
center?: number;
|
|
1578
|
+
/** The `"base"` colour. Defaults to light grey `[200, 200, 200, 255]`. */
|
|
1579
|
+
base?: Rgba;
|
|
1580
|
+
/** The colour of NaN (dead or unused vertices). Defaults to `[128, 128, 128, 255]`. */
|
|
1581
|
+
nan?: Rgba;
|
|
1582
|
+
}
|
|
1583
|
+
/** A section plane in world coordinates. */
|
|
1584
|
+
interface SectionPlane {
|
|
1585
|
+
origin: Readonly<Vec3>;
|
|
1586
|
+
/** Points to the plane's `+` side; normalised. */
|
|
1587
|
+
normal: Readonly<Vec3>;
|
|
1588
|
+
}
|
|
1589
|
+
/** A plane section to add with {@link Scene.addSection}. */
|
|
1590
|
+
interface SectionDesc {
|
|
1591
|
+
plane: SectionPlane;
|
|
1592
|
+
/** The meshes cut, each once. */
|
|
1593
|
+
meshes: readonly MeshHandle[];
|
|
1594
|
+
/** Whether results carry the filled cross-section. Defaults to `false`. */
|
|
1595
|
+
fill?: boolean;
|
|
1596
|
+
}
|
|
1597
|
+
/** One chain of a section: a closed loop or an open polyline. */
|
|
1598
|
+
interface SectionContour {
|
|
1599
|
+
/**
|
|
1600
|
+
* World xyz, 3 floats per point. A copy. Where the plane passes exactly
|
|
1601
|
+
* through a vertex, the contour repeats that point (a zero-length segment).
|
|
1602
|
+
* Rounded to `f32`: far from the world origin that is by up to half of its
|
|
1603
|
+
* steps there (0.004 at 1e5). `points64` has them as precise as the mesh.
|
|
1604
|
+
*/
|
|
1605
|
+
points: Float32Array;
|
|
1606
|
+
/**
|
|
1607
|
+
* The same points in `f64`, as precise as the mesh's own positions however
|
|
1608
|
+
* far from the world origin it is. A copy. Always there on a result of this
|
|
1609
|
+
* library.
|
|
1610
|
+
*/
|
|
1611
|
+
points64?: Float64Array;
|
|
1612
|
+
closed: boolean;
|
|
1613
|
+
}
|
|
1614
|
+
/** A section's result for one mesh, from {@link Scene.section}. Copies, in world coordinates. */
|
|
1615
|
+
interface SectionResult {
|
|
1616
|
+
/** `"stale"` when not computed yet or something changed since: call {@link Scene.updateSections}. */
|
|
1617
|
+
status: "current" | "stale";
|
|
1618
|
+
contours: SectionContour[];
|
|
1619
|
+
/** Summed length of every contour. */
|
|
1620
|
+
length: number;
|
|
1621
|
+
/** Summed signed area of the closed, oriented contours (positive counter-clockwise about the normal). */
|
|
1622
|
+
area: number;
|
|
1623
|
+
/**
|
|
1624
|
+
* The filled cross-section, when the section has fill on and it was computed.
|
|
1625
|
+
* `positions64` are its `positions` before they are rounded to `f32`, as
|
|
1626
|
+
* `points64` are a contour's.
|
|
1627
|
+
*/
|
|
1628
|
+
fill?: {
|
|
1629
|
+
positions: Float32Array;
|
|
1630
|
+
positions64?: Float64Array;
|
|
1631
|
+
indices: Uint32Array;
|
|
1632
|
+
};
|
|
1633
|
+
}
|
|
1634
|
+
/** The closest pair between two meshes' contours, from {@link Scene.sectionGap}. */
|
|
1635
|
+
interface SectionGap {
|
|
1636
|
+
/** Measured in the plane; 0 when the contours cross or touch. */
|
|
1637
|
+
distance: number;
|
|
1638
|
+
/** World point on the first mesh's contours. */
|
|
1639
|
+
a: Vec3;
|
|
1640
|
+
/** World point on the second mesh's contours. */
|
|
1641
|
+
b: Vec3;
|
|
1642
|
+
}
|
|
1643
|
+
/**
|
|
1644
|
+
* An id produced by an earlier op of the same {@link Scene.edit} list: id `i`
|
|
1645
|
+
* of the result of op `opIndex` (a vertex of `addVertices`, a triangle of
|
|
1646
|
+
* `addTriangles`).
|
|
1647
|
+
*/
|
|
1648
|
+
interface EditRef {
|
|
1649
|
+
ref: readonly [opIndex: number, i: number];
|
|
1650
|
+
}
|
|
1651
|
+
/**
|
|
1652
|
+
* One op of {@link Scene.edit}. Positions are in world space (3 per vertex);
|
|
1653
|
+
* ids are vertex or triangle slots, or {@link EditRef}s to ids added earlier
|
|
1654
|
+
* in the same list.
|
|
1655
|
+
*/
|
|
1656
|
+
type EditOp = {
|
|
1657
|
+
op: "setPositions";
|
|
1658
|
+
vertices: Uint32Array | readonly number[];
|
|
1659
|
+
positions: Positions64;
|
|
1660
|
+
} | {
|
|
1661
|
+
op: "addVertices";
|
|
1662
|
+
positions: Positions64;
|
|
1663
|
+
} | {
|
|
1664
|
+
op: "addTriangles";
|
|
1665
|
+
triangles: readonly (number | EditRef)[] | Uint32Array;
|
|
1666
|
+
} | {
|
|
1667
|
+
op: "removeTriangles";
|
|
1668
|
+
triangles: Uint32Array | readonly number[];
|
|
1669
|
+
} | {
|
|
1670
|
+
op: "removeVertices";
|
|
1671
|
+
vertices: Uint32Array | readonly number[] | readonly EditRef[];
|
|
1672
|
+
} |
|
|
1673
|
+
/**
|
|
1674
|
+
* Sets the UVs of vertices (2 values each; undoable like the rest of the
|
|
1675
|
+
* edit), `addVertices` ones included. `addVertices` alone gives a mesh with
|
|
1676
|
+
* UVs the UV `(0, 0)`, and `setPositions` leaves them as they were.
|
|
1677
|
+
*
|
|
1678
|
+
* @throws `INVALID_ARGUMENT` on a mesh without UVs.
|
|
1679
|
+
*/
|
|
1680
|
+
{
|
|
1681
|
+
op: "setUvs";
|
|
1682
|
+
vertices: Uint32Array | readonly (number | EditRef)[];
|
|
1683
|
+
uvs: Float32Array | readonly number[];
|
|
1684
|
+
};
|
|
1685
|
+
/** What {@link Scene.edit} added. */
|
|
1686
|
+
interface EditResult {
|
|
1687
|
+
/** Per op, in order: the new vertex or triangle ids (empty for ops that add nothing). */
|
|
1688
|
+
added: Uint32Array[];
|
|
1689
|
+
}
|
|
1690
|
+
/**
|
|
1691
|
+
* A boundary loop's content fingerprint, valid while its vertex sequence is
|
|
1692
|
+
* unchanged: pass it back to `fillHoles` to pick that loop.
|
|
1693
|
+
*/
|
|
1694
|
+
interface LoopId {
|
|
1695
|
+
/** The smallest vertex id on the loop. */
|
|
1696
|
+
minVertex: number;
|
|
1697
|
+
/** The number of vertices on the loop. */
|
|
1698
|
+
len: number;
|
|
1699
|
+
/** FNV-1a 64 of the loop's vertex ids. */
|
|
1700
|
+
hash: bigint;
|
|
1701
|
+
}
|
|
1702
|
+
/** A chain of boundary edges, from {@link Scene.analyze}. */
|
|
1703
|
+
interface BoundaryLoop {
|
|
1704
|
+
id: LoopId;
|
|
1705
|
+
/** In loop order; a closed loop starts at `id.minVertex`. */
|
|
1706
|
+
vertices: Uint32Array;
|
|
1707
|
+
/** Length of the closed polygon. */
|
|
1708
|
+
perimeter: number;
|
|
1709
|
+
/** Vector area of the closed polygon. */
|
|
1710
|
+
area: number;
|
|
1711
|
+
/** `false` for an open chain (never filled). */
|
|
1712
|
+
closed: boolean;
|
|
1713
|
+
/** `false` when the loop touches a non-manifold edge, an unordered pinch or an orientation seam. */
|
|
1714
|
+
clean: boolean;
|
|
1715
|
+
}
|
|
1716
|
+
/** Triangles connected through shared edges, from {@link Scene.analyze}. */
|
|
1717
|
+
interface MeshComponent {
|
|
1718
|
+
/** Ascending. */
|
|
1719
|
+
triangles: Uint32Array;
|
|
1720
|
+
area: number;
|
|
1721
|
+
/** No boundary and no non-manifold edge. */
|
|
1722
|
+
closed: boolean;
|
|
1723
|
+
/** A void of a hollow solid: closed, wound inward, and inside the material of the components around it. */
|
|
1724
|
+
cavity: boolean;
|
|
1725
|
+
}
|
|
1726
|
+
/**
|
|
1727
|
+
* The defects of a mesh, from {@link Scene.analyze}. Lists with a count beside
|
|
1728
|
+
* them keep their first `maxListed` entries; counts are exact.
|
|
1729
|
+
*/
|
|
1730
|
+
interface Analysis {
|
|
1731
|
+
loops: BoundaryLoop[];
|
|
1732
|
+
/** Groups of two or more coincident vertices. */
|
|
1733
|
+
coincidentGroups: number;
|
|
1734
|
+
/** The groups, by smallest id, each ascending. */
|
|
1735
|
+
coincident: Uint32Array[];
|
|
1736
|
+
/** Degenerate triangles (repeated vertex or near-zero area). */
|
|
1737
|
+
degenerate: number;
|
|
1738
|
+
degenerateList: Uint32Array;
|
|
1739
|
+
/** Triangles repeating the vertex set of a triangle with a smaller id. */
|
|
1740
|
+
duplicate: number;
|
|
1741
|
+
duplicateList: Uint32Array;
|
|
1742
|
+
/** Edges with three or more triangles. */
|
|
1743
|
+
nonManifoldEdges: number;
|
|
1744
|
+
/** Those edges as `[min, max]`, ascending. */
|
|
1745
|
+
nonManifoldEdgeList: [number, number][];
|
|
1746
|
+
nonManifoldVertices: Uint32Array;
|
|
1747
|
+
/** Vertices whose triangle fan splits into several pieces. */
|
|
1748
|
+
pinchVertices: Uint32Array;
|
|
1749
|
+
components: MeshComponent[];
|
|
1750
|
+
/** Interior edges used in the same direction by both their triangles. */
|
|
1751
|
+
orientationConflicts: number;
|
|
1752
|
+
/** Whether two triangles sharing no vertex intersect; `null` when not checked. */
|
|
1753
|
+
selfIntersects: boolean | null;
|
|
1754
|
+
}
|
|
1755
|
+
/**
|
|
1756
|
+
* Scalar measurements of a mesh, from {@link Scene.measure}. The report is
|
|
1757
|
+
* in world coordinates (the placement applied), so scaled meshes measure
|
|
1758
|
+
* scaled. Thickness (#116) and curvature (#117) build on this.
|
|
1759
|
+
*/
|
|
1760
|
+
interface MeasureResult {
|
|
1761
|
+
/** The total triangle area; always defined. */
|
|
1762
|
+
area: number;
|
|
1763
|
+
/**
|
|
1764
|
+
* The enclosed volume, or `null` when the mesh is not watertight (open
|
|
1765
|
+
* or non-manifold), with `volumeReason` saying why. The volume is the
|
|
1766
|
+
* absolute signed sum, so inconsistent winding does not fail the call:
|
|
1767
|
+
* it only shows up in `orientationConflicts`, while partly cancelling
|
|
1768
|
+
* the number. Require `orientationConflicts === 0` for a strict reading.
|
|
1769
|
+
*/
|
|
1770
|
+
volume: number | null;
|
|
1771
|
+
/** No boundary loop or open chain and no non-manifold edge. */
|
|
1772
|
+
closed: boolean;
|
|
1773
|
+
/** Why `volume` is `null`; `null` exactly when `closed`. */
|
|
1774
|
+
volumeReason: "open" | "non-manifold" | null;
|
|
1775
|
+
/** The boundary loops and open chains, as `analyze` reports them. */
|
|
1776
|
+
boundaryLoops: number;
|
|
1777
|
+
/** How many edges have three or more triangles. */
|
|
1778
|
+
nonManifoldEdges: number;
|
|
1779
|
+
/** Interior edges used in the same direction by both their triangles. */
|
|
1780
|
+
orientationConflicts: number;
|
|
1781
|
+
}
|
|
1782
|
+
/**
|
|
1783
|
+
* Options of {@link Scene.analyze}. Distances are in mesh units; with a
|
|
1784
|
+
* rigid placement local and world distances agree, with a scaled one local
|
|
1785
|
+
* distances are in unscaled units.
|
|
1786
|
+
*/
|
|
1787
|
+
interface AnalyzeOptions {
|
|
1788
|
+
/**
|
|
1789
|
+
* Vertices at most this far apart count as coincident. Defaults to 0 (exact
|
|
1790
|
+
* duplicates). Converted to `f32`: a value below the `f32` range rounds to 0.
|
|
1791
|
+
*/
|
|
1792
|
+
weldTolerance?: number;
|
|
1793
|
+
/**
|
|
1794
|
+
* Check for self-intersection with the mesh's BVH. A stale `"manual"` mesh
|
|
1795
|
+
* throws `STALE_BVH`; others are brought up to date first. Defaults to `false`.
|
|
1796
|
+
*/
|
|
1797
|
+
selfIntersection?: boolean;
|
|
1798
|
+
/** The most entries kept in each counted list. Defaults to 1000. */
|
|
1799
|
+
maxListed?: number;
|
|
1800
|
+
}
|
|
1801
|
+
/** Which normal direction `inflate` pushes vertices along. */
|
|
1802
|
+
type InflateMethod = "vertexNormal" | "averageNormal" | "strokeNormal";
|
|
1803
|
+
/** Surface relaxation kernel for `smooth`. */
|
|
1804
|
+
type SmoothMethod = "taubin" | "laplacian" | "hcLaplacian" | "cotangent";
|
|
1805
|
+
/** Spatial or elastic kernel for `grab`. */
|
|
1806
|
+
type GrabMethod = "sphere" | "geodesic" | "kelvinlet";
|
|
1807
|
+
/** Which side(s) of the brush plane `flatten` projects toward the plane. */
|
|
1808
|
+
type FlattenMode = "both" | "peaks" | "valleys";
|
|
1809
|
+
/** Footprint profile for `clay`. */
|
|
1810
|
+
type ClayProfile = "round" | "strips";
|
|
1811
|
+
/** Rotational kernel for `twist`. */
|
|
1812
|
+
type TwistMethod = "vortex" | "kelvinlet";
|
|
1813
|
+
/** Surface offsetting / reconstruction algorithm for `repair(mesh, { op: "offset", ... })`. */
|
|
1814
|
+
type OffsetAlgorithm = "normal" | "fhEdt" | "bvhSdf";
|
|
1815
|
+
/**
|
|
1816
|
+
* Composable per-vertex surface feature mask multiplied into a brush's
|
|
1817
|
+
* spatial falloff.
|
|
1818
|
+
*/
|
|
1819
|
+
type SurfaceFilter = {
|
|
1820
|
+
kind: "none";
|
|
1821
|
+
} | {
|
|
1822
|
+
kind: "peaksOnly";
|
|
1823
|
+
threshold?: number;
|
|
1824
|
+
contrast?: number;
|
|
1825
|
+
} | {
|
|
1826
|
+
kind: "valleysOnly";
|
|
1827
|
+
threshold?: number;
|
|
1828
|
+
contrast?: number;
|
|
1829
|
+
} | {
|
|
1830
|
+
kind: "normalAngle";
|
|
1831
|
+
normal?: Readonly<Vec3>;
|
|
1832
|
+
maxAngleDeg?: number;
|
|
1833
|
+
};
|
|
1834
|
+
/** Mirror symmetry axes across local coordinate planes `x = 0`, `y = 0`, `z = 0`. */
|
|
1835
|
+
interface Symmetry {
|
|
1836
|
+
x?: boolean;
|
|
1837
|
+
y?: boolean;
|
|
1838
|
+
z?: boolean;
|
|
1839
|
+
}
|
|
1840
|
+
/**
|
|
1841
|
+
* One sculpt brush, stroke capture, or dynamic-topology operation for
|
|
1842
|
+
* {@link Scene.sculpt} (and accepted identically by {@link Scene.repair}).
|
|
1843
|
+
* Distances are in local mesh units.
|
|
1844
|
+
*/
|
|
1845
|
+
type SculptOp = {
|
|
1846
|
+
op: "inflate";
|
|
1847
|
+
/** Brush center in local mesh coordinates, as in `views(mesh).positions()`. */
|
|
1848
|
+
center: Readonly<Vec3>;
|
|
1849
|
+
radius: number;
|
|
1850
|
+
falloff: "linear" | "smooth";
|
|
1851
|
+
/** Displacement scale; negative pulls instead of pushing. */
|
|
1852
|
+
strength: number;
|
|
1853
|
+
/** Normal evaluation mode; unset means `"vertexNormal"`. */
|
|
1854
|
+
method?: InflateMethod;
|
|
1855
|
+
/** Optional per-vertex surface feature mask. */
|
|
1856
|
+
filter?: SurfaceFilter;
|
|
1857
|
+
/** Optional mirror symmetry across local coordinate planes. */
|
|
1858
|
+
symmetry?: Symmetry;
|
|
1859
|
+
/** Vertices this op must hold in place, or move less. */
|
|
1860
|
+
protect?: VertexProtection;
|
|
1861
|
+
} | {
|
|
1862
|
+
op: "smooth";
|
|
1863
|
+
/** Brush center in local mesh coordinates, as in `views(mesh).positions()`. */
|
|
1864
|
+
center: Readonly<Vec3>;
|
|
1865
|
+
radius: number;
|
|
1866
|
+
falloff: "linear" | "smooth";
|
|
1867
|
+
/** Displacement scale; the per-vertex weight is `strength * falloff`. */
|
|
1868
|
+
strength: number;
|
|
1869
|
+
/** How many relaxation cycles to run; 0 moves nothing. */
|
|
1870
|
+
cycles: number;
|
|
1871
|
+
/** Relaxation kernel; unset means `"taubin"`. */
|
|
1872
|
+
method?: SmoothMethod;
|
|
1873
|
+
/** Optional per-vertex surface feature mask. */
|
|
1874
|
+
filter?: SurfaceFilter;
|
|
1875
|
+
/** Optional mirror symmetry across local coordinate planes. */
|
|
1876
|
+
symmetry?: Symmetry;
|
|
1877
|
+
/** Vertices this op must hold in place, or move less. */
|
|
1878
|
+
protect?: VertexProtection;
|
|
1879
|
+
} | {
|
|
1880
|
+
op: "relax";
|
|
1881
|
+
/** Brush center in local mesh coordinates, as in `views(mesh).positions()`. */
|
|
1882
|
+
center: Readonly<Vec3>;
|
|
1883
|
+
radius: number;
|
|
1884
|
+
falloff: "linear" | "smooth";
|
|
1885
|
+
/** Displacement scale; the per-vertex weight is `strength * falloff`. */
|
|
1886
|
+
strength: number;
|
|
1887
|
+
/** How many plain Laplacian passes to run; 0 moves nothing. */
|
|
1888
|
+
cycles: number;
|
|
1889
|
+
/** Optional per-vertex surface feature mask. */
|
|
1890
|
+
filter?: SurfaceFilter;
|
|
1891
|
+
/** Optional mirror symmetry across local coordinate planes. */
|
|
1892
|
+
symmetry?: Symmetry;
|
|
1893
|
+
/** Vertices this op must hold in place, or move less. */
|
|
1894
|
+
protect?: VertexProtection;
|
|
1895
|
+
} | {
|
|
1896
|
+
op: "grab";
|
|
1897
|
+
/** Brush center in local mesh coordinates, as in `views(mesh).positions()`. */
|
|
1898
|
+
center: Readonly<Vec3>;
|
|
1899
|
+
radius: number;
|
|
1900
|
+
falloff: "linear" | "smooth";
|
|
1901
|
+
/** Displacement scale; the per-vertex offset is `strength * falloff * direction`. */
|
|
1902
|
+
strength: number;
|
|
1903
|
+
/** The drag vector in local coordinates; zero moves nothing. */
|
|
1904
|
+
direction: Readonly<Vec3>;
|
|
1905
|
+
/** Spatial or elastic kernel; unset means `"sphere"`. */
|
|
1906
|
+
method?: GrabMethod;
|
|
1907
|
+
/** Elastic Poisson ratio in `[0, 0.5]` for `"kelvinlet"`; unset means `0.4`. */
|
|
1908
|
+
poisson?: number;
|
|
1909
|
+
/** Evaluate offsets from stroke-start rest positions (`captureStrokeState`). */
|
|
1910
|
+
fromStroke?: boolean;
|
|
1911
|
+
/** Automatically widen brush reach on tangential surface drags to prevent fold-over. */
|
|
1912
|
+
adaptiveReach?: boolean;
|
|
1913
|
+
/** Optional per-vertex surface feature mask. */
|
|
1914
|
+
filter?: SurfaceFilter;
|
|
1915
|
+
/** Optional mirror symmetry across local coordinate planes. */
|
|
1916
|
+
symmetry?: Symmetry;
|
|
1917
|
+
/** Vertices this op must hold in place, or move less. */
|
|
1918
|
+
protect?: VertexProtection;
|
|
1919
|
+
} | {
|
|
1920
|
+
op: "flatten";
|
|
1921
|
+
/** Brush center in local mesh coordinates, as in `views(mesh).positions()`. */
|
|
1922
|
+
center: Readonly<Vec3>;
|
|
1923
|
+
radius: number;
|
|
1924
|
+
falloff: "linear" | "smooth";
|
|
1925
|
+
/** Projection blend scale toward the brush plane. */
|
|
1926
|
+
strength: number;
|
|
1927
|
+
/** Which side(s) of the plane to project; unset means `"both"`. */
|
|
1928
|
+
mode?: FlattenMode;
|
|
1929
|
+
/** Explicit plane origin in local coordinates; unset fits the falloff-weighted centroid. */
|
|
1930
|
+
planeOrigin?: Readonly<Vec3>;
|
|
1931
|
+
/** Explicit non-zero plane normal in local coordinates; unset fits the falloff-weighted average normal. */
|
|
1932
|
+
planeNormal?: Readonly<Vec3>;
|
|
1933
|
+
/** Optional per-vertex surface feature mask. */
|
|
1934
|
+
filter?: SurfaceFilter;
|
|
1935
|
+
/** Optional mirror symmetry across local coordinate planes. */
|
|
1936
|
+
symmetry?: Symmetry;
|
|
1937
|
+
/** Vertices this op must hold in place, or move less. */
|
|
1938
|
+
protect?: VertexProtection;
|
|
1939
|
+
} | {
|
|
1940
|
+
op: "crease";
|
|
1941
|
+
/** Brush center in local mesh coordinates, as in `views(mesh).positions()`. */
|
|
1942
|
+
center: Readonly<Vec3>;
|
|
1943
|
+
radius: number;
|
|
1944
|
+
falloff: "linear" | "smooth";
|
|
1945
|
+
/** Normal groove/ridge scale (`< 0` carves a crease, `> 0` raises a ridge, `0` pinches only). */
|
|
1946
|
+
strength: number;
|
|
1947
|
+
/** Tangent-plane radial pinch factor in `[0, 1]`; unset means `0.5`. */
|
|
1948
|
+
pinch?: number;
|
|
1949
|
+
/** Optional per-vertex surface feature mask. */
|
|
1950
|
+
filter?: SurfaceFilter;
|
|
1951
|
+
/** Optional mirror symmetry across local coordinate planes. */
|
|
1952
|
+
symmetry?: Symmetry;
|
|
1953
|
+
/** Vertices this op must hold in place, or move less. */
|
|
1954
|
+
protect?: VertexProtection;
|
|
1955
|
+
} | {
|
|
1956
|
+
op: "clay";
|
|
1957
|
+
/** Brush center in local mesh coordinates, as in `views(mesh).positions()`. */
|
|
1958
|
+
center: Readonly<Vec3>;
|
|
1959
|
+
radius: number;
|
|
1960
|
+
falloff: "linear" | "smooth";
|
|
1961
|
+
/** Buildup/carve scale (`> 0` builds up, `< 0` carves down). */
|
|
1962
|
+
strength: number;
|
|
1963
|
+
/** Footprint profile (`"round"` or `"strips"`); unset means `"round"`. */
|
|
1964
|
+
profile?: ClayProfile;
|
|
1965
|
+
/** Optional stroke tangent direction in local coordinates for `"strips"`. */
|
|
1966
|
+
tangent?: Readonly<Vec3>;
|
|
1967
|
+
/** Optional per-vertex surface feature mask. */
|
|
1968
|
+
filter?: SurfaceFilter;
|
|
1969
|
+
/** Optional mirror symmetry across local coordinate planes. */
|
|
1970
|
+
symmetry?: Symmetry;
|
|
1971
|
+
/** Vertices this op must hold in place, or move less. */
|
|
1972
|
+
protect?: VertexProtection;
|
|
1973
|
+
} | {
|
|
1974
|
+
op: "twist";
|
|
1975
|
+
/** Brush center in local mesh coordinates, as in `views(mesh).positions()`. */
|
|
1976
|
+
center: Readonly<Vec3>;
|
|
1977
|
+
radius: number;
|
|
1978
|
+
falloff: "linear" | "smooth";
|
|
1979
|
+
/** Twist angle scale in radians. */
|
|
1980
|
+
strength: number;
|
|
1981
|
+
/** Rotational kernel; unset means `"vortex"`. */
|
|
1982
|
+
method?: TwistMethod;
|
|
1983
|
+
/** Explicit non-zero twist axis in local coordinates; unset uses the average brush normal. */
|
|
1984
|
+
axis?: Readonly<Vec3>;
|
|
1985
|
+
/** Optional per-vertex surface feature mask. */
|
|
1986
|
+
filter?: SurfaceFilter;
|
|
1987
|
+
/** Optional mirror symmetry across local coordinate planes. */
|
|
1988
|
+
symmetry?: Symmetry;
|
|
1989
|
+
/** Vertices this op must hold in place, or move less. */
|
|
1990
|
+
protect?: VertexProtection;
|
|
1991
|
+
} | {
|
|
1992
|
+
/**
|
|
1993
|
+
* Snapshots lazy stroke-start rest positions and smooth normals for
|
|
1994
|
+
* `inflate` (`method: "strokeNormal"`) and `grab` (`fromStroke: true`).
|
|
1995
|
+
* Not an edit: no undo step, and it must be the only op of its list.
|
|
1996
|
+
*/
|
|
1997
|
+
op: "captureStrokeState";
|
|
1998
|
+
/** Keep an already active stroke snapshot on this mesh. Unset means `false`. */
|
|
1999
|
+
onlyIfMissing?: boolean;
|
|
2000
|
+
} | {
|
|
2001
|
+
op: "remesh";
|
|
2002
|
+
/** Region center in local mesh coordinates, as in `views(mesh).positions()`. */
|
|
2003
|
+
center: Readonly<Vec3>;
|
|
2004
|
+
radius: number;
|
|
2005
|
+
/** Target edge length; unset means the mesh-wide mean edge length. */
|
|
2006
|
+
targetLength?: number;
|
|
2007
|
+
/** Maximum split/collapse/flip rounds; unset means the default (10). */
|
|
2008
|
+
maxRounds?: number;
|
|
2009
|
+
/** Split long edges only (no collapses, no flips); unset means a full pass. */
|
|
2010
|
+
splitOnly?: boolean;
|
|
2011
|
+
} | {
|
|
2012
|
+
/**
|
|
2013
|
+
* Records each vertex's longest edge as its rest size, for
|
|
2014
|
+
* `splitStretched`. Run it before the deformation starts. Not an edit:
|
|
2015
|
+
* no undo step, and it must be the only op of its list. Running it again
|
|
2016
|
+
* accepts the mesh as it is then as the new rest shape; `onlyIfMissing`
|
|
2017
|
+
* avoids that. The sizes last until a topology edit other than
|
|
2018
|
+
* `splitStretched`, or an undo or redo of an edit from before the capture;
|
|
2019
|
+
* undoing a topology edit from after it brings them back.
|
|
2020
|
+
*/
|
|
2021
|
+
op: "captureRestSizes";
|
|
2022
|
+
/** Keep rest sizes the mesh still holds. Unset means `false`. */
|
|
2023
|
+
onlyIfMissing?: boolean;
|
|
2024
|
+
} | {
|
|
2025
|
+
/**
|
|
2026
|
+
* Splits the edges a deformation stretched, and nothing else: an edge
|
|
2027
|
+
* splits once it is past `limit` times the smaller rest size of its
|
|
2028
|
+
* endpoints, measured by `captureRestSizes`. Existing vertices keep their
|
|
2029
|
+
* ids and positions, nothing collapses or flips, and a triangle with no
|
|
2030
|
+
* split edge keeps its slot. Fails while the mesh holds no valid rest
|
|
2031
|
+
* sizes: see `captureRestSizes`.
|
|
2032
|
+
*/
|
|
2033
|
+
op: "splitStretched";
|
|
2034
|
+
/** Region center in local mesh coordinates; edges with an endpoint in the region are checked. */
|
|
2035
|
+
center: Readonly<Vec3>;
|
|
2036
|
+
radius: number;
|
|
2037
|
+
/** Multiple of the rest size an edge may reach, above 1; unset means 4/3. */
|
|
2038
|
+
limit?: number;
|
|
2039
|
+
/** Most interior splits per call, the longest first; boundary edges do not count. Unset means 2^20. */
|
|
2040
|
+
maxSplits?: number;
|
|
2041
|
+
/** New interior vertices follow the surface's curvature; `false` uses midpoints. Unset means `true`. */
|
|
2042
|
+
smooth?: boolean;
|
|
2043
|
+
/**
|
|
2044
|
+
* With `smooth`, the angle in degrees past which two faces count as
|
|
2045
|
+
* separated by a crease, in `(0, 180]`; unset means 45. A new vertex on
|
|
2046
|
+
* such an edge sits at its midpoint, and faces beyond it do not tilt a
|
|
2047
|
+
* curved point. A gentler crease rounds off, and a flat face beside it
|
|
2048
|
+
* bulges: at 45, 0.20 beside a 30 degree crease on a 6.0 edge. Set it below
|
|
2049
|
+
* a model's gentlest crease to keep that crease's flat faces flat; a coarse
|
|
2050
|
+
* curved surface then rounds less.
|
|
2051
|
+
*/
|
|
2052
|
+
sharpAngle?: number;
|
|
2053
|
+
};
|
|
2054
|
+
/** Domain preset for {@link AutoRepairRequest}. */
|
|
2055
|
+
type AutoRepairPreset = "general" | "scan3d" | "print3d" | "cadImport";
|
|
2056
|
+
/** Strategy for {@link resolveSelfIntersections} and {@link AutoRepairRequest}. */
|
|
2057
|
+
type SelfIntersectionMode = "none" | "deleteAndFill" | "cutAndStitch" | "voxelHeal";
|
|
2058
|
+
/** Options for the `"makeManifold"` repair op. */
|
|
2059
|
+
interface ManifoldOptions {
|
|
2060
|
+
/** Remove exact duplicate triangles sharing the same unordered vertex triple. Defaults to `true`. */
|
|
2061
|
+
removeDuplicates?: boolean;
|
|
2062
|
+
/** Prune small dangling boundary fins attached to non-manifold edges. Defaults to `true`. */
|
|
2063
|
+
pruneFins?: boolean;
|
|
2064
|
+
/** Separate non-manifold edges (`> 2` incident faces) across sheets. Defaults to `true`. */
|
|
2065
|
+
splitNonManifoldEdges?: boolean;
|
|
2066
|
+
/** Separate pinch (bow-tie) vertices into distinct fan components. Defaults to `true`. */
|
|
2067
|
+
splitPinchVertices?: boolean;
|
|
2068
|
+
}
|
|
2069
|
+
/** Options for the `"resolveSelfIntersections"` repair op. */
|
|
2070
|
+
interface SelfIntersectOptions {
|
|
2071
|
+
/** Resolution mode. Defaults to `"deleteAndFill"`. */
|
|
2072
|
+
mode?: SelfIntersectionMode;
|
|
2073
|
+
/** Number of 1-ring neighbor layers deleted around colliding faces (`"deleteAndFill"` and local fallback). Defaults to `1`. */
|
|
2074
|
+
ringExpansion?: number;
|
|
2075
|
+
/** Explicit voxel pitch in mesh units for `"voxelHeal"`. Omit for automatic sizing. */
|
|
2076
|
+
voxelSize?: number;
|
|
2077
|
+
/** Maximum voxel count for `"voxelHeal"` (`>= 64`). Defaults to `16_777_216` (`256^3`). */
|
|
2078
|
+
maxVoxels?: number;
|
|
2079
|
+
/** Optional hole boundary edge cap passed to `fillHoles`. Defaults to unbounded. */
|
|
2080
|
+
maxHoleEdges?: number;
|
|
2081
|
+
/** Whether hole patches in `"deleteAndFill"` are faired. Defaults to `true`. */
|
|
2082
|
+
fair?: boolean;
|
|
2083
|
+
/** Spatial weld tolerance for shared cut seam vertices in `"cutAndStitch"`. Defaults to `1e-5`. */
|
|
2084
|
+
stitchTolerance?: number;
|
|
2085
|
+
}
|
|
2086
|
+
/** Options for the `"cleanupSlivers"` repair op. */
|
|
2087
|
+
interface SliverOptions {
|
|
2088
|
+
/** Maximum allowed circumradius-to-2-inradius aspect ratio (`>= 1`). Defaults to `20`. */
|
|
2089
|
+
maxAspectRatio?: number;
|
|
2090
|
+
/** Minimum interior angle threshold in degrees (`[0, 60]`). Defaults to `2`. */
|
|
2091
|
+
minAngleDeg?: number;
|
|
2092
|
+
/** Maximum interior angle threshold in degrees (`[60, 180]`). Defaults to `176`. */
|
|
2093
|
+
maxAngleDeg?: number;
|
|
2094
|
+
/** Maximum cleanup passes over the mesh. Defaults to `3`. */
|
|
2095
|
+
maxIterations?: number;
|
|
2096
|
+
}
|
|
2097
|
+
/**
|
|
2098
|
+
* One repair operation for {@link Scene.repair}. Distances and areas are in
|
|
2099
|
+
* the mesh's own units: before its placement's scale, so equal to world units
|
|
2100
|
+
* unless it has one. They are converted to `f32`, so a tolerance or area below
|
|
2101
|
+
* the `f32` range rounds to 0.
|
|
2102
|
+
*/
|
|
2103
|
+
type RepairOp = SculptOp | {
|
|
2104
|
+
op: "weld";
|
|
2105
|
+
tolerance: number;
|
|
2106
|
+
} | {
|
|
2107
|
+
op: "removeDegenerate";
|
|
2108
|
+
areaEpsilon?: number;
|
|
2109
|
+
removeUnusedVertices?: boolean;
|
|
2110
|
+
} | {
|
|
2111
|
+
op: "removeSmallComponents";
|
|
2112
|
+
minTriangles?: number;
|
|
2113
|
+
minArea?: number;
|
|
2114
|
+
/** Keep the largest component even when it is below a bound. Default `true`. */
|
|
2115
|
+
keepLargest?: boolean;
|
|
2116
|
+
/**
|
|
2117
|
+
* Keep the cavities (see {@link MeshComponent.cavity}) of the components
|
|
2118
|
+
* that stay, however small they are: removing one fills a void of a
|
|
2119
|
+
* hollow solid. Default `true`. A cavity of a removed component goes
|
|
2120
|
+
* with it.
|
|
2121
|
+
*/
|
|
2122
|
+
keepCavities?: boolean;
|
|
2123
|
+
} | {
|
|
2124
|
+
op: "orient";
|
|
2125
|
+
} | ({
|
|
2126
|
+
op: "makeManifold";
|
|
2127
|
+
} & ManifoldOptions) | ({
|
|
2128
|
+
op: "resolveSelfIntersections";
|
|
2129
|
+
} & SelfIntersectOptions) | ({
|
|
2130
|
+
op: "cleanupSlivers";
|
|
2131
|
+
} & SliverOptions) | {
|
|
2132
|
+
op: "fillHoles";
|
|
2133
|
+
maxEdges?: number;
|
|
2134
|
+
maxPerimeter?: number;
|
|
2135
|
+
maxArea?: number;
|
|
2136
|
+
loops?: readonly LoopId[];
|
|
2137
|
+
allowUnclean?: boolean;
|
|
2138
|
+
fair?: boolean;
|
|
2139
|
+
dpLimit?: number;
|
|
2140
|
+
/** Reject a minimum-weight triangulation past this dihedral, in radians. */
|
|
2141
|
+
maxDihedral?: number;
|
|
2142
|
+
/** Stop refining a patch once it has this many new vertices. */
|
|
2143
|
+
maxRefineVertices?: number;
|
|
2144
|
+
} | {
|
|
2145
|
+
op: "bridgeLoops";
|
|
2146
|
+
/** The two loops to connect, from `analyze(mesh).loops`. Order is insignificant. */
|
|
2147
|
+
loops: readonly [LoopId, LoopId];
|
|
2148
|
+
/** Maximum vertices per loop; unset means the default (128). */
|
|
2149
|
+
maxEdges?: number;
|
|
2150
|
+
} | {
|
|
2151
|
+
op: "offset";
|
|
2152
|
+
/**
|
|
2153
|
+
* Offset distance in local mesh units.
|
|
2154
|
+
* - `"normal"` (default): moves vertices along smooth normals (`0` moves nothing).
|
|
2155
|
+
* - `"fhEdt"` / `"bvhSdf"`: on closed outward-wound solids, positive expands,
|
|
2156
|
+
* negative shrinks, and `0` voxel-remeshes at the current surface; on open
|
|
2157
|
+
* sheets, `distance > 0` builds a closed thickened shell and `distance <= 0`
|
|
2158
|
+
* throws `INVALID_ARGUMENT`. Drops UVs (`uvsDropped: true`, undoable).
|
|
2159
|
+
*/
|
|
2160
|
+
distance: number;
|
|
2161
|
+
/** Offsetting algorithm; defaults to `"normal"`. */
|
|
2162
|
+
algorithm?: OffsetAlgorithm;
|
|
2163
|
+
/**
|
|
2164
|
+
* Grid spacing in local mesh units for `"fhEdt"` and `"bvhSdf"`; must be
|
|
2165
|
+
* positive and finite when provided. Omit for automatic (`bbox_diag / 64`,
|
|
2166
|
+
* clamped to `maxVoxels`). Ignored when `algorithm` is `"normal"`.
|
|
2167
|
+
*/
|
|
2168
|
+
voxelSize?: number;
|
|
2169
|
+
/**
|
|
2170
|
+
* Maximum 3D grid voxel count (`nx * ny * nz`) for `"fhEdt"` and `"bvhSdf"`;
|
|
2171
|
+
* must be an integer `>= 64`. Defaults to `16_777_216` (`256^3`).
|
|
2172
|
+
*/
|
|
2173
|
+
maxVoxels?: number;
|
|
2174
|
+
} | {
|
|
2175
|
+
op: "shell";
|
|
2176
|
+
/**
|
|
2177
|
+
* Wall thickness in the mesh's own units (before its placement's
|
|
2178
|
+
* scale): the input surface stays and gains a reversed copy one thickness against its
|
|
2179
|
+
* smooth normals, with every boundary rim stitched shut. Must be
|
|
2180
|
+
* positive and finite.
|
|
2181
|
+
*/
|
|
2182
|
+
thickness: number;
|
|
2183
|
+
} | {
|
|
2184
|
+
op: "simplify";
|
|
2185
|
+
/**
|
|
2186
|
+
* Stop once this many triangles are alive; must be at least 1 when set.
|
|
2187
|
+
* Optional when `targetRatio` or `maxDeviation` is provided; a target
|
|
2188
|
+
* at or above the live count leaves the mesh alone.
|
|
2189
|
+
*/
|
|
2190
|
+
targetTriangles?: number;
|
|
2191
|
+
/**
|
|
2192
|
+
* Target fraction of live input triangles in `(0, 1]`. When provided,
|
|
2193
|
+
* resolves the triangle budget to `(live * targetRatio).round().max(1)`.
|
|
2194
|
+
*/
|
|
2195
|
+
targetRatio?: number;
|
|
2196
|
+
/**
|
|
2197
|
+
* Maximum allowed root-quadric geometric deviation; collapses exceeding
|
|
2198
|
+
* `maxDeviation^2` stop or skip cleanly.
|
|
2199
|
+
*/
|
|
2200
|
+
maxDeviation?: number;
|
|
2201
|
+
/** Keep boundary vertices in place; defaults to `true`. */
|
|
2202
|
+
preserveBoundary?: boolean;
|
|
2203
|
+
/**
|
|
2204
|
+
* Use Hoppe appearance-aware UV quadrics, protect UV chart borders, and
|
|
2205
|
+
* block collapses that fold 2D UV triangles; defaults to `false`.
|
|
2206
|
+
*/
|
|
2207
|
+
preserveUvs?: boolean;
|
|
2208
|
+
/**
|
|
2209
|
+
* Penalize perpendicular displacement off sharp dihedral creases above
|
|
2210
|
+
* `creaseAngleDeg` and lock crease corners; defaults to `false`.
|
|
2211
|
+
*/
|
|
2212
|
+
lockCreases?: boolean;
|
|
2213
|
+
/**
|
|
2214
|
+
* Dihedral angle threshold in degrees (`[0, 180]`) for feature creases
|
|
2215
|
+
* when `lockCreases` is enabled; defaults to `30`.
|
|
2216
|
+
*/
|
|
2217
|
+
creaseAngleDeg?: number;
|
|
2218
|
+
/**
|
|
2219
|
+
* Reject collapses that invert any 1-ring incident triangle normal by
|
|
2220
|
+
* `90` degrees or more; defaults to `true`.
|
|
2221
|
+
*/
|
|
2222
|
+
preventNormalInversion?: boolean;
|
|
2223
|
+
} | {
|
|
2224
|
+
op: "remeshSurface";
|
|
2225
|
+
/** Uniform `"isotropic"` (default) or curvature-`"adaptive"` edge sizing. */
|
|
2226
|
+
mode?: SurfaceRemeshMode;
|
|
2227
|
+
/** Nominal target edge length in local mesh units (positive finite). */
|
|
2228
|
+
targetEdgeLength: number;
|
|
2229
|
+
/**
|
|
2230
|
+
* Lower edge-length bound in `"adaptive"` mode; defaults to
|
|
2231
|
+
* `0.35 * targetEdgeLength`.
|
|
2232
|
+
*/
|
|
2233
|
+
minEdgeLength?: number;
|
|
2234
|
+
/**
|
|
2235
|
+
* Upper edge-length bound in `"adaptive"` mode; defaults to
|
|
2236
|
+
* `2 * targetEdgeLength`.
|
|
2237
|
+
*/
|
|
2238
|
+
maxEdgeLength?: number;
|
|
2239
|
+
/**
|
|
2240
|
+
* Number of split/collapse/flip/relax/reproject passes (capped at `64`);
|
|
2241
|
+
* defaults to `5`.
|
|
2242
|
+
*/
|
|
2243
|
+
iterations?: number;
|
|
2244
|
+
/** Tangential relaxation strength in `[0, 1]`; defaults to `0.5`. */
|
|
2245
|
+
smoothStrength?: number;
|
|
2246
|
+
/**
|
|
2247
|
+
* Reproject moved interior vertices onto the input reference surface via
|
|
2248
|
+
* BVH; defaults to `true`.
|
|
2249
|
+
*/
|
|
2250
|
+
projectToSurface?: boolean;
|
|
2251
|
+
/** Keep open boundary vertices fixed; defaults to `true`. */
|
|
2252
|
+
lockBoundaries?: boolean;
|
|
2253
|
+
/**
|
|
2254
|
+
* Detect sharp dihedral edges above `creaseAngleDeg` and preserve sharp
|
|
2255
|
+
* creases and corners; defaults to `true`.
|
|
2256
|
+
*/
|
|
2257
|
+
lockCreases?: boolean;
|
|
2258
|
+
/**
|
|
2259
|
+
* Dihedral angle threshold in degrees (`[0, 180]`) for feature creases;
|
|
2260
|
+
* defaults to `30`.
|
|
2261
|
+
*/
|
|
2262
|
+
creaseAngleDeg?: number;
|
|
2263
|
+
} | {
|
|
2264
|
+
op: "subdivide";
|
|
2265
|
+
/**
|
|
2266
|
+
* Subdivision scheme; only `"loop"` exists. Defaults to `"loop"`.
|
|
2267
|
+
*/
|
|
2268
|
+
method?: "loop";
|
|
2269
|
+
/**
|
|
2270
|
+
* How many times to split every triangle; must be an integer of at
|
|
2271
|
+
* least 1. Each level quadruples the triangle count. Defaults to `1`.
|
|
2272
|
+
*/
|
|
2273
|
+
levels?: number;
|
|
2274
|
+
};
|
|
2275
|
+
/** What `weld` did. */
|
|
2276
|
+
interface WeldReport {
|
|
2277
|
+
mergedVertices: number;
|
|
2278
|
+
removedTriangles: number;
|
|
2279
|
+
}
|
|
2280
|
+
/** What `removeDegenerate` did. */
|
|
2281
|
+
interface DegenerateReport {
|
|
2282
|
+
removedTriangles: number;
|
|
2283
|
+
removedVertices: number;
|
|
2284
|
+
}
|
|
2285
|
+
/** What `removeSmallComponents` did. */
|
|
2286
|
+
interface RemoveReport {
|
|
2287
|
+
removedComponents: number;
|
|
2288
|
+
removedTriangles: number;
|
|
2289
|
+
removedVertices: number;
|
|
2290
|
+
}
|
|
2291
|
+
/** What `orient` did. */
|
|
2292
|
+
interface OrientReport {
|
|
2293
|
+
flippedTriangles: number;
|
|
2294
|
+
patches: number;
|
|
2295
|
+
nonOrientablePatches: number;
|
|
2296
|
+
flippedOutwardComponents: number;
|
|
2297
|
+
}
|
|
2298
|
+
/** A loop `fillHoles` filled. */
|
|
2299
|
+
interface FilledLoop {
|
|
2300
|
+
/** The loop as it was before the fill. */
|
|
2301
|
+
id: LoopId;
|
|
2302
|
+
trianglesAdded: number;
|
|
2303
|
+
/** Vertices added by refinement. */
|
|
2304
|
+
verticesAdded: number;
|
|
2305
|
+
/** Whether fairing converged; `true` when it did not run. */
|
|
2306
|
+
converged: boolean;
|
|
2307
|
+
/** The Laplacian weights fairing used; `null` when it did not run. */
|
|
2308
|
+
weights: "cotangent" | "uniform" | null;
|
|
2309
|
+
/** Whether refinement stopped early on its vertex budget or rounds. */
|
|
2310
|
+
refineCapped: boolean;
|
|
2311
|
+
}
|
|
2312
|
+
/** What `fillHoles` did, each list in loop order. */
|
|
2313
|
+
interface FillReport {
|
|
2314
|
+
filled: FilledLoop[];
|
|
2315
|
+
/** Loops left out: beyond a bound, or unclean (or open). */
|
|
2316
|
+
skipped: {
|
|
2317
|
+
id: LoopId;
|
|
2318
|
+
reason: "bounds" | "unclean" | "uvSeam";
|
|
2319
|
+
}[];
|
|
2320
|
+
/** Selected loops that could not be filled; they stay open. */
|
|
2321
|
+
failed: {
|
|
2322
|
+
id: LoopId;
|
|
2323
|
+
reason: "projectionFolds" | "noValidTriangulation" | "solver";
|
|
2324
|
+
}[];
|
|
2325
|
+
}
|
|
2326
|
+
/**
|
|
2327
|
+
* Vertices a brush op holds back, with optional geodesic soft-band feathering.
|
|
2328
|
+
* After the op runs, each listed vertex's move is scaled by its weight: `0`
|
|
2329
|
+
* leaves it at exactly the bytes it had, `1` keeps the whole move. When
|
|
2330
|
+
* `band > 0`, vertices within geodesic surface distance `band` of `0`-weight
|
|
2331
|
+
* vertices feather smoothly across `[0, band]`. The op's report describes its
|
|
2332
|
+
* own move before scaling, and it stays one undo step; an op alone whose brush
|
|
2333
|
+
* holds only vertices at `0` reports 0 and leaves no step.
|
|
2334
|
+
*
|
|
2335
|
+
* @throws `INVALID_ARGUMENT` when a vertex is not alive, a weight is outside
|
|
2336
|
+
* `[0, 1]`, `band` is negative or non-finite, or the lists differ in length.
|
|
2337
|
+
*/
|
|
2338
|
+
interface VertexProtection {
|
|
2339
|
+
/** The vertex slots to protect. */
|
|
2340
|
+
vertices: Indices;
|
|
2341
|
+
/** One weight per vertex, each in `[0, 1]`; unset holds every listed vertex fully (all `0`). */
|
|
2342
|
+
weights?: ArrayLike<number>;
|
|
2343
|
+
/** Geodesic soft-falloff transition band width in local units around `0`-weight vertices; unset means `0`. */
|
|
2344
|
+
band?: number;
|
|
2345
|
+
}
|
|
2346
|
+
/** What `inflate` did. */
|
|
2347
|
+
interface InflateReport {
|
|
2348
|
+
moved: number;
|
|
2349
|
+
maxDisplacement: number;
|
|
2350
|
+
}
|
|
2351
|
+
/** What `smooth` did. */
|
|
2352
|
+
interface SmoothReport {
|
|
2353
|
+
moved: number;
|
|
2354
|
+
maxDisplacement: number;
|
|
2355
|
+
}
|
|
2356
|
+
/** What `flatten` did. */
|
|
2357
|
+
interface FlattenReport {
|
|
2358
|
+
moved: number;
|
|
2359
|
+
maxDisplacement: number;
|
|
2360
|
+
}
|
|
2361
|
+
/** What `crease` did. */
|
|
2362
|
+
interface CreaseReport {
|
|
2363
|
+
moved: number;
|
|
2364
|
+
maxDisplacement: number;
|
|
2365
|
+
}
|
|
2366
|
+
/** What `clay` did. */
|
|
2367
|
+
interface ClayReport {
|
|
2368
|
+
moved: number;
|
|
2369
|
+
maxDisplacement: number;
|
|
2370
|
+
}
|
|
2371
|
+
/** What `twist` did. */
|
|
2372
|
+
interface TwistReport {
|
|
2373
|
+
moved: number;
|
|
2374
|
+
maxDisplacement: number;
|
|
2375
|
+
}
|
|
2376
|
+
/** What `captureStrokeState` did: nothing to report. */
|
|
2377
|
+
type CaptureStrokeReport = Record<string, never>;
|
|
2378
|
+
/** Edge sizing strategy for `remeshSurface`. */
|
|
2379
|
+
type SurfaceRemeshMode = "isotropic" | "adaptive";
|
|
2380
|
+
/** What `remeshSurface` did. */
|
|
2381
|
+
interface SurfaceRemeshReport {
|
|
2382
|
+
/** Alive triangles before remeshing. */
|
|
2383
|
+
initialTriangles: number;
|
|
2384
|
+
/** Alive triangles after remeshing. */
|
|
2385
|
+
finalTriangles: number;
|
|
2386
|
+
/** Edge splits performed across all passes. */
|
|
2387
|
+
splits: number;
|
|
2388
|
+
/** Edge collapses performed across all passes. */
|
|
2389
|
+
collapses: number;
|
|
2390
|
+
/** Valence-reducing interior edge flips performed across all passes. */
|
|
2391
|
+
flips: number;
|
|
2392
|
+
/** Iterations executed. */
|
|
2393
|
+
iterationsRun: number;
|
|
2394
|
+
/** Whether a UV channel existed and was dropped undoably. */
|
|
2395
|
+
uvsDropped: boolean;
|
|
2396
|
+
}
|
|
2397
|
+
/** What `remesh` did. */
|
|
2398
|
+
interface RemeshReport {
|
|
2399
|
+
splits: number;
|
|
2400
|
+
collapses: number;
|
|
2401
|
+
flips: number;
|
|
2402
|
+
rounds: number;
|
|
2403
|
+
}
|
|
2404
|
+
/** What `splitStretched` did. */
|
|
2405
|
+
interface StretchReport {
|
|
2406
|
+
splits: number;
|
|
2407
|
+
/** Edges still past the limit because `maxSplits` ran out, for a later call. */
|
|
2408
|
+
remaining: number;
|
|
2409
|
+
/**
|
|
2410
|
+
* `new, a, b` per split, in order: the new vertex and its edge's endpoints,
|
|
2411
|
+
* which may be new vertices from earlier in the list. For a caller that holds
|
|
2412
|
+
* per-vertex state of its own and has to carry it over.
|
|
2413
|
+
*/
|
|
2414
|
+
vertices: Uint32Array;
|
|
2415
|
+
}
|
|
2416
|
+
/** What `captureRestSizes` did: nothing to report. */
|
|
2417
|
+
type CaptureRestReport = Record<string, never>;
|
|
2418
|
+
/** What `bridgeLoops` did. */
|
|
2419
|
+
interface BridgeReport {
|
|
2420
|
+
trianglesAdded: number;
|
|
2421
|
+
}
|
|
2422
|
+
/** What `grab` did. */
|
|
2423
|
+
interface GrabReport {
|
|
2424
|
+
moved: number;
|
|
2425
|
+
maxDisplacement: number;
|
|
2426
|
+
}
|
|
2427
|
+
/** What `relax` did. */
|
|
2428
|
+
interface RelaxReport {
|
|
2429
|
+
moved: number;
|
|
2430
|
+
maxDisplacement: number;
|
|
2431
|
+
}
|
|
2432
|
+
/** What `offset` did. */
|
|
2433
|
+
interface OffsetReport {
|
|
2434
|
+
moved: number;
|
|
2435
|
+
maxDisplacement: number;
|
|
2436
|
+
/** Degenerate triangles the cleanup pass removed. */
|
|
2437
|
+
degenerateRemoved: number;
|
|
2438
|
+
/** Vertices removed (cleanup pass for `"normal"`, replaced + cleanup for volumetric). */
|
|
2439
|
+
verticesRemoved: number;
|
|
2440
|
+
/** New vertices added by Marching Cubes (`0` for `"normal"`). */
|
|
2441
|
+
verticesAdded: number;
|
|
2442
|
+
/** New triangles added by Marching Cubes (`0` for `"normal"`). */
|
|
2443
|
+
trianglesAdded: number;
|
|
2444
|
+
/** Original triangles replaced (`0` for `"normal"`). */
|
|
2445
|
+
trianglesRemoved: number;
|
|
2446
|
+
/** Voxel spacing used in local mesh units (`0` for `"normal"`). */
|
|
2447
|
+
voxelSize: number;
|
|
2448
|
+
/** Whether the `"uv"` channel was dropped (`false` for `"normal"` or meshes without UVs). */
|
|
2449
|
+
uvsDropped: boolean;
|
|
2450
|
+
}
|
|
2451
|
+
/** What `shell` did. */
|
|
2452
|
+
interface ShellReport {
|
|
2453
|
+
/** Copy vertices added. */
|
|
2454
|
+
verticesAdded: number;
|
|
2455
|
+
/** Copy and wall triangles added. */
|
|
2456
|
+
trianglesAdded: number;
|
|
2457
|
+
/** Boundary rims stitched to their copy. A closed mesh has none. */
|
|
2458
|
+
loopsClosed: number;
|
|
2459
|
+
/** Degenerate triangles the cleanup pass removed. */
|
|
2460
|
+
degenerateRemoved: number;
|
|
2461
|
+
/** Vertices the cleanup pass removed. */
|
|
2462
|
+
verticesRemoved: number;
|
|
2463
|
+
}
|
|
2464
|
+
/** What `simplify` did. */
|
|
2465
|
+
interface SimplifyReport {
|
|
2466
|
+
/** Edge collapses performed. */
|
|
2467
|
+
collapsed: number;
|
|
2468
|
+
/** Triangles removed (one per boundary collapse, two per interior one). */
|
|
2469
|
+
trianglesRemoved: number;
|
|
2470
|
+
/** Vertices removed (one per collapse). */
|
|
2471
|
+
verticesRemoved: number;
|
|
2472
|
+
/** Maximum root-quadric geometric error observed across accepted collapses. */
|
|
2473
|
+
maxDeviationAchieved: number;
|
|
2474
|
+
}
|
|
2475
|
+
/** What `subdivide` did. */
|
|
2476
|
+
interface SubdivideReport {
|
|
2477
|
+
/** Vertices added, one per subdivided edge per level. */
|
|
2478
|
+
verticesAdded: number;
|
|
2479
|
+
/** Triangles added: three per subdivided triangle per level. */
|
|
2480
|
+
trianglesAdded: number;
|
|
2481
|
+
}
|
|
2482
|
+
/** What `makeManifold` did. */
|
|
2483
|
+
interface ManifoldReport {
|
|
2484
|
+
removedDuplicateTriangles: number;
|
|
2485
|
+
prunedFinTriangles: number;
|
|
2486
|
+
splitNonManifoldEdges: number;
|
|
2487
|
+
splitPinchVertices: number;
|
|
2488
|
+
verticesAdded: number;
|
|
2489
|
+
removedVertices: number;
|
|
2490
|
+
}
|
|
2491
|
+
/** What `resolveSelfIntersections` did. */
|
|
2492
|
+
interface SelfIntersectReport {
|
|
2493
|
+
initialPairs: number;
|
|
2494
|
+
remainingPairs: number;
|
|
2495
|
+
removedTriangles: number;
|
|
2496
|
+
addedTriangles: number;
|
|
2497
|
+
modeUsed: SelfIntersectionMode;
|
|
2498
|
+
uvsDropped: boolean;
|
|
2499
|
+
}
|
|
2500
|
+
/** What `cleanupSlivers` did. */
|
|
2501
|
+
interface SliverReport {
|
|
2502
|
+
collapsedNeedles: number;
|
|
2503
|
+
flippedCaps: number;
|
|
2504
|
+
removedDegenerate: number;
|
|
2505
|
+
removedVertices: number;
|
|
2506
|
+
}
|
|
2507
|
+
/** Options of {@link Scene.join}. */
|
|
2508
|
+
interface JoinOptions {
|
|
2509
|
+
/** The loop on the target, from `analyze(target).loops`. */
|
|
2510
|
+
loopA: LoopId;
|
|
2511
|
+
/** The loop on the source, from `analyze(source).loops`. */
|
|
2512
|
+
loopB: LoopId;
|
|
2513
|
+
/** Maximum vertices per loop; unset means the default (128). */
|
|
2514
|
+
maxEdges?: number;
|
|
2515
|
+
}
|
|
2516
|
+
/** What {@link Scene.join} did. */
|
|
2517
|
+
interface JoinReport {
|
|
2518
|
+
/** Source vertices copied into the target. */
|
|
2519
|
+
verticesAdded: number;
|
|
2520
|
+
/** Source triangles copied into the target. */
|
|
2521
|
+
trianglesAdded: number;
|
|
2522
|
+
/** Bridge triangles between the two loops. */
|
|
2523
|
+
bridgeTrianglesAdded: number;
|
|
2524
|
+
}
|
|
2525
|
+
/** Options of {@link Scene.register}. */
|
|
2526
|
+
interface RegisterOptions {
|
|
2527
|
+
/** The most solver steps. 0 only measures the current placement. Default 50. */
|
|
2528
|
+
maxIterations?: number;
|
|
2529
|
+
/**
|
|
2530
|
+
* Stops when one step moves every point by at most this fraction of the
|
|
2531
|
+
* moving mesh's extent (the largest distance of its points from their
|
|
2532
|
+
* centroid). Default `1e-6`.
|
|
2533
|
+
*/
|
|
2534
|
+
tolerance?: number;
|
|
2535
|
+
/**
|
|
2536
|
+
* The fraction of the moving mesh expected to lie over the fixed one, in
|
|
2537
|
+
* `(0, 1]`: each iteration uses that many of its points, closest first, so
|
|
2538
|
+
* the rest (the part beyond the overlap, and outliers) do not pull the
|
|
2539
|
+
* result. Set it a little below the true overlap for partial scans.
|
|
2540
|
+
* Default 1: every point counts, and nothing is rejected.
|
|
2541
|
+
*/
|
|
2542
|
+
overlap?: number;
|
|
2543
|
+
/** Points farther than this from the fixed mesh (world units) are not used. Default: no limit. */
|
|
2544
|
+
maxDistance?: number;
|
|
2545
|
+
/**
|
|
2546
|
+
* The most points of the moving mesh to use, evenly spaced over its
|
|
2547
|
+
* triangles' centroids and its vertices. `rmse` is measured on these.
|
|
2548
|
+
* Default 100,000.
|
|
2549
|
+
*/
|
|
2550
|
+
maxSamples?: number;
|
|
2551
|
+
/**
|
|
2552
|
+
* Whether a good result becomes the moving mesh's placement, as one undo
|
|
2553
|
+
* step: it must converge, with `rmse` within `maxRmse` and at least half of
|
|
2554
|
+
* the points `overlap` expects in range. Anything else is not applied,
|
|
2555
|
+
* whatever this says; {@link RegisterResult.notApplied} says why. Default
|
|
2556
|
+
* `true`.
|
|
2557
|
+
*/
|
|
2558
|
+
apply?: boolean;
|
|
2559
|
+
/**
|
|
2560
|
+
* The largest `rmse` (world units) that may be applied, to keep a wrong local
|
|
2561
|
+
* minimum from moving the mesh. Default: 1% of the moving points' extent,
|
|
2562
|
+
* reported as {@link RegisterResult.maxRmse}. Scans noisier than that need
|
|
2563
|
+
* their own limit; `Infinity` turns the guard off.
|
|
2564
|
+
*/
|
|
2565
|
+
maxRmse?: number;
|
|
2566
|
+
}
|
|
2567
|
+
/** Why {@link Scene.register} did not apply its result. */
|
|
2568
|
+
type RegisterNotApplied = "notRequested" | "notConverged" | "rmseAboveLimit" | "tooFewInliers";
|
|
2569
|
+
/**
|
|
2570
|
+
* A rigid motion the data do not determine, in world coordinates: a point `p`
|
|
2571
|
+
* moves along `translation + rotation x (p - about)`, scaled so that the moving
|
|
2572
|
+
* mesh's points move by 1 (root mean square).
|
|
2573
|
+
*/
|
|
2574
|
+
interface RegisterMotion {
|
|
2575
|
+
translation: Vec3;
|
|
2576
|
+
/** The rotation part, as an axis scaled by its rate. */
|
|
2577
|
+
rotation: Vec3;
|
|
2578
|
+
/** The point the rotation turns about: the moved points' centroid. */
|
|
2579
|
+
about: Vec3;
|
|
2580
|
+
/** The rmse of the other pose found along this motion, which fits as well. */
|
|
2581
|
+
alternativeRmse: number;
|
|
2582
|
+
}
|
|
2583
|
+
/**
|
|
2584
|
+
* Why {@link Scene.register} stopped:
|
|
2585
|
+
* - `"converged"`: a step fell below the tolerance, and restarting from displaced
|
|
2586
|
+
* poses came back to the result, or only found worse fits: the data determine
|
|
2587
|
+
* every rigid motion locally.
|
|
2588
|
+
* - `"maxIterations"`: the steps ran out first, with no motion found undetermined.
|
|
2589
|
+
* - `"underconstrained"`: the data do not determine the pose. A restart stayed
|
|
2590
|
+
* displaced with a fit as good, as for a plane's slide, or a sphere's or a
|
|
2591
|
+
* cylinder's spin, even when facets or noise let the iteration settle with a
|
|
2592
|
+
* tiny `rmse`. {@link RegisterResult.undetermined} names the motions, and the
|
|
2593
|
+
* pose along them is arbitrary.
|
|
2594
|
+
* - `"tooFewCorrespondences"`: fewer than six points have a usable closest
|
|
2595
|
+
* point.
|
|
2596
|
+
* - `"diverged"`: a step took points out of the range the query can represent.
|
|
2597
|
+
*/
|
|
2598
|
+
type RegisterStatus = "converged" | "maxIterations" | "underconstrained" | "tooFewCorrespondences" | "diverged";
|
|
2599
|
+
/** What {@link Scene.register} found. */
|
|
2600
|
+
interface RegisterResult {
|
|
2601
|
+
/**
|
|
2602
|
+
* The moving mesh's aligned placement, with its scale unchanged: the
|
|
2603
|
+
* converged result, or the best estimate when it did not converge.
|
|
2604
|
+
*/
|
|
2605
|
+
placement: Placement;
|
|
2606
|
+
/**
|
|
2607
|
+
* The root mean square distance (world units) from the used points to the
|
|
2608
|
+
* fixed mesh at `placement`; `Infinity` when no point has a closest point.
|
|
2609
|
+
*/
|
|
2610
|
+
rmse: number;
|
|
2611
|
+
/** Solver steps taken. */
|
|
2612
|
+
iterations: number;
|
|
2613
|
+
/**
|
|
2614
|
+
* `status === "converged"`. ICP is local, so this says the iteration settled
|
|
2615
|
+
* and the data determine the result locally, not that it found the right
|
|
2616
|
+
* alignment: a far guess can settle in a wrong minimum. `maxRmse` guards
|
|
2617
|
+
* applying against that.
|
|
2618
|
+
*/
|
|
2619
|
+
converged: boolean;
|
|
2620
|
+
/** Why iteration stopped. */
|
|
2621
|
+
status: RegisterStatus;
|
|
2622
|
+
/** Whether `placement` was set on the moving mesh. */
|
|
2623
|
+
applied: boolean;
|
|
2624
|
+
/** Why it was not; `null` exactly when `applied`. */
|
|
2625
|
+
notApplied: RegisterNotApplied | null;
|
|
2626
|
+
/** The `rmse` limit that applied (world units). */
|
|
2627
|
+
maxRmse: number;
|
|
2628
|
+
/** Points of the moving mesh sampled. */
|
|
2629
|
+
samples: number;
|
|
2630
|
+
/** Sampled points used at `placement`: the rest were trimmed or out of range. */
|
|
2631
|
+
inliers: number;
|
|
2632
|
+
/**
|
|
2633
|
+
* The smallest eigenvalue of the solver's normal equations over the largest
|
|
2634
|
+
* at the last step, in `[0, 1]`; 0 when no step ran. Geometry only, with no
|
|
2635
|
+
* reference to noise: a low value warns of a weak motion, but a high one does
|
|
2636
|
+
* not show that it is determined. That is `undetermined`.
|
|
2637
|
+
*/
|
|
2638
|
+
conditioning: number;
|
|
2639
|
+
/** The motions the data do not determine; non-empty only when `"underconstrained"`. */
|
|
2640
|
+
undetermined: RegisterMotion[];
|
|
2641
|
+
}
|
|
2642
|
+
/** Options of {@link Scene.cutByPlane}. */
|
|
2643
|
+
interface CutOptions {
|
|
2644
|
+
/**
|
|
2645
|
+
* Close both openings with flat, unfaired patches, across UV seams on a
|
|
2646
|
+
* mesh with UVs. Defaults to `true`; without it both parts keep the open
|
|
2647
|
+
* rim the cut leaves.
|
|
2648
|
+
*/
|
|
2649
|
+
cap?: boolean;
|
|
2650
|
+
}
|
|
2651
|
+
/** What {@link Scene.cutByPlane} did. */
|
|
2652
|
+
interface CutReport {
|
|
2653
|
+
/** The original handle, now holding the `+` side. */
|
|
2654
|
+
kept: MeshHandle;
|
|
2655
|
+
/** The new handle holding the `-` side. */
|
|
2656
|
+
removed: MeshHandle;
|
|
2657
|
+
/** Alive triangles of {@link CutReport.kept}, cap included. */
|
|
2658
|
+
keptTriangles: number;
|
|
2659
|
+
/** Alive triangles of {@link CutReport.removed}, cap included. */
|
|
2660
|
+
removedTriangles: number;
|
|
2661
|
+
/** Cap triangles added on both sides together. */
|
|
2662
|
+
capTriangles: number;
|
|
2663
|
+
}
|
|
2664
|
+
/** Which boolean for {@link Scene.boolean} to compute. */
|
|
2665
|
+
type BooleanOp = "union" | "subtract" | "intersect";
|
|
2666
|
+
/** Execution backend for boolean CSG operations. */
|
|
2667
|
+
type BooleanMethod = "manifold" | "bvhSdf" | "fhEdt";
|
|
2668
|
+
/** Options for {@link Scene.boolean}, {@link Scene.booleanBatch}, and {@link BooleanDomain} operations. */
|
|
2669
|
+
interface BooleanOptions {
|
|
2670
|
+
/** Boolean operation when invoking a generic boolean call. */
|
|
2671
|
+
op?: BooleanOp;
|
|
2672
|
+
/** Exact topological arrangement (`"manifold"`, default) or volumetric Marching Cubes fallback (`"bvhSdf"`, `"fhEdt"`). */
|
|
2673
|
+
method?: BooleanMethod;
|
|
2674
|
+
/**
|
|
2675
|
+
* Coplanar facet snap/classification tolerance, in the units of the mesh
|
|
2676
|
+
* the result replaces (before its placement's scale); in world units for
|
|
2677
|
+
* {@link Scene.booleanBatch}.
|
|
2678
|
+
*/
|
|
2679
|
+
coplanarTolerance?: number;
|
|
2680
|
+
/** Collapse needle/sliver triangles created along cut seams (default `true`). */
|
|
2681
|
+
snapSlivers?: boolean;
|
|
2682
|
+
/**
|
|
2683
|
+
* Voxel pitch for `"bvhSdf"` / `"fhEdt"` volumetric fallback (defaults to
|
|
2684
|
+
* automatic pitch), in the same units as `coplanarTolerance`. The voxels lie
|
|
2685
|
+
* along the axes of the mesh the result replaces, or the world's for
|
|
2686
|
+
* {@link Scene.booleanBatch}.
|
|
2687
|
+
*/
|
|
2688
|
+
voxelPitch?: number;
|
|
2689
|
+
/** Optional target triangle budget for post-boolean simplification. */
|
|
2690
|
+
maxTriangles?: number;
|
|
2691
|
+
}
|
|
2692
|
+
/** A node of an N-ary CSG boolean tree over meshes or mesh indices. */
|
|
2693
|
+
type CsgNode = {
|
|
2694
|
+
kind: "leaf";
|
|
2695
|
+
meshIndex: number;
|
|
2696
|
+
} | {
|
|
2697
|
+
kind: "leaf";
|
|
2698
|
+
mesh: MeshHandle;
|
|
2699
|
+
} | {
|
|
2700
|
+
kind: "op";
|
|
2701
|
+
op: BooleanOp;
|
|
2702
|
+
left: CsgNode;
|
|
2703
|
+
right: CsgNode;
|
|
2704
|
+
};
|
|
2705
|
+
/** Options for conforming polyline imprinting and closed-curve trimming via {@link Scene.trimByCurve}. */
|
|
2706
|
+
interface TrimCurveOptions {
|
|
2707
|
+
/** World-space polyline vertices to imprint onto the mesh surface, all on one component of it. */
|
|
2708
|
+
points: readonly Readonly<Vec3>[];
|
|
2709
|
+
/** Treat the curve as a closed loop and delete one side of it from its component (default `false`). */
|
|
2710
|
+
closed?: boolean;
|
|
2711
|
+
/**
|
|
2712
|
+
* When `closed` is `true`, delete the inside of the loop (`true`, default) or
|
|
2713
|
+
* its outside (`false`), as {@link Scene.trimByCurve} tells them apart.
|
|
2714
|
+
*/
|
|
2715
|
+
deleteInside?: boolean;
|
|
2716
|
+
/** Snap tolerance in world units (`0` / omitted chooses automatically). */
|
|
2717
|
+
snapTolerance?: number;
|
|
2718
|
+
}
|
|
2719
|
+
/**
|
|
2720
|
+
* What {@link Scene.trimByCurve} changed.
|
|
2721
|
+
*
|
|
2722
|
+
* Imprinting the curve replaces the triangles it crosses with smaller ones on
|
|
2723
|
+
* the same surface; deleting a side of a loop takes surface away. Either way
|
|
2724
|
+
* the mesh has `trianglesAdded - trianglesRemoved` more triangles than before,
|
|
2725
|
+
* so those two do not tell a cut from an imprint. `removedArea` and
|
|
2726
|
+
* `cutTriangles` do: both are `0` when nothing was cut away (an open curve, or
|
|
2727
|
+
* a loop that separates nothing, such as one around a torus's tube).
|
|
2728
|
+
*/
|
|
2729
|
+
interface TrimReport {
|
|
2730
|
+
/** Handle of the trimmed mesh (`kept`). */
|
|
2731
|
+
kept: MeshHandle;
|
|
2732
|
+
/** Triangles the mesh did not have before: the pieces left of the triangles the curve split. */
|
|
2733
|
+
trianglesAdded: number;
|
|
2734
|
+
/**
|
|
2735
|
+
* Triangles the mesh no longer has, replaced by the imprint or cut away:
|
|
2736
|
+
* `imprintTriangles + cutTriangles`.
|
|
2737
|
+
*/
|
|
2738
|
+
trianglesRemoved: number;
|
|
2739
|
+
/** Of those, the ones replaced with smaller triangles that all stayed: none of their surface is gone. */
|
|
2740
|
+
imprintTriangles: number;
|
|
2741
|
+
/** Of those, the ones that lost surface, in whole or in part. */
|
|
2742
|
+
cutTriangles: number;
|
|
2743
|
+
/** The area of the surface taken away, in world units squared. */
|
|
2744
|
+
removedArea: number;
|
|
2745
|
+
/** New vertices along the curve. */
|
|
2746
|
+
verticesAdded: number;
|
|
2747
|
+
/** Distinct mesh edges along the curve. */
|
|
2748
|
+
seamEdges: number;
|
|
2749
|
+
}
|
|
2750
|
+
/** Options for printability overhang inspection via {@link Scene.overhangs}. */
|
|
2751
|
+
interface OverhangOptions {
|
|
2752
|
+
/** Build direction vector in world coordinates (defaults to `[0, 0, 1]`). */
|
|
2753
|
+
buildDirection?: Readonly<Vec3>;
|
|
2754
|
+
/** Critical overhang angle from horizontal in degrees (defaults to `45`). */
|
|
2755
|
+
criticalAngleDeg?: number;
|
|
2756
|
+
}
|
|
2757
|
+
/** Overhang report and per-vertex overhang angles returned by {@link Scene.overhangs}. */
|
|
2758
|
+
interface OverhangReport {
|
|
2759
|
+
totalSupportArea: number;
|
|
2760
|
+
overhangFaceCount: number;
|
|
2761
|
+
maxOverhangAngleDeg: number;
|
|
2762
|
+
/** Per-vertex overhang angles in degrees, aligned with `views(mesh).positions()` slots. */
|
|
2763
|
+
vertexAnglesDeg: Float32Array;
|
|
2764
|
+
}
|
|
2765
|
+
/** Element quality metric evaluated by {@link Scene.triangleQuality}. */
|
|
2766
|
+
type QualityMetric = "radiusRatio" | "minAngleDeg" | "aspectRatio";
|
|
2767
|
+
/** Options for {@link Scene.triangleQuality}. */
|
|
2768
|
+
interface TriangleQualityOptions {
|
|
2769
|
+
metric?: QualityMetric;
|
|
2770
|
+
/** Threshold below (or above for `"aspectRatio"`) which a live triangle counts as a sliver. */
|
|
2771
|
+
sliverThreshold?: number;
|
|
2772
|
+
}
|
|
2773
|
+
/** Triangle quality report and per-vertex worst-incident quality returned by {@link Scene.triangleQuality}. */
|
|
2774
|
+
interface QualityReport {
|
|
2775
|
+
min: number;
|
|
2776
|
+
max: number;
|
|
2777
|
+
mean: number;
|
|
2778
|
+
sliverTriangleCount: number;
|
|
2779
|
+
liveTriangleCount: number;
|
|
2780
|
+
/** Worst incident triangle quality per vertex slot, aligned with `views(mesh).positions()`. */
|
|
2781
|
+
vertexQuality: Float32Array;
|
|
2782
|
+
}
|
|
2783
|
+
/** Options for Hausdorff / signed mesh deviation inspection via {@link Scene.meshDeviation}. */
|
|
2784
|
+
interface DeviationOptions {
|
|
2785
|
+
/** Return signed deviations using target normals (`false` = unsigned Euclidean distance, default). */
|
|
2786
|
+
signed?: boolean;
|
|
2787
|
+
/** Optional maximum search distance cutoff in world units. */
|
|
2788
|
+
maxDistance?: number;
|
|
2789
|
+
}
|
|
2790
|
+
/** Mesh-to-mesh deviation statistics and per-vertex deviations returned by {@link Scene.meshDeviation}. */
|
|
2791
|
+
interface DeviationStats {
|
|
2792
|
+
min: number;
|
|
2793
|
+
max: number;
|
|
2794
|
+
mean: number;
|
|
2795
|
+
rms: number;
|
|
2796
|
+
p95: number;
|
|
2797
|
+
sampleCount: number;
|
|
2798
|
+
/** Per-vertex deviations in world units, aligned with `views(source).positions()` slots. */
|
|
2799
|
+
vertexDeviations: Float32Array;
|
|
2800
|
+
}
|
|
2801
|
+
/** Algorithm used by {@link Scene.geodesicDistances}. */
|
|
2802
|
+
type GeodesicMethod = "dijkstra" | "heatMethod";
|
|
2803
|
+
/** Options for surface geodesic distance evaluation via {@link Scene.geodesicDistances}. */
|
|
2804
|
+
interface GeodesicOptions {
|
|
2805
|
+
/**
|
|
2806
|
+
* `"dijkstra"` (fast graph distance, default) or `"heatMethod"` (Crane PDE
|
|
2807
|
+
* diffusion); `inspect.geodesicDistances` says how far off each is.
|
|
2808
|
+
*/
|
|
2809
|
+
method?: GeodesicMethod;
|
|
2810
|
+
/** Optional maximum distance cutoff in world units. */
|
|
2811
|
+
maxDistance?: number;
|
|
2812
|
+
/**
|
|
2813
|
+
* Dimensionless time-step scale `m` (`t = m * h^2`) for `"heatMethod"`,
|
|
2814
|
+
* where `h` is the mean edge length, or `sqrt(area / 2000)` where that is
|
|
2815
|
+
* smaller.
|
|
2816
|
+
*/
|
|
2817
|
+
timeStepScale?: number;
|
|
2818
|
+
/**
|
|
2819
|
+
* Cancels the query: its promise rejects with the signal's reason at once,
|
|
2820
|
+
* and a `WorkerScene`'s Worker stops computing at the query's next step. A
|
|
2821
|
+
* `Scene` computes in one call, so there the signal only counts when it is
|
|
2822
|
+
* aborted already: the call then throws its reason.
|
|
2823
|
+
*/
|
|
2824
|
+
signal?: AbortSignal;
|
|
2825
|
+
}
|
|
2826
|
+
/** Sample point along an intrinsic surface shortest path. */
|
|
2827
|
+
interface SurfacePathPoint {
|
|
2828
|
+
/** World-space position on the surface, as precise as the mesh's local positions wherever it is. */
|
|
2829
|
+
position: Vec3;
|
|
2830
|
+
/** Triangle slot index containing this point. */
|
|
2831
|
+
triangle: number;
|
|
2832
|
+
/** Barycentric coordinates `[u, v, w]` inside `triangle`. */
|
|
2833
|
+
barycentric: Vec3;
|
|
2834
|
+
}
|
|
2835
|
+
/** Options for {@link Scene.shortestSurfacePath}. */
|
|
2836
|
+
interface SurfacePathOptions extends GeodesicOptions {
|
|
2837
|
+
/** Precomputed geodesic distances from {@link Scene.geodesicDistances}. */
|
|
2838
|
+
distances?: Float32Array;
|
|
2839
|
+
}
|
|
2840
|
+
/** Corresponding world-space landmark pair `(source, target)` for {@link Scene.alignByLandmarks}. */
|
|
2841
|
+
interface LandmarkPair {
|
|
2842
|
+
source: Readonly<Vec3>;
|
|
2843
|
+
target: Readonly<Vec3>;
|
|
2844
|
+
}
|
|
2845
|
+
/** Result of N-point Umeyama landmark SVD alignment via {@link Scene.alignByLandmarks}. */
|
|
2846
|
+
interface LandmarkAlignment {
|
|
2847
|
+
placement: Placement;
|
|
2848
|
+
scale: number;
|
|
2849
|
+
rmse: number;
|
|
2850
|
+
}
|
|
2851
|
+
/** Coarse pre-alignment strategy for {@link Scene.registerMultistage}. */
|
|
2852
|
+
type CoarseAlignMethod = "none" | "pcaCentroid" | "orientedBoundingBox";
|
|
2853
|
+
/** Fine ICP error metric for {@link Scene.registerMultistage}. */
|
|
2854
|
+
type IcpObjective = "pointToPoint" | "pointToPlane" | "symmetricNormal";
|
|
2855
|
+
/** Options for multi-stage coarse + ICP registration via {@link Scene.registerMultistage}. */
|
|
2856
|
+
interface RegistrationOptions {
|
|
2857
|
+
coarseMethod?: CoarseAlignMethod;
|
|
2858
|
+
objective?: IcpObjective;
|
|
2859
|
+
maxIterations?: number;
|
|
2860
|
+
tolerance?: number;
|
|
2861
|
+
overlap?: number;
|
|
2862
|
+
maxDistance?: number;
|
|
2863
|
+
targetRmse?: number;
|
|
2864
|
+
sampleCount?: number;
|
|
2865
|
+
andersonWindow?: number;
|
|
2866
|
+
}
|
|
2867
|
+
/** Result of {@link Scene.registerMultistage}. */
|
|
2868
|
+
interface RegistrationReport {
|
|
2869
|
+
placement: Placement;
|
|
2870
|
+
/** Column-major 4x4 transform matrix applied to `moving`. */
|
|
2871
|
+
transform: number[];
|
|
2872
|
+
finalRmse: number;
|
|
2873
|
+
iterations: number;
|
|
2874
|
+
status: RegisterStatus;
|
|
2875
|
+
converged: boolean;
|
|
2876
|
+
}
|
|
2877
|
+
/** Symmetry plane result of {@link Scene.detectSymmetryPlane}. */
|
|
2878
|
+
interface SymmetryPlaneReport {
|
|
2879
|
+
planeNormal: Vec3;
|
|
2880
|
+
planePoint: Vec3;
|
|
2881
|
+
symmetryErrorRms: number;
|
|
2882
|
+
symmetryScore: number;
|
|
2883
|
+
}
|
|
2884
|
+
/** Continuity mode across boundary seam edges for {@link Scene.fillHoleContinuity} (#210). */
|
|
2885
|
+
type FillContinuity = "flat" | "tangent" | "curvature";
|
|
2886
|
+
/** Options for {@link Scene.fillHoleContinuity} and {@link Scene.fillAllHolesContinuity} (#210). */
|
|
2887
|
+
interface FillHolesContinuityOptions {
|
|
2888
|
+
/** Continuity mode (`"curvature"` by default). */
|
|
2889
|
+
continuity?: FillContinuity;
|
|
2890
|
+
/** Maximum boundary loop perimeter to fill (unbounded when unset). */
|
|
2891
|
+
maxHolePerimeter?: number;
|
|
2892
|
+
/** Maximum boundary vertex count to fill (unbounded when unset). */
|
|
2893
|
+
maxHoleVertices?: number;
|
|
2894
|
+
/** Refine and fair the interior patch (`true` by default). */
|
|
2895
|
+
refinePatch?: boolean;
|
|
2896
|
+
/** Iterative relaxation rounds during refinement (`1` by default). */
|
|
2897
|
+
smoothIterations?: number;
|
|
2898
|
+
/** Detect and merge nested island loops enclosed inside the hole (`true` by default). */
|
|
2899
|
+
detectIslands?: boolean;
|
|
2900
|
+
}
|
|
2901
|
+
/** Result statistics returned by continuity hole filling (#210). */
|
|
2902
|
+
interface FillContinuityStats {
|
|
2903
|
+
loopIndex: number;
|
|
2904
|
+
filledVertices: number;
|
|
2905
|
+
filledTriangles: number;
|
|
2906
|
+
perimeter: number;
|
|
2907
|
+
maxDihedralAngleDeg: number;
|
|
2908
|
+
continuity: FillContinuity;
|
|
2909
|
+
islandLoopsMerged: number;
|
|
2910
|
+
converged: boolean;
|
|
2911
|
+
}
|
|
2912
|
+
/** Options for {@link Scene.bridgePartialArcs} (#210). */
|
|
2913
|
+
interface PartialBridgeOptions {
|
|
2914
|
+
/** Index of the first boundary loop (`0` by default; overridden when `loopA` vertices are provided). */
|
|
2915
|
+
loopAIndex?: number;
|
|
2916
|
+
/** Inclusive-start vertex index pair `[start, end]` along loop A (`[0, 1]` by default). */
|
|
2917
|
+
arcARange?: readonly [number, number];
|
|
2918
|
+
/** Index of the second boundary loop (`0` by default; overridden when `loopB` vertices are provided). */
|
|
2919
|
+
loopBIndex?: number;
|
|
2920
|
+
/** Inclusive-start vertex index pair `[start, end]` along loop B (`[2, 3]` by default). */
|
|
2921
|
+
arcBRange?: readonly [number, number];
|
|
2922
|
+
/** Cyclic offset applied when pairing `arcB` vertices (`0` by default). */
|
|
2923
|
+
twistOffset?: number;
|
|
2924
|
+
/** Explicit grid subdivisions across the bridge (auto-matched when omitted). */
|
|
2925
|
+
subdivisions?: number;
|
|
2926
|
+
}
|
|
2927
|
+
/** Result statistics returned by {@link Scene.bridgePartialArcs} (#210). */
|
|
2928
|
+
interface BridgeStats {
|
|
2929
|
+
trianglesAdded: number;
|
|
2930
|
+
verticesAdded: number;
|
|
2931
|
+
resultingLoops: number;
|
|
2932
|
+
arcAVertices: number;
|
|
2933
|
+
arcBVertices: number;
|
|
2934
|
+
}
|
|
2935
|
+
/** Dynamic topology detail policy (#212). */
|
|
2936
|
+
type DyntopoMode = "split-collapse" | "split-only" | "brush-relative" | "constant-detail";
|
|
2937
|
+
/** Configuration for localized dynamic topology remeshing (#212). */
|
|
2938
|
+
interface DyntopoOptions {
|
|
2939
|
+
/** Detail sizing and split/collapse mode (`"split-collapse"` by default). */
|
|
2940
|
+
mode?: DyntopoMode;
|
|
2941
|
+
/** Target edge length in local units (or brush radius multiplier for `"brush-relative"`). */
|
|
2942
|
+
detailSize?: number;
|
|
2943
|
+
/** Collapse threshold multiplier relative to `detailSize` (`0.4` by default). */
|
|
2944
|
+
minDetailRatio?: number;
|
|
2945
|
+
/** Split threshold multiplier relative to `detailSize` (`1.33` by default). */
|
|
2946
|
+
maxDetailRatio?: number;
|
|
2947
|
+
/** Equalize vertex valence via Delaunay/valence interior edge flips (`true` by default). */
|
|
2948
|
+
equalizeValence?: boolean;
|
|
2949
|
+
/** Apply tangential relaxation inside the ROI (`false` by default). */
|
|
2950
|
+
smoothTangent?: boolean;
|
|
2951
|
+
}
|
|
2952
|
+
/** Topological delta returned by {@link Scene.applyDyntopo} (#212). */
|
|
2953
|
+
interface DyntopoReport {
|
|
2954
|
+
splits: number;
|
|
2955
|
+
collapses: number;
|
|
2956
|
+
flips: number;
|
|
2957
|
+
smoothed: number;
|
|
2958
|
+
createdVertices: Uint32Array;
|
|
2959
|
+
removedVertices: Uint32Array;
|
|
2960
|
+
}
|
|
2961
|
+
/** Combined brush and dynamic topology report returned by {@link Scene.dyntopoDab} (#212). */
|
|
2962
|
+
interface DyntopoDabReport extends DyntopoReport {
|
|
2963
|
+
moved: number;
|
|
2964
|
+
maxDisplacement: number;
|
|
2965
|
+
}
|
|
2966
|
+
/** Sculpt brush ops that operate over a localized brush sphere and support Dyntopo. */
|
|
2967
|
+
type SculptBrushOp = Extract<SculptOp, {
|
|
2968
|
+
op: "inflate" | "smooth" | "relax" | "grab" | "flatten" | "crease" | "clay" | "twist";
|
|
2969
|
+
}>;
|
|
2970
|
+
/**
|
|
2971
|
+
* The standard cleanup pipeline for {@link Scene.repair}: weld, remove
|
|
2972
|
+
* degenerate, orient, remove small components, fill holes, as one transaction.
|
|
2973
|
+
* The library owns the order; an option left out takes the library's default.
|
|
2974
|
+
*/
|
|
2975
|
+
interface AutoRepairRequest {
|
|
2976
|
+
kind: "auto";
|
|
2977
|
+
/** Domain preset configuring stages and defaults. Defaults to `"general"`. */
|
|
2978
|
+
preset?: AutoRepairPreset;
|
|
2979
|
+
/** Optional self-intersection resolution override for this run. */
|
|
2980
|
+
selfIntersectionMode?: SelfIntersectionMode;
|
|
2981
|
+
/** Voxel spacing in mesh units for volumetric healing (`"voxelHeal"` or `"print3d"` fallback). */
|
|
2982
|
+
voxelSize?: number;
|
|
2983
|
+
/** Maximum voxel count (`>= 64`) for volumetric healing. Defaults to `16_777_216`. */
|
|
2984
|
+
maxVoxels?: number;
|
|
2985
|
+
/** Vertices at most this far apart are welded, in mesh units. Default depends on `preset` (`1e-5` for `"general"`). */
|
|
2986
|
+
weldTolerance?: number;
|
|
2987
|
+
/** Components with fewer triangles are removed; the largest always stays. Default depends on `preset` (`500` for `"general"`). */
|
|
2988
|
+
minTriangles?: number;
|
|
2989
|
+
/** Fill only holes with at most this many edges; `Infinity` fills any size (`"cadImport"` preserves open boundaries unless finite). Default depends on `preset` (`64` for `"general"`). */
|
|
2990
|
+
maxEdges?: number;
|
|
2991
|
+
/** Refine and fair each fill so it follows the surrounding curvature. Default `true`. */
|
|
2992
|
+
fair?: boolean;
|
|
2993
|
+
}
|
|
2994
|
+
/**
|
|
2995
|
+
* What an {@link AutoRepairRequest} did, one report per stage, keyed by the
|
|
2996
|
+
* stage's {@link RepairOp} name. The keys iterate in the order the stages ran.
|
|
2997
|
+
*/
|
|
2998
|
+
interface AutoRepairReport {
|
|
2999
|
+
weld: WeldReport;
|
|
3000
|
+
removeDegenerate: DegenerateReport;
|
|
3001
|
+
orient: OrientReport;
|
|
3002
|
+
removeSmallComponents: RemoveReport;
|
|
3003
|
+
fillHoles: FillReport;
|
|
3004
|
+
makeManifold?: ManifoldReport;
|
|
3005
|
+
cleanupSlivers?: SliverReport;
|
|
3006
|
+
resolveSelfIntersections?: SelfIntersectReport;
|
|
3007
|
+
}
|
|
3008
|
+
/** The report of a {@link SculptOp}. */
|
|
3009
|
+
type SculptReport = InflateReport | SmoothReport | RelaxReport | GrabReport | FlattenReport | CreaseReport | ClayReport | TwistReport | CaptureStrokeReport | CaptureRestReport | StretchReport | RemeshReport;
|
|
3010
|
+
/** The report type of a sculpt op. */
|
|
3011
|
+
type SculptReportOf<O extends SculptOp> = O extends {
|
|
3012
|
+
op: "inflate";
|
|
3013
|
+
} ? InflateReport : O extends {
|
|
3014
|
+
op: "smooth";
|
|
3015
|
+
} ? SmoothReport : O extends {
|
|
3016
|
+
op: "relax";
|
|
3017
|
+
} ? RelaxReport : O extends {
|
|
3018
|
+
op: "grab";
|
|
3019
|
+
} ? GrabReport : O extends {
|
|
3020
|
+
op: "flatten";
|
|
3021
|
+
} ? FlattenReport : O extends {
|
|
3022
|
+
op: "crease";
|
|
3023
|
+
} ? CreaseReport : O extends {
|
|
3024
|
+
op: "clay";
|
|
3025
|
+
} ? ClayReport : O extends {
|
|
3026
|
+
op: "twist";
|
|
3027
|
+
} ? TwistReport : O extends {
|
|
3028
|
+
op: "captureStrokeState";
|
|
3029
|
+
} ? CaptureStrokeReport : O extends {
|
|
3030
|
+
op: "captureRestSizes";
|
|
3031
|
+
} ? CaptureRestReport : O extends {
|
|
3032
|
+
op: "splitStretched";
|
|
3033
|
+
} ? StretchReport : O extends {
|
|
3034
|
+
op: "remesh";
|
|
3035
|
+
} ? RemeshReport : SculptReport;
|
|
3036
|
+
/** The report of a {@link RepairOp}. */
|
|
3037
|
+
type RepairReport = SculptReport | WeldReport | DegenerateReport | RemoveReport | OrientReport | FillReport | BridgeReport | OffsetReport | ShellReport | SimplifyReport | SurfaceRemeshReport | SubdivideReport | ManifoldReport | SelfIntersectReport | SliverReport;
|
|
3038
|
+
/** The report type of a repair op. */
|
|
3039
|
+
type RepairReportOf<O extends RepairOp> = O extends {
|
|
3040
|
+
op: "weld";
|
|
3041
|
+
} ? WeldReport : O extends {
|
|
3042
|
+
op: "removeDegenerate";
|
|
3043
|
+
} ? DegenerateReport : O extends {
|
|
3044
|
+
op: "removeSmallComponents";
|
|
3045
|
+
} ? RemoveReport : O extends {
|
|
3046
|
+
op: "orient";
|
|
3047
|
+
} ? OrientReport : O extends {
|
|
3048
|
+
op: "makeManifold";
|
|
3049
|
+
} ? ManifoldReport : O extends {
|
|
3050
|
+
op: "resolveSelfIntersections";
|
|
3051
|
+
} ? SelfIntersectReport : O extends {
|
|
3052
|
+
op: "cleanupSlivers";
|
|
3053
|
+
} ? SliverReport : O extends {
|
|
3054
|
+
op: "fillHoles";
|
|
3055
|
+
} ? FillReport : O extends {
|
|
3056
|
+
op: "inflate";
|
|
3057
|
+
} ? InflateReport : O extends {
|
|
3058
|
+
op: "smooth";
|
|
3059
|
+
} ? SmoothReport : O extends {
|
|
3060
|
+
op: "remesh";
|
|
3061
|
+
} ? RemeshReport : O extends {
|
|
3062
|
+
op: "bridgeLoops";
|
|
3063
|
+
} ? BridgeReport : O extends {
|
|
3064
|
+
op: "grab";
|
|
3065
|
+
} ? GrabReport : O extends {
|
|
3066
|
+
op: "relax";
|
|
3067
|
+
} ? RelaxReport : O extends {
|
|
3068
|
+
op: "flatten";
|
|
3069
|
+
} ? FlattenReport : O extends {
|
|
3070
|
+
op: "crease";
|
|
3071
|
+
} ? CreaseReport : O extends {
|
|
3072
|
+
op: "clay";
|
|
3073
|
+
} ? ClayReport : O extends {
|
|
3074
|
+
op: "twist";
|
|
3075
|
+
} ? TwistReport : O extends {
|
|
3076
|
+
op: "captureStrokeState";
|
|
3077
|
+
} ? CaptureStrokeReport : O extends {
|
|
3078
|
+
op: "offset";
|
|
3079
|
+
} ? OffsetReport : O extends {
|
|
3080
|
+
op: "shell";
|
|
3081
|
+
} ? ShellReport : O extends {
|
|
3082
|
+
op: "simplify";
|
|
3083
|
+
} ? SimplifyReport : O extends {
|
|
3084
|
+
op: "remeshSurface";
|
|
3085
|
+
} ? SurfaceRemeshReport : O extends {
|
|
3086
|
+
op: "subdivide";
|
|
3087
|
+
} ? SubdivideReport : O extends {
|
|
3088
|
+
op: "splitStretched";
|
|
3089
|
+
} ? StretchReport : O extends {
|
|
3090
|
+
op: "captureRestSizes";
|
|
3091
|
+
} ? CaptureRestReport : RepairReport;
|
|
3092
|
+
/**
|
|
3093
|
+
* A scene of editable meshes. Create it after `await init()`; release it with
|
|
3094
|
+
* {@link Scene.free} or a `using` declaration (otherwise it is freed when
|
|
3095
|
+
* garbage collected).
|
|
3096
|
+
*
|
|
3097
|
+
* Render views ({@link Scene.views}) point into WebAssembly memory and are
|
|
3098
|
+
* only valid until the next scene call that may allocate or move buffers: a
|
|
3099
|
+
* kept view may read other data or be empty. Re-acquire them after every
|
|
3100
|
+
* scene call; see {@link MeshViews}.
|
|
3101
|
+
*/
|
|
3102
|
+
declare class Scene implements SceneLike {
|
|
3103
|
+
#private;
|
|
3104
|
+
/**
|
|
3105
|
+
* Callable repair domain (`scene.repair(mesh, op)` and `scene.repair.<method>(...)`).
|
|
3106
|
+
*/
|
|
3107
|
+
readonly repair: SyncRepairDomain;
|
|
3108
|
+
/**
|
|
3109
|
+
* Callable sculpt domain (`scene.sculpt(mesh, op)` and `scene.sculpt.<method>(...)`).
|
|
3110
|
+
*/
|
|
3111
|
+
readonly sculpt: SyncSculptDomain;
|
|
3112
|
+
/** Remesh, simplification, subdivision, and volumetric reconstruction domain. */
|
|
3113
|
+
readonly remesh: SyncRemeshDomain;
|
|
3114
|
+
/** Callable boolean, cutting, trimming, offsetting, and shell domain. */
|
|
3115
|
+
readonly boolean: SyncBooleanDomain;
|
|
3116
|
+
/** Surface deformation and vertex-protection domain. */
|
|
3117
|
+
readonly deform: SyncDeformDomain;
|
|
3118
|
+
/** Defect analysis, metrology, queries, printability/quality/geodesic fields, paths, and section inspection domain. */
|
|
3119
|
+
readonly inspect: SyncInspectDomain;
|
|
3120
|
+
/** Rigid registration, landmark SVD, multi-stage alignment, and symmetry detection domain. */
|
|
3121
|
+
readonly align: SyncAlignDomain;
|
|
3122
|
+
constructor(options?: SceneOptions);
|
|
3123
|
+
/** Releases the scene and everything in it. Later calls throw `INVALID_ARGUMENT`; calling it again does nothing. */
|
|
3124
|
+
free(): void;
|
|
3125
|
+
/** Same as {@link Scene.free}, for `using scene = new Scene()`. */
|
|
3126
|
+
[Symbol.dispose](): void;
|
|
3127
|
+
/**
|
|
3128
|
+
* Adds a mesh from world positions. They are stored as `p − origin` in
|
|
3129
|
+
* `f32` (see {@link AddMeshOptions.origin}); the placement starts as the
|
|
3130
|
+
* identity, so {@link Scene.matrix4} maps the local coordinates back to
|
|
3131
|
+
* where they were given.
|
|
3132
|
+
*
|
|
3133
|
+
* @throws `INVALID_ARGUMENT` for bad lengths or options (`uvs` not 2 finite
|
|
3134
|
+
* values per vertex included), `INVALID_INDEX` for an index out of range.
|
|
3135
|
+
*/
|
|
3136
|
+
addMesh(positions: Positions64, indices: Indices, options?: AddMeshOptions): MeshHandle;
|
|
3137
|
+
/**
|
|
3138
|
+
* Removes a mesh. Its handle then gives `UNKNOWN_MESH`. An active drag of
|
|
3139
|
+
* the mesh is ended first, closing its step; the mesh's history entries
|
|
3140
|
+
* (the drag's included) are then dropped with it.
|
|
3141
|
+
*
|
|
3142
|
+
* With `undoable` the removal is an undo step (or part of the open one)
|
|
3143
|
+
* and the history stays: {@link Scene.undo} brings the mesh back with the
|
|
3144
|
+
* same handle, its data, placement, display (normals, colouring), the
|
|
3145
|
+
* fields on it and its collision rules (a rule once both its meshes are
|
|
3146
|
+
* back). Nothing is copied, whatever the mesh's size. What belongs to other
|
|
3147
|
+
* meshes is cut as by any removal and does not come back: fields on other
|
|
3148
|
+
* meshes measured to it, and its section entries. The kept mesh counts
|
|
3149
|
+
* against the history's memory budget, and is freed once the history drops
|
|
3150
|
+
* the step (see {@link Scene.isRestorable}). A removal larger than the
|
|
3151
|
+
* whole budget is permanent: {@link Scene.removalBytes} tells before,
|
|
3152
|
+
* {@link Scene.onPermanent} after.
|
|
3153
|
+
*/
|
|
3154
|
+
removeMesh(mesh: MeshHandle, options?: RemoveMeshOptions): void;
|
|
3155
|
+
/** Whether the scene has `mesh`: `false` once it is removed, or its add is undone. */
|
|
3156
|
+
has(mesh: MeshHandle): boolean;
|
|
3157
|
+
/**
|
|
3158
|
+
* Whether undo or redo can still bring back `mesh`: it was removed with
|
|
3159
|
+
* `undoable`, or its undoable add was undone, and the history has not
|
|
3160
|
+
* dropped the step (its memory budget, {@link Scene.clearHistory}, or a
|
|
3161
|
+
* new step after an undone add). `false` for a mesh in the scene.
|
|
3162
|
+
*/
|
|
3163
|
+
isRestorable(mesh: MeshHandle): boolean;
|
|
3164
|
+
/**
|
|
3165
|
+
* About the bytes of history an undoable {@link Scene.removeMesh} of `mesh`
|
|
3166
|
+
* takes. One larger than {@link Scene.historyBudget} is permanent.
|
|
3167
|
+
*
|
|
3168
|
+
* @example
|
|
3169
|
+
* ```ts
|
|
3170
|
+
* if (scene.removalBytes(mesh) <= scene.historyBudget() || confirm("Remove for good?")) {
|
|
3171
|
+
* scene.removeMesh(mesh, { undoable: true });
|
|
3172
|
+
* }
|
|
3173
|
+
* ```
|
|
3174
|
+
*/
|
|
3175
|
+
removalBytes(mesh: MeshHandle): number;
|
|
3176
|
+
/**
|
|
3177
|
+
* Joins `source` into `target`: copies the source's geometry into the
|
|
3178
|
+
* target (keeping its world shape), bridges `options.loopA` to the copied
|
|
3179
|
+
* `options.loopB`, and removes the source. All of it is one undo step:
|
|
3180
|
+
* {@link Scene.undo} restores the target and brings the source back with
|
|
3181
|
+
* the same handle, as for {@link Scene.removeMesh} with `undoable` (what
|
|
3182
|
+
* comes back with it, and the memory it takes, are described there). A drag
|
|
3183
|
+
* of the source ends first, recording its moves as one step, so they
|
|
3184
|
+
* survive a failed join.
|
|
3185
|
+
*
|
|
3186
|
+
* @deprecated Use `scene.repair.join()` instead.
|
|
3187
|
+
* @throws `UNKNOWN_MESH` for a removed handle; `INVALID_ARGUMENT` for one
|
|
3188
|
+
* mesh twice or loops that cannot bridge; `STALE_LOOPS` for a loop that is
|
|
3189
|
+
* not there. A failed join changes nothing.
|
|
3190
|
+
*/
|
|
3191
|
+
join(target: MeshHandle, source: MeshHandle, options: JoinOptions): JoinReport;
|
|
3192
|
+
/**
|
|
3193
|
+
* Cuts `mesh` with a world `plane`: the `+` side
|
|
3194
|
+
* (`signedDistance >= 0`) stays on the mesh and the `-` side is added as
|
|
3195
|
+
* a new mesh with the same placement, so the world shape is kept.
|
|
3196
|
+
* Cutting a closed mesh with `cap` (the default) yields two closed
|
|
3197
|
+
* meshes, capped with flat, unfaired patches. On a mesh with UVs, closed
|
|
3198
|
+
* means closed by exact position, so seams count as closed: the cap's UVs
|
|
3199
|
+
* come from the rim and blend across a seam. A rim that runs into a real
|
|
3200
|
+
* boundary of an open mesh stays open. A mesh without UVs is read by vertex
|
|
3201
|
+
* index, so its split vertices are such a boundary: weld it first.
|
|
3202
|
+
*
|
|
3203
|
+
* The cut and the added mesh are one undo step: undo restores the mesh
|
|
3204
|
+
* and removes the added one, redo brings it back with the same handle.
|
|
3205
|
+
*
|
|
3206
|
+
* @deprecated Use `scene.boolean.cut()` instead.
|
|
3207
|
+
* @throws `UNKNOWN_MESH` for a removed handle; `INVALID_ARGUMENT` when
|
|
3208
|
+
* the plane does not cut the mesh or a rim cannot be capped, as listed in
|
|
3209
|
+
* `docs/uv-channel.md`, for example a rim that closes by position with its
|
|
3210
|
+
* walls wound against each other. A failed cut changes nothing.
|
|
3211
|
+
*/
|
|
3212
|
+
cutByPlane(mesh: MeshHandle, plane: SectionPlane, options?: CutOptions): CutReport;
|
|
3213
|
+
/**
|
|
3214
|
+
* Evaluates an N-ary CSG tree over `meshes` (or handle-leaf nodes) and inserts
|
|
3215
|
+
* the resulting mesh into the scene at identity placement (one undo step). Its
|
|
3216
|
+
* {@link Scene.origin} is the centre of the bounds of the meshes used, so that it
|
|
3217
|
+
* is as precise far from the world origin as near it.
|
|
3218
|
+
*/
|
|
3219
|
+
booleanBatch(meshes: readonly MeshHandle[], tree: CsgNode, options?: BooleanOptions): MeshHandle;
|
|
3220
|
+
booleanBatch(tree: CsgNode, options?: BooleanOptions): MeshHandle;
|
|
3221
|
+
/**
|
|
3222
|
+
* Adds the convex hull of `meshes` (one mesh or several) as a new mesh and
|
|
3223
|
+
* returns it with its counts. The hull is built from the vertices the
|
|
3224
|
+
* meshes' live triangles use; the meshes are not changed.
|
|
3225
|
+
*
|
|
3226
|
+
* The hull is exact (no tolerance): every vertex is inside it or on its
|
|
3227
|
+
* boundary, and it is convex, closed and wound outward, with no
|
|
3228
|
+
* degenerate triangle. Its vertices are input vertices, including every
|
|
3229
|
+
* corner. Duplicate, coplanar and collinear vertices are fine.
|
|
3230
|
+
*
|
|
3231
|
+
* When every mesh has the same placement (one mesh, say), the hull is built
|
|
3232
|
+
* in their own space and the new mesh gets that placement, so it moves
|
|
3233
|
+
* with them; with one origin too, its vertices are exactly theirs.
|
|
3234
|
+
* Otherwise it is built in world space at the identity placement.
|
|
3235
|
+
*
|
|
3236
|
+
* The new mesh is added as one undo step: {@link Scene.undo} removes it and
|
|
3237
|
+
* {@link Scene.redo} brings it back with the same handle.
|
|
3238
|
+
*
|
|
3239
|
+
* @throws {FastMeshError} `INVALID_ARGUMENT` for an empty list or when the
|
|
3240
|
+
* vertices have no volume (all on one point, line or plane; the message
|
|
3241
|
+
* says which), `UNKNOWN_MESH` for a removed mesh.
|
|
3242
|
+
*/
|
|
3243
|
+
convexHull(meshes: MeshHandle | readonly MeshHandle[], options?: ConvexHullOptions): ConvexHullResult;
|
|
3244
|
+
/**
|
|
3245
|
+
* Adds the convex hull of world `points` (flat positions or a packed point
|
|
3246
|
+
* cloud) as a new mesh at the identity placement, and returns it with its
|
|
3247
|
+
* counts. Exact and one undo step, as for {@link Scene.convexHull}.
|
|
3248
|
+
*
|
|
3249
|
+
* @throws {FastMeshError} `INVALID_ARGUMENT` for fewer than four points, a
|
|
3250
|
+
* value that is not a finite number (or beyond `1e100`), or points without
|
|
3251
|
+
* volume (all on one point, line or plane; the message says which).
|
|
3252
|
+
*/
|
|
3253
|
+
convexHullOfPoints(points: ConvexHullPoints, options?: ConvexHullOptions): ConvexHullResult;
|
|
3254
|
+
/**
|
|
3255
|
+
* Fits a height map's frame to `meshes` (one mesh or several): an
|
|
3256
|
+
* orthographic image of square pixels looking along `options.direction`,
|
|
3257
|
+
* centred on the meshes, with their height range. `heightMap` samples it.
|
|
3258
|
+
*
|
|
3259
|
+
* @throws {FastMeshError} `INVALID_ARGUMENT` for an empty list, meshes
|
|
3260
|
+
* without a triangle or without an extent across the direction, an option
|
|
3261
|
+
* out of range, or an image over {@link MAX_HEIGHT_MAP_PIXELS};
|
|
3262
|
+
* `UNKNOWN_MESH` for a removed mesh.
|
|
3263
|
+
*/
|
|
3264
|
+
heightMapFrame(meshes: MeshHandle | readonly MeshHandle[], options?: HeightMapOptions): HeightMapFrame;
|
|
3265
|
+
/**
|
|
3266
|
+
* An orthographic depth image of `meshes` (one mesh or several, in their
|
|
3267
|
+
* placements): the height of each pixel above the frame's zero plane, NaN
|
|
3268
|
+
* where no surface is seen. A pixel's ray runs through its centre and takes
|
|
3269
|
+
* the first surface within the frame's range (either side of a triangle);
|
|
3270
|
+
* a ray exactly through an edge or vertex takes the nearest of the triangles
|
|
3271
|
+
* meeting there, so a watertight mesh has no cracks.
|
|
3272
|
+
*
|
|
3273
|
+
* `frame` is a frame (from {@link Scene.heightMapFrame}, say), or the options
|
|
3274
|
+
* to fit one with. `rows` samples a band of the image's rows, `[first, end)`:
|
|
3275
|
+
* the bands of an image hold exactly what sampling it whole would, so a large
|
|
3276
|
+
* image can be taken in steps.
|
|
3277
|
+
*
|
|
3278
|
+
* `addHeightfield` with the heights, the frame's pixel size and
|
|
3279
|
+
* `heightMapPlacement(frame)` makes a relief that lies on the surface seen.
|
|
3280
|
+
*
|
|
3281
|
+
* @example
|
|
3282
|
+
* ```ts
|
|
3283
|
+
* const { frame, heights } = scene.heightMap(mesh, { direction: [0, 0, -1], resolution: 1024 });
|
|
3284
|
+
* ```
|
|
3285
|
+
* @throws {FastMeshError} `INVALID_ARGUMENT` for an empty list, an invalid
|
|
3286
|
+
* frame, rows outside it, or as for {@link Scene.heightMapFrame};
|
|
3287
|
+
* `UNKNOWN_MESH` for a removed mesh, `STALE_BVH` for a stale manual mesh.
|
|
3288
|
+
*/
|
|
3289
|
+
heightMap(meshes: MeshHandle | readonly MeshHandle[], frame?: HeightMapFrame | HeightMapOptions, rows?: readonly [number, number]): HeightMap;
|
|
3290
|
+
/**
|
|
3291
|
+
* Adds the relief of a grid of heights as a new mesh and returns it with its
|
|
3292
|
+
* counts: a closed, outward-wound solid from a flat base up to the heights,
|
|
3293
|
+
* with a vertex per sample at exactly its height (see `generateHeightfield`
|
|
3294
|
+
* for its frame). The buffers never leave the engine, so large reliefs cost
|
|
3295
|
+
* no copy on this side.
|
|
3296
|
+
*
|
|
3297
|
+
* The new mesh is added as one undo step: {@link Scene.undo} removes it and
|
|
3298
|
+
* {@link Scene.redo} brings it back with the same handle.
|
|
3299
|
+
*
|
|
3300
|
+
* @throws {FastMeshError} `INVALID_ARGUMENT` for fewer than 2 samples on a
|
|
3301
|
+
* side, a wrong number of heights, a height that is infinite or not above
|
|
3302
|
+
* `-base`, or an invalid placement; `OUT_OF_MEMORY` when the relief does
|
|
3303
|
+
* not fit.
|
|
3304
|
+
*/
|
|
3305
|
+
addHeightfield(field: Heightfield, options?: AddHeightfieldOptions): HeightfieldResult;
|
|
3306
|
+
/**
|
|
3307
|
+
* Smooths noise (from a scan, say) out of `mesh` while keeping its sharp
|
|
3308
|
+
* features, as one undo step: the face normals are filtered over their
|
|
3309
|
+
* neighbours, except across edges sharper than `featureAngle`, and the
|
|
3310
|
+
* vertices move to fit them. Flat faces become flat again and the edges
|
|
3311
|
+
* between them stay sharp. The triangles and UVs are kept.
|
|
3312
|
+
*
|
|
3313
|
+
* With `region` (a face selection), only those triangles are smoothed and
|
|
3314
|
+
* no vertex that another triangle uses moves. The report has the
|
|
3315
|
+
* surface's readouts before and after. Nothing is recorded when nothing
|
|
3316
|
+
* moves.
|
|
3317
|
+
*
|
|
3318
|
+
* @throws {FastMeshError} `INVALID_ARGUMENT` for an option out of range or
|
|
3319
|
+
* a dead or out-of-range triangle in `region`, `UNKNOWN_MESH` for a
|
|
3320
|
+
* removed mesh. Nothing changes then.
|
|
3321
|
+
*/
|
|
3322
|
+
denoise(mesh: MeshHandle, options?: DenoiseOptions): DenoiseReport;
|
|
3323
|
+
/**
|
|
3324
|
+
* Improves `mesh`'s triangles without moving a vertex, as one undo step:
|
|
3325
|
+
* flips edges towards a Delaunay triangulation wherever that takes the
|
|
3326
|
+
* surface at most `dihedralLimit` degrees from what it was. Edges sharper
|
|
3327
|
+
* than the limit never flip, and the smallest corner angle never drops.
|
|
3328
|
+
* UVs are kept.
|
|
3329
|
+
*
|
|
3330
|
+
* With `region` (a face selection), only edges between two of its
|
|
3331
|
+
* triangles flip. The report has the surface's readouts before and after.
|
|
3332
|
+
* Nothing is recorded when nothing flips.
|
|
3333
|
+
*
|
|
3334
|
+
* @throws {FastMeshError} as {@link Scene.denoise}.
|
|
3335
|
+
*/
|
|
3336
|
+
delaunayFlips(mesh: MeshHandle, options?: DelaunayFlipOptions): DelaunayFlipReport;
|
|
3337
|
+
/**
|
|
3338
|
+
* Plans the voxel grid of {@link Scene.wrap} for the same meshes and
|
|
3339
|
+
* options without running it: its dimensions, voxel size, voxel count and
|
|
3340
|
+
* estimated memory, and whether it is within `maxVoxels`. Cheap (one pass
|
|
3341
|
+
* over the vertices), so it can follow a settings form.
|
|
3342
|
+
*
|
|
3343
|
+
* @throws {FastMeshError} `INVALID_ARGUMENT` for an empty list, bad options,
|
|
3344
|
+
* meshes without triangles, or a voxel size that `f32` positions cannot
|
|
3345
|
+
* resolve; `UNKNOWN_MESH` for a removed mesh. A grid over the limit is not
|
|
3346
|
+
* an error here: it comes back with `fits: false`.
|
|
3347
|
+
*/
|
|
3348
|
+
wrapPlan(meshes: MeshHandle | readonly MeshHandle[], options?: WrapGridOptions): WrapPlan;
|
|
3349
|
+
/**
|
|
3350
|
+
* Wraps `meshes` (one mesh or several) in one closed envelope, added as a
|
|
3351
|
+
* new mesh, and returns it with its counts. A robust last resort for broken
|
|
3352
|
+
* scans and merged parts: the meshes may be open, holed, overlapping,
|
|
3353
|
+
* self-intersecting or wound either way, and are not changed.
|
|
3354
|
+
*
|
|
3355
|
+
* The envelope is closed, manifold, wound outward and free of
|
|
3356
|
+
* self-intersections. Gaps, slots and holes narrower than `gap` are closed,
|
|
3357
|
+
* and interior cavities are filled. Every vertex is within about half the
|
|
3358
|
+
* gap (and a voxel) of the meshes. It is built on a voxel grid: features
|
|
3359
|
+
* thinner than a voxel may be lost, and sharp edges are cut by up to a voxel,
|
|
3360
|
+
* less with `project`. A shell with a hole wider than the gap is open to the
|
|
3361
|
+
* outside, so its inside is not filled and its walls, with no thickness,
|
|
3362
|
+
* are lost: raise the gap over the hole. {@link Scene.wrapPlan} reports the
|
|
3363
|
+
* grid and its memory beforehand, and a grid over `maxVoxels` is refused.
|
|
3364
|
+
*
|
|
3365
|
+
* When every mesh has the same placement and it has no scale, the wrap is
|
|
3366
|
+
* built in their own space and the new mesh gets that placement; otherwise
|
|
3367
|
+
* it is built in world space at the identity placement. Lengths are world
|
|
3368
|
+
* units either way.
|
|
3369
|
+
*
|
|
3370
|
+
* The new mesh is added as one undo step: {@link Scene.undo} removes it and
|
|
3371
|
+
* {@link Scene.redo} brings it back with the same handle.
|
|
3372
|
+
*
|
|
3373
|
+
* At a million triangles this takes from about half a second to many
|
|
3374
|
+
* seconds, by detail and threads: use `WorkerScene.wrap` to keep the page
|
|
3375
|
+
* live.
|
|
3376
|
+
*
|
|
3377
|
+
* @throws {FastMeshError} `INVALID_ARGUMENT` for an empty list, bad options,
|
|
3378
|
+
* a grid over `maxVoxels` (the message has its size and memory), or meshes
|
|
3379
|
+
* that enclose no volume at this gap and voxel size (a flat sheet, or a
|
|
3380
|
+
* shell with a hole wider than the gap); `UNKNOWN_MESH` for a removed mesh;
|
|
3381
|
+
* `OUT_OF_MEMORY`.
|
|
3382
|
+
*/
|
|
3383
|
+
wrap(meshes: MeshHandle | readonly MeshHandle[], options?: WrapOptions): WrapResult;
|
|
3384
|
+
/**
|
|
3385
|
+
* Conformatively imprints a world-space polyline onto `mesh`, and with
|
|
3386
|
+
* `closed: true` deletes the inside of the loop (or its outside, with
|
|
3387
|
+
* `deleteInside: false`), as one undo step.
|
|
3388
|
+
*
|
|
3389
|
+
* Only the component the curve lies on is imprinted and cut; every other one
|
|
3390
|
+
* stays as it is. A component is a set of triangles joined through shared
|
|
3391
|
+
* edges. On a mesh with UVs an edge also joins across a seam (two edges at
|
|
3392
|
+
* exactly the same positions), so the UV islands of one surface are one
|
|
3393
|
+
* component, and the curve and the cut cross from one to the next. Split
|
|
3394
|
+
* vertices on a mesh without UVs are a real border between components: weld
|
|
3395
|
+
* them first.
|
|
3396
|
+
*
|
|
3397
|
+
* All points must lie on one component: a curve with points on several
|
|
3398
|
+
* throws. Where components touch or coincide, a point lies on each of them.
|
|
3399
|
+
* When all points lie on several, the curve is on the one the first point
|
|
3400
|
+
* projects to, or else on the one with the smallest triangle id there.
|
|
3401
|
+
*
|
|
3402
|
+
* The inside of a loop is the side away from the component's open edges. On
|
|
3403
|
+
* a component with none (a closed one), or when every side reaches one, it
|
|
3404
|
+
* is the side with the smallest world area. A loop that separates nothing,
|
|
3405
|
+
* such as one around a torus's tube, deletes nothing: it is imprinted, and
|
|
3406
|
+
* {@link TrimReport.removedArea} is `0`.
|
|
3407
|
+
*
|
|
3408
|
+
* @throws {FastMeshError} `INVALID_ARGUMENT` for too few or non-finite
|
|
3409
|
+
* points, or points on several components (nothing changes);
|
|
3410
|
+
* `UNKNOWN_MESH` for a removed mesh.
|
|
3411
|
+
*/
|
|
3412
|
+
trimByCurve(mesh: MeshHandle, options: TrimCurveOptions): TrimReport;
|
|
3413
|
+
trimByCurve(mesh: MeshHandle, curve: readonly (Readonly<Vec3> | SurfacePathPoint)[], options?: Omit<TrimCurveOptions, "points">): TrimReport;
|
|
3414
|
+
/**
|
|
3415
|
+
* Fills a single boundary loop with selectable continuity (`"flat"`, `"tangent"`, or `"curvature"`)
|
|
3416
|
+
* and nested island detection (one undo step).
|
|
3417
|
+
*/
|
|
3418
|
+
fillHoleContinuity(mesh: MeshHandle, loopIndex: number, options?: FillHolesContinuityOptions): FillContinuityStats;
|
|
3419
|
+
/**
|
|
3420
|
+
* Fills all eligible boundary loops with selectable continuity (one undo step).
|
|
3421
|
+
*/
|
|
3422
|
+
fillAllHolesContinuity(mesh: MeshHandle, options?: FillHolesContinuityOptions): FillContinuityStats;
|
|
3423
|
+
/**
|
|
3424
|
+
* Bridges two boundary arcs (resolved from `loopA`/`loopB` vertex arrays when non-empty,
|
|
3425
|
+
* or via `options.loopAIndex`/`arcARange` and `loopBIndex`/`arcBRange`) in one undo step.
|
|
3426
|
+
*/
|
|
3427
|
+
bridgePartialArcs(mesh: MeshHandle, loopA?: Indices, loopB?: Indices, options?: PartialBridgeOptions): BridgeStats;
|
|
3428
|
+
/**
|
|
3429
|
+
* Applies localized dynamic topology remeshing inside sphere `(center, radius)`,
|
|
3430
|
+
* locking any `pinned` vertex IDs (one undo step).
|
|
3431
|
+
*/
|
|
3432
|
+
applyDyntopo(mesh: MeshHandle, center: Readonly<Vec3>, radius: number, options?: DyntopoOptions, pinned?: Indices): DyntopoReport;
|
|
3433
|
+
/**
|
|
3434
|
+
* Applies localized dynamic topology remeshing followed by a brush dab (with optional
|
|
3435
|
+
* `protection`), coalescing cleanly inside an active `beginStep`/`endStep`.
|
|
3436
|
+
*/
|
|
3437
|
+
dyntopoDab(mesh: MeshHandle, dab: SculptBrushOp, options?: DyntopoOptions, protection?: VertexProtection): DyntopoDabReport;
|
|
3438
|
+
/**
|
|
3439
|
+
* Rigidly aligns the mesh `moving` to the mesh `fixed` by point-to-plane ICP,
|
|
3440
|
+
* with the closest points found through `fixed`'s BVH and trimmed by
|
|
3441
|
+
* `options.overlap`. A drag of either mesh ends first, recording its moves
|
|
3442
|
+
* as one step, once the arguments have been checked.
|
|
3443
|
+
*
|
|
3444
|
+
* **The initial guess is the current placements.** ICP finds the nearest
|
|
3445
|
+
* fit, so put the meshes roughly in place first with `setPlacement`.
|
|
3446
|
+
*
|
|
3447
|
+
* **Applying.** By default a good result becomes `moving`'s placement as one
|
|
3448
|
+
* undo step (`applied` in the result): converged, with `rmse` within `maxRmse`
|
|
3449
|
+
* and enough points in range. Otherwise nothing moves, and `notApplied` says
|
|
3450
|
+
* why; `placement` still holds the estimate, for `setPlacement` if it will do.
|
|
3451
|
+
* `apply: false` only returns it.
|
|
3452
|
+
*
|
|
3453
|
+
* **Undetermined poses.** A plane's slide and a sphere's or a cylinder's spin
|
|
3454
|
+
* are not fixed by the data, though facets or noise can let the iteration
|
|
3455
|
+
* settle with a tiny `rmse`. These report `"underconstrained"` and list the
|
|
3456
|
+
* motions in `undetermined`. So do coarse regular meshes with exact fits close
|
|
3457
|
+
* by: a 16-sided sphere fits every 22.5 degrees. The check is local, so a
|
|
3458
|
+
* cube's 90-degree symmetry does not count. It adds a bounded cost: up to 12
|
|
3459
|
+
* restarts of up to 12 steps on at most 10,000 points.
|
|
3460
|
+
*
|
|
3461
|
+
* **Scales.** Only rotation and translation are solved. `moving`'s scale is
|
|
3462
|
+
* applied to its points and kept. `fixed`'s scale, uniform or not, is
|
|
3463
|
+
* followed exactly on a copy baked through it, so each such call costs a BVH
|
|
3464
|
+
* build. All distances are in world units.
|
|
3465
|
+
*
|
|
3466
|
+
* @deprecated Use `scene.align.register()` instead.
|
|
3467
|
+
* @throws `UNKNOWN_MESH` for a removed handle; `INVALID_ARGUMENT` for one
|
|
3468
|
+
* mesh twice, a mesh without triangles or an invalid option; `STALE_BVH` for
|
|
3469
|
+
* a stale Manual `fixed`. Bad options and one mesh twice change nothing,
|
|
3470
|
+
* and a drag keeps running. The other errors come after a drag has ended, and
|
|
3471
|
+
* change nothing else.
|
|
3472
|
+
*/
|
|
3473
|
+
register(moving: MeshHandle, fixed: MeshHandle, options?: RegisterOptions): RegisterResult;
|
|
3474
|
+
/**
|
|
3475
|
+
* Aligns `moving` onto `fixed` from N corresponding world-space landmark pairs
|
|
3476
|
+
* using Umeyama SVD (one undo step).
|
|
3477
|
+
*/
|
|
3478
|
+
alignByLandmarks(moving: MeshHandle, fixed: MeshHandle, pairs: readonly LandmarkPair[], allowScaling?: boolean): LandmarkAlignment;
|
|
3479
|
+
/**
|
|
3480
|
+
* Runs coarse pre-alignment (PCA centroid or OBB) followed by iterative ICP
|
|
3481
|
+
* with selectable error objective (`pointToPoint`, `pointToPlane`, or
|
|
3482
|
+
* `symmetricNormal`) and applies the placement to `moving` (one undo step).
|
|
3483
|
+
*/
|
|
3484
|
+
registerMultistage(moving: MeshHandle, fixed: MeshHandle, options?: RegistrationOptions): RegistrationReport;
|
|
3485
|
+
/** Detects the dominant reflection symmetry plane of `mesh` in world space. */
|
|
3486
|
+
detectSymmetryPlane(mesh: MeshHandle): SymmetryPlaneReport;
|
|
3487
|
+
/**
|
|
3488
|
+
* Sets a mesh's placement: world = rotation · (scale · local) + translation,
|
|
3489
|
+
* where local is relative to the mesh origin. A quaternion is normalised
|
|
3490
|
+
* and converted in double precision. The scale defaults to `[1, 1, 1]`
|
|
3491
|
+
* (rigid) and must be 3 finite positive numbers.
|
|
3492
|
+
*
|
|
3493
|
+
* @throws `INVALID_ARGUMENT` when the rotation is not a proper rotation, the
|
|
3494
|
+
* scale is not 3 finite positive numbers, or a quaternion is zero.
|
|
3495
|
+
*/
|
|
3496
|
+
setPlacement(mesh: MeshHandle, placement: PlacementInput): void;
|
|
3497
|
+
/** A mesh's placement, with the rotation as a row-major matrix. */
|
|
3498
|
+
placement(mesh: MeshHandle): Placement;
|
|
3499
|
+
/**
|
|
3500
|
+
* The mesh's origin. `views(mesh).positions()` are relative to it, while
|
|
3501
|
+
* `edit`'s `setPositions` and `addVertices` take positions with it added.
|
|
3502
|
+
*/
|
|
3503
|
+
origin(mesh: MeshHandle): Vec3;
|
|
3504
|
+
/**
|
|
3505
|
+
* The column-major world matrix of the local render coordinates,
|
|
3506
|
+
* `placement · translate(origin)`, ready for renderers (convert to `f32`
|
|
3507
|
+
* yourself). The rotation columns carry the scale; normals need the
|
|
3508
|
+
* inverse-transpose (three.js' normal matrix does this from the matrix).
|
|
3509
|
+
*/
|
|
3510
|
+
matrix4(mesh: MeshHandle): Float64Array;
|
|
3511
|
+
/**
|
|
3512
|
+
* Starts (`points`) or ends (`null`) an interaction: a gesture that changes
|
|
3513
|
+
* a placement or a mesh many times a second (a drag, a brush stroke), during
|
|
3514
|
+
* which a distance field too large to recompute per update stays live near
|
|
3515
|
+
* the contact, and is made exact when the gesture ends.
|
|
3516
|
+
*
|
|
3517
|
+
* While it lasts, a field with more finite values than `points` updates
|
|
3518
|
+
* only the vertices near its moved targets (within a margin that follows
|
|
3519
|
+
* the work, about `points` vertices an update), the vertices an edit moved
|
|
3520
|
+
* and a sweep of a quarter of `points` others. The rest keep their values
|
|
3521
|
+
* and colours, out of date by at most how far the meshes moved since, so
|
|
3522
|
+
* nothing turns far meanwhile. A smaller field updates as usual. Ending it
|
|
3523
|
+
* recomputes the fields it left out of date: their values and colours are
|
|
3524
|
+
* then those of an exact update. A gesture that changed nothing costs
|
|
3525
|
+
* nothing. The results do not depend on the thread count.
|
|
3526
|
+
*
|
|
3527
|
+
* @throws `INVALID_ARGUMENT` unless `points` is `null` or an integer in
|
|
3528
|
+
* `[1, 2^32)`.
|
|
3529
|
+
*/
|
|
3530
|
+
setFieldInteraction(points: number | null): void;
|
|
3531
|
+
/** Sets when the mesh's derived data follows its edits; see {@link UpdateMode}. */
|
|
3532
|
+
setMode(mesh: MeshHandle, mode: UpdateMode): void;
|
|
3533
|
+
/** When the mesh's derived data follows its edits; see {@link UpdateMode}. */
|
|
3534
|
+
mode(mesh: MeshHandle): UpdateMode;
|
|
3535
|
+
/**
|
|
3536
|
+
* The box around the vertices the live triangles use, in the mesh's local
|
|
3537
|
+
* render coordinates ({@link Scene.matrix4} maps them to the world). Dead
|
|
3538
|
+
* slots keep stale positions, so they are excluded. `null` without live
|
|
3539
|
+
* triangles.
|
|
3540
|
+
*/
|
|
3541
|
+
bounds(mesh: MeshHandle): Bounds | null;
|
|
3542
|
+
/** Brings the mesh's derived data up to date now, whatever its mode. */
|
|
3543
|
+
update(mesh: MeshHandle): void;
|
|
3544
|
+
/** Brings every mesh that is not `"manual"` up to date. */
|
|
3545
|
+
flush(): void;
|
|
3546
|
+
/** Vertex slots, alive or dead: the vertex length of the render buffers. */
|
|
3547
|
+
vertexSlots(mesh: MeshHandle): number;
|
|
3548
|
+
/** Triangle slots, alive or dead: the triangle length of the index buffer. */
|
|
3549
|
+
triangleSlots(mesh: MeshHandle): number;
|
|
3550
|
+
/** Alive vertices. */
|
|
3551
|
+
vertexCount(mesh: MeshHandle): number;
|
|
3552
|
+
/** Alive triangles. */
|
|
3553
|
+
triangleCount(mesh: MeshHandle): number;
|
|
3554
|
+
/**
|
|
3555
|
+
* Zero-copy views of the mesh's render buffers. Each getter builds a fresh
|
|
3556
|
+
* view; re-acquire views after every scene call that may allocate, since a
|
|
3557
|
+
* kept one may read other data or be empty (see {@link MeshViews}).
|
|
3558
|
+
*/
|
|
3559
|
+
views(mesh: MeshHandle): SceneMeshViews;
|
|
3560
|
+
/**
|
|
3561
|
+
* Everything that changed since the previous call, one record per mesh.
|
|
3562
|
+
* There is a single consumer: apps that use {@link Scene.onChanges} call
|
|
3563
|
+
* {@link Scene.commitFrame} instead.
|
|
3564
|
+
*/
|
|
3565
|
+
takeChanges(): MeshChange[];
|
|
3566
|
+
/**
|
|
3567
|
+
* Registers a listener for {@link Scene.commitFrame}. Returns a function
|
|
3568
|
+
* that unregisters it.
|
|
3569
|
+
*/
|
|
3570
|
+
onChanges(listener: (changes: MeshChange[]) => void): () => void;
|
|
3571
|
+
/**
|
|
3572
|
+
* Takes the changes once and delivers the same array to every listener,
|
|
3573
|
+
* then returns it. Call it once per animation frame. Every listener runs
|
|
3574
|
+
* even if one throws; the first error is rethrown afterwards.
|
|
3575
|
+
*/
|
|
3576
|
+
commitFrame(): MeshChange[];
|
|
3577
|
+
/**
|
|
3578
|
+
* Undoes the latest step; an active drag is ended first. Without an open
|
|
3579
|
+
* step around the drag, the drag is what gets undone; inside a caller's
|
|
3580
|
+
* open step, that whole step (drag included) is closed and undone. A mesh
|
|
3581
|
+
* the step added undoably leaves the scene, and one it removed undoably
|
|
3582
|
+
* comes back (see {@link MeshChange.added}). Returns `false` when there is
|
|
3583
|
+
* nothing to undo.
|
|
3584
|
+
*/
|
|
3585
|
+
undo(): boolean;
|
|
3586
|
+
/** Redoes the latest undone step. Returns `false` when there is nothing to redo. */
|
|
3587
|
+
redo(): boolean;
|
|
3588
|
+
/** True if {@link Scene.undo} would undo something. */
|
|
3589
|
+
canUndo(): boolean;
|
|
3590
|
+
/** True if {@link Scene.redo} would redo something. */
|
|
3591
|
+
canRedo(): boolean;
|
|
3592
|
+
/** Closes an open step, then drops every undo and redo step. */
|
|
3593
|
+
clearHistory(): void;
|
|
3594
|
+
/**
|
|
3595
|
+
* Records an entry of the application's own in the history, in the open
|
|
3596
|
+
* step or as a step of its own, for state that is not the scene's: a
|
|
3597
|
+
* selection, a list of curves, a document's title. Make the change, then
|
|
3598
|
+
* record how to take it back and make it again. The entry is undone, redone
|
|
3599
|
+
* and cancelled in order with mesh edits and with its step, counts against
|
|
3600
|
+
* the budget, and drops the steps undone before it.
|
|
3601
|
+
*
|
|
3602
|
+
* On undo its `undo` is called before {@link Scene.undo} returns, once
|
|
3603
|
+
* every mesh of the step has changed; the entries of one step are called in
|
|
3604
|
+
* reverse order, and in order on redo. A callback should not change the
|
|
3605
|
+
* scene (that would be a new step); an error it throws is reported
|
|
3606
|
+
* (`reportError`), and the undo stands.
|
|
3607
|
+
*
|
|
3608
|
+
* @throws `INVALID_ARGUMENT` for an entry without `undo` and `redo`, or with
|
|
3609
|
+
* bytes below 0. Nothing is recorded then, and no function is called.
|
|
3610
|
+
*
|
|
3611
|
+
* @example
|
|
3612
|
+
* ```ts
|
|
3613
|
+
* const before = doc.title;
|
|
3614
|
+
* const after = input.value;
|
|
3615
|
+
* doc.title = after;
|
|
3616
|
+
* scene.recordEntry({
|
|
3617
|
+
* undo: () => (doc.title = before),
|
|
3618
|
+
* redo: () => (doc.title = after),
|
|
3619
|
+
* bytes: 2 * (before.length + after.length),
|
|
3620
|
+
* });
|
|
3621
|
+
* ```
|
|
3622
|
+
*/
|
|
3623
|
+
recordEntry(entry: HistoryEntry): void;
|
|
3624
|
+
/** The most bytes the history may hold; see {@link SceneOptions.historyBudget}. */
|
|
3625
|
+
historyBudget(): number;
|
|
3626
|
+
/**
|
|
3627
|
+
* Changes the most bytes the history may hold
|
|
3628
|
+
* ({@link SceneOptions.historyBudget}). A smaller budget is met at once:
|
|
3629
|
+
* the oldest steps go first, then the undone steps furthest from being
|
|
3630
|
+
* redone. The meshes in the scene stay as they are, and an open step is
|
|
3631
|
+
* kept until it closes.
|
|
3632
|
+
*
|
|
3633
|
+
* @throws `INVALID_ARGUMENT` for anything but a number, 0 or more.
|
|
3634
|
+
*/
|
|
3635
|
+
setHistoryBudget(bytes: number): void;
|
|
3636
|
+
/** The bytes the history holds now, the open step included. */
|
|
3637
|
+
historyBytes(): number;
|
|
3638
|
+
/**
|
|
3639
|
+
* Registers a listener called with each step the history could not keep,
|
|
3640
|
+
* since it is larger than the whole budget: an action that is permanent, or
|
|
3641
|
+
* one just undone that cannot be redone. Steps dropped later, to make room
|
|
3642
|
+
* for newer ones or by {@link Scene.setHistoryBudget}, are not reported.
|
|
3643
|
+
* It is called by the history calls themselves (`removeMesh`, `join`,
|
|
3644
|
+
* `endStep`, `undo`, ...), and within a microtask of any other. Returns a
|
|
3645
|
+
* function that unregisters it.
|
|
3646
|
+
*
|
|
3647
|
+
* @example
|
|
3648
|
+
* ```ts
|
|
3649
|
+
* scene.onPermanent(({ lost, gone }) => {
|
|
3650
|
+
* if (lost === "undo") {
|
|
3651
|
+
* notify(gone.length > 0 ? "The removal cannot be undone." : "The change cannot be undone.");
|
|
3652
|
+
* }
|
|
3653
|
+
* });
|
|
3654
|
+
* ```
|
|
3655
|
+
*/
|
|
3656
|
+
onPermanent(listener: PermanentListener): () => void;
|
|
3657
|
+
/**
|
|
3658
|
+
* Opens a history step, or one more nesting level of the open one. Edits,
|
|
3659
|
+
* placement changes and undoable adds and removals until the matching
|
|
3660
|
+
* {@link Scene.endStep} are undone together.
|
|
3661
|
+
*/
|
|
3662
|
+
beginStep(): void;
|
|
3663
|
+
/** Ends one nesting level of the open step. Throws `STEP_NOT_OPEN` when none is open. */
|
|
3664
|
+
endStep(): void;
|
|
3665
|
+
/**
|
|
3666
|
+
* Reverts and discards the open step, however deeply nested. The
|
|
3667
|
+
* application's entries in it are undone and dropped. Throws `STEP_NOT_OPEN`
|
|
3668
|
+
* when none is open.
|
|
3669
|
+
*/
|
|
3670
|
+
cancelStep(): void;
|
|
3671
|
+
/**
|
|
3672
|
+
* Starts dragging a mesh: the moves until {@link DragSession.end} form one
|
|
3673
|
+
* undo step (nested in the open step, if there is one). One drag at a time.
|
|
3674
|
+
* Every {@link DragSession.move} recomputes the eager fields, so make at most
|
|
3675
|
+
* one move per animation frame, with the latest pointer pose, or pass
|
|
3676
|
+
* `{ coalesce: true }` to have the drag do that for you.
|
|
3677
|
+
*/
|
|
3678
|
+
drag(mesh: MeshHandle, options?: DragOptions): DragSession;
|
|
3679
|
+
/**
|
|
3680
|
+
* Edits a mesh's geometry with a list of ops, run in Rust as one
|
|
3681
|
+
* transaction: one undo step (or part of the open step), and when any op
|
|
3682
|
+
* fails nothing changes and nothing is recorded. Positions are world
|
|
3683
|
+
* coordinates, mapped to local with the mesh's placement and origin. Ids
|
|
3684
|
+
* may be {@link EditRef}s to ids added by earlier ops of the list; every
|
|
3685
|
+
* ref is checked before anything is written. Normals, colours, fields,
|
|
3686
|
+
* sections and the BVH follow by the mesh's mode.
|
|
3687
|
+
*
|
|
3688
|
+
* @throws `INVALID_INDEX` for a bad ref or an id that is not alive;
|
|
3689
|
+
* `INVALID_ARGUMENT` for a malformed op, positions not 3 per vertex or not
|
|
3690
|
+
* finite in local `f32`, or removing a vertex still in use.
|
|
3691
|
+
*/
|
|
3692
|
+
edit(mesh: MeshHandle, ops: readonly EditOp[]): EditResult;
|
|
3693
|
+
/**
|
|
3694
|
+
* Removes the mesh's dead slots and renumbers the rest. Its next change
|
|
3695
|
+
* record has every buffer `"all"` and `capacityChanged` when the slot counts
|
|
3696
|
+
* shrank. The mesh's earlier edits leave the history (its placement changes
|
|
3697
|
+
* stay undoable).
|
|
3698
|
+
*/
|
|
3699
|
+
compact(mesh: MeshHandle): void;
|
|
3700
|
+
/**
|
|
3701
|
+
* A read-only report of the mesh's defects: boundary loops (whose ids
|
|
3702
|
+
* `fillHoles` takes), coincident vertices, degenerate and duplicate
|
|
3703
|
+
* triangles, non-manifold edges and vertices, components, orientation
|
|
3704
|
+
* conflicts and, on request, self-intersection.
|
|
3705
|
+
*
|
|
3706
|
+
* @deprecated Use `scene.inspect.analyze()` or `scene.repair.analyze()` instead.
|
|
3707
|
+
* @throws `INVALID_ARGUMENT` for a negative or non-finite `weldTolerance`; `STALE_BVH`, see {@link AnalyzeOptions.selfIntersection}.
|
|
3708
|
+
*/
|
|
3709
|
+
analyze(mesh: MeshHandle, options?: AnalyzeOptions): Analysis;
|
|
3710
|
+
/**
|
|
3711
|
+
* Scalar measurements of a mesh in world coordinates: its surface area
|
|
3712
|
+
* (always) and, when watertight, its enclosed volume. An open or
|
|
3713
|
+
* non-manifold mesh still gets its area; only `volume` is `null`, with
|
|
3714
|
+
* `volumeReason` saying why. A read-only call: it leaves every view
|
|
3715
|
+
* valid.
|
|
3716
|
+
*
|
|
3717
|
+
* @deprecated Use `scene.inspect.measure()` instead.
|
|
3718
|
+
*/
|
|
3719
|
+
measure(mesh: MeshHandle): MeasureResult;
|
|
3720
|
+
/**
|
|
3721
|
+
* Live triangle-used vertex ids of `mesh` inside the closed local-space
|
|
3722
|
+
* sphere `(center, radius)`, in ascending order. Brings a `"lazy"` BVH up
|
|
3723
|
+
* to date first; throws `STALE_BVH` on a stale `"manual"` mesh.
|
|
3724
|
+
*
|
|
3725
|
+
* @deprecated Use `scene.sculpt.verticesInSphere()` instead.
|
|
3726
|
+
* @throws `UNKNOWN_MESH` for a removed handle; `INVALID_ARGUMENT` when
|
|
3727
|
+
* `center` is not 3 finite numbers or `radius` is negative or non-finite;
|
|
3728
|
+
* `STALE_BVH` for a stale `"manual"` mesh.
|
|
3729
|
+
*/
|
|
3730
|
+
verticesInSphere(mesh: MeshHandle, center: Readonly<Vec3>, radius: number): Uint32Array;
|
|
3731
|
+
/**
|
|
3732
|
+
* The nearest hit of a world ray over every mesh, or `null`. `direction`
|
|
3733
|
+
* need not be unit length; `distance` is in world units. Lazy meshes are
|
|
3734
|
+
* brought up to date first.
|
|
3735
|
+
*
|
|
3736
|
+
* @deprecated Use `scene.inspect.raycast()` instead.
|
|
3737
|
+
* @throws `INVALID_ARGUMENT` for a non-finite origin or a zero direction; `STALE_BVH` for a stale `"manual"` mesh.
|
|
3738
|
+
*/
|
|
3739
|
+
raycast(origin: Readonly<Vec3>, direction: Readonly<Vec3>, options?: RaycastOptions): RayHit | null;
|
|
3740
|
+
/**
|
|
3741
|
+
* The surface point nearest to a world point, over every mesh or one, or
|
|
3742
|
+
* `null` when none is within `maxDistance`.
|
|
3743
|
+
*
|
|
3744
|
+
* @deprecated Use `scene.inspect.closestPoint()` instead.
|
|
3745
|
+
*/
|
|
3746
|
+
closestPoint(point: Readonly<Vec3>, options?: ClosestPointOptions): ClosestHit | null;
|
|
3747
|
+
/**
|
|
3748
|
+
* The distance between two meshes' surfaces as placed, with a closest pair
|
|
3749
|
+
* of points, or `null` when it exceeds `maxDistance` (default `Infinity`)
|
|
3750
|
+
* or a mesh has no triangle.
|
|
3751
|
+
*
|
|
3752
|
+
* @deprecated Use `scene.inspect.meshDistance()` instead.
|
|
3753
|
+
*/
|
|
3754
|
+
meshDistance(a: MeshHandle, b: MeshHandle, options?: {
|
|
3755
|
+
maxDistance?: number;
|
|
3756
|
+
}): MeshDistance | null;
|
|
3757
|
+
/**
|
|
3758
|
+
* Whether two meshes intersect or touch as placed.
|
|
3759
|
+
*
|
|
3760
|
+
* @deprecated Use `scene.inspect.intersects()` instead.
|
|
3761
|
+
*/
|
|
3762
|
+
intersects(a: MeshHandle, b: MeshHandle): boolean;
|
|
3763
|
+
/**
|
|
3764
|
+
* The live triangle slots of `mesh` that intersect or touch another of its
|
|
3765
|
+
* own triangles, ascending, each once. Triangles that share a vertex are
|
|
3766
|
+
* never tested against each other (neighbours always touch), and
|
|
3767
|
+
* degenerate triangles are skipped, as for
|
|
3768
|
+
* {@link AnalyzeOptions.selfIntersection}. The placement does not change
|
|
3769
|
+
* the answer. The mesh's BVH is brought up to date first.
|
|
3770
|
+
*
|
|
3771
|
+
* @throws `STALE_BVH` for a `"manual"` mesh whose BVH is stale.
|
|
3772
|
+
*/
|
|
3773
|
+
selfIntersectingTriangles(mesh: MeshHandle): Uint32Array;
|
|
3774
|
+
/**
|
|
3775
|
+
* Every mesh pair (or every pair of `pairs`) within `margin`, sorted by mesh id.
|
|
3776
|
+
*
|
|
3777
|
+
* @deprecated Use `scene.inspect.findContacts()` instead.
|
|
3778
|
+
*/
|
|
3779
|
+
findContacts(options?: FindContactsOptions): Contact[];
|
|
3780
|
+
/** Evaluates printability overhang angles and support surface area in world coordinates. */
|
|
3781
|
+
overhangs(mesh: MeshHandle, options?: OverhangOptions): OverhangReport;
|
|
3782
|
+
/** Evaluates triangle element quality metrics across `mesh` in world coordinates. */
|
|
3783
|
+
triangleQuality(mesh: MeshHandle, metricOrOptions?: QualityMetric | TriangleQualityOptions, sliverThreshold?: number): QualityReport;
|
|
3784
|
+
/** Computes vertex-to-surface Hausdorff / signed deviation from `source` to `target` in world units. */
|
|
3785
|
+
meshDeviation(source: MeshHandle, target: MeshHandle, options?: DeviationOptions): DeviationStats;
|
|
3786
|
+
/**
|
|
3787
|
+
* Computes per-vertex surface geodesic distances from `sources` in world
|
|
3788
|
+
* units; `inspect.geodesicDistances` says what `"heatMethod"` keeps.
|
|
3789
|
+
*/
|
|
3790
|
+
geodesicDistances(mesh: MeshHandle, sources: number | readonly number[], options?: GeodesicOptions): Float32Array;
|
|
3791
|
+
/** Frees what `"heatMethod"` queries keep for the next one of the same mesh. */
|
|
3792
|
+
releaseGeodesics(): void;
|
|
3793
|
+
/** Traces the intrinsic shortest surface path from `sources` to `targetVertex` in world coordinates. */
|
|
3794
|
+
shortestSurfacePath(mesh: MeshHandle, sources: number | readonly number[], targetVertex: number, options?: SurfacePathOptions): SurfacePathPoint[];
|
|
3795
|
+
/**
|
|
3796
|
+
* Selects vertices of a mesh: a sphere brush, a lasso polygon, or the
|
|
3797
|
+
* connected component holding a seed vertex. The result is a snapshot
|
|
3798
|
+
* (ascending ids plus the mesh's content stamp); any edit, repair, compact,
|
|
3799
|
+
* undo or redo of the mesh invalidates it, and the selection methods then
|
|
3800
|
+
* throw `STALE_SELECTION` instead of silently remapping ids. Placement
|
|
3801
|
+
* changes keep selections valid. Only vertices a live triangle uses can
|
|
3802
|
+
* be selected (dead or never-used slots never are).
|
|
3803
|
+
*
|
|
3804
|
+
* @throws `UNKNOWN_MESH` for a removed mesh; `INVALID_ARGUMENT` for a bad
|
|
3805
|
+
* spec; `INVALID_INDEX` for an out-of-range component seed.
|
|
3806
|
+
*/
|
|
3807
|
+
select(mesh: MeshHandle, spec: SelectSpec): VertexSelection;
|
|
3808
|
+
/**
|
|
3809
|
+
* Whether `sel` is still usable: its mesh is alive and no topology edit
|
|
3810
|
+
* landed since it was taken. Never throws.
|
|
3811
|
+
*/
|
|
3812
|
+
selectionAlive(sel: VertexSelection): boolean;
|
|
3813
|
+
/**
|
|
3814
|
+
* Grows a selection by `steps` rings of edge neighbours (staying on live
|
|
3815
|
+
* vertices). The result carries the current stamp, so a fresh selection
|
|
3816
|
+
* can be grown right after an edit. `steps` 0 returns an equal copy.
|
|
3817
|
+
*
|
|
3818
|
+
* @throws `STALE_SELECTION` when the mesh changed since the selection;
|
|
3819
|
+
* `UNKNOWN_MESH` for a removed mesh.
|
|
3820
|
+
*/
|
|
3821
|
+
selectGrow(sel: VertexSelection, steps?: number): VertexSelection;
|
|
3822
|
+
/**
|
|
3823
|
+
* Shrinks a selection by `steps` rings, dropping the members with a live
|
|
3824
|
+
* neighbour outside the set. Interior selections (no boundary) survive
|
|
3825
|
+
* unchanged; shrinking past the core gives an empty (still valid)
|
|
3826
|
+
* selection.
|
|
3827
|
+
*
|
|
3828
|
+
* @throws `STALE_SELECTION` when the mesh changed since the selection;
|
|
3829
|
+
* `UNKNOWN_MESH` for a removed mesh.
|
|
3830
|
+
*/
|
|
3831
|
+
selectShrink(sel: VertexSelection, steps?: number): VertexSelection;
|
|
3832
|
+
/**
|
|
3833
|
+
* Inverts a selection: every live vertex outside it. The result carries
|
|
3834
|
+
* the current stamp.
|
|
3835
|
+
*
|
|
3836
|
+
* @throws `STALE_SELECTION` when the mesh changed since the selection;
|
|
3837
|
+
* `UNKNOWN_MESH` for a removed mesh.
|
|
3838
|
+
*/
|
|
3839
|
+
selectInvert(sel: VertexSelection): VertexSelection;
|
|
3840
|
+
/**
|
|
3841
|
+
* Isolates a selection: removes the triangles fully outside it (no
|
|
3842
|
+
* selected vertex), one undo step. Boundary triangles with at least one
|
|
3843
|
+
* selected vertex stay. An empty selection selects nothing to keep and
|
|
3844
|
+
* throws `INVALID_ARGUMENT` rather than clearing the mesh.
|
|
3845
|
+
*
|
|
3846
|
+
* @throws `STALE_SELECTION` when the mesh changed since the selection;
|
|
3847
|
+
* `UNKNOWN_MESH` for a removed mesh.
|
|
3848
|
+
*/
|
|
3849
|
+
isolate(mesh: MeshHandle, sel: VertexSelection): IsolateReport;
|
|
3850
|
+
/**
|
|
3851
|
+
* Adds a signed distance field: one value per vertex slot of `on`, the
|
|
3852
|
+
* distance to `to` as placed (negative inside), `Infinity` beyond
|
|
3853
|
+
* `maxDistance`, NaN for dead or unused vertices. With several meshes in
|
|
3854
|
+
* `to`, the smallest over them, ties going to the earliest. It follows
|
|
3855
|
+
* edits and placements by the mesh modes, like normals. Removing a mesh of
|
|
3856
|
+
* `to` removes it from the field, or the field with its last target.
|
|
3857
|
+
*
|
|
3858
|
+
* @deprecated Use `scene.inspect.addDistanceField()` instead.
|
|
3859
|
+
* @throws `INVALID_ARGUMENT` when `to` is empty, holds `on` or a mesh twice, `maxDistance` is negative or NaN, or the name is taken.
|
|
3860
|
+
*/
|
|
3861
|
+
addDistanceField(desc: DistanceFieldDesc): FieldHandle;
|
|
3862
|
+
/**
|
|
3863
|
+
* Adds a per-vertex wall-thickness field: one value per vertex slot of
|
|
3864
|
+
* `on`, the distance to the opposite surface along the vertex's smooth
|
|
3865
|
+
* normal, in world units. Open sheets and rims read NaN, hits beyond
|
|
3866
|
+
* `maxDistance` read `Infinity`. It follows edits and placements by the
|
|
3867
|
+
* mesh modes, like normals, and colours like any field.
|
|
3868
|
+
*
|
|
3869
|
+
* @deprecated Use `scene.inspect.addThicknessField()` instead.
|
|
3870
|
+
* @throws `INVALID_ARGUMENT` when `maxDistance` is negative or NaN, or the name is taken.
|
|
3871
|
+
*/
|
|
3872
|
+
addThicknessField(desc: ThicknessFieldDesc): FieldHandle;
|
|
3873
|
+
/**
|
|
3874
|
+
* Adds a per-vertex curvature field: one value per vertex slot of `on`,
|
|
3875
|
+
* the signed mean curvature there, in 1/world-units (positive on domes,
|
|
3876
|
+
* negative in bowls, zero on flats). It follows edits and placements by
|
|
3877
|
+
* the mesh modes, like normals, and colours like any field.
|
|
3878
|
+
*
|
|
3879
|
+
* @deprecated Use `scene.inspect.addCurvatureField()` instead.
|
|
3880
|
+
* @throws `INVALID_ARGUMENT` when the name is taken.
|
|
3881
|
+
*/
|
|
3882
|
+
addCurvatureField(desc: CurvatureFieldDesc): FieldHandle;
|
|
3883
|
+
/** Removes a field, and a colouring by it. Its handle then gives `UNKNOWN_FIELD`. */
|
|
3884
|
+
removeField(field: FieldHandle): void;
|
|
3885
|
+
/**
|
|
3886
|
+
* A zero-copy view of the field's values as of its last update, one per
|
|
3887
|
+
* vertex slot. Like render views, it is only valid until the next call
|
|
3888
|
+
* that may allocate (a kept one may read other data or be empty): get it
|
|
3889
|
+
* right before use.
|
|
3890
|
+
*/
|
|
3891
|
+
fieldValues(field: FieldHandle): Float32Array;
|
|
3892
|
+
/**
|
|
3893
|
+
* Per vertex slot, the index in {@link Scene.fieldTargets} of the target
|
|
3894
|
+
* the field's value came from, or `0xffffffff` for none (`Infinity` or
|
|
3895
|
+
* NaN). A copy, as of the field's last update.
|
|
3896
|
+
*/
|
|
3897
|
+
fieldNearest(field: FieldHandle): Uint32Array;
|
|
3898
|
+
/** The field's target meshes, in index order (a removed target leaves the list). */
|
|
3899
|
+
fieldTargets(field: FieldHandle): MeshHandle[];
|
|
3900
|
+
/**
|
|
3901
|
+
* What the sign data found out about each of the field's targets, in the
|
|
3902
|
+
* order of {@link Scene.fieldTargets}.
|
|
3903
|
+
*/
|
|
3904
|
+
fieldTargetStatus(field: FieldHandle): FieldStatus["sign"][];
|
|
3905
|
+
/**
|
|
3906
|
+
* Whether the field is current, and what its sign data found out about the
|
|
3907
|
+
* target meshes, together (see {@link FieldStatus.sign}).
|
|
3908
|
+
*/
|
|
3909
|
+
fieldStatus(field: FieldHandle): FieldStatus;
|
|
3910
|
+
/**
|
|
3911
|
+
* Colours a mesh from one of its fields (`views(mesh).colors()`), or turns
|
|
3912
|
+
* colouring off with `null`, after which `colors()` returns `null`. Every
|
|
3913
|
+
* vertex is recoloured and reported as `"all"`; later field updates (edits,
|
|
3914
|
+
* drags) report only the vertices whose colour may change. A display
|
|
3915
|
+
* setting: never recorded in history.
|
|
3916
|
+
*
|
|
3917
|
+
* @throws `INVALID_ARGUMENT` when the field is not on `mesh` or the rule is invalid; `UNKNOWN_FIELD`.
|
|
3918
|
+
*/
|
|
3919
|
+
setColoring(mesh: MeshHandle, rule: ColorRule | null): void;
|
|
3920
|
+
/**
|
|
3921
|
+
* The rule the mesh is coloured by (a frozen copy of the one given to
|
|
3922
|
+
* {@link Scene.setColoring}, the same object on every read), or `null`
|
|
3923
|
+
* without colouring (never set, turned off, or its field removed).
|
|
3924
|
+
*
|
|
3925
|
+
* @throws `UNKNOWN_MESH`.
|
|
3926
|
+
*/
|
|
3927
|
+
coloring(mesh: MeshHandle): ColorRule | null;
|
|
3928
|
+
/**
|
|
3929
|
+
* Adds a plane section of `meshes`. Results of `"eager"` meshes are computed
|
|
3930
|
+
* right away; others on {@link Scene.updateSections} or `flush()`.
|
|
3931
|
+
*
|
|
3932
|
+
* @throws `INVALID_ARGUMENT` for a zero normal or a mesh listed twice.
|
|
3933
|
+
*/
|
|
3934
|
+
addSection(desc: SectionDesc): SectionHandle;
|
|
3935
|
+
/** Moves a section's plane. */
|
|
3936
|
+
setSectionPlane(section: SectionHandle, plane: SectionPlane): void;
|
|
3937
|
+
/**
|
|
3938
|
+
* A section's plane as last set by {@link Scene.addSection} or
|
|
3939
|
+
* {@link Scene.setSectionPlane}, the normal normalised. Results not yet
|
|
3940
|
+
* recomputed (`"stale"`) may still be cut with an earlier plane.
|
|
3941
|
+
*/
|
|
3942
|
+
sectionPlane(section: SectionHandle): SectionPlane;
|
|
3943
|
+
/** Changes the meshes a section cuts. */
|
|
3944
|
+
setSectionMeshes(section: SectionHandle, meshes: readonly MeshHandle[]): void;
|
|
3945
|
+
/** Turns a section's fill on or off. */
|
|
3946
|
+
setSectionFill(section: SectionHandle, fill: boolean): void;
|
|
3947
|
+
/** Removes a section. Its handle then gives `UNKNOWN_SECTION`. */
|
|
3948
|
+
removeSection(section: SectionHandle): void;
|
|
3949
|
+
/** Computes every stale section result, whatever the mesh modes. */
|
|
3950
|
+
updateSections(): void;
|
|
3951
|
+
/**
|
|
3952
|
+
* A section's result for one of its meshes as of its last computation
|
|
3953
|
+
* (empty before the first), copied, in world coordinates.
|
|
3954
|
+
*
|
|
3955
|
+
* @throws `INVALID_ARGUMENT` when the section does not cut `mesh`.
|
|
3956
|
+
*/
|
|
3957
|
+
section(section: SectionHandle, mesh: MeshHandle): SectionResult;
|
|
3958
|
+
/**
|
|
3959
|
+
* The closest pair between two meshes' contours in a section, measured in
|
|
3960
|
+
* the plane, or `null` when either has none or their results were cut with
|
|
3961
|
+
* different planes (call {@link Scene.updateSections} first).
|
|
3962
|
+
*/
|
|
3963
|
+
sectionGap(section: SectionHandle, a: MeshHandle, b: MeshHandle): SectionGap | null;
|
|
3964
|
+
/**
|
|
3965
|
+
* Selects triangles enclosed by or intersecting a screen-space rectangle or lasso in NDC. The
|
|
3966
|
+
* camera is in world coordinates and taken in `f64`: see {@link ScreenSelectOptions.viewProj}.
|
|
3967
|
+
*/
|
|
3968
|
+
selectFacesScreen(mesh: MeshHandle, shape: ScreenSelectionShape, options: ScreenSelectOptions): Uint32Array;
|
|
3969
|
+
/** Selects triangles intersecting a world-space sphere (optionally restricted by a normal cone). */
|
|
3970
|
+
selectFacesInSphere(mesh: MeshHandle, center: Readonly<Vec3>, radius: number, normalCone?: FaceSelectionNormalCone): Uint32Array;
|
|
3971
|
+
/** Flood-fills triangles across edges whose dihedral angle does not exceed `maxDihedralRad`. */
|
|
3972
|
+
selectByCreaseAngle(mesh: MeshHandle, seedTri: number, maxDihedralRad: number): Uint32Array;
|
|
3973
|
+
/** Selects the edge-connected shell containing `seedTri`. */
|
|
3974
|
+
selectConnectedShell(mesh: MeshHandle, seedTri: number): Uint32Array;
|
|
3975
|
+
/** Selects small edge-connected face islands bounded by `maxFaceCount` and optional `maxArea`. */
|
|
3976
|
+
selectSmallFaceIslands(mesh: MeshHandle, maxFaceCount: number, maxArea?: number): Uint32Array;
|
|
3977
|
+
/** Expands `selectedTris` outward by `rings` topological rings. */
|
|
3978
|
+
growFaceSelection(mesh: MeshHandle, selectedTris: Indices, rings?: number, adjacency?: AdjacencyKind): Uint32Array;
|
|
3979
|
+
/** Erodes `selectedTris` inward by `rings` topological rings. */
|
|
3980
|
+
shrinkFaceSelection(mesh: MeshHandle, selectedTris: Indices, rings?: number, adjacency?: AdjacencyKind): Uint32Array;
|
|
3981
|
+
/** Fills interior unselected triangle holes up to `maxHoleTris`. */
|
|
3982
|
+
fillSelectionHoles(mesh: MeshHandle, selectedTris: Indices, maxHoleTris: number): Uint32Array;
|
|
3983
|
+
/** Smooths jagged boundaries of a face selection via majority-neighbor voting. */
|
|
3984
|
+
smoothSelectionBoundary(mesh: MeshHandle, selectedTris: Indices, iterations?: number): Uint32Array;
|
|
3985
|
+
/** Converts a face selection into per-vertex `[0, 1]` coverage weights aligned with `vertexSlots()`. */
|
|
3986
|
+
faceSelectionToVertexMask(mesh: MeshHandle, selectedTris: Indices): Float32Array;
|
|
3987
|
+
/** Converts a per-vertex scalar mask into selected triangle indices. */
|
|
3988
|
+
vertexMaskToFaceSelection(mesh: MeshHandle, mask: Float32Array | ArrayLike<number>, threshold?: number, requireAllVertices?: boolean): Uint32Array;
|
|
3989
|
+
/** Deletes `selectedTris` from `mesh` in one undo step. */
|
|
3990
|
+
deleteSelectedFaces(mesh: MeshHandle, selectedTris: Indices): FaceEditReport;
|
|
3991
|
+
/**
|
|
3992
|
+
* Extrudes `triangles` of `mesh`: moves them by `options.distance` (world
|
|
3993
|
+
* units) and builds side walls between where the selection's boundary was
|
|
3994
|
+
* and where it went, as one undo step. A closed, consistently wound mesh
|
|
3995
|
+
* stays closed and consistently wound.
|
|
3996
|
+
*
|
|
3997
|
+
* Each region of the selection moves along its average normal by default;
|
|
3998
|
+
* see {@link ExtrudeFacesOptions.direction}. Selections with holes get walls
|
|
3999
|
+
* around them, and regions that touch at a vertex separate there. Selected
|
|
4000
|
+
* edges on the mesh's open boundary get walls too. The triangles keep their
|
|
4001
|
+
* slots and are the moved faces, so the same selection extrudes them again.
|
|
4002
|
+
*
|
|
4003
|
+
* Self-intersections of the result are reported, not refused: pushing a
|
|
4004
|
+
* face through the other side of a thin part, say, gives a closed mesh that
|
|
4005
|
+
* crosses itself.
|
|
4006
|
+
*
|
|
4007
|
+
* @throws {FastMeshError} `INVALID_ARGUMENT` for an empty selection, a slot
|
|
4008
|
+
* without a live triangle, a distance or direction that is zero or not
|
|
4009
|
+
* finite, a selected edge shared by three or more triangles, selected
|
|
4010
|
+
* triangles wound against each other, or a region whose normals cancel out
|
|
4011
|
+
* (give a direction then); `UNKNOWN_MESH` for a removed mesh. The mesh is
|
|
4012
|
+
* unchanged on error.
|
|
4013
|
+
*/
|
|
4014
|
+
extrudeFaces(mesh: MeshHandle, triangles: Indices, options: ExtrudeFacesOptions): ExtrudeFacesResult;
|
|
4015
|
+
/**
|
|
4016
|
+
* Turns an open surface into a solid, as one undo step: runs boundary loops
|
|
4017
|
+
* of `mesh` along a world direction (down by default) to a flat plane
|
|
4018
|
+
* perpendicular to it, joins each with a wall and closes it with a flat cap.
|
|
4019
|
+
* The plane is at `options.height`, or `options.offset` past the mesh's
|
|
4020
|
+
* furthest vertex.
|
|
4021
|
+
*
|
|
4022
|
+
* By default only the longest loop is extruded, so fill smaller holes first
|
|
4023
|
+
* (or pass `loops: "all"`, which makes them holes through the solid). A
|
|
4024
|
+
* surface that faces the base is turned around, so that the solid faces
|
|
4025
|
+
* outward ({@link ExtrudeBaseResult.flipped}).
|
|
4026
|
+
*
|
|
4027
|
+
* Self-intersections of the result are reported, not refused: a plane that
|
|
4028
|
+
* cuts through the surface, say.
|
|
4029
|
+
*
|
|
4030
|
+
* @throws {FastMeshError} `INVALID_ARGUMENT` when the mesh has no boundary
|
|
4031
|
+
* loop, a loop is open or not clean (orient or repair the mesh first), a
|
|
4032
|
+
* boundary vertex does not lie before the plane, or a loop's outline on
|
|
4033
|
+
* the plane crosses itself; `STALE_LOOPS` for a loop id that matches no
|
|
4034
|
+
* loop; `UNKNOWN_MESH` for a removed mesh. The mesh is unchanged on error.
|
|
4035
|
+
*/
|
|
4036
|
+
extrudeBase(mesh: MeshHandle, options: ExtrudeBaseOptions): ExtrudeBaseResult;
|
|
4037
|
+
/**
|
|
4038
|
+
* Extracts `selectedTris` into a new standalone mesh preserving exact world
|
|
4039
|
+
* coordinates, as one undo step: {@link Scene.undo} removes the new mesh and
|
|
4040
|
+
* {@link Scene.redo} brings it back with the same handle.
|
|
4041
|
+
*/
|
|
4042
|
+
extractSelectedFaces(mesh: MeshHandle, selectedTris: Indices, options?: {
|
|
4043
|
+
normals?: boolean;
|
|
4044
|
+
}): MeshHandle;
|
|
4045
|
+
/**
|
|
4046
|
+
* Splits `selectedTris` off into a new detached mesh and removes them from
|
|
4047
|
+
* `mesh`, as one undo step: {@link Scene.undo} makes `mesh` whole again and
|
|
4048
|
+
* removes the new mesh, which {@link Scene.redo} brings back with the same
|
|
4049
|
+
* handle.
|
|
4050
|
+
*/
|
|
4051
|
+
splitSelectedFaces(mesh: MeshHandle, selectedTris: Indices, options?: {
|
|
4052
|
+
normals?: boolean;
|
|
4053
|
+
}): SplitFacesReport;
|
|
4054
|
+
/**
|
|
4055
|
+
* Builds a zero-offset FFD lattice around `mesh`, in its local coordinates
|
|
4056
|
+
* and along its own axes; `padding` is in its own units.
|
|
4057
|
+
*/
|
|
4058
|
+
buildFfdLattice(mesh: MeshHandle, dims: readonly [number, number, number], basis?: FfdBasisInput, padding?: number): FfdLatticeData;
|
|
4059
|
+
/** Applies Free-Form Deformation (FFD) in one undo step. */
|
|
4060
|
+
applyFfd(mesh: MeshHandle, options: FfdOptions): FreeformReport;
|
|
4061
|
+
/** Applies As-Rigid-As-Possible (ARAP) surface deformation in one undo step. */
|
|
4062
|
+
applyArap(mesh: MeshHandle, options: ArapOptions): FreeformReport;
|
|
4063
|
+
/** Applies a regularized elastic Kelvinlet deformation in one undo step. */
|
|
4064
|
+
applyKelvinlet(mesh: MeshHandle, options: KelvinletOptions): FreeformReport;
|
|
4065
|
+
/** Runs an XPBD soft-body solve with optional self-collision handling in one undo step. */
|
|
4066
|
+
applyXpbd(mesh: MeshHandle, options: XpbdOptions): FreeformReport;
|
|
4067
|
+
/** Sets the scene's fallback inter-object collision rule. */
|
|
4068
|
+
setDefaultCollisionRule(rule: CollisionRuleInput): void;
|
|
4069
|
+
/** Returns the scene's fallback inter-object collision rule. */
|
|
4070
|
+
defaultCollisionRule(): CollisionRule;
|
|
4071
|
+
/** Configures the collision response rule for unordered pair `(a, b)`. */
|
|
4072
|
+
setCollisionRule(a: MeshHandle, b: MeshHandle, rule: CollisionRuleInput): void;
|
|
4073
|
+
/** Clears any pair-specific collision override for `(a, b)`, returning `true` if one existed. */
|
|
4074
|
+
clearCollisionRule(a: MeshHandle, b: MeshHandle): boolean;
|
|
4075
|
+
/** Returns the effective collision rule for `(a, b)`. */
|
|
4076
|
+
collisionRule(a: MeshHandle, b: MeshHandle): CollisionRule;
|
|
4077
|
+
/** True when `mesh` participates in at least one active non-passThrough collision rule. */
|
|
4078
|
+
hasActiveCollisionResponse(mesh: MeshHandle): boolean;
|
|
4079
|
+
/** Moves `mesh` toward `placement` with inter-object collision detection and response. */
|
|
4080
|
+
moveWithCollision(mesh: MeshHandle, placement: PlacementInput, isRelease?: boolean): CollisionStepReport;
|
|
4081
|
+
/** Finalizes queued release actions (deferred cuts, elastic recovery) for `mesh`. */
|
|
4082
|
+
commitCollisionInteraction(mesh: MeshHandle): CollisionStepReport;
|
|
4083
|
+
/**
|
|
4084
|
+
* Fits a geometric primitive (`plane`, `sphere`, `cylinder`, `cone`, or
|
|
4085
|
+
* `auto`) in world space, as precisely far from the world origin as near it.
|
|
4086
|
+
*/
|
|
4087
|
+
fitPrimitive(mesh: MeshHandle, options?: FitPrimitiveOptions): FittedPrimitiveReport;
|
|
4088
|
+
/** Rigidly aligns `mesh`'s fitted datum onto `targetAxis` and `targetOrigin` in one undo step. */
|
|
4089
|
+
alignToFittedPrimitive(mesh: MeshHandle, primitive: FittedPrimitive, targetAxis: Readonly<Vec3>, targetOrigin: Readonly<Vec3>): Placement;
|
|
4090
|
+
/**
|
|
4091
|
+
* Slices world-space planar contours through `mesh`, as precisely far from
|
|
4092
|
+
* the world origin as near it: take the points from `points3d64` there
|
|
4093
|
+
* (`points3d` is `f32`). `origin` may be anywhere on the plane.
|
|
4094
|
+
*/
|
|
4095
|
+
sliceContours(mesh: MeshHandle, origin: Readonly<Vec3>, normal: Readonly<Vec3>): ContourSlice;
|
|
4096
|
+
/** Slices an evenly spaced stack of `count` parallel contours through `mesh`, each as {@link Scene.sliceContours}. */
|
|
4097
|
+
sliceContourStack(mesh: MeshHandle, origin: Readonly<Vec3>, normal: Readonly<Vec3>, spacing: number, count: number): ContourSlice[];
|
|
4098
|
+
/**
|
|
4099
|
+
* Reconstructs a triangle mesh from a packed point cloud and adds it to the
|
|
4100
|
+
* scene, as one undo step: {@link Scene.undo} removes it and
|
|
4101
|
+
* {@link Scene.redo} brings it back with the same handle.
|
|
4102
|
+
*
|
|
4103
|
+
* The cloud's `origin` is the mesh's {@link Scene.origin}. Without one, and
|
|
4104
|
+
* for a bare buffer, the positions are world positions in `f32`, which far
|
|
4105
|
+
* from the world origin are off by up to half of its steps (0.004 at 1e5):
|
|
4106
|
+
* see {@link PackedPointCloud} for clouds there.
|
|
4107
|
+
*/
|
|
4108
|
+
reconstructPointCloud(cloud: PackedPointCloud | Float32Array, options?: SurfaceReconstructOptions): MeshHandle;
|
|
4109
|
+
/** Hollows `mesh` with optional per-vertex wall thickness modulation in one undo step. */
|
|
4110
|
+
hollowMesh(mesh: MeshHandle, options: HollowOptions): HollowReport;
|
|
4111
|
+
/**
|
|
4112
|
+
* Plans the voxel grid of {@link Scene.latticeFill} for the same mesh and
|
|
4113
|
+
* options without running it: its dimensions, voxel size, voxel count,
|
|
4114
|
+
* estimated triangles and memory, the share of space the walls fill, and
|
|
4115
|
+
* whether the grid is within `maxVoxels`. Costs a few passes over the mesh
|
|
4116
|
+
* (tens of milliseconds at a million triangles), so it can follow a
|
|
4117
|
+
* settings form.
|
|
4118
|
+
*
|
|
4119
|
+
* @throws {FastMeshError} as {@link Scene.latticeFill}, except that the mesh
|
|
4120
|
+
* is not checked for being closed, and that a grid over the limit comes
|
|
4121
|
+
* back with `fits: false`.
|
|
4122
|
+
*/
|
|
4123
|
+
latticePlan(mesh: MeshHandle, options: LatticeOptions): LatticePlan;
|
|
4124
|
+
/**
|
|
4125
|
+
* Fills the inside of the closed, outward-wound `mesh`, or the cavity of a
|
|
4126
|
+
* hollowed one, with a lattice: walls of uniform thickness that follow a
|
|
4127
|
+
* gyroid, Schwarz P or diamond surface. One undo step.
|
|
4128
|
+
*
|
|
4129
|
+
* - Without a shell, filling the inside turns the mesh into an open
|
|
4130
|
+
* lattice, cut off at its surface.
|
|
4131
|
+
* - With `shellThickness`, the mesh's surface is kept as it is, and the
|
|
4132
|
+
* space between the walls is carved out from that depth on, so shell and
|
|
4133
|
+
* walls are one solid.
|
|
4134
|
+
* - In a cavity, the walls grow out of the shell that is there, whose outer
|
|
4135
|
+
* surface is kept as it is.
|
|
4136
|
+
*
|
|
4137
|
+
* The result is closed, manifold and free of self-intersections, as far as
|
|
4138
|
+
* the surface that is kept is. It is built on a voxel grid that follows
|
|
4139
|
+
* from the lengths, or from `voxelSize`: edges where walls meet the mesh's
|
|
4140
|
+
* surface are cut by a fraction of a voxel. {@link Scene.latticePlan}
|
|
4141
|
+
* reports the grid, the triangles and the memory beforehand, and
|
|
4142
|
+
* {@link Scene.latticePreview} shows the walls on a small grid.
|
|
4143
|
+
*
|
|
4144
|
+
* Lengths and volumes are measured in the world. The cells are aligned with
|
|
4145
|
+
* the mesh's own axes, around the middle of its bounds. Its UVs are
|
|
4146
|
+
* dropped. A lattice has many triangles (about 2,000 per gyroid cell at ten
|
|
4147
|
+
* voxels a cell, 12,000 at 25) and takes seconds at a few million: use
|
|
4148
|
+
* `WorkerScene.latticeFill` to keep the page live.
|
|
4149
|
+
*
|
|
4150
|
+
* @throws {FastMeshError} `INVALID_ARGUMENT` for bad options, a mesh that is
|
|
4151
|
+
* not closed and consistently wound outward, `region: "cavity"` without
|
|
4152
|
+
* a cavity, a grid over `maxVoxels` (the message has its size and
|
|
4153
|
+
* memory) or too coarse for the walls, the shell, the cells or the wall
|
|
4154
|
+
* around a cavity, or a lattice that leaves nothing, or nothing open;
|
|
4155
|
+
* `UNKNOWN_MESH` for a removed mesh; `OUT_OF_MEMORY`. The mesh is
|
|
4156
|
+
* unchanged on error.
|
|
4157
|
+
*/
|
|
4158
|
+
latticeFill(mesh: MeshHandle, options: LatticeOptions): LatticeReport;
|
|
4159
|
+
/**
|
|
4160
|
+
* The walls {@link Scene.latticeFill} would put into `mesh`, on a small
|
|
4161
|
+
* grid, without changing the mesh: buffers in its local frame, to draw at
|
|
4162
|
+
* its `matrix4`. The grid has at most `maxVoxels` voxels (default
|
|
4163
|
+
* {@link DEFAULT_LATTICE_PREVIEW_VOXELS}); walls it is too coarse for are
|
|
4164
|
+
* drawn two voxels thick (`plan.wallThickness`), and a part with too many
|
|
4165
|
+
* cells for it shows its middle only (`plan.cropped`). With a shell the
|
|
4166
|
+
* walls start at its inner face.
|
|
4167
|
+
*
|
|
4168
|
+
* @throws {FastMeshError} as {@link Scene.latticeFill}, except that the grid
|
|
4169
|
+
* always fits and that a lattice without walls is an empty preview.
|
|
4170
|
+
*/
|
|
4171
|
+
latticePreview(mesh: MeshHandle, options: LatticeOptions): LatticePreview;
|
|
4172
|
+
/**
|
|
4173
|
+
* Punches a tapered/chamfered drain hole in `mesh` (with optional plug
|
|
4174
|
+
* generation) in one undo step: {@link Scene.undo} fills the hole again and
|
|
4175
|
+
* removes the plug, which {@link Scene.redo} brings back with the same
|
|
4176
|
+
* handle.
|
|
4177
|
+
*/
|
|
4178
|
+
punchDrainHole(mesh: MeshHandle, options: DrainHoleOptions): DrainHoleReport;
|
|
4179
|
+
/**
|
|
4180
|
+
* Places `stamp` onto `target` at a hit point/normal, optionally unioning/engraving/conformance-wrapping,
|
|
4181
|
+
* in one undo step. Kept separate, the placed stamp is a new mesh with the hit point as its
|
|
4182
|
+
* {@link Scene.origin}, which {@link Scene.undo} removes and {@link Scene.redo} brings back with
|
|
4183
|
+
* the same handle.
|
|
4184
|
+
*
|
|
4185
|
+
* The zero of the stamp's own coordinates goes to the hit point, or `options.stampAnchor`, which
|
|
4186
|
+
* says what happens with a stamp far from that zero. A `stampAnchor` far from the stamp puts it
|
|
4187
|
+
* as far from the hit point: kept separate (and not conforming) it is placed as precisely there,
|
|
4188
|
+
* around an origin of its own; merged into a target it has the precision of that mesh's `f32`
|
|
4189
|
+
* positions at that distance.
|
|
4190
|
+
*/
|
|
4191
|
+
placeMesh(target: MeshHandle, stamp: MeshHandle, options: PlaceMeshOptions): PlaceMeshReport;
|
|
4192
|
+
}
|
|
4193
|
+
/** Return type parameterized over synchronous (`Scene`) vs worker (`WorkerScene`) hosts. */
|
|
4194
|
+
type AlignReturn<Async extends boolean, T> = Async extends true ? Promise<T> : T;
|
|
4195
|
+
/** Low-level host backend used by {@link createAlignDomain}. */
|
|
4196
|
+
interface AlignBackend<Async extends boolean = false> {
|
|
4197
|
+
register(moving: MeshHandle, fixed: MeshHandle, options?: RegisterOptions): AlignReturn<Async, RegisterResult>;
|
|
4198
|
+
alignByLandmarks(moving: MeshHandle, fixed: MeshHandle, pairs: readonly LandmarkPair[], allowScaling?: boolean): AlignReturn<Async, LandmarkAlignment>;
|
|
4199
|
+
registerMultistage(moving: MeshHandle, fixed: MeshHandle, options?: RegistrationOptions): AlignReturn<Async, RegistrationReport>;
|
|
4200
|
+
detectSymmetryPlane(mesh: MeshHandle): AlignReturn<Async, SymmetryPlaneReport>;
|
|
4201
|
+
}
|
|
4202
|
+
/** Rigid registration, multi-stage alignment, landmark SVD, and symmetry-plane domain (`scene.align.*`). */
|
|
4203
|
+
interface AlignDomain<Async extends boolean = false> {
|
|
4204
|
+
register(moving: MeshHandle, fixed: MeshHandle, options?: RegisterOptions): AlignReturn<Async, RegisterResult>;
|
|
4205
|
+
alignByLandmarks(moving: MeshHandle, fixed: MeshHandle, pairs: readonly LandmarkPair[], allowScaling?: boolean): AlignReturn<Async, LandmarkAlignment>;
|
|
4206
|
+
registerMultistage(moving: MeshHandle, fixed: MeshHandle, options?: RegistrationOptions): AlignReturn<Async, RegistrationReport>;
|
|
4207
|
+
detectSymmetryPlane(mesh: MeshHandle): AlignReturn<Async, SymmetryPlaneReport>;
|
|
4208
|
+
detectSymmetry(mesh: MeshHandle): AlignReturn<Async, SymmetryPlaneReport>;
|
|
4209
|
+
}
|
|
4210
|
+
/** Synchronous alignment domain exposed by `Scene.align`. */
|
|
4211
|
+
type SyncAlignDomain = AlignDomain<false>;
|
|
4212
|
+
/** Asynchronous alignment domain exposed by `WorkerScene.align`. */
|
|
4213
|
+
type WorkerAlignDomain = AlignDomain<true>;
|
|
4214
|
+
/** Builds an {@link AlignDomain} backed by `backend`. */
|
|
4215
|
+
declare function createAlignDomain<Async extends boolean>(backend: AlignBackend<Async>): AlignDomain<Async>;
|
|
4216
|
+
/** Return type parameterized over synchronous (`Scene`) vs worker (`WorkerScene`) hosts. */
|
|
4217
|
+
type BooleanReturn<Async extends boolean, T> = Async extends true ? Promise<T> : T;
|
|
4218
|
+
/** Options for {@link BooleanDomain.offset}. */
|
|
4219
|
+
type OffsetOptions = Omit<Extract<RepairOp, {
|
|
4220
|
+
op: "offset";
|
|
4221
|
+
}>, "op">;
|
|
4222
|
+
/** Options for {@link BooleanDomain.shell}. */
|
|
4223
|
+
type ShellOptions = Omit<Extract<RepairOp, {
|
|
4224
|
+
op: "shell";
|
|
4225
|
+
}>, "op">;
|
|
4226
|
+
/** Low-level host backend used by {@link createBooleanDomain}. */
|
|
4227
|
+
interface BooleanBackend<Async extends boolean = false> {
|
|
4228
|
+
readonly isAsync: Async;
|
|
4229
|
+
repair<const O extends RepairOp>(mesh: MeshHandle, op: O): BooleanReturn<Async, RepairReportOf<O>>;
|
|
4230
|
+
boolean?: (target: MeshHandle, source: MeshHandle, op: BooleanOp, options?: Omit<BooleanOptions, "op">) => BooleanReturn<Async, MeshHandle>;
|
|
4231
|
+
booleanBatch?: (meshesOrTree: readonly MeshHandle[] | CsgNode, treeOrOptions?: CsgNode | BooleanOptions, maybeOptions?: BooleanOptions) => BooleanReturn<Async, MeshHandle>;
|
|
4232
|
+
cutByPlane?: (mesh: MeshHandle, plane: SectionPlane, options?: CutOptions) => BooleanReturn<Async, CutReport>;
|
|
4233
|
+
trimByCurve?: (mesh: MeshHandle, optionsOrCurve: TrimCurveOptions | readonly (Readonly<Vec3> | SurfacePathPoint)[], maybeOptions?: Omit<TrimCurveOptions, "points">) => BooleanReturn<Async, TrimReport>;
|
|
4234
|
+
hollowMesh(mesh: MeshHandle, options: HollowOptions): BooleanReturn<Async, HollowReport>;
|
|
4235
|
+
punchDrainHole(mesh: MeshHandle, options: DrainHoleOptions): BooleanReturn<Async, DrainHoleReport>;
|
|
4236
|
+
placeMesh(target: MeshHandle, stamp: MeshHandle, options: PlaceMeshOptions): BooleanReturn<Async, PlaceMeshReport>;
|
|
4237
|
+
}
|
|
4238
|
+
/**
|
|
4239
|
+
* Callable boolean, cutting, offsetting, and shell solidification domain
|
|
4240
|
+
* (`scene.boolean(...)` and `scene.boolean.<method>(...)`).
|
|
4241
|
+
*/
|
|
4242
|
+
interface BooleanDomain<Async extends boolean = false> {
|
|
4243
|
+
(target: MeshHandle, source: MeshHandle, op: BooleanOp, options?: Omit<BooleanOptions, "op">): BooleanReturn<Async, MeshHandle>;
|
|
4244
|
+
union(target: MeshHandle, source: MeshHandle, options?: Omit<BooleanOptions, "op">): BooleanReturn<Async, MeshHandle>;
|
|
4245
|
+
difference(target: MeshHandle, source: MeshHandle, options?: Omit<BooleanOptions, "op">): BooleanReturn<Async, MeshHandle>;
|
|
4246
|
+
subtract(target: MeshHandle, source: MeshHandle, options?: Omit<BooleanOptions, "op">): BooleanReturn<Async, MeshHandle>;
|
|
4247
|
+
intersection(target: MeshHandle, source: MeshHandle, options?: Omit<BooleanOptions, "op">): BooleanReturn<Async, MeshHandle>;
|
|
4248
|
+
intersect(target: MeshHandle, source: MeshHandle, options?: Omit<BooleanOptions, "op">): BooleanReturn<Async, MeshHandle>;
|
|
4249
|
+
batch(meshes: readonly MeshHandle[], tree: CsgNode, options?: BooleanOptions): BooleanReturn<Async, MeshHandle>;
|
|
4250
|
+
batch(tree: CsgNode, options?: BooleanOptions): BooleanReturn<Async, MeshHandle>;
|
|
4251
|
+
booleanBatch(meshes: readonly MeshHandle[], tree: CsgNode, options?: BooleanOptions): BooleanReturn<Async, MeshHandle>;
|
|
4252
|
+
booleanBatch(tree: CsgNode, options?: BooleanOptions): BooleanReturn<Async, MeshHandle>;
|
|
4253
|
+
cut(mesh: MeshHandle, plane: SectionPlane, options?: CutOptions): BooleanReturn<Async, CutReport>;
|
|
4254
|
+
cutByPlane(mesh: MeshHandle, plane: SectionPlane, options?: CutOptions): BooleanReturn<Async, CutReport>;
|
|
4255
|
+
/**
|
|
4256
|
+
* Imprints a world-space polyline onto `mesh` and, with `closed: true`,
|
|
4257
|
+
* deletes one side of the loop from the component it lies on: see
|
|
4258
|
+
* `Scene.trimByCurve`.
|
|
4259
|
+
*/
|
|
4260
|
+
trimByCurve(mesh: MeshHandle, options: TrimCurveOptions): BooleanReturn<Async, TrimReport>;
|
|
4261
|
+
trimByCurve(mesh: MeshHandle, curve: readonly (Readonly<Vec3> | SurfacePathPoint)[], options?: Omit<TrimCurveOptions, "points">): BooleanReturn<Async, TrimReport>;
|
|
4262
|
+
offset(mesh: MeshHandle, options: OffsetOptions): BooleanReturn<Async, OffsetReport>;
|
|
4263
|
+
shell(mesh: MeshHandle, thickness: number | ShellOptions): BooleanReturn<Async, ShellReport>;
|
|
4264
|
+
hollowMesh(mesh: MeshHandle, options: HollowOptions): BooleanReturn<Async, HollowReport>;
|
|
4265
|
+
punchDrainHole(mesh: MeshHandle, options: DrainHoleOptions): BooleanReturn<Async, DrainHoleReport>;
|
|
4266
|
+
placeMesh(target: MeshHandle, stamp: MeshHandle, options: PlaceMeshOptions): BooleanReturn<Async, PlaceMeshReport>;
|
|
4267
|
+
}
|
|
4268
|
+
/** Synchronous boolean domain exposed by `Scene.boolean`. */
|
|
4269
|
+
type SyncBooleanDomain = BooleanDomain<false>;
|
|
4270
|
+
/** Asynchronous boolean domain exposed by `WorkerScene.boolean`. */
|
|
4271
|
+
type WorkerBooleanDomain = BooleanDomain<true>;
|
|
4272
|
+
/** Builds a callable {@link BooleanDomain} backed by `backend`. */
|
|
4273
|
+
declare function createBooleanDomain<Async extends boolean>(backend: BooleanBackend<Async>): BooleanDomain<Async>;
|
|
4274
|
+
/** Return type parameterized over synchronous (`Scene`) vs worker (`WorkerScene`) hosts. */
|
|
4275
|
+
type SculptReturn<Async extends boolean, T> = Async extends true ? Promise<T> : T;
|
|
4276
|
+
type InflateOp = Omit<Extract<SculptOp, {
|
|
4277
|
+
op: "inflate";
|
|
4278
|
+
}>, "op">;
|
|
4279
|
+
type SmoothOp = Omit<Extract<SculptOp, {
|
|
4280
|
+
op: "smooth";
|
|
4281
|
+
}>, "op">;
|
|
4282
|
+
type RelaxOp = Omit<Extract<SculptOp, {
|
|
4283
|
+
op: "relax";
|
|
4284
|
+
}>, "op">;
|
|
4285
|
+
type GrabOp = Omit<Extract<SculptOp, {
|
|
4286
|
+
op: "grab";
|
|
4287
|
+
}>, "op">;
|
|
4288
|
+
type FlattenOp = Omit<Extract<SculptOp, {
|
|
4289
|
+
op: "flatten";
|
|
4290
|
+
}>, "op">;
|
|
4291
|
+
type CreaseOp = Omit<Extract<SculptOp, {
|
|
4292
|
+
op: "crease";
|
|
4293
|
+
}>, "op">;
|
|
4294
|
+
type ClayOp = Omit<Extract<SculptOp, {
|
|
4295
|
+
op: "clay";
|
|
4296
|
+
}>, "op">;
|
|
4297
|
+
type TwistOp = Omit<Extract<SculptOp, {
|
|
4298
|
+
op: "twist";
|
|
4299
|
+
}>, "op">;
|
|
4300
|
+
type CaptureStrokeOptions = Omit<Extract<SculptOp, {
|
|
4301
|
+
op: "captureStrokeState";
|
|
4302
|
+
}>, "op">;
|
|
4303
|
+
type CaptureRestOptions = Omit<Extract<SculptOp, {
|
|
4304
|
+
op: "captureRestSizes";
|
|
4305
|
+
}>, "op">;
|
|
4306
|
+
type SplitStretchedOptions = Omit<Extract<SculptOp, {
|
|
4307
|
+
op: "splitStretched";
|
|
4308
|
+
}>, "op">;
|
|
4309
|
+
/** Options for {@link SculptDomain.beginStroke}. */
|
|
4310
|
+
interface BeginStrokeOptions {
|
|
4311
|
+
/** Keep an already active stroke snapshot on the mesh (`false` by default). */
|
|
4312
|
+
onlyIfMissing?: boolean;
|
|
4313
|
+
/** Also capture per-vertex rest edge sizes for dynamic `splitStretched`. */
|
|
4314
|
+
captureRestSizes?: boolean;
|
|
4315
|
+
/** Wrap stroke dabs inside a single history step when supported (`true` by default). */
|
|
4316
|
+
groupStep?: boolean;
|
|
4317
|
+
}
|
|
4318
|
+
/** Sculpt operations that support composable per-vertex surface filters. */
|
|
4319
|
+
type FilteredSculptOp = Extract<SculptOp, {
|
|
4320
|
+
filter?: SurfaceFilter;
|
|
4321
|
+
}>;
|
|
4322
|
+
/** Options for {@link SculptDomain.dab}. */
|
|
4323
|
+
interface SculptDabOptions {
|
|
4324
|
+
/** Override or disable (`null`) dynamic topology for this dab. */
|
|
4325
|
+
dyntopo?: DyntopoOptions | null;
|
|
4326
|
+
}
|
|
4327
|
+
/** Low-level host backend used by {@link createSculptDomain}. */
|
|
4328
|
+
interface SculptBackend<Async extends boolean = false> {
|
|
4329
|
+
sculpt<const O extends SculptOp>(mesh: MeshHandle, op: O): SculptReturn<Async, SculptReportOf<O>>;
|
|
4330
|
+
sculpt<const O extends readonly SculptOp[]>(mesh: MeshHandle, ops: O): SculptReturn<Async, { -readonly [K in keyof O]: SculptReportOf<O[K]>; }>;
|
|
4331
|
+
verticesInSphere(mesh: MeshHandle, center: Readonly<Vec3>, radius: number): SculptReturn<Async, Uint32Array>;
|
|
4332
|
+
beginStep?: () => void;
|
|
4333
|
+
endStep?: () => void;
|
|
4334
|
+
cancelStep?: () => void;
|
|
4335
|
+
applyDyntopo(mesh: MeshHandle, center: Readonly<Vec3>, radius: number, options?: DyntopoOptions, pinned?: Indices): SculptReturn<Async, DyntopoReport>;
|
|
4336
|
+
dyntopoDab(mesh: MeshHandle, dab: SculptBrushOp, options?: DyntopoOptions, protection?: VertexProtection): SculptReturn<Async, DyntopoDabReport>;
|
|
4337
|
+
}
|
|
4338
|
+
/**
|
|
4339
|
+
* Callable sculpt domain namespace (`scene.sculpt(...)` and `scene.sculpt.<method>(...)`).
|
|
4340
|
+
*
|
|
4341
|
+
* Preserves legacy `sculpt(mesh, op | ops)` call signatures while exposing
|
|
4342
|
+
* stroke lifecycle, surface filter helpers, brush shorthands, and dynamic
|
|
4343
|
+
* topology subdivision.
|
|
4344
|
+
*/
|
|
4345
|
+
interface SculptDomain<Async extends boolean = false> {
|
|
4346
|
+
<const O extends SculptOp>(mesh: MeshHandle, op: O): SculptReturn<Async, SculptReportOf<O>>;
|
|
4347
|
+
<const O extends readonly SculptOp[]>(mesh: MeshHandle, ops: O): SculptReturn<Async, { -readonly [K in keyof O]: SculptReportOf<O[K]>; }>;
|
|
4348
|
+
beginStroke(mesh: MeshHandle, options?: BeginStrokeOptions): SculptReturn<Async, CaptureStrokeReport>;
|
|
4349
|
+
dab<const O extends SculptOp>(mesh: MeshHandle, op: O, options?: SculptDabOptions): SculptReturn<Async, SculptReportOf<O>>;
|
|
4350
|
+
dab<const O extends readonly SculptOp[]>(mesh: MeshHandle, ops: O, options?: SculptDabOptions): SculptReturn<Async, { -readonly [K in keyof O]: SculptReportOf<O[K]>; }>;
|
|
4351
|
+
endStroke(): void;
|
|
4352
|
+
cancelStroke(): void;
|
|
4353
|
+
setDyntopo(options: DyntopoOptions | null): void;
|
|
4354
|
+
getDyntopo(): DyntopoOptions | null;
|
|
4355
|
+
applyDyntopo(mesh: MeshHandle, center: Readonly<Vec3>, radius: number, options?: DyntopoOptions, pinned?: Indices): SculptReturn<Async, DyntopoReport>;
|
|
4356
|
+
dyntopoDab(mesh: MeshHandle, dab: SculptBrushOp, options?: DyntopoOptions, protection?: VertexProtection): SculptReturn<Async, DyntopoDabReport>;
|
|
4357
|
+
filter<T extends FilteredSculptOp>(op: T, surfaceFilter: SurfaceFilter): T & {
|
|
4358
|
+
filter: SurfaceFilter;
|
|
4359
|
+
};
|
|
4360
|
+
filter<const O extends FilteredSculptOp>(mesh: MeshHandle, op: O, surfaceFilter: SurfaceFilter): SculptReturn<Async, SculptReportOf<O>>;
|
|
4361
|
+
inflate(mesh: MeshHandle, op: InflateOp): SculptReturn<Async, InflateReport>;
|
|
4362
|
+
smooth(mesh: MeshHandle, op: SmoothOp): SculptReturn<Async, SmoothReport>;
|
|
4363
|
+
relax(mesh: MeshHandle, op: RelaxOp): SculptReturn<Async, RelaxReport>;
|
|
4364
|
+
grab(mesh: MeshHandle, op: GrabOp): SculptReturn<Async, GrabReport>;
|
|
4365
|
+
flatten(mesh: MeshHandle, op: FlattenOp): SculptReturn<Async, FlattenReport>;
|
|
4366
|
+
crease(mesh: MeshHandle, op: CreaseOp): SculptReturn<Async, CreaseReport>;
|
|
4367
|
+
clay(mesh: MeshHandle, op: ClayOp): SculptReturn<Async, ClayReport>;
|
|
4368
|
+
twist(mesh: MeshHandle, op: TwistOp): SculptReturn<Async, TwistReport>;
|
|
4369
|
+
captureStrokeState(mesh: MeshHandle, options?: CaptureStrokeOptions): SculptReturn<Async, CaptureStrokeReport>;
|
|
4370
|
+
captureRestSizes(mesh: MeshHandle, options?: CaptureRestOptions): SculptReturn<Async, CaptureRestReport>;
|
|
4371
|
+
splitStretched(mesh: MeshHandle, op: SplitStretchedOptions): SculptReturn<Async, StretchReport>;
|
|
4372
|
+
verticesInSphere(mesh: MeshHandle, center: Readonly<Vec3>, radius: number): SculptReturn<Async, Uint32Array>;
|
|
4373
|
+
}
|
|
4374
|
+
/** Synchronous sculpt domain exposed by `Scene.sculpt`. */
|
|
4375
|
+
type SyncSculptDomain = SculptDomain<false>;
|
|
4376
|
+
/** Asynchronous sculpt domain exposed by `WorkerScene.sculpt`. */
|
|
4377
|
+
type WorkerSculptDomain = SculptDomain<true>;
|
|
4378
|
+
/** Builds a callable {@link SculptDomain} backed by `backend`. */
|
|
4379
|
+
declare function createSculptDomain<Async extends boolean>(backend: SculptBackend<Async>): SculptDomain<Async>;
|
|
4380
|
+
/** Return type parameterized over synchronous (`Scene`) vs worker (`WorkerScene`) hosts. */
|
|
4381
|
+
type DeformReturn<Async extends boolean, T> = Async extends true ? Promise<T> : T;
|
|
4382
|
+
/** Deformation operations supporting per-vertex protection weights and geodesic falloff bands. */
|
|
4383
|
+
type ProtectedSculptOp = Extract<SculptOp, {
|
|
4384
|
+
protect?: VertexProtection;
|
|
4385
|
+
}>;
|
|
4386
|
+
/** Low-level host backend used by {@link createDeformDomain}. */
|
|
4387
|
+
interface DeformBackend<Async extends boolean = false> {
|
|
4388
|
+
sculpt<const O extends SculptOp>(mesh: MeshHandle, op: O): DeformReturn<Async, SculptReportOf<O>>;
|
|
4389
|
+
buildFfdLattice(mesh: MeshHandle, dims: readonly [number, number, number], basis?: FfdBasisInput, padding?: number): DeformReturn<Async, FfdLatticeData>;
|
|
4390
|
+
applyFfd(mesh: MeshHandle, options: FfdOptions): DeformReturn<Async, FreeformReport>;
|
|
4391
|
+
applyArap(mesh: MeshHandle, options: ArapOptions): DeformReturn<Async, FreeformReport>;
|
|
4392
|
+
applyKelvinlet(mesh: MeshHandle, options: KelvinletOptions): DeformReturn<Async, FreeformReport>;
|
|
4393
|
+
applyXpbd(mesh: MeshHandle, options: XpbdOptions): DeformReturn<Async, FreeformReport>;
|
|
4394
|
+
}
|
|
4395
|
+
/** Surface deformation and vertex-protection domain. */
|
|
4396
|
+
interface DeformDomain<Async extends boolean = false> {
|
|
4397
|
+
inflate(mesh: MeshHandle, op: InflateOp): DeformReturn<Async, InflateReport>;
|
|
4398
|
+
smooth(mesh: MeshHandle, op: SmoothOp): DeformReturn<Async, SmoothReport>;
|
|
4399
|
+
relax(mesh: MeshHandle, op: RelaxOp): DeformReturn<Async, RelaxReport>;
|
|
4400
|
+
relaxed(mesh: MeshHandle, op: RelaxOp): DeformReturn<Async, RelaxReport>;
|
|
4401
|
+
grab(mesh: MeshHandle, op: GrabOp): DeformReturn<Async, GrabReport>;
|
|
4402
|
+
flatten(mesh: MeshHandle, op: FlattenOp): DeformReturn<Async, FlattenReport>;
|
|
4403
|
+
crease(mesh: MeshHandle, op: CreaseOp): DeformReturn<Async, CreaseReport>;
|
|
4404
|
+
clay(mesh: MeshHandle, op: ClayOp): DeformReturn<Async, ClayReport>;
|
|
4405
|
+
twist(mesh: MeshHandle, op: TwistOp): DeformReturn<Async, TwistReport>;
|
|
4406
|
+
protect<T extends ProtectedSculptOp>(op: T, protection: VertexProtection): T & {
|
|
4407
|
+
protect: VertexProtection;
|
|
4408
|
+
};
|
|
4409
|
+
protect<const O extends ProtectedSculptOp>(mesh: MeshHandle, op: O, protection: VertexProtection): DeformReturn<Async, SculptReportOf<O>>;
|
|
4410
|
+
buildFfdLattice(mesh: MeshHandle, dims: readonly [number, number, number], basis?: FfdBasisInput, padding?: number): DeformReturn<Async, FfdLatticeData>;
|
|
4411
|
+
applyFfd(mesh: MeshHandle, options: FfdOptions): DeformReturn<Async, FreeformReport>;
|
|
4412
|
+
applyArap(mesh: MeshHandle, options: ArapOptions): DeformReturn<Async, FreeformReport>;
|
|
4413
|
+
applyKelvinlet(mesh: MeshHandle, options: KelvinletOptions): DeformReturn<Async, FreeformReport>;
|
|
4414
|
+
applyXpbd(mesh: MeshHandle, options: XpbdOptions): DeformReturn<Async, FreeformReport>;
|
|
4415
|
+
}
|
|
4416
|
+
/** Synchronous deformation domain exposed by `Scene.deform`. */
|
|
4417
|
+
type SyncDeformDomain = DeformDomain<false>;
|
|
4418
|
+
/** Asynchronous deformation domain exposed by `WorkerScene.deform`. */
|
|
4419
|
+
type WorkerDeformDomain = DeformDomain<true>;
|
|
4420
|
+
/** Builds a {@link DeformDomain} backed by `backend`. */
|
|
4421
|
+
declare function createDeformDomain<Async extends boolean>(backend: DeformBackend<Async>): DeformDomain<Async>;
|
|
4422
|
+
/** Return type parameterized over synchronous (`Scene`) vs worker (`WorkerScene`) hosts. */
|
|
4423
|
+
type InspectReturn<Async extends boolean, T> = Async extends true ? Promise<T> : T;
|
|
4424
|
+
/** Low-level host backend used by {@link createInspectDomain}. */
|
|
4425
|
+
interface InspectBackend<Async extends boolean = false> {
|
|
4426
|
+
analyze(mesh: MeshHandle, options?: AnalyzeOptions): InspectReturn<Async, Analysis>;
|
|
4427
|
+
measure(mesh: MeshHandle): InspectReturn<Async, MeasureResult>;
|
|
4428
|
+
bounds(mesh: MeshHandle): Bounds | null;
|
|
4429
|
+
raycast(origin: Readonly<Vec3>, direction: Readonly<Vec3>, options?: RaycastOptions): InspectReturn<Async, RayHit | null>;
|
|
4430
|
+
closestPoint(point: Readonly<Vec3>, options?: ClosestPointOptions): InspectReturn<Async, ClosestHit | null>;
|
|
4431
|
+
meshDistance(a: MeshHandle, b: MeshHandle, options?: {
|
|
4432
|
+
maxDistance?: number;
|
|
4433
|
+
}): InspectReturn<Async, MeshDistance | null>;
|
|
4434
|
+
intersects(a: MeshHandle, b: MeshHandle): InspectReturn<Async, boolean>;
|
|
4435
|
+
selfIntersectingTriangles(mesh: MeshHandle): InspectReturn<Async, Uint32Array>;
|
|
4436
|
+
findContacts(options?: FindContactsOptions): InspectReturn<Async, Contact[]>;
|
|
4437
|
+
overhangs(mesh: MeshHandle, options?: OverhangOptions): InspectReturn<Async, OverhangReport>;
|
|
4438
|
+
triangleQuality(mesh: MeshHandle, metricOrOptions?: QualityMetric | TriangleQualityOptions, sliverThreshold?: number): InspectReturn<Async, QualityReport>;
|
|
4439
|
+
meshDeviation(source: MeshHandle, target: MeshHandle, options?: DeviationOptions): InspectReturn<Async, DeviationStats>;
|
|
4440
|
+
geodesicDistances(mesh: MeshHandle, sources: number | readonly number[], options?: GeodesicOptions): InspectReturn<Async, Float32Array>;
|
|
4441
|
+
shortestSurfacePath(mesh: MeshHandle, sources: number | readonly number[], targetVertex: number, options?: SurfacePathOptions): InspectReturn<Async, SurfacePathPoint[]>;
|
|
4442
|
+
releaseGeodesics?: () => InspectReturn<Async, void>;
|
|
4443
|
+
addDistanceField(desc: DistanceFieldDesc): FieldHandle;
|
|
4444
|
+
addThicknessField?: (desc: ThicknessFieldDesc) => FieldHandle;
|
|
4445
|
+
addCurvatureField?: (desc: CurvatureFieldDesc) => FieldHandle;
|
|
4446
|
+
removeField(field: FieldHandle): void;
|
|
4447
|
+
fieldValues(field: FieldHandle): InspectReturn<Async, Float32Array>;
|
|
4448
|
+
fieldNearest(field: FieldHandle): InspectReturn<Async, Uint32Array>;
|
|
4449
|
+
fieldStatus(field: FieldHandle): InspectReturn<Async, FieldStatus>;
|
|
4450
|
+
fieldTargetStatus(field: FieldHandle): InspectReturn<Async, FieldStatus["sign"][]>;
|
|
4451
|
+
setColoring(mesh: MeshHandle, rule: ColorRule | null): void;
|
|
4452
|
+
coloring(mesh: MeshHandle): ColorRule | null;
|
|
4453
|
+
addSection(desc: SectionDesc): SectionHandle;
|
|
4454
|
+
setSectionPlane(section: SectionHandle, plane: SectionPlane): void;
|
|
4455
|
+
sectionPlane(section: SectionHandle): SectionPlane;
|
|
4456
|
+
setSectionMeshes(section: SectionHandle, meshes: readonly MeshHandle[]): void;
|
|
4457
|
+
setSectionFill(section: SectionHandle, fill: boolean): void;
|
|
4458
|
+
removeSection(section: SectionHandle): void;
|
|
4459
|
+
section(section: SectionHandle, mesh: MeshHandle): SectionResult;
|
|
4460
|
+
sectionGap(section: SectionHandle, a: MeshHandle, b: MeshHandle): InspectReturn<Async, SectionGap | null>;
|
|
4461
|
+
updateSections?: () => void;
|
|
4462
|
+
fitPrimitive(mesh: MeshHandle, options?: FitPrimitiveOptions): InspectReturn<Async, FittedPrimitiveReport>;
|
|
4463
|
+
alignToFittedPrimitive(mesh: MeshHandle, primitive: FittedPrimitive, targetAxis: Readonly<Vec3>, targetOrigin: Readonly<Vec3>): InspectReturn<Async, Placement>;
|
|
4464
|
+
sliceContours(mesh: MeshHandle, origin: Readonly<Vec3>, normal: Readonly<Vec3>): InspectReturn<Async, ContourSlice>;
|
|
4465
|
+
sliceContourStack(mesh: MeshHandle, origin: Readonly<Vec3>, normal: Readonly<Vec3>, spacing: number, count: number): InspectReturn<Async, ContourSlice[]>;
|
|
4466
|
+
reconstructPointCloud(cloud: PackedPointCloud | Float32Array, options?: SurfaceReconstructOptions): InspectReturn<Async, MeshHandle>;
|
|
4467
|
+
}
|
|
4468
|
+
/** Metrology, defect analysis, raycasting, printability/quality/geodesic fields, surface paths, and cross-section inspection domain. */
|
|
4469
|
+
interface InspectDomain<Async extends boolean = false> {
|
|
4470
|
+
analyze(mesh: MeshHandle, options?: AnalyzeOptions): InspectReturn<Async, Analysis>;
|
|
4471
|
+
measure(mesh: MeshHandle): InspectReturn<Async, MeasureResult>;
|
|
4472
|
+
bounds(mesh: MeshHandle): Bounds | null;
|
|
4473
|
+
raycast(origin: Readonly<Vec3>, direction: Readonly<Vec3>, options?: RaycastOptions): InspectReturn<Async, RayHit | null>;
|
|
4474
|
+
closestPoint(point: Readonly<Vec3>, options?: ClosestPointOptions): InspectReturn<Async, ClosestHit | null>;
|
|
4475
|
+
meshDistance(a: MeshHandle, b: MeshHandle, options?: {
|
|
4476
|
+
maxDistance?: number;
|
|
4477
|
+
}): InspectReturn<Async, MeshDistance | null>;
|
|
4478
|
+
intersects(a: MeshHandle, b: MeshHandle): InspectReturn<Async, boolean>;
|
|
4479
|
+
/**
|
|
4480
|
+
* The live triangle slots of `mesh` that intersect or touch another of its
|
|
4481
|
+
* own triangles, ascending, each once. Triangles sharing a vertex are never
|
|
4482
|
+
* tested against each other and degenerate triangles are skipped. The
|
|
4483
|
+
* mesh's BVH is brought up to date first; a stale `"manual"` mesh throws
|
|
4484
|
+
* `STALE_BVH`.
|
|
4485
|
+
*/
|
|
4486
|
+
selfIntersectingTriangles(mesh: MeshHandle): InspectReturn<Async, Uint32Array>;
|
|
4487
|
+
findContacts(options?: FindContactsOptions): InspectReturn<Async, Contact[]>;
|
|
4488
|
+
overhangs(mesh: MeshHandle, options?: OverhangOptions): InspectReturn<Async, OverhangReport>;
|
|
4489
|
+
triangleQuality(mesh: MeshHandle, metricOrOptions?: QualityMetric | TriangleQualityOptions, sliverThreshold?: number): InspectReturn<Async, QualityReport>;
|
|
4490
|
+
meshDeviation(source: MeshHandle, target: MeshHandle, options?: DeviationOptions): InspectReturn<Async, DeviationStats>;
|
|
4491
|
+
/**
|
|
4492
|
+
* The distance along the surface from the nearest of the vertices
|
|
4493
|
+
* `sources` to every vertex slot, in world units: `Infinity` where no
|
|
4494
|
+
* source reaches, on unused slots and past `maxDistance`.
|
|
4495
|
+
*
|
|
4496
|
+
* `"dijkstra"` gives the length of the shortest way along the edges, which
|
|
4497
|
+
* is longer than the one over the faces, and much longer where triangles
|
|
4498
|
+
* are stretched. `"heatMethod"` gives the distance over the faces, whatever
|
|
4499
|
+
* the triangles are like (stretched, obtuse, fans, or of all sizes), off by
|
|
4500
|
+
* about 1 % on average. On the meshes it is tested with, against exact
|
|
4501
|
+
* distances, the mean error of the distances above a tenth of the largest
|
|
4502
|
+
* one is below 3 %, and no distance is off by more than 4 % of the largest
|
|
4503
|
+
* one. Distances of a few edge lengths are relatively further off, by up to
|
|
4504
|
+
* about the mean edge length.
|
|
4505
|
+
*
|
|
4506
|
+
* `"heatMethod"` first prepares operators of the mesh, about half the time
|
|
4507
|
+
* of a query, and more where the mesh has triangles such as these: the
|
|
4508
|
+
* surface is then cut into better ones, inside the operators only. They are
|
|
4509
|
+
* kept (about 130 bytes a triangle, up to about 190 with such triangles)
|
|
4510
|
+
* for later queries of the same mesh, until it changes, another mesh is
|
|
4511
|
+
* queried, or {@link InspectDomain.releaseGeodesics}. On a `WorkerScene` a
|
|
4512
|
+
* query runs in steps and can be cancelled (`options.signal`).
|
|
4513
|
+
*/
|
|
4514
|
+
geodesicDistances(mesh: MeshHandle, sources: number | readonly number[], options?: GeodesicOptions): InspectReturn<Async, Float32Array>;
|
|
4515
|
+
/**
|
|
4516
|
+
* Frees what `"heatMethod"` queries keep for the next one (see
|
|
4517
|
+
* {@link InspectDomain.geodesicDistances}).
|
|
4518
|
+
*/
|
|
4519
|
+
releaseGeodesics(): InspectReturn<Async, void>;
|
|
4520
|
+
shortestSurfacePath(mesh: MeshHandle, sources: number | readonly number[], targetVertex: number, options?: SurfacePathOptions): InspectReturn<Async, SurfacePathPoint[]>;
|
|
4521
|
+
findSurfacePath(mesh: MeshHandle, sources: number | readonly number[], targetVertex: number, options?: SurfacePathOptions): InspectReturn<Async, SurfacePathPoint[]>;
|
|
4522
|
+
addDistanceField(desc: DistanceFieldDesc): FieldHandle;
|
|
4523
|
+
addThicknessField(desc: ThicknessFieldDesc): FieldHandle;
|
|
4524
|
+
addCurvatureField(desc: CurvatureFieldDesc): FieldHandle;
|
|
4525
|
+
removeField(field: FieldHandle): void;
|
|
4526
|
+
fieldValues(field: FieldHandle): InspectReturn<Async, Float32Array>;
|
|
4527
|
+
fieldNearest(field: FieldHandle): InspectReturn<Async, Uint32Array>;
|
|
4528
|
+
fieldStatus(field: FieldHandle): InspectReturn<Async, FieldStatus>;
|
|
4529
|
+
fieldTargetStatus(field: FieldHandle): InspectReturn<Async, FieldStatus["sign"][]>;
|
|
4530
|
+
setColoring(mesh: MeshHandle, rule: ColorRule | null): void;
|
|
4531
|
+
coloring(mesh: MeshHandle): ColorRule | null;
|
|
4532
|
+
addSection(desc: SectionDesc): SectionHandle;
|
|
4533
|
+
setSectionPlane(section: SectionHandle, plane: SectionPlane): void;
|
|
4534
|
+
sectionPlane(section: SectionHandle): SectionPlane;
|
|
4535
|
+
setSectionMeshes(section: SectionHandle, meshes: readonly MeshHandle[]): void;
|
|
4536
|
+
setSectionFill(section: SectionHandle, fill: boolean): void;
|
|
4537
|
+
removeSection(section: SectionHandle): void;
|
|
4538
|
+
section(section: SectionHandle, mesh: MeshHandle): SectionResult;
|
|
4539
|
+
sectionGap(section: SectionHandle, a: MeshHandle, b: MeshHandle): InspectReturn<Async, SectionGap | null>;
|
|
4540
|
+
updateSections(): void;
|
|
4541
|
+
fitPrimitive(mesh: MeshHandle, options?: FitPrimitiveOptions): InspectReturn<Async, FittedPrimitiveReport>;
|
|
4542
|
+
alignToFittedPrimitive(mesh: MeshHandle, primitive: FittedPrimitive, targetAxis: Readonly<Vec3>, targetOrigin: Readonly<Vec3>): InspectReturn<Async, Placement>;
|
|
4543
|
+
sliceContours(mesh: MeshHandle, origin: Readonly<Vec3>, normal: Readonly<Vec3>): InspectReturn<Async, ContourSlice>;
|
|
4544
|
+
sliceContourStack(mesh: MeshHandle, origin: Readonly<Vec3>, normal: Readonly<Vec3>, spacing: number, count: number): InspectReturn<Async, ContourSlice[]>;
|
|
4545
|
+
reconstructPointCloud(cloud: PackedPointCloud | Float32Array, options?: SurfaceReconstructOptions): InspectReturn<Async, MeshHandle>;
|
|
4546
|
+
}
|
|
4547
|
+
/** Synchronous inspect domain exposed by `Scene.inspect`. */
|
|
4548
|
+
type SyncInspectDomain = InspectDomain<false>;
|
|
4549
|
+
/** Asynchronous inspect domain exposed by `WorkerScene.inspect`. */
|
|
4550
|
+
type WorkerInspectDomain = InspectDomain<true>;
|
|
4551
|
+
/** Builds an {@link InspectDomain} backed by `backend`. */
|
|
4552
|
+
declare function createInspectDomain<Async extends boolean>(backend: InspectBackend<Async>): InspectDomain<Async>;
|
|
4553
|
+
/** Return type parameterized over synchronous (`Scene`) vs worker (`WorkerScene`) hosts. */
|
|
4554
|
+
type RemeshReturn<Async extends boolean, T> = Async extends true ? Promise<T> : T;
|
|
4555
|
+
/** Options for {@link RemeshDomain.region} / {@link RemeshDomain.remesh}. */
|
|
4556
|
+
type RegionRemeshOptions = Omit<Extract<RepairOp, {
|
|
4557
|
+
op: "remesh";
|
|
4558
|
+
}>, "op">;
|
|
4559
|
+
/** Options for {@link RemeshDomain.surface}. */
|
|
4560
|
+
type SurfaceRemeshOptions = Omit<Extract<RepairOp, {
|
|
4561
|
+
op: "remeshSurface";
|
|
4562
|
+
}>, "op">;
|
|
4563
|
+
/** Options for {@link RemeshDomain.isotropic}. */
|
|
4564
|
+
type IsotropicRemeshOptions = Omit<SurfaceRemeshOptions, "mode">;
|
|
4565
|
+
/** Options for {@link RemeshDomain.adaptive}. */
|
|
4566
|
+
type AdaptiveRemeshOptions = Omit<SurfaceRemeshOptions, "mode">;
|
|
4567
|
+
/** Options for {@link RemeshDomain.simplify}. */
|
|
4568
|
+
type SimplifyOptions = Omit<Extract<RepairOp, {
|
|
4569
|
+
op: "simplify";
|
|
4570
|
+
}>, "op">;
|
|
4571
|
+
/** Options for {@link RemeshDomain.subdivide}. */
|
|
4572
|
+
type SubdivideOptions = Omit<Extract<RepairOp, {
|
|
4573
|
+
op: "subdivide";
|
|
4574
|
+
}>, "op">;
|
|
4575
|
+
/** Options for {@link RemeshDomain.voxel}. */
|
|
4576
|
+
interface VoxelRemeshOptions {
|
|
4577
|
+
/** Volumetric reconstruction backend (`"fhEdt"` by default). */
|
|
4578
|
+
algorithm?: Exclude<OffsetAlgorithm, "normal">;
|
|
4579
|
+
/** Grid voxel size in local mesh units (automatic when omitted). */
|
|
4580
|
+
voxelSize?: number;
|
|
4581
|
+
/** Maximum 3D grid voxel count (`>= 64`, defaults to `16_777_216`). */
|
|
4582
|
+
maxVoxels?: number;
|
|
4583
|
+
}
|
|
4584
|
+
/** Low-level host backend used by {@link createRemeshDomain}. */
|
|
4585
|
+
interface RemeshBackend<Async extends boolean = false> {
|
|
4586
|
+
repair<const O extends RepairOp>(mesh: MeshHandle, op: O): RemeshReturn<Async, RepairReportOf<O>>;
|
|
4587
|
+
}
|
|
4588
|
+
/** Remesh, simplification, subdivision, and volumetric reconstruction domain. */
|
|
4589
|
+
interface RemeshDomain<Async extends boolean = false> {
|
|
4590
|
+
remesh(mesh: MeshHandle, options: RegionRemeshOptions): RemeshReturn<Async, RemeshReport>;
|
|
4591
|
+
region(mesh: MeshHandle, options: RegionRemeshOptions): RemeshReturn<Async, RemeshReport>;
|
|
4592
|
+
surface(mesh: MeshHandle, options: SurfaceRemeshOptions): RemeshReturn<Async, SurfaceRemeshReport>;
|
|
4593
|
+
isotropic(mesh: MeshHandle, options: IsotropicRemeshOptions): RemeshReturn<Async, SurfaceRemeshReport>;
|
|
4594
|
+
adaptive(mesh: MeshHandle, options: AdaptiveRemeshOptions): RemeshReturn<Async, SurfaceRemeshReport>;
|
|
4595
|
+
simplify(mesh: MeshHandle, options: SimplifyOptions): RemeshReturn<Async, SimplifyReport>;
|
|
4596
|
+
subdivide(mesh: MeshHandle, options?: SubdivideOptions): RemeshReturn<Async, SubdivideReport>;
|
|
4597
|
+
voxel(mesh: MeshHandle, options?: VoxelRemeshOptions): RemeshReturn<Async, OffsetReport>;
|
|
4598
|
+
}
|
|
4599
|
+
/** Synchronous remesh domain exposed by `Scene.remesh`. */
|
|
4600
|
+
type SyncRemeshDomain = RemeshDomain<false>;
|
|
4601
|
+
/** Asynchronous remesh domain exposed by `WorkerScene.remesh`. */
|
|
4602
|
+
type WorkerRemeshDomain = RemeshDomain<true>;
|
|
4603
|
+
/** Builds a {@link RemeshDomain} backed by `backend`. */
|
|
4604
|
+
declare function createRemeshDomain<Async extends boolean>(backend: RemeshBackend<Async>): RemeshDomain<Async>;
|
|
4605
|
+
/** Return type parameterized over synchronous (`Scene`) vs worker (`WorkerScene`) hosts. */
|
|
4606
|
+
type RepairReturn<Async extends boolean, T> = Async extends true ? Promise<T> : T;
|
|
4607
|
+
/** Options for {@link RepairDomain.autoRepair} (`AutoRepairRequest` without `kind`). */
|
|
4608
|
+
type AutoRepairOptions = Omit<AutoRepairRequest, "kind">;
|
|
4609
|
+
/** Options for {@link RepairDomain.removeDegenerate}. */
|
|
4610
|
+
type DegenerateOptions = Omit<Extract<RepairOp, {
|
|
4611
|
+
op: "removeDegenerate";
|
|
4612
|
+
}>, "op">;
|
|
4613
|
+
/** Options for {@link RepairDomain.removeSmallComponents}. */
|
|
4614
|
+
type SmallComponentOptions = Omit<Extract<RepairOp, {
|
|
4615
|
+
op: "removeSmallComponents";
|
|
4616
|
+
}>, "op">;
|
|
4617
|
+
/** Options for {@link RepairDomain.fillHoles}. */
|
|
4618
|
+
type FillHolesOptions = Omit<Extract<RepairOp, {
|
|
4619
|
+
op: "fillHoles";
|
|
4620
|
+
}>, "op">;
|
|
4621
|
+
/** Options for {@link RepairDomain.bridge}. */
|
|
4622
|
+
type BridgeLoopsOptions = Omit<Extract<RepairOp, {
|
|
4623
|
+
op: "bridgeLoops";
|
|
4624
|
+
}>, "op">;
|
|
4625
|
+
/** Options for {@link RepairDomain.clean}. */
|
|
4626
|
+
interface CleanOptions {
|
|
4627
|
+
areaEpsilon?: number;
|
|
4628
|
+
removeUnusedVertices?: boolean;
|
|
4629
|
+
minTriangles?: number;
|
|
4630
|
+
minArea?: number;
|
|
4631
|
+
keepLargest?: boolean;
|
|
4632
|
+
keepCavities?: boolean;
|
|
4633
|
+
}
|
|
4634
|
+
/** Combined report returned by {@link RepairDomain.clean}. */
|
|
4635
|
+
interface CleanReport {
|
|
4636
|
+
degenerate: DegenerateReport;
|
|
4637
|
+
components: RemoveReport;
|
|
4638
|
+
}
|
|
4639
|
+
/** Low-level host backend used by {@link createRepairDomain}. */
|
|
4640
|
+
interface RepairBackend<Async extends boolean = false> {
|
|
4641
|
+
repair(mesh: MeshHandle, request: AutoRepairRequest): RepairReturn<Async, AutoRepairReport>;
|
|
4642
|
+
repair<const O extends RepairOp>(mesh: MeshHandle, op: O): RepairReturn<Async, RepairReportOf<O>>;
|
|
4643
|
+
repair<const O extends readonly RepairOp[]>(mesh: MeshHandle, ops: O): RepairReturn<Async, { -readonly [K in keyof O]: RepairReportOf<O[K]>; }>;
|
|
4644
|
+
analyze(mesh: MeshHandle, options?: AnalyzeOptions): RepairReturn<Async, Analysis>;
|
|
4645
|
+
join(target: MeshHandle, source: MeshHandle, options: JoinOptions): RepairReturn<Async, JoinReport>;
|
|
4646
|
+
fillHoleContinuity(mesh: MeshHandle, loopIndex: number, options?: FillHolesContinuityOptions): RepairReturn<Async, FillContinuityStats>;
|
|
4647
|
+
fillAllHolesContinuity(mesh: MeshHandle, options?: FillHolesContinuityOptions): RepairReturn<Async, FillContinuityStats>;
|
|
4648
|
+
bridgePartialArcs(mesh: MeshHandle, loopA: Indices, loopB: Indices, options?: PartialBridgeOptions): RepairReturn<Async, BridgeStats>;
|
|
4649
|
+
selectFacesScreen(mesh: MeshHandle, shape: ScreenSelectionShape, options: ScreenSelectOptions): RepairReturn<Async, Uint32Array>;
|
|
4650
|
+
selectFacesInSphere(mesh: MeshHandle, center: Readonly<Vec3>, radius: number, normalCone?: FaceSelectionNormalCone): RepairReturn<Async, Uint32Array>;
|
|
4651
|
+
selectByCreaseAngle(mesh: MeshHandle, seedTri: number, maxDihedralRad: number): RepairReturn<Async, Uint32Array>;
|
|
4652
|
+
selectConnectedShell(mesh: MeshHandle, seedTri: number): RepairReturn<Async, Uint32Array>;
|
|
4653
|
+
selectSmallFaceIslands(mesh: MeshHandle, maxFaceCount: number, maxArea?: number): RepairReturn<Async, Uint32Array>;
|
|
4654
|
+
growFaceSelection(mesh: MeshHandle, selectedTris: Indices, rings?: number, adjacency?: AdjacencyKind): RepairReturn<Async, Uint32Array>;
|
|
4655
|
+
shrinkFaceSelection(mesh: MeshHandle, selectedTris: Indices, rings?: number, adjacency?: AdjacencyKind): RepairReturn<Async, Uint32Array>;
|
|
4656
|
+
fillSelectionHoles(mesh: MeshHandle, selectedTris: Indices, maxHoleTris: number): RepairReturn<Async, Uint32Array>;
|
|
4657
|
+
smoothSelectionBoundary(mesh: MeshHandle, selectedTris: Indices, iterations?: number): RepairReturn<Async, Uint32Array>;
|
|
4658
|
+
faceSelectionToVertexMask(mesh: MeshHandle, selectedTris: Indices): RepairReturn<Async, Float32Array>;
|
|
4659
|
+
vertexMaskToFaceSelection(mesh: MeshHandle, mask: Float32Array | ArrayLike<number>, threshold?: number, requireAllVertices?: boolean): RepairReturn<Async, Uint32Array>;
|
|
4660
|
+
deleteSelectedFaces(mesh: MeshHandle, selectedTris: Indices): RepairReturn<Async, FaceEditReport>;
|
|
4661
|
+
extractSelectedFaces(mesh: MeshHandle, selectedTris: Indices, options?: {
|
|
4662
|
+
normals?: boolean;
|
|
4663
|
+
}): RepairReturn<Async, MeshHandle>;
|
|
4664
|
+
splitSelectedFaces(mesh: MeshHandle, selectedTris: Indices, options?: {
|
|
4665
|
+
normals?: boolean;
|
|
4666
|
+
}): RepairReturn<Async, SplitFacesReport>;
|
|
4667
|
+
}
|
|
4668
|
+
/**
|
|
4669
|
+
* Callable repair domain namespace (`scene.repair(...)` and `scene.repair.<method>(...)`).
|
|
4670
|
+
*
|
|
4671
|
+
* Preserves legacy `repair(mesh, op | ops | request)` call signatures while
|
|
4672
|
+
* organizing repair operations cleanly under `scene.repair.*`.
|
|
4673
|
+
*/
|
|
4674
|
+
interface RepairDomain<Async extends boolean = false> {
|
|
4675
|
+
(mesh: MeshHandle, request: AutoRepairRequest): RepairReturn<Async, AutoRepairReport>;
|
|
4676
|
+
<const O extends RepairOp>(mesh: MeshHandle, op: O): RepairReturn<Async, RepairReportOf<O>>;
|
|
4677
|
+
<const O extends readonly RepairOp[]>(mesh: MeshHandle, ops: O): RepairReturn<Async, { -readonly [K in keyof O]: RepairReportOf<O[K]>; }>;
|
|
4678
|
+
analyze(mesh: MeshHandle, options?: AnalyzeOptions): RepairReturn<Async, Analysis>;
|
|
4679
|
+
autoRepair(mesh: MeshHandle, options?: AutoRepairOptions): RepairReturn<Async, AutoRepairReport>;
|
|
4680
|
+
clean(mesh: MeshHandle, options?: CleanOptions): RepairReturn<Async, CleanReport>;
|
|
4681
|
+
weld(mesh: MeshHandle, tolerance: number): RepairReturn<Async, WeldReport>;
|
|
4682
|
+
removeDegenerate(mesh: MeshHandle, options?: DegenerateOptions): RepairReturn<Async, DegenerateReport>;
|
|
4683
|
+
removeSmallComponents(mesh: MeshHandle, options?: SmallComponentOptions): RepairReturn<Async, RemoveReport>;
|
|
4684
|
+
orient(mesh: MeshHandle): RepairReturn<Async, OrientReport>;
|
|
4685
|
+
fillHoles(mesh: MeshHandle, options?: FillHolesOptions): RepairReturn<Async, FillReport>;
|
|
4686
|
+
fillHoleContinuity(mesh: MeshHandle, loopIndex: number, options?: FillHolesContinuityOptions): RepairReturn<Async, FillContinuityStats>;
|
|
4687
|
+
fillAllHolesContinuity(mesh: MeshHandle, options?: FillHolesContinuityOptions): RepairReturn<Async, FillContinuityStats>;
|
|
4688
|
+
bridge(mesh: MeshHandle, options: BridgeLoopsOptions): RepairReturn<Async, BridgeReport>;
|
|
4689
|
+
bridgeLoops(mesh: MeshHandle, options: BridgeLoopsOptions): RepairReturn<Async, BridgeReport>;
|
|
4690
|
+
bridgePartialArcs(mesh: MeshHandle, loopA: Indices, loopB: Indices, options?: PartialBridgeOptions): RepairReturn<Async, BridgeStats>;
|
|
4691
|
+
join(target: MeshHandle, source: MeshHandle, options: JoinOptions): RepairReturn<Async, JoinReport>;
|
|
4692
|
+
makeManifold(mesh: MeshHandle, options?: ManifoldOptions): RepairReturn<Async, ManifoldReport>;
|
|
4693
|
+
resolveSelfIntersections(mesh: MeshHandle, options?: SelfIntersectOptions): RepairReturn<Async, SelfIntersectReport>;
|
|
4694
|
+
cleanupSlivers(mesh: MeshHandle, options?: SliverOptions): RepairReturn<Async, SliverReport>;
|
|
4695
|
+
selectFacesScreen(mesh: MeshHandle, shape: ScreenSelectionShape, options: ScreenSelectOptions): RepairReturn<Async, Uint32Array>;
|
|
4696
|
+
selectFacesInSphere(mesh: MeshHandle, center: Readonly<Vec3>, radius: number, normalCone?: FaceSelectionNormalCone): RepairReturn<Async, Uint32Array>;
|
|
4697
|
+
selectByCreaseAngle(mesh: MeshHandle, seedTri: number, maxDihedralRad: number): RepairReturn<Async, Uint32Array>;
|
|
4698
|
+
selectConnectedShell(mesh: MeshHandle, seedTri: number): RepairReturn<Async, Uint32Array>;
|
|
4699
|
+
selectSmallFaceIslands(mesh: MeshHandle, maxFaceCount: number, maxArea?: number): RepairReturn<Async, Uint32Array>;
|
|
4700
|
+
growFaceSelection(mesh: MeshHandle, selectedTris: Indices, rings?: number, adjacency?: AdjacencyKind): RepairReturn<Async, Uint32Array>;
|
|
4701
|
+
shrinkFaceSelection(mesh: MeshHandle, selectedTris: Indices, rings?: number, adjacency?: AdjacencyKind): RepairReturn<Async, Uint32Array>;
|
|
4702
|
+
fillSelectionHoles(mesh: MeshHandle, selectedTris: Indices, maxHoleTris: number): RepairReturn<Async, Uint32Array>;
|
|
4703
|
+
smoothSelectionBoundary(mesh: MeshHandle, selectedTris: Indices, iterations?: number): RepairReturn<Async, Uint32Array>;
|
|
4704
|
+
faceSelectionToVertexMask(mesh: MeshHandle, selectedTris: Indices): RepairReturn<Async, Float32Array>;
|
|
4705
|
+
vertexMaskToFaceSelection(mesh: MeshHandle, mask: Float32Array | ArrayLike<number>, threshold?: number, requireAllVertices?: boolean): RepairReturn<Async, Uint32Array>;
|
|
4706
|
+
deleteSelectedFaces(mesh: MeshHandle, selectedTris: Indices): RepairReturn<Async, FaceEditReport>;
|
|
4707
|
+
extractSelectedFaces(mesh: MeshHandle, selectedTris: Indices, options?: {
|
|
4708
|
+
normals?: boolean;
|
|
4709
|
+
}): RepairReturn<Async, MeshHandle>;
|
|
4710
|
+
splitSelectedFaces(mesh: MeshHandle, selectedTris: Indices, options?: {
|
|
4711
|
+
normals?: boolean;
|
|
4712
|
+
}): RepairReturn<Async, SplitFacesReport>;
|
|
4713
|
+
}
|
|
4714
|
+
/** Synchronous repair domain exposed by `Scene.repair`. */
|
|
4715
|
+
type SyncRepairDomain = RepairDomain<false>;
|
|
4716
|
+
/** Asynchronous repair domain exposed by `WorkerScene.repair`. */
|
|
4717
|
+
type WorkerRepairDomain = RepairDomain<true>;
|
|
4718
|
+
/** Builds a callable {@link RepairDomain} backed by `backend`. */
|
|
4719
|
+
declare function createRepairDomain<Async extends boolean>(backend: RepairBackend<Async>): RepairDomain<Async>;
|
|
4720
|
+
/** Complete seven-domain API surface shared by `Scene` and `WorkerScene`. */
|
|
4721
|
+
interface SceneDomains<Async extends boolean = false> {
|
|
4722
|
+
readonly repair: RepairDomain<Async>;
|
|
4723
|
+
readonly sculpt: SculptDomain<Async>;
|
|
4724
|
+
readonly remesh: RemeshDomain<Async>;
|
|
4725
|
+
readonly boolean: BooleanDomain<Async>;
|
|
4726
|
+
readonly deform: DeformDomain<Async>;
|
|
4727
|
+
readonly inspect: InspectDomain<Async>;
|
|
4728
|
+
readonly align: AlignDomain<Async>;
|
|
4729
|
+
}
|
|
4730
|
+
/** Synchronous seven-domain surface implemented by `Scene`. */
|
|
4731
|
+
type SyncSceneDomains = SceneDomains<false>;
|
|
4732
|
+
/** Asynchronous seven-domain surface implemented by `WorkerScene`. */
|
|
4733
|
+
type WorkerSceneDomains = SceneDomains<true>;
|
|
4734
|
+
/** Domain-separated capability surface exposed by both `Scene` and `WorkerScene`. */
|
|
4735
|
+
interface SceneDomainsLike {
|
|
4736
|
+
readonly repair?: SyncRepairDomain | WorkerRepairDomain;
|
|
4737
|
+
readonly sculpt?: SyncSculptDomain | WorkerSculptDomain;
|
|
4738
|
+
readonly remesh?: SyncRemeshDomain | WorkerRemeshDomain;
|
|
4739
|
+
readonly boolean?: SyncBooleanDomain | WorkerBooleanDomain;
|
|
4740
|
+
readonly deform?: SyncDeformDomain | WorkerDeformDomain;
|
|
4741
|
+
readonly inspect?: SyncInspectDomain | WorkerInspectDomain;
|
|
4742
|
+
readonly align?: SyncAlignDomain | WorkerAlignDomain;
|
|
4743
|
+
}
|
|
4744
|
+
/**
|
|
4745
|
+
* What the adapters need from a scene: render buffers, placements, section
|
|
4746
|
+
* results, change notification and drags. All methods are synchronous.
|
|
4747
|
+
* `Scene` and `WorkerScene` also attach the seven optional domain namespaces.
|
|
4748
|
+
*/
|
|
4749
|
+
interface SceneLike extends SceneDomainsLike {
|
|
4750
|
+
/**
|
|
4751
|
+
* Views of the mesh's render buffers. Slot counts follow from them, so
|
|
4752
|
+
* `positions()` must be exactly 3 × vertex slots long and `indices()`
|
|
4753
|
+
* exactly 3 × triangle slots long (normals 3, colours 4 and UVs 2 per vertex
|
|
4754
|
+
* slot, when present): `positions().length / 3` vertex slots and
|
|
4755
|
+
* `indices().length / 3` triangle slots.
|
|
4756
|
+
*/
|
|
4757
|
+
views(mesh: MeshHandle): MeshViews;
|
|
4758
|
+
/** The column-major world matrix of the mesh's local render coordinates. */
|
|
4759
|
+
matrix4(mesh: MeshHandle): Float64Array;
|
|
4760
|
+
placement(mesh: MeshHandle): Placement;
|
|
4761
|
+
section(s: SectionHandle, mesh: MeshHandle): SectionResult;
|
|
4762
|
+
sectionPlane(s: SectionHandle): SectionPlane;
|
|
4763
|
+
/** Registers a change listener; returns the function that removes it. */
|
|
4764
|
+
onChanges(listener: (c: MeshChange[]) => void): () => void;
|
|
4765
|
+
/** Flushes pending changes to the listeners and returns them. */
|
|
4766
|
+
commitFrame(): MeshChange[];
|
|
4767
|
+
drag(mesh: MeshHandle): DragSession;
|
|
4768
|
+
/** Opens a nested history step when supported by the scene host. */
|
|
4769
|
+
beginStep?(): void;
|
|
4770
|
+
/** Ends one open history step nesting level when supported by the scene host. */
|
|
4771
|
+
endStep?(): void;
|
|
4772
|
+
/** Cancels and reverts the active history step when supported by the scene host. */
|
|
4773
|
+
cancelStep?(): void;
|
|
4774
|
+
/** Records an entry of the application's own in the history when supported by the scene host. */
|
|
4775
|
+
recordEntry?(entry: HistoryEntry): void;
|
|
4776
|
+
/** Fills a single boundary loop with selectable G0/G1/G2 continuity. */
|
|
4777
|
+
fillHoleContinuity?(mesh: MeshHandle, loopIndex: number, options?: FillHolesContinuityOptions): FillContinuityStats | Promise<FillContinuityStats>;
|
|
4778
|
+
/** Fills all eligible holes with selectable G0/G1/G2 continuity. */
|
|
4779
|
+
fillAllHolesContinuity?(mesh: MeshHandle, options?: FillHolesContinuityOptions): FillContinuityStats | Promise<FillContinuityStats>;
|
|
4780
|
+
/** Bridges two boundary vertex arcs or index ranges. */
|
|
4781
|
+
bridgePartialArcs?(mesh: MeshHandle, loopA: Indices, loopB: Indices, options?: PartialBridgeOptions): BridgeStats | Promise<BridgeStats>;
|
|
4782
|
+
/** Applies localized dynamic topology remeshing inside sphere `(center, radius)`. */
|
|
4783
|
+
applyDyntopo?(mesh: MeshHandle, center: Readonly<Vec3>, radius: number, options?: DyntopoOptions, pinned?: Indices): DyntopoReport | Promise<DyntopoReport>;
|
|
4784
|
+
/** Applies localized dynamic topology followed by a brush dab. */
|
|
4785
|
+
dyntopoDab?(mesh: MeshHandle, dab: SculptBrushOp, options?: DyntopoOptions, protection?: VertexProtection): DyntopoDabReport | Promise<DyntopoDabReport>;
|
|
4786
|
+
/**
|
|
4787
|
+
* The rule the mesh is coloured by, or `null` without colouring. Optional:
|
|
4788
|
+
* `bindMesh`'s fragment shading needs it (with `views(mesh).values`) and
|
|
4789
|
+
* falls back to vertex colours on a host without it.
|
|
4790
|
+
*/
|
|
4791
|
+
coloring?(mesh: MeshHandle): ColorRule | null;
|
|
4792
|
+
/**
|
|
4793
|
+
* The box around the vertices the mesh's live triangles use, in local
|
|
4794
|
+
* render coordinates, or `null` without live triangles. Optional:
|
|
4795
|
+
* `bindMesh` takes its bounds from it and walks the mirrors on a host
|
|
4796
|
+
* without it.
|
|
4797
|
+
*/
|
|
4798
|
+
bounds?(mesh: MeshHandle): Bounds | null;
|
|
4799
|
+
setDefaultCollisionRule?(rule: CollisionRuleInput): void;
|
|
4800
|
+
defaultCollisionRule?(): CollisionRule | Promise<CollisionRule>;
|
|
4801
|
+
setCollisionRule?(a: MeshHandle, b: MeshHandle, rule: CollisionRuleInput): void;
|
|
4802
|
+
clearCollisionRule?(a: MeshHandle, b: MeshHandle): boolean | Promise<boolean>;
|
|
4803
|
+
collisionRule?(a: MeshHandle, b: MeshHandle): CollisionRule | Promise<CollisionRule>;
|
|
4804
|
+
hasActiveCollisionResponse?(mesh: MeshHandle): boolean | Promise<boolean>;
|
|
4805
|
+
moveWithCollision?(mesh: MeshHandle, placement: PlacementInput, isRelease?: boolean): CollisionStepReport | Promise<CollisionStepReport>;
|
|
4806
|
+
commitCollisionInteraction?(mesh: MeshHandle): CollisionStepReport | Promise<CollisionStepReport>;
|
|
4807
|
+
}
|
|
4808
|
+
export { InflateOp as $, ExtrudeBaseOptions as $a, FaceSelectionNormalCone as $i, RegisterStatus as $n, pointCloudVoxelDownsample as $r, DeviationOptions as $t, WorkerRemeshDomain as A, PrimitiveKind as Aa, ConvexHullPoints as Ai, LandmarkPair as An, SmoothReport as Ar, AutoRepairRequest as At, DeformReturn as B, XpbdPinInput as Ba, CollisionPairOutcome as Bi, OrientReport as Bn, ThicknessFieldDesc as Br, ClayReport as Bt, RemeshDomain as C, PlaceMeshOptions as Ca, LatticeKind as Ci, GrabReport as Cn, computeBounds as Co, SelfIntersectionMode as Cr, WorkerAlignDomain as Ct, SurfaceRemeshOptions as D, PlaceUpAxis as Da, LatticeRegion as Di, JoinOptions as Dn, SliverOptions as Dr, AnalyzeOptions as Dt, SubdivideOptions as E, PlaceTransform as Ea, LatticePreview as Ei, InflateReport as En, SimplifyReport as Er, Analysis as Et, SyncInspectDomain as F, SplitFacesReport as Fa, ArapOptions as Fi, MeshChange as Fn, SurfacePathPoint as Fr, BridgeReport as Ft, BeginStrokeOptions as G, CheckedHeightfieldPlacement as Ga, ContourExportFormat as Gi, QualityMetric as Gn, TwistReport as Gr, Colormap as Gt, SyncDeformDomain as H, unpackPointCloud as Ha, CollisionRule as Hi, OverhangOptions as Hn, TrimCurveOptions as Hr, ClosestPointOptions as Ht, WorkerInspectDomain as I, SurfaceReconstructMethod as Ia, ArapSolver as Ii, MeshComponent as In, SurfaceRemeshMode as Ir, BridgeStats as It, ClayOp as J, HeightMapOptions as Ja, CutTrigger as Ji, RaycastOptions as Jn, parsePointCloudBytes as Jr, CsgNode as Jt, CaptureRestOptions as K, HeightMap as Ka, ContourLoop as Ki, QualityReport as Kn, VertexProtection as Kr, Contact as Kt, createInspectDomain as L, SurfaceReconstructOptions as La, ArapWeights as Li, MeshDistance as Ln, SurfaceRemeshReport as Lr, CaptureRestReport as Lt, InspectBackend as M, ScreenSelectOptions as Ma, AdjacencyKind as Mi, ManifoldOptions as Mn, SubdivideReport as Mr, BooleanOp as Mt, InspectDomain as N, ScreenSelectionShape as Na, ArapAnchorInput as Ni, ManifoldReport as Nn, SurfaceFilter as Nr, BooleanOptions as Nt, SyncRemeshDomain as O, PointCloudFilterResult as Oa, LatticeReport as Oi, JoinReport as On, SliverReport as Or, AutoRepairPreset as Ot, InspectReturn as P, SoftDeformSolver as Pa, ArapHandleInput as Pi, MeasureResult as Pn, SurfacePathOptions as Pr, BoundaryLoop as Pt, GrabOp as Q, heightMapPlacement as Qa, FaceEditReport as Qi, RegisterResult as Qn, pointCloudSor as Qr, DegenerateReport as Qt, DeformBackend as R, XpbdHandleInput as Ra, CollisionDistanceBackend as Ri, OffsetAlgorithm as Rn, Symmetry as Rr, CaptureStrokeReport as Rt, RemeshBackend as S, ParsePointCloudOptions as Sa, DEFAULT_LATTICE_PREVIEW_VOXELS as Si, GrabMethod as Sn, Vec3 as So, SelfIntersectReport as Sr, SyncAlignDomain as St, SimplifyOptions as T, PlaceMode as Ta, LatticePlan as Ti, InflateMethod as Tn, SignMode as Tr, AddMeshOptions as Tt, WorkerDeformDomain as U, AddHeightfieldOptions as Ua, CollisionRuleInput as Ui, OverhangReport as Un, TrimReport as Ur, CoarseAlignMethod as Ut, ProtectedSculptOp as V, packPointCloud as Va, CollisionRole as Vi, OutOfRange as Vn, TriangleQualityOptions as Vr, ClosestHit as Vt, createDeformDomain as W, CheckedHeightfield as Wa, CollisionStepReport as Wi, PartialBridgeOptions as Wn, TwistMethod as Wr, ColorRule as Wt, FilteredSculptOp as X, HeightfieldResult as Xa, DrainHoleOptions as Xi, RegisterNotApplied as Xn, pointCloudEstimateNormals as Xr, CutOptions as Xt, CreaseOp as Y, Heightfield as Ya, DEFAULT_COLLISION_RULE as Yi, RegisterMotion as Yn, parsePointCloudText as Yr, CurvatureFieldDesc as Yt, FlattenOp as Z, MAX_HEIGHT_MAP_PIXELS as Za, DrainHoleReport as Zi, RegisterOptions as Zn, pointCloudRor as Zr, CutReport as Zt, WorkerRepairDomain as _, KelvinletOptions as _a, WrapGridOptions as _i, FindContactsOptions as _n, PlacementInput as _o, SectionDesc as _r, WorkerBooleanDomain as _t, WorkerSceneDomains as a, FfdOptions as aa, IsolateReport as ai, DyntopoMode as an, DelaunayFlipReport as ao, RemoveReport as ar, SmoothOp as at, IsotropicRemeshOptions as b, OutlierReport as ba, WrapResult as bi, GeodesicMethod as bn, Quat as bo, SectionResult as br, AlignDomain as bt, CleanOptions as c, FittedPrimitive as ca, VertexSelection as ci, EditOp as cn, SurfaceStats as co, RepairReportOf as cr, TwistOp as ct, FillHolesOptions as d, FreeformReport as da, HistoryEntry as di, FieldStatus as dn, SectionHandle as do, SceneOptions as dr, BooleanBackend as dt, FfdBasis as ea, sliceContoursExport as ei, DeviationStats as en, ExtrudeBaseResult as eo, RegistrationOptions as er, RelaxOp as et, RepairBackend as f, FreeformScope as fa, PermanentListener as fi, FillContinuity as fn, Bounds as fo, SculptBrushOp as fr, BooleanDomain as ft, SyncRepairDomain as g, KelvinletLoad as ga, DEFAULT_WRAP_MAX_VOXELS as gi, FilledLoop as gn, Placement as go, SectionContour as gr, SyncBooleanDomain as gt, SmallComponentOptions as h, HollowReport as ha, DEFAULT_WRAP_DETAIL as hi, FillReport as hn, Mat3 as ho, SculptReportOf as hr, ShellOptions as ht, SyncSceneDomains as i, FfdLatticeData as ia, ComponentSelect as ii, DyntopoDabReport as in, DelaunayFlipOptions as io, RemoveMeshOptions as ir, SculptReturn as it, createRemeshDomain as j, PrimitiveKindInput as ja, ConvexHullResult as ji, LoopId as jn, StretchReport as jr, BooleanMethod as jt, VoxelRemeshOptions as k, PointCloudFormat as ka, ConvexHullOptions as ki, LandmarkAlignment as kn, SmoothMethod as kr, AutoRepairReport as kt, CleanReport as l, FittedPrimitiveReport as la, DEFAULT_HISTORY_BUDGET as li, EditRef as ln, FieldHandle as lo, Rgba as lr, WorkerSculptDomain as lt, RepairReturn as m, HollowOptions as ma, Range as mi, FillHolesContinuityOptions as mn, InitInput as mo, SculptReport as mr, OffsetOptions as mt, SceneLike as n, FfdFrameData as na, SceneMeshViews as ni, DragOptions as nn, ExtrudeFacesOptions as no, RelaxReport as nr, SculptDabOptions as nt, AutoRepairOptions as o, FfdOutsideMode as oa, LassoSelect as oi, DyntopoOptions as on, DenoiseOptions as oo, RepairOp as or, SplitStretchedOptions as ot, RepairDomain as p, HollowBackend as pa, PermanentStep as pi, FillContinuityStats as pn, Indices as po, SculptOp as pr, BooleanReturn as pt, CaptureStrokeOptions as q, HeightMapFrame as qa, ContourSlice as qi, RayHit as qn, WeldReport as qr, CreaseReport as qt, SceneDomains as r, FfdLattice as ra, BrushSelect as ri, DragSession as rn, ExtrudeFacesResult as ro, RemeshReport as rr, SculptDomain as rt, BridgeLoopsOptions as s, FitPrimitiveOptions as sa, SelectSpec as si, DyntopoReport as sn, DenoiseReport as so, RepairReport as sr, SyncSculptDomain as st, SceneDomainsLike as t, FfdBasisInput as ta, MeshViews as ti, DistanceFieldDesc as tn, ExtrudeDirection as to, RegistrationReport as tr, SculptBackend as tt, DegenerateOptions as u, FreeformProtection as ua, EntryEvent as ui, EditResult as un, MeshHandle as uo, Scene as ur, createSculptDomain as ut, createRepairDomain as v, KelvinletScale as va, WrapOptions as vi, FlattenMode as vn, Positions as vo, SectionGap as vr, createBooleanDomain as vt, RemeshReturn as w, PlaceMeshReport as wa, LatticeOptions as wi, IcpObjective as wn, computeVertexNormals as wo, ShellReport as wr, createAlignDomain as wt, RegionRemeshOptions as x, PackedPointCloud as xa, DEFAULT_LATTICE_MAX_VOXELS as xi, GeodesicOptions as xn, UpdateMode as xo, SelfIntersectOptions as xr, AlignReturn as xt, AdaptiveRemeshOptions as y, MaterialMemory as ya, WrapPlan as yi, FlattenReport as yn, Positions64 as yo, SectionPlane as yr, AlignBackend as yt, DeformDomain as z, XpbdOptions as za, CollisionMode as zi, OffsetReport as zn, SymmetryPlaneReport as zr, ClayProfile as zt };
|