bimatter-viewer-react 0.11.11 → 1.0.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.
@@ -191338,139 +191338,148 @@ var x_ = class {
191338
191338
  this.clearPropertyCaches(), this.spatialLinesCache.clear(), this.spatialTreeChunksCache.clear();
191339
191339
  }
191340
191340
  async getPropertiesAsBlobs(e, t, n, r) {
191341
- let i = await this.getAllRelDefinesByProps(e), a = i.size, o = t.size, s = {}, c = this.parser.GetLineIDsWithType(e, Cd).get(0);
191342
- if (c === void 0) return s;
191343
- let l = await this.getItemPropertiesBatch(e, i), u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
191344
- for (let e of l.values()) {
191341
+ let i = await this.getAllRelDefinesByProps(e), a = i.size, o = t.size, s = await this.getMaterialsByElement(e), c = {}, l = this.parser.GetLineIDsWithType(e, Cd).get(0);
191342
+ if (l === void 0) return c;
191343
+ let u = await this.getItemPropertiesBatch(e, i), d = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set();
191344
+ for (let e of u.values()) {
191345
191345
  if (!e) continue;
191346
191346
  let t = y_(e.RelatingPropertyDefinition);
191347
- t !== null && u.add(t);
191348
- for (let t of b_(e.RelatedObjects)) d.add(t);
191349
- }
191350
- let f = await this.getItemPropertiesBatch(e, u), p = /* @__PURE__ */ new Set();
191351
- for (let e of f.values()) if (e) {
191352
- for (let t of b_(e.HasProperties)) p.add(t);
191353
- for (let t of b_(e.Quantities)) p.add(t);
191354
- }
191355
- await this.getItemPropertiesBatch(e, p);
191356
- let m = new Set(t);
191357
- for (let e of d) m.add(e);
191358
- m.add(c), await this.getItemPropertiesBatch(e, m);
191359
- let ee = await this.getItemProperty(e, c) ?? {
191360
- id: c,
191347
+ t !== null && d.add(t);
191348
+ for (let t of b_(e.RelatedObjects)) f.add(t);
191349
+ }
191350
+ let p = await this.getTypePropertySetIDsByElement(e);
191351
+ for (let [e, t] of p) f.add(e), t.forEach((e) => d.add(e));
191352
+ let m = await this.getItemPropertiesBatch(e, d), ee = /* @__PURE__ */ new Set();
191353
+ for (let e of m.values()) if (e) {
191354
+ for (let t of b_(e.HasProperties)) ee.add(t);
191355
+ for (let t of b_(e.Quantities)) ee.add(t);
191356
+ }
191357
+ await this.getItemPropertiesBatch(e, ee);
191358
+ let te = /* @__PURE__ */ new Map(), ne = (t) => {
191359
+ let n = te.get(t);
191360
+ return n || (n = this.createPropertySet(e, t), te.set(t, n)), n;
191361
+ }, re = /* @__PURE__ */ new Map();
191362
+ for (let [e, t] of p) {
191363
+ let n = [];
191364
+ for (let e of t) n = this.mergePropertySet(n, await ne(e));
191365
+ re.set(e, n);
191366
+ }
191367
+ let h = new Set(t);
191368
+ for (let e of f) h.add(e);
191369
+ h.add(l), await this.getItemPropertiesBatch(e, h);
191370
+ let ie = await this.getItemProperty(e, l) ?? {
191371
+ id: l,
191361
191372
  props: {},
191362
191373
  sets: []
191363
191374
  };
191364
- ee.sets = [], s[c] = ee;
191365
- let te = 0;
191375
+ ie.sets = [], c[l] = ie;
191376
+ let ae = 0;
191366
191377
  for (let t of i) {
191367
191378
  let r = await this.getItemProperty(e, t);
191368
191379
  if (r) {
191369
191380
  let t = y_(r.RelatingPropertyDefinition);
191370
191381
  if (t === null) continue;
191371
- let n = await this.getPropertySetData(e, t), i = {
191372
- id: t,
191373
- guid: "null",
191374
- name: "null",
191375
- props: [],
191376
- isQuantities: !1
191377
- };
191378
- n && (n.HasProperties || n.Quantities) && (i = {
191379
- id: t,
191380
- guid: this.getStringValue(n.GlobalId) ?? "null",
191381
- name: this.getStringValue(n.Name) ?? "null",
191382
- props: n.HasProperties ? n.HasProperties : n.Quantities ? n.Quantities : [],
191383
- isQuantities: !!n.Quantities
191384
- });
191385
- let a = b_(r.RelatedObjects);
191386
- for (let t of a) if (s[t]) s[t].sets ??= [], s[t].sets.push(i);
191382
+ let n = await ne(t), i = b_(r.RelatedObjects);
191383
+ for (let t of i) if (c[t]) c[t].sets ??= [], c[t].sets = this.mergePropertySet(c[t].sets, n);
191387
191384
  else {
191388
- let n = await this.getItemProperty(e, t);
191389
- if (n) {
191390
- let e = this.getStringValue(n.GlobalId), r = n.Name, a = n.ObjectType, o = n.LongName, c = this.getStringValue(n.type), l = {
191391
- name: r,
191385
+ let r = await this.getItemProperty(e, t);
191386
+ if (r) {
191387
+ let e = this.getStringValue(r.GlobalId), i = r.Name, a = r.ObjectType, o = r.LongName, l = this.getStringValue(r.type), u = {
191388
+ Material: s.get(t),
191389
+ PredefinedType: r.PredefinedType,
191390
+ name: i,
191392
191391
  typeName: a,
191393
191392
  longName: o,
191394
- type: c,
191393
+ type: l,
191395
191394
  elevation: void 0
191396
191395
  };
191397
- s[t] = {
191396
+ c[t] = {
191398
191397
  id: t,
191399
191398
  guid: e,
191400
- props: l,
191401
- sets: [i]
191402
- }, c === "IfcBuildingStorey" && (l.elevation = n.Elevation);
191403
- } else s[t] = {
191399
+ props: u,
191400
+ sets: this.mergePropertySet(re.get(t) ?? [], n)
191401
+ }, l === "IfcBuildingStorey" && (u.elevation = r.Elevation);
191402
+ } else c[t] = {
191404
191403
  id: t,
191405
191404
  guid: "null",
191406
191405
  props: {
191406
+ Material: s.get(t),
191407
+ PredefinedType: "null",
191407
191408
  name: "null",
191408
191409
  typeName: "null",
191409
191410
  longName: "null",
191410
191411
  type: "null",
191411
191412
  elevation: void 0
191412
191413
  },
191413
- sets: [i]
191414
+ sets: this.mergePropertySet(re.get(t) ?? [], n)
191414
191415
  };
191415
191416
  }
191416
191417
  }
191417
- te += 1, this.shouldEmitProgress(te, a) && n?.({
191418
- loaded: te,
191418
+ ae += 1, this.shouldEmitProgress(ae, a) && n?.({
191419
+ loaded: ae,
191419
191420
  phase: "propertySets",
191420
191421
  total: a
191421
191422
  });
191422
191423
  }
191423
- let ne = 0, re = /* @__PURE__ */ new Set(), h = (e) => {
191424
- if (re.has(e)) return;
191425
- let t = s[e];
191426
- t && (re.add(e), r?.({
191424
+ let oe = 0, se = /* @__PURE__ */ new Set(), ce = (e) => {
191425
+ if (se.has(e)) return;
191426
+ let t = c[e];
191427
+ t && (se.add(e), r?.({
191427
191428
  elementID: e,
191428
191429
  props: t
191429
191430
  }));
191430
191431
  };
191431
- Object.keys(s).forEach((e) => {
191432
+ Object.keys(c).forEach((e) => {
191432
191433
  let t = Number(e);
191433
- Number.isFinite(t) && h(t);
191434
+ Number.isFinite(t) && ce(t);
191434
191435
  });
191435
191436
  for (let r of t) {
191436
- if (s[r]) {
191437
- h(r), ne += 1, this.shouldEmitProgress(ne, o) && n?.({
191438
- loaded: ne,
191437
+ if (c[r]) {
191438
+ ce(r), oe += 1, this.shouldEmitProgress(oe, o) && n?.({
191439
+ loaded: oe,
191439
191440
  phase: "elements",
191440
191441
  total: o
191441
191442
  });
191442
191443
  continue;
191443
191444
  }
191444
191445
  let t = await this.getItemProperty(e, r);
191445
- t ? s[r] = {
191446
- id: r,
191447
- guid: this.getStringValue(t.GlobalId),
191448
- props: {
191449
- name: t.Name,
191450
- typeName: t.ObjectType,
191451
- longName: t.LongName,
191452
- type: this.getStringValue(t.type),
191453
- elevation: void 0
191454
- },
191455
- sets: []
191456
- } : s[r] = {
191446
+ if (t) {
191447
+ let e = this.getStringValue(t.GlobalId), n = t.Name, i = t.ObjectType, a = t.LongName, o = this.getStringValue(t.type);
191448
+ c[r] = {
191449
+ id: r,
191450
+ guid: e,
191451
+ props: {
191452
+ Material: s.get(r),
191453
+ PredefinedType: t.PredefinedType,
191454
+ name: n,
191455
+ typeName: i,
191456
+ longName: a,
191457
+ type: o,
191458
+ elevation: void 0
191459
+ },
191460
+ sets: [...re.get(r) ?? []]
191461
+ };
191462
+ } else c[r] = {
191457
191463
  id: r,
191458
191464
  guid: "null",
191459
191465
  props: {
191466
+ Material: s.get(r),
191467
+ PredefinedType: "null",
191460
191468
  name: "null",
191461
191469
  typeName: "null",
191462
191470
  longName: "null",
191463
191471
  type: "null",
191464
191472
  elevation: void 0
191465
191473
  },
191466
- sets: []
191467
- }, h(r), ne += 1, this.shouldEmitProgress(ne, o) && n?.({
191468
- loaded: ne,
191474
+ sets: [...re.get(r) ?? []]
191475
+ };
191476
+ ce(r), oe += 1, this.shouldEmitProgress(oe, o) && n?.({
191477
+ loaded: oe,
191469
191478
  phase: "elements",
191470
191479
  total: o
191471
191480
  });
191472
191481
  }
191473
- return s;
191482
+ return c;
191474
191483
  }
191475
191484
  async getItemProperty(e, t, n = !1) {
191476
191485
  let r = this.getItemPropertyCacheKey(e, t, n), i = this.itemPropertyCache.get(r);
@@ -191618,6 +191627,145 @@ var x_ = class {
191618
191627
  for (let e = 0; e < r; e++) n.add(t.get(e));
191619
191628
  return n;
191620
191629
  }
191630
+ async getTypePropertySetIDsByElement(e) {
191631
+ let t = this.parser.GetLineIDsWithType(e, M), n = [];
191632
+ for (let e = 0; e < t.size(); e += 1) n.push(t.get(e));
191633
+ let r = await this.getItemPropertiesBatch(e, n), i = /* @__PURE__ */ new Set();
191634
+ for (let e of r.values()) {
191635
+ if (!e) continue;
191636
+ let t = y_(e.RelatingType);
191637
+ t !== null && i.add(t);
191638
+ }
191639
+ let a = await this.getItemPropertiesBatch(e, i), o = /* @__PURE__ */ new Map();
191640
+ for (let e of r.values()) {
191641
+ if (!e) continue;
191642
+ let t = y_(e.RelatingType);
191643
+ if (t === null) continue;
191644
+ let n = a.get(t);
191645
+ if (!n) continue;
191646
+ let r = b_(n.HasPropertySets);
191647
+ if (r.length !== 0) for (let t of b_(e.RelatedObjects)) o.set(t, r);
191648
+ }
191649
+ return o;
191650
+ }
191651
+ async createPropertySet(e, t) {
191652
+ let n = await this.getPropertySetData(e, t);
191653
+ return !n || !n.HasProperties && !n.Quantities ? {
191654
+ id: t,
191655
+ guid: "null",
191656
+ name: "null",
191657
+ props: [],
191658
+ isQuantities: !1
191659
+ } : {
191660
+ id: t,
191661
+ guid: this.getStringValue(n.GlobalId) ?? "null",
191662
+ name: this.getStringValue(n.Name) ?? "null",
191663
+ props: n.HasProperties ?? n.Quantities ?? [],
191664
+ isQuantities: !!n.Quantities
191665
+ };
191666
+ }
191667
+ mergePropertySet(e, t) {
191668
+ let n = this.getPropertySetMergeName(t);
191669
+ if (!n) return [...e, t];
191670
+ let r = e.findIndex((e) => this.getPropertySetMergeName(e) === n);
191671
+ if (r === -1) return [...e, t];
191672
+ let i = e[r], a = [...e];
191673
+ return a[r] = {
191674
+ ...i,
191675
+ ...t,
191676
+ props: this.mergePropertySetProps(i.props, t.props)
191677
+ }, a;
191678
+ }
191679
+ getPropertySetMergeName(e) {
191680
+ let t = this.getStringValue(e.name)?.trim();
191681
+ return t && t !== "null" ? t : void 0;
191682
+ }
191683
+ mergePropertySetProps(e, t) {
191684
+ if (Array.isArray(e) && Array.isArray(t)) {
191685
+ let n = [...e], r = /* @__PURE__ */ new Map();
191686
+ return n.forEach((e, t) => {
191687
+ let n = this.getPropertyMergeName(e);
191688
+ n && r.set(n, t);
191689
+ }), t.forEach((e) => {
191690
+ let t = this.getPropertyMergeName(e), i = t ? r.get(t) : void 0;
191691
+ i === void 0 ? (t && r.set(t, n.length), n.push(e)) : n[i] = e;
191692
+ }), n;
191693
+ }
191694
+ return e && t && typeof e == "object" && typeof t == "object" && !Array.isArray(e) && !Array.isArray(t) ? {
191695
+ ...e,
191696
+ ...t
191697
+ } : t ?? e;
191698
+ }
191699
+ getPropertyMergeName(e) {
191700
+ if (!e || typeof e != "object" || Array.isArray(e)) return;
191701
+ let t = e;
191702
+ return this.getStringValue(t.Name ?? t.name)?.trim() || void 0;
191703
+ }
191704
+ async getMaterialsByElement(e) {
191705
+ let t = this.parser.GetLineIDsWithType(e, id), n = [];
191706
+ for (let e = 0; e < t.size(); e += 1) n.push(t.get(e));
191707
+ let r = await this.getItemPropertiesBatch(e, n), i = /* @__PURE__ */ new Set();
191708
+ for (let e of r.values()) {
191709
+ if (!e) continue;
191710
+ let t = y_(e.RelatingMaterial);
191711
+ t !== null && i.add(t);
191712
+ }
191713
+ let a = await this.getItemPropertiesBatch(e, i, !0), o = /* @__PURE__ */ new Map();
191714
+ for (let e of r.values()) {
191715
+ if (!e) continue;
191716
+ let t = y_(e.RelatingMaterial);
191717
+ if (t === null) continue;
191718
+ let n = a.get(t);
191719
+ if (!n) continue;
191720
+ let r = this.getMaterialNames(n);
191721
+ if (r.length !== 0) for (let t of b_(e.RelatedObjects)) {
191722
+ let e = o.get(t) ?? /* @__PURE__ */ new Set();
191723
+ r.forEach((t) => e.add(t)), o.set(t, e);
191724
+ }
191725
+ }
191726
+ let s = this.parser.GetLineIDsWithType(e, M), c = [];
191727
+ for (let e = 0; e < s.size(); e += 1) c.push(s.get(e));
191728
+ let l = await this.getItemPropertiesBatch(e, c);
191729
+ for (let e of l.values()) {
191730
+ if (!e) continue;
191731
+ let t = y_(e.RelatingType);
191732
+ if (t === null) continue;
191733
+ let n = o.get(t);
191734
+ if (n) for (let t of b_(e.RelatedObjects)) {
191735
+ let e = o.get(t) ?? /* @__PURE__ */ new Set();
191736
+ n.forEach((t) => e.add(t)), o.set(t, e);
191737
+ }
191738
+ }
191739
+ let u = /* @__PURE__ */ new Map();
191740
+ return o.forEach((e, t) => {
191741
+ let n = [...e];
191742
+ u.set(t, n.length === 1 ? n[0] : n);
191743
+ }), u;
191744
+ }
191745
+ getMaterialNames(e) {
191746
+ let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = (e) => {
191747
+ if (!e || typeof e != "object" || n.has(e)) return;
191748
+ if (n.add(e), Array.isArray(e)) {
191749
+ e.forEach(r);
191750
+ return;
191751
+ }
191752
+ if (v_(e)) {
191753
+ r(e.value);
191754
+ return;
191755
+ }
191756
+ let i = e, a = v_(i.type) ? i.type.value : i.type;
191757
+ if (a === 1838606355 || typeof a == "string" && a.replace(/[^a-z0-9]/gi, "").toUpperCase() === "IFCMATERIAL") {
191758
+ let e = this.getStringValue(i.Name);
191759
+ e && t.add(e);
191760
+ }
191761
+ Object.values(i).forEach(r);
191762
+ };
191763
+ if (r(e), t.size === 0) {
191764
+ let n = this.getStringValue(e.Name) ?? this.getStringValue(e.LayerSetName);
191765
+ n && t.add(n);
191766
+ }
191767
+ return [...t];
191768
+ }
191621
191769
  async getSpatialStructure(e, t = !1) {
191622
191770
  let n = await this.getSpatialTreeChunks(e), r = await this.getSpatialLineMap(e, n), i = this.getProjectID(e);
191623
191771
  if (i === void 0) return {
@@ -191880,13 +192028,24 @@ var C_ = class {
191880
192028
  z: -(this.getScaledCoordinate(c, 1) ?? 0)
191881
192029
  }, d.points = e, d;
191882
192030
  }
191883
- }, w_ = 1e-5, T_ = {
192031
+ }, w_ = 1e-5, T_ = 262144, E_ = 250, D_ = 32768, O_ = 4096;
192032
+ function k_(e, t) {
192033
+ if (t <= e.length) return e;
192034
+ let n = new Float32Array(Math.max(t, e.length * 2));
192035
+ return n.set(e), n;
192036
+ }
192037
+ function A_(e, t) {
192038
+ if (t <= e.length) return e;
192039
+ let n = new Uint32Array(Math.max(t, e.length * 2));
192040
+ return n.set(e), n;
192041
+ }
192042
+ var j_ = {
191884
192043
  b: .55,
191885
192044
  g: .55,
191886
192045
  name: -1,
191887
192046
  opacity: .18,
191888
192047
  r: .55
191889
- }, E_ = class {
192048
+ }, M_ = class {
191890
192049
  useIfcElemetAssembly = !1;
191891
192050
  useIfcColors = !1;
191892
192051
  useIfcSpace = !0;
@@ -191984,7 +192143,7 @@ var C_ = class {
191984
192143
  }
191985
192144
  if (console.log("spend to read ifc file: ", Date.now() - r, "ms"), a === -1) return console.error("Model loading error"), !1;
191986
192145
  try {
191987
- let e = this.coordinationMatrix?.toArray(), t = new D_(this.parser, a, {
192146
+ let e = this.coordinationMatrix?.toArray(), t = new N_(this.parser, a, {
191988
192147
  geometryTransformation: e,
191989
192148
  maxGeometriesPerMesh: this.chunk,
191990
192149
  maxMeshBytes: this.maxMeshBytes,
@@ -192116,7 +192275,7 @@ var C_ = class {
192116
192275
  }
192117
192276
  };
192118
192277
  }
192119
- }, D_ = class {
192278
+ }, N_ = class {
192120
192279
  materials = {};
192121
192280
  elementsAssembly = null;
192122
192281
  parser;
@@ -192135,7 +192294,7 @@ var C_ = class {
192135
192294
  let i = this.planGeometryChunks();
192136
192295
  n && this.planGeometryChunks(i, {
192137
192296
  isIfcSpace: !0,
192138
- material: T_,
192297
+ material: j_,
192139
192298
  types: [Lc]
192140
192299
  }), this.applyGeometryTransformation();
192141
192300
  let a = this.createChunkBuilders(i), o = /* @__PURE__ */ new Map(), s = {
@@ -192145,7 +192304,7 @@ var C_ = class {
192145
192304
  };
192146
192305
  return this.streamGeometryChunks(a, o, e, {}, s), n && this.streamGeometryChunks(a, o, e, {
192147
192306
  isIfcSpace: !0,
192148
- material: T_,
192307
+ material: j_,
192149
192308
  types: [Lc]
192150
192309
  }, s), this.createModelDataFromChunks(a, r);
192151
192310
  }
@@ -192154,14 +192313,14 @@ var C_ = class {
192154
192313
  let r = /* @__PURE__ */ new Map(), i = {
192155
192314
  callbacks: n,
192156
192315
  emittedChunks: 0,
192316
+ lastFlushTime: Date.now(),
192157
192317
  nextGeometryID: 0,
192158
- pendingGeometryCount: 0,
192159
192318
  processedGeometryCount: 0,
192160
192319
  totalGeometries: this.getGeometryProgressTotal()
192161
192320
  };
192162
192321
  return this.streamDynamicGeometryChunks(r, e, {}, i), t && this.streamDynamicGeometryChunks(r, e, {
192163
192322
  isIfcSpace: !0,
192164
- material: T_,
192323
+ material: j_,
192165
192324
  types: [Lc]
192166
192325
  }, i), this.flushDynamicGeometryChunks(r, i), {
192167
192326
  data: {},
@@ -192177,11 +192336,13 @@ var C_ = class {
192177
192336
  let s = a.get(o), c = this.getPlacedGeometryPayload(s, i.expressID, n.material);
192178
192337
  if (!c) continue;
192179
192338
  let l = this.getDynamicChunkBuilder(e, c, !!n.isIfcSpace, r);
192180
- this.writeGeometryPayloadToDynamicBuilder(l, c), t.add(c.elementId), r.pendingGeometryCount++, r.processedGeometryCount++, r.callbacks.onGeometryProgress?.({
192339
+ this.writeGeometryPayloadToDynamicBuilder(l, c), t.add(c.elementId), r.processedGeometryCount++, r.callbacks.onGeometryProgress?.({
192181
192340
  emittedChunks: r.emittedChunks,
192182
192341
  processed: r.processedGeometryCount,
192183
192342
  total: r.totalGeometries
192184
- }), this.options.maxGeometriesPerMesh > 0 && r.pendingGeometryCount >= this.options.maxGeometriesPerMesh && this.flushDynamicGeometryChunks(e, r);
192343
+ });
192344
+ let u = Date.now();
192345
+ u - r.lastFlushTime >= E_ && (r.lastFlushTime = u, this.flushLargeDynamicGeometryChunks(e, r));
192185
192346
  }
192186
192347
  } finally {
192187
192348
  this.deleteFlatMesh(i);
@@ -192190,58 +192351,70 @@ var C_ = class {
192190
192351
  }
192191
192352
  getDynamicChunkBuilder(e, t, n, r) {
192192
192353
  let i = e.get(t.materialKey);
192193
- if (i && this.canFitInChunk(i, t)) return i;
192354
+ if (i && this.canFitInStreamingChunk(i, t)) return i;
192194
192355
  i && this.emitDynamicGeometryChunk(i, r);
192195
192356
  let a = {
192196
192357
  ...t.material,
192197
192358
  name: r.nextGeometryID
192198
192359
  };
192199
192360
  r.nextGeometryID++;
192200
- let o = {
192361
+ let o = Math.max(O_, t.vertexCount), s = {
192201
192362
  bytes: 0,
192202
192363
  geometryCount: 0,
192203
192364
  geometryID: a.name,
192204
- ids: [],
192365
+ ids: new Uint32Array(o),
192205
192366
  indexCount: 0,
192206
- indices: [],
192367
+ indices: new Uint32Array(Math.max(o * 2, t.indexCount)),
192207
192368
  isIfcSpace: n,
192208
192369
  material: a,
192209
192370
  materialKey: t.materialKey,
192210
- normals: [],
192211
- positions: [],
192371
+ normals: new Float32Array(o * 3),
192372
+ positions: new Float32Array(o * 3),
192212
192373
  vertexCount: 0
192213
192374
  };
192214
- return e.set(t.materialKey, o), o;
192375
+ return e.set(t.materialKey, s), s;
192215
192376
  }
192216
192377
  writeGeometryPayloadToDynamicBuilder(e, t) {
192217
- let n = this.meshMatrix.fromArray(t.matrix), r = n.elements, i = this.normalMatrix.getNormalMatrix(n).elements, a = e.vertexCount;
192218
- for (let n = 0; n < t.vertexData.length; n += 6) {
192219
- let a = this.getFiniteNumber(t.vertexData[n]), o = this.getFiniteNumber(t.vertexData[n + 1]), s = this.getFiniteNumber(t.vertexData[n + 2]), c = this.getFiniteNumber(t.vertexData[n + 3]), l = this.getFiniteNumber(t.vertexData[n + 4]), u = this.getFiniteNumber(t.vertexData[n + 5]);
192220
- e.positions.push(r[0] * a + r[4] * o + r[8] * s + r[12], r[1] * a + r[5] * o + r[9] * s + r[13], r[2] * a + r[6] * o + r[10] * s + r[14]);
192221
- let d = i[0] * c + i[3] * l + i[6] * u, f = i[1] * c + i[4] * l + i[7] * u, p = i[2] * c + i[5] * l + i[8] * u, m = Math.hypot(d, f, p);
192222
- m > 0 && (d /= m, f /= m, p /= m), e.normals.push(d, f, p), e.ids.push(t.elementId);
192223
- }
192224
- if (t.indexData.length) for (let n = 0; n < t.indexData.length; n++) e.indices.push(t.indexData[n] + a);
192225
- else for (let n = 0; n < t.vertexCount; n++) e.indices.push(a + n);
192378
+ let n = this.meshMatrix.fromArray(t.matrix), r = n.elements, i = this.normalMatrix.getNormalMatrix(n).elements, a = e.vertexCount, o = a + t.vertexCount, s = e.indexCount, { ids: c, normals: l, positions: u } = this.reserveDynamicBuilder(e, o, s + t.indexCount), d = a;
192379
+ for (let e = 0; e < t.vertexData.length; e += 6, d++) {
192380
+ let n = this.getFiniteNumber(t.vertexData[e]), a = this.getFiniteNumber(t.vertexData[e + 1]), o = this.getFiniteNumber(t.vertexData[e + 2]), s = this.getFiniteNumber(t.vertexData[e + 3]), f = this.getFiniteNumber(t.vertexData[e + 4]), p = this.getFiniteNumber(t.vertexData[e + 5]), m = d * 3;
192381
+ u[m] = r[0] * n + r[4] * a + r[8] * o + r[12], u[m + 1] = r[1] * n + r[5] * a + r[9] * o + r[13], u[m + 2] = r[2] * n + r[6] * a + r[10] * o + r[14];
192382
+ let ee = i[0] * s + i[3] * f + i[6] * p, te = i[1] * s + i[4] * f + i[7] * p, ne = i[2] * s + i[5] * f + i[8] * p, re = Math.hypot(ee, te, ne);
192383
+ re > 0 && (ee /= re, te /= re, ne /= re), l[m] = ee, l[m + 1] = te, l[m + 2] = ne, c[d] = t.elementId;
192384
+ }
192385
+ let { indices: f } = e;
192386
+ if (t.indexData.length) for (let e = 0; e < t.indexData.length; e++) f[s + e] = t.indexData[e] + a;
192387
+ else for (let e = 0; e < t.vertexCount; e++) f[s + e] = a + e;
192226
192388
  e.bytes += t.bytes, e.geometryCount++, e.indexCount += t.indexCount, e.vertexCount += t.vertexCount;
192227
192389
  }
192390
+ reserveDynamicBuilder(e, t, n) {
192391
+ return e.positions = k_(e.positions, t * 3), e.normals = k_(e.normals, t * 3), e.ids = A_(e.ids, t), e.indices = A_(e.indices, n), e;
192392
+ }
192393
+ canFitInStreamingChunk(e, t) {
192394
+ return e.geometryCount > 0 && e.vertexCount + t.vertexCount > T_ ? !1 : this.canFitInChunk(e, t);
192395
+ }
192396
+ flushLargeDynamicGeometryChunks(e, t) {
192397
+ e.forEach((n, r) => {
192398
+ n.vertexCount < D_ || (this.emitDynamicGeometryChunk(n, t), e.delete(r));
192399
+ });
192400
+ }
192228
192401
  flushDynamicGeometryChunks(e, t) {
192229
192402
  e.forEach((e) => {
192230
192403
  this.emitDynamicGeometryChunk(e, t);
192231
- }), e.clear(), t.pendingGeometryCount = 0;
192404
+ }), e.clear();
192232
192405
  }
192233
192406
  emitDynamicGeometryChunk(e, t) {
192234
192407
  if (!e.geometryCount) return;
192235
- let n = t.emittedChunks;
192408
+ let n = t.emittedChunks, { indexCount: r, vertexCount: i } = e;
192236
192409
  t.emittedChunks++, t.callbacks.onGeometryChunk?.({
192237
192410
  chunkIndex: n,
192238
192411
  geometry: this.optimizeIfcGeometryData({
192239
- ids: new Uint32Array(e.ids),
192240
- ind: new Uint32Array(e.indices),
192412
+ ids: e.ids.slice(0, i),
192413
+ ind: e.indices.slice(0, r),
192241
192414
  isIfcSpace: e.isIfcSpace || void 0,
192242
192415
  mat: e.material,
192243
- norm: new Float32Array(e.normals),
192244
- pos: new Float32Array(e.positions)
192416
+ norm: e.normals.slice(0, i * 3),
192417
+ pos: e.positions.slice(0, i * 3)
192245
192418
  }),
192246
192419
  geometryID: e.geometryID,
192247
192420
  isIfcSpace: e.isIfcSpace,
@@ -192250,7 +192423,7 @@ var C_ = class {
192250
192423
  emittedChunks: t.emittedChunks,
192251
192424
  processed: t.processedGeometryCount,
192252
192425
  total: t.totalGeometries
192253
- }), e.bytes = 0, e.geometryCount = 0, e.ids = [], e.indexCount = 0, e.indices = [], e.normals = [], e.positions = [], e.vertexCount = 0;
192426
+ }), e.geometryCount = 0;
192254
192427
  }
192255
192428
  streamGeometryChunks(e, t, n, r, i) {
192256
192429
  this.streamMeshes(r, (a) => {
@@ -192505,4 +192678,4 @@ var C_ = class {
192505
192678
  }
192506
192679
  };
192507
192680
  //#endregion
192508
- export { E_ as IFCLoader };
192681
+ export { M_ as IFCLoader };
@@ -131,5 +131,45 @@ export declare class BMTLoader {
131
131
  private getModelNameFromPath;
132
132
  loadModel(path: string, callbacks?: BmtParseCallbacks): Promise<BmtModelData>;
133
133
  parseBinaryFile(data: ArrayBuffer, callbacks?: BmtParseCallbacks): BmtModelData;
134
+ /**
135
+ * Incremental parser for bytes that arrive over time (e.g. a fetch
136
+ * stream). Geometry chunks are emitted as soon as their bytes are read.
137
+ */
138
+ createStreamParser(callbacks?: BmtParseCallbacks, totalBytes?: number): BmtStreamParser;
139
+ /** @internal */
140
+ createParseState(streamingCoordinationMatrix?: string): BmtParseState;
141
+ /** @internal */
142
+ parseChunk(state: BmtParseState, type: number, data: Uint8Array, callbacks: BmtParseCallbacks, loadedBytes: number, totalBytes: number): void;
143
+ /** @internal */
144
+ createModelData(state: BmtParseState): BmtModelData;
145
+ private parseGeometry;
146
+ }
147
+ type BmtParseState = {
148
+ curMatrix: string;
149
+ deferredChunks: BmtGeometryChunkData[] | null;
150
+ emittedChunks: number;
151
+ firstMatrix?: string;
152
+ geomData: BmtModelGeometryData;
153
+ gridsData?: ModelGridsData;
154
+ propsData: BmtModelProps;
155
+ streamingCoordinationMatrix?: string;
156
+ structure: BmtModelStructure;
157
+ trailingMatrix?: string;
158
+ trueNorthAngle?: number;
159
+ };
160
+ export declare class BmtStreamParser {
161
+ private buffer;
162
+ private headerRead;
163
+ private length;
164
+ private offset;
165
+ private readonly state;
166
+ private readonly loader;
167
+ private readonly callbacks;
168
+ private readonly totalBytes;
169
+ constructor(loader: BMTLoader, callbacks: BmtParseCallbacks, totalBytes?: number);
170
+ push(bytes: Uint8Array): void;
171
+ finish(): BmtModelData;
172
+ private ensureCapacity;
173
+ private parseAvailable;
134
174
  }
135
175
  export {};
@@ -97,6 +97,9 @@ export declare class IfcParser {
97
97
  private streamDynamicGeometryChunks;
98
98
  private getDynamicChunkBuilder;
99
99
  private writeGeometryPayloadToDynamicBuilder;
100
+ private reserveDynamicBuilder;
101
+ private canFitInStreamingChunk;
102
+ private flushLargeDynamicGeometryChunks;
100
103
  private flushDynamicGeometryChunks;
101
104
  private emitDynamicGeometryChunk;
102
105
  private streamGeometryChunks;
@@ -10,14 +10,17 @@ type IfcLineData = Record<string, IfcRawValue> & {
10
10
  expressID?: number;
11
11
  Elevation?: BmtPropertyValue;
12
12
  GlobalId?: BmtPropertyValue;
13
+ HasPropertySets?: IfcRawValue[];
13
14
  HasProperties?: BmtPropertyRecord[];
14
15
  HasQuantities?: IfcRawValue[];
15
16
  LongName?: BmtPropertyValue;
16
17
  Name?: BmtPropertyValue;
17
18
  ObjectType?: BmtPropertyValue;
19
+ PredefinedType?: BmtPropertyValue;
18
20
  Quantities?: BmtPropertyRecord[];
19
21
  RelatedObjects?: number[];
20
22
  RelatingPropertyDefinition?: number;
23
+ RelatingType?: number;
21
24
  type?: number | string;
22
25
  };
23
26
  type PropertyRelationConfig = {
@@ -68,6 +71,14 @@ export declare class PropertySerializer {
68
71
  getElementsAssembly(modelID: number): Promise<IfcElementsAssembly>;
69
72
  private formatItemProperties;
70
73
  private getAllRelDefinesByProps;
74
+ private getTypePropertySetIDsByElement;
75
+ private createPropertySet;
76
+ private mergePropertySet;
77
+ private getPropertySetMergeName;
78
+ private mergePropertySetProps;
79
+ private getPropertyMergeName;
80
+ private getMaterialsByElement;
81
+ private getMaterialNames;
71
82
  getSpatialStructure(modelID: number, includeProperties?: boolean): Promise<BmtModelStructureNode>;
72
83
  getRelatedProperties(modelID: number, elementID: number, propsName: PropertyRelationConfig, recursive?: boolean): Promise<IfcLineData[]>;
73
84
  getChunks(modelID: number, chunks: SpatialTreeChunks, propNames: PropertyRelationConfig): Promise<void>;
package/lib/Model.d.ts CHANGED
@@ -8,8 +8,8 @@ type ModelProps = {
8
8
  data: BmtModelData;
9
9
  loadGeneration: number;
10
10
  materialMode?: ViewerMaterialMode;
11
- onUploadComplete?: (uploadedItemCount: number) => void;
12
- onUploadProgress?: (uploadedItemCount: number, totalItemCount: number) => void;
11
+ onUploadComplete?: (modelID: number, uploadedItemCount: number) => void;
12
+ onUploadProgress?: (modelID: number, uploadedItemCount: number, totalItemCount: number) => void;
13
13
  trueNorthEnabled?: boolean;
14
14
  useWebGPU?: boolean;
15
15
  };