@ifc-lite/wasm 1.2.1 → 1.5.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 CHANGED
@@ -5,7 +5,7 @@
5
5
  "IFC-Lite Contributors"
6
6
  ],
7
7
  "description": "WebAssembly bindings for IFC-Lite",
8
- "version": "1.2.1",
8
+ "version": "1.5.0",
9
9
  "license": "MPL-2.0",
10
10
  "repository": {
11
11
  "type": "git",
package/pkg/ifc-lite.d.ts CHANGED
@@ -54,6 +54,10 @@ export class GeoReferenceJs {
54
54
  export class GpuGeometry {
55
55
  free(): void;
56
56
  [Symbol.dispose](): void;
57
+ /**
58
+ * Set the RTC (Relative To Center) offset applied to coordinates
59
+ */
60
+ set_rtc_offset(x: number, y: number, z: number): void;
57
61
  /**
58
62
  * Get IFC type name by index
59
63
  */
@@ -78,6 +82,22 @@ export class GpuGeometry {
78
82
  * Get pointer to indices array for zero-copy view
79
83
  */
80
84
  readonly indicesPtr: number;
85
+ /**
86
+ * Get X component of RTC offset
87
+ */
88
+ readonly rtcOffsetX: number;
89
+ /**
90
+ * Get Y component of RTC offset
91
+ */
92
+ readonly rtcOffsetY: number;
93
+ /**
94
+ * Get Z component of RTC offset
95
+ */
96
+ readonly rtcOffsetZ: number;
97
+ /**
98
+ * Check if RTC offset is active (non-zero)
99
+ */
100
+ readonly hasRtcOffset: boolean;
81
101
  /**
82
102
  * Get length of vertex data array (in f32 elements, not bytes)
83
103
  */
@@ -256,13 +276,25 @@ export class IfcAPI {
256
276
  * Parse IFC file with streaming mesh batches for progressive rendering
257
277
  * Calls the callback with batches of meshes, yielding to browser between batches
258
278
  *
279
+ * Options:
280
+ * - `batchSize`: Number of meshes per batch (default: 25)
281
+ * - `onBatch(meshes, progress)`: Called for each batch of meshes
282
+ * - `onRtcOffset({x, y, z, hasRtc})`: Called early with RTC offset for camera/world setup
283
+ * - `onColorUpdate(Map<id, color>)`: Called with style updates after initial render
284
+ * - `onComplete(stats)`: Called when parsing completes with stats including rtcOffset
285
+ *
259
286
  * Example:
260
287
  * ```javascript
261
288
  * const api = new IfcAPI();
262
289
  * await api.parseMeshesAsync(ifcData, {
263
290
  * batchSize: 100,
291
+ * onRtcOffset: (rtc) => {
292
+ * if (rtc.hasRtc) {
293
+ * // Model uses large coordinates - adjust camera/world origin
294
+ * viewer.setWorldOffset(rtc.x, rtc.y, rtc.z);
295
+ * }
296
+ * },
264
297
  * onBatch: (meshes, progress) => {
265
- * // Add meshes to scene
266
298
  * for (const mesh of meshes) {
267
299
  * scene.add(createThreeMesh(mesh));
268
300
  * }
@@ -270,6 +302,7 @@ export class IfcAPI {
270
302
  * },
271
303
  * onComplete: (stats) => {
272
304
  * console.log(`Done! ${stats.totalMeshes} meshes`);
305
+ * // stats.rtcOffset also available here: {x, y, z, hasRtc}
273
306
  * }
274
307
  * });
275
308
  * ```
@@ -428,6 +461,22 @@ export class IfcAPI {
428
461
  * ```
429
462
  */
430
463
  parseMeshesInstancedAsync(content: string, options: any): Promise<any>;
464
+ /**
465
+ * Parse IFC file and extract symbolic representations (Plan, Annotation, FootPrint)
466
+ * These are 2D curves used for architectural drawings instead of sectioning 3D geometry
467
+ *
468
+ * Example:
469
+ * ```javascript
470
+ * const api = new IfcAPI();
471
+ * const symbols = api.parseSymbolicRepresentations(ifcData);
472
+ * console.log('Found', symbols.totalCount, 'symbolic items');
473
+ * for (let i = 0; i < symbols.polylineCount; i++) {
474
+ * const polyline = symbols.getPolyline(i);
475
+ * console.log('Polyline for', polyline.ifcType, ':', polyline.points);
476
+ * }
477
+ * ```
478
+ */
479
+ parseSymbolicRepresentations(content: string): SymbolicRepresentationCollection;
431
480
  /**
432
481
  * Parse IFC file to GPU-ready instanced geometry for zero-copy upload
433
482
  *
@@ -495,10 +544,32 @@ export class MeshCollection {
495
544
  private constructor();
496
545
  free(): void;
497
546
  [Symbol.dispose](): void;
547
+ /**
548
+ * Check if RTC offset is significant (>10km)
549
+ */
550
+ hasRtcOffset(): boolean;
551
+ /**
552
+ * Convert local coordinates to world coordinates
553
+ * Use this to convert mesh positions back to original IFC coordinates
554
+ */
555
+ localToWorld(x: number, y: number, z: number): Float64Array;
498
556
  /**
499
557
  * Get mesh at index
500
558
  */
501
559
  get(index: number): MeshDataJs | undefined;
560
+ /**
561
+ * Get RTC offset X (for converting local coords back to world coords)
562
+ * Add this to local X coordinates to get world X coordinates
563
+ */
564
+ readonly rtcOffsetX: number;
565
+ /**
566
+ * Get RTC offset Y
567
+ */
568
+ readonly rtcOffsetY: number;
569
+ /**
570
+ * Get RTC offset Z
571
+ */
572
+ readonly rtcOffsetZ: number;
502
573
  /**
503
574
  * Get total vertex count across all meshes
504
575
  */
@@ -507,6 +578,11 @@ export class MeshCollection {
507
578
  * Get total triangle count across all meshes
508
579
  */
509
580
  readonly totalTriangles: number;
581
+ /**
582
+ * Get building rotation angle in radians (from IfcSite placement)
583
+ * Returns None if no rotation was detected
584
+ */
585
+ readonly buildingRotation: number | undefined;
510
586
  /**
511
587
  * Get number of meshes
512
588
  */
@@ -599,6 +675,88 @@ export class RtcOffsetJs {
599
675
  z: number;
600
676
  }
601
677
 
678
+ export class SymbolicCircle {
679
+ private constructor();
680
+ free(): void;
681
+ [Symbol.dispose](): void;
682
+ readonly expressId: number;
683
+ readonly startAngle: number;
684
+ /**
685
+ * Check if this is a full circle
686
+ */
687
+ readonly isFullCircle: boolean;
688
+ readonly repIdentifier: string;
689
+ readonly radius: number;
690
+ readonly centerX: number;
691
+ readonly centerY: number;
692
+ readonly ifcType: string;
693
+ readonly endAngle: number;
694
+ }
695
+
696
+ export class SymbolicPolyline {
697
+ private constructor();
698
+ free(): void;
699
+ [Symbol.dispose](): void;
700
+ /**
701
+ * Get express ID of the parent element
702
+ */
703
+ readonly expressId: number;
704
+ /**
705
+ * Get number of points
706
+ */
707
+ readonly pointCount: number;
708
+ /**
709
+ * Get representation identifier ("Plan", "Annotation", "FootPrint", "Axis")
710
+ */
711
+ readonly repIdentifier: string;
712
+ /**
713
+ * Get 2D points as Float32Array [x1, y1, x2, y2, ...]
714
+ */
715
+ readonly points: Float32Array;
716
+ /**
717
+ * Get IFC type name (e.g., "IfcDoor", "IfcWindow")
718
+ */
719
+ readonly ifcType: string;
720
+ /**
721
+ * Check if this is a closed loop
722
+ */
723
+ readonly isClosed: boolean;
724
+ }
725
+
726
+ export class SymbolicRepresentationCollection {
727
+ private constructor();
728
+ free(): void;
729
+ [Symbol.dispose](): void;
730
+ /**
731
+ * Get circle at index
732
+ */
733
+ getCircle(index: number): SymbolicCircle | undefined;
734
+ /**
735
+ * Get polyline at index
736
+ */
737
+ getPolyline(index: number): SymbolicPolyline | undefined;
738
+ /**
739
+ * Get all express IDs that have symbolic representations
740
+ */
741
+ getExpressIds(): Uint32Array;
742
+ /**
743
+ * Get total count of all symbolic items
744
+ */
745
+ readonly totalCount: number;
746
+ /**
747
+ * Get number of circles/arcs
748
+ */
749
+ readonly circleCount: number;
750
+ /**
751
+ * Get number of polylines
752
+ */
753
+ readonly polylineCount: number;
754
+ /**
755
+ * Check if collection is empty
756
+ */
757
+ readonly isEmpty: boolean;
758
+ }
759
+
602
760
  export class ZeroCopyMesh {
603
761
  free(): void;
604
762
  [Symbol.dispose](): void;
@@ -711,6 +869,9 @@ export interface InitOutput {
711
869
  readonly __wbg_set_georeferencejs_scale: (a: number, b: number) => void;
712
870
  readonly __wbg_set_georeferencejs_x_axis_abscissa: (a: number, b: number) => void;
713
871
  readonly __wbg_set_georeferencejs_x_axis_ordinate: (a: number, b: number) => void;
872
+ readonly __wbg_symboliccircle_free: (a: number, b: number) => void;
873
+ readonly __wbg_symbolicpolyline_free: (a: number, b: number) => void;
874
+ readonly __wbg_symbolicrepresentationcollection_free: (a: number, b: number) => void;
714
875
  readonly __wbg_zerocopymesh_free: (a: number, b: number) => void;
715
876
  readonly georeferencejs_crsName: (a: number, b: number) => void;
716
877
  readonly georeferencejs_localToMap: (a: number, b: number, c: number, d: number, e: number) => void;
@@ -719,12 +880,17 @@ export interface InitOutput {
719
880
  readonly georeferencejs_toMatrix: (a: number, b: number) => void;
720
881
  readonly gpugeometry_getIfcTypeName: (a: number, b: number, c: number) => void;
721
882
  readonly gpugeometry_getMeshMetadata: (a: number, b: number) => number;
883
+ readonly gpugeometry_hasRtcOffset: (a: number) => number;
722
884
  readonly gpugeometry_indicesByteLength: (a: number) => number;
723
885
  readonly gpugeometry_indicesLen: (a: number) => number;
724
886
  readonly gpugeometry_indicesPtr: (a: number) => number;
725
887
  readonly gpugeometry_isEmpty: (a: number) => number;
726
888
  readonly gpugeometry_meshCount: (a: number) => number;
727
889
  readonly gpugeometry_new: () => number;
890
+ readonly gpugeometry_rtcOffsetX: (a: number) => number;
891
+ readonly gpugeometry_rtcOffsetY: (a: number) => number;
892
+ readonly gpugeometry_rtcOffsetZ: (a: number) => number;
893
+ readonly gpugeometry_set_rtc_offset: (a: number, b: number, c: number, d: number) => void;
728
894
  readonly gpugeometry_totalTriangleCount: (a: number) => number;
729
895
  readonly gpugeometry_totalVertexCount: (a: number) => number;
730
896
  readonly gpugeometry_vertexDataByteLength: (a: number) => number;
@@ -744,6 +910,7 @@ export interface InitOutput {
744
910
  readonly gpuinstancedgeometry_vertexCount: (a: number) => number;
745
911
  readonly gpuinstancedgeometry_vertexDataByteLength: (a: number) => number;
746
912
  readonly gpuinstancedgeometry_vertexDataLen: (a: number) => number;
913
+ readonly gpuinstancedgeometry_vertexDataPtr: (a: number) => number;
747
914
  readonly gpuinstancedgeometrycollection_get: (a: number, b: number) => number;
748
915
  readonly gpuinstancedgeometrycollection_getRef: (a: number, b: number) => number;
749
916
  readonly gpuinstancedgeometrycollection_length: (a: number) => number;
@@ -780,6 +947,7 @@ export interface InitOutput {
780
947
  readonly ifcapi_parseMeshesInstancedAsync: (a: number, b: number, c: number, d: number) => number;
781
948
  readonly ifcapi_parseMeshesWithRtc: (a: number, b: number, c: number) => number;
782
949
  readonly ifcapi_parseStreaming: (a: number, b: number, c: number, d: number) => number;
950
+ readonly ifcapi_parseSymbolicRepresentations: (a: number, b: number, c: number) => number;
783
951
  readonly ifcapi_parseToGpuGeometry: (a: number, b: number, c: number) => number;
784
952
  readonly ifcapi_parseToGpuGeometryAsync: (a: number, b: number, c: number, d: number) => number;
785
953
  readonly ifcapi_parseToGpuInstancedGeometry: (a: number, b: number, c: number) => number;
@@ -797,12 +965,16 @@ export interface InitOutput {
797
965
  readonly instancedgeometry_positions: (a: number) => number;
798
966
  readonly instancedmeshcollection_get: (a: number, b: number) => number;
799
967
  readonly instancedmeshcollection_totalInstances: (a: number) => number;
968
+ readonly meshcollection_buildingRotation: (a: number, b: number) => void;
800
969
  readonly meshcollection_get: (a: number, b: number) => number;
970
+ readonly meshcollection_hasRtcOffset: (a: number) => number;
801
971
  readonly meshcollection_length: (a: number) => number;
972
+ readonly meshcollection_localToWorld: (a: number, b: number, c: number, d: number, e: number) => void;
973
+ readonly meshcollection_rtcOffsetY: (a: number) => number;
974
+ readonly meshcollection_rtcOffsetZ: (a: number) => number;
802
975
  readonly meshcollection_totalTriangles: (a: number) => number;
803
976
  readonly meshcollection_totalVertices: (a: number) => number;
804
977
  readonly meshcollectionwithrtc_get: (a: number, b: number) => number;
805
- readonly meshcollectionwithrtc_length: (a: number) => number;
806
978
  readonly meshcollectionwithrtc_meshes: (a: number) => number;
807
979
  readonly meshcollectionwithrtc_rtcOffset: (a: number) => number;
808
980
  readonly meshdatajs_color: (a: number, b: number) => void;
@@ -812,43 +984,66 @@ export interface InitOutput {
812
984
  readonly meshdatajs_normals: (a: number) => number;
813
985
  readonly meshdatajs_positions: (a: number) => number;
814
986
  readonly meshdatajs_triangleCount: (a: number) => number;
987
+ readonly meshdatajs_vertexCount: (a: number) => number;
815
988
  readonly rtcoffsetjs_isSignificant: (a: number) => number;
816
989
  readonly rtcoffsetjs_toWorld: (a: number, b: number, c: number, d: number, e: number) => void;
990
+ readonly symboliccircle_centerX: (a: number) => number;
991
+ readonly symboliccircle_centerY: (a: number) => number;
992
+ readonly symboliccircle_endAngle: (a: number) => number;
993
+ readonly symboliccircle_ifcType: (a: number, b: number) => void;
994
+ readonly symboliccircle_isFullCircle: (a: number) => number;
995
+ readonly symboliccircle_radius: (a: number) => number;
996
+ readonly symboliccircle_repIdentifier: (a: number, b: number) => void;
997
+ readonly symboliccircle_startAngle: (a: number) => number;
998
+ readonly symbolicpolyline_expressId: (a: number) => number;
999
+ readonly symbolicpolyline_ifcType: (a: number, b: number) => void;
1000
+ readonly symbolicpolyline_isClosed: (a: number) => number;
1001
+ readonly symbolicpolyline_pointCount: (a: number) => number;
1002
+ readonly symbolicpolyline_points: (a: number) => number;
1003
+ readonly symbolicpolyline_repIdentifier: (a: number, b: number) => void;
1004
+ readonly symbolicrepresentationcollection_circleCount: (a: number) => number;
1005
+ readonly symbolicrepresentationcollection_getCircle: (a: number, b: number) => number;
1006
+ readonly symbolicrepresentationcollection_getExpressIds: (a: number, b: number) => void;
1007
+ readonly symbolicrepresentationcollection_getPolyline: (a: number, b: number) => number;
1008
+ readonly symbolicrepresentationcollection_isEmpty: (a: number) => number;
1009
+ readonly symbolicrepresentationcollection_polylineCount: (a: number) => number;
1010
+ readonly symbolicrepresentationcollection_totalCount: (a: number) => number;
817
1011
  readonly version: (a: number) => void;
818
1012
  readonly zerocopymesh_bounds_max: (a: number, b: number) => void;
819
1013
  readonly zerocopymesh_bounds_min: (a: number, b: number) => void;
1014
+ readonly zerocopymesh_is_empty: (a: number) => number;
820
1015
  readonly zerocopymesh_new: () => number;
1016
+ readonly zerocopymesh_normals_len: (a: number) => number;
1017
+ readonly zerocopymesh_positions_len: (a: number) => number;
1018
+ readonly zerocopymesh_positions_ptr: (a: number) => number;
821
1019
  readonly zerocopymesh_vertex_count: (a: number) => number;
822
1020
  readonly init: () => void;
823
1021
  readonly instancedmeshcollection_length: (a: number) => number;
824
1022
  readonly instancedmeshcollection_totalGeometries: (a: number) => number;
1023
+ readonly meshcollectionwithrtc_length: (a: number) => number;
825
1024
  readonly zerocopymesh_indices_len: (a: number) => number;
826
- readonly zerocopymesh_normals_len: (a: number) => number;
827
- readonly zerocopymesh_positions_len: (a: number) => number;
828
1025
  readonly __wbg_set_rtcoffsetjs_x: (a: number, b: number) => void;
829
1026
  readonly __wbg_set_rtcoffsetjs_y: (a: number, b: number) => void;
830
1027
  readonly __wbg_set_rtcoffsetjs_z: (a: number, b: number) => void;
831
- readonly meshdatajs_vertexCount: (a: number) => number;
832
1028
  readonly zerocopymesh_triangle_count: (a: number) => number;
833
1029
  readonly get_memory: () => number;
834
- readonly gpuinstancedgeometry_vertexDataPtr: (a: number) => number;
835
1030
  readonly zerocopymesh_indices_ptr: (a: number) => number;
836
1031
  readonly zerocopymesh_normals_ptr: (a: number) => number;
837
- readonly zerocopymesh_positions_ptr: (a: number) => number;
838
- readonly zerocopymesh_is_empty: (a: number) => number;
839
1032
  readonly __wbg_get_rtcoffsetjs_x: (a: number) => number;
840
1033
  readonly __wbg_get_rtcoffsetjs_y: (a: number) => number;
841
1034
  readonly __wbg_get_rtcoffsetjs_z: (a: number) => number;
842
1035
  readonly instancedgeometry_geometryId: (a: number) => bigint;
843
- readonly __wasm_bindgen_func_elem_393: (a: number, b: number) => void;
844
- readonly __wasm_bindgen_func_elem_389: (a: number, b: number) => void;
845
- readonly __wasm_bindgen_func_elem_725: (a: number, b: number, c: number) => void;
846
- readonly __wasm_bindgen_func_elem_720: (a: number, b: number) => void;
847
- readonly __wasm_bindgen_func_elem_756: (a: number, b: number, c: number, d: number) => void;
848
- readonly __wbindgen_export: (a: number, b: number) => number;
849
- readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
850
- readonly __wbindgen_export3: (a: number) => void;
851
- readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
1036
+ readonly meshcollection_rtcOffsetX: (a: number) => number;
1037
+ readonly symboliccircle_expressId: (a: number) => number;
1038
+ readonly __wasm_bindgen_func_elem_474: (a: number, b: number) => void;
1039
+ readonly __wasm_bindgen_func_elem_472: (a: number, b: number) => void;
1040
+ readonly __wasm_bindgen_func_elem_921: (a: number, b: number, c: number) => void;
1041
+ readonly __wasm_bindgen_func_elem_919: (a: number, b: number) => void;
1042
+ readonly __wasm_bindgen_func_elem_952: (a: number, b: number, c: number, d: number) => void;
1043
+ readonly __wbindgen_export: (a: number) => void;
1044
+ readonly __wbindgen_export2: (a: number, b: number, c: number) => void;
1045
+ readonly __wbindgen_export3: (a: number, b: number) => number;
1046
+ readonly __wbindgen_export4: (a: number, b: number, c: number, d: number) => number;
852
1047
  readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
853
1048
  readonly __wbindgen_start: () => void;
854
1049
  }