@thatopen/components 2.3.10 → 2.3.12

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
@@ -3137,7 +3137,7 @@ const Fs = class Fs {
3137
3137
  /**
3138
3138
  * The version of the @thatopen/components library.
3139
3139
  */
3140
- C(Fs, "release", "2.3.10");
3140
+ C(Fs, "release", "2.3.12");
3141
3141
  let Cs = Fs;
3142
3142
  class Qa extends xn {
3143
3143
  constructor() {
@@ -6959,9 +6959,11 @@ class Vn {
6959
6959
  * @param {boolean} state - The new enabled state.
6960
6960
  */
6961
6961
  set enabled(i) {
6962
- if (!this.world.renderer)
6963
- throw new Error("No renderer found for clipping plane!");
6964
- this._enabled = i, this.world.renderer.setPlane(i, this.three);
6962
+ if (!this.world.isDisposing) {
6963
+ if (!this.world.renderer)
6964
+ throw new Error("No renderer found for clipping plane!");
6965
+ this._enabled = i, this.world.renderer.setPlane(i, this.three);
6966
+ }
6965
6967
  }
6966
6968
  /** {@link Hideable.visible } */
6967
6969
  get visible() {
@@ -18547,9 +18549,9 @@ class To {
18547
18549
  */
18548
18550
  C(this, "clippingPlanes", new we());
18549
18551
  C(this, "camera", {
18550
- aspectRatio: 0,
18551
- fov: 0,
18552
- direction: { x: 0, y: 0, z: 80 },
18552
+ aspectRatio: 1,
18553
+ fov: 60,
18554
+ direction: { x: 0, y: 0, z: 0 },
18553
18555
  position: { x: 0, y: 0, z: 0 }
18554
18556
  });
18555
18557
  /**
@@ -18747,28 +18749,38 @@ class To {
18747
18749
  "Viewpoint: the world's camera need controls to set the viewpoint."
18748
18750
  );
18749
18751
  t instanceof _c && t.projection.set(this.projection);
18750
- const e = this.position, s = this.direction;
18751
- let n = {
18752
- x: e.x + s.x * 80,
18753
- y: e.y + s.y * 80,
18754
- z: e.z + s.z * 80
18752
+ const e = new D.Vector3(
18753
+ this.camera.position.x,
18754
+ this.camera.position.y,
18755
+ this.camera.position.z
18756
+ ), s = new D.Vector3(
18757
+ this.camera.direction.x,
18758
+ this.camera.direction.y,
18759
+ this.camera.direction.z
18760
+ );
18761
+ if (e.equals(new D.Vector3()) && s.equals(new D.Vector3()))
18762
+ return;
18763
+ const n = this.position, r = this.direction;
18764
+ let o = {
18765
+ x: n.x + r.x * 80,
18766
+ y: n.y + r.y * 80,
18767
+ z: n.z + r.z * 80
18755
18768
  };
18756
- const r = this.selection;
18757
- if (Object.keys(r).length === 0) {
18758
- const h = this._components.get(ci).get(this.world).castRayFromVector(e, this.direction);
18759
- h && (n = h.point);
18769
+ const a = this.selection;
18770
+ if (Object.keys(a).length === 0) {
18771
+ const f = this._components.get(ci).get(this.world).castRayFromVector(n, this.direction);
18772
+ f && (o = f.point);
18760
18773
  } else {
18761
- const a = this._components.get(wn);
18762
- a.reset(), a.addFragmentIdMap(r), n = a.getSphere().center, a.reset();
18763
- }
18764
- const o = this._components.get(Mn);
18765
- o.set(this.defaultVisibility), o.set(!this.defaultVisibility, this.exception), o.set(!0, r), await t.controls.setLookAt(
18766
- e.x,
18767
- e.y,
18768
- e.z,
18774
+ const l = this._components.get(wn);
18775
+ l.reset(), l.addFragmentIdMap(a), o = l.getSphere().center, l.reset();
18776
+ }
18777
+ await t.controls.setLookAt(
18769
18778
  n.x,
18770
18779
  n.y,
18771
18780
  n.z,
18781
+ o.x,
18782
+ o.y,
18783
+ o.z,
18772
18784
  i
18773
18785
  );
18774
18786
  }
@@ -18811,6 +18823,10 @@ class To {
18811
18823
  viewToWorldScale: s.top - s.bottom
18812
18824
  }), this._components.get(ie).list.set(this.guid, this);
18813
18825
  }
18826
+ applyVisibility() {
18827
+ const i = this._components.get(Mn);
18828
+ i.set(this.defaultVisibility), i.set(!this.defaultVisibility, this.exception), i.set(!0, this.selection);
18829
+ }
18814
18830
  /**
18815
18831
  * Applies color to the components in the viewpoint based on their GUIDs.
18816
18832
  *
@@ -18821,21 +18837,15 @@ class To {
18821
18837
  * The color is applied using the `Classifier.setColor` method, which sets the color of the specified fragments.
18822
18838
  * The color is provided as a hexadecimal string, prefixed with a '#'.
18823
18839
  */
18824
- colorize() {
18840
+ applyColors() {
18825
18841
  const i = this._components.get(ie), t = this._components.get(Tt), e = this._components.get(Bi);
18826
18842
  for (const [s, n] of this.componentColors) {
18827
- const r = t.guidToFragmentIdMap(n), o = new D.Color(`#${s}`);
18828
- e.setColor(
18829
- r,
18830
- o,
18831
- i.config.overwriteColors
18832
- );
18843
+ const r = t.guidToFragmentIdMap(n);
18844
+ e.setColor(r, s, i.config.overwriteColors);
18833
18845
  }
18834
18846
  }
18835
18847
  /**
18836
18848
  * Resets the colors of all components in the viewpoint to their original color.
18837
- * This method iterates through the `componentColors` map, retrieves the fragment IDs
18838
- * corresponding to each color, and then uses the `Classifier` to reset the color of those fragments.
18839
18849
  */
18840
18850
  resetColors() {
18841
18851
  const i = this._components.get(Tt), t = this._components.get(Bi);
@@ -18873,6 +18883,20 @@ class To {
18873
18883
  `);
18874
18884
  return s;
18875
18885
  }
18886
+ createColorTags() {
18887
+ let i = "";
18888
+ for (const [t, e] of this.componentColors.entries()) {
18889
+ const s = `#${t.getHexString()}`, n = e.map((r) => `
18890
+ <Component IfcGuid="${r}" />`).join(`
18891
+ `);
18892
+ i += `<Color Color="${s}">
18893
+ ${n}
18894
+ </Color>`;
18895
+ }
18896
+ return i.length !== 0 ? `<Coloring>
18897
+ ${i}
18898
+ </Coloring>` : "<Coloring />";
18899
+ }
18876
18900
  /**
18877
18901
  * Serializes the viewpoint into a buildingSMART compliant XML string for export.
18878
18902
  *
@@ -18919,7 +18943,7 @@ class To {
18919
18943
  ${h}
18920
18944
  <FieldOfView>${this.camera.fov}</FieldOfView>
18921
18945
  </PerspectiveCamera>`);
18922
- const I = `<ViewSetupHints SpacesVisible="${this.spacesVisible ?? !1}" SpaceBoundariesVisible="${this.spaceBoundariesVisible ?? !1}" OpeningsVisible="${this.openingsVisible ?? !1}" />`, u = (await this.createComponentTags("selection")).trim(), d = (await this.createComponentTags("exception")).trim();
18946
+ const I = `<ViewSetupHints SpacesVisible="${this.spacesVisible ?? !1}" SpaceBoundariesVisible="${this.spaceBoundariesVisible ?? !1}" OpeningsVisible="${this.openingsVisible ?? !1}" />`, u = (await this.createComponentTags("selection")).trim(), d = (await this.createComponentTags("exception")).trim(), E = this.createColorTags();
18923
18947
  return `<?xml version="1.0" encoding="UTF-8"?>
18924
18948
  <VisualizationInfo Guid="${this.guid}">
18925
18949
  <Components>
@@ -18929,6 +18953,7 @@ class To {
18929
18953
  ${i === "3" ? I : ""}
18930
18954
  ${d.length !== 0 ? `<Exceptions>${d}</Exceptions>` : ""}
18931
18955
  </Visibility>
18956
+ ${E}
18932
18957
  </Components>
18933
18958
  ${f}
18934
18959
  </VisualizationInfo>`;