@ifc-lite/wasm 2.11.0 → 2.11.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.11.0",
8
+ "version": "2.11.1",
9
9
  "license": "MPL-2.0",
10
10
  "repository": {
11
11
  "type": "git",
package/pkg/ifc-lite.d.ts CHANGED
@@ -123,8 +123,11 @@ export class IfcAPI {
123
123
  */
124
124
  buildPrePassOnce(data: Uint8Array): any;
125
125
  /**
126
- * Process geometry for a subset of pre-scanned entities.
127
- * Takes raw bytes and pre-pass data from buildPrePassOnce.
126
+ * Process geometry for a subset of pre-scanned entities → flat
127
+ * MeshCollection. Takes raw bytes + pre-pass data from buildPrePassOnce.
128
+ * Thin wrapper over [`IfcAPI::produce_batch`]; converts each produced mesh
129
+ * to MeshDataJs (the IFC Z-up→WebGL Y-up swap + winding reversal happen
130
+ * there). Output is byte-for-byte what the pre-refactor method produced.
128
131
  */
129
132
  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;
130
133
  /**
@@ -153,6 +156,36 @@ export class IfcAPI {
153
156
  * `{ type: "complete", totalJobs }`
154
157
  */
155
158
  buildPrePassStreaming(data: Uint8Array, on_event: Function, chunk_size: number, disabled_type_names: string[] | null | undefined, skip_type_geometry: boolean): any;
159
+ /**
160
+ * Like [`IfcAPI::process_geometry_batch`] but collates the batch's meshes
161
+ * into a GPU-instancing shard (IFNS wire format) instead of a flat
162
+ * MeshCollection. Repeated geometry collapses to one template + per-
163
+ * occurrence transforms; non-instanceable meshes ride as flat singleton
164
+ * templates so nothing is dropped. The shard stays in the producer-native
165
+ * (IFC Z-up) frame — the renderer composes the constant Z-up→Y-up swap at
166
+ * upload. Each batch shard renders independently: affinity routing already
167
+ * co-locates identical geometry on one worker, so per-batch collation
168
+ * captures ~all the dedup and no cross-batch merge is needed. Returns empty
169
+ * bytes only when the batch produced zero non-empty meshes.
170
+ */
171
+ processGeometryBatchInstanced(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): Uint8Array;
172
+ /**
173
+ * Produce a batch ONCE and PARTITION it (the instanced-ONLY path): opaque
174
+ * ordinary occurrences (colour alpha >= 0.99 AND geometry_class == 0) are
175
+ * collated into the instanced shard; everything else (transparent glass,
176
+ * type-product geometry) goes to the flat MeshCollection. Each mesh takes
177
+ * exactly ONE route, so produce_batch runs once (no emit-both 2× meshing)
178
+ * and the renderer draws opaque occurrences via instancing instead of flat.
179
+ * Partition mirrors the renderer gates: INSTANCED_ALPHA_CUTOFF (0.99 =
180
+ * OPAQUE_ALPHA_CUTOFF) for transparency, geometry_class for the Model/Types
181
+ * split.
182
+ *
183
+ * NOTE: the renderer must be instanced-feature-complete (picking / selection
184
+ * / lens overlays on instanced geometry) before the worker calls this in
185
+ * place of processGeometryBatch — otherwise those features break for the
186
+ * opaque bulk. See the instanced-only follow-ups.
187
+ */
188
+ processGeometryBatchPartitioned(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): PartitionedBatch;
156
189
  /**
157
190
  * Parse the file and return structured per-axis data (tag + endpoints) in
158
191
  * the renderer's Y-up world space (RTC-subtracted, metres). Use this when
@@ -568,6 +601,27 @@ export class MeshOutlineJs {
568
601
  readonly axisMin: number;
569
602
  }
570
603
 
604
+ export class PartitionedBatch {
605
+ private constructor();
606
+ free(): void;
607
+ [Symbol.dispose](): void;
608
+ /**
609
+ * The instanced IFNS shard bytes (opaque ordinary occurrences). Moves out.
610
+ */
611
+ takeShard(): Uint8Array;
612
+ /**
613
+ * The flat MeshCollection (transparent glass + type-product geometry).
614
+ * Moves out — call once.
615
+ */
616
+ takeMeshes(): MeshCollection | undefined;
617
+ /**
618
+ * Number of occurrences routed into the instanced shard this batch. The viewer
619
+ * folds this into its total mesh count so the count reflects ALL rendered
620
+ * geometry (flat + instanced), not just the flat MeshCollection.
621
+ */
622
+ readonly instancedOccurrences: number;
623
+ }
624
+
571
625
  export class ProfileCollection {
572
626
  private constructor();
573
627
  free(): void;
@@ -983,6 +1037,7 @@ export interface InitOutput {
983
1037
  readonly __wbg_meshcollection_free: (a: number, b: number) => void;
984
1038
  readonly __wbg_meshdatajs_free: (a: number, b: number) => void;
985
1039
  readonly __wbg_meshoutlinejs_free: (a: number, b: number) => void;
1040
+ readonly __wbg_partitionedbatch_free: (a: number, b: number) => void;
986
1041
  readonly __wbg_profilecollection_free: (a: number, b: number) => void;
987
1042
  readonly __wbg_profileentryjs_free: (a: number, b: number) => void;
988
1043
  readonly __wbg_spaceplatehandle_free: (a: number, b: number) => void;
@@ -1031,6 +1086,8 @@ export interface InitOutput {
1031
1086
  readonly ifcapi_parseGridLines: (a: number, b: number, c: number) => number;
1032
1087
  readonly ifcapi_parseSymbolicRepresentations: (a: number, b: number, c: number) => number;
1033
1088
  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;
1089
+ readonly ifcapi_processGeometryBatchInstanced: (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, c1: number) => void;
1090
+ readonly ifcapi_processGeometryBatchPartitioned: (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;
1034
1091
  readonly ifcapi_scanEntitiesFast: (a: number, b: number, c: number) => number;
1035
1092
  readonly ifcapi_scanEntitiesFastBytes: (a: number, b: number, c: number) => number;
1036
1093
  readonly ifcapi_scanGeometryEntitiesFast: (a: number, b: number, c: number) => number;
@@ -1076,6 +1133,9 @@ export interface InitOutput {
1076
1133
  readonly meshoutlinejs_axisMin: (a: number) => number;
1077
1134
  readonly meshoutlinejs_contour: (a: number, b: number) => number;
1078
1135
  readonly meshoutlinejs_contourCount: (a: number) => number;
1136
+ readonly partitionedbatch_instancedOccurrences: (a: number) => number;
1137
+ readonly partitionedbatch_takeMeshes: (a: number) => number;
1138
+ readonly partitionedbatch_takeShard: (a: number, b: number) => void;
1079
1139
  readonly profilecollection_get: (a: number, b: number) => number;
1080
1140
  readonly profilecollection_length: (a: number) => number;
1081
1141
  readonly profileentryjs_extrusionDepth: (a: number) => number;
package/pkg/ifc-lite.js CHANGED
@@ -262,6 +262,10 @@ const MeshOutlineJsFinalization = (typeof FinalizationRegistry === 'undefined')
262
262
  ? { register: () => {}, unregister: () => {} }
263
263
  : new FinalizationRegistry(ptr => wasm.__wbg_meshoutlinejs_free(ptr >>> 0, 1));
264
264
 
265
+ const PartitionedBatchFinalization = (typeof FinalizationRegistry === 'undefined')
266
+ ? { register: () => {}, unregister: () => {} }
267
+ : new FinalizationRegistry(ptr => wasm.__wbg_partitionedbatch_free(ptr >>> 0, 1));
268
+
265
269
  const ProfileCollectionFinalization = (typeof FinalizationRegistry === 'undefined')
266
270
  ? { register: () => {}, unregister: () => {} }
267
271
  : new FinalizationRegistry(ptr => wasm.__wbg_profilecollection_free(ptr >>> 0, 1));
@@ -786,8 +790,11 @@ export class IfcAPI {
786
790
  return takeObject(ret);
787
791
  }
788
792
  /**
789
- * Process geometry for a subset of pre-scanned entities.
790
- * Takes raw bytes and pre-pass data from buildPrePassOnce.
793
+ * Process geometry for a subset of pre-scanned entities → flat
794
+ * MeshCollection. Takes raw bytes + pre-pass data from buildPrePassOnce.
795
+ * Thin wrapper over [`IfcAPI::produce_batch`]; converts each produced mesh
796
+ * to MeshDataJs (the IFC Z-up→WebGL Y-up swap + winding reversal happen
797
+ * there). Output is byte-for-byte what the pre-refactor method produced.
791
798
  * @param {Uint8Array} data
792
799
  * @param {Uint32Array} jobs_flat
793
800
  * @param {number} unit_scale
@@ -881,6 +888,125 @@ export class IfcAPI {
881
888
  heap[stack_pointer++] = undefined;
882
889
  }
883
890
  }
891
+ /**
892
+ * Like [`IfcAPI::process_geometry_batch`] but collates the batch's meshes
893
+ * into a GPU-instancing shard (IFNS wire format) instead of a flat
894
+ * MeshCollection. Repeated geometry collapses to one template + per-
895
+ * occurrence transforms; non-instanceable meshes ride as flat singleton
896
+ * templates so nothing is dropped. The shard stays in the producer-native
897
+ * (IFC Z-up) frame — the renderer composes the constant Z-up→Y-up swap at
898
+ * upload. Each batch shard renders independently: affinity routing already
899
+ * co-locates identical geometry on one worker, so per-batch collation
900
+ * captures ~all the dedup and no cross-batch merge is needed. Returns empty
901
+ * bytes only when the batch produced zero non-empty meshes.
902
+ * @param {Uint8Array} data
903
+ * @param {Uint32Array} jobs_flat
904
+ * @param {number} unit_scale
905
+ * @param {number} rtc_x
906
+ * @param {number} rtc_y
907
+ * @param {number} rtc_z
908
+ * @param {boolean} needs_shift
909
+ * @param {Uint32Array} void_keys
910
+ * @param {Uint32Array} void_counts
911
+ * @param {Uint32Array} void_values
912
+ * @param {Uint32Array} style_ids
913
+ * @param {Uint8Array} style_colors
914
+ * @param {number | null} [plane_angle_to_radians]
915
+ * @param {Uint32Array | null} [material_element_ids]
916
+ * @param {Uint32Array | null} [material_color_counts]
917
+ * @param {Uint8Array | null} [material_colors_rgba]
918
+ * @returns {Uint8Array}
919
+ */
920
+ processGeometryBatchInstanced(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) {
921
+ try {
922
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
923
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
924
+ const len0 = WASM_VECTOR_LEN;
925
+ const ptr1 = passArray32ToWasm0(jobs_flat, wasm.__wbindgen_export);
926
+ const len1 = WASM_VECTOR_LEN;
927
+ const ptr2 = passArray32ToWasm0(void_keys, wasm.__wbindgen_export);
928
+ const len2 = WASM_VECTOR_LEN;
929
+ const ptr3 = passArray32ToWasm0(void_counts, wasm.__wbindgen_export);
930
+ const len3 = WASM_VECTOR_LEN;
931
+ const ptr4 = passArray32ToWasm0(void_values, wasm.__wbindgen_export);
932
+ const len4 = WASM_VECTOR_LEN;
933
+ const ptr5 = passArray32ToWasm0(style_ids, wasm.__wbindgen_export);
934
+ const len5 = WASM_VECTOR_LEN;
935
+ const ptr6 = passArray8ToWasm0(style_colors, wasm.__wbindgen_export);
936
+ const len6 = WASM_VECTOR_LEN;
937
+ var ptr7 = isLikeNone(material_element_ids) ? 0 : passArray32ToWasm0(material_element_ids, wasm.__wbindgen_export);
938
+ var len7 = WASM_VECTOR_LEN;
939
+ var ptr8 = isLikeNone(material_color_counts) ? 0 : passArray32ToWasm0(material_color_counts, wasm.__wbindgen_export);
940
+ var len8 = WASM_VECTOR_LEN;
941
+ var ptr9 = isLikeNone(material_colors_rgba) ? 0 : passArray8ToWasm0(material_colors_rgba, wasm.__wbindgen_export);
942
+ var len9 = WASM_VECTOR_LEN;
943
+ wasm.ifcapi_processGeometryBatchInstanced(retptr, 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);
944
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
945
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
946
+ var v11 = getArrayU8FromWasm0(r0, r1).slice();
947
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
948
+ return v11;
949
+ } finally {
950
+ wasm.__wbindgen_add_to_stack_pointer(16);
951
+ }
952
+ }
953
+ /**
954
+ * Produce a batch ONCE and PARTITION it (the instanced-ONLY path): opaque
955
+ * ordinary occurrences (colour alpha >= 0.99 AND geometry_class == 0) are
956
+ * collated into the instanced shard; everything else (transparent glass,
957
+ * type-product geometry) goes to the flat MeshCollection. Each mesh takes
958
+ * exactly ONE route, so produce_batch runs once (no emit-both 2× meshing)
959
+ * and the renderer draws opaque occurrences via instancing instead of flat.
960
+ * Partition mirrors the renderer gates: INSTANCED_ALPHA_CUTOFF (0.99 =
961
+ * OPAQUE_ALPHA_CUTOFF) for transparency, geometry_class for the Model/Types
962
+ * split.
963
+ *
964
+ * NOTE: the renderer must be instanced-feature-complete (picking / selection
965
+ * / lens overlays on instanced geometry) before the worker calls this in
966
+ * place of processGeometryBatch — otherwise those features break for the
967
+ * opaque bulk. See the instanced-only follow-ups.
968
+ * @param {Uint8Array} data
969
+ * @param {Uint32Array} jobs_flat
970
+ * @param {number} unit_scale
971
+ * @param {number} rtc_x
972
+ * @param {number} rtc_y
973
+ * @param {number} rtc_z
974
+ * @param {boolean} needs_shift
975
+ * @param {Uint32Array} void_keys
976
+ * @param {Uint32Array} void_counts
977
+ * @param {Uint32Array} void_values
978
+ * @param {Uint32Array} style_ids
979
+ * @param {Uint8Array} style_colors
980
+ * @param {number | null} [plane_angle_to_radians]
981
+ * @param {Uint32Array | null} [material_element_ids]
982
+ * @param {Uint32Array | null} [material_color_counts]
983
+ * @param {Uint8Array | null} [material_colors_rgba]
984
+ * @returns {PartitionedBatch}
985
+ */
986
+ processGeometryBatchPartitioned(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) {
987
+ const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export);
988
+ const len0 = WASM_VECTOR_LEN;
989
+ const ptr1 = passArray32ToWasm0(jobs_flat, wasm.__wbindgen_export);
990
+ const len1 = WASM_VECTOR_LEN;
991
+ const ptr2 = passArray32ToWasm0(void_keys, wasm.__wbindgen_export);
992
+ const len2 = WASM_VECTOR_LEN;
993
+ const ptr3 = passArray32ToWasm0(void_counts, wasm.__wbindgen_export);
994
+ const len3 = WASM_VECTOR_LEN;
995
+ const ptr4 = passArray32ToWasm0(void_values, wasm.__wbindgen_export);
996
+ const len4 = WASM_VECTOR_LEN;
997
+ const ptr5 = passArray32ToWasm0(style_ids, wasm.__wbindgen_export);
998
+ const len5 = WASM_VECTOR_LEN;
999
+ const ptr6 = passArray8ToWasm0(style_colors, wasm.__wbindgen_export);
1000
+ const len6 = WASM_VECTOR_LEN;
1001
+ var ptr7 = isLikeNone(material_element_ids) ? 0 : passArray32ToWasm0(material_element_ids, wasm.__wbindgen_export);
1002
+ var len7 = WASM_VECTOR_LEN;
1003
+ var ptr8 = isLikeNone(material_color_counts) ? 0 : passArray32ToWasm0(material_color_counts, wasm.__wbindgen_export);
1004
+ var len8 = WASM_VECTOR_LEN;
1005
+ var ptr9 = isLikeNone(material_colors_rgba) ? 0 : passArray8ToWasm0(material_colors_rgba, wasm.__wbindgen_export);
1006
+ var len9 = WASM_VECTOR_LEN;
1007
+ const ret = wasm.ifcapi_processGeometryBatchPartitioned(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);
1008
+ return PartitionedBatch.__wrap(ret);
1009
+ }
884
1010
  /**
885
1011
  * Parse the file and return structured per-axis data (tag + endpoints) in
886
1012
  * the renderer's Y-up world space (RTC-subtracted, metres). Use this when
@@ -1838,6 +1964,69 @@ export class MeshOutlineJs {
1838
1964
  }
1839
1965
  if (Symbol.dispose) MeshOutlineJs.prototype[Symbol.dispose] = MeshOutlineJs.prototype.free;
1840
1966
 
1967
+ /**
1968
+ * Result of [`IfcAPI::process_geometry_batch_partitioned`]: the flat
1969
+ * MeshCollection (transparent + type geometry) and the instanced IFNS shard
1970
+ * (opaque ordinary occurrences) from ONE produce_batch. Take-once accessors so
1971
+ * the JS side moves each out without a clone.
1972
+ */
1973
+ export class PartitionedBatch {
1974
+ static __wrap(ptr) {
1975
+ ptr = ptr >>> 0;
1976
+ const obj = Object.create(PartitionedBatch.prototype);
1977
+ obj.__wbg_ptr = ptr;
1978
+ PartitionedBatchFinalization.register(obj, obj.__wbg_ptr, obj);
1979
+ return obj;
1980
+ }
1981
+ __destroy_into_raw() {
1982
+ const ptr = this.__wbg_ptr;
1983
+ this.__wbg_ptr = 0;
1984
+ PartitionedBatchFinalization.unregister(this);
1985
+ return ptr;
1986
+ }
1987
+ free() {
1988
+ const ptr = this.__destroy_into_raw();
1989
+ wasm.__wbg_partitionedbatch_free(ptr, 0);
1990
+ }
1991
+ /**
1992
+ * The instanced IFNS shard bytes (opaque ordinary occurrences). Moves out.
1993
+ * @returns {Uint8Array}
1994
+ */
1995
+ takeShard() {
1996
+ try {
1997
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1998
+ wasm.partitionedbatch_takeShard(retptr, this.__wbg_ptr);
1999
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2000
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2001
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
2002
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
2003
+ return v1;
2004
+ } finally {
2005
+ wasm.__wbindgen_add_to_stack_pointer(16);
2006
+ }
2007
+ }
2008
+ /**
2009
+ * The flat MeshCollection (transparent glass + type-product geometry).
2010
+ * Moves out — call once.
2011
+ * @returns {MeshCollection | undefined}
2012
+ */
2013
+ takeMeshes() {
2014
+ const ret = wasm.partitionedbatch_takeMeshes(this.__wbg_ptr);
2015
+ return ret === 0 ? undefined : MeshCollection.__wrap(ret);
2016
+ }
2017
+ /**
2018
+ * Number of occurrences routed into the instanced shard this batch. The viewer
2019
+ * folds this into its total mesh count so the count reflects ALL rendered
2020
+ * geometry (flat + instanced), not just the flat MeshCollection.
2021
+ * @returns {number}
2022
+ */
2023
+ get instancedOccurrences() {
2024
+ const ret = wasm.partitionedbatch_instancedOccurrences(this.__wbg_ptr);
2025
+ return ret >>> 0;
2026
+ }
2027
+ }
2028
+ if (Symbol.dispose) PartitionedBatch.prototype[Symbol.dispose] = PartitionedBatch.prototype.free;
2029
+
1841
2030
  /**
1842
2031
  * A collection of extracted profiles.
1843
2032
  */
Binary file