@francisdb/vpin-wasm 0.29.0 → 0.30.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/package.json +1 -1
- package/vpin.d.ts +80 -0
- package/vpin.js +49 -0
- package/vpin_bg.wasm +0 -0
- package/vpin_bg.wasm.d.ts +1 -0
package/package.json
CHANGED
package/vpin.d.ts
CHANGED
|
@@ -27,6 +27,47 @@ export interface GlbExportOptions {
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Options for `export_obj`. Pass a plain object literal; every field
|
|
32
|
+
* is optional.
|
|
33
|
+
*/
|
|
34
|
+
export interface ObjExportOptions {
|
|
35
|
+
/**
|
|
36
|
+
* Axis convention of the written OBJ. Default:
|
|
37
|
+
* `AxisConvention.ZDownRightHanded`, vpinball's own OBJ export
|
|
38
|
+
* layout. Use `AxisConvention.YUpRightHanded` for Blender and most
|
|
39
|
+
* other tools with default import settings.
|
|
40
|
+
*/
|
|
41
|
+
axes?: AxisConvention;
|
|
42
|
+
/**
|
|
43
|
+
* Unit of the written positions. Default: `ExportUnits.M`.
|
|
44
|
+
*/
|
|
45
|
+
units?: ExportUnits;
|
|
46
|
+
/**
|
|
47
|
+
* Emit one `newmtl` block per distinct (material, texture) pair
|
|
48
|
+
* instead of one per `usemtl`. Default: `true`.
|
|
49
|
+
*/
|
|
50
|
+
dedupMtlBlocks?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Write the referenced textures to `images/` and reference them
|
|
53
|
+
* from the MTL. Default: `true`.
|
|
54
|
+
*/
|
|
55
|
+
extractTextures?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Include the plunger mesh. Default: `true`.
|
|
58
|
+
*/
|
|
59
|
+
includePlunger?: boolean;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Result of `export_obj`: path relative to the export directory to file
|
|
64
|
+
* contents, e.g. `{ "table.obj": Uint8Array, "table.mtl": Uint8Array,
|
|
65
|
+
* "images/playfield.png": Uint8Array }`.
|
|
66
|
+
*/
|
|
67
|
+
export type ObjExportFileMap = Record<string, Uint8Array>;
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
30
71
|
/**
|
|
31
72
|
* Options for `mesh_to_glb`. Pass a plain object literal; every field
|
|
32
73
|
* is optional.
|
|
@@ -108,6 +149,34 @@ export enum AxisConvention {
|
|
|
108
149
|
YUpRightHanded = 2,
|
|
109
150
|
}
|
|
110
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Output unit for table exports (OBJ, glTF/GLB).
|
|
154
|
+
*
|
|
155
|
+
* VPinball internally uses "VP Units" (VPU): 50 VPU = 1.0625 inches
|
|
156
|
+
* (one pinball diameter), so a standard table around 20 inches wide
|
|
157
|
+
* is roughly 950 VPU. Loaded straight into a tool that treats
|
|
158
|
+
* numbers as metres, that becomes a ~950 m table. Pick a metric
|
|
159
|
+
* variant to scale positions on the way out.
|
|
160
|
+
*/
|
|
161
|
+
export enum ExportUnits {
|
|
162
|
+
/**
|
|
163
|
+
* Raw VPinball Units (no scaling).
|
|
164
|
+
*/
|
|
165
|
+
Vpu = 0,
|
|
166
|
+
/**
|
|
167
|
+
* Millimetres.
|
|
168
|
+
*/
|
|
169
|
+
Mm = 1,
|
|
170
|
+
/**
|
|
171
|
+
* Centimetres.
|
|
172
|
+
*/
|
|
173
|
+
Cm = 2,
|
|
174
|
+
/**
|
|
175
|
+
* Metres.
|
|
176
|
+
*/
|
|
177
|
+
M = 3,
|
|
178
|
+
}
|
|
179
|
+
|
|
111
180
|
/**
|
|
112
181
|
* Mesh data for a single primitive: positions, texture coordinates,
|
|
113
182
|
* normals and triangle indices, packed as flat typed arrays for direct
|
|
@@ -175,6 +244,16 @@ export function assemble(files: VpxFileMap, callback?: Function | null): Uint8Ar
|
|
|
175
244
|
*/
|
|
176
245
|
export function export_glb(files: VpxFileMap, options?: GlbExportOptions | null, callback?: Function | null): Uint8Array;
|
|
177
246
|
|
|
247
|
+
/**
|
|
248
|
+
* Export a whole table as a Wavefront OBJ with its MTL and, by
|
|
249
|
+
* default, the referenced textures. Takes the file map produced by
|
|
250
|
+
* `extract` and returns a file map relative to the export directory:
|
|
251
|
+
* `table.obj`, `table.mtl` and `images/*`.
|
|
252
|
+
*
|
|
253
|
+
* Sound entries are ignored like in `export_glb`.
|
|
254
|
+
*/
|
|
255
|
+
export function export_obj(files: VpxFileMap, options?: ObjExportOptions | null, callback?: Function | null): ObjExportFileMap;
|
|
256
|
+
|
|
178
257
|
export function extract(data: Uint8Array, callback?: Function | null): VpxFileMap;
|
|
179
258
|
|
|
180
259
|
/**
|
|
@@ -293,6 +372,7 @@ export interface InitOutput {
|
|
|
293
372
|
readonly __wbg_primitivemesh_free: (a: number, b: number) => void;
|
|
294
373
|
readonly assemble: (a: any, b: number) => [number, number, number, number];
|
|
295
374
|
readonly export_glb: (a: any, b: number, c: number) => [number, number, number, number];
|
|
375
|
+
readonly export_obj: (a: any, b: number, c: number) => [number, number, number];
|
|
296
376
|
readonly extract: (a: number, b: number, c: number) => [number, number, number];
|
|
297
377
|
readonly generate_builtin_primitive: (a: number, b: number) => [number, number, number];
|
|
298
378
|
readonly mesh_to_glb: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => [number, number, number, number];
|
package/vpin.js
CHANGED
|
@@ -46,6 +46,35 @@ export const AxisConvention = Object.freeze({
|
|
|
46
46
|
YUpRightHanded: 2, "2": "YUpRightHanded",
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Output unit for table exports (OBJ, glTF/GLB).
|
|
51
|
+
*
|
|
52
|
+
* VPinball internally uses "VP Units" (VPU): 50 VPU = 1.0625 inches
|
|
53
|
+
* (one pinball diameter), so a standard table around 20 inches wide
|
|
54
|
+
* is roughly 950 VPU. Loaded straight into a tool that treats
|
|
55
|
+
* numbers as metres, that becomes a ~950 m table. Pick a metric
|
|
56
|
+
* variant to scale positions on the way out.
|
|
57
|
+
* @enum {0 | 1 | 2 | 3}
|
|
58
|
+
*/
|
|
59
|
+
export const ExportUnits = Object.freeze({
|
|
60
|
+
/**
|
|
61
|
+
* Raw VPinball Units (no scaling).
|
|
62
|
+
*/
|
|
63
|
+
Vpu: 0, "0": "Vpu",
|
|
64
|
+
/**
|
|
65
|
+
* Millimetres.
|
|
66
|
+
*/
|
|
67
|
+
Mm: 1, "1": "Mm",
|
|
68
|
+
/**
|
|
69
|
+
* Centimetres.
|
|
70
|
+
*/
|
|
71
|
+
Cm: 2, "2": "Cm",
|
|
72
|
+
/**
|
|
73
|
+
* Metres.
|
|
74
|
+
*/
|
|
75
|
+
M: 3, "3": "M",
|
|
76
|
+
});
|
|
77
|
+
|
|
49
78
|
/**
|
|
50
79
|
* Mesh data for a single primitive: positions, texture coordinates,
|
|
51
80
|
* normals and triangle indices, packed as flat typed arrays for direct
|
|
@@ -194,6 +223,26 @@ export function export_glb(files, options, callback) {
|
|
|
194
223
|
return v1;
|
|
195
224
|
}
|
|
196
225
|
|
|
226
|
+
/**
|
|
227
|
+
* Export a whole table as a Wavefront OBJ with its MTL and, by
|
|
228
|
+
* default, the referenced textures. Takes the file map produced by
|
|
229
|
+
* `extract` and returns a file map relative to the export directory:
|
|
230
|
+
* `table.obj`, `table.mtl` and `images/*`.
|
|
231
|
+
*
|
|
232
|
+
* Sound entries are ignored like in `export_glb`.
|
|
233
|
+
* @param {VpxFileMap} files
|
|
234
|
+
* @param {ObjExportOptions | null} [options]
|
|
235
|
+
* @param {Function | null} [callback]
|
|
236
|
+
* @returns {ObjExportFileMap}
|
|
237
|
+
*/
|
|
238
|
+
export function export_obj(files, options, callback) {
|
|
239
|
+
const ret = wasm.export_obj(files, isLikeNone(options) ? 0 : addToExternrefTable0(options), isLikeNone(callback) ? 0 : addToExternrefTable0(callback));
|
|
240
|
+
if (ret[2]) {
|
|
241
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
242
|
+
}
|
|
243
|
+
return takeFromExternrefTable0(ret[0]);
|
|
244
|
+
}
|
|
245
|
+
|
|
197
246
|
/**
|
|
198
247
|
* @param {Uint8Array} data
|
|
199
248
|
* @param {Function | null} [callback]
|
package/vpin_bg.wasm
CHANGED
|
Binary file
|
package/vpin_bg.wasm.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export const memory: WebAssembly.Memory;
|
|
|
4
4
|
export const __wbg_primitivemesh_free: (a: number, b: number) => void;
|
|
5
5
|
export const assemble: (a: any, b: number) => [number, number, number, number];
|
|
6
6
|
export const export_glb: (a: any, b: number, c: number) => [number, number, number, number];
|
|
7
|
+
export const export_obj: (a: any, b: number, c: number) => [number, number, number];
|
|
7
8
|
export const extract: (a: number, b: number, c: number) => [number, number, number];
|
|
8
9
|
export const generate_builtin_primitive: (a: number, b: number) => [number, number, number];
|
|
9
10
|
export const mesh_to_glb: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => [number, number, number, number];
|