@ifc-lite/wasm 2.8.0 → 2.8.1

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": "2.8.0",
8
+ "version": "2.8.1",
9
9
  "license": "MPL-2.0",
10
10
  "repository": {
11
11
  "type": "git",
package/pkg/ifc-lite.d.ts CHANGED
@@ -91,7 +91,7 @@ export class IfcAPI {
91
91
  * Process geometry for a subset of pre-scanned entities.
92
92
  * Takes raw bytes and pre-pass data from buildPrePassOnce.
93
93
  */
94
- processGeometryBatch(data: Uint8Array, jobs_flat: Uint32Array, unit_scale: number, rtc_x: number, rtc_y: number, rtc_z: number, needs_shift: boolean, void_keys: Uint32Array, void_counts: Uint32Array, void_values: Uint32Array, style_ids: Uint32Array, style_colors: Uint8Array): MeshCollection;
94
+ processGeometryBatch(data: Uint8Array, jobs_flat: Uint32Array, unit_scale: number, rtc_x: number, rtc_y: number, rtc_z: number, needs_shift: boolean, void_keys: Uint32Array, void_counts: Uint32Array, void_values: Uint32Array, style_ids: Uint32Array, style_colors: Uint8Array, plane_angle_to_radians?: number | null, material_element_ids?: Uint32Array | null, material_color_counts?: Uint32Array | null, material_colors_rgba?: Uint8Array | null): MeshCollection;
95
95
  /**
96
96
  * Streaming pre-pass: emits geometry jobs in chunks via a JS callback
97
97
  * instead of waiting for the full file scan to complete.
@@ -117,7 +117,7 @@ export class IfcAPI {
117
117
  * `{ type: "jobs", jobs: Uint32Array }` // [id, start, end] triples
118
118
  * `{ type: "complete", totalJobs }`
119
119
  */
120
- buildPrePassStreaming(data: Uint8Array, on_event: Function, chunk_size: number): any;
120
+ buildPrePassStreaming(data: Uint8Array, on_event: Function, chunk_size: number, disabled_type_names: string[] | null | undefined, skip_type_geometry: boolean): any;
121
121
  /**
122
122
  * Parse the file and return structured per-axis data (tag + endpoints) in
123
123
  * the renderer's Y-up world space (RTC-subtracted, metres). Use this when
@@ -306,9 +306,19 @@ export class MeshCollection {
306
306
  */
307
307
  hasRtcOffset(): boolean;
308
308
  /**
309
- * Get mesh at index
309
+ * Get mesh at index (clones — non-destructive). Prefer `takeMesh` on the
310
+ * hot streaming path; this stays for callers that read meshes more than once.
310
311
  */
311
312
  get(index: number): MeshDataJs | undefined;
313
+ /**
314
+ * #1097 perf: MOVE the mesh at `index` out of the collection (the Vec
315
+ * buffers are `std::mem::take`-n, leaving an empty stub). The streaming
316
+ * worker reads each mesh exactly once, so moving avoids the full vertex-
317
+ * data clone `get` pays — one fewer copy of positions/normals/indices/uvs/
318
+ * texture per mesh (the JS getters still do the single Rust→JS copy). Calling
319
+ * it twice for the same index yields the second call an empty mesh.
320
+ */
321
+ takeMesh(index: number): MeshDataJs | undefined;
312
322
  /**
313
323
  * Get RTC offset X (for converting local coords back to world coords)
314
324
  * Add this to local X coordinates to get world X coordinates
@@ -413,6 +423,12 @@ export class MeshDataJs {
413
423
  * Get color as [r, g, b, a] array
414
424
  */
415
425
  readonly color: Float32Array;
426
+ /**
427
+ * Per-element local-frame origin (Float64Array[3], WebGL Y-up, metres):
428
+ * world position of vertex i = `origin + positions[3i..3i+3]`. Returns
429
+ * [0,0,0] when positions are absolute (legacy / local frame off).
430
+ */
431
+ readonly origin: Float64Array;
416
432
  /**
417
433
  * Get indices as Uint32Array (copy to JS)
418
434
  */
@@ -835,7 +851,7 @@ export interface InitOutput {
835
851
  readonly gridaxisjs_start: (a: number) => number;
836
852
  readonly gridaxisjs_tag: (a: number, b: number) => void;
837
853
  readonly ifcapi_buildPrePassOnce: (a: number, b: number, c: number) => number;
838
- readonly ifcapi_buildPrePassStreaming: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
854
+ readonly ifcapi_buildPrePassStreaming: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
839
855
  readonly ifcapi_clearPrePassCache: (a: number) => void;
840
856
  readonly ifcapi_extractProfiles: (a: number, b: number, c: number, d: number) => number;
841
857
  readonly ifcapi_getMemory: (a: number) => number;
@@ -845,7 +861,7 @@ export interface InitOutput {
845
861
  readonly ifcapi_parseGridAxes: (a: number, b: number, c: number) => number;
846
862
  readonly ifcapi_parseGridLines: (a: number, b: number, c: number) => number;
847
863
  readonly ifcapi_parseSymbolicRepresentations: (a: number, b: number, c: number) => number;
848
- readonly ifcapi_processGeometryBatch: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number) => number;
864
+ readonly ifcapi_processGeometryBatch: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number, r: number, s: number, t: number, u: number, v: number, w: number, x: number, y: number, z: number, a1: number, b1: number) => number;
849
865
  readonly ifcapi_scanEntitiesFast: (a: number, b: number, c: number) => number;
850
866
  readonly ifcapi_scanEntitiesFastBytes: (a: number, b: number, c: number) => number;
851
867
  readonly ifcapi_scanGeometryEntitiesFast: (a: number, b: number, c: number) => number;
@@ -865,6 +881,7 @@ export interface InitOutput {
865
881
  readonly meshcollection_rtcOffsetX: (a: number) => number;
866
882
  readonly meshcollection_rtcOffsetY: (a: number) => number;
867
883
  readonly meshcollection_rtcOffsetZ: (a: number) => number;
884
+ readonly meshcollection_takeMesh: (a: number, b: number) => number;
868
885
  readonly meshcollection_totalTriangles: (a: number) => number;
869
886
  readonly meshcollection_totalVertices: (a: number) => number;
870
887
  readonly meshdatajs_color: (a: number, b: number) => void;
@@ -874,6 +891,7 @@ export interface InitOutput {
874
891
  readonly meshdatajs_ifcType: (a: number, b: number) => void;
875
892
  readonly meshdatajs_indices: (a: number) => number;
876
893
  readonly meshdatajs_normals: (a: number) => number;
894
+ readonly meshdatajs_origin: (a: number) => number;
877
895
  readonly meshdatajs_positions: (a: number) => number;
878
896
  readonly meshdatajs_shadingColor: (a: number, b: number) => void;
879
897
  readonly meshdatajs_textureHeight: (a: number) => number;
@@ -890,7 +908,6 @@ export interface InitOutput {
890
908
  readonly meshoutlinejs_contourCount: (a: number) => number;
891
909
  readonly profilecollection_get: (a: number, b: number) => number;
892
910
  readonly profilecollection_length: (a: number) => number;
893
- readonly profileentryjs_expressId: (a: number) => number;
894
911
  readonly profileentryjs_extrusionDepth: (a: number) => number;
895
912
  readonly profileentryjs_extrusionDir: (a: number) => number;
896
913
  readonly profileentryjs_holeCounts: (a: number) => number;
@@ -966,6 +983,7 @@ export interface InitOutput {
966
983
  readonly init: () => void;
967
984
  readonly symbolicpolyline_pointCount: (a: number) => number;
968
985
  readonly get_memory: () => number;
986
+ readonly profileentryjs_expressId: (a: number) => number;
969
987
  readonly symbolicfillarea_expressId: (a: number) => number;
970
988
  readonly symbolicpolyline_worldY: (a: number) => number;
971
989
  readonly symbolictext_colorB: (a: number) => number;
package/pkg/ifc-lite.js CHANGED
@@ -146,6 +146,16 @@ function passArrayF64ToWasm0(arg, malloc) {
146
146
  return ptr;
147
147
  }
148
148
 
149
+ function passArrayJsValueToWasm0(array, malloc) {
150
+ const ptr = malloc(array.length * 4, 4) >>> 0;
151
+ const mem = getDataViewMemory0();
152
+ for (let i = 0; i < array.length; i++) {
153
+ mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
154
+ }
155
+ WASM_VECTOR_LEN = array.length;
156
+ return ptr;
157
+ }
158
+
149
159
  function passStringToWasm0(arg, malloc, realloc) {
150
160
  if (realloc === undefined) {
151
161
  const buf = cachedTextEncoder.encode(arg);
@@ -641,9 +651,13 @@ export class IfcAPI {
641
651
  * @param {Uint32Array} void_values
642
652
  * @param {Uint32Array} style_ids
643
653
  * @param {Uint8Array} style_colors
654
+ * @param {number | null} [plane_angle_to_radians]
655
+ * @param {Uint32Array | null} [material_element_ids]
656
+ * @param {Uint32Array | null} [material_color_counts]
657
+ * @param {Uint8Array | null} [material_colors_rgba]
644
658
  * @returns {MeshCollection}
645
659
  */
646
- processGeometryBatch(data, jobs_flat, unit_scale, rtc_x, rtc_y, rtc_z, needs_shift, void_keys, void_counts, void_values, style_ids, style_colors) {
660
+ processGeometryBatch(data, jobs_flat, unit_scale, rtc_x, rtc_y, rtc_z, needs_shift, void_keys, void_counts, void_values, style_ids, style_colors, plane_angle_to_radians, material_element_ids, material_color_counts, material_colors_rgba) {
647
661
  const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
648
662
  const len0 = WASM_VECTOR_LEN;
649
663
  const ptr1 = passArray32ToWasm0(jobs_flat, wasm.__wbindgen_export);
@@ -658,7 +672,13 @@ export class IfcAPI {
658
672
  const len5 = WASM_VECTOR_LEN;
659
673
  const ptr6 = passArray8ToWasm0(style_colors, wasm.__wbindgen_export);
660
674
  const len6 = WASM_VECTOR_LEN;
661
- const ret = wasm.ifcapi_processGeometryBatch(this.__wbg_ptr, ptr0, len0, ptr1, len1, unit_scale, rtc_x, rtc_y, rtc_z, needs_shift, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6);
675
+ var ptr7 = isLikeNone(material_element_ids) ? 0 : passArray32ToWasm0(material_element_ids, wasm.__wbindgen_export);
676
+ var len7 = WASM_VECTOR_LEN;
677
+ var ptr8 = isLikeNone(material_color_counts) ? 0 : passArray32ToWasm0(material_color_counts, wasm.__wbindgen_export);
678
+ var len8 = WASM_VECTOR_LEN;
679
+ var ptr9 = isLikeNone(material_colors_rgba) ? 0 : passArray8ToWasm0(material_colors_rgba, wasm.__wbindgen_export);
680
+ var len9 = WASM_VECTOR_LEN;
681
+ const ret = wasm.ifcapi_processGeometryBatch(this.__wbg_ptr, ptr0, len0, ptr1, len1, unit_scale, rtc_x, rtc_y, rtc_z, needs_shift, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, !isLikeNone(plane_angle_to_radians), isLikeNone(plane_angle_to_radians) ? 0 : plane_angle_to_radians, ptr7, len7, ptr8, len8, ptr9, len9);
662
682
  return MeshCollection.__wrap(ret);
663
683
  }
664
684
  /**
@@ -688,14 +708,18 @@ export class IfcAPI {
688
708
  * @param {Uint8Array} data
689
709
  * @param {Function} on_event
690
710
  * @param {number} chunk_size
711
+ * @param {string[] | null | undefined} disabled_type_names
712
+ * @param {boolean} skip_type_geometry
691
713
  * @returns {any}
692
714
  */
693
- buildPrePassStreaming(data, on_event, chunk_size) {
715
+ buildPrePassStreaming(data, on_event, chunk_size, disabled_type_names, skip_type_geometry) {
694
716
  try {
695
717
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
696
718
  const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
697
719
  const len0 = WASM_VECTOR_LEN;
698
- wasm.ifcapi_buildPrePassStreaming(retptr, this.__wbg_ptr, ptr0, len0, addBorrowedObject(on_event), chunk_size);
720
+ var ptr1 = isLikeNone(disabled_type_names) ? 0 : passArrayJsValueToWasm0(disabled_type_names, wasm.__wbindgen_export);
721
+ var len1 = WASM_VECTOR_LEN;
722
+ wasm.ifcapi_buildPrePassStreaming(retptr, this.__wbg_ptr, ptr0, len0, addBorrowedObject(on_event), chunk_size, ptr1, len1, skip_type_geometry);
699
723
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
700
724
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
701
725
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1124,7 +1148,8 @@ export class MeshCollection {
1124
1148
  return takeObject(ret);
1125
1149
  }
1126
1150
  /**
1127
- * Get mesh at index
1151
+ * Get mesh at index (clones — non-destructive). Prefer `takeMesh` on the
1152
+ * hot streaming path; this stays for callers that read meshes more than once.
1128
1153
  * @param {number} index
1129
1154
  * @returns {MeshDataJs | undefined}
1130
1155
  */
@@ -1140,6 +1165,20 @@ export class MeshCollection {
1140
1165
  const ret = wasm.meshcollection_length(this.__wbg_ptr);
1141
1166
  return ret >>> 0;
1142
1167
  }
1168
+ /**
1169
+ * #1097 perf: MOVE the mesh at `index` out of the collection (the Vec
1170
+ * buffers are `std::mem::take`-n, leaving an empty stub). The streaming
1171
+ * worker reads each mesh exactly once, so moving avoids the full vertex-
1172
+ * data clone `get` pays — one fewer copy of positions/normals/indices/uvs/
1173
+ * texture per mesh (the JS getters still do the single Rust→JS copy). Calling
1174
+ * it twice for the same index yields the second call an empty mesh.
1175
+ * @param {number} index
1176
+ * @returns {MeshDataJs | undefined}
1177
+ */
1178
+ takeMesh(index) {
1179
+ const ret = wasm.meshcollection_takeMesh(this.__wbg_ptr, index);
1180
+ return ret === 0 ? undefined : MeshDataJs.__wrap(ret);
1181
+ }
1143
1182
  }
1144
1183
  if (Symbol.dispose) MeshCollection.prototype[Symbol.dispose] = MeshCollection.prototype.free;
1145
1184
 
@@ -1292,6 +1331,16 @@ export class MeshDataJs {
1292
1331
  wasm.__wbindgen_add_to_stack_pointer(16);
1293
1332
  }
1294
1333
  }
1334
+ /**
1335
+ * Per-element local-frame origin (Float64Array[3], WebGL Y-up, metres):
1336
+ * world position of vertex i = `origin + positions[3i..3i+3]`. Returns
1337
+ * [0,0,0] when positions are absolute (legacy / local frame off).
1338
+ * @returns {Float64Array}
1339
+ */
1340
+ get origin() {
1341
+ const ret = wasm.meshdatajs_origin(this.__wbg_ptr);
1342
+ return takeObject(ret);
1343
+ }
1295
1344
  /**
1296
1345
  * Get indices as Uint32Array (copy to JS)
1297
1346
  * @returns {Uint32Array}
@@ -1473,7 +1522,7 @@ export class ProfileEntryJs {
1473
1522
  * @returns {number}
1474
1523
  */
1475
1524
  get expressId() {
1476
- const ret = wasm.profileentryjs_expressId(this.__wbg_ptr);
1525
+ const ret = wasm.meshdatajs_textureWidth(this.__wbg_ptr);
1477
1526
  return ret >>> 0;
1478
1527
  }
1479
1528
  /**
@@ -1996,7 +2045,7 @@ export class SymbolicFillArea {
1996
2045
  * @returns {number}
1997
2046
  */
1998
2047
  get expressId() {
1999
- const ret = wasm.profileentryjs_expressId(this.__wbg_ptr);
2048
+ const ret = wasm.meshdatajs_textureWidth(this.__wbg_ptr);
2000
2049
  return ret >>> 0;
2001
2050
  }
2002
2051
  /**
@@ -2404,7 +2453,7 @@ export class SymbolicText {
2404
2453
  * @returns {number}
2405
2454
  */
2406
2455
  get expressId() {
2407
- const ret = wasm.profileentryjs_expressId(this.__wbg_ptr);
2456
+ const ret = wasm.meshdatajs_textureWidth(this.__wbg_ptr);
2408
2457
  return ret >>> 0;
2409
2458
  }
2410
2459
  /**
@@ -2694,6 +2743,14 @@ function __wbg_get_imports() {
2694
2743
  const ret = wasm.memory;
2695
2744
  return addHeapObject(ret);
2696
2745
  };
2746
+ imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
2747
+ const obj = getObject(arg1);
2748
+ const ret = typeof(obj) === 'string' ? obj : undefined;
2749
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2750
+ var len1 = WASM_VECTOR_LEN;
2751
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2752
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2753
+ };
2697
2754
  imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
2698
2755
  throw new Error(getStringFromWasm0(arg0, arg1));
2699
2756
  };
@@ -2735,6 +2792,10 @@ function __wbg_get_imports() {
2735
2792
  const ret = new BigUint64Array(getArrayU64FromWasm0(arg0, arg1));
2736
2793
  return addHeapObject(ret);
2737
2794
  };
2795
+ imports.wbg.__wbg_new_from_slice_9a48ef80d2a51f94 = function(arg0, arg1) {
2796
+ const ret = new Float64Array(getArrayF64FromWasm0(arg0, arg1));
2797
+ return addHeapObject(ret);
2798
+ };
2738
2799
  imports.wbg.__wbg_new_from_slice_db0691b69e9d3891 = function(arg0, arg1) {
2739
2800
  const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
2740
2801
  return addHeapObject(ret);
@@ -2751,10 +2812,6 @@ function __wbg_get_imports() {
2751
2812
  const ret = new Float64Array(arg0 >>> 0);
2752
2813
  return addHeapObject(ret);
2753
2814
  };
2754
- imports.wbg.__wbg_new_with_length_aa5eaf41d35235e5 = function(arg0) {
2755
- const ret = new Uint8Array(arg0 >>> 0);
2756
- return addHeapObject(ret);
2757
- };
2758
2815
  imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
2759
2816
  getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
2760
2817
  };
@@ -2768,9 +2825,6 @@ function __wbg_get_imports() {
2768
2825
  imports.wbg.__wbg_set_index_021489b2916af13e = function(arg0, arg1, arg2) {
2769
2826
  getObject(arg0)[arg1 >>> 0] = arg2;
2770
2827
  };
2771
- imports.wbg.__wbg_set_index_04c4b93e64d08a52 = function(arg0, arg1, arg2) {
2772
- getObject(arg0)[arg1 >>> 0] = arg2;
2773
- };
2774
2828
  imports.wbg.__wbg_set_index_42abe35f117e614e = function(arg0, arg1, arg2) {
2775
2829
  getObject(arg0)[arg1 >>> 0] = arg2 >>> 0;
2776
2830
  };
Binary file