fast-mesh-wasm 0.6.0 → 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.
Files changed (37) hide show
  1. package/dist/{client-BrTp2eMp.js → client-DFgvktkT.js} +164 -10
  2. package/dist/{client-Ds09vLkN.d.ts → client-nvmbhtn-.d.ts} +76 -14
  3. package/dist/{engine-DjdY3GxK.js → engine-BL5_sWAf.js} +15 -4
  4. package/dist/io.d.ts +200 -2
  5. package/dist/io.js +3057 -3
  6. package/dist/{mesh-BsqIofgT.d.ts → mesh-BHTFxsXc.d.ts} +1 -1
  7. package/dist/node.d.ts +2 -2
  8. package/dist/node.js +3 -2
  9. package/dist/{protocol-Cb23HelE.d.ts → protocol-DFR0JDAS.d.ts} +3 -1
  10. package/dist/r3f.d.ts +3 -3
  11. package/dist/r3f.js +1 -1
  12. package/dist/react.d.ts +2 -2
  13. package/dist/{scene-D0HNTwoo.js → scene-DUsj6uJD.js} +346 -30
  14. package/dist/{scene-like-CADk1vfb.d.ts → scene-like-CR_Dpohm.d.ts} +902 -146
  15. package/dist/{store-BfC6kkf5.d.ts → store-8HWG90Jg.d.ts} +14 -3
  16. package/dist/{store-DIQmxF_s.js → store-BAzHRRkt.js} +18 -2
  17. package/dist/store.d.ts +3 -3
  18. package/dist/store.js +1 -1
  19. package/dist/three.d.ts +2 -2
  20. package/dist/views-BSy-Qeg8.js +584 -0
  21. package/dist/wasm/fast_mesh_wasm.d.ts +7 -0
  22. package/dist/wasm/fast_mesh_wasm.js +21 -0
  23. package/dist/wasm/fast_mesh_wasm_bg.wasm +0 -0
  24. package/dist/wasm/fast_mesh_wasm_bg.wasm.d.ts +1 -0
  25. package/dist/wasm-threads/fast_mesh_wasm.d.ts +7 -0
  26. package/dist/wasm-threads/fast_mesh_wasm.js +21 -0
  27. package/dist/wasm-threads/fast_mesh_wasm_bg.wasm +0 -0
  28. package/dist/wasm-threads/fast_mesh_wasm_bg.wasm.d.ts +1 -0
  29. package/dist/web.d.ts +2 -2
  30. package/dist/web.js +3 -2
  31. package/dist/worker-engine.d.ts +1 -1
  32. package/dist/worker-engine.js +1 -1
  33. package/dist/worker-entry.js +1 -1
  34. package/dist/worker.d.ts +1 -1
  35. package/dist/worker.js +1 -1
  36. package/package.json +1 -1
  37. package/dist/views-B00kdV0R.js +0 -214
package/dist/io.d.ts CHANGED
@@ -1,4 +1,197 @@
1
- import { Ot as MeshHandle, t as SceneLike } from "./scene-like-CADk1vfb.js";
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 {
@@ -225,6 +420,8 @@ export interface ImportedMesh {
225
420
  * count or accessor type, non-finite values) throw instead.
226
421
  */
227
422
  uvsSkipped?: string;
423
+ /** Optional vertex normals (3 floats per vertex), when supplied by the format (e.g. PLY, OBJ). */
424
+ normals?: Float32Array | null;
228
425
  }
229
426
  /**
230
427
  * Reads a glTF 2.0 asset: a binary `.glb`, or a `.gltf` JSON whose buffers
@@ -318,4 +515,5 @@ export declare function decodeDraco(bytes: Uint8Array | ArrayBuffer, options?: D
318
515
  * to decode, a primitive is not a triangle mesh, or the file holds no
319
516
  * triangle meshes.
320
517
  */
321
- 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 };