@ifc-lite/wasm 1.0.0 → 1.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.
@@ -0,0 +1,592 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export class GeoReferenceJs {
5
+ private constructor();
6
+ free(): void;
7
+ [Symbol.dispose](): void;
8
+ /**
9
+ * Transform local coordinates to map coordinates
10
+ */
11
+ localToMap(x: number, y: number, z: number): Float64Array;
12
+ /**
13
+ * Transform map coordinates to local coordinates
14
+ */
15
+ mapToLocal(e: number, n: number, h: number): Float64Array;
16
+ /**
17
+ * Get 4x4 transformation matrix (column-major for WebGL)
18
+ */
19
+ toMatrix(): Float64Array;
20
+ /**
21
+ * Get CRS name
22
+ */
23
+ readonly crsName: string | undefined;
24
+ /**
25
+ * Get rotation angle in radians
26
+ */
27
+ readonly rotation: number;
28
+ /**
29
+ * Eastings (X offset)
30
+ */
31
+ eastings: number;
32
+ /**
33
+ * Northings (Y offset)
34
+ */
35
+ northings: number;
36
+ /**
37
+ * Orthogonal height (Z offset)
38
+ */
39
+ orthogonal_height: number;
40
+ /**
41
+ * X-axis abscissa (cos of rotation)
42
+ */
43
+ x_axis_abscissa: number;
44
+ /**
45
+ * X-axis ordinate (sin of rotation)
46
+ */
47
+ x_axis_ordinate: number;
48
+ /**
49
+ * Scale factor
50
+ */
51
+ scale: number;
52
+ }
53
+
54
+ export class IfcAPI {
55
+ free(): void;
56
+ [Symbol.dispose](): void;
57
+ /**
58
+ * Get WASM memory for zero-copy access
59
+ */
60
+ getMemory(): any;
61
+ /**
62
+ * Parse IFC file and return individual meshes with express IDs and colors
63
+ * This matches the MeshData[] format expected by the viewer
64
+ *
65
+ * Example:
66
+ * ```javascript
67
+ * const api = new IfcAPI();
68
+ * const collection = api.parseMeshes(ifcData);
69
+ * for (let i = 0; i < collection.length; i++) {
70
+ * const mesh = collection.get(i);
71
+ * console.log('Express ID:', mesh.expressId);
72
+ * console.log('Positions:', mesh.positions);
73
+ * console.log('Color:', mesh.color);
74
+ * }
75
+ * ```
76
+ */
77
+ parseMeshes(content: string): MeshCollection;
78
+ /**
79
+ * Parse IFC file with streaming events
80
+ * Calls the callback function for each parse event
81
+ *
82
+ * Example:
83
+ * ```javascript
84
+ * const api = new IfcAPI();
85
+ * await api.parseStreaming(ifcData, (event) => {
86
+ * console.log('Event:', event);
87
+ * });
88
+ * ```
89
+ */
90
+ parseStreaming(content: string, callback: Function): Promise<any>;
91
+ /**
92
+ * Parse IFC file with zero-copy mesh data
93
+ * Maximum performance - returns mesh with direct memory access
94
+ *
95
+ * Example:
96
+ * ```javascript
97
+ * const api = new IfcAPI();
98
+ * const mesh = await api.parseZeroCopy(ifcData);
99
+ *
100
+ * // Create TypedArray views (NO COPYING!)
101
+ * const memory = await api.getMemory();
102
+ * const positions = new Float32Array(
103
+ * memory.buffer,
104
+ * mesh.positions_ptr,
105
+ * mesh.positions_len
106
+ * );
107
+ *
108
+ * // Upload directly to GPU
109
+ * gl.bufferData(gl.ARRAY_BUFFER, positions, gl.STATIC_DRAW);
110
+ * ```
111
+ */
112
+ parseZeroCopy(content: string): ZeroCopyMesh;
113
+ /**
114
+ * Extract georeferencing information from IFC content
115
+ * Returns null if no georeferencing is present
116
+ *
117
+ * Example:
118
+ * ```javascript
119
+ * const api = new IfcAPI();
120
+ * const georef = api.getGeoReference(ifcData);
121
+ * if (georef) {
122
+ * console.log('CRS:', georef.crsName);
123
+ * const [e, n, h] = georef.localToMap(10, 20, 5);
124
+ * }
125
+ * ```
126
+ */
127
+ getGeoReference(content: string): GeoReferenceJs | undefined;
128
+ /**
129
+ * Parse IFC file with streaming mesh batches for progressive rendering
130
+ * Calls the callback with batches of meshes, yielding to browser between batches
131
+ *
132
+ * Example:
133
+ * ```javascript
134
+ * const api = new IfcAPI();
135
+ * await api.parseMeshesAsync(ifcData, {
136
+ * batchSize: 100,
137
+ * onBatch: (meshes, progress) => {
138
+ * // Add meshes to scene
139
+ * for (const mesh of meshes) {
140
+ * scene.add(createThreeMesh(mesh));
141
+ * }
142
+ * console.log(`Progress: ${progress.percent}%`);
143
+ * },
144
+ * onComplete: (stats) => {
145
+ * console.log(`Done! ${stats.totalMeshes} meshes`);
146
+ * }
147
+ * });
148
+ * ```
149
+ */
150
+ parseMeshesAsync(content: string, options: any): Promise<any>;
151
+ /**
152
+ * Parse IFC file and return mesh with RTC offset for large coordinates
153
+ * This handles georeferenced models by shifting to centroid
154
+ *
155
+ * Example:
156
+ * ```javascript
157
+ * const api = new IfcAPI();
158
+ * const result = api.parseMeshesWithRtc(ifcData);
159
+ * const rtcOffset = result.rtcOffset;
160
+ * const meshes = result.meshes;
161
+ *
162
+ * // Convert local coords back to world:
163
+ * if (rtcOffset.isSignificant()) {
164
+ * const [wx, wy, wz] = rtcOffset.toWorld(localX, localY, localZ);
165
+ * }
166
+ * ```
167
+ */
168
+ parseMeshesWithRtc(content: string): MeshCollectionWithRtc;
169
+ /**
170
+ * Parse IFC file and return instanced geometry grouped by geometry hash
171
+ * This reduces draw calls by grouping identical geometries with different transforms
172
+ *
173
+ * Example:
174
+ * ```javascript
175
+ * const api = new IfcAPI();
176
+ * const collection = api.parseMeshesInstanced(ifcData);
177
+ * for (let i = 0; i < collection.length; i++) {
178
+ * const geometry = collection.get(i);
179
+ * console.log('Geometry ID:', geometry.geometryId);
180
+ * console.log('Instances:', geometry.instanceCount);
181
+ * for (let j = 0; j < geometry.instanceCount; j++) {
182
+ * const inst = geometry.getInstance(j);
183
+ * console.log(' Express ID:', inst.expressId);
184
+ * console.log(' Transform:', inst.transform);
185
+ * }
186
+ * }
187
+ * ```
188
+ */
189
+ parseMeshesInstanced(content: string): InstancedMeshCollection;
190
+ /**
191
+ * Debug: Test processing entity #953 (FacetedBrep wall)
192
+ */
193
+ debugProcessEntity953(content: string): string;
194
+ /**
195
+ * Debug: Test processing a single wall
196
+ */
197
+ debugProcessFirstWall(content: string): string;
198
+ /**
199
+ * Parse IFC file with streaming instanced geometry batches for progressive rendering
200
+ * Groups identical geometries and yields batches of InstancedGeometry
201
+ * Uses fast-first-frame streaming: simple geometry (walls, slabs) first
202
+ *
203
+ * Example:
204
+ * ```javascript
205
+ * const api = new IfcAPI();
206
+ * await api.parseMeshesInstancedAsync(ifcData, {
207
+ * batchSize: 25, // Number of unique geometries per batch
208
+ * onBatch: (geometries, progress) => {
209
+ * for (const geom of geometries) {
210
+ * renderer.addInstancedGeometry(geom);
211
+ * }
212
+ * },
213
+ * onComplete: (stats) => {
214
+ * console.log(`Done! ${stats.totalGeometries} unique geometries, ${stats.totalInstances} instances`);
215
+ * }
216
+ * });
217
+ * ```
218
+ */
219
+ parseMeshesInstancedAsync(content: string, options: any): Promise<any>;
220
+ /**
221
+ * Create and initialize the IFC API
222
+ */
223
+ constructor();
224
+ /**
225
+ * Parse IFC file (traditional - waits for completion)
226
+ *
227
+ * Example:
228
+ * ```javascript
229
+ * const api = new IfcAPI();
230
+ * const result = await api.parse(ifcData);
231
+ * console.log('Entities:', result.entityCount);
232
+ * ```
233
+ */
234
+ parse(content: string): Promise<any>;
235
+ /**
236
+ * Get version string
237
+ */
238
+ readonly version: string;
239
+ /**
240
+ * Check if API is initialized
241
+ */
242
+ readonly is_ready: boolean;
243
+ }
244
+
245
+ export class InstanceData {
246
+ private constructor();
247
+ free(): void;
248
+ [Symbol.dispose](): void;
249
+ readonly expressId: number;
250
+ readonly color: Float32Array;
251
+ readonly transform: Float32Array;
252
+ }
253
+
254
+ export class InstancedGeometry {
255
+ private constructor();
256
+ free(): void;
257
+ [Symbol.dispose](): void;
258
+ get_instance(index: number): InstanceData | undefined;
259
+ readonly geometryId: bigint;
260
+ readonly instance_count: number;
261
+ readonly indices: Uint32Array;
262
+ readonly normals: Float32Array;
263
+ readonly positions: Float32Array;
264
+ }
265
+
266
+ export class InstancedMeshCollection {
267
+ private constructor();
268
+ free(): void;
269
+ [Symbol.dispose](): void;
270
+ get(index: number): InstancedGeometry | undefined;
271
+ readonly totalInstances: number;
272
+ readonly totalGeometries: number;
273
+ readonly length: number;
274
+ }
275
+
276
+ export class MeshCollection {
277
+ private constructor();
278
+ free(): void;
279
+ [Symbol.dispose](): void;
280
+ /**
281
+ * Get mesh at index
282
+ */
283
+ get(index: number): MeshDataJs | undefined;
284
+ /**
285
+ * Get total vertex count across all meshes
286
+ */
287
+ readonly totalVertices: number;
288
+ /**
289
+ * Get total triangle count across all meshes
290
+ */
291
+ readonly totalTriangles: number;
292
+ /**
293
+ * Get number of meshes
294
+ */
295
+ readonly length: number;
296
+ }
297
+
298
+ export class MeshCollectionWithRtc {
299
+ private constructor();
300
+ free(): void;
301
+ [Symbol.dispose](): void;
302
+ /**
303
+ * Get mesh at index
304
+ */
305
+ get(index: number): MeshDataJs | undefined;
306
+ /**
307
+ * Get the RTC offset
308
+ */
309
+ readonly rtcOffset: RtcOffsetJs;
310
+ /**
311
+ * Get number of meshes
312
+ */
313
+ readonly length: number;
314
+ /**
315
+ * Get the mesh collection
316
+ */
317
+ readonly meshes: MeshCollection;
318
+ }
319
+
320
+ export class MeshDataJs {
321
+ private constructor();
322
+ free(): void;
323
+ [Symbol.dispose](): void;
324
+ /**
325
+ * Get express ID
326
+ */
327
+ readonly expressId: number;
328
+ /**
329
+ * Get vertex count
330
+ */
331
+ readonly vertexCount: number;
332
+ /**
333
+ * Get triangle count
334
+ */
335
+ readonly triangleCount: number;
336
+ /**
337
+ * Get color as [r, g, b, a] array
338
+ */
339
+ readonly color: Float32Array;
340
+ /**
341
+ * Get indices as Uint32Array (copy to JS)
342
+ */
343
+ readonly indices: Uint32Array;
344
+ /**
345
+ * Get normals as Float32Array (copy to JS)
346
+ */
347
+ readonly normals: Float32Array;
348
+ /**
349
+ * Get positions as Float32Array (copy to JS)
350
+ */
351
+ readonly positions: Float32Array;
352
+ }
353
+
354
+ export class RtcOffsetJs {
355
+ private constructor();
356
+ free(): void;
357
+ [Symbol.dispose](): void;
358
+ /**
359
+ * Check if offset is significant (>10km)
360
+ */
361
+ isSignificant(): boolean;
362
+ /**
363
+ * Convert local coordinates to world coordinates
364
+ */
365
+ toWorld(x: number, y: number, z: number): Float64Array;
366
+ /**
367
+ * X offset (subtracted from positions)
368
+ */
369
+ x: number;
370
+ /**
371
+ * Y offset
372
+ */
373
+ y: number;
374
+ /**
375
+ * Z offset
376
+ */
377
+ z: number;
378
+ }
379
+
380
+ export class ZeroCopyMesh {
381
+ free(): void;
382
+ [Symbol.dispose](): void;
383
+ /**
384
+ * Get bounding box maximum point
385
+ */
386
+ bounds_max(): Float32Array;
387
+ /**
388
+ * Get bounding box minimum point
389
+ */
390
+ bounds_min(): Float32Array;
391
+ /**
392
+ * Create a new zero-copy mesh from a Mesh
393
+ */
394
+ constructor();
395
+ /**
396
+ * Get length of indices array
397
+ */
398
+ readonly indices_len: number;
399
+ /**
400
+ * Get pointer to indices array
401
+ */
402
+ readonly indices_ptr: number;
403
+ /**
404
+ * Get length of normals array
405
+ */
406
+ readonly normals_len: number;
407
+ /**
408
+ * Get pointer to normals array
409
+ */
410
+ readonly normals_ptr: number;
411
+ /**
412
+ * Get vertex count
413
+ */
414
+ readonly vertex_count: number;
415
+ /**
416
+ * Get length of positions array (in f32 elements, not bytes)
417
+ */
418
+ readonly positions_len: number;
419
+ /**
420
+ * Get pointer to positions array
421
+ * JavaScript can create Float32Array view: new Float32Array(memory.buffer, ptr, length)
422
+ */
423
+ readonly positions_ptr: number;
424
+ /**
425
+ * Get triangle count
426
+ */
427
+ readonly triangle_count: number;
428
+ /**
429
+ * Check if mesh is empty
430
+ */
431
+ readonly is_empty: boolean;
432
+ }
433
+
434
+ /**
435
+ * Get WASM memory to allow JavaScript to create TypedArray views
436
+ */
437
+ export function get_memory(): any;
438
+
439
+ /**
440
+ * Initialize the WASM module.
441
+ *
442
+ * This function is called automatically when the WASM module is loaded.
443
+ * It sets up panic hooks for better error messages in the browser console.
444
+ */
445
+ export function init(): void;
446
+
447
+ /**
448
+ * Get the version of IFC-Lite.
449
+ *
450
+ * # Returns
451
+ *
452
+ * Version string (e.g., "0.1.0")
453
+ *
454
+ * # Example
455
+ *
456
+ * ```javascript
457
+ * console.log(`IFC-Lite version: ${version()}`);
458
+ * ```
459
+ */
460
+ export function version(): string;
461
+
462
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
463
+
464
+ export interface InitOutput {
465
+ readonly memory: WebAssembly.Memory;
466
+ readonly __wbg_georeferencejs_free: (a: number, b: number) => void;
467
+ readonly __wbg_get_georeferencejs_eastings: (a: number) => number;
468
+ readonly __wbg_get_georeferencejs_northings: (a: number) => number;
469
+ readonly __wbg_get_georeferencejs_orthogonal_height: (a: number) => number;
470
+ readonly __wbg_get_georeferencejs_scale: (a: number) => number;
471
+ readonly __wbg_get_georeferencejs_x_axis_abscissa: (a: number) => number;
472
+ readonly __wbg_get_georeferencejs_x_axis_ordinate: (a: number) => number;
473
+ readonly __wbg_ifcapi_free: (a: number, b: number) => void;
474
+ readonly __wbg_instancedata_free: (a: number, b: number) => void;
475
+ readonly __wbg_instancedgeometry_free: (a: number, b: number) => void;
476
+ readonly __wbg_instancedmeshcollection_free: (a: number, b: number) => void;
477
+ readonly __wbg_meshcollection_free: (a: number, b: number) => void;
478
+ readonly __wbg_meshcollectionwithrtc_free: (a: number, b: number) => void;
479
+ readonly __wbg_meshdatajs_free: (a: number, b: number) => void;
480
+ readonly __wbg_rtcoffsetjs_free: (a: number, b: number) => void;
481
+ readonly __wbg_set_georeferencejs_eastings: (a: number, b: number) => void;
482
+ readonly __wbg_set_georeferencejs_northings: (a: number, b: number) => void;
483
+ readonly __wbg_set_georeferencejs_orthogonal_height: (a: number, b: number) => void;
484
+ readonly __wbg_set_georeferencejs_scale: (a: number, b: number) => void;
485
+ readonly __wbg_set_georeferencejs_x_axis_abscissa: (a: number, b: number) => void;
486
+ readonly __wbg_set_georeferencejs_x_axis_ordinate: (a: number, b: number) => void;
487
+ readonly __wbg_zerocopymesh_free: (a: number, b: number) => void;
488
+ readonly georeferencejs_crsName: (a: number, b: number) => void;
489
+ readonly georeferencejs_localToMap: (a: number, b: number, c: number, d: number, e: number) => void;
490
+ readonly georeferencejs_mapToLocal: (a: number, b: number, c: number, d: number, e: number) => void;
491
+ readonly georeferencejs_rotation: (a: number) => number;
492
+ readonly georeferencejs_toMatrix: (a: number, b: number) => void;
493
+ readonly ifcapi_debugProcessEntity953: (a: number, b: number, c: number, d: number) => void;
494
+ readonly ifcapi_debugProcessFirstWall: (a: number, b: number, c: number, d: number) => void;
495
+ readonly ifcapi_getGeoReference: (a: number, b: number, c: number) => number;
496
+ readonly ifcapi_getMemory: (a: number) => number;
497
+ readonly ifcapi_is_ready: (a: number) => number;
498
+ readonly ifcapi_new: () => number;
499
+ readonly ifcapi_parse: (a: number, b: number, c: number) => number;
500
+ readonly ifcapi_parseMeshes: (a: number, b: number, c: number) => number;
501
+ readonly ifcapi_parseMeshesAsync: (a: number, b: number, c: number, d: number) => number;
502
+ readonly ifcapi_parseMeshesInstanced: (a: number, b: number, c: number) => number;
503
+ readonly ifcapi_parseMeshesInstancedAsync: (a: number, b: number, c: number, d: number) => number;
504
+ readonly ifcapi_parseMeshesWithRtc: (a: number, b: number, c: number) => number;
505
+ readonly ifcapi_parseStreaming: (a: number, b: number, c: number, d: number) => number;
506
+ readonly ifcapi_parseZeroCopy: (a: number, b: number, c: number) => number;
507
+ readonly ifcapi_version: (a: number, b: number) => void;
508
+ readonly instancedata_color: (a: number, b: number) => void;
509
+ readonly instancedata_expressId: (a: number) => number;
510
+ readonly instancedata_transform: (a: number) => number;
511
+ readonly instancedgeometry_geometryId: (a: number) => bigint;
512
+ readonly instancedgeometry_get_instance: (a: number, b: number) => number;
513
+ readonly instancedgeometry_indices: (a: number) => number;
514
+ readonly instancedgeometry_instance_count: (a: number) => number;
515
+ readonly instancedgeometry_normals: (a: number) => number;
516
+ readonly instancedgeometry_positions: (a: number) => number;
517
+ readonly instancedmeshcollection_get: (a: number, b: number) => number;
518
+ readonly instancedmeshcollection_length: (a: number) => number;
519
+ readonly instancedmeshcollection_totalInstances: (a: number) => number;
520
+ readonly meshcollection_get: (a: number, b: number) => number;
521
+ readonly meshcollection_totalTriangles: (a: number) => number;
522
+ readonly meshcollection_totalVertices: (a: number) => number;
523
+ readonly meshcollectionwithrtc_get: (a: number, b: number) => number;
524
+ readonly meshcollectionwithrtc_length: (a: number) => number;
525
+ readonly meshcollectionwithrtc_meshes: (a: number) => number;
526
+ readonly meshcollectionwithrtc_rtcOffset: (a: number) => number;
527
+ readonly meshdatajs_color: (a: number, b: number) => void;
528
+ readonly meshdatajs_expressId: (a: number) => number;
529
+ readonly meshdatajs_indices: (a: number) => number;
530
+ readonly meshdatajs_normals: (a: number) => number;
531
+ readonly meshdatajs_positions: (a: number) => number;
532
+ readonly meshdatajs_triangleCount: (a: number) => number;
533
+ readonly meshdatajs_vertexCount: (a: number) => number;
534
+ readonly rtcoffsetjs_isSignificant: (a: number) => number;
535
+ readonly rtcoffsetjs_toWorld: (a: number, b: number, c: number, d: number, e: number) => void;
536
+ readonly version: (a: number) => void;
537
+ readonly zerocopymesh_bounds_max: (a: number, b: number) => void;
538
+ readonly zerocopymesh_bounds_min: (a: number, b: number) => void;
539
+ readonly zerocopymesh_indices_len: (a: number) => number;
540
+ readonly zerocopymesh_indices_ptr: (a: number) => number;
541
+ readonly zerocopymesh_is_empty: (a: number) => number;
542
+ readonly zerocopymesh_new: () => number;
543
+ readonly zerocopymesh_normals_len: (a: number) => number;
544
+ readonly zerocopymesh_normals_ptr: (a: number) => number;
545
+ readonly zerocopymesh_positions_len: (a: number) => number;
546
+ readonly zerocopymesh_positions_ptr: (a: number) => number;
547
+ readonly init: () => void;
548
+ readonly instancedmeshcollection_totalGeometries: (a: number) => number;
549
+ readonly meshcollection_length: (a: number) => number;
550
+ readonly __wbg_set_rtcoffsetjs_x: (a: number, b: number) => void;
551
+ readonly __wbg_set_rtcoffsetjs_y: (a: number, b: number) => void;
552
+ readonly __wbg_set_rtcoffsetjs_z: (a: number, b: number) => void;
553
+ readonly zerocopymesh_triangle_count: (a: number) => number;
554
+ readonly zerocopymesh_vertex_count: (a: number) => number;
555
+ readonly get_memory: () => number;
556
+ readonly __wbg_get_rtcoffsetjs_x: (a: number) => number;
557
+ readonly __wbg_get_rtcoffsetjs_y: (a: number) => number;
558
+ readonly __wbg_get_rtcoffsetjs_z: (a: number) => number;
559
+ readonly __wasm_bindgen_func_elem_295: (a: number, b: number) => void;
560
+ readonly __wasm_bindgen_func_elem_294: (a: number, b: number) => void;
561
+ readonly __wasm_bindgen_func_elem_306: (a: number, b: number, c: number) => void;
562
+ readonly __wasm_bindgen_func_elem_305: (a: number, b: number) => void;
563
+ readonly __wasm_bindgen_func_elem_340: (a: number, b: number, c: number, d: number) => void;
564
+ readonly __wbindgen_export: (a: number, b: number) => number;
565
+ readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
566
+ readonly __wbindgen_export3: (a: number) => void;
567
+ readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
568
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
569
+ readonly __wbindgen_start: () => void;
570
+ }
571
+
572
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
573
+
574
+ /**
575
+ * Instantiates the given `module`, which can either be bytes or
576
+ * a precompiled `WebAssembly.Module`.
577
+ *
578
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
579
+ *
580
+ * @returns {InitOutput}
581
+ */
582
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
583
+
584
+ /**
585
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
586
+ * for everything else, calls `WebAssembly.instantiate` directly.
587
+ *
588
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
589
+ *
590
+ * @returns {Promise<InitOutput>}
591
+ */
592
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;