@thatopen/components 2.1.2 → 2.1.4

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/dist/index.mjs CHANGED
@@ -2968,7 +2968,7 @@ const Fs = class Fs {
2968
2968
  /**
2969
2969
  * The version of the @thatopen/components library.
2970
2970
  */
2971
- I(Fs, "release", "2.1.2");
2971
+ I(Fs, "release", "2.1.4");
2972
2972
  let pi = Fs;
2973
2973
  class Rr {
2974
2974
  constructor(s) {
@@ -5648,6 +5648,8 @@ class Pi {
5648
5648
  I(this, "components");
5649
5649
  /** The world instance to which this plane belongs. */
5650
5650
  I(this, "world");
5651
+ /** A custom string to identify what this plane is used for. */
5652
+ I(this, "type", "default");
5651
5653
  I(this, "_helper");
5652
5654
  I(this, "_visible", !0);
5653
5655
  I(this, "_enabled", !0);
@@ -5910,7 +5912,7 @@ const ve = class ve extends et {
5910
5912
  /** {@link Createable.create} */
5911
5913
  create(t) {
5912
5914
  const o = this.components.get(ze).get(t).castRay();
5913
- o && this.createPlaneFromIntersection(t, o);
5915
+ return o ? this.createPlaneFromIntersection(t, o) : null;
5914
5916
  }
5915
5917
  /**
5916
5918
  * Creates a plane in a certain place and with a certain orientation,
@@ -5935,12 +5937,19 @@ const ve = class ve extends et {
5935
5937
  delete(t, e) {
5936
5938
  e || (e = this.pickPlane(t)), e && this.deletePlane(e);
5937
5939
  }
5938
- /** Deletes all the existing clipping planes. */
5939
- deleteAll() {
5940
- for (; this.list.length > 0; ) {
5941
- const t = this.list[0];
5942
- this.delete(t.world, t);
5943
- }
5940
+ /**
5941
+ * Deletes all the existing clipping planes.
5942
+ *
5943
+ * @param types - the types of planes to be deleted. If not provided, all planes will be deleted.
5944
+ */
5945
+ deleteAll(t) {
5946
+ const e = [...this.list];
5947
+ for (const i of e)
5948
+ if (!t || t.has(i.type)) {
5949
+ this.delete(i.world, i);
5950
+ const o = this.list.indexOf(i);
5951
+ o !== -1 && this.list.splice(o, 1);
5952
+ }
5944
5953
  }
5945
5954
  deletePlane(t) {
5946
5955
  const e = this.list.indexOf(t);
@@ -5969,9 +5978,9 @@ const ve = class ve extends et {
5969
5978
  throw new Error("The given world must have a renderer!");
5970
5979
  const i = e.point.distanceTo(new g.Vector3(0, 0, 0)), o = (a = e.face) == null ? void 0 : a.normal;
5971
5980
  if (!i || !o)
5972
- return;
5981
+ return null;
5973
5982
  const n = this.getWorldNormal(e, o), r = this.newPlane(t, e.point, n.negate());
5974
- r.visible = this._visible, r.size = this._size, t.renderer.setPlane(!0, r.three), this.updateMaterialsAndPlanes();
5983
+ return r.visible = this._visible, r.size = this._size, t.renderer.setPlane(!0, r.three), this.updateMaterialsAndPlanes(), r;
5975
5984
  }
5976
5985
  getWorldNormal(t, e) {
5977
5986
  const i = t.object;
@@ -6288,7 +6297,7 @@ class Vr extends Yr {
6288
6297
  this._currentVisibleMeshes.delete(t), this._recentlyHiddenMeshes.delete(t);
6289
6298
  const i = this.colorMeshes.get(t.uuid), o = this._meshIDColorCodeMap.get(t.uuid);
6290
6299
  if (!i || !o) {
6291
- this.isProcessing = !1, console.log(t.visible);
6300
+ this.isProcessing = !1;
6292
6301
  return;
6293
6302
  }
6294
6303
  this._colorCodeMeshMap.delete(o), this._meshIDColorCodeMap.delete(t.uuid), this.colorMeshes.delete(t.uuid), i.geometry = void 0, i.material = [], e.destroy(i, !0), this._recentlyHiddenMeshes.delete(t), this._currentVisibleMeshes.delete(t), this.isProcessing = !1;
@@ -7200,6 +7209,7 @@ const Ns = class Ns extends et {
7200
7209
  */
7201
7210
  I(this, "groups", /* @__PURE__ */ new Map());
7202
7211
  I(this, "baseCoordinationModel", "");
7212
+ I(this, "baseCoordinationMatrix", new g.Matrix4());
7203
7213
  /** {@link Component.enabled} */
7204
7214
  I(this, "enabled", !0);
7205
7215
  I(this, "_loader", new to());
@@ -7308,26 +7318,18 @@ const Ns = class Ns extends et {
7308
7318
  * All other models are then transformed to match the base model's coordinate system.
7309
7319
  *
7310
7320
  * @param models - The models to apply coordinate transformation to.
7311
- * If not provided, all groups are used.
7312
- *
7313
- * @returns {void}
7321
+ * If not provided, all models are used.
7314
7322
  */
7315
7323
  coordinate(t = Array.from(this.groups.values())) {
7316
7324
  if (this.baseCoordinationModel.length === 0) {
7317
- const o = t.pop();
7318
- if (!o)
7325
+ const i = t.pop();
7326
+ if (!i)
7319
7327
  return;
7320
- this.baseCoordinationModel = o.uuid;
7321
- }
7322
- if (!t.length)
7323
- return;
7324
- const i = this.groups.get(this.baseCoordinationModel);
7325
- if (!i) {
7326
- console.log("No base model found for coordination!");
7327
- return;
7328
+ this.baseCoordinationModel = i.uuid, this.baseCoordinationMatrix = i.coordinationMatrix.clone();
7328
7329
  }
7329
- for (const o of t)
7330
- o !== i && (o.position.set(0, 0, 0), o.rotation.set(0, 0, 0), o.scale.set(1, 1, 1), o.updateMatrix(), o.applyMatrix4(o.coordinationMatrix.clone().invert()), o.applyMatrix4(i.coordinationMatrix));
7330
+ if (t.length)
7331
+ for (const i of t)
7332
+ i.coordinationMatrix.equals(this.baseCoordinationMatrix) || (i.position.set(0, 0, 0), i.rotation.set(0, 0, 0), i.scale.set(1, 1, 1), i.updateMatrix(), i.applyMatrix4(i.coordinationMatrix.clone().invert()), i.applyMatrix4(this.baseCoordinationMatrix));
7331
7333
  }
7332
7334
  };
7333
7335
  /**
@@ -9511,7 +9513,7 @@ const Ve = class Ve extends et {
9511
9513
  }
9512
9514
  /** {@link Disposable.dispose} */
9513
9515
  dispose() {
9514
- this.webIfc = null, this.onDisposed.trigger(Ve.uuid), this.onDisposed.reset();
9516
+ this.webIfc.Dispose(), this.webIfc = null, this.onDisposed.trigger(Ve.uuid), this.onDisposed.reset();
9515
9517
  }
9516
9518
  /**
9517
9519
  * Sets up the IfcLoader component with the provided configuration.
@@ -9602,7 +9604,7 @@ const Ve = class Ve extends et {
9602
9604
  * ```
9603
9605
  */
9604
9606
  cleanUp() {
9605
- this.webIfc = null, this.webIfc = new b.IfcAPI(), this._visitedFragments.clear(), this._fragmentInstances.clear();
9607
+ this.webIfc.Dispose(), this.webIfc = null, this.webIfc = new b.IfcAPI(), this._visitedFragments.clear(), this._fragmentInstances.clear();
9606
9608
  }
9607
9609
  async getAllGeometries() {
9608
9610
  this._spatialTree.setUp(this.webIfc);
@@ -10472,13 +10474,13 @@ const ys = class ys extends et {
10472
10474
  const r = e.list[this.groupName], a = new g.Matrix4();
10473
10475
  for (const c in r) {
10474
10476
  a.elements[13] = n * o * this.height;
10475
- for (const h in r[c]) {
10477
+ for (const h in r[c].map) {
10476
10478
  const d = i.list.get(h), E = c + h, u = this.list.has(E);
10477
10479
  if (!d || t && u || !t && !u)
10478
10480
  continue;
10479
10481
  t ? this.list.add(E) : this.list.delete(E);
10480
10482
  const f = r[c].map[h];
10481
- d.applyTransform(f, a);
10483
+ d.applyTransform(f, a), d.mesh.computeBoundingSphere(), d.mesh.computeBoundingBox();
10482
10484
  }
10483
10485
  n++;
10484
10486
  }
@@ -10610,7 +10612,7 @@ const ws = class ws extends et {
10610
10612
  }
10611
10613
  /** {@link Disposable.dispose} */
10612
10614
  dispose() {
10613
- this.onIfcLoaded.reset(), this.onGeometryStreamed.reset(), this.onAssetStreamed.reset(), this.webIfc = null, this.onDisposed.trigger(), this.onDisposed.reset();
10615
+ this.onIfcLoaded.reset(), this.onGeometryStreamed.reset(), this.onAssetStreamed.reset(), this.webIfc.Dispose(), this.webIfc = null, this.onDisposed.trigger(), this.onDisposed.reset();
10614
10616
  }
10615
10617
  /**
10616
10618
  * This method streams the IFC file from a given buffer.
@@ -10707,7 +10709,7 @@ const ws = class ws extends et {
10707
10709
  this.onIfcLoaded.trigger(R), n.dispose(!0);
10708
10710
  }
10709
10711
  cleanUp() {
10710
- this.webIfc = null, this.webIfc = new b.IfcAPI(), this._visitedGeometries.clear(), this._geometries.clear(), this._assets = [], this._meshesWithHoles.clear();
10712
+ this.webIfc.Dispose(), this.webIfc = null, this.webIfc = new b.IfcAPI(), this._visitedGeometries.clear(), this._geometries.clear(), this._assets = [], this._meshesWithHoles.clear();
10711
10713
  }
10712
10714
  getMesh(t, e, i) {
10713
10715
  const o = e.geometries.size(), n = e.expressID, r = { id: n, geometries: [] };
@@ -10816,7 +10818,7 @@ class Kr extends et {
10816
10818
  }
10817
10819
  /** {@link Disposable.dispose} */
10818
10820
  async dispose() {
10819
- this.onIndicesStreamed.reset(), this.onPropertiesStreamed.reset(), this.webIfc = null, this.onDisposed.reset();
10821
+ this.onIndicesStreamed.reset(), this.onPropertiesStreamed.reset(), this.webIfc.Dispose(), this.webIfc = null, this.onDisposed.reset();
10820
10822
  }
10821
10823
  /**
10822
10824
  * This method converts properties from an IFC file to tiles given its data as a Uint8Array.
@@ -10887,14 +10889,14 @@ class Kr extends et {
10887
10889
  }
10888
10890
  await this.onPropertiesStreamed.trigger({ type: c, data: R });
10889
10891
  }
10890
- const f = n / e.size;
10891
- f > o && (o += 0.01, o = Math.max(o, f), await this.onProgress.trigger(Math.round(o * 100) / 100));
10892
+ n / e.size > o && (o = Math.round(o * 100) / 100, await this.onProgress.trigger(o), o += 0.01);
10892
10893
  }
10894
+ await this.onProgress.trigger(1);
10893
10895
  const a = await this.components.get(ke).processFromWebIfc(this.webIfc, 0);
10894
10896
  await this.onIndicesStreamed.trigger(a);
10895
10897
  }
10896
10898
  cleanUp() {
10897
- this.webIfc = null, this.webIfc = new b.IfcAPI();
10899
+ this.webIfc.Dispose(), this.webIfc = null, this.webIfc = new b.IfcAPI();
10898
10900
  }
10899
10901
  }
10900
10902
  /**