vim-web 0.3.44-dev.31 → 0.3.44-dev.33

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/vim-web.js CHANGED
@@ -52973,7 +52973,7 @@ class RenderScene {
52973
52973
  * @param target box in which to copy result, a new instance is created if undefined.
52974
52974
  */
52975
52975
  getBoundingBox(target = new Box3()) {
52976
- return this._boundingBox ? target.copy(this._boundingBox) : target.set(new Vector3(-1, -1, -1), new Vector3(1, 1, 1));
52976
+ return this._boundingBox ? target.copy(this._boundingBox) : void 0;
52977
52977
  }
52978
52978
  /**
52979
52979
  * Returns the bounding box of the average center of all meshes.
@@ -55601,6 +55601,34 @@ class SectionBoxGizmo {
55601
55601
  this.handles.dispose();
55602
55602
  }
55603
55603
  }
55604
+ function addBox(b1, b2) {
55605
+ const r = b1.clone();
55606
+ r.min.x += b2.min.x;
55607
+ r.min.y += b2.min.y;
55608
+ r.min.z += b2.min.z;
55609
+ r.max.x += b2.max.x;
55610
+ r.max.y += b2.max.y;
55611
+ r.max.z += b2.max.z;
55612
+ return r;
55613
+ }
55614
+ function safeBox(b1) {
55615
+ if (b1.max.x <= b1.min.x) {
55616
+ const temp = b1.min.x;
55617
+ b1.min.x = b1.max.x;
55618
+ b1.max.x = temp;
55619
+ }
55620
+ if (b1.max.y <= b1.min.y) {
55621
+ const temp = b1.min.y;
55622
+ b1.min.y = b1.max.y;
55623
+ b1.max.y = temp;
55624
+ }
55625
+ if (b1.max.z <= b1.min.z) {
55626
+ const temp = b1.min.z;
55627
+ b1.min.z = b1.max.z;
55628
+ b1.max.z = temp;
55629
+ }
55630
+ return b1;
55631
+ }
55604
55632
  let SectionBox$1 = class SectionBox {
55605
55633
  // -------------------------------------------------------------------------
55606
55634
  // Constructor
@@ -55639,9 +55667,6 @@ let SectionBox$1 = class SectionBox {
55639
55667
  this.update();
55640
55668
  };
55641
55669
  this._inputs.onBoxConfirm = (box) => this._onBoxConfirm.dispatch(box);
55642
- viewer.renderer.onBoxUpdated.subscribe(() => {
55643
- this.fitBox(viewer.renderer.getBoundingBox());
55644
- });
55645
55670
  this.clip = false;
55646
55671
  this.visible = false;
55647
55672
  this.interactive = false;
@@ -55761,6 +55786,7 @@ let SectionBox$1 = class SectionBox {
55761
55786
  */
55762
55787
  fitBox(box) {
55763
55788
  if (!box) return;
55789
+ box = safeBox(box);
55764
55790
  this._gizmos.fitBox(box);
55765
55791
  this.renderer.section.fitBox(box);
55766
55792
  this._onBoxConfirm.dispatch(this.box);
@@ -61869,7 +61895,12 @@ class SectionBox2 {
61869
61895
  this._clip = value;
61870
61896
  this.scheduleUpdate();
61871
61897
  }
61898
+ /**
61899
+ * Fits the given box, invalid dimensions will be reversed.
61900
+ * @param box - The new bounding box.
61901
+ */
61872
61902
  fitBox(box) {
61903
+ box = safeBox(box);
61873
61904
  this._box = box;
61874
61905
  this.scheduleUpdate();
61875
61906
  }
@@ -75758,16 +75789,6 @@ function computePosition(panelRef) {
75758
75789
  }
75759
75790
  return { top: 0, left: 0 };
75760
75791
  }
75761
- function addBox(b1, b2) {
75762
- const r = b1.clone();
75763
- r.min.x += b2.min.x;
75764
- r.min.y += b2.min.y;
75765
- r.min.z += b2.min.z;
75766
- r.max.x += b2.max.x;
75767
- r.max.y += b2.max.y;
75768
- r.max.z += b2.max.z;
75769
- return r;
75770
- }
75771
75792
  function useStateRef(initialValue) {
75772
75793
  const [value, setValue] = useState(initialValue);
75773
75794
  const ref = useRef(initialValue);
@@ -75893,6 +75914,7 @@ function useSectionBox(adapter) {
75893
75914
  });
75894
75915
  visible2.useOnChange((v) => adapter.setVisible(v));
75895
75916
  const section = useArgActionRef((baseBox) => {
75917
+ if (baseBox === void 0) return;
75896
75918
  boxRef.current = baseBox;
75897
75919
  const newBox = addBox(baseBox, offsetsToBox3(topOffset.get(), sideOffset.get(), bottomOffset.get()));
75898
75920
  adapter.fitBox(newBox);