fast-mesh-wasm 0.0.0-stage → 0.1.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 CHANGED
@@ -1,3 +1,105 @@
1
- # Temporary Holding Version
1
+ # fast-mesh-wasm
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm](https://img.shields.io/npm/v/fast-mesh-wasm)](https://www.npmjs.com/package/fast-mesh-wasm)
4
+ [![CI](https://github.com/YoonDongGeun/fast-mesh-wasm/actions/workflows/ci.yml/badge.svg)](https://github.com/YoonDongGeun/fast-mesh-wasm/actions/workflows/ci.yml)
5
+ [![license](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue)](#license)
6
+
7
+ Fast triangle mesh utilities for JavaScript and TypeScript, written in Rust and compiled to WebAssembly.
8
+
9
+ - Works in browsers (Vite, webpack, Next.js), Node.js and Bun
10
+ - Installs the same way with npm, pnpm and bun. No native build step, no install scripts, zero dependencies
11
+ - Full TypeScript types and inline docs, generated from the Rust source
12
+ - Uses the flat buffer layout of WebGL and three.js `BufferGeometry`, so data goes in and out without conversion
13
+
14
+ > **Status:** early development (0.x). The API may change between minor versions.
15
+
16
+ ## Install
17
+
18
+ ```sh
19
+ npm install fast-mesh-wasm
20
+ pnpm add fast-mesh-wasm
21
+ bun add fast-mesh-wasm
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ```ts
27
+ import { init, computeVertexNormals, computeBounds } from "fast-mesh-wasm";
28
+
29
+ await init(); // loads the .wasm file; required in browsers, a no-op in Node.js and Bun
30
+
31
+ // A unit quad: 4 vertices, 2 triangles
32
+ const positions = new Float32Array([0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0]);
33
+ const indices = new Uint32Array([0, 1, 2, 0, 2, 3]);
34
+
35
+ const normals = computeVertexNormals(positions, indices);
36
+ // Float32Array [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1]
37
+
38
+ using bounds = computeBounds(positions); // freed automatically at the end of the block
39
+ bounds.min; // Float32Array [0, 0, 0]
40
+ bounds.max; // Float32Array [1, 1, 0]
41
+ ```
42
+
43
+ ### With three.js
44
+
45
+ ```ts
46
+ const geometry = new THREE.BufferGeometry();
47
+ geometry.setAttribute("position", new THREE.BufferAttribute(positions, 3));
48
+ geometry.setIndex(new THREE.BufferAttribute(indices, 1));
49
+
50
+ const normals = computeVertexNormals(
51
+ geometry.attributes.position.array as Float32Array,
52
+ geometry.index!.array as Uint32Array,
53
+ );
54
+ geometry.setAttribute("normal", new THREE.BufferAttribute(normals, 3));
55
+ ```
56
+
57
+ ## API
58
+
59
+ | Function | Returns | Description |
60
+ | --- | --- | --- |
61
+ | `init(input?)` | `Promise<void>` | Loads the WebAssembly module. Call once before anything else. Safe to call repeatedly. |
62
+ | `computeVertexNormals(positions, indices)` | `Float32Array` | Smooth, area-weighted per-vertex normals. Same length as `positions`. |
63
+ | `computeBounds(positions)` | `Bounds` | Axis-aligned bounding box with `min`, `max`, `center` and `size`. |
64
+
65
+ All functions throw an `Error` with a readable message when a buffer length is not a multiple of 3 or an index is out of range.
66
+
67
+ ### Memory
68
+
69
+ Objects returned as classes (such as `Bounds`) live in WebAssembly memory, which the JavaScript garbage collector does not reclaim right away. Release them with `using` (TypeScript 5.2+, modern runtimes) or by calling `.free()`:
70
+
71
+ ```ts
72
+ const bounds = computeBounds(positions);
73
+ try {
74
+ console.log(bounds.size);
75
+ } finally {
76
+ bounds.free();
77
+ }
78
+ ```
79
+
80
+ Typed arrays such as the result of `computeVertexNormals` are ordinary JavaScript copies and need no cleanup.
81
+
82
+ ## Supported environments
83
+
84
+ | Environment | Entry | Notes |
85
+ | --- | --- | --- |
86
+ | Browsers via a bundler | `dist/web.js` | Vite, webpack 5, Next.js and others copy the `.wasm` asset automatically |
87
+ | Node.js 22+ | `dist/node.js` | The module is ready on import |
88
+ | Bun | `dist/node.js` | Same as Node.js |
89
+
90
+ The right entry is picked automatically through the `exports` field of `package.json`. The package is ESM only.
91
+
92
+ ## Contributing
93
+
94
+ Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for setup, the build pipeline and the release process. Please follow the [Code of Conduct](CODE_OF_CONDUCT.md).
95
+
96
+ ## License
97
+
98
+ Licensed under either of
99
+
100
+ - Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or <https://www.apache.org/licenses/LICENSE-2.0>)
101
+ - MIT license ([LICENSE-MIT](LICENSE-MIT) or <https://opensource.org/licenses/MIT>)
102
+
103
+ at your option.
104
+
105
+ Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
package/dist/node.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { Bounds, computeBounds, computeVertexNormals } from "./wasm/fast_mesh_wasm.js";
2
+ //#region src/node.d.ts
3
+ /**
4
+ * Resolves immediately: in Node.js and Bun the module is ready as soon as it is imported.
5
+ * Exists so the same code runs in the browser, where `await init()` is required.
6
+ */
7
+ export declare function init(): Promise<void>;
8
+ //#endregion
9
+ export { Bounds, computeBounds, computeVertexNormals };
package/dist/node.js ADDED
@@ -0,0 +1,13 @@
1
+ import { Bounds, computeBounds, computeVertexNormals, initSync } from "./wasm/fast_mesh_wasm.js";
2
+ import { readFileSync } from "node:fs";
3
+ //#region src/node.ts
4
+ initSync({ module: readFileSync(new URL("./wasm/fast_mesh_wasm_bg.wasm", import.meta.url)) });
5
+ /**
6
+ * Resolves immediately: in Node.js and Bun the module is ready as soon as it is imported.
7
+ * Exists so the same code runs in the browser, where `await init()` is required.
8
+ */
9
+ function init() {
10
+ return Promise.resolve();
11
+ }
12
+ //#endregion
13
+ export { Bounds, computeBounds, computeVertexNormals, init };
@@ -0,0 +1,88 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Axis-aligned bounding box returned by {@link computeBounds}.
6
+ */
7
+ export class Bounds {
8
+ private constructor();
9
+ free(): void;
10
+ [Symbol.dispose](): void;
11
+ /**
12
+ * Box center `[x, y, z]`.
13
+ */
14
+ readonly center: Float32Array;
15
+ /**
16
+ * Largest `[x, y, z]` over all vertices.
17
+ */
18
+ readonly max: Float32Array;
19
+ /**
20
+ * Smallest `[x, y, z]` over all vertices.
21
+ */
22
+ readonly min: Float32Array;
23
+ /**
24
+ * Box extent `[width, height, depth]`.
25
+ */
26
+ readonly size: Float32Array;
27
+ }
28
+
29
+ /**
30
+ * Computes the axis-aligned bounding box of a mesh.
31
+ *
32
+ * The returned object owns WebAssembly memory. Call `free()` when done,
33
+ * or declare it with `using` so it is released automatically.
34
+ *
35
+ * @param positions - Vertex positions `[x0, y0, z0, x1, ...]`. Length must be a multiple of 3.
36
+ * @throws If `positions` is empty or its length is not a multiple of 3.
37
+ */
38
+ export function computeBounds(positions: Float32Array): Bounds;
39
+
40
+ /**
41
+ * Computes smooth, area-weighted per-vertex normals.
42
+ *
43
+ * @param positions - Vertex positions `[x0, y0, z0, x1, ...]`. Length must be a multiple of 3.
44
+ * @param indices - Triangle indices `[a0, b0, c0, a1, ...]`. Length must be a multiple of 3.
45
+ * @returns Normals with the same length as `positions`. Unused vertices get `[0, 0, 0]`.
46
+ * @throws If a buffer length is not a multiple of 3 or an index is out of range.
47
+ */
48
+ export function computeVertexNormals(positions: Float32Array, indices: Uint32Array): Float32Array;
49
+
50
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
51
+
52
+ export interface InitOutput {
53
+ readonly memory: WebAssembly.Memory;
54
+ readonly __wbg_bounds_free: (a: number, b: number) => void;
55
+ readonly bounds_center: (a: number) => [number, number];
56
+ readonly bounds_max: (a: number) => [number, number];
57
+ readonly bounds_min: (a: number) => [number, number];
58
+ readonly bounds_size: (a: number) => [number, number];
59
+ readonly computeBounds: (a: number, b: number) => [number, number, number];
60
+ readonly computeVertexNormals: (a: number, b: number, c: number, d: number) => [number, number, number, number];
61
+ readonly __wbindgen_externrefs: WebAssembly.Table;
62
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
63
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
64
+ readonly __externref_table_dealloc: (a: number) => void;
65
+ readonly __wbindgen_start: () => void;
66
+ }
67
+
68
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
69
+
70
+ /**
71
+ * Instantiates the given `module`, which can either be bytes or
72
+ * a precompiled `WebAssembly.Module`.
73
+ *
74
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
75
+ *
76
+ * @returns {InitOutput}
77
+ */
78
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
79
+
80
+ /**
81
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
82
+ * for everything else, calls `WebAssembly.instantiate` directly.
83
+ *
84
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
85
+ *
86
+ * @returns {Promise<InitOutput>}
87
+ */
88
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,307 @@
1
+ /* @ts-self-types="./fast_mesh_wasm.d.ts" */
2
+
3
+ /**
4
+ * Axis-aligned bounding box returned by {@link computeBounds}.
5
+ */
6
+ export class Bounds {
7
+ static __wrap(ptr) {
8
+ const obj = Object.create(Bounds.prototype);
9
+ obj.__wbg_ptr = ptr;
10
+ BoundsFinalization.register(obj, obj.__wbg_ptr, obj);
11
+ return obj;
12
+ }
13
+ __destroy_into_raw() {
14
+ const ptr = this.__wbg_ptr;
15
+ this.__wbg_ptr = 0;
16
+ BoundsFinalization.unregister(this);
17
+ return ptr;
18
+ }
19
+ free() {
20
+ const ptr = this.__destroy_into_raw();
21
+ wasm.__wbg_bounds_free(ptr, 0);
22
+ }
23
+ /**
24
+ * Box center `[x, y, z]`.
25
+ * @returns {Float32Array}
26
+ */
27
+ get center() {
28
+ const ret = wasm.bounds_center(this.__wbg_ptr);
29
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
30
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
31
+ return v1;
32
+ }
33
+ /**
34
+ * Largest `[x, y, z]` over all vertices.
35
+ * @returns {Float32Array}
36
+ */
37
+ get max() {
38
+ const ret = wasm.bounds_max(this.__wbg_ptr);
39
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
40
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
41
+ return v1;
42
+ }
43
+ /**
44
+ * Smallest `[x, y, z]` over all vertices.
45
+ * @returns {Float32Array}
46
+ */
47
+ get min() {
48
+ const ret = wasm.bounds_min(this.__wbg_ptr);
49
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
50
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
51
+ return v1;
52
+ }
53
+ /**
54
+ * Box extent `[width, height, depth]`.
55
+ * @returns {Float32Array}
56
+ */
57
+ get size() {
58
+ const ret = wasm.bounds_size(this.__wbg_ptr);
59
+ var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
60
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
61
+ return v1;
62
+ }
63
+ }
64
+ if (Symbol.dispose) Bounds.prototype[Symbol.dispose] = Bounds.prototype.free;
65
+
66
+ /**
67
+ * Computes the axis-aligned bounding box of a mesh.
68
+ *
69
+ * The returned object owns WebAssembly memory. Call `free()` when done,
70
+ * or declare it with `using` so it is released automatically.
71
+ *
72
+ * @param positions - Vertex positions `[x0, y0, z0, x1, ...]`. Length must be a multiple of 3.
73
+ * @throws If `positions` is empty or its length is not a multiple of 3.
74
+ * @param {Float32Array} positions
75
+ * @returns {Bounds}
76
+ */
77
+ export function computeBounds(positions) {
78
+ const ptr0 = passArrayF32ToWasm0(positions, wasm.__wbindgen_malloc);
79
+ const len0 = WASM_VECTOR_LEN;
80
+ const ret = wasm.computeBounds(ptr0, len0);
81
+ if (ret[2]) {
82
+ throw takeFromExternrefTable0(ret[1]);
83
+ }
84
+ return Bounds.__wrap(ret[0]);
85
+ }
86
+
87
+ /**
88
+ * Computes smooth, area-weighted per-vertex normals.
89
+ *
90
+ * @param positions - Vertex positions `[x0, y0, z0, x1, ...]`. Length must be a multiple of 3.
91
+ * @param indices - Triangle indices `[a0, b0, c0, a1, ...]`. Length must be a multiple of 3.
92
+ * @returns Normals with the same length as `positions`. Unused vertices get `[0, 0, 0]`.
93
+ * @throws If a buffer length is not a multiple of 3 or an index is out of range.
94
+ * @param {Float32Array} positions
95
+ * @param {Uint32Array} indices
96
+ * @returns {Float32Array}
97
+ */
98
+ export function computeVertexNormals(positions, indices) {
99
+ const ptr0 = passArrayF32ToWasm0(positions, wasm.__wbindgen_malloc);
100
+ const len0 = WASM_VECTOR_LEN;
101
+ const ptr1 = passArray32ToWasm0(indices, wasm.__wbindgen_malloc);
102
+ const len1 = WASM_VECTOR_LEN;
103
+ const ret = wasm.computeVertexNormals(ptr0, len0, ptr1, len1);
104
+ if (ret[3]) {
105
+ throw takeFromExternrefTable0(ret[2]);
106
+ }
107
+ var v3 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
108
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
109
+ return v3;
110
+ }
111
+ function __wbg_get_imports() {
112
+ const import0 = {
113
+ __proto__: null,
114
+ __wbg_Error_30c8987f7c2ed4e2: function(arg0, arg1) {
115
+ const ret = Error(getStringFromWasm0(arg0, arg1));
116
+ return ret;
117
+ },
118
+ __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
119
+ throw new Error(getStringFromWasm0(arg0, arg1));
120
+ },
121
+ __wbindgen_init_externref_table: function() {
122
+ const table = wasm.__wbindgen_externrefs;
123
+ const offset = table.grow(4);
124
+ table.set(0, undefined);
125
+ table.set(offset + 0, undefined);
126
+ table.set(offset + 1, null);
127
+ table.set(offset + 2, true);
128
+ table.set(offset + 3, false);
129
+ },
130
+ };
131
+ return {
132
+ __proto__: null,
133
+ "./fast_mesh_wasm_bg.js": import0,
134
+ };
135
+ }
136
+
137
+ const BoundsFinalization = (typeof FinalizationRegistry === 'undefined')
138
+ ? { register: () => {}, unregister: () => {} }
139
+ : new FinalizationRegistry(ptr => wasm.__wbg_bounds_free(ptr, 1));
140
+
141
+ function getArrayF32FromWasm0(ptr, len) {
142
+ ptr = ptr >>> 0;
143
+ return getFloat32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
144
+ }
145
+
146
+ let cachedFloat32ArrayMemory0 = null;
147
+ function getFloat32ArrayMemory0() {
148
+ if (cachedFloat32ArrayMemory0 === null || cachedFloat32ArrayMemory0.byteLength === 0) {
149
+ cachedFloat32ArrayMemory0 = new Float32Array(wasm.memory.buffer);
150
+ }
151
+ return cachedFloat32ArrayMemory0;
152
+ }
153
+
154
+ function getStringFromWasm0(ptr, len) {
155
+ return decodeText(ptr >>> 0, len);
156
+ }
157
+
158
+ let cachedUint32ArrayMemory0 = null;
159
+ function getUint32ArrayMemory0() {
160
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
161
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
162
+ }
163
+ return cachedUint32ArrayMemory0;
164
+ }
165
+
166
+ let cachedUint8ArrayMemory0 = null;
167
+ function getUint8ArrayMemory0() {
168
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
169
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
170
+ }
171
+ return cachedUint8ArrayMemory0;
172
+ }
173
+
174
+ function passArray32ToWasm0(arg, malloc) {
175
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
176
+ getUint32ArrayMemory0().set(arg, ptr / 4);
177
+ WASM_VECTOR_LEN = arg.length;
178
+ return ptr;
179
+ }
180
+
181
+ function passArrayF32ToWasm0(arg, malloc) {
182
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
183
+ getFloat32ArrayMemory0().set(arg, ptr / 4);
184
+ WASM_VECTOR_LEN = arg.length;
185
+ return ptr;
186
+ }
187
+
188
+ function takeFromExternrefTable0(idx) {
189
+ const value = wasm.__wbindgen_externrefs.get(idx);
190
+ wasm.__externref_table_dealloc(idx);
191
+ return value;
192
+ }
193
+
194
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
195
+ cachedTextDecoder.decode();
196
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
197
+ let numBytesDecoded = 0;
198
+ function decodeText(ptr, len) {
199
+ numBytesDecoded += len;
200
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
201
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
202
+ cachedTextDecoder.decode();
203
+ numBytesDecoded = len;
204
+ }
205
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
206
+ }
207
+
208
+ let WASM_VECTOR_LEN = 0;
209
+
210
+ let wasmModule, wasmInstance, wasm;
211
+ function __wbg_finalize_init(instance, module) {
212
+ wasmInstance = instance;
213
+ wasm = instance.exports;
214
+ wasmModule = module;
215
+ cachedFloat32ArrayMemory0 = null;
216
+ cachedUint32ArrayMemory0 = null;
217
+ cachedUint8ArrayMemory0 = null;
218
+ wasm.__wbindgen_start();
219
+ return wasm;
220
+ }
221
+
222
+ async function __wbg_load(module, imports) {
223
+ if (typeof Response === 'function' && module instanceof Response) {
224
+ if (!module.ok) {
225
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
226
+ }
227
+
228
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
229
+ try {
230
+ return await WebAssembly.instantiateStreaming(module, imports);
231
+ } catch (e) {
232
+ const validResponse = expectedResponseType(module.type);
233
+
234
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
235
+ 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);
236
+
237
+ } else { throw e; }
238
+ }
239
+ }
240
+
241
+ const bytes = await module.arrayBuffer();
242
+ return await WebAssembly.instantiate(bytes, imports);
243
+ } else {
244
+ const instance = await WebAssembly.instantiate(module, imports);
245
+
246
+ if (instance instanceof WebAssembly.Instance) {
247
+ return { instance, module };
248
+ } else {
249
+ return instance;
250
+ }
251
+ }
252
+
253
+ function expectedResponseType(type) {
254
+ switch (type) {
255
+ case 'basic': case 'cors': case 'default': return true;
256
+ }
257
+ return false;
258
+ }
259
+ }
260
+
261
+ function initSync(module) {
262
+ if (wasm !== undefined) return wasm;
263
+
264
+
265
+ if (module !== undefined) {
266
+ if (Object.getPrototypeOf(module) === Object.prototype) {
267
+ ({module} = module)
268
+ } else {
269
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
270
+ }
271
+ }
272
+
273
+ const imports = __wbg_get_imports();
274
+ if (!(module instanceof WebAssembly.Module)) {
275
+ module = new WebAssembly.Module(module);
276
+ }
277
+ const instance = new WebAssembly.Instance(module, imports);
278
+ return __wbg_finalize_init(instance, module);
279
+ }
280
+
281
+ async function __wbg_init(module_or_path) {
282
+ if (wasm !== undefined) return wasm;
283
+
284
+
285
+ if (module_or_path !== undefined) {
286
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
287
+ ({module_or_path} = module_or_path)
288
+ } else {
289
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
290
+ }
291
+ }
292
+
293
+ if (module_or_path === undefined) {
294
+ module_or_path = new URL('fast_mesh_wasm_bg.wasm', import.meta.url);
295
+ }
296
+ const imports = __wbg_get_imports();
297
+
298
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
299
+ module_or_path = fetch(module_or_path);
300
+ }
301
+
302
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
303
+
304
+ return __wbg_finalize_init(instance, module);
305
+ }
306
+
307
+ export { initSync, __wbg_init as default };
Binary file
@@ -0,0 +1,15 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const __wbg_bounds_free: (a: number, b: number) => void;
5
+ export const bounds_center: (a: number) => [number, number];
6
+ export const bounds_max: (a: number) => [number, number];
7
+ export const bounds_min: (a: number) => [number, number];
8
+ export const bounds_size: (a: number) => [number, number];
9
+ export const computeBounds: (a: number, b: number) => [number, number, number];
10
+ export const computeVertexNormals: (a: number, b: number, c: number, d: number) => [number, number, number, number];
11
+ export const __wbindgen_externrefs: WebAssembly.Table;
12
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
13
+ export const __wbindgen_malloc: (a: number, b: number) => number;
14
+ export const __externref_table_dealloc: (a: number) => void;
15
+ export const __wbindgen_start: () => void;
package/dist/web.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { Bounds, InitInput, computeBounds, computeVertexNormals } from "./wasm/fast_mesh_wasm.js";
2
+ //#region src/web.d.ts
3
+ /**
4
+ * Loads the WebAssembly module. Await this once before calling any other function.
5
+ * Calling it again returns the same promise.
6
+ *
7
+ * @param input - Optional custom source for the `.wasm` file (URL, Response, bytes or module).
8
+ * Leave empty to load the file shipped with this package.
9
+ */
10
+ export declare function init(input?: InitInput | Promise<InitInput>): Promise<void>;
11
+ //#endregion
12
+ export { Bounds, computeBounds, computeVertexNormals };
package/dist/web.js ADDED
@@ -0,0 +1,16 @@
1
+ import wasmInit, { Bounds, computeBounds, computeVertexNormals } from "./wasm/fast_mesh_wasm.js";
2
+ //#region src/web.ts
3
+ let ready;
4
+ /**
5
+ * Loads the WebAssembly module. Await this once before calling any other function.
6
+ * Calling it again returns the same promise.
7
+ *
8
+ * @param input - Optional custom source for the `.wasm` file (URL, Response, bytes or module).
9
+ * Leave empty to load the file shipped with this package.
10
+ */
11
+ function init(input) {
12
+ ready ??= wasmInit(input === void 0 ? void 0 : { module_or_path: input }).then(() => {});
13
+ return ready;
14
+ }
15
+ //#endregion
16
+ export { Bounds, computeBounds, computeVertexNormals, init };
package/package.json CHANGED
@@ -1,6 +1,63 @@
1
1
  {
2
2
  "name": "fast-mesh-wasm",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Fast triangle mesh utilities for JavaScript, written in Rust and compiled to WebAssembly",
5
+ "keywords": [
6
+ "mesh",
7
+ "geometry",
8
+ "normals",
9
+ "bounding-box",
10
+ "webassembly",
11
+ "wasm",
12
+ "rust",
13
+ "threejs"
14
+ ],
15
+ "homepage": "https://github.com/YoonDongGeun/fast-mesh-wasm#readme",
16
+ "bugs": "https://github.com/YoonDongGeun/fast-mesh-wasm/issues",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/YoonDongGeun/fast-mesh-wasm.git",
20
+ "directory": "packages/fast-mesh-wasm"
21
+ },
22
+ "license": "MIT OR Apache-2.0",
23
+ "author": "DongGeun Yoon",
24
+ "type": "module",
25
+ "sideEffects": false,
26
+ "exports": {
27
+ ".": {
28
+ "node": {
29
+ "types": "./dist/node.d.ts",
30
+ "default": "./dist/node.js"
31
+ },
32
+ "default": {
33
+ "types": "./dist/web.d.ts",
34
+ "default": "./dist/web.js"
35
+ }
36
+ },
37
+ "./package.json": "./package.json"
38
+ },
39
+ "types": "./dist/web.d.ts",
40
+ "files": [
41
+ "dist"
42
+ ],
43
+ "engines": {
44
+ "node": ">=22"
45
+ },
46
+ "devDependencies": {
47
+ "@arethetypeswrong/cli": "^0.18.5",
48
+ "@types/node": "^24.19.2",
49
+ "publint": "^0.3.25",
50
+ "tsdown": "^0.23.1",
51
+ "typescript": "^7.0.2",
52
+ "vitest": "^5.0.4"
53
+ },
54
+ "publishConfig": {
55
+ "access": "public",
56
+ "provenance": true
57
+ },
58
+ "scripts": {
59
+ "build": "tsdown",
60
+ "test": "vitest run",
61
+ "check": "publint --strict && attw --pack . --profile esm-only"
62
+ }
6
63
  }