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
package/dist/io.d.ts
CHANGED
|
@@ -1,4 +1,197 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Nn as Scene, n as SceneLike, vr as MeshHandle } from "./scene-like-CR_Dpohm.js";
|
|
2
|
+
import { i as WorkerScene } from "./client-nvmbhtn-.js";
|
|
3
|
+
/**
|
|
4
|
+
* Zero-dependency ZIP reader and writer (`STORE` and `DEFLATE`) with hostile-input guards.
|
|
5
|
+
*
|
|
6
|
+
* Uses Web-standard `DecompressionStream("deflate-raw")` and
|
|
7
|
+
* `CompressionStream("deflate-raw")` with IEEE CRC-32 verification and strict
|
|
8
|
+
* bounds checks to prevent zip bombs, OOM allocations, and Zip Slip traversal.
|
|
9
|
+
*/
|
|
10
|
+
interface ZipEntryInput {
|
|
11
|
+
/** Archive-relative POSIX path (e.g. `"3D/3dmodel.model"`). */
|
|
12
|
+
name: string;
|
|
13
|
+
/** Uncompressed entry payload. */
|
|
14
|
+
data: Uint8Array;
|
|
15
|
+
/** Override per-entry compression (`true` = deflate when smaller, `false` = store). */
|
|
16
|
+
compress?: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface ZipReadOptions {
|
|
19
|
+
/** Maximum accepted ZIP archive size in bytes. Default: 512 MiB. */
|
|
20
|
+
maxFileBytes?: number;
|
|
21
|
+
/** Maximum accepted number of ZIP entries. Default: 4096. */
|
|
22
|
+
maxEntries?: number;
|
|
23
|
+
/** Maximum uncompressed bytes allowed for any single entry. Default: `maxFileBytes`. */
|
|
24
|
+
maxEntryBytes?: number;
|
|
25
|
+
/** Maximum cumulative uncompressed bytes across all entries. Default: `maxFileBytes`. */
|
|
26
|
+
maxTotalUncompressedBytes?: number;
|
|
27
|
+
/** Verify IEEE CRC-32 checksums on read entries. Default: `true`. */
|
|
28
|
+
verifyCrc?: boolean;
|
|
29
|
+
/** Optional abort signal to cancel extraction mid-stream. */
|
|
30
|
+
signal?: AbortSignal;
|
|
31
|
+
}
|
|
32
|
+
interface ZipWriteOptions {
|
|
33
|
+
/** Compress entries using raw DEFLATE (`CompressionStream("deflate-raw")`). Default: `true`. */
|
|
34
|
+
compress?: boolean;
|
|
35
|
+
}
|
|
36
|
+
interface ZipEntry {
|
|
37
|
+
name: string;
|
|
38
|
+
data: Uint8Array;
|
|
39
|
+
method: number;
|
|
40
|
+
crc32: number;
|
|
41
|
+
compressedSize: number;
|
|
42
|
+
uncompressedSize: number;
|
|
43
|
+
}
|
|
44
|
+
export declare const DEFAULT_MAX_ZIP_FILE_BYTES: number;
|
|
45
|
+
export declare const DEFAULT_MAX_ZIP_ENTRIES = 4096;
|
|
46
|
+
/**
|
|
47
|
+
* Compute standard IEEE 802.3 CRC-32 checksum.
|
|
48
|
+
*/
|
|
49
|
+
export declare function crc32(data: Uint8Array): number;
|
|
50
|
+
/**
|
|
51
|
+
* Reject absolute paths, drive letters, NUL bytes, backslashes, and `..` traversal.
|
|
52
|
+
*/
|
|
53
|
+
export declare function validateZipEntryName(name: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* Parse and decompress all entries in a ZIP archive with strict bounds checks.
|
|
56
|
+
*/
|
|
57
|
+
export declare function readZip(bytes: Uint8Array, options?: ZipReadOptions): Promise<Map<string, Uint8Array>>;
|
|
58
|
+
/**
|
|
59
|
+
* Create a ZIP archive synchronously using `STORE` (method 0).
|
|
60
|
+
*/
|
|
61
|
+
export declare function writeZipSync(entries: readonly ZipEntryInput[]): Uint8Array;
|
|
62
|
+
/**
|
|
63
|
+
* Create a ZIP archive, compressing entries with raw DEFLATE when smaller.
|
|
64
|
+
*/
|
|
65
|
+
export declare function writeZip(entries: readonly ZipEntryInput[], options?: ZipWriteOptions): Promise<Uint8Array>;
|
|
66
|
+
/** Supported 3MF `<model unit="...">` values. */
|
|
67
|
+
type ThreeMfUnit = "micron" | "millimeter" | "centimeter" | "inch" | "foot" | "meter";
|
|
68
|
+
/** Options for {@link import3MF}. */
|
|
69
|
+
interface ThreeMfImportOptions {
|
|
70
|
+
/** Maximum accepted ZIP archive / uncompressed payload size in bytes. Default: 512 MiB. */
|
|
71
|
+
maxFileBytes?: number;
|
|
72
|
+
/** Override millimeter scale factor instead of reading `<model unit="...">`. */
|
|
73
|
+
unitScale?: number;
|
|
74
|
+
/** Optional abort signal. */
|
|
75
|
+
signal?: AbortSignal;
|
|
76
|
+
}
|
|
77
|
+
/** Options for {@link export3MF} and {@link export3MFSync}. */
|
|
78
|
+
interface ThreeMfExportOptions extends ExportOptions {
|
|
79
|
+
/** Model coordinate unit stored in `<model unit="...">`. Defaults to `"millimeter"`. */
|
|
80
|
+
unit?: ThreeMfUnit;
|
|
81
|
+
/** Write per-vertex/per-triangle RGBA colors when present on the mesh. Defaults to `true`. */
|
|
82
|
+
vertexColors?: boolean;
|
|
83
|
+
/** Deflate-compress ZIP entries in async {@link export3MF}. Defaults to `true`. */
|
|
84
|
+
compress?: boolean;
|
|
85
|
+
/** Object name (or prefix when exporting multiple meshes). Defaults to `"mesh"`. */
|
|
86
|
+
name?: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Parse a 3MF archive into {@link ImportedMesh} records scaled to millimeters.
|
|
90
|
+
*/
|
|
91
|
+
export declare function import3MF(bytes: Uint8Array | ArrayBuffer, options?: ThreeMfImportOptions): Promise<ImportedMesh[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Export one or more scene meshes as a compressed 3MF archive.
|
|
94
|
+
*/
|
|
95
|
+
export declare function export3MF(scene: SceneLike, meshes: MeshHandle | readonly MeshHandle[], options?: ThreeMfExportOptions): Promise<Uint8Array>;
|
|
96
|
+
/**
|
|
97
|
+
* Export one or more scene meshes synchronously as an uncompressed (`STORE`) 3MF archive.
|
|
98
|
+
*/
|
|
99
|
+
export declare function export3MFSync(scene: SceneLike, meshes: MeshHandle | readonly MeshHandle[], options?: ThreeMfExportOptions): Uint8Array;
|
|
100
|
+
/** Options for {@link importPLY}. */
|
|
101
|
+
interface PlyImportOptions {
|
|
102
|
+
/** Mesh name assigned to the imported record. Defaults to `"mesh"`. */
|
|
103
|
+
name?: string;
|
|
104
|
+
/** Maximum accepted file size in bytes. Default: 512 MiB. */
|
|
105
|
+
maxFileBytes?: number;
|
|
106
|
+
/** Optional abort signal. */
|
|
107
|
+
signal?: AbortSignal;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Parse an ASCII or binary (little- or big-endian) PLY file into an {@link ImportedMesh}.
|
|
111
|
+
*/
|
|
112
|
+
export declare function importPLY(bytes: Uint8Array | ArrayBuffer, options?: PlyImportOptions): ImportedMesh;
|
|
113
|
+
/** Options for {@link importSTL}. */
|
|
114
|
+
interface StlImportOptions {
|
|
115
|
+
/** Override mesh name. Defaults to ASCII `solid` name or `"mesh"`. */
|
|
116
|
+
name?: string;
|
|
117
|
+
/** Weld coincident vertices (`-0` normalized to `0`) via spatial hashing. Default: `false`. */
|
|
118
|
+
deduplicateVertices?: boolean;
|
|
119
|
+
/** Maximum accepted file size in bytes. Default: 512 MiB. */
|
|
120
|
+
maxFileBytes?: number;
|
|
121
|
+
/** Optional abort signal. */
|
|
122
|
+
signal?: AbortSignal;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Parse a binary or ASCII STL payload into an {@link ImportedMesh}.
|
|
126
|
+
*/
|
|
127
|
+
export declare function importSTL(bytes: Uint8Array | ArrayBuffer, options?: StlImportOptions): ImportedMesh;
|
|
128
|
+
/** Options for {@link importOBJ}. */
|
|
129
|
+
interface ObjImportOptions {
|
|
130
|
+
/** Override base mesh name when no `o`/`g` header is present or when merging groups. */
|
|
131
|
+
name?: string;
|
|
132
|
+
/** Merge all `o`/`g` groups into a single {@link ImportedMesh}. Default: `false`. */
|
|
133
|
+
mergeGroups?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Ignore normals/UVs/colors and keep vertices in original file order without
|
|
136
|
+
* splitting attribute seams. Default: `false`.
|
|
137
|
+
*/
|
|
138
|
+
positionsOnly?: boolean;
|
|
139
|
+
/** Maximum accepted file size in bytes. Default: 512 MiB. */
|
|
140
|
+
maxFileBytes?: number;
|
|
141
|
+
/** Optional abort signal. */
|
|
142
|
+
signal?: AbortSignal;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Parse a Wavefront OBJ file into one or more {@link ImportedMesh} records.
|
|
146
|
+
*/
|
|
147
|
+
export declare function importOBJ(bytes: Uint8Array | ArrayBuffer, options?: ObjImportOptions): ImportedMesh[];
|
|
148
|
+
/** Normalized mesh format identifiers supported by the streaming importer. */
|
|
149
|
+
type MeshFileFormat = "threemf" | "ply" | "stl" | "obj" | "gltf" | "glb";
|
|
150
|
+
/** Progress event emitted by {@link parseMeshStream} and {@link loadMeshStream}. */
|
|
151
|
+
interface IoProgress {
|
|
152
|
+
/** Bytes read from the input source so far. */
|
|
153
|
+
bytesRead: number;
|
|
154
|
+
/** Expected total byte length when known (e.g. `Blob`/`File`/`Uint8Array`), else `null`. */
|
|
155
|
+
totalBytes: number | null;
|
|
156
|
+
/** Current pipeline stage. */
|
|
157
|
+
stage: "reading" | "parsing" | "building_bvh";
|
|
158
|
+
}
|
|
159
|
+
/** Supported input sources for {@link parseMeshStream} and {@link loadMeshStream}. */
|
|
160
|
+
type MeshStreamSource = ReadableStream<Uint8Array> | Blob | Uint8Array | ArrayBuffer;
|
|
161
|
+
/** Scene targets accepted by {@link loadMeshStream} (sync `Scene` or async `WorkerScene`). */
|
|
162
|
+
type MeshLoadTarget = Scene | WorkerScene;
|
|
163
|
+
/** Unified options for {@link parseMeshStream} and {@link loadMeshStream}. */
|
|
164
|
+
interface ImportOptions extends GltfImportOptions {
|
|
165
|
+
/** Explicitly override format detection (accepts `"3mf"` alias for `"threemf"`). */
|
|
166
|
+
format?: MeshFileFormat | "3mf";
|
|
167
|
+
/** Filename or path hint used for extension-based format detection. */
|
|
168
|
+
filename?: string;
|
|
169
|
+
/** Maximum accepted payload size in bytes. Default: 512 MiB. */
|
|
170
|
+
maxFileBytes?: number;
|
|
171
|
+
/** Override 3MF millimeter unit scale factor. */
|
|
172
|
+
unitScale?: number;
|
|
173
|
+
/** Weld duplicate vertices when importing STL meshes. Default: `false`. */
|
|
174
|
+
deduplicateVertices?: boolean;
|
|
175
|
+
/** Merge OBJ `o`/`g` groups into a single mesh. Default: `false`. */
|
|
176
|
+
mergeGroups?: boolean;
|
|
177
|
+
/** Optional abort signal to cancel reading, parsing, or scene upload. */
|
|
178
|
+
signal?: AbortSignal;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Detect a mesh file format from header magic bytes and/or filename extension.
|
|
182
|
+
*/
|
|
183
|
+
export declare function detectMeshFormat(bytesOrFilename?: Uint8Array | ArrayBuffer | string | null, filename?: string): MeshFileFormat | null;
|
|
184
|
+
/**
|
|
185
|
+
* Stream, detect format, and parse a mesh from a `ReadableStream`, `Blob`/`File`,
|
|
186
|
+
* `Uint8Array`, or `ArrayBuffer` without loading Worker/Wasm state.
|
|
187
|
+
*/
|
|
188
|
+
export declare function parseMeshStream(source: MeshStreamSource, options?: ImportOptions, onProgress?: (progress: IoProgress) => void, signal?: AbortSignal): Promise<ImportedMesh[]>;
|
|
189
|
+
/**
|
|
190
|
+
* Stream, parse, and upload meshes into either a synchronous {@link Scene} or
|
|
191
|
+
* an asynchronous {@link WorkerScene}, emitting `"reading"`, `"parsing"`, and
|
|
192
|
+
* `"building_bvh"` progress stages. Cleans up partial meshes on abort or error.
|
|
193
|
+
*/
|
|
194
|
+
export declare function loadMeshStream(scene: MeshLoadTarget, source: MeshStreamSource, options?: ImportOptions, onProgress?: (progress: IoProgress) => void, signal?: AbortSignal): Promise<MeshHandle[]>;
|
|
2
195
|
/** Shared by every exporter: whether local render coordinates are mapped to the world. */
|
|
3
196
|
export interface ExportOptions {
|
|
4
197
|
/**
|
|
@@ -23,6 +216,8 @@ export interface StlExportOptions extends ExportOptions {
|
|
|
23
216
|
export interface ObjExportOptions extends ExportOptions {
|
|
24
217
|
/** The `o` object name. Defaults to `"mesh"`. */
|
|
25
218
|
name?: string;
|
|
219
|
+
/** Append `r g b` 0..1 vertex colors on `v` lines when present. Defaults to `true`. */
|
|
220
|
+
vertexColors?: boolean;
|
|
26
221
|
}
|
|
27
222
|
/** Options of {@link exportPLY}. */
|
|
28
223
|
export interface PlyExportOptions extends ExportOptions {
|
|
@@ -116,8 +311,9 @@ export interface DracoQuantizationBits {
|
|
|
116
311
|
/** TEX_COORD bits, over the UVs' range. Defaults to `16`. */
|
|
117
312
|
uv?: number;
|
|
118
313
|
/**
|
|
119
|
-
*
|
|
120
|
-
*
|
|
314
|
+
* The same as {@link DracoQuantizationBits.uv}, which wins when both are set.
|
|
315
|
+
*
|
|
316
|
+
* @deprecated Use `uv`.
|
|
121
317
|
*/
|
|
122
318
|
texCoord?: number;
|
|
123
319
|
}
|
|
@@ -189,7 +385,8 @@ export declare function encodeDraco(positions: ArrayLike<number>, indices: Array
|
|
|
189
385
|
*
|
|
190
386
|
* Only uncompressed buffers are read. `KHR_draco_mesh_compression`
|
|
191
387
|
* primitives throw (decode them with {@link importGLTFAsync}), as do sparse
|
|
192
|
-
* accessors
|
|
388
|
+
* accessors, except a sparse `TEXCOORD_0`, which is skipped like any other
|
|
389
|
+
* unsupported UVs: see {@link ImportedMesh.uvsSkipped}. External (non-embedded) `.bin` buffers load through
|
|
193
390
|
* {@link importGLTFAsync}'s `resolveBuffer`. Animations, skins, materials
|
|
194
391
|
* beyond per-vertex colors and `TEXCOORD_1` and up are skipped: the documented
|
|
195
392
|
* subset.
|
|
@@ -208,8 +405,23 @@ export interface ImportedMesh {
|
|
|
208
405
|
/**
|
|
209
406
|
* 2 floats per vertex from `TEXCOORD_0` (`scene.addMesh`'s `uvs`), or `null`
|
|
210
407
|
* without UVs. In glTF's convention: `v` points down from the image's top.
|
|
408
|
+
*
|
|
409
|
+
* Read as glTF defines it: float as stored, and normalized `u8`/`u16` mapped
|
|
410
|
+
* to `[0, 1]`. An asset declaring `KHR_mesh_quantization` may also use `i8`
|
|
411
|
+
* and `i16`, normalized to `[-1, 1]`, and any of the integer types without
|
|
412
|
+
* `normalized`, whose values stay as stored. Such values usually rely on a
|
|
413
|
+
* `KHR_texture_transform` on the material to scale them, which is not read.
|
|
211
414
|
*/
|
|
212
415
|
uvs: Float32Array | null;
|
|
416
|
+
/**
|
|
417
|
+
* Why a present `TEXCOORD_0` was left out, so `uvs` is `null` while the
|
|
418
|
+
* geometry still imports: a sparse accessor, or a component type glTF does
|
|
419
|
+
* not allow for it. Absent when nothing was skipped. Malformed UVs (a wrong
|
|
420
|
+
* count or accessor type, non-finite values) throw instead.
|
|
421
|
+
*/
|
|
422
|
+
uvsSkipped?: string;
|
|
423
|
+
/** Optional vertex normals (3 floats per vertex), when supplied by the format (e.g. PLY, OBJ). */
|
|
424
|
+
normals?: Float32Array | null;
|
|
213
425
|
}
|
|
214
426
|
/**
|
|
215
427
|
* Reads a glTF 2.0 asset: a binary `.glb`, or a `.gltf` JSON whose buffers
|
|
@@ -303,4 +515,5 @@ export declare function decodeDraco(bytes: Uint8Array | ArrayBuffer, options?: D
|
|
|
303
515
|
* to decode, a primitive is not a triangle mesh, or the file holds no
|
|
304
516
|
* triangle meshes.
|
|
305
517
|
*/
|
|
306
|
-
export declare function importGLTFAsync(bytes: Uint8Array | ArrayBuffer, options?: GltfImportOptions): Promise<ImportedMesh[]>;
|
|
518
|
+
export declare function importGLTFAsync(bytes: Uint8Array | ArrayBuffer, options?: GltfImportOptions): Promise<ImportedMesh[]>;
|
|
519
|
+
export type { ImportOptions, IoProgress, MeshFileFormat, MeshLoadTarget, MeshStreamSource, ObjImportOptions, PlyImportOptions, StlImportOptions, ThreeMfExportOptions, ThreeMfImportOptions, ThreeMfUnit, ZipEntry, ZipEntryInput, ZipReadOptions, ZipWriteOptions };
|