fast-mesh-wasm 0.5.3 → 0.7.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 +2 -1
- package/dist/{client-f895H_yB.js → client-DFgvktkT.js} +183 -10
- package/dist/{client-D7yfPOyU.d.ts → client-nvmbhtn-.d.ts} +87 -14
- package/dist/{engine-BcJ5W6kS.js → engine-BL5_sWAf.js} +21 -6
- package/dist/io.d.ts +218 -5
- package/dist/io.js +3121 -12
- package/dist/{mesh-B3QP93wx.d.ts → mesh-BHTFxsXc.d.ts} +5 -2
- package/dist/{mesh-hPWBQPaN.js → mesh-DIWD2F5-.js} +51 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +3 -2
- package/dist/{protocol-Dt0zgang.d.ts → protocol-DFR0JDAS.d.ts} +9 -1
- package/dist/r3f.d.ts +3 -3
- package/dist/r3f.js +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/{scene-CXtM_bxV.js → scene-DUsj6uJD.js} +421 -29
- package/dist/{scene-like-Dq9_SaUL.d.ts → scene-like-CR_Dpohm.d.ts} +999 -133
- package/dist/{store-CIW19oCh.d.ts → store-8HWG90Jg.d.ts} +14 -3
- package/dist/{store-C9h7GFFl.js → store-BAzHRRkt.js} +18 -2
- package/dist/store.d.ts +3 -3
- package/dist/store.js +1 -1
- package/dist/three.d.ts +2 -2
- package/dist/three.js +1 -1
- package/dist/views-BSy-Qeg8.js +584 -0
- package/dist/wasm/fast_mesh_wasm.d.ts +21 -1
- package/dist/wasm/fast_mesh_wasm.js +50 -1
- package/dist/wasm/fast_mesh_wasm_bg.wasm +0 -0
- package/dist/wasm/fast_mesh_wasm_bg.wasm.d.ts +3 -0
- package/dist/wasm-threads/fast_mesh_wasm.d.ts +21 -1
- package/dist/wasm-threads/fast_mesh_wasm.js +50 -1
- package/dist/wasm-threads/fast_mesh_wasm_bg.wasm +0 -0
- package/dist/wasm-threads/fast_mesh_wasm_bg.wasm.d.ts +3 -0
- package/dist/web.d.ts +2 -2
- package/dist/web.js +3 -2
- package/dist/worker-engine.d.ts +5 -3
- 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/views-mp7Mf8CQ.js +0 -209
|
@@ -538,7 +538,8 @@ export class WasmScene {
|
|
|
538
538
|
* the same placement. Returns `[kept index, kept generation, added
|
|
539
539
|
* index, added generation, kept triangles, removed triangles, cap
|
|
540
540
|
* triangles]`. With `cap` (the usual case) both openings are closed
|
|
541
|
-
* with flat, unfaired patches
|
|
541
|
+
* with flat, unfaired patches, across UV seams on a mesh with UVs;
|
|
542
|
+
* without it both parts keep the open rim.
|
|
542
543
|
* The cut undoes in one step; the added mesh stays, like the removed
|
|
543
544
|
* source of [`WasmScene::join`].
|
|
544
545
|
* @param {number} index
|
|
@@ -962,6 +963,22 @@ export class WasmScene {
|
|
|
962
963
|
}
|
|
963
964
|
return ret[0] >>> 0;
|
|
964
965
|
}
|
|
966
|
+
/**
|
|
967
|
+
* The mesh's origin: its stored positions are relative to it, and
|
|
968
|
+
* `setPositions` takes positions with it added back.
|
|
969
|
+
* @param {number} index
|
|
970
|
+
* @param {number} generation
|
|
971
|
+
* @returns {Float64Array}
|
|
972
|
+
*/
|
|
973
|
+
origin(index, generation) {
|
|
974
|
+
const ret = wasm.wasmscene_origin(this.__wbg_ptr, index, generation);
|
|
975
|
+
if (ret[3]) {
|
|
976
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
977
|
+
}
|
|
978
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
979
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
980
|
+
return v1;
|
|
981
|
+
}
|
|
965
982
|
/**
|
|
966
983
|
* The placement: the row-major rotation (9 values), then the
|
|
967
984
|
* translation (3 values), then the scale (3 values).
|
|
@@ -1208,6 +1225,17 @@ export class WasmScene {
|
|
|
1208
1225
|
set_defer_fields(on) {
|
|
1209
1226
|
wasm.wasmscene_set_defer_fields(this.__wbg_ptr, on);
|
|
1210
1227
|
}
|
|
1228
|
+
/**
|
|
1229
|
+
* Starts (a budget of `points`) or ends (`undefined`) an interaction; see
|
|
1230
|
+
* [`Scene::set_field_interaction`].
|
|
1231
|
+
* @param {number | null} [points]
|
|
1232
|
+
*/
|
|
1233
|
+
set_field_interaction(points) {
|
|
1234
|
+
const ret = wasm.wasmscene_set_field_interaction(this.__wbg_ptr, isLikeNone(points) ? Number.MAX_SAFE_INTEGER : (points) >>> 0);
|
|
1235
|
+
if (ret[1]) {
|
|
1236
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1211
1239
|
/**
|
|
1212
1240
|
* Sets when the mesh's BVH, normals, fields and sections follow its
|
|
1213
1241
|
* edits: 0 (Eager), 1 (Lazy) or 2 (Manual).
|
|
@@ -1430,6 +1458,27 @@ export class WasmScene {
|
|
|
1430
1458
|
}
|
|
1431
1459
|
return ret[0] >>> 0;
|
|
1432
1460
|
}
|
|
1461
|
+
/**
|
|
1462
|
+
* Live triangle-used vertex ids of a mesh inside the closed local-space
|
|
1463
|
+
* sphere `(cx, cy, cz, radius)`, in ascending order. Brings a Lazy BVH up
|
|
1464
|
+
* to date first; refuses a stale Manual BVH with `STALE_BVH`.
|
|
1465
|
+
* @param {number} index
|
|
1466
|
+
* @param {number} generation
|
|
1467
|
+
* @param {number} cx
|
|
1468
|
+
* @param {number} cy
|
|
1469
|
+
* @param {number} cz
|
|
1470
|
+
* @param {number} radius
|
|
1471
|
+
* @returns {Uint32Array}
|
|
1472
|
+
*/
|
|
1473
|
+
vertices_in_sphere(index, generation, cx, cy, cz, radius) {
|
|
1474
|
+
const ret = wasm.wasmscene_vertices_in_sphere(this.__wbg_ptr, index, generation, cx, cy, cz, radius);
|
|
1475
|
+
if (ret[3]) {
|
|
1476
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1477
|
+
}
|
|
1478
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
1479
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1480
|
+
return v1;
|
|
1481
|
+
}
|
|
1433
1482
|
/**
|
|
1434
1483
|
* Removes a field never computed, reporting nothing; `false` (nothing
|
|
1435
1484
|
* done) when it was computed or colours its mesh. See
|
|
Binary file
|
|
@@ -62,6 +62,7 @@ export const wasmscene_mode: (a: number, b: number, c: number) => [number, numbe
|
|
|
62
62
|
export const wasmscene_new: () => number;
|
|
63
63
|
export const wasmscene_normals_len: (a: number, b: number, c: number) => [number, number, number];
|
|
64
64
|
export const wasmscene_normals_ptr: (a: number, b: number, c: number) => [number, number, number];
|
|
65
|
+
export const wasmscene_origin: (a: number, b: number, c: number) => [number, number, number, number];
|
|
65
66
|
export const wasmscene_placement: (a: number, b: number, c: number) => [number, number, number, number];
|
|
66
67
|
export const wasmscene_positions_len: (a: number, b: number, c: number) => [number, number, number];
|
|
67
68
|
export const wasmscene_positions_ptr: (a: number, b: number, c: number) => [number, number, number];
|
|
@@ -77,6 +78,7 @@ export const wasmscene_section_desc_plane: (a: number, b: number) => [number, nu
|
|
|
77
78
|
export const wasmscene_section_gap: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
78
79
|
export const wasmscene_set_coloring: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
|
|
79
80
|
export const wasmscene_set_defer_fields: (a: number, b: number) => void;
|
|
81
|
+
export const wasmscene_set_field_interaction: (a: number, b: number) => [number, number];
|
|
80
82
|
export const wasmscene_set_mode: (a: number, b: number, c: number, d: number) => [number, number];
|
|
81
83
|
export const wasmscene_set_placement: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
|
|
82
84
|
export const wasmscene_set_section_fill: (a: number, b: number, c: number) => [number, number];
|
|
@@ -94,6 +96,7 @@ export const wasmscene_values_len: (a: number, b: number, c: number) => [number,
|
|
|
94
96
|
export const wasmscene_values_ptr: (a: number, b: number, c: number) => [number, number, number];
|
|
95
97
|
export const wasmscene_vertex_count: (a: number, b: number, c: number) => [number, number, number];
|
|
96
98
|
export const wasmscene_vertex_slots: (a: number, b: number, c: number) => [number, number, number];
|
|
99
|
+
export const wasmscene_vertices_in_sphere: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number];
|
|
97
100
|
export const wasmscene_withdraw_field: (a: number, b: number) => [number, number, number];
|
|
98
101
|
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
99
102
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
@@ -200,7 +200,8 @@ export class WasmScene {
|
|
|
200
200
|
* the same placement. Returns `[kept index, kept generation, added
|
|
201
201
|
* index, added generation, kept triangles, removed triangles, cap
|
|
202
202
|
* triangles]`. With `cap` (the usual case) both openings are closed
|
|
203
|
-
* with flat, unfaired patches
|
|
203
|
+
* with flat, unfaired patches, across UV seams on a mesh with UVs;
|
|
204
|
+
* without it both parts keep the open rim.
|
|
204
205
|
* The cut undoes in one step; the added mesh stays, like the removed
|
|
205
206
|
* source of [`WasmScene::join`].
|
|
206
207
|
*/
|
|
@@ -363,6 +364,11 @@ export class WasmScene {
|
|
|
363
364
|
* off.
|
|
364
365
|
*/
|
|
365
366
|
normals_ptr(index: number, generation: number): number;
|
|
367
|
+
/**
|
|
368
|
+
* The mesh's origin: its stored positions are relative to it, and
|
|
369
|
+
* `setPositions` takes positions with it added back.
|
|
370
|
+
*/
|
|
371
|
+
origin(index: number, generation: number): Float64Array;
|
|
366
372
|
/**
|
|
367
373
|
* The placement: the row-major rotation (9 values), then the
|
|
368
374
|
* translation (3 values), then the scale (3 values).
|
|
@@ -448,6 +454,11 @@ export class WasmScene {
|
|
|
448
454
|
* [`Scene::set_defer_fields`].
|
|
449
455
|
*/
|
|
450
456
|
set_defer_fields(on: boolean): void;
|
|
457
|
+
/**
|
|
458
|
+
* Starts (a budget of `points`) or ends (`undefined`) an interaction; see
|
|
459
|
+
* [`Scene::set_field_interaction`].
|
|
460
|
+
*/
|
|
461
|
+
set_field_interaction(points?: number | null): void;
|
|
451
462
|
/**
|
|
452
463
|
* Sets when the mesh's BVH, normals, fields and sections follow its
|
|
453
464
|
* edits: 0 (Eager), 1 (Lazy) or 2 (Manual).
|
|
@@ -524,6 +535,12 @@ export class WasmScene {
|
|
|
524
535
|
* Vertex slots, alive or dead: the length of the vertex buffers.
|
|
525
536
|
*/
|
|
526
537
|
vertex_slots(index: number, generation: number): number;
|
|
538
|
+
/**
|
|
539
|
+
* Live triangle-used vertex ids of a mesh inside the closed local-space
|
|
540
|
+
* sphere `(cx, cy, cz, radius)`, in ascending order. Brings a Lazy BVH up
|
|
541
|
+
* to date first; refuses a stale Manual BVH with `STALE_BVH`.
|
|
542
|
+
*/
|
|
543
|
+
vertices_in_sphere(index: number, generation: number, cx: number, cy: number, cz: number, radius: number): Uint32Array;
|
|
527
544
|
/**
|
|
528
545
|
* Removes a field never computed, reporting nothing; `false` (nothing
|
|
529
546
|
* done) when it was computed or colours its mesh. See
|
|
@@ -632,6 +649,7 @@ export interface InitOutput {
|
|
|
632
649
|
readonly wasmscene_new: () => number;
|
|
633
650
|
readonly wasmscene_normals_len: (a: number, b: number, c: number) => [number, number, number];
|
|
634
651
|
readonly wasmscene_normals_ptr: (a: number, b: number, c: number) => [number, number, number];
|
|
652
|
+
readonly wasmscene_origin: (a: number, b: number, c: number) => [number, number, number, number];
|
|
635
653
|
readonly wasmscene_placement: (a: number, b: number, c: number) => [number, number, number, number];
|
|
636
654
|
readonly wasmscene_positions_len: (a: number, b: number, c: number) => [number, number, number];
|
|
637
655
|
readonly wasmscene_positions_ptr: (a: number, b: number, c: number) => [number, number, number];
|
|
@@ -647,6 +665,7 @@ export interface InitOutput {
|
|
|
647
665
|
readonly wasmscene_section_gap: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
648
666
|
readonly wasmscene_set_coloring: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
|
|
649
667
|
readonly wasmscene_set_defer_fields: (a: number, b: number) => void;
|
|
668
|
+
readonly wasmscene_set_field_interaction: (a: number, b: number) => [number, number];
|
|
650
669
|
readonly wasmscene_set_mode: (a: number, b: number, c: number, d: number) => [number, number];
|
|
651
670
|
readonly wasmscene_set_placement: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
|
|
652
671
|
readonly wasmscene_set_section_fill: (a: number, b: number, c: number) => [number, number];
|
|
@@ -664,6 +683,7 @@ export interface InitOutput {
|
|
|
664
683
|
readonly wasmscene_values_ptr: (a: number, b: number, c: number) => [number, number, number];
|
|
665
684
|
readonly wasmscene_vertex_count: (a: number, b: number, c: number) => [number, number, number];
|
|
666
685
|
readonly wasmscene_vertex_slots: (a: number, b: number, c: number) => [number, number, number];
|
|
686
|
+
readonly wasmscene_vertices_in_sphere: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number];
|
|
667
687
|
readonly wasmscene_withdraw_field: (a: number, b: number) => [number, number, number];
|
|
668
688
|
readonly watchPoolCrashes: (a: number, b: number) => void;
|
|
669
689
|
readonly wbg_rayon_poolbuilder_build: (a: number) => void;
|
|
@@ -541,7 +541,8 @@ export class WasmScene {
|
|
|
541
541
|
* the same placement. Returns `[kept index, kept generation, added
|
|
542
542
|
* index, added generation, kept triangles, removed triangles, cap
|
|
543
543
|
* triangles]`. With `cap` (the usual case) both openings are closed
|
|
544
|
-
* with flat, unfaired patches
|
|
544
|
+
* with flat, unfaired patches, across UV seams on a mesh with UVs;
|
|
545
|
+
* without it both parts keep the open rim.
|
|
545
546
|
* The cut undoes in one step; the added mesh stays, like the removed
|
|
546
547
|
* source of [`WasmScene::join`].
|
|
547
548
|
* @param {number} index
|
|
@@ -965,6 +966,22 @@ export class WasmScene {
|
|
|
965
966
|
}
|
|
966
967
|
return ret[0] >>> 0;
|
|
967
968
|
}
|
|
969
|
+
/**
|
|
970
|
+
* The mesh's origin: its stored positions are relative to it, and
|
|
971
|
+
* `setPositions` takes positions with it added back.
|
|
972
|
+
* @param {number} index
|
|
973
|
+
* @param {number} generation
|
|
974
|
+
* @returns {Float64Array}
|
|
975
|
+
*/
|
|
976
|
+
origin(index, generation) {
|
|
977
|
+
const ret = wasm.wasmscene_origin(this.__wbg_ptr, index, generation);
|
|
978
|
+
if (ret[3]) {
|
|
979
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
980
|
+
}
|
|
981
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
982
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
983
|
+
return v1;
|
|
984
|
+
}
|
|
968
985
|
/**
|
|
969
986
|
* The placement: the row-major rotation (9 values), then the
|
|
970
987
|
* translation (3 values), then the scale (3 values).
|
|
@@ -1211,6 +1228,17 @@ export class WasmScene {
|
|
|
1211
1228
|
set_defer_fields(on) {
|
|
1212
1229
|
wasm.wasmscene_set_defer_fields(this.__wbg_ptr, on);
|
|
1213
1230
|
}
|
|
1231
|
+
/**
|
|
1232
|
+
* Starts (a budget of `points`) or ends (`undefined`) an interaction; see
|
|
1233
|
+
* [`Scene::set_field_interaction`].
|
|
1234
|
+
* @param {number | null} [points]
|
|
1235
|
+
*/
|
|
1236
|
+
set_field_interaction(points) {
|
|
1237
|
+
const ret = wasm.wasmscene_set_field_interaction(this.__wbg_ptr, isLikeNone(points) ? Number.MAX_SAFE_INTEGER : (points) >>> 0);
|
|
1238
|
+
if (ret[1]) {
|
|
1239
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1214
1242
|
/**
|
|
1215
1243
|
* Sets when the mesh's BVH, normals, fields and sections follow its
|
|
1216
1244
|
* edits: 0 (Eager), 1 (Lazy) or 2 (Manual).
|
|
@@ -1433,6 +1461,27 @@ export class WasmScene {
|
|
|
1433
1461
|
}
|
|
1434
1462
|
return ret[0] >>> 0;
|
|
1435
1463
|
}
|
|
1464
|
+
/**
|
|
1465
|
+
* Live triangle-used vertex ids of a mesh inside the closed local-space
|
|
1466
|
+
* sphere `(cx, cy, cz, radius)`, in ascending order. Brings a Lazy BVH up
|
|
1467
|
+
* to date first; refuses a stale Manual BVH with `STALE_BVH`.
|
|
1468
|
+
* @param {number} index
|
|
1469
|
+
* @param {number} generation
|
|
1470
|
+
* @param {number} cx
|
|
1471
|
+
* @param {number} cy
|
|
1472
|
+
* @param {number} cz
|
|
1473
|
+
* @param {number} radius
|
|
1474
|
+
* @returns {Uint32Array}
|
|
1475
|
+
*/
|
|
1476
|
+
vertices_in_sphere(index, generation, cx, cy, cz, radius) {
|
|
1477
|
+
const ret = wasm.wasmscene_vertices_in_sphere(this.__wbg_ptr, index, generation, cx, cy, cz, radius);
|
|
1478
|
+
if (ret[3]) {
|
|
1479
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1480
|
+
}
|
|
1481
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
1482
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1483
|
+
return v1;
|
|
1484
|
+
}
|
|
1436
1485
|
/**
|
|
1437
1486
|
* Removes a field never computed, reporting nothing; `false` (nothing
|
|
1438
1487
|
* done) when it was computed or colours its mesh. See
|
|
Binary file
|
|
@@ -63,6 +63,7 @@ export const wasmscene_mode: (a: number, b: number, c: number) => [number, numbe
|
|
|
63
63
|
export const wasmscene_new: () => number;
|
|
64
64
|
export const wasmscene_normals_len: (a: number, b: number, c: number) => [number, number, number];
|
|
65
65
|
export const wasmscene_normals_ptr: (a: number, b: number, c: number) => [number, number, number];
|
|
66
|
+
export const wasmscene_origin: (a: number, b: number, c: number) => [number, number, number, number];
|
|
66
67
|
export const wasmscene_placement: (a: number, b: number, c: number) => [number, number, number, number];
|
|
67
68
|
export const wasmscene_positions_len: (a: number, b: number, c: number) => [number, number, number];
|
|
68
69
|
export const wasmscene_positions_ptr: (a: number, b: number, c: number) => [number, number, number];
|
|
@@ -78,6 +79,7 @@ export const wasmscene_section_desc_plane: (a: number, b: number) => [number, nu
|
|
|
78
79
|
export const wasmscene_section_gap: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
79
80
|
export const wasmscene_set_coloring: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
|
|
80
81
|
export const wasmscene_set_defer_fields: (a: number, b: number) => void;
|
|
82
|
+
export const wasmscene_set_field_interaction: (a: number, b: number) => [number, number];
|
|
81
83
|
export const wasmscene_set_mode: (a: number, b: number, c: number, d: number) => [number, number];
|
|
82
84
|
export const wasmscene_set_placement: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
|
|
83
85
|
export const wasmscene_set_section_fill: (a: number, b: number, c: number) => [number, number];
|
|
@@ -95,6 +97,7 @@ export const wasmscene_values_len: (a: number, b: number, c: number) => [number,
|
|
|
95
97
|
export const wasmscene_values_ptr: (a: number, b: number, c: number) => [number, number, number];
|
|
96
98
|
export const wasmscene_vertex_count: (a: number, b: number, c: number) => [number, number, number];
|
|
97
99
|
export const wasmscene_vertex_slots: (a: number, b: number, c: number) => [number, number, number];
|
|
100
|
+
export const wasmscene_vertices_in_sphere: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number];
|
|
98
101
|
export const wasmscene_withdraw_field: (a: number, b: number) => [number, number, number];
|
|
99
102
|
export const watchPoolCrashes: (a: number, b: number) => void;
|
|
100
103
|
export const wbg_rayon_poolbuilder_build: (a: number) => void;
|
package/dist/web.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as SculptDomain, $n as StretchReport, $t as FindContactsOptions, A as InspectDomain, An as RepairReport, Ar as Vec3, At as CaptureRestReport, B as WorkerDeformDomain, Bn as SectionGap, Bt as CurvatureFieldDesc, C as SimplifyOptions, Cn as RegisterOptions, Cr as Mat3, Ct as AnalyzeOptions, D as WorkerRemeshDomain, Dn as RemeshReport, Dr as Positions64, Dt as BooleanOp, E as VoxelRemeshOptions, En as RelaxReport, Er as Positions, Et as AutoRepairRequest, F as DeformBackend, Fn as SculptOp, Ft as ClosestPointOptions, G as ClayOp, Gn as SelfIntersectionMode, Gt as DragOptions, H as BeginStrokeOptions, Hn as SectionResult, Ht as CutReport, I as DeformDomain, In as SculptReport, It as ColorRule, J as FlattenOp, Jn as SimplifyReport, Jt as EditRef, K as CreaseOp, Kn as ShellReport, Kt as DragSession, L as DeformReturn, Ln as SculptReportOf, Lt as Colormap, M as SyncInspectDomain, Mn as Rgba, Mr as computeVertexNormals, Mt as ClayProfile, N as WorkerInspectDomain, Nn as Scene, Nt as ClayReport, O as createRemeshDomain, On as RemoveReport, Or as Quat, Ot as BoundaryLoop, P as createInspectDomain, Pn as SceneOptions, Pt as ClosestHit, Q as SculptBackend, Qn as SmoothReport, Qt as FilledLoop, R as ProtectedSculptOp, Rn as SectionContour, Rt as Contact, S as RemeshReturn, Sn as RegisterNotApplied, Sr as InitInput, St as Analysis, T as SyncRemeshDomain, Tn as RegisterStatus, Tr as PlacementInput, Tt as AutoRepairReport, U as CaptureRestOptions, Un as SelfIntersectOptions, Ut as DegenerateReport, V as createDeformDomain, Vn as SectionPlane, Vt as CutOptions, W as CaptureStrokeOptions, Wn as SelfIntersectReport, Wt as DistanceFieldDesc, X as InflateOp, Xn as SliverReport, Xt as FieldStatus, Y as GrabOp, Yn as SliverOptions, Yt as EditResult, Z as RelaxOp, Zn as SmoothMethod, Zt as FillReport, _ as WorkerRepairDomain, _n as OrientReport, _r as FieldHandle, _t as AlignReturn, a as WorkerSceneDomains, an as InflateReport, ar as TwistReport, at as WorkerSculptDomain, b as RemeshBackend, bn as RaycastOptions, br as Bounds, bt as createAlignDomain, c as CleanOptions, cn as LoopId, cr as MeshViews, ct as BooleanDomain, d as FillHolesOptions, dn as MeasureResult, dr as ComponentSelect, dt as ShellOptions, en as FlattenMode, er as SubdivideReport, et as SculptReturn, f as RepairBackend, fn as MeshChange, fr as IsolateReport, ft as SyncBooleanDomain, g as SyncRepairDomain, gn as OffsetReport, gr as Range, gt as AlignDomain, h as SmallComponentOptions, hn as OffsetAlgorithm, hr as VertexSelection, ht as AlignBackend, i as SyncSceneDomains, in as InflateMethod, ir as TwistMethod, it as TwistOp, j as InspectReturn, jn as RepairReportOf, jr as computeBounds, jt as CaptureStrokeReport, k as InspectBackend, kn as RepairOp, kr as UpdateMode, kt as BridgeReport, l as CleanReport, ln as ManifoldOptions, lr as SceneMeshViews, lt as BooleanReturn, m as RepairReturn, mn as MeshDistance, mr as SelectSpec, mt as createBooleanDomain, n as SceneLike, nn as GrabMethod, nr as Symmetry, nt as SplitStretchedOptions, o as AutoRepairOptions, on as JoinOptions, or as VertexProtection, ot as createSculptDomain, p as RepairDomain, pn as MeshComponent, pr as LassoSelect, pt as WorkerBooleanDomain, q as FilteredSculptOp, qn as SignMode, qt as EditOp, r as SceneDomains, rn as GrabReport, rr as ThicknessFieldDesc, rt as SyncSculptDomain, s as BridgeLoopsOptions, sn as JoinReport, sr as WeldReport, st as BooleanBackend, t as SceneDomainsLike, tn as FlattenReport, tr as SurfaceFilter, tt as SmoothOp, u as DegenerateOptions, un as ManifoldReport, ur as BrushSelect, ut as OffsetOptions, v as createRepairDomain, vn as OutOfRange, vr as MeshHandle, vt as SyncAlignDomain, w as SubdivideOptions, wn as RegisterResult, wr as Placement, wt as AutoRepairPreset, x as RemeshDomain, xn as RegisterMotion, xr as Indices, xt as AddMeshOptions, y as RegionRemeshOptions, yn as RayHit, yr as SectionHandle, yt as WorkerAlignDomain, z as SyncDeformDomain, zn as SectionDesc, zt as CreaseReport } from "./scene-like-CR_Dpohm.js";
|
|
2
2
|
import { n as FastMeshErrorCode, t as FastMeshError } from "./core-CJ9D6U5A.js";
|
|
3
3
|
/**
|
|
4
4
|
* Loads the WebAssembly module. Await this once before calling any other function.
|
|
@@ -8,4 +8,4 @@ import { n as FastMeshErrorCode, t as FastMeshError } from "./core-CJ9D6U5A.js";
|
|
|
8
8
|
* Leave empty to load the file shipped with this package.
|
|
9
9
|
*/
|
|
10
10
|
export declare function init(input?: InitInput | Promise<InitInput>): Promise<void>;
|
|
11
|
-
export { type AddMeshOptions, type Analysis, type AnalyzeOptions, type AutoRepairReport, type AutoRepairRequest, type BooleanOp, type BoundaryLoop, type Bounds, type BridgeReport, type BrushSelect, type ClosestHit, type ClosestPointOptions, type ColorRule, type Colormap, type ComponentSelect, type Contact, type CurvatureFieldDesc, type CutOptions, type CutReport, type DegenerateReport, type DistanceFieldDesc, type DragOptions, type DragSession, type EditOp, type EditRef, type EditResult, FastMeshError, type FastMeshErrorCode, type FieldHandle, type FieldStatus, type FillReport, type FilledLoop, type FindContactsOptions, type GrabReport, type Indices, type InflateReport, type InitInput, type IsolateReport, type JoinOptions, type JoinReport, type LassoSelect, type LoopId, type Mat3, type MeasureResult, type MeshChange, type MeshComponent, type MeshDistance, type MeshHandle, type MeshViews, type OffsetReport, type OrientReport, type OutOfRange, type Placement, type PlacementInput, type Positions, type Positions64, type Quat, type Range, type RayHit, type RaycastOptions, type RegisterMotion, type RegisterNotApplied, type RegisterOptions, type RegisterResult, type RegisterStatus, type RelaxReport, type RemeshReport, type RemoveReport, type RepairOp, type RepairReport, type RepairReportOf, type Rgba, Scene, type SceneLike, type SceneMeshViews, type SceneOptions, type SectionContour, type SectionDesc, type SectionGap, type SectionHandle, type SectionPlane, type SectionResult, type SelectSpec, type ShellReport, type SignMode, type SimplifyReport, type SmoothReport, type SubdivideReport, type ThicknessFieldDesc, type UpdateMode, type Vec3, type VertexSelection, type WeldReport, computeBounds, computeVertexNormals };
|
|
11
|
+
export { type AddMeshOptions, type AlignBackend, type AlignDomain, type AlignReturn, type Analysis, type AnalyzeOptions, type AutoRepairOptions, type AutoRepairPreset, type AutoRepairReport, type AutoRepairRequest, type BeginStrokeOptions, type BooleanBackend, type BooleanDomain, type BooleanOp, type BooleanReturn, type BoundaryLoop, type Bounds, type BridgeLoopsOptions, type BridgeReport, type BrushSelect, type CaptureRestOptions, type CaptureRestReport, type CaptureStrokeOptions, type CaptureStrokeReport, type ClayOp, type ClayProfile, type ClayReport, type CleanOptions, type CleanReport, type ClosestHit, type ClosestPointOptions, type ColorRule, type Colormap, type ComponentSelect, type Contact, type CreaseOp, type CreaseReport, type CurvatureFieldDesc, type CutOptions, type CutReport, type DeformBackend, type DeformDomain, type DeformReturn, type DegenerateOptions, type DegenerateReport, type DistanceFieldDesc, type DragOptions, type DragSession, type EditOp, type EditRef, type EditResult, FastMeshError, type FastMeshErrorCode, type FieldHandle, type FieldStatus, type FillHolesOptions, type FillReport, type FilledLoop, type FilteredSculptOp, type FindContactsOptions, type FlattenMode, type FlattenOp, type FlattenReport, type GrabMethod, type GrabOp, type GrabReport, type Indices, type InflateMethod, type InflateOp, type InflateReport, type InitInput, type InspectBackend, type InspectDomain, type InspectReturn, type IsolateReport, type JoinOptions, type JoinReport, type LassoSelect, type LoopId, type ManifoldOptions, type ManifoldReport, type Mat3, type MeasureResult, type MeshChange, type MeshComponent, type MeshDistance, type MeshHandle, type MeshViews, type OffsetAlgorithm, type OffsetOptions, type OffsetReport, type OrientReport, type OutOfRange, type Placement, type PlacementInput, type Positions, type Positions64, type ProtectedSculptOp, type Quat, type Range, type RayHit, type RaycastOptions, type RegionRemeshOptions, type RegisterMotion, type RegisterNotApplied, type RegisterOptions, type RegisterResult, type RegisterStatus, type RelaxOp, type RelaxReport, type RemeshBackend, type RemeshDomain, type RemeshReport, type RemeshReturn, type RemoveReport, type RepairBackend, type RepairDomain, type RepairOp, type RepairReport, type RepairReportOf, type RepairReturn, type Rgba, Scene, type SceneDomains, type SceneDomainsLike, type SceneLike, type SceneMeshViews, type SceneOptions, type SculptBackend, type SculptDomain, type SculptOp, type SculptReport, type SculptReportOf, type SculptReturn, type SectionContour, type SectionDesc, type SectionGap, type SectionHandle, type SectionPlane, type SectionResult, type SelectSpec, type SelfIntersectOptions, type SelfIntersectReport, type SelfIntersectionMode, type ShellOptions, type ShellReport, type SignMode, type SimplifyOptions, type SimplifyReport, type SliverOptions, type SliverReport, type SmallComponentOptions, type SmoothMethod, type SmoothOp, type SmoothReport, type SplitStretchedOptions, type StretchReport, type SubdivideOptions, type SubdivideReport, type SurfaceFilter, type Symmetry, type SyncAlignDomain, type SyncBooleanDomain, type SyncDeformDomain, type SyncInspectDomain, type SyncRemeshDomain, type SyncRepairDomain, type SyncSceneDomains, type SyncSculptDomain, type ThicknessFieldDesc, type TwistMethod, type TwistOp, type TwistReport, type UpdateMode, type Vec3, type VertexProtection, type VertexSelection, type VoxelRemeshOptions, type WeldReport, type WorkerAlignDomain, type WorkerBooleanDomain, type WorkerDeformDomain, type WorkerInspectDomain, type WorkerRemeshDomain, type WorkerRepairDomain, type WorkerSceneDomains, type WorkerSculptDomain, computeBounds, computeVertexNormals, createAlignDomain, createBooleanDomain, createDeformDomain, createInspectDomain, createRemeshDomain, createRepairDomain, createSculptDomain };
|
package/dist/web.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { n as computeVertexNormals, r as markInitialized, t as computeBounds } from "./api-4kz45-Mq.js";
|
|
2
2
|
import { t as FastMeshError } from "./core-4OcWKu3r.js";
|
|
3
|
-
import {
|
|
3
|
+
import { _ as createBooleanDomain, f as createSculptDomain, g as createDeformDomain, h as createInspectDomain, m as createRemeshDomain, p as createRepairDomain, v as createAlignDomain } from "./views-BSy-Qeg8.js";
|
|
4
|
+
import { t as Scene } from "./scene-DUsj6uJD.js";
|
|
4
5
|
import wasmInit from "./wasm/fast_mesh_wasm.js";
|
|
5
6
|
// src/web.ts
|
|
6
7
|
let ready;
|
|
@@ -15,4 +16,4 @@ function init(input) {
|
|
|
15
16
|
ready ??= wasmInit(input === void 0 ? void 0 : { module_or_path: input }).then(markInitialized);
|
|
16
17
|
return ready;
|
|
17
18
|
}
|
|
18
|
-
export { FastMeshError, Scene, computeBounds, computeVertexNormals, init };
|
|
19
|
+
export { FastMeshError, Scene, computeBounds, computeVertexNormals, createAlignDomain, createBooleanDomain, createDeformDomain, createInspectDomain, createRemeshDomain, createRepairDomain, createSculptDomain, init };
|
package/dist/worker-engine.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as WorkerMessage, i as Result, n as InitMessage, r as Request, t as ClientId } from "./protocol-
|
|
1
|
+
import { a as WorkerMessage, i as Result, n as InitMessage, r as Request, t as ClientId } from "./protocol-DFR0JDAS.js";
|
|
2
2
|
import { WasmScene } from "./wasm/fast_mesh_wasm.js";
|
|
3
3
|
/** What the engine needs of a wasm-bindgen glue module. */
|
|
4
4
|
interface Glue {
|
|
@@ -158,7 +158,9 @@ export interface EngineOptions {
|
|
|
158
158
|
* completed, a queued drag move no longer abandons the unit: it completes
|
|
159
159
|
* and is published, and the newest pose follows. So a sustained drag whose
|
|
160
160
|
* recompute outlasts the gaps between moves still updates its colours
|
|
161
|
-
* about every guard plus one recompute, each update exactly one pose.
|
|
161
|
+
* about every guard plus one recompute, each update exactly one pose. At
|
|
162
|
+
* the default of 0 a move never abandons a unit: every recompute that
|
|
163
|
+
* starts is shown, so its time alone sets the update rate.
|
|
162
164
|
* Edits, repairs, compactions, removals, placements, undo, redo and drag
|
|
163
165
|
* cancels always abandon, and so do drag moves once the drag's `end` is
|
|
164
166
|
* queued (the final pose then follows within one recompute; a pointer
|
|
@@ -203,7 +205,7 @@ export interface EngineOptions {
|
|
|
203
205
|
/** The default {@link EngineOptions.yieldMs}. */
|
|
204
206
|
export declare const YIELD_MS = 4;
|
|
205
207
|
/** The default {@link EngineOptions.staleGuardMs}. */
|
|
206
|
-
export declare const STALE_GUARD_MS =
|
|
208
|
+
export declare const STALE_GUARD_MS = 0;
|
|
207
209
|
/** The default {@link EngineOptions.stepPoints}. */
|
|
208
210
|
export declare const STEP_POINTS = 4096;
|
|
209
211
|
/**
|
package/dist/worker-engine.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as ADD_STEP_WORK, n as BACKGROUND_ADD_TRIANGLES, r as STALE_GUARD_MS, i as STEP_POINTS, a as YIELD_MS, c as loadEngine, u as probeSharedGrowth, o as runEngine, s as serveEngine, l as startEngine } from "./engine-
|
|
1
|
+
export { t as ADD_STEP_WORK, n as BACKGROUND_ADD_TRIANGLES, r as STALE_GUARD_MS, i as STEP_POINTS, a as YIELD_MS, c as loadEngine, u as probeSharedGrowth, o as runEngine, s as serveEngine, l as startEngine } from "./engine-BL5_sWAf.js";
|
package/dist/worker-entry.js
CHANGED
package/dist/worker.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as WorkerSceneOptions, i as WorkerScene, n as MAX_THREADS, o as createWorkerScene, r as WorkerLike, t as KeyStatus } from "./client-
|
|
1
|
+
import { a as WorkerSceneOptions, i as WorkerScene, n as MAX_THREADS, o as createWorkerScene, r as WorkerLike, t as KeyStatus } from "./client-nvmbhtn-.js";
|
|
2
2
|
export { type KeyStatus, MAX_THREADS, type WorkerLike, WorkerScene, type WorkerSceneOptions, createWorkerScene };
|
package/dist/worker.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as MAX_THREADS, n as WorkerScene, i as createWorkerScene } from "./client-
|
|
1
|
+
export { t as MAX_THREADS, n as WorkerScene, i as createWorkerScene } from "./client-DFgvktkT.js";
|
package/package.json
CHANGED
package/dist/views-mp7Mf8CQ.js
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import { c as wasmMemory, n as call, t as FastMeshError } from "./core-4OcWKu3r.js";
|
|
2
|
-
import { n as DEFAULT_NAN, t as DEFAULT_BASE } from "./colormap-Dr5V3bvs.js";
|
|
3
|
-
// src/register.ts
|
|
4
|
-
function invalid$1(message) {
|
|
5
|
-
return new FastMeshError("INVALID_ARGUMENT", message);
|
|
6
|
-
}
|
|
7
|
-
function isNumber(v) {
|
|
8
|
-
return typeof v === "number" && !Number.isNaN(v);
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Throws `INVALID_ARGUMENT` for an option out of range or for one mesh twice.
|
|
12
|
-
* Unset options are valid: they take their defaults.
|
|
13
|
-
*/
|
|
14
|
-
function checkRegisterOptions(sameMesh, o) {
|
|
15
|
-
if (sameMesh) throw invalid$1("cannot register a mesh to itself");
|
|
16
|
-
const { maxIterations: it, tolerance: tol, overlap, maxDistance: far, maxSamples: cap, maxRmse: rmse } = o;
|
|
17
|
-
if (it !== void 0 && !(Number.isInteger(it) && it >= 0)) throw invalid$1("maxIterations must be a non-negative integer");
|
|
18
|
-
if (tol !== void 0 && !(isNumber(tol) && Number.isFinite(tol) && tol >= 0)) throw invalid$1("tolerance must be finite and zero or greater");
|
|
19
|
-
if (overlap !== void 0 && !(isNumber(overlap) && overlap > 0 && overlap <= 1)) throw invalid$1("overlap must be in (0, 1]");
|
|
20
|
-
if (far !== void 0 && !(isNumber(far) && far > 0)) throw invalid$1("maxDistance must be positive");
|
|
21
|
-
if (cap !== void 0 && !(Number.isInteger(cap) && cap >= 1)) throw invalid$1("maxSamples must be a positive integer");
|
|
22
|
-
if (rmse !== void 0 && !(isNumber(rmse) && rmse >= 0)) throw invalid$1("maxRmse must be zero or greater");
|
|
23
|
-
if (o.apply !== void 0 && typeof o.apply !== "boolean") throw invalid$1("apply must be a boolean");
|
|
24
|
-
}
|
|
25
|
-
// src/handles.ts
|
|
26
|
-
/**
|
|
27
|
-
* A mesh in a {@link Scene}. Opaque: pass it to the scene's methods. The same
|
|
28
|
-
* mesh always gives the same handle object, so handles compare with `===`.
|
|
29
|
-
*/
|
|
30
|
-
var MeshHandle = class {};
|
|
31
|
-
/**
|
|
32
|
-
* A field in a {@link Scene}. Opaque and deduplicated like {@link MeshHandle}.
|
|
33
|
-
* The scene keeps every field handle it gave out for its own lifetime, even
|
|
34
|
-
* after the field is removed, so a removal in a change record names the same
|
|
35
|
-
* object you hold.
|
|
36
|
-
*/
|
|
37
|
-
var FieldHandle = class {};
|
|
38
|
-
/**
|
|
39
|
-
* A section in a {@link Scene}. Opaque and deduplicated like {@link MeshHandle},
|
|
40
|
-
* and kept for the scene's lifetime like {@link FieldHandle}.
|
|
41
|
-
*/
|
|
42
|
-
var SectionHandle = class {};
|
|
43
|
-
/** A quaternion as a row-major rotation matrix, normalised first, in f64. */
|
|
44
|
-
function quatToMat3(q) {
|
|
45
|
-
const n = Math.hypot(q[0], q[1], q[2], q[3]);
|
|
46
|
-
if (!(n > 0) || !Number.isFinite(n)) throw new FastMeshError("INVALID_ARGUMENT", "quaternion must be non-zero and finite");
|
|
47
|
-
const x = q[0] / n;
|
|
48
|
-
const y = q[1] / n;
|
|
49
|
-
const z = q[2] / n;
|
|
50
|
-
const w = q[3] / n;
|
|
51
|
-
return [
|
|
52
|
-
1 - 2 * (y * y + z * z),
|
|
53
|
-
2 * (x * y - z * w),
|
|
54
|
-
2 * (x * z + y * w),
|
|
55
|
-
2 * (x * y + z * w),
|
|
56
|
-
1 - 2 * (x * x + z * z),
|
|
57
|
-
2 * (y * z - x * w),
|
|
58
|
-
2 * (x * z - y * w),
|
|
59
|
-
2 * (y * z + x * w),
|
|
60
|
-
1 - 2 * (x * x + y * y)
|
|
61
|
-
];
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* A placement rotation as 9 numbers, row-major (a quaternion converted in
|
|
65
|
-
* f64). Internal: shared with the Worker client, not part of the public API.
|
|
66
|
-
*/
|
|
67
|
-
function rotationMatrix(rotation) {
|
|
68
|
-
if (rotation.length === 4) return quatToMat3(rotation);
|
|
69
|
-
if (rotation.length === 9) return Array.from(rotation);
|
|
70
|
-
throw new FastMeshError("INVALID_ARGUMENT", "rotation must be a 3×3 matrix (9 numbers) or a quaternion (4 numbers)");
|
|
71
|
-
}
|
|
72
|
-
/** A distance field's target or targets (`DistanceFieldDesc.to`), as a list. Internal. */
|
|
73
|
-
function targetsOf(to) {
|
|
74
|
-
return Array.isArray(to) ? to : [to];
|
|
75
|
-
}
|
|
76
|
-
// src/rule.ts
|
|
77
|
-
const MAPS = {
|
|
78
|
-
turbo: 0,
|
|
79
|
-
viridis: 1,
|
|
80
|
-
coolwarm: 2,
|
|
81
|
-
grayscale: 3
|
|
82
|
-
};
|
|
83
|
-
const OUT_OF_RANGE = {
|
|
84
|
-
clamp: 0,
|
|
85
|
-
base: 1
|
|
86
|
-
};
|
|
87
|
-
function invalid(message) {
|
|
88
|
-
return new FastMeshError("INVALID_ARGUMENT", message);
|
|
89
|
-
}
|
|
90
|
-
/** The code of a string option in `table`, or `INVALID_ARGUMENT` naming `what`. */
|
|
91
|
-
function codeIn(table, value, what) {
|
|
92
|
-
if (!Object.hasOwn(table, value)) throw invalid(`${what} must be one of ${Object.keys(table).join(", ")}`);
|
|
93
|
-
return table[value];
|
|
94
|
-
}
|
|
95
|
-
/** A colour rule as the binding's `(map, rule)`: see `parse_rule` in the Rust crate. */
|
|
96
|
-
function encodeRule(rule) {
|
|
97
|
-
if (rule.range?.length !== 2) throw invalid("range must be [lo, hi]");
|
|
98
|
-
if (rule.center !== void 0 && Number.isNaN(rule.center)) throw invalid("color center must lie within the range");
|
|
99
|
-
const base = rule.base ?? DEFAULT_BASE;
|
|
100
|
-
const nan = rule.nan ?? DEFAULT_NAN;
|
|
101
|
-
if (base.length !== 4) throw invalid("base must have 4 channels");
|
|
102
|
-
if (nan.length !== 4) throw invalid("nan must have 4 channels");
|
|
103
|
-
const values = [
|
|
104
|
-
rule.range[0],
|
|
105
|
-
rule.range[1],
|
|
106
|
-
rule.center ?? NaN,
|
|
107
|
-
codeIn(OUT_OF_RANGE, rule.below ?? "clamp", "below"),
|
|
108
|
-
codeIn(OUT_OF_RANGE, rule.above ?? "base", "above"),
|
|
109
|
-
...base,
|
|
110
|
-
...nan
|
|
111
|
-
];
|
|
112
|
-
let map;
|
|
113
|
-
if (typeof rule.map === "string") map = codeIn(MAPS, rule.map, "map");
|
|
114
|
-
else if (typeof rule.map === "object" && rule.map !== null && Array.isArray(rule.map.stops)) {
|
|
115
|
-
map = 4;
|
|
116
|
-
for (const stop of rule.map.stops) {
|
|
117
|
-
if (!Array.isArray(stop) || stop.length !== 2) throw invalid("each stop must be [t, rgba]");
|
|
118
|
-
const [t, color] = stop;
|
|
119
|
-
if (typeof color !== "object" || color === null || color.length !== 4) throw invalid("stop colours must have 4 channels");
|
|
120
|
-
values.push(t, ...Array.from(color));
|
|
121
|
-
}
|
|
122
|
-
} else throw invalid("map must be \"turbo\", \"viridis\", \"coolwarm\", \"grayscale\" or { stops }");
|
|
123
|
-
return {
|
|
124
|
-
map,
|
|
125
|
-
values: Float32Array.from(values)
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* A deep, frozen copy of a colour rule (the field handle kept, not frozen):
|
|
130
|
-
* its range and colours, and a custom map's stops with their colours, so
|
|
131
|
-
* later changes to the caller's object do not leak in and callers of
|
|
132
|
-
* `coloring()` cannot change it. Colours given as typed arrays become plain
|
|
133
|
-
* arrays (a typed array cannot be frozen). Copies what it is given; the
|
|
134
|
-
* engine checks it.
|
|
135
|
-
*/
|
|
136
|
-
function copyRule(rule) {
|
|
137
|
-
const frozen = (x) => Array.isArray(x) || ArrayBuffer.isView(x) ? Object.freeze(Array.from(x)) : x;
|
|
138
|
-
const copy = { ...rule };
|
|
139
|
-
for (const [k, v] of Object.entries(copy)) if (k !== "field") copy[k] = frozen(v);
|
|
140
|
-
const stops = rule.map?.stops;
|
|
141
|
-
if (Array.isArray(stops)) copy.map = Object.freeze({ stops: Object.freeze(stops.map((stop) => Array.isArray(stop) ? Object.freeze(stop.map(frozen)) : stop)) });
|
|
142
|
-
return Object.freeze(copy);
|
|
143
|
-
}
|
|
144
|
-
// src/views.ts
|
|
145
|
-
/**
|
|
146
|
-
* Debug-mode check of kept views. The scene bumps the epoch on every call
|
|
147
|
-
* that may allocate or move buffers; a guarded view is a `Proxy` over the
|
|
148
|
-
* typed array that, on every access, warns (once per guard) when the epoch
|
|
149
|
-
* moved since the view was made, or the memory growth detached it.
|
|
150
|
-
*/
|
|
151
|
-
var ViewGuard = class {
|
|
152
|
-
#epoch = 0;
|
|
153
|
-
#warned = false;
|
|
154
|
-
/** A scene call that may allocate or move buffers is about to run. */
|
|
155
|
-
bump() {
|
|
156
|
-
this.#epoch++;
|
|
157
|
-
}
|
|
158
|
-
/** `view`, checked on every access. */
|
|
159
|
-
wrap(view) {
|
|
160
|
-
const born = this.#epoch;
|
|
161
|
-
const attached = view.byteLength > 0;
|
|
162
|
-
const check = () => {
|
|
163
|
-
if (!this.#warned && (this.#epoch !== born || attached && view.byteLength === 0)) {
|
|
164
|
-
this.#warned = true;
|
|
165
|
-
console.warn("fast-mesh-wasm: a render view was read after a scene call that may have moved or freed its buffer, so it may read other data or be empty. Views are only valid until the next scene call: re-acquire them right before use (scene.views(mesh).positions() etc.) and do not keep them.");
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
return new Proxy(view, {
|
|
169
|
-
get(target, key) {
|
|
170
|
-
check();
|
|
171
|
-
const value = Reflect.get(target, key, target);
|
|
172
|
-
return typeof value === "function" ? value.bind(target) : value;
|
|
173
|
-
},
|
|
174
|
-
set(target, key, value) {
|
|
175
|
-
check();
|
|
176
|
-
return Reflect.set(target, key, value, target);
|
|
177
|
-
},
|
|
178
|
-
has(target, key) {
|
|
179
|
-
check();
|
|
180
|
-
return Reflect.has(target, key);
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
/**
|
|
186
|
-
* The views of mesh `(index, generation)`. `scene` returns the live raw scene
|
|
187
|
-
* (it throws once the scene is freed); every getter goes through it.
|
|
188
|
-
*/
|
|
189
|
-
function meshViews(scene, index, generation, guard) {
|
|
190
|
-
const build = (make, ptr, len) => {
|
|
191
|
-
const s = scene();
|
|
192
|
-
const p = call(() => ptr(s));
|
|
193
|
-
if (p === 0) return null;
|
|
194
|
-
const view = make(wasmMemory().buffer, p, call(() => len(s)));
|
|
195
|
-
return guard === void 0 ? view : guard.wrap(view);
|
|
196
|
-
};
|
|
197
|
-
const f32 = (b, p, n) => new Float32Array(b, p, n);
|
|
198
|
-
const u8 = (b, p, n) => new Uint8Array(b, p, n);
|
|
199
|
-
const u32 = (b, p, n) => new Uint32Array(b, p, n);
|
|
200
|
-
return {
|
|
201
|
-
positions: () => build(f32, (s) => s.positions_ptr(index, generation), (s) => s.positions_len(index, generation)),
|
|
202
|
-
normals: () => build(f32, (s) => s.normals_ptr(index, generation), (s) => s.normals_len(index, generation)),
|
|
203
|
-
colors: () => build(u8, (s) => s.colors_ptr(index, generation), (s) => s.colors_len(index, generation)),
|
|
204
|
-
values: () => build(f32, (s) => s.values_ptr(index, generation), (s) => s.values_len(index, generation)),
|
|
205
|
-
uvs: () => build(f32, (s) => s.uvs_ptr(index, generation), (s) => s.uvs_len(index, generation)),
|
|
206
|
-
indices: () => build(u32, (s) => s.indices_ptr(index, generation), (s) => s.indices_len(index, generation))
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
export { FieldHandle as a, rotationMatrix as c, encodeRule as i, targetsOf as l, meshViews as n, MeshHandle as o, copyRule as r, SectionHandle as s, ViewGuard as t, checkRegisterOptions as u };
|