fast-mesh-wasm 0.2.0 → 0.3.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 +488 -1
- package/dist/{api-D0o2HjaU.js → api-BUy7FRx7.js} +11 -11
- package/dist/client-Bp9FRd70.js +2278 -0
- package/dist/client-m2zSdFlu.d.ts +305 -0
- package/dist/colormap-D_xH5hI5.js +303 -0
- package/dist/core-Cke_kZ2e.js +113 -0
- package/dist/core-D2X9GPfK.d.ts +15 -0
- package/dist/engine-B-ZEzR1c.js +1818 -0
- package/dist/mesh-B16gV3oX.d.ts +130 -0
- package/dist/mesh-B8pae8WA.js +428 -0
- package/dist/node.d.ts +3 -2
- package/dist/node.js +5 -4
- package/dist/protocol-CAUYm1gd.js +68 -0
- package/dist/protocol-W9R-iGl5.d.ts +293 -0
- package/dist/r3f.d.ts +59 -0
- package/dist/r3f.js +165 -0
- package/dist/react-CTADh3NN.js +124 -0
- package/dist/react.d.ts +65 -0
- package/dist/react.js +1 -0
- package/dist/scene-BG3EEyfw.js +1243 -0
- package/dist/scene-like-B_3qm0u6.d.ts +925 -0
- package/dist/snapshot-Cf6NgDl7.js +104 -0
- package/dist/store-D3ErV6o-.js +1379 -0
- package/dist/store-DNnHN33A.d.ts +285 -0
- package/dist/store.d.ts +61 -0
- package/dist/store.js +105 -0
- package/dist/three.d.ts +118 -0
- package/dist/three.js +390 -0
- package/dist/views-BaZqBxlX.js +189 -0
- package/dist/wasm/fast_mesh_wasm.d.ts +458 -0
- package/dist/wasm/fast_mesh_wasm.js +1150 -0
- package/dist/wasm/fast_mesh_wasm_bg.wasm +0 -0
- package/dist/wasm/fast_mesh_wasm_bg.wasm.d.ts +74 -0
- package/dist/wasm-threads/fast_mesh_wasm.d.ts +540 -0
- package/dist/wasm-threads/fast_mesh_wasm.js +1513 -0
- package/dist/wasm-threads/fast_mesh_wasm_bg.wasm +0 -0
- package/dist/wasm-threads/fast_mesh_wasm_bg.wasm.d.ts +93 -0
- package/dist/wasm-threads/package.json +7 -0
- package/dist/wasm-threads/snippets/fast-mesh-wasm-ae14781a92c2789e/inline0.js +16 -0
- package/dist/wasm-threads/snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.js +107 -0
- package/dist/web.d.ts +3 -2
- package/dist/web.js +4 -2
- package/dist/worker-engine.d.ts +248 -0
- package/dist/worker-engine.js +1 -0
- package/dist/worker-entry.d.ts +1 -0
- package/dist/worker-entry.js +11 -0
- package/dist/worker.d.ts +2 -0
- package/dist/worker.js +1 -0
- package/package.json +53 -4
- package/dist/api-HcskOwd7.d.ts +0 -43
|
@@ -0,0 +1,1513 @@
|
|
|
1
|
+
/* @ts-self-types="./fast_mesh_wasm.d.ts" */
|
|
2
|
+
import { post_crash, watch_worker } from './snippets/fast-mesh-wasm-ae14781a92c2789e/inline0.js';
|
|
3
|
+
import { startWorkers } from './snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.js';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A scene of editable meshes with render buffers and change records.
|
|
8
|
+
*/
|
|
9
|
+
export class WasmScene {
|
|
10
|
+
__destroy_into_raw() {
|
|
11
|
+
const ptr = this.__wbg_ptr;
|
|
12
|
+
this.__wbg_ptr = 0;
|
|
13
|
+
WasmSceneFinalization.unregister(this);
|
|
14
|
+
return ptr;
|
|
15
|
+
}
|
|
16
|
+
free() {
|
|
17
|
+
const ptr = this.__destroy_into_raw();
|
|
18
|
+
wasm.__wbg_wasmscene_free(ptr, 0);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Drops the open step unit, if any; see [`Scene::abandon_field_step`].
|
|
22
|
+
*/
|
|
23
|
+
abandon_field_step() {
|
|
24
|
+
wasm.wasmscene_abandon_field_step(this.__wbg_ptr);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Adds a signed distance field on mesh `on` to one or more target
|
|
28
|
+
* meshes, given as flat pairs `[on index, on generation, to index, to
|
|
29
|
+
* generation, ...]`, and returns its raw id. `sign` is 0 (auto), 1
|
|
30
|
+
* (pseudonormal) or 2 (winding).
|
|
31
|
+
* @param {string} name
|
|
32
|
+
* @param {Uint32Array} on_to
|
|
33
|
+
* @param {number} max_distance
|
|
34
|
+
* @param {number} sign
|
|
35
|
+
* @returns {number}
|
|
36
|
+
*/
|
|
37
|
+
add_distance_field(name, on_to, max_distance, sign) {
|
|
38
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
39
|
+
const len0 = WASM_VECTOR_LEN;
|
|
40
|
+
const ptr1 = passArray32ToWasm0(on_to, wasm.__wbindgen_malloc);
|
|
41
|
+
const len1 = WASM_VECTOR_LEN;
|
|
42
|
+
const ret = wasm.wasmscene_add_distance_field(this.__wbg_ptr, ptr0, len0, ptr1, len1, max_distance, sign);
|
|
43
|
+
if (ret[2]) {
|
|
44
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
45
|
+
}
|
|
46
|
+
return ret[0] >>> 0;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* [`WasmScene::add_distance_field`] computing nothing yet: the field is
|
|
50
|
+
* due until stepped or updated; see
|
|
51
|
+
* [`Scene::add_distance_field_deferred`].
|
|
52
|
+
* @param {string} name
|
|
53
|
+
* @param {Uint32Array} on_to
|
|
54
|
+
* @param {number} max_distance
|
|
55
|
+
* @param {number} sign
|
|
56
|
+
* @returns {number}
|
|
57
|
+
*/
|
|
58
|
+
add_distance_field_deferred(name, on_to, max_distance, sign) {
|
|
59
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
60
|
+
const len0 = WASM_VECTOR_LEN;
|
|
61
|
+
const ptr1 = passArray32ToWasm0(on_to, wasm.__wbindgen_malloc);
|
|
62
|
+
const len1 = WASM_VECTOR_LEN;
|
|
63
|
+
const ret = wasm.wasmscene_add_distance_field_deferred(this.__wbg_ptr, ptr0, len0, ptr1, len1, max_distance, sign);
|
|
64
|
+
if (ret[2]) {
|
|
65
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
66
|
+
}
|
|
67
|
+
return ret[0] >>> 0;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Adds a mesh from world positions and returns `[index, generation]`.
|
|
71
|
+
* Positions are stored as `p - origin` in `f32`; without `origin` it
|
|
72
|
+
* is the bounding-box centre. `mode` is 0 (Eager), 1 (Lazy) or 2
|
|
73
|
+
* (Manual); `normals` turns vertex normals on. The placement starts as
|
|
74
|
+
* the identity. Nothing is added on error.
|
|
75
|
+
* @param {Float64Array} positions
|
|
76
|
+
* @param {Uint32Array} indices
|
|
77
|
+
* @param {Float64Array | null | undefined} origin
|
|
78
|
+
* @param {number} mode
|
|
79
|
+
* @param {boolean} normals
|
|
80
|
+
* @returns {Uint32Array}
|
|
81
|
+
*/
|
|
82
|
+
add_mesh(positions, indices, origin, mode, normals) {
|
|
83
|
+
const ptr0 = passArrayF64ToWasm0(positions, wasm.__wbindgen_malloc);
|
|
84
|
+
const len0 = WASM_VECTOR_LEN;
|
|
85
|
+
const ptr1 = passArray32ToWasm0(indices, wasm.__wbindgen_malloc);
|
|
86
|
+
const len1 = WASM_VECTOR_LEN;
|
|
87
|
+
var ptr2 = isLikeNone(origin) ? 0 : passArrayF64ToWasm0(origin, wasm.__wbindgen_malloc);
|
|
88
|
+
var len2 = WASM_VECTOR_LEN;
|
|
89
|
+
const ret = wasm.wasmscene_add_mesh(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, mode, normals);
|
|
90
|
+
if (ret[3]) {
|
|
91
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
92
|
+
}
|
|
93
|
+
var v4 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
94
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
95
|
+
return v4;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Builds about `budget` more units of a mesh being added (see
|
|
99
|
+
* `MeshBuild::step`); `true` once its BVH is built. A failed build is
|
|
100
|
+
* dropped.
|
|
101
|
+
* @param {number} build
|
|
102
|
+
* @param {number} budget
|
|
103
|
+
* @returns {boolean}
|
|
104
|
+
*/
|
|
105
|
+
add_mesh_step(build, budget) {
|
|
106
|
+
const ret = wasm.wasmscene_add_mesh_step(this.__wbg_ptr, build, budget);
|
|
107
|
+
if (ret[2]) {
|
|
108
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
109
|
+
}
|
|
110
|
+
return ret[0] !== 0;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Adds a section cutting `meshes` (flat pairs) with the world plane
|
|
114
|
+
* `[origin xyz, normal xyz]`, and returns its raw id.
|
|
115
|
+
* @param {Float64Array} plane
|
|
116
|
+
* @param {Uint32Array} meshes
|
|
117
|
+
* @param {boolean} fill
|
|
118
|
+
* @returns {number}
|
|
119
|
+
*/
|
|
120
|
+
add_section(plane, meshes, fill) {
|
|
121
|
+
const ptr0 = passArrayF64ToWasm0(plane, wasm.__wbindgen_malloc);
|
|
122
|
+
const len0 = WASM_VECTOR_LEN;
|
|
123
|
+
const ptr1 = passArray32ToWasm0(meshes, wasm.__wbindgen_malloc);
|
|
124
|
+
const len1 = WASM_VECTOR_LEN;
|
|
125
|
+
const ret = wasm.wasmscene_add_section(this.__wbg_ptr, ptr0, len0, ptr1, len1, fill);
|
|
126
|
+
if (ret[2]) {
|
|
127
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
128
|
+
}
|
|
129
|
+
return ret[0] >>> 0;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* A read-only report of the mesh's defects, laid out as in
|
|
133
|
+
* [`crate::edit::encode_analysis`]. `weld_tolerance` (local units,
|
|
134
|
+
* equal to world units) groups coincident vertices; lists with a count
|
|
135
|
+
* keep their first `max_listed` entries. `self_intersection` checks
|
|
136
|
+
* for self-intersection with the mesh's BVH, which is brought up to
|
|
137
|
+
* date first unless the mesh is Manual (then `STALE_BVH` when stale).
|
|
138
|
+
* @param {number} index
|
|
139
|
+
* @param {number} generation
|
|
140
|
+
* @param {number} weld_tolerance
|
|
141
|
+
* @param {boolean} self_intersection
|
|
142
|
+
* @param {number} max_listed
|
|
143
|
+
* @returns {Float64Array}
|
|
144
|
+
*/
|
|
145
|
+
analyze(index, generation, weld_tolerance, self_intersection, max_listed) {
|
|
146
|
+
const ret = wasm.wasmscene_analyze(this.__wbg_ptr, index, generation, weld_tolerance, self_intersection, max_listed);
|
|
147
|
+
if (ret[3]) {
|
|
148
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
149
|
+
}
|
|
150
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
151
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
152
|
+
return v1;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* [`WasmScene::add_mesh`] in steps: starts building the mesh and its
|
|
156
|
+
* BVH outside the scene ([`MeshBuild`]) and returns the build's id, for
|
|
157
|
+
* [`WasmScene::add_mesh_step`] and [`WasmScene::finish_add_mesh`]. The
|
|
158
|
+
* scene is unchanged until the mesh is added.
|
|
159
|
+
* @param {Float64Array} positions
|
|
160
|
+
* @param {Uint32Array} indices
|
|
161
|
+
* @param {Float64Array | null | undefined} origin
|
|
162
|
+
* @param {number} mode
|
|
163
|
+
* @param {boolean} normals
|
|
164
|
+
* @returns {number}
|
|
165
|
+
*/
|
|
166
|
+
begin_add_mesh(positions, indices, origin, mode, normals) {
|
|
167
|
+
const ptr0 = passArrayF64ToWasm0(positions, wasm.__wbindgen_malloc);
|
|
168
|
+
const len0 = WASM_VECTOR_LEN;
|
|
169
|
+
const ptr1 = passArray32ToWasm0(indices, wasm.__wbindgen_malloc);
|
|
170
|
+
const len1 = WASM_VECTOR_LEN;
|
|
171
|
+
var ptr2 = isLikeNone(origin) ? 0 : passArrayF64ToWasm0(origin, wasm.__wbindgen_malloc);
|
|
172
|
+
var len2 = WASM_VECTOR_LEN;
|
|
173
|
+
const ret = wasm.wasmscene_begin_add_mesh(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, mode, normals);
|
|
174
|
+
if (ret[2]) {
|
|
175
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
176
|
+
}
|
|
177
|
+
return ret[0] >>> 0;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Opens a history step, or one more nesting level of the open one.
|
|
181
|
+
*/
|
|
182
|
+
begin_step() {
|
|
183
|
+
wasm.wasmscene_begin_step(this.__wbg_ptr);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* True if `redo` would redo something.
|
|
187
|
+
* @returns {boolean}
|
|
188
|
+
*/
|
|
189
|
+
can_redo() {
|
|
190
|
+
const ret = wasm.wasmscene_can_redo(this.__wbg_ptr);
|
|
191
|
+
return ret !== 0;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* True if `undo` would undo something.
|
|
195
|
+
* @returns {boolean}
|
|
196
|
+
*/
|
|
197
|
+
can_undo() {
|
|
198
|
+
const ret = wasm.wasmscene_can_undo(this.__wbg_ptr);
|
|
199
|
+
return ret !== 0;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Reverts and discards the open step.
|
|
203
|
+
*/
|
|
204
|
+
cancel_step() {
|
|
205
|
+
const ret = wasm.wasmscene_cancel_step(this.__wbg_ptr);
|
|
206
|
+
if (ret[1]) {
|
|
207
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Stops colouring a mesh. Not recorded in history.
|
|
212
|
+
* @param {number} index
|
|
213
|
+
* @param {number} generation
|
|
214
|
+
*/
|
|
215
|
+
clear_coloring(index, generation) {
|
|
216
|
+
const ret = wasm.wasmscene_clear_coloring(this.__wbg_ptr, index, generation);
|
|
217
|
+
if (ret[1]) {
|
|
218
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Drops every undo and redo step.
|
|
223
|
+
*/
|
|
224
|
+
clear_history() {
|
|
225
|
+
const ret = wasm.wasmscene_clear_history(this.__wbg_ptr);
|
|
226
|
+
if (ret[1]) {
|
|
227
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* The point of the scene nearest to world point `p` within
|
|
232
|
+
* `max_distance`. Empty when none, else `[index, generation, triangle,
|
|
233
|
+
* point xyz, distance]`.
|
|
234
|
+
* @param {Float64Array} p
|
|
235
|
+
* @param {number} max_distance
|
|
236
|
+
* @returns {Float64Array}
|
|
237
|
+
*/
|
|
238
|
+
closest_point(p, max_distance) {
|
|
239
|
+
const ptr0 = passArrayF64ToWasm0(p, wasm.__wbindgen_malloc);
|
|
240
|
+
const len0 = WASM_VECTOR_LEN;
|
|
241
|
+
const ret = wasm.wasmscene_closest_point(this.__wbg_ptr, ptr0, len0, max_distance);
|
|
242
|
+
if (ret[3]) {
|
|
243
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
244
|
+
}
|
|
245
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
246
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
247
|
+
return v2;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* [`WasmScene::closest_point`] on one mesh.
|
|
251
|
+
* @param {number} index
|
|
252
|
+
* @param {number} generation
|
|
253
|
+
* @param {Float64Array} p
|
|
254
|
+
* @param {number} max_distance
|
|
255
|
+
* @returns {Float64Array}
|
|
256
|
+
*/
|
|
257
|
+
closest_point_on(index, generation, p, max_distance) {
|
|
258
|
+
const ptr0 = passArrayF64ToWasm0(p, wasm.__wbindgen_malloc);
|
|
259
|
+
const len0 = WASM_VECTOR_LEN;
|
|
260
|
+
const ret = wasm.wasmscene_closest_point_on(this.__wbg_ptr, index, generation, ptr0, len0, max_distance);
|
|
261
|
+
if (ret[3]) {
|
|
262
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
263
|
+
}
|
|
264
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
265
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
266
|
+
return v2;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Length of the colours in bytes, 0 when the mesh has no colouring.
|
|
270
|
+
* @param {number} index
|
|
271
|
+
* @param {number} generation
|
|
272
|
+
* @returns {number}
|
|
273
|
+
*/
|
|
274
|
+
colors_len(index, generation) {
|
|
275
|
+
const ret = wasm.wasmscene_colors_len(this.__wbg_ptr, index, generation);
|
|
276
|
+
if (ret[2]) {
|
|
277
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
278
|
+
}
|
|
279
|
+
return ret[0] >>> 0;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Address of the colours (RGBA8, 4 bytes per vertex slot), 0 when the
|
|
283
|
+
* mesh has no colouring.
|
|
284
|
+
* @param {number} index
|
|
285
|
+
* @param {number} generation
|
|
286
|
+
* @returns {number}
|
|
287
|
+
*/
|
|
288
|
+
colors_ptr(index, generation) {
|
|
289
|
+
const ret = wasm.wasmscene_colors_ptr(this.__wbg_ptr, index, generation);
|
|
290
|
+
if (ret[2]) {
|
|
291
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
292
|
+
}
|
|
293
|
+
return ret[0] >>> 0;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Removes the mesh's dead slots and renumbers the rest. Its next change
|
|
297
|
+
* record reports every buffer as "all", with the capacity change; its
|
|
298
|
+
* edits leave the history (placements stay).
|
|
299
|
+
* @param {number} index
|
|
300
|
+
* @param {number} generation
|
|
301
|
+
*/
|
|
302
|
+
compact(index, generation) {
|
|
303
|
+
const ret = wasm.wasmscene_compact(this.__wbg_ptr, index, generation);
|
|
304
|
+
if (ret[1]) {
|
|
305
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Drops a mesh being added in steps (nothing was added).
|
|
310
|
+
* @param {number} build
|
|
311
|
+
*/
|
|
312
|
+
drop_add_mesh(build) {
|
|
313
|
+
wasm.wasmscene_drop_add_mesh(this.__wbg_ptr, build);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Runs an edit op list on a mesh as one transaction: one undo step, and
|
|
317
|
+
* nothing changes when an op fails. `ops` and `values` are laid out as
|
|
318
|
+
* in [`crate::edit`]: `ops` is a `u32` sequence of op codes (0 set
|
|
319
|
+
* positions, 1 add vertices, 2 add triangles, 3 remove triangles, 4
|
|
320
|
+
* remove vertices) with their id lists, whose refs name ids added by
|
|
321
|
+
* earlier ops of the list; `values` holds the world positions, mapped
|
|
322
|
+
* to local with the placement inverse and the origin in `f64`, then
|
|
323
|
+
* stored as `f32`. Returns `[n, id × n]` per op: the new vertex or
|
|
324
|
+
* triangle ids, none for the other ops. The list is decoded and every
|
|
325
|
+
* ref checked before the mesh is touched.
|
|
326
|
+
* @param {number} index
|
|
327
|
+
* @param {number} generation
|
|
328
|
+
* @param {Uint32Array} ops
|
|
329
|
+
* @param {Float64Array} values
|
|
330
|
+
* @returns {Uint32Array}
|
|
331
|
+
*/
|
|
332
|
+
edit(index, generation, ops, values) {
|
|
333
|
+
const ptr0 = passArray32ToWasm0(ops, wasm.__wbindgen_malloc);
|
|
334
|
+
const len0 = WASM_VECTOR_LEN;
|
|
335
|
+
const ptr1 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
|
|
336
|
+
const len1 = WASM_VECTOR_LEN;
|
|
337
|
+
const ret = wasm.wasmscene_edit(this.__wbg_ptr, index, generation, ptr0, len0, ptr1, len1);
|
|
338
|
+
if (ret[3]) {
|
|
339
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
340
|
+
}
|
|
341
|
+
var v3 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
342
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
343
|
+
return v3;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Ends one nesting level of the open step.
|
|
347
|
+
*/
|
|
348
|
+
end_step() {
|
|
349
|
+
const ret = wasm.wasmscene_end_step(this.__wbg_ptr);
|
|
350
|
+
if (ret[1]) {
|
|
351
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* A copy of the field's nearest-target indices, one per value (see
|
|
356
|
+
* [`Scene::field_nearest`]): `u32::MAX` for none, including slots
|
|
357
|
+
* added since the field's last update.
|
|
358
|
+
* @param {number} field
|
|
359
|
+
* @returns {Uint32Array}
|
|
360
|
+
*/
|
|
361
|
+
field_nearest(field) {
|
|
362
|
+
const ret = wasm.wasmscene_field_nearest(this.__wbg_ptr, field);
|
|
363
|
+
if (ret[3]) {
|
|
364
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
365
|
+
}
|
|
366
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
367
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
368
|
+
return v1;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* `[current (0/1), sign mode (1 pseudonormal, 2 winding), closed,
|
|
372
|
+
* consistent orientation, non-manifold vertices, degenerate
|
|
373
|
+
* triangles]`, the sign part over every target together (see
|
|
374
|
+
* [`fast_mesh_scene::FieldStatus::sign`]).
|
|
375
|
+
* @param {number} field
|
|
376
|
+
* @returns {Uint32Array}
|
|
377
|
+
*/
|
|
378
|
+
field_status(field) {
|
|
379
|
+
const ret = wasm.wasmscene_field_status(this.__wbg_ptr, field);
|
|
380
|
+
if (ret[3]) {
|
|
381
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
382
|
+
}
|
|
383
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
384
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
385
|
+
return v1;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Computes up to `points` candidate vertices of the due Eager fields,
|
|
389
|
+
* opening a unit first if none is open; see [`Scene::field_step`].
|
|
390
|
+
* Returns 0 (idle: nothing was due), 1 (pending) or 2 (done: the unit
|
|
391
|
+
* was applied). An error also ends the unit: the fields that could be
|
|
392
|
+
* applied were.
|
|
393
|
+
* @param {number} points
|
|
394
|
+
* @returns {number}
|
|
395
|
+
*/
|
|
396
|
+
field_step(points) {
|
|
397
|
+
const ret = wasm.wasmscene_field_step(this.__wbg_ptr, points);
|
|
398
|
+
if (ret[2]) {
|
|
399
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
400
|
+
}
|
|
401
|
+
return ret[0];
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* [`WasmScene::field_step`] for one field alone; see
|
|
405
|
+
* [`Scene::field_step_field`]. Returns 0 (idle: the field is current),
|
|
406
|
+
* 1 (pending) or 2 (done).
|
|
407
|
+
* @param {number} field
|
|
408
|
+
* @param {number} points
|
|
409
|
+
* @returns {number}
|
|
410
|
+
*/
|
|
411
|
+
field_step_field(field, points) {
|
|
412
|
+
const ret = wasm.wasmscene_field_step_field(this.__wbg_ptr, field, points);
|
|
413
|
+
if (ret[2]) {
|
|
414
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
415
|
+
}
|
|
416
|
+
return ret[0];
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* The meshes of the open step unit's fields as flat `[index,
|
|
420
|
+
* generation, ...]` pairs, each once; empty when no unit is open.
|
|
421
|
+
* @returns {Uint32Array}
|
|
422
|
+
*/
|
|
423
|
+
field_step_meshes() {
|
|
424
|
+
const ret = wasm.wasmscene_field_step_meshes(this.__wbg_ptr);
|
|
425
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
426
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
427
|
+
return v1;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* What the sign data found out about each target, in index order: five
|
|
431
|
+
* numbers per target, `[mode, closed, consistent orientation,
|
|
432
|
+
* non-manifold vertices, degenerate triangles]` as in
|
|
433
|
+
* [`WasmScene::field_status`].
|
|
434
|
+
* @param {number} field
|
|
435
|
+
* @returns {Uint32Array}
|
|
436
|
+
*/
|
|
437
|
+
field_target_status(field) {
|
|
438
|
+
const ret = wasm.wasmscene_field_target_status(this.__wbg_ptr, field);
|
|
439
|
+
if (ret[3]) {
|
|
440
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
441
|
+
}
|
|
442
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
443
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
444
|
+
return v1;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* The field's target meshes as flat `[index, generation, ...]` pairs,
|
|
448
|
+
* in target index order (see [`Scene::field_targets`]).
|
|
449
|
+
* @param {number} field
|
|
450
|
+
* @returns {Uint32Array}
|
|
451
|
+
*/
|
|
452
|
+
field_targets(field) {
|
|
453
|
+
const ret = wasm.wasmscene_field_targets(this.__wbg_ptr, field);
|
|
454
|
+
if (ret[3]) {
|
|
455
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
456
|
+
}
|
|
457
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
458
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
459
|
+
return v1;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Length of the field's values in `f32`s.
|
|
463
|
+
* @param {number} field
|
|
464
|
+
* @returns {number}
|
|
465
|
+
*/
|
|
466
|
+
field_values_len(field) {
|
|
467
|
+
const ret = wasm.wasmscene_field_values_len(this.__wbg_ptr, field);
|
|
468
|
+
if (ret[2]) {
|
|
469
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
470
|
+
}
|
|
471
|
+
return ret[0] >>> 0;
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Address of the field's values (`f32`, one per vertex slot of its
|
|
475
|
+
* mesh).
|
|
476
|
+
* @param {number} field
|
|
477
|
+
* @returns {number}
|
|
478
|
+
*/
|
|
479
|
+
field_values_ptr(field) {
|
|
480
|
+
const ret = wasm.wasmscene_field_values_ptr(this.__wbg_ptr, field);
|
|
481
|
+
if (ret[2]) {
|
|
482
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
483
|
+
}
|
|
484
|
+
return ret[0] >>> 0;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* The mesh pairs within `margin` of each other, of `pairs` (flat
|
|
488
|
+
* `[a index, a generation, b index, b generation, ...]`) or of the
|
|
489
|
+
* whole scene. `[count, contact...]`, each contact `[a index, a
|
|
490
|
+
* generation, b index, b generation, intersecting (0/1), distance,
|
|
491
|
+
* triangle count of a, of b, triangles of a..., triangles of b...]`.
|
|
492
|
+
* @param {number} margin
|
|
493
|
+
* @param {Uint32Array | null} [pairs]
|
|
494
|
+
* @returns {Float64Array}
|
|
495
|
+
*/
|
|
496
|
+
find_contacts(margin, pairs) {
|
|
497
|
+
var ptr0 = isLikeNone(pairs) ? 0 : passArray32ToWasm0(pairs, wasm.__wbindgen_malloc);
|
|
498
|
+
var len0 = WASM_VECTOR_LEN;
|
|
499
|
+
const ret = wasm.wasmscene_find_contacts(this.__wbg_ptr, margin, ptr0, len0);
|
|
500
|
+
if (ret[3]) {
|
|
501
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
502
|
+
}
|
|
503
|
+
var v2 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
504
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
505
|
+
return v2;
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Adds a mesh built in steps, finishing what is left of its BVH, and
|
|
509
|
+
* returns `[index, generation]`, as [`WasmScene::add_mesh`] would.
|
|
510
|
+
* @param {number} build
|
|
511
|
+
* @returns {Uint32Array}
|
|
512
|
+
*/
|
|
513
|
+
finish_add_mesh(build) {
|
|
514
|
+
const ret = wasm.wasmscene_finish_add_mesh(this.__wbg_ptr, build);
|
|
515
|
+
if (ret[3]) {
|
|
516
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
517
|
+
}
|
|
518
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
519
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
520
|
+
return v1;
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Brings every non-Manual mesh up to date.
|
|
524
|
+
*/
|
|
525
|
+
flush() {
|
|
526
|
+
const ret = wasm.wasmscene_flush(this.__wbg_ptr);
|
|
527
|
+
if (ret[1]) {
|
|
528
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Length of the index buffer in `u32`s.
|
|
533
|
+
* @param {number} index
|
|
534
|
+
* @param {number} generation
|
|
535
|
+
* @returns {number}
|
|
536
|
+
*/
|
|
537
|
+
indices_len(index, generation) {
|
|
538
|
+
const ret = wasm.wasmscene_indices_len(this.__wbg_ptr, index, generation);
|
|
539
|
+
if (ret[2]) {
|
|
540
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
541
|
+
}
|
|
542
|
+
return ret[0] >>> 0;
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Address of the index buffer (`u32`, 3 per triangle slot; a removed
|
|
546
|
+
* triangle reads `0, 0, 0`).
|
|
547
|
+
* @param {number} index
|
|
548
|
+
* @param {number} generation
|
|
549
|
+
* @returns {number}
|
|
550
|
+
*/
|
|
551
|
+
indices_ptr(index, generation) {
|
|
552
|
+
const ret = wasm.wasmscene_indices_ptr(this.__wbg_ptr, index, generation);
|
|
553
|
+
if (ret[2]) {
|
|
554
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
555
|
+
}
|
|
556
|
+
return ret[0] >>> 0;
|
|
557
|
+
}
|
|
558
|
+
/**
|
|
559
|
+
* Whether two meshes intersect or touch as placed.
|
|
560
|
+
* @param {number} a_index
|
|
561
|
+
* @param {number} a_generation
|
|
562
|
+
* @param {number} b_index
|
|
563
|
+
* @param {number} b_generation
|
|
564
|
+
* @returns {boolean}
|
|
565
|
+
*/
|
|
566
|
+
intersects(a_index, a_generation, b_index, b_generation) {
|
|
567
|
+
const ret = wasm.wasmscene_intersects(this.__wbg_ptr, a_index, a_generation, b_index, b_generation);
|
|
568
|
+
if (ret[2]) {
|
|
569
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
570
|
+
}
|
|
571
|
+
return ret[0] !== 0;
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* The world matrix of the local render coordinates,
|
|
575
|
+
* `placement · translate(origin)`, column-major (16 values).
|
|
576
|
+
* @param {number} index
|
|
577
|
+
* @param {number} generation
|
|
578
|
+
* @returns {Float64Array}
|
|
579
|
+
*/
|
|
580
|
+
matrix4(index, generation) {
|
|
581
|
+
const ret = wasm.wasmscene_matrix4(this.__wbg_ptr, index, generation);
|
|
582
|
+
if (ret[3]) {
|
|
583
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
584
|
+
}
|
|
585
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
586
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
587
|
+
return v1;
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* The distance between two meshes' surfaces as placed. Empty when it
|
|
591
|
+
* exceeds `max_distance` or a mesh has no triangle, else `[distance,
|
|
592
|
+
* point on a xyz, point on b xyz, triangle of a, triangle of b]`.
|
|
593
|
+
* @param {number} a_index
|
|
594
|
+
* @param {number} a_generation
|
|
595
|
+
* @param {number} b_index
|
|
596
|
+
* @param {number} b_generation
|
|
597
|
+
* @param {number} max_distance
|
|
598
|
+
* @returns {Float64Array}
|
|
599
|
+
*/
|
|
600
|
+
mesh_distance(a_index, a_generation, b_index, b_generation, max_distance) {
|
|
601
|
+
const ret = wasm.wasmscene_mesh_distance(this.__wbg_ptr, a_index, a_generation, b_index, b_generation, max_distance);
|
|
602
|
+
if (ret[3]) {
|
|
603
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
604
|
+
}
|
|
605
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
606
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
607
|
+
return v1;
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* An empty scene with the default history budget.
|
|
611
|
+
*/
|
|
612
|
+
constructor() {
|
|
613
|
+
const ret = wasm.wasmscene_new();
|
|
614
|
+
this.__wbg_ptr = ret;
|
|
615
|
+
WasmSceneFinalization.register(this, this.__wbg_ptr, this);
|
|
616
|
+
return this;
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Length of the normals in `f32`s, 0 when they are off. After the
|
|
620
|
+
* scene ran out of memory it may differ from 3 · vertex slots until
|
|
621
|
+
* the next successful update.
|
|
622
|
+
* @param {number} index
|
|
623
|
+
* @param {number} generation
|
|
624
|
+
* @returns {number}
|
|
625
|
+
*/
|
|
626
|
+
normals_len(index, generation) {
|
|
627
|
+
const ret = wasm.wasmscene_normals_len(this.__wbg_ptr, index, generation);
|
|
628
|
+
if (ret[2]) {
|
|
629
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
630
|
+
}
|
|
631
|
+
return ret[0] >>> 0;
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Address of the normals (`f32`, 3 per vertex slot), 0 when they are
|
|
635
|
+
* off.
|
|
636
|
+
* @param {number} index
|
|
637
|
+
* @param {number} generation
|
|
638
|
+
* @returns {number}
|
|
639
|
+
*/
|
|
640
|
+
normals_ptr(index, generation) {
|
|
641
|
+
const ret = wasm.wasmscene_normals_ptr(this.__wbg_ptr, index, generation);
|
|
642
|
+
if (ret[2]) {
|
|
643
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
644
|
+
}
|
|
645
|
+
return ret[0] >>> 0;
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* The placement: the row-major rotation (9 values), then the
|
|
649
|
+
* translation (3 values).
|
|
650
|
+
* @param {number} index
|
|
651
|
+
* @param {number} generation
|
|
652
|
+
* @returns {Float64Array}
|
|
653
|
+
*/
|
|
654
|
+
placement(index, generation) {
|
|
655
|
+
const ret = wasm.wasmscene_placement(this.__wbg_ptr, index, generation);
|
|
656
|
+
if (ret[3]) {
|
|
657
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
658
|
+
}
|
|
659
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
660
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
661
|
+
return v1;
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Length of the positions in `f32`s.
|
|
665
|
+
* @param {number} index
|
|
666
|
+
* @param {number} generation
|
|
667
|
+
* @returns {number}
|
|
668
|
+
*/
|
|
669
|
+
positions_len(index, generation) {
|
|
670
|
+
const ret = wasm.wasmscene_positions_len(this.__wbg_ptr, index, generation);
|
|
671
|
+
if (ret[2]) {
|
|
672
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
673
|
+
}
|
|
674
|
+
return ret[0] >>> 0;
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Address of the local positions (`f32`, 3 per vertex slot).
|
|
678
|
+
* @param {number} index
|
|
679
|
+
* @param {number} generation
|
|
680
|
+
* @returns {number}
|
|
681
|
+
*/
|
|
682
|
+
positions_ptr(index, generation) {
|
|
683
|
+
const ret = wasm.wasmscene_positions_ptr(this.__wbg_ptr, index, generation);
|
|
684
|
+
if (ret[2]) {
|
|
685
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
686
|
+
}
|
|
687
|
+
return ret[0] >>> 0;
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* The nearest hit of a world ray over every mesh with
|
|
691
|
+
* `min_distance <= t <= max_distance`; `cull` is 0 (none), 1 (back
|
|
692
|
+
* faces) or 2 (front faces). Empty on a miss, else `[index,
|
|
693
|
+
* generation, triangle, point xyz, distance, barycentric uvw]`.
|
|
694
|
+
* @param {Float64Array} origin
|
|
695
|
+
* @param {Float64Array} direction
|
|
696
|
+
* @param {number} min_distance
|
|
697
|
+
* @param {number} max_distance
|
|
698
|
+
* @param {number} cull
|
|
699
|
+
* @returns {Float64Array}
|
|
700
|
+
*/
|
|
701
|
+
raycast(origin, direction, min_distance, max_distance, cull) {
|
|
702
|
+
const ptr0 = passArrayF64ToWasm0(origin, wasm.__wbindgen_malloc);
|
|
703
|
+
const len0 = WASM_VECTOR_LEN;
|
|
704
|
+
const ptr1 = passArrayF64ToWasm0(direction, wasm.__wbindgen_malloc);
|
|
705
|
+
const len1 = WASM_VECTOR_LEN;
|
|
706
|
+
const ret = wasm.wasmscene_raycast(this.__wbg_ptr, ptr0, len0, ptr1, len1, min_distance, max_distance, cull);
|
|
707
|
+
if (ret[3]) {
|
|
708
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
709
|
+
}
|
|
710
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
711
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
712
|
+
return v3;
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* Redoes the latest undone step; false when there is nothing to redo.
|
|
716
|
+
* @returns {boolean}
|
|
717
|
+
*/
|
|
718
|
+
redo() {
|
|
719
|
+
const ret = wasm.wasmscene_redo(this.__wbg_ptr);
|
|
720
|
+
if (ret[2]) {
|
|
721
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
722
|
+
}
|
|
723
|
+
return ret[0] !== 0;
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* Removes a field (and a colouring by it).
|
|
727
|
+
* @param {number} field
|
|
728
|
+
*/
|
|
729
|
+
remove_field(field) {
|
|
730
|
+
const ret = wasm.wasmscene_remove_field(this.__wbg_ptr, field);
|
|
731
|
+
if (ret[1]) {
|
|
732
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* Removes a mesh; its id never matches again.
|
|
737
|
+
* @param {number} index
|
|
738
|
+
* @param {number} generation
|
|
739
|
+
*/
|
|
740
|
+
remove_mesh(index, generation) {
|
|
741
|
+
const ret = wasm.wasmscene_remove_mesh(this.__wbg_ptr, index, generation);
|
|
742
|
+
if (ret[1]) {
|
|
743
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
/**
|
|
747
|
+
* Removes a section.
|
|
748
|
+
* @param {number} section
|
|
749
|
+
*/
|
|
750
|
+
remove_section(section) {
|
|
751
|
+
const ret = wasm.wasmscene_remove_section(this.__wbg_ptr, section);
|
|
752
|
+
if (ret[1]) {
|
|
753
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* Runs repair operations on a mesh, in order, in one transaction: one
|
|
758
|
+
* undo step, and nothing changes when an operation fails. `ops` (`f64`)
|
|
759
|
+
* and `loops` (`u32`, loop ids for fill holes) are laid out as in
|
|
760
|
+
* [`crate::edit`]; returns the reports concatenated in op order.
|
|
761
|
+
* Lengths and areas in the options are in local units, equal to world
|
|
762
|
+
* units.
|
|
763
|
+
* @param {number} index
|
|
764
|
+
* @param {number} generation
|
|
765
|
+
* @param {Float64Array} ops
|
|
766
|
+
* @param {Uint32Array} loops
|
|
767
|
+
* @returns {Float64Array}
|
|
768
|
+
*/
|
|
769
|
+
repair(index, generation, ops, loops) {
|
|
770
|
+
const ptr0 = passArrayF64ToWasm0(ops, wasm.__wbindgen_malloc);
|
|
771
|
+
const len0 = WASM_VECTOR_LEN;
|
|
772
|
+
const ptr1 = passArray32ToWasm0(loops, wasm.__wbindgen_malloc);
|
|
773
|
+
const len1 = WASM_VECTOR_LEN;
|
|
774
|
+
const ret = wasm.wasmscene_repair(this.__wbg_ptr, index, generation, ptr0, len0, ptr1, len1);
|
|
775
|
+
if (ret[3]) {
|
|
776
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
777
|
+
}
|
|
778
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
779
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
780
|
+
return v3;
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* A section's result for a mesh, in world coordinates: `[status (0
|
|
784
|
+
* current, 1 stale), length, area, contour count, contour..., has fill
|
|
785
|
+
* (0/1), fill]`. Each contour is `[closed (0/1), point count, xyz...]`;
|
|
786
|
+
* the fill is `[point count, xyz..., triangle count, abc...]`.
|
|
787
|
+
* @param {number} section
|
|
788
|
+
* @param {number} index
|
|
789
|
+
* @param {number} generation
|
|
790
|
+
* @returns {Float64Array}
|
|
791
|
+
*/
|
|
792
|
+
section(section, index, generation) {
|
|
793
|
+
const ret = wasm.wasmscene_section(this.__wbg_ptr, section, index, generation);
|
|
794
|
+
if (ret[3]) {
|
|
795
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
796
|
+
}
|
|
797
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
798
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
799
|
+
return v1;
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* A section's plane as last set, `[origin xyz, normal xyz]`, the normal
|
|
803
|
+
* normalised.
|
|
804
|
+
* @param {number} section
|
|
805
|
+
* @returns {Float64Array}
|
|
806
|
+
*/
|
|
807
|
+
section_desc_plane(section) {
|
|
808
|
+
const ret = wasm.wasmscene_section_desc_plane(this.__wbg_ptr, section);
|
|
809
|
+
if (ret[3]) {
|
|
810
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
811
|
+
}
|
|
812
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
813
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
814
|
+
return v1;
|
|
815
|
+
}
|
|
816
|
+
/**
|
|
817
|
+
* The closest pair between two meshes' contours in a section. Empty
|
|
818
|
+
* when there is none, else `[distance, point on a xyz, point on b
|
|
819
|
+
* xyz]`.
|
|
820
|
+
* @param {number} section
|
|
821
|
+
* @param {number} a_index
|
|
822
|
+
* @param {number} a_generation
|
|
823
|
+
* @param {number} b_index
|
|
824
|
+
* @param {number} b_generation
|
|
825
|
+
* @returns {Float64Array}
|
|
826
|
+
*/
|
|
827
|
+
section_gap(section, a_index, a_generation, b_index, b_generation) {
|
|
828
|
+
const ret = wasm.wasmscene_section_gap(this.__wbg_ptr, section, a_index, a_generation, b_index, b_generation);
|
|
829
|
+
if (ret[3]) {
|
|
830
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
831
|
+
}
|
|
832
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
833
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
834
|
+
return v1;
|
|
835
|
+
}
|
|
836
|
+
/**
|
|
837
|
+
* Colours a mesh from one of its fields; see [`parse_rule`] for `map`
|
|
838
|
+
* and `rule`. A display setting: not recorded in history.
|
|
839
|
+
* @param {number} index
|
|
840
|
+
* @param {number} generation
|
|
841
|
+
* @param {number} field
|
|
842
|
+
* @param {number} map
|
|
843
|
+
* @param {Float32Array} rule
|
|
844
|
+
*/
|
|
845
|
+
set_coloring(index, generation, field, map, rule) {
|
|
846
|
+
const ptr0 = passArrayF32ToWasm0(rule, wasm.__wbindgen_malloc);
|
|
847
|
+
const len0 = WASM_VECTOR_LEN;
|
|
848
|
+
const ret = wasm.wasmscene_set_coloring(this.__wbg_ptr, index, generation, field, map, ptr0, len0);
|
|
849
|
+
if (ret[1]) {
|
|
850
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* Defers Eager field updates to [`WasmScene::field_step`]; see
|
|
855
|
+
* [`Scene::set_defer_fields`].
|
|
856
|
+
* @param {boolean} on
|
|
857
|
+
*/
|
|
858
|
+
set_defer_fields(on) {
|
|
859
|
+
wasm.wasmscene_set_defer_fields(this.__wbg_ptr, on);
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Sets when the mesh's BVH, normals, fields and sections follow its
|
|
863
|
+
* edits: 0 (Eager), 1 (Lazy) or 2 (Manual).
|
|
864
|
+
* @param {number} index
|
|
865
|
+
* @param {number} generation
|
|
866
|
+
* @param {number} mode
|
|
867
|
+
*/
|
|
868
|
+
set_mode(index, generation, mode) {
|
|
869
|
+
const ret = wasm.wasmscene_set_mode(this.__wbg_ptr, index, generation, mode);
|
|
870
|
+
if (ret[1]) {
|
|
871
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
/**
|
|
875
|
+
* Sets the placement from a row-major rotation (9 values) and a
|
|
876
|
+
* translation (3 values). The rotation must be a proper rotation.
|
|
877
|
+
* @param {number} index
|
|
878
|
+
* @param {number} generation
|
|
879
|
+
* @param {Float64Array} rotation
|
|
880
|
+
* @param {Float64Array} translation
|
|
881
|
+
*/
|
|
882
|
+
set_placement(index, generation, rotation, translation) {
|
|
883
|
+
const ptr0 = passArrayF64ToWasm0(rotation, wasm.__wbindgen_malloc);
|
|
884
|
+
const len0 = WASM_VECTOR_LEN;
|
|
885
|
+
const ptr1 = passArrayF64ToWasm0(translation, wasm.__wbindgen_malloc);
|
|
886
|
+
const len1 = WASM_VECTOR_LEN;
|
|
887
|
+
const ret = wasm.wasmscene_set_placement(this.__wbg_ptr, index, generation, ptr0, len0, ptr1, len1);
|
|
888
|
+
if (ret[1]) {
|
|
889
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* Turns a section's fill on or off.
|
|
894
|
+
* @param {number} section
|
|
895
|
+
* @param {boolean} fill
|
|
896
|
+
*/
|
|
897
|
+
set_section_fill(section, fill) {
|
|
898
|
+
const ret = wasm.wasmscene_set_section_fill(this.__wbg_ptr, section, fill);
|
|
899
|
+
if (ret[1]) {
|
|
900
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
/**
|
|
904
|
+
* Changes the meshes a section cuts (flat pairs).
|
|
905
|
+
* @param {number} section
|
|
906
|
+
* @param {Uint32Array} meshes
|
|
907
|
+
*/
|
|
908
|
+
set_section_meshes(section, meshes) {
|
|
909
|
+
const ptr0 = passArray32ToWasm0(meshes, wasm.__wbindgen_malloc);
|
|
910
|
+
const len0 = WASM_VECTOR_LEN;
|
|
911
|
+
const ret = wasm.wasmscene_set_section_meshes(this.__wbg_ptr, section, ptr0, len0);
|
|
912
|
+
if (ret[1]) {
|
|
913
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* Moves a section's plane, `[origin xyz, normal xyz]`.
|
|
918
|
+
* @param {number} section
|
|
919
|
+
* @param {Float64Array} plane
|
|
920
|
+
*/
|
|
921
|
+
set_section_plane(section, plane) {
|
|
922
|
+
const ptr0 = passArrayF64ToWasm0(plane, wasm.__wbindgen_malloc);
|
|
923
|
+
const len0 = WASM_VECTOR_LEN;
|
|
924
|
+
const ret = wasm.wasmscene_set_section_plane(this.__wbg_ptr, section, ptr0, len0);
|
|
925
|
+
if (ret[1]) {
|
|
926
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* Everything that changed since the last call, as one message in the
|
|
931
|
+
* format of [`crate::render`]: `[record_count, record...]`.
|
|
932
|
+
* @returns {Uint32Array}
|
|
933
|
+
*/
|
|
934
|
+
take_changes() {
|
|
935
|
+
const ret = wasm.wasmscene_take_changes(this.__wbg_ptr);
|
|
936
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
937
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
938
|
+
return v1;
|
|
939
|
+
}
|
|
940
|
+
/**
|
|
941
|
+
* Alive triangles.
|
|
942
|
+
* @param {number} index
|
|
943
|
+
* @param {number} generation
|
|
944
|
+
* @returns {number}
|
|
945
|
+
*/
|
|
946
|
+
triangle_count(index, generation) {
|
|
947
|
+
const ret = wasm.wasmscene_triangle_count(this.__wbg_ptr, index, generation);
|
|
948
|
+
if (ret[2]) {
|
|
949
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
950
|
+
}
|
|
951
|
+
return ret[0] >>> 0;
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* Triangle slots, alive or dead: the length of the index buffer.
|
|
955
|
+
* @param {number} index
|
|
956
|
+
* @param {number} generation
|
|
957
|
+
* @returns {number}
|
|
958
|
+
*/
|
|
959
|
+
triangle_slots(index, generation) {
|
|
960
|
+
const ret = wasm.wasmscene_triangle_slots(this.__wbg_ptr, index, generation);
|
|
961
|
+
if (ret[2]) {
|
|
962
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
963
|
+
}
|
|
964
|
+
return ret[0] >>> 0;
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* Undoes the latest step; false when there is nothing to undo.
|
|
968
|
+
* @returns {boolean}
|
|
969
|
+
*/
|
|
970
|
+
undo() {
|
|
971
|
+
const ret = wasm.wasmscene_undo(this.__wbg_ptr);
|
|
972
|
+
if (ret[2]) {
|
|
973
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
974
|
+
}
|
|
975
|
+
return ret[0] !== 0;
|
|
976
|
+
}
|
|
977
|
+
/**
|
|
978
|
+
* Brings the mesh's BVH, normals, fields and sections up to date now.
|
|
979
|
+
* @param {number} index
|
|
980
|
+
* @param {number} generation
|
|
981
|
+
*/
|
|
982
|
+
update(index, generation) {
|
|
983
|
+
const ret = wasm.wasmscene_update(this.__wbg_ptr, index, generation);
|
|
984
|
+
if (ret[1]) {
|
|
985
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* Computes every stale section entry.
|
|
990
|
+
*/
|
|
991
|
+
update_sections() {
|
|
992
|
+
const ret = wasm.wasmscene_update_sections(this.__wbg_ptr);
|
|
993
|
+
if (ret[1]) {
|
|
994
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* Length of the colour values in `f32`s, 0 when the mesh has no
|
|
999
|
+
* colouring.
|
|
1000
|
+
* @param {number} index
|
|
1001
|
+
* @param {number} generation
|
|
1002
|
+
* @returns {number}
|
|
1003
|
+
*/
|
|
1004
|
+
values_len(index, generation) {
|
|
1005
|
+
const ret = wasm.wasmscene_values_len(this.__wbg_ptr, index, generation);
|
|
1006
|
+
if (ret[2]) {
|
|
1007
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1008
|
+
}
|
|
1009
|
+
return ret[0] >>> 0;
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Address of the values the colours are made from (`f32`, 1 per vertex
|
|
1013
|
+
* slot: the colouring field's channel), 0 when the mesh has no
|
|
1014
|
+
* colouring. They change only at the colours' dirty slots.
|
|
1015
|
+
* @param {number} index
|
|
1016
|
+
* @param {number} generation
|
|
1017
|
+
* @returns {number}
|
|
1018
|
+
*/
|
|
1019
|
+
values_ptr(index, generation) {
|
|
1020
|
+
const ret = wasm.wasmscene_values_ptr(this.__wbg_ptr, index, generation);
|
|
1021
|
+
if (ret[2]) {
|
|
1022
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1023
|
+
}
|
|
1024
|
+
return ret[0] >>> 0;
|
|
1025
|
+
}
|
|
1026
|
+
/**
|
|
1027
|
+
* Alive vertices.
|
|
1028
|
+
* @param {number} index
|
|
1029
|
+
* @param {number} generation
|
|
1030
|
+
* @returns {number}
|
|
1031
|
+
*/
|
|
1032
|
+
vertex_count(index, generation) {
|
|
1033
|
+
const ret = wasm.wasmscene_vertex_count(this.__wbg_ptr, index, generation);
|
|
1034
|
+
if (ret[2]) {
|
|
1035
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1036
|
+
}
|
|
1037
|
+
return ret[0] >>> 0;
|
|
1038
|
+
}
|
|
1039
|
+
/**
|
|
1040
|
+
* Vertex slots, alive or dead: the length of the vertex buffers.
|
|
1041
|
+
* @param {number} index
|
|
1042
|
+
* @param {number} generation
|
|
1043
|
+
* @returns {number}
|
|
1044
|
+
*/
|
|
1045
|
+
vertex_slots(index, generation) {
|
|
1046
|
+
const ret = wasm.wasmscene_vertex_slots(this.__wbg_ptr, index, generation);
|
|
1047
|
+
if (ret[2]) {
|
|
1048
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1049
|
+
}
|
|
1050
|
+
return ret[0] >>> 0;
|
|
1051
|
+
}
|
|
1052
|
+
/**
|
|
1053
|
+
* Removes a field never computed, reporting nothing; `false` (nothing
|
|
1054
|
+
* done) when it was computed or colours its mesh. See
|
|
1055
|
+
* [`Scene::withdraw_field`].
|
|
1056
|
+
* @param {number} field
|
|
1057
|
+
* @returns {boolean}
|
|
1058
|
+
*/
|
|
1059
|
+
withdraw_field(field) {
|
|
1060
|
+
const ret = wasm.wasmscene_withdraw_field(this.__wbg_ptr, field);
|
|
1061
|
+
if (ret[2]) {
|
|
1062
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1063
|
+
}
|
|
1064
|
+
return ret[0] !== 0;
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
if (Symbol.dispose) WasmScene.prototype[Symbol.dispose] = WasmScene.prototype.free;
|
|
1068
|
+
|
|
1069
|
+
/**
|
|
1070
|
+
* Axis-aligned bounding box as six floats: `[minX, minY, minZ, maxX, maxY, maxZ]`.
|
|
1071
|
+
*
|
|
1072
|
+
* Returned as plain numbers so JavaScript never holds WebAssembly memory for it.
|
|
1073
|
+
* @param {Float32Array} positions
|
|
1074
|
+
* @returns {Float32Array}
|
|
1075
|
+
*/
|
|
1076
|
+
export function computeBounds(positions) {
|
|
1077
|
+
const ptr0 = passArrayF32ToWasm0(positions, wasm.__wbindgen_malloc);
|
|
1078
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1079
|
+
const ret = wasm.computeBounds(ptr0, len0);
|
|
1080
|
+
if (ret[3]) {
|
|
1081
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1082
|
+
}
|
|
1083
|
+
var v2 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
1084
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1085
|
+
return v2;
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
/**
|
|
1089
|
+
* Smooth, area-weighted per-vertex normals; same length as `positions`.
|
|
1090
|
+
* @param {Float32Array} positions
|
|
1091
|
+
* @param {Uint32Array} indices
|
|
1092
|
+
* @returns {Float32Array}
|
|
1093
|
+
*/
|
|
1094
|
+
export function computeVertexNormals(positions, indices) {
|
|
1095
|
+
const ptr0 = passArrayF32ToWasm0(positions, wasm.__wbindgen_malloc);
|
|
1096
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1097
|
+
const ptr1 = passArray32ToWasm0(indices, wasm.__wbindgen_malloc);
|
|
1098
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1099
|
+
const ret = wasm.computeVertexNormals(ptr0, len0, ptr1, len1);
|
|
1100
|
+
if (ret[3]) {
|
|
1101
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1102
|
+
}
|
|
1103
|
+
var v3 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
1104
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1105
|
+
return v3;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
/**
|
|
1109
|
+
* @param {number} num_threads
|
|
1110
|
+
* @returns {Promise<any>}
|
|
1111
|
+
*/
|
|
1112
|
+
export function initThreadPool(num_threads) {
|
|
1113
|
+
const ret = wasm.initThreadPool(num_threads);
|
|
1114
|
+
return ret;
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
/**
|
|
1118
|
+
* `watchPoolCrashes(channel)`: from now on, a panic or a trap on a thread of
|
|
1119
|
+
* rayon's pool posts `{ kind: "poolCrash", detail }` on the
|
|
1120
|
+
* `BroadcastChannel` named `channel`. Call once, after `initThreadPool`, on
|
|
1121
|
+
* the thread that started the pool; later calls do nothing. Costs nothing
|
|
1122
|
+
* until a thread crashes.
|
|
1123
|
+
* @param {string} channel
|
|
1124
|
+
*/
|
|
1125
|
+
export function watchPoolCrashes(channel) {
|
|
1126
|
+
const ptr0 = passStringToWasm0(channel, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1127
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1128
|
+
wasm.watchPoolCrashes(ptr0, len0);
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
export class wbg_rayon_PoolBuilder {
|
|
1132
|
+
static __wrap(ptr) {
|
|
1133
|
+
const obj = Object.create(wbg_rayon_PoolBuilder.prototype);
|
|
1134
|
+
obj.__wbg_ptr = ptr;
|
|
1135
|
+
wbg_rayon_PoolBuilderFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1136
|
+
return obj;
|
|
1137
|
+
}
|
|
1138
|
+
__destroy_into_raw() {
|
|
1139
|
+
const ptr = this.__wbg_ptr;
|
|
1140
|
+
this.__wbg_ptr = 0;
|
|
1141
|
+
wbg_rayon_PoolBuilderFinalization.unregister(this);
|
|
1142
|
+
return ptr;
|
|
1143
|
+
}
|
|
1144
|
+
free() {
|
|
1145
|
+
const ptr = this.__destroy_into_raw();
|
|
1146
|
+
wasm.__wbg_wbg_rayon_poolbuilder_free(ptr, 0);
|
|
1147
|
+
}
|
|
1148
|
+
build() {
|
|
1149
|
+
wasm.wbg_rayon_poolbuilder_build(this.__wbg_ptr);
|
|
1150
|
+
}
|
|
1151
|
+
/**
|
|
1152
|
+
* @returns {number}
|
|
1153
|
+
*/
|
|
1154
|
+
numThreads() {
|
|
1155
|
+
const ret = wasm.wbg_rayon_poolbuilder_numThreads(this.__wbg_ptr);
|
|
1156
|
+
return ret >>> 0;
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* @returns {number}
|
|
1160
|
+
*/
|
|
1161
|
+
receiver() {
|
|
1162
|
+
const ret = wasm.wbg_rayon_poolbuilder_receiver(this.__wbg_ptr);
|
|
1163
|
+
return ret >>> 0;
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
if (Symbol.dispose) wbg_rayon_PoolBuilder.prototype[Symbol.dispose] = wbg_rayon_PoolBuilder.prototype.free;
|
|
1167
|
+
|
|
1168
|
+
/**
|
|
1169
|
+
* @param {number} receiver
|
|
1170
|
+
*/
|
|
1171
|
+
export function wbg_rayon_start_worker(receiver) {
|
|
1172
|
+
wasm.wbg_rayon_start_worker(receiver);
|
|
1173
|
+
}
|
|
1174
|
+
function __wbg_get_imports(memory) {
|
|
1175
|
+
const import0 = {
|
|
1176
|
+
__proto__: null,
|
|
1177
|
+
__wbg_Error_30c8987f7c2ed4e2: function(arg0, arg1) {
|
|
1178
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
1179
|
+
return ret;
|
|
1180
|
+
},
|
|
1181
|
+
__wbg___wbindgen_is_undefined_8865fb403f8fe9d8: function(arg0) {
|
|
1182
|
+
const ret = arg0 === undefined;
|
|
1183
|
+
return ret;
|
|
1184
|
+
},
|
|
1185
|
+
__wbg___wbindgen_memory_caa4a6165639c8b5: function() {
|
|
1186
|
+
const ret = wasm.memory;
|
|
1187
|
+
return ret;
|
|
1188
|
+
},
|
|
1189
|
+
__wbg___wbindgen_module_7115fb14045f9891: function() {
|
|
1190
|
+
const ret = wasmModule;
|
|
1191
|
+
return ret;
|
|
1192
|
+
},
|
|
1193
|
+
__wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
|
|
1194
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1195
|
+
},
|
|
1196
|
+
__wbg_instanceof_Window_82d71df4eddf88bc: function(arg0) {
|
|
1197
|
+
let result;
|
|
1198
|
+
try {
|
|
1199
|
+
result = arg0 instanceof Window;
|
|
1200
|
+
} catch (_) {
|
|
1201
|
+
result = false;
|
|
1202
|
+
}
|
|
1203
|
+
const ret = result;
|
|
1204
|
+
return ret;
|
|
1205
|
+
},
|
|
1206
|
+
__wbg_post_crash_3d4ea77d98a4eb9e: function(arg0, arg1, arg2, arg3) {
|
|
1207
|
+
post_crash(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3));
|
|
1208
|
+
},
|
|
1209
|
+
__wbg_startWorkers_8b582d57e92bd2d4: function(arg0, arg1, arg2) {
|
|
1210
|
+
const ret = startWorkers(arg0, arg1, wbg_rayon_PoolBuilder.__wrap(arg2));
|
|
1211
|
+
return ret;
|
|
1212
|
+
},
|
|
1213
|
+
__wbg_static_accessor_GLOBAL_266715b9d96ba635: function() {
|
|
1214
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
1215
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1216
|
+
},
|
|
1217
|
+
__wbg_static_accessor_GLOBAL_THIS_10fb7dc1ae063179: function() {
|
|
1218
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
1219
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1220
|
+
},
|
|
1221
|
+
__wbg_static_accessor_SELF_0b583911f537483a: function() {
|
|
1222
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
1223
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1224
|
+
},
|
|
1225
|
+
__wbg_static_accessor_WINDOW_d7f903d1508cbdc4: function() {
|
|
1226
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
1227
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1228
|
+
},
|
|
1229
|
+
__wbg_watch_worker_5a08461f97c2364c: function(arg0, arg1) {
|
|
1230
|
+
watch_worker(getStringFromWasm0(arg0, arg1));
|
|
1231
|
+
},
|
|
1232
|
+
__wbindgen_init_externref_table: function() {
|
|
1233
|
+
const table = wasm.__wbindgen_externrefs;
|
|
1234
|
+
const offset = table.grow(4);
|
|
1235
|
+
table.set(0, undefined);
|
|
1236
|
+
table.set(offset + 0, undefined);
|
|
1237
|
+
table.set(offset + 1, null);
|
|
1238
|
+
table.set(offset + 2, true);
|
|
1239
|
+
table.set(offset + 3, false);
|
|
1240
|
+
},
|
|
1241
|
+
memory: memory || new WebAssembly.Memory({initial:18,maximum:65536,shared:true}),
|
|
1242
|
+
};
|
|
1243
|
+
return {
|
|
1244
|
+
__proto__: null,
|
|
1245
|
+
"./fast_mesh_wasm_bg.js": import0,
|
|
1246
|
+
};
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
const WasmSceneFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1250
|
+
? { register: () => {}, unregister: () => {} }
|
|
1251
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmscene_free(ptr, 1));
|
|
1252
|
+
const wbg_rayon_PoolBuilderFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1253
|
+
? { register: () => {}, unregister: () => {} }
|
|
1254
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wbg_rayon_poolbuilder_free(ptr, 1));
|
|
1255
|
+
|
|
1256
|
+
function addToExternrefTable0(obj) {
|
|
1257
|
+
const idx = wasm.__externref_table_alloc();
|
|
1258
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
1259
|
+
return idx;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
function getArrayF32FromWasm0(ptr, len) {
|
|
1263
|
+
ptr = ptr >>> 0;
|
|
1264
|
+
return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
function getArrayF64FromWasm0(ptr, len) {
|
|
1268
|
+
ptr = ptr >>> 0;
|
|
1269
|
+
return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
1273
|
+
ptr = ptr >>> 0;
|
|
1274
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
let cachedFloat32ArrayMemory0 = null;
|
|
1278
|
+
function getFloat32ArrayMemory0() {
|
|
1279
|
+
if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.buffer !== wasm.memory.buffer) {
|
|
1280
|
+
cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
|
|
1281
|
+
}
|
|
1282
|
+
return cachedFloat32ArrayMemory0;
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
let cachedFloat64ArrayMemory0 = null;
|
|
1286
|
+
function getFloat64ArrayMemory0() {
|
|
1287
|
+
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.buffer !== wasm.memory.buffer) {
|
|
1288
|
+
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
|
|
1289
|
+
}
|
|
1290
|
+
return cachedFloat64ArrayMemory0;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
function getStringFromWasm0(ptr, len) {
|
|
1294
|
+
return decodeText(ptr >>> 0, len);
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
let cachedUint32ArrayMemory0 = null;
|
|
1298
|
+
function getUint32ArrayMemory0() {
|
|
1299
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.buffer !== wasm.memory.buffer) {
|
|
1300
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
1301
|
+
}
|
|
1302
|
+
return cachedUint32ArrayMemory0;
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
let cachedUint8ArrayMemory0 = null;
|
|
1306
|
+
function getUint8ArrayMemory0() {
|
|
1307
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.buffer !== wasm.memory.buffer) {
|
|
1308
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
1309
|
+
}
|
|
1310
|
+
return cachedUint8ArrayMemory0;
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
function isLikeNone(x) {
|
|
1314
|
+
return x === undefined || x === null;
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
function passArray32ToWasm0(arg, malloc) {
|
|
1318
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
1319
|
+
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
1320
|
+
WASM_VECTOR_LEN = arg.length;
|
|
1321
|
+
return ptr;
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
function passArrayF32ToWasm0(arg, malloc) {
|
|
1325
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
1326
|
+
getFloat32ArrayMemory0().set(arg, ptr / 4);
|
|
1327
|
+
WASM_VECTOR_LEN = arg.length;
|
|
1328
|
+
return ptr;
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
function passArrayF64ToWasm0(arg, malloc) {
|
|
1332
|
+
const ptr = malloc(arg.length * 8, 8) >>> 0;
|
|
1333
|
+
getFloat64ArrayMemory0().set(arg, ptr / 8);
|
|
1334
|
+
WASM_VECTOR_LEN = arg.length;
|
|
1335
|
+
return ptr;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
1339
|
+
if (realloc === undefined) {
|
|
1340
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1341
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
1342
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
1343
|
+
WASM_VECTOR_LEN = buf.length;
|
|
1344
|
+
return ptr;
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
let len = arg.length;
|
|
1348
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
1349
|
+
|
|
1350
|
+
const mem = getUint8ArrayMemory0();
|
|
1351
|
+
|
|
1352
|
+
let offset = 0;
|
|
1353
|
+
|
|
1354
|
+
for (; offset < len; offset++) {
|
|
1355
|
+
const code = arg.charCodeAt(offset);
|
|
1356
|
+
if (code > 0x7F) break;
|
|
1357
|
+
mem[ptr + offset] = code;
|
|
1358
|
+
}
|
|
1359
|
+
if (offset !== len) {
|
|
1360
|
+
if (offset !== 0) {
|
|
1361
|
+
arg = arg.slice(offset);
|
|
1362
|
+
}
|
|
1363
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
1364
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
1365
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
1366
|
+
|
|
1367
|
+
offset += ret.written;
|
|
1368
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
WASM_VECTOR_LEN = offset;
|
|
1372
|
+
return ptr;
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
function takeFromExternrefTable0(idx) {
|
|
1376
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
1377
|
+
wasm.__externref_table_dealloc(idx);
|
|
1378
|
+
return value;
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
let cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : undefined);
|
|
1382
|
+
if (cachedTextDecoder) cachedTextDecoder.decode();
|
|
1383
|
+
|
|
1384
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
1385
|
+
let numBytesDecoded = 0;
|
|
1386
|
+
function decodeText(ptr, len) {
|
|
1387
|
+
numBytesDecoded += len;
|
|
1388
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
1389
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1390
|
+
cachedTextDecoder.decode();
|
|
1391
|
+
numBytesDecoded = len;
|
|
1392
|
+
}
|
|
1393
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().slice(ptr, ptr + len));
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder() : undefined);
|
|
1397
|
+
|
|
1398
|
+
if (cachedTextEncoder) {
|
|
1399
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
1400
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1401
|
+
view.set(buf);
|
|
1402
|
+
return {
|
|
1403
|
+
read: arg.length,
|
|
1404
|
+
written: buf.length
|
|
1405
|
+
};
|
|
1406
|
+
};
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
let WASM_VECTOR_LEN = 0;
|
|
1410
|
+
|
|
1411
|
+
let wasmModule, wasmInstance, wasm;
|
|
1412
|
+
function __wbg_finalize_init(instance, module, thread_stack_size) {
|
|
1413
|
+
wasmInstance = instance;
|
|
1414
|
+
wasm = instance.exports;
|
|
1415
|
+
wasmModule = module;
|
|
1416
|
+
cachedFloat32ArrayMemory0 = null;
|
|
1417
|
+
cachedFloat64ArrayMemory0 = null;
|
|
1418
|
+
cachedUint32ArrayMemory0 = null;
|
|
1419
|
+
cachedUint8ArrayMemory0 = null;
|
|
1420
|
+
if (typeof thread_stack_size !== 'undefined' && (typeof thread_stack_size !== 'number' || thread_stack_size === 0 || thread_stack_size % 65536 !== 0)) {
|
|
1421
|
+
throw new Error('invalid stack size');
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
wasm.__wbindgen_start(thread_stack_size);
|
|
1425
|
+
return wasm;
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
async function __wbg_load(module, imports) {
|
|
1429
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
1430
|
+
if (!module.ok) {
|
|
1431
|
+
throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
1435
|
+
try {
|
|
1436
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
1437
|
+
} catch (e) {
|
|
1438
|
+
const validResponse = expectedResponseType(module.type);
|
|
1439
|
+
|
|
1440
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
1441
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
1442
|
+
|
|
1443
|
+
} else { throw e; }
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1447
|
+
const bytes = await module.arrayBuffer();
|
|
1448
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
1449
|
+
} else {
|
|
1450
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
1451
|
+
|
|
1452
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
1453
|
+
return { instance, module };
|
|
1454
|
+
} else {
|
|
1455
|
+
return instance;
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
function expectedResponseType(type) {
|
|
1460
|
+
switch (type) {
|
|
1461
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
1462
|
+
}
|
|
1463
|
+
return false;
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
function initSync(module, memory) {
|
|
1468
|
+
if (wasm !== undefined) return wasm;
|
|
1469
|
+
|
|
1470
|
+
let thread_stack_size
|
|
1471
|
+
if (module !== undefined) {
|
|
1472
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
1473
|
+
({module, memory, thread_stack_size} = module)
|
|
1474
|
+
} else {
|
|
1475
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
const imports = __wbg_get_imports(memory);
|
|
1480
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
1481
|
+
module = new WebAssembly.Module(module);
|
|
1482
|
+
}
|
|
1483
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
1484
|
+
return __wbg_finalize_init(instance, module, thread_stack_size);
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
async function __wbg_init(module_or_path, memory) {
|
|
1488
|
+
if (wasm !== undefined) return wasm;
|
|
1489
|
+
|
|
1490
|
+
let thread_stack_size
|
|
1491
|
+
if (module_or_path !== undefined) {
|
|
1492
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
1493
|
+
({module_or_path, memory, thread_stack_size} = module_or_path)
|
|
1494
|
+
} else {
|
|
1495
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
if (module_or_path === undefined) {
|
|
1500
|
+
module_or_path = new URL('fast_mesh_wasm_bg.wasm', import.meta.url);
|
|
1501
|
+
}
|
|
1502
|
+
const imports = __wbg_get_imports(memory);
|
|
1503
|
+
|
|
1504
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
1505
|
+
module_or_path = fetch(module_or_path);
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
1509
|
+
|
|
1510
|
+
return __wbg_finalize_init(instance, module, thread_stack_size);
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
export { initSync, __wbg_init as default };
|