fast-mesh-wasm 0.3.1 → 0.4.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 +5 -2
- package/dist/{client-Bp9FRd70.js → client-Bpjy-eFY.js} +1 -1
- package/dist/{client-m2zSdFlu.d.ts → client-D-O5-tAg.d.ts} +2 -2
- package/dist/{colormap-D_xH5hI5.js → colormap-DxGMYVfs.js} +1 -1
- package/dist/{engine-BpnthBYQ.js → engine-D6MpGb9i.js} +36 -10
- package/dist/{mesh-B16gV3oX.d.ts → mesh-BUVxv3jo.d.ts} +8 -1
- package/dist/{mesh-B8pae8WA.js → mesh-zj7-wJBw.js} +52 -5
- package/dist/node.d.ts +2 -2
- package/dist/node.js +1 -1
- package/dist/{protocol-W9R-iGl5.d.ts → protocol-CK6_3aqo.d.ts} +1 -1
- package/dist/r3f.d.ts +3 -3
- package/dist/r3f.js +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/{scene-BFd6nYRe.js → scene-D6m9XM3O.js} +98 -12
- package/dist/{scene-like-B_3qm0u6.d.ts → scene-like-DJKQP5uf.d.ts} +46 -5
- package/dist/{store-D3ErV6o-.js → store-Ml3TQGsR.js} +2 -2
- package/dist/{store-DNnHN33A.d.ts → store-QWRDXlAn.d.ts} +2 -2
- package/dist/store.d.ts +2 -2
- package/dist/store.js +1 -1
- package/dist/three.d.ts +7 -6
- package/dist/three.js +7 -2
- package/dist/{views-BaZqBxlX.js → views-Dh3aWc2q.js} +1 -1
- package/dist/wasm/fast_mesh_wasm.d.ts +44 -12
- package/dist/wasm/fast_mesh_wasm.js +82 -20
- package/dist/wasm/fast_mesh_wasm_bg.wasm +0 -0
- package/dist/wasm/fast_mesh_wasm_bg.wasm.d.ts +5 -1
- package/dist/wasm-threads/fast_mesh_wasm.d.ts +44 -12
- package/dist/wasm-threads/fast_mesh_wasm.js +82 -20
- package/dist/wasm-threads/fast_mesh_wasm_bg.wasm +0 -0
- package/dist/wasm-threads/fast_mesh_wasm_bg.wasm.d.ts +5 -1
- package/dist/web.d.ts +2 -2
- package/dist/web.js +1 -1
- package/dist/worker-engine.d.ts +7 -5
- 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
|
@@ -71,7 +71,8 @@ export class WasmScene {
|
|
|
71
71
|
* Positions are stored as `p - origin` in `f32`; without `origin` it
|
|
72
72
|
* is the bounding-box centre. `mode` is 0 (Eager), 1 (Lazy) or 2
|
|
73
73
|
* (Manual); `normals` turns vertex normals on. The placement starts as
|
|
74
|
-
* the identity.
|
|
74
|
+
* the identity. A Lazy or Manual mesh builds its BVH on first use
|
|
75
|
+
* instead of up front. Nothing is added on error.
|
|
75
76
|
* @param {Float64Array} positions
|
|
76
77
|
* @param {Uint32Array} indices
|
|
77
78
|
* @param {Float64Array | null | undefined} origin
|
|
@@ -115,9 +116,38 @@ export class WasmScene {
|
|
|
115
116
|
return v1;
|
|
116
117
|
}
|
|
117
118
|
/**
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
119
|
+
* Appends a chunk of flat `[a, b, c, ...]` indices to a mesh being
|
|
120
|
+
* added; the chunks must add up to its declared triangles.
|
|
121
|
+
* @param {number} build
|
|
122
|
+
* @param {Uint32Array} chunk
|
|
123
|
+
*/
|
|
124
|
+
add_mesh_push_indices(build, chunk) {
|
|
125
|
+
const ptr0 = passArray32ToWasm0(chunk, wasm.__wbindgen_malloc);
|
|
126
|
+
const len0 = WASM_VECTOR_LEN;
|
|
127
|
+
const ret = wasm.wasmscene_add_mesh_push_indices(this.__wbg_ptr, build, ptr0, len0);
|
|
128
|
+
if (ret[1]) {
|
|
129
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Appends a chunk of flat `[x, y, z, ...]` world positions to a mesh
|
|
134
|
+
* being added; the chunks must add up to its declared vertices.
|
|
135
|
+
* @param {number} build
|
|
136
|
+
* @param {Float64Array} chunk
|
|
137
|
+
*/
|
|
138
|
+
add_mesh_push_positions(build, chunk) {
|
|
139
|
+
const ptr0 = passArrayF64ToWasm0(chunk, wasm.__wbindgen_malloc);
|
|
140
|
+
const len0 = WASM_VECTOR_LEN;
|
|
141
|
+
const ret = wasm.wasmscene_add_mesh_push_positions(this.__wbg_ptr, build, ptr0, len0);
|
|
142
|
+
if (ret[1]) {
|
|
143
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Builds about `budget` more units of a mesh being added: first its
|
|
148
|
+
* store (vertices or triangles a unit), then its BVH (see
|
|
149
|
+
* `MeshBuild::step`); `true` once its BVH is built. The upload must be
|
|
150
|
+
* complete first. A failed build is dropped.
|
|
121
151
|
* @param {number} build
|
|
122
152
|
* @param {number} budget
|
|
123
153
|
* @returns {boolean}
|
|
@@ -172,25 +202,25 @@ export class WasmScene {
|
|
|
172
202
|
return v1;
|
|
173
203
|
}
|
|
174
204
|
/**
|
|
175
|
-
* [`WasmScene::add_mesh`] in steps:
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
205
|
+
* [`WasmScene::add_mesh`] in steps: reserves a mesh of `vertices`
|
|
206
|
+
* vertices and `triangles` triangles outside the scene and returns the
|
|
207
|
+
* build's id. Its inputs upload in chunks
|
|
208
|
+
* ([`WasmScene::add_mesh_push_positions`] and
|
|
209
|
+
* [`WasmScene::add_mesh_push_indices`]), then its store, BVH and
|
|
210
|
+
* normals build in steps ([`WasmScene::add_mesh_step`]), for
|
|
211
|
+
* [`WasmScene::finish_add_mesh`]. The scene is unchanged until the
|
|
212
|
+
* mesh is added.
|
|
213
|
+
* @param {number} vertices
|
|
214
|
+
* @param {number} triangles
|
|
181
215
|
* @param {Float64Array | null | undefined} origin
|
|
182
216
|
* @param {number} mode
|
|
183
217
|
* @param {boolean} normals
|
|
184
218
|
* @returns {number}
|
|
185
219
|
*/
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
const
|
|
190
|
-
const len1 = WASM_VECTOR_LEN;
|
|
191
|
-
var ptr2 = isLikeNone(origin) ? 0 : passArrayF64ToWasm0(origin, wasm.__wbindgen_malloc);
|
|
192
|
-
var len2 = WASM_VECTOR_LEN;
|
|
193
|
-
const ret = wasm.wasmscene_begin_add_mesh(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, mode, normals);
|
|
220
|
+
begin_add_mesh_upload(vertices, triangles, origin, mode, normals) {
|
|
221
|
+
var ptr0 = isLikeNone(origin) ? 0 : passArrayF64ToWasm0(origin, wasm.__wbindgen_malloc);
|
|
222
|
+
var len0 = WASM_VECTOR_LEN;
|
|
223
|
+
const ret = wasm.wasmscene_begin_add_mesh_upload(this.__wbg_ptr, vertices, triangles, ptr0, len0, mode, normals);
|
|
194
224
|
if (ret[2]) {
|
|
195
225
|
throw takeFromExternrefTable0(ret[1]);
|
|
196
226
|
}
|
|
@@ -202,6 +232,23 @@ export class WasmScene {
|
|
|
202
232
|
begin_step() {
|
|
203
233
|
wasm.wasmscene_begin_step(this.__wbg_ptr);
|
|
204
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* The box around the vertices the live triangles use, in the mesh's
|
|
237
|
+
* stored local coordinates: `[min xyz, max xyz]`. Empty without live
|
|
238
|
+
* triangles.
|
|
239
|
+
* @param {number} index
|
|
240
|
+
* @param {number} generation
|
|
241
|
+
* @returns {Float64Array}
|
|
242
|
+
*/
|
|
243
|
+
bounds(index, generation) {
|
|
244
|
+
const ret = wasm.wasmscene_bounds(this.__wbg_ptr, index, generation);
|
|
245
|
+
if (ret[3]) {
|
|
246
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
247
|
+
}
|
|
248
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
249
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
250
|
+
return v1;
|
|
251
|
+
}
|
|
205
252
|
/**
|
|
206
253
|
* True if `redo` would redo something.
|
|
207
254
|
* @returns {boolean}
|
|
@@ -539,8 +586,9 @@ export class WasmScene {
|
|
|
539
586
|
return v2;
|
|
540
587
|
}
|
|
541
588
|
/**
|
|
542
|
-
* Adds a mesh built in steps, finishing what is left of its
|
|
543
|
-
* returns `[index, generation]`, as
|
|
589
|
+
* Adds a mesh built in steps, finishing what is left of its store,
|
|
590
|
+
* BVH and normals, and returns `[index, generation]`, as
|
|
591
|
+
* [`WasmScene::add_mesh`] would.
|
|
544
592
|
* @param {number} build
|
|
545
593
|
* @returns {Uint32Array}
|
|
546
594
|
*/
|
|
@@ -640,6 +688,20 @@ export class WasmScene {
|
|
|
640
688
|
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
641
689
|
return v1;
|
|
642
690
|
}
|
|
691
|
+
/**
|
|
692
|
+
* When the mesh's BVH, normals, fields and sections follow its edits:
|
|
693
|
+
* 0 (Eager), 1 (Lazy) or 2 (Manual).
|
|
694
|
+
* @param {number} index
|
|
695
|
+
* @param {number} generation
|
|
696
|
+
* @returns {number}
|
|
697
|
+
*/
|
|
698
|
+
mode(index, generation) {
|
|
699
|
+
const ret = wasm.wasmscene_mode(this.__wbg_ptr, index, generation);
|
|
700
|
+
if (ret[2]) {
|
|
701
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
702
|
+
}
|
|
703
|
+
return ret[0];
|
|
704
|
+
}
|
|
643
705
|
/**
|
|
644
706
|
* An empty scene with the default history budget.
|
|
645
707
|
*/
|
|
Binary file
|
|
@@ -10,11 +10,14 @@ export const wasmscene_add_distance_field: (a: number, b: number, c: number, d:
|
|
|
10
10
|
export const wasmscene_add_distance_field_deferred: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
|
|
11
11
|
export const wasmscene_add_mesh: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number, number, number];
|
|
12
12
|
export const wasmscene_add_mesh_buffers: (a: number, b: number) => [number, number, number, number];
|
|
13
|
+
export const wasmscene_add_mesh_push_indices: (a: number, b: number, c: number, d: number) => [number, number];
|
|
14
|
+
export const wasmscene_add_mesh_push_positions: (a: number, b: number, c: number, d: number) => [number, number];
|
|
13
15
|
export const wasmscene_add_mesh_step: (a: number, b: number, c: number) => [number, number, number];
|
|
14
16
|
export const wasmscene_add_section: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
|
|
15
17
|
export const wasmscene_analyze: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
16
|
-
export const
|
|
18
|
+
export const wasmscene_begin_add_mesh_upload: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
|
|
17
19
|
export const wasmscene_begin_step: (a: number) => void;
|
|
20
|
+
export const wasmscene_bounds: (a: number, b: number, c: number) => [number, number, number, number];
|
|
18
21
|
export const wasmscene_can_redo: (a: number) => number;
|
|
19
22
|
export const wasmscene_can_undo: (a: number) => number;
|
|
20
23
|
export const wasmscene_cancel_step: (a: number) => [number, number];
|
|
@@ -46,6 +49,7 @@ export const wasmscene_indices_ptr: (a: number, b: number, c: number) => [number
|
|
|
46
49
|
export const wasmscene_intersects: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
47
50
|
export const wasmscene_matrix4: (a: number, b: number, c: number) => [number, number, number, number];
|
|
48
51
|
export const wasmscene_mesh_distance: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
52
|
+
export const wasmscene_mode: (a: number, b: number, c: number) => [number, number, number];
|
|
49
53
|
export const wasmscene_new: () => number;
|
|
50
54
|
export const wasmscene_normals_len: (a: number, b: number, c: number) => [number, number, number];
|
|
51
55
|
export const wasmscene_normals_ptr: (a: number, b: number, c: number) => [number, number, number];
|
package/dist/web.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as Placement, A as RemoveReport, B as SectionPlane, C as MeshChange, D as OutOfRange, E as OrientReport, F as Scene, G as MeshHandle, H as SignMode, I as SceneOptions, J as MeshViews, K as SectionHandle, L as SectionContour, M as RepairReport, N as RepairReportOf, O as RayHit, P as Rgba, Q as Mat3, R as SectionDesc, S as LoopId, T as MeshDistance, U as WeldReport, V as SectionResult, W as FieldHandle, X as Indices, Y as Bounds, Z as InitInput, _ as EditResult, a as BoundaryLoop, at as Vec3, b as FilledLoop, c as ColorRule, d as DegenerateReport, et as PlacementInput, f as DistanceFieldDesc, g as EditRef, h as EditOp, i as AnalyzeOptions, it as UpdateMode, j as RepairOp, k as RaycastOptions, l as Colormap, m as DragSession, n as AddMeshOptions, nt as Positions64, o as ClosestHit, ot as computeBounds, p as DragOptions, q as Range, r as Analysis, rt as Quat, s as ClosestPointOptions, st as computeVertexNormals, t as SceneLike, tt as Positions, u as Contact, v as FieldStatus, w as MeshComponent, x as FindContactsOptions, y as FillReport, z as SectionGap } from "./scene-like-DJKQP5uf.js";
|
|
2
2
|
import { n as FastMeshErrorCode, t as FastMeshError } from "./core-D2X9GPfK.js";
|
|
3
3
|
//#region src/web.d.ts
|
|
4
4
|
/**
|
|
@@ -10,4 +10,4 @@ import { n as FastMeshErrorCode, t as FastMeshError } from "./core-D2X9GPfK.js";
|
|
|
10
10
|
*/
|
|
11
11
|
export declare function init(input?: InitInput | Promise<InitInput>): Promise<void>;
|
|
12
12
|
//#endregion
|
|
13
|
-
export { type AddMeshOptions, type Analysis, type AnalyzeOptions, type BoundaryLoop, type Bounds, type ClosestHit, type ClosestPointOptions, type ColorRule, type Colormap, type Contact, type DegenerateReport, type DistanceFieldDesc, type DragSession, type EditOp, type EditRef, type EditResult, FastMeshError, type FastMeshErrorCode, type FieldHandle, type FieldStatus, type FillReport, type FilledLoop, type FindContactsOptions, type Indices, type InitInput, type LoopId, type Mat3, type MeshChange, type MeshComponent, type MeshDistance, type MeshHandle, type MeshViews, type OrientReport, type OutOfRange, type Placement, type PlacementInput, type Positions, type Positions64, type Quat, type Range, type RayHit, type RaycastOptions, type RemoveReport, type RepairOp, type RepairReport, type RepairReportOf, type Rgba, Scene, type SceneLike, type SceneOptions, type SectionContour, type SectionDesc, type SectionGap, type SectionHandle, type SectionPlane, type SectionResult, type SignMode, type UpdateMode, type Vec3, type WeldReport, computeBounds, computeVertexNormals };
|
|
13
|
+
export { type AddMeshOptions, type Analysis, type AnalyzeOptions, type BoundaryLoop, type Bounds, type ClosestHit, type ClosestPointOptions, type ColorRule, type Colormap, type Contact, 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 Indices, type InitInput, type LoopId, type Mat3, type MeshChange, type MeshComponent, type MeshDistance, type MeshHandle, type MeshViews, type OrientReport, type OutOfRange, type Placement, type PlacementInput, type Positions, type Positions64, type Quat, type Range, type RayHit, type RaycastOptions, type RemoveReport, type RepairOp, type RepairReport, type RepairReportOf, type Rgba, Scene, type SceneLike, type SceneOptions, type SectionContour, type SectionDesc, type SectionGap, type SectionHandle, type SectionPlane, type SectionResult, type SignMode, type UpdateMode, type Vec3, type WeldReport, computeBounds, computeVertexNormals };
|
package/dist/web.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as FastMeshError } from "./core-Cke_kZ2e.js";
|
|
2
2
|
import { n as computeVertexNormals, r as markInitialized, t as computeBounds } from "./api-BUy7FRx7.js";
|
|
3
|
-
import { t as Scene } from "./scene-
|
|
3
|
+
import { t as Scene } from "./scene-D6m9XM3O.js";
|
|
4
4
|
import wasmInit from "./wasm/fast_mesh_wasm.js";
|
|
5
5
|
//#region src/web.ts
|
|
6
6
|
let ready;
|
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-CK6_3aqo.js";
|
|
2
2
|
import { WasmScene } from "./wasm/fast_mesh_wasm.js";
|
|
3
3
|
//#region src/worker/load.d.ts
|
|
4
4
|
/** What the engine needs of a wasm-bindgen glue module. */
|
|
@@ -182,10 +182,12 @@ export interface EngineOptions {
|
|
|
182
182
|
backgroundAddTriangles?: number;
|
|
183
183
|
/**
|
|
184
184
|
* The work of one step of a background add ({@link ADD_STEP_WORK} by
|
|
185
|
-
* default):
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
185
|
+
* default): 64 bytes of the upload of its positions and indices into
|
|
186
|
+
* wasm memory; a vertex or triangle of its store build; a triangle's
|
|
187
|
+
* box, or a triangle visited per tree level, of its BVH build; 4
|
|
188
|
+
* triangles or 16 vertices of its normals; 64 bytes of the copy of its
|
|
189
|
+
* render buffers. Clamped to 1 to 2^32 − 1; NaN or less than 1 keeps
|
|
190
|
+
* the default.
|
|
189
191
|
*/
|
|
190
192
|
addStepWork?: number;
|
|
191
193
|
/**
|
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-D6MpGb9i.js";
|
package/dist/worker-entry.js
CHANGED
package/dist/worker.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as createWorkerScene, i as WorkerSceneOptions, n as WorkerLike, r as WorkerScene, t as KeyStatus } from "./client-
|
|
1
|
+
import { a as createWorkerScene, i as WorkerSceneOptions, n as WorkerLike, r as WorkerScene, t as KeyStatus } from "./client-D-O5-tAg.js";
|
|
2
2
|
export { type KeyStatus, type WorkerLike, WorkerScene, type WorkerSceneOptions, createWorkerScene };
|
package/dist/worker.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as WorkerScene, r as createWorkerScene } from "./client-
|
|
1
|
+
export { t as WorkerScene, r as createWorkerScene } from "./client-Bpjy-eFY.js";
|