@xeokit/xeokit-sdk 2.3.2 → 2.3.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.
@@ -746,9 +746,7 @@ class ContextMenu {
746
746
 
747
747
  item.itemElement.addEventListener("mouseenter", (event) => {
748
748
  event.preventDefault();
749
- if (item.enabled === false) {
750
- return;
751
- }
749
+
752
750
  const subMenu = item.subMenu;
753
751
  if (!subMenu) {
754
752
  if (lastSubMenu) {
@@ -762,6 +760,10 @@ class ContextMenu {
762
760
  lastSubMenu = null;
763
761
  }
764
762
 
763
+ if (item.enabled === false) {
764
+ return;
765
+ }
766
+
765
767
  const itemElement = item.itemElement;
766
768
  const subMenuElement = subMenu.menuElement;
767
769
 
@@ -12638,7 +12640,7 @@ function buildBoxGeometry(cfg = {}) {
12638
12640
  * xSize: 1, // Half-size on each axis
12639
12641
  * ySize: 1,
12640
12642
  * zSize: 1
12641
- * }),
12643
+ * })),
12642
12644
  * material: new PhongMaterial(viewer.scene, {
12643
12645
  * emissive: [0,1,0]
12644
12646
  * })
@@ -65449,37 +65451,91 @@ class Wire {
65449
65451
 
65450
65452
  constructor(parentElement, cfg = {}) {
65451
65453
 
65454
+ this._color = cfg.color || "black";
65455
+ this._highlightClass = "viewer-ruler-wire-highlighted";
65456
+
65452
65457
  this._wire = document.createElement('div');
65453
65458
  this._wire.className += this._wire.className ? ' viewer-ruler-wire' : 'viewer-ruler-wire';
65454
65459
 
65455
- var wire = this._wire;
65456
- var style = wire.style;
65460
+ this._wireClickable = document.createElement('div');
65461
+ this._wireClickable.className += this._wireClickable.className ? ' viewer-ruler-wire-clickable' : 'viewer-ruler-wire-clickable';
65457
65462
 
65458
65463
  this._thickness = cfg.thickness || 1.0;
65464
+ this._thicknessClickable = cfg.thicknessClickable || 6.0;
65459
65465
 
65460
- style.border = "solid " + this._thickness + "px " + (cfg.color || "black");
65461
- style.position = "absolute";
65462
- style["z-index"] = cfg.zIndex === undefined ? "2000001" : cfg.zIndex ;
65463
- style.width = 0 + "px";
65464
- style.height = 0 + "px";
65465
- style.visibility = "visible";
65466
- style.top = 0 + "px";
65467
- style.left = 0 + "px";
65468
- style["pointer-events"] = "none";
65469
- style['-webkit-transform-origin'] = "0 0";
65470
- style['-moz-transform-origin'] = "0 0";
65471
- style['-ms-transform-origin'] = "0 0";
65472
- style['-o-transform-origin'] = "0 0";
65473
- style['transform-origin'] = "0 0";
65474
- style['-webkit-transform'] = 'rotate(0deg)';
65475
- style['-moz-transform'] = 'rotate(0deg)';
65476
- style['-ms-transform'] = 'rotate(0deg)';
65477
- style['-o-transform'] = 'rotate(0deg)';
65478
- style['transform'] = 'rotate(0deg)';
65479
- style["opacity"] = 1.0;
65466
+ var wire = this._wire;
65467
+ var wireStyle = wire.style;
65468
+
65469
+ wireStyle.border = "solid " + this._thickness + "px " + this._color;
65470
+ wireStyle.position = "absolute";
65471
+ wireStyle["z-index"] = cfg.zIndex === undefined ? "2000001" : cfg.zIndex;
65472
+ wireStyle.width = 0 + "px";
65473
+ wireStyle.height = 0 + "px";
65474
+ wireStyle.visibility = "visible";
65475
+ wireStyle.top = 0 + "px";
65476
+ wireStyle.left = 0 + "px";
65477
+ wireStyle['-webkit-transform-origin'] = "0 0";
65478
+ wireStyle['-moz-transform-origin'] = "0 0";
65479
+ wireStyle['-ms-transform-origin'] = "0 0";
65480
+ wireStyle['-o-transform-origin'] = "0 0";
65481
+ wireStyle['transform-origin'] = "0 0";
65482
+ wireStyle['-webkit-transform'] = 'rotate(0deg)';
65483
+ wireStyle['-moz-transform'] = 'rotate(0deg)';
65484
+ wireStyle['-ms-transform'] = 'rotate(0deg)';
65485
+ wireStyle['-o-transform'] = 'rotate(0deg)';
65486
+ wireStyle['transform'] = 'rotate(0deg)';
65487
+ wireStyle["opacity"] = 1.0;
65488
+ if (cfg.onContextMenu) ;
65480
65489
 
65481
65490
  parentElement.appendChild(wire);
65482
65491
 
65492
+ var wireClickable = this._wireClickable;
65493
+ var wireClickableStyle = wireClickable.style;
65494
+
65495
+ wireClickableStyle.border = "solid " + this._thicknessClickable + "px " + this._color;
65496
+ wireClickableStyle.position = "absolute";
65497
+ wireClickableStyle["z-index"] = cfg.zIndex === undefined ? "2000002" : (cfg.zIndex + 1);
65498
+ wireClickableStyle.width = 0 + "px";
65499
+ wireClickableStyle.height = 0 + "px";
65500
+ wireClickableStyle.visibility = "visible";
65501
+ wireClickableStyle.top = 0 + "px";
65502
+ wireClickableStyle.left = 0 + "px";
65503
+ // wireClickableStyle["pointer-events"] = "none";
65504
+ wireClickableStyle['-webkit-transform-origin'] = "0 0";
65505
+ wireClickableStyle['-moz-transform-origin'] = "0 0";
65506
+ wireClickableStyle['-ms-transform-origin'] = "0 0";
65507
+ wireClickableStyle['-o-transform-origin'] = "0 0";
65508
+ wireClickableStyle['transform-origin'] = "0 0";
65509
+ wireClickableStyle['-webkit-transform'] = 'rotate(0deg)';
65510
+ wireClickableStyle['-moz-transform'] = 'rotate(0deg)';
65511
+ wireClickableStyle['-ms-transform'] = 'rotate(0deg)';
65512
+ wireClickableStyle['-o-transform'] = 'rotate(0deg)';
65513
+ wireClickableStyle['transform'] = 'rotate(0deg)';
65514
+ wireClickableStyle["opacity"] = 0.0;
65515
+ wireClickableStyle["pointer-events"] = "all";
65516
+ if (cfg.onContextMenu) ;
65517
+
65518
+ parentElement.appendChild(wireClickable);
65519
+
65520
+ if (cfg.onMouseOver) {
65521
+ wireClickable.addEventListener('mouseover', (event) => {
65522
+ cfg.onMouseOver(event, this);
65523
+ });
65524
+ }
65525
+
65526
+ if (cfg.onMouseLeave) {
65527
+ wireClickable.addEventListener('mouseleave', (event) => {
65528
+ cfg.onMouseLeave(event, this);
65529
+ });
65530
+ }
65531
+
65532
+ if (cfg.onContextMenu) {
65533
+ wireClickable.addEventListener('contextmenu', (event) => {
65534
+ cfg.onContextMenu(event, this);
65535
+ event.preventDefault();
65536
+ });
65537
+ }
65538
+
65483
65539
  this._x1 = 0;
65484
65540
  this._y1 = 0;
65485
65541
  this._x2 = 0;
@@ -65497,16 +65553,25 @@ class Wire {
65497
65553
  var length = Math.abs(Math.sqrt((this._x1 - this._x2) * (this._x1 - this._x2) + (this._y1 - this._y2) * (this._y1 - this._y2)));
65498
65554
  var angle = Math.atan2(this._y2 - this._y1, this._x2 - this._x1) * 180.0 / Math.PI;
65499
65555
 
65500
- var style = this._wire.style;
65501
- style["width"] = Math.round(length) + 'px';
65502
- style["left"] = Math.round(this._x1) + 'px';
65503
- style["top"] = Math.round(this._y1) + 'px';
65504
- style['-webkit-transform'] = 'rotate(' + angle + 'deg)';
65505
- style['-moz-transform'] = 'rotate(' + angle + 'deg)';
65506
- style['-ms-transform'] = 'rotate(' + angle + 'deg)';
65507
- style['-o-transform'] = 'rotate(' + angle + 'deg)';
65508
- style['transform'] = 'rotate(' + angle + 'deg)';
65509
- style["pointer-events"] = "none";
65556
+ var wireStyle = this._wire.style;
65557
+ wireStyle["width"] = Math.round(length) + 'px';
65558
+ wireStyle["left"] = Math.round(this._x1) + 'px';
65559
+ wireStyle["top"] = Math.round(this._y1) + 'px';
65560
+ wireStyle['-webkit-transform'] = 'rotate(' + angle + 'deg)';
65561
+ wireStyle['-moz-transform'] = 'rotate(' + angle + 'deg)';
65562
+ wireStyle['-ms-transform'] = 'rotate(' + angle + 'deg)';
65563
+ wireStyle['-o-transform'] = 'rotate(' + angle + 'deg)';
65564
+ wireStyle['transform'] = 'rotate(' + angle + 'deg)';
65565
+
65566
+ var wireClickableStyle = this._wireClickable.style;
65567
+ wireClickableStyle["width"] = Math.round(length) + 'px';
65568
+ wireClickableStyle["left"] = Math.round(this._x1) + 'px';
65569
+ wireClickableStyle["top"] = Math.round(this._y1) + 'px';
65570
+ wireClickableStyle['-webkit-transform'] = 'rotate(' + angle + 'deg)';
65571
+ wireClickableStyle['-moz-transform'] = 'rotate(' + angle + 'deg)';
65572
+ wireClickableStyle['-ms-transform'] = 'rotate(' + angle + 'deg)';
65573
+ wireClickableStyle['-o-transform'] = 'rotate(' + angle + 'deg)';
65574
+ wireClickableStyle['transform'] = 'rotate(' + angle + 'deg)';
65510
65575
  }
65511
65576
 
65512
65577
  setStartAndEnd(x1, y1, x2, y2) {
@@ -65518,7 +65583,8 @@ class Wire {
65518
65583
  }
65519
65584
 
65520
65585
  setColor(color) {
65521
- this._wire.style.border = "solid " + this._thickness + "px " + (color || "black");
65586
+ this._color = color || "black";
65587
+ this._wire.style.border = "solid " + this._thickness + "px " + this._color;
65522
65588
  }
65523
65589
 
65524
65590
  setOpacity(opacity) {
@@ -65533,8 +65599,25 @@ class Wire {
65533
65599
  this._wire.style.visibility = visible ? "visible" : "hidden";
65534
65600
  }
65535
65601
 
65602
+ setClickable(clickable) {
65603
+ this._wireClickable.style["pointer-events"] = (!!clickable) ? "all" : "none";
65604
+ }
65605
+
65606
+ setHighlighted(highlighted) {
65607
+ if (this._highlighted === highlighted) {
65608
+ return;
65609
+ }
65610
+ this._highlighted = !!highlighted;
65611
+ if (this._highlighted) {
65612
+ this._wire.classList.add(this._highlightClass);
65613
+ } else {
65614
+ this._wire.classList.remove(this._highlightClass);
65615
+ }
65616
+ }
65617
+
65536
65618
  destroy(visible) {
65537
65619
  this._wire.parentElement.removeChild(this._wire);
65620
+ this._wireClickable.parentElement.removeChild(this._wireClickable);
65538
65621
  }
65539
65622
  }
65540
65623
 
@@ -65543,6 +65626,8 @@ class Dot {
65543
65626
 
65544
65627
  constructor(parentElement, cfg = {}) {
65545
65628
 
65629
+ this._highlightClass = "viewer-ruler-dot-highlighted";
65630
+
65546
65631
  this._x = 0;
65547
65632
  this._y = 0;
65548
65633
 
@@ -65550,37 +65635,77 @@ class Dot {
65550
65635
  this._dot = document.createElement('div');
65551
65636
  this._dot.className += this._dot.className ? ' viewer-ruler-dot' : 'viewer-ruler-dot';
65552
65637
 
65638
+ this._dotClickable = document.createElement('div');
65639
+ this._dotClickable.className += this._dotClickable.className ? ' viewer-ruler-dot-clickable' : 'viewer-ruler-dot-clickable';
65640
+
65553
65641
  var dot = this._dot;
65554
- var style = dot.style;
65642
+ var dotStyle = dot.style;
65643
+ dotStyle["border-radius"] = 25 + "px";
65644
+ dotStyle.border = "solid 2px white";
65645
+ dotStyle.background = "lightgreen";
65646
+ dotStyle.position = "absolute";
65647
+ dotStyle["z-index"] = cfg.zIndex === undefined ? "40000005" : cfg.zIndex ;
65648
+ dotStyle.width = 8 + "px";
65649
+ dotStyle.height = 8 + "px";
65650
+ dotStyle.visibility = cfg.visible !== false ? "visible" : "hidden";
65651
+ dotStyle.top = 0 + "px";
65652
+ dotStyle.left = 0 + "px";
65653
+ dotStyle["box-shadow"] = "0 2px 5px 0 #182A3D;";
65654
+ dotStyle["opacity"] = 1.0;
65655
+ dotStyle["pointer-events"] = "none";
65656
+ if (cfg.onContextMenu) ;
65657
+ parentElement.appendChild(dot);
65555
65658
 
65556
- style["border-radius"] = 25 + "px";
65557
- style.border = "solid 2px white";
65558
- style.background = "lightgreen";
65559
- style.position = "absolute";
65560
- style["z-index"] = cfg.zIndex === undefined ? "40000005" : cfg.zIndex ;
65561
- style.width = 8 + "px";
65562
- style.height = 8 + "px";
65563
- style.visibility = cfg.visible !== false ? "visible" : "hidden";
65564
- style.top = 0 + "px";
65565
- style.left = 0 + "px";
65566
- style["box-shadow"] = "0 2px 5px 0 #182A3D;";
65567
- style["pointer-events"] = "none";
65568
- style["opacity"] = 1.0;
65659
+ var dotClickable = this._dotClickable;
65660
+ var dotClickableStyle = dotClickable.style;
65661
+ dotClickableStyle["border-radius"] = 35 + "px";
65662
+ dotClickableStyle.border = "solid 10px white";
65663
+ dotClickableStyle.position = "absolute";
65664
+ dotClickableStyle["z-index"] = cfg.zIndex === undefined ? "40000007" : (cfg.zIndex + 1);
65665
+ dotClickableStyle.width = 8 + "px";
65666
+ dotClickableStyle.height = 8 + "px";
65667
+ dotClickableStyle.visibility = "visible";
65668
+ dotClickableStyle.top = 0 + "px";
65669
+ dotClickableStyle.left = 0 + "px";
65670
+ dotClickableStyle["opacity"] = 0.0;
65671
+ dotClickableStyle["pointer-events"] = "all";
65672
+ if (cfg.onContextMenu) ;
65673
+ parentElement.appendChild(dotClickable);
65674
+
65675
+ if (cfg.onMouseOver) {
65676
+ dotClickable.addEventListener('mouseover', (event) => {
65677
+ cfg.onMouseOver(event, this);
65678
+ });
65679
+ }
65569
65680
 
65570
- parentElement.appendChild(dot);
65681
+ if (cfg.onMouseLeave) {
65682
+ dotClickable.addEventListener('mouseleave', (event) => {
65683
+ cfg.onMouseLeave(event, this);
65684
+ });
65685
+ }
65571
65686
 
65687
+ if (cfg.onContextMenu) {
65688
+ dotClickable.addEventListener('contextmenu', (event) => {
65689
+ cfg.onContextMenu(event, this);
65690
+ event.preventDefault();
65691
+ });
65692
+ }
65693
+
65572
65694
  this.setPos(cfg.x || 0, cfg.y || 0);
65573
65695
  this.setFillColor(cfg.fillColor);
65574
65696
  this.setBorderColor(cfg.borderColor);
65575
- this.setClickable(false);
65576
65697
  }
65577
65698
 
65578
65699
  setPos(x, y) {
65579
65700
  this._x = x;
65580
65701
  this._y = y;
65581
- var style = this._dot.style;
65582
- style["left"] = (Math.round(x) - 5) + 'px';
65583
- style["top"] = (Math.round(y) - 5) + 'px';
65702
+ var dotStyle = this._dot.style;
65703
+ dotStyle["left"] = (Math.round(x) - 4) + 'px';
65704
+ dotStyle["top"] = (Math.round(y) - 4) + 'px';
65705
+
65706
+ var dotClickableStyle = this._dotClickable.style;
65707
+ dotClickableStyle["left"] = (Math.round(x) - 9) + 'px';
65708
+ dotClickableStyle["top"] = (Math.round(y) - 9) + 'px';
65584
65709
  }
65585
65710
 
65586
65711
  setFillColor(color) {
@@ -65604,12 +65729,26 @@ class Dot {
65604
65729
  }
65605
65730
 
65606
65731
  setClickable(clickable) {
65732
+ this._dotClickable.style["pointer-events"] = (!!clickable) ? "all" : "none";
65607
65733
  this._dot.style["pointer-events"] = (!!clickable) ? "all" : "none";
65608
65734
  }
65609
65735
 
65736
+ setHighlighted(highlighted) {
65737
+ if (this._highlighted === highlighted) {
65738
+ return;
65739
+ }
65740
+ this._highlighted = !!highlighted;
65741
+ if (this._highlighted) {
65742
+ this._dot.classList.add(this._highlightClass);
65743
+ } else {
65744
+ this._dot.classList.remove(this._highlightClass);
65745
+ }
65746
+ }
65747
+
65610
65748
  destroy() {
65611
65749
  this.setVisible(false);
65612
65750
  this._dot.parentElement.removeChild(this._dot);
65751
+ this._dotClickable.parentElement.removeChild(this._dotClickable);
65613
65752
  }
65614
65753
  }
65615
65754
 
@@ -65618,10 +65757,13 @@ class Label {
65618
65757
 
65619
65758
  constructor(parentElement, cfg = {}) {
65620
65759
 
65760
+ this._highlightClass = "viewer-ruler-label-highlighted";
65761
+
65621
65762
  this._prefix = cfg.prefix || "";
65622
65763
  this._x = 0;
65623
65764
  this._y = 0;
65624
65765
  this._visible = true;
65766
+ this._culled = false;
65625
65767
 
65626
65768
  this._label = document.createElement('div');
65627
65769
  this._label.className += this._label.className ? ' viewer-ruler-label' : 'viewer-ruler-label';
@@ -65632,7 +65774,7 @@ class Label {
65632
65774
  style["border-radius"] = 5 + "px";
65633
65775
  style.color = "white";
65634
65776
  style.padding = "4px";
65635
- style.border = "solid 0px white";
65777
+ style.border = "solid 1px";
65636
65778
  style.background = "lightgreen";
65637
65779
  style.position = "absolute";
65638
65780
  style["z-index"] = cfg.zIndex === undefined ? "5000005" : cfg.zIndex;
@@ -65641,16 +65783,38 @@ class Label {
65641
65783
  style.visibility = "visible";
65642
65784
  style.top = 0 + "px";
65643
65785
  style.left = 0 + "px";
65644
- style["pointer-events"] = "none";
65786
+ style["pointer-events"] = "all";
65645
65787
  style["opacity"] = 1.0;
65788
+ if (cfg.onContextMenu) ;
65646
65789
  label.innerText = "";
65647
65790
 
65648
65791
  parentElement.appendChild(label);
65649
65792
 
65650
65793
  this.setPos(cfg.x || 0, cfg.y || 0);
65651
65794
  this.setFillColor(cfg.fillColor);
65652
- this.setBorderColor(cfg.borderColor);
65795
+ this.setBorderColor(cfg.fillColor);
65653
65796
  this.setText(cfg.text);
65797
+
65798
+ if (cfg.onMouseOver) {
65799
+ label.addEventListener('mouseover', (event) => {
65800
+ cfg.onMouseOver(event, this);
65801
+ event.preventDefault();
65802
+ });
65803
+ }
65804
+
65805
+ if (cfg.onMouseLeave) {
65806
+ label.addEventListener('mouseleave', (event) => {
65807
+ cfg.onMouseLeave(event, this);
65808
+ event.preventDefault();
65809
+ });
65810
+ }
65811
+
65812
+ if (cfg.onContextMenu) {
65813
+ label.addEventListener('contextmenu', (event) => {
65814
+ cfg.onContextMenu(event, this);
65815
+ event.preventDefault();
65816
+ });
65817
+ }
65654
65818
  }
65655
65819
 
65656
65820
  setPos(x, y) {
@@ -65682,11 +65846,13 @@ class Label {
65682
65846
  }
65683
65847
 
65684
65848
  setFillColor(color) {
65685
- this._label.style.background = color || "lightgreen";
65849
+ this._fillColor = color || "lightgreen";
65850
+ this._label.style.background =this._fillColor;
65686
65851
  }
65687
65852
 
65688
65853
  setBorderColor(color) {
65689
- this._label.style.border = "solid 2px" + (color || "black");
65854
+ this._borderColor = color || "black";
65855
+ this._label.style.border = "solid 1px " + this._borderColor;
65690
65856
  }
65691
65857
 
65692
65858
  setOpacity(opacity) {
@@ -65698,7 +65864,31 @@ class Label {
65698
65864
  return;
65699
65865
  }
65700
65866
  this._visible = !!visible;
65701
- this._label.style.visibility = this._visible ? "visible" : "hidden";
65867
+ this._label.style.visibility = this._visible && !this._culled ? "visible" : "hidden";
65868
+ }
65869
+
65870
+ setCulled(culled) {
65871
+ if (this._culled === culled) {
65872
+ return;
65873
+ }
65874
+ this._culled = !!culled;
65875
+ this._label.style.visibility = this._visible && !this._culled ? "visible" : "hidden";
65876
+ }
65877
+
65878
+ setHighlighted(highlighted) {
65879
+ if (this._highlighted === highlighted) {
65880
+ return;
65881
+ }
65882
+ this._highlighted = !!highlighted;
65883
+ if (this._highlighted) {
65884
+ this._label.classList.add(this._highlightClass);
65885
+ } else {
65886
+ this._label.classList.remove(this._highlightClass);
65887
+ }
65888
+ }
65889
+
65890
+ setClickable(clickable) {
65891
+ this._label.style["pointer-events"] = (!!clickable) ? "all" : "none";
65702
65892
  }
65703
65893
 
65704
65894
  destroy() {
@@ -65751,35 +65941,65 @@ class AngleMeasurement extends Component {
65751
65941
  this._pp = new Float64Array(12);
65752
65942
  this._cp = new Int16Array(6);
65753
65943
 
65944
+ const onMouseOver = cfg.onMouseOver ? (event) => {
65945
+ cfg.onMouseOver(event, this);
65946
+ } : null;
65947
+
65948
+ const onMouseLeave = cfg.onMouseLeave ? (event) => {
65949
+ cfg.onMouseLeave(event, this);
65950
+ } : null;
65951
+
65952
+ const onContextMenu = cfg.onContextMenu ? (event) => {
65953
+ cfg.onContextMenu(event, this);
65954
+ } : null;
65955
+
65754
65956
  this._originDot = new Dot(this._container, {
65755
65957
  fillColor: this._color,
65756
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2: undefined
65958
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2: undefined,
65959
+ onMouseOver,
65960
+ onMouseLeave,
65961
+ onContextMenu
65757
65962
  });
65758
65963
  this._cornerDot = new Dot(this._container, {
65759
65964
  fillColor: this._color,
65760
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2: undefined
65965
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2: undefined,
65966
+ onMouseOver,
65967
+ onMouseLeave,
65968
+ onContextMenu
65761
65969
  });
65762
65970
  this._targetDot = new Dot(this._container, {
65763
65971
  fillColor: this._color,
65764
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2: undefined
65972
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2: undefined,
65973
+ onMouseOver,
65974
+ onMouseLeave,
65975
+ onContextMenu
65765
65976
  });
65766
65977
 
65767
65978
  this._originWire = new Wire(this._container, {
65768
65979
  color: this._color || "blue",
65769
65980
  thickness: 1,
65770
- zIndex: plugin.zIndex
65981
+ zIndex: plugin.zIndex,
65982
+ onMouseOver,
65983
+ onMouseLeave,
65984
+ onContextMenu
65771
65985
  });
65772
65986
  this._targetWire = new Wire(this._container, {
65773
65987
  color: this._color || "red",
65774
65988
  thickness: 1,
65775
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1: undefined
65989
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1: undefined,
65990
+ onMouseOver,
65991
+ onMouseLeave,
65992
+ onContextMenu
65776
65993
  });
65777
65994
 
65778
65995
  this._angleLabel = new Label(this._container, {
65779
65996
  fillColor: this._color || "#00BBFF",
65780
65997
  prefix: "",
65781
65998
  text: "",
65782
- zIndex: plugin.zIndex + 2
65999
+ zIndex: plugin.zIndex + 2,
66000
+ onMouseOver,
66001
+ onMouseLeave,
66002
+ onContextMenu
65783
66003
  });
65784
66004
 
65785
66005
  this._wpDirty = false;
@@ -65795,6 +66015,8 @@ class AngleMeasurement extends Component {
65795
66015
  this._targetWireVisible = false;
65796
66016
 
65797
66017
  this._angleVisible = false;
66018
+ this._labelsVisible = false;
66019
+ this._clickable = true;
65798
66020
 
65799
66021
  this._originMarker.on("worldPos", (value) => {
65800
66022
  this._originWorld.set(value || [0, 0, 0]);
@@ -65840,6 +66062,7 @@ class AngleMeasurement extends Component {
65840
66062
  this.targetWireVisible = cfg.targetWireVisible;
65841
66063
 
65842
66064
  this.angleVisible = cfg.angleVisible;
66065
+ this.labelsVisible = cfg.labelsVisible;
65843
66066
  }
65844
66067
 
65845
66068
  _update() {
@@ -65899,7 +66122,7 @@ class AngleMeasurement extends Component {
65899
66122
  this._originWire.setVisible(false);
65900
66123
  this._targetWire.setVisible(false);
65901
66124
 
65902
- this._angleLabel.setVisible(false);
66125
+ this._angleLabel.setCulled(true);
65903
66126
 
65904
66127
  return;
65905
66128
  }
@@ -65963,7 +66186,7 @@ class AngleMeasurement extends Component {
65963
66186
  this._originWire.setVisible(this._visible && this._originWireVisible);
65964
66187
  this._targetWire.setVisible(this._visible && this._targetWireVisible);
65965
66188
 
65966
- this._angleLabel.setVisible(this._visible && this._angleVisible);
66189
+ this._angleLabel.setCulled(!(this._visible && this._angleVisible && this.labelsVisible));
65967
66190
 
65968
66191
  this._cpDirty = false;
65969
66192
  }
@@ -66077,6 +66300,8 @@ class AngleMeasurement extends Component {
66077
66300
  this._originWire.setVisible(this._visible && this._originWireVisible);
66078
66301
  this._targetWire.setVisible(this._visible && this._targetWireVisible);
66079
66302
  this._angleLabel.setVisible(this._visible && this._angleVisible);
66303
+ this._cpDirty = true;
66304
+ this._needUpdate();
66080
66305
  }
66081
66306
 
66082
66307
  /**
@@ -66097,6 +66322,8 @@ class AngleMeasurement extends Component {
66097
66322
  value = value !== false;
66098
66323
  this._originVisible = value;
66099
66324
  this._originDot.setVisible(this._visible && this._originVisible);
66325
+ this._cpDirty = true;
66326
+ this._needUpdate();
66100
66327
  }
66101
66328
 
66102
66329
  /**
@@ -66117,6 +66344,8 @@ class AngleMeasurement extends Component {
66117
66344
  value = value !== false;
66118
66345
  this._cornerVisible = value;
66119
66346
  this._cornerDot.setVisible(this._visible && this._cornerVisible);
66347
+ this._cpDirty = true;
66348
+ this._needUpdate();
66120
66349
  }
66121
66350
 
66122
66351
  /**
@@ -66137,6 +66366,8 @@ class AngleMeasurement extends Component {
66137
66366
  value = value !== false;
66138
66367
  this._targetVisible = value;
66139
66368
  this._targetDot.setVisible(this._visible && this._targetVisible);
66369
+ this._cpDirty = true;
66370
+ this._needUpdate();
66140
66371
  }
66141
66372
 
66142
66373
  /**
@@ -66157,6 +66388,8 @@ class AngleMeasurement extends Component {
66157
66388
  value = value !== false;
66158
66389
  this._originWireVisible = value;
66159
66390
  this._originWire.setVisible(this._visible && this._originWireVisible);
66391
+ this._cpDirty = true;
66392
+ this._needUpdate();
66160
66393
  }
66161
66394
 
66162
66395
  /**
@@ -66177,6 +66410,8 @@ class AngleMeasurement extends Component {
66177
66410
  value = value !== false;
66178
66411
  this._targetWireVisible = value;
66179
66412
  this._targetWire.setVisible(this._visible && this._targetWireVisible);
66413
+ this._cpDirty = true;
66414
+ this._needUpdate();
66180
66415
  }
66181
66416
 
66182
66417
  /**
@@ -66197,6 +66432,8 @@ class AngleMeasurement extends Component {
66197
66432
  value = value !== false;
66198
66433
  this._angleVisible = value;
66199
66434
  this._angleLabel.setVisible(this._visible && this._angleVisible);
66435
+ this._cpDirty = true;
66436
+ this._needUpdate();
66200
66437
  }
66201
66438
 
66202
66439
  /**
@@ -66208,6 +66445,67 @@ class AngleMeasurement extends Component {
66208
66445
  return this._angleVisible;
66209
66446
  }
66210
66447
 
66448
+ /**
66449
+ * Sets if the labels are visible.
66450
+ *
66451
+ * @type {Boolean}
66452
+ */
66453
+ set labelsVisible(value) {
66454
+ value = value !== undefined ? Boolean(value) : this.plugin.defaultLabelsVisible;
66455
+ this._labelsVisible = value;
66456
+ var labelsVisible = this._visible && this._labelsVisible;
66457
+ this._angleLabel.setVisible(labelsVisible);
66458
+ this._cpDirty = true;
66459
+ this._needUpdate();
66460
+ }
66461
+
66462
+ /**
66463
+ * Gets if the labels are visible.
66464
+ *
66465
+ * @type {Boolean}
66466
+ */
66467
+ get labelsVisible() {
66468
+ return this._labelsVisible;
66469
+ }
66470
+
66471
+ /**
66472
+ * Sets if this DistanceMeasurement appears highlighted.
66473
+ * @param highlighted
66474
+ */
66475
+ setHighlighted(highlighted) {
66476
+ this._originDot.setHighlighted(highlighted);
66477
+ this._cornerDot.setHighlighted(highlighted);
66478
+ this._targetDot.setHighlighted(highlighted);
66479
+ this._originWire.setHighlighted(highlighted);
66480
+ this._targetWire.setHighlighted(highlighted);
66481
+ this._angleLabel.setHighlighted(highlighted);
66482
+ }
66483
+
66484
+ /**
66485
+ * Sets if the wires, dots ad labels will fire "mouseOver" "mouseLeave" and "contextMenu" events.
66486
+ *
66487
+ * @type {Boolean}
66488
+ */
66489
+ set clickable(value) {
66490
+ value = !!value;
66491
+ this._clickable = value;
66492
+ this._originDot.setClickable(this._clickable);
66493
+ this._cornerDot.setClickable(this._clickable);
66494
+ this._targetDot.setClickable(this._clickable);
66495
+ this._originWire.setClickable(this._clickable);
66496
+ this._targetWire.setClickable(this._clickable);
66497
+ this._angleLabel.setClickable(this._clickable);
66498
+ }
66499
+
66500
+ /**
66501
+ * Gets if the wires, dots ad labels will fire "mouseOver" "mouseLeave" and "contextMenu" events.
66502
+ *
66503
+ * @type {Boolean}
66504
+ */
66505
+ get clickable() {
66506
+ return this._clickable;
66507
+ }
66508
+
66211
66509
  /**
66212
66510
  * @private
66213
66511
  */
@@ -66534,6 +66832,7 @@ class AngleMeasurementsControl extends Component {
66534
66832
  this._currentAngleMeasurement.targetWireVisible = false;
66535
66833
  this._currentAngleMeasurement.targetVisible = false;
66536
66834
  this._currentAngleMeasurement.angleVisible = false;
66835
+ this._currentAngleMeasurement.clickable = false;
66537
66836
  this._state = FINDING_CORNER;
66538
66837
  this.fire("measurementStart", this._currentAngleMeasurement);
66539
66838
  break;
@@ -66549,6 +66848,7 @@ class AngleMeasurementsControl extends Component {
66549
66848
  // this._currentAngleMeasurement.approximate = false;
66550
66849
  this._currentAngleMeasurement.targetVisible = true;
66551
66850
  this._currentAngleMeasurement.angleVisible = true;
66851
+ this._currentAngleMeasurement.clickable = true;
66552
66852
  this.fire("measurementEnd", this._currentAngleMeasurement);
66553
66853
  this._currentAngleMeasurement = null;
66554
66854
  this._state = FINDING_ORIGIN;
@@ -66774,6 +67074,85 @@ const getCanvasPosFromEvent$5 = function (event, canvasPos) {
66774
67074
  *
66775
67075
  * angleMeasurements.control.activate(); // <------------ Activate the AngleMeasurementsControl
66776
67076
  * ````
67077
+ *
67078
+ * ## Example 4: Attaching Mouse Handlers
67079
+ *
67080
+ * In our fourth example, we'll attach even handlers to our plugin, to catch when the user
67081
+ * hovers or right-clicks over our measurements.
67082
+ *
67083
+ * [[Run example](https://xeokit.github.io/xeokit-sdk/examples/#measurements_angle_modelWithMeasurements)]
67084
+ *
67085
+ * ````javascript
67086
+ * import {Viewer, XKTLoaderPlugin, AngleMeasurementsPlugin} from "xeokit-sdk.es.js";
67087
+ *
67088
+ * const viewer = new Viewer({
67089
+ * canvasId: "myCanvas",
67090
+ * transparent: true
67091
+ * });
67092
+ *
67093
+ * viewer.scene.camera.eye = [-2.37, 18.97, -26.12];
67094
+ * viewer.scene.camera.look = [10.97, 5.82, -11.22];
67095
+ * viewer.scene.camera.up = [0.36, 0.83, 0.40];
67096
+ *
67097
+ * const xktLoader = new XKTLoaderPlugin(viewer);
67098
+ *
67099
+ * const angleMeasurements = new AngleMeasurementsPlugin(viewer);
67100
+ *
67101
+ * angleMeasurements.on("mouseOver", (e) => {
67102
+ * e.measurement.setHighlighted(true);
67103
+ * });
67104
+ *
67105
+ * angleMeasurements.on("mouseLeave", (e) => {
67106
+ * e.measurement.setHighlighted(false);
67107
+ * });
67108
+ *
67109
+ * angleMeasurements.on("contextMenu", (e) => {
67110
+ * // Show context menu
67111
+ * e.event.preventDefault();
67112
+ * });
67113
+ *
67114
+ * const model = xktLoader.load({
67115
+ * src: "./models/xkt/duplex/duplex.xkt"
67116
+ * });
67117
+ *
67118
+ * model.on("loaded", () => {
67119
+ *
67120
+ * angleMeasurementsPlugin.createMeasurement({
67121
+ * id: "angleMeasurement1",
67122
+ * origin: {
67123
+ * entity: viewer.scene.objects["1CZILmCaHETO8tf3SgGEXu"],
67124
+ * worldPos: [0.4158603637281142, 2.5193106917110457, 17.79972838299403]
67125
+ * },
67126
+ * corner: {
67127
+ * entity: viewer.scene.objects["1CZILmCaHETO8tf3SgGEXu"],
67128
+ * worldPos: [0.41857741956197625,0.0987169929481646,17.799763071093395]
67129
+ * },
67130
+ * target: {
67131
+ * entity: viewer.scene.objects["1CZILmCaHETO8tf3SgGEXu"],
67132
+ * worldPos: [5.235526066859247, 0.11580773869801986, 17.824891550941565]
67133
+ * },
67134
+ * visible: true
67135
+ * });
67136
+ *
67137
+ * angleMeasurementsPlugin.createMeasurement({
67138
+ * id: "angleMeasurement2",
67139
+ * origin: {
67140
+ * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FNr2"],
67141
+ * worldPos: [-0.00003814187850181838, 5.9996748076205115,17.79996871551525]
67142
+ * },
67143
+ * corner: {
67144
+ * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FNqI"],
67145
+ * worldPos: [-0.0005214119318139865, 3.1010044228517595, 17.787656604483363]
67146
+ *
67147
+ * },
67148
+ * target: {
67149
+ * entity: viewer.scene.objects["1s1jVhK8z0pgKYcr9jt7AB"],
67150
+ * worldPos: [ 8.380657312957396, 3.1055697628459553, 17.799220108187185]
67151
+ * },
67152
+ * visible: true
67153
+ * });
67154
+ * });
67155
+ * ````
66777
67156
  */
66778
67157
  class AngleMeasurementsPlugin extends Plugin {
66779
67158
 
@@ -66784,6 +67163,7 @@ class AngleMeasurementsPlugin extends Plugin {
66784
67163
  * @param {String} [cfg.id="AngleMeasurements"] Optional ID for this plugin, so that we can find it within {@link Viewer#plugins}.
66785
67164
  * @param {HTMLElement} [cfg.container] Container DOM element for markers and labels. Defaults to ````document.body````.
66786
67165
  * @param {string} [cfg.defaultColor=null] The default color of the dots, wire and label.
67166
+ * @param {boolean} [cfg.defaultLabelsVisible=true] The default value of {@link AngleMeasurement.labelsVisible}.
66787
67167
  * @param {number} [cfg.zIndex] If set, the wires, dots and labels will have this zIndex (+1 for dots and +2 for labels).
66788
67168
  */
66789
67169
  constructor(viewer, cfg = {}) {
@@ -66796,8 +67176,33 @@ class AngleMeasurementsPlugin extends Plugin {
66796
67176
 
66797
67177
  this._measurements = {};
66798
67178
 
66799
- this.defaultColor = cfg.defaultColor;
67179
+ this.defaultColor = cfg.defaultColor !== undefined ? cfg.defaultColor : "#00BBFF";
67180
+ this.defaultLabelsVisible = cfg.defaultLabelsVisible !== false;
66800
67181
  this.zIndex = cfg.zIndex || 10000;
67182
+
67183
+ this._onMouseOver = (event, measurement) => {
67184
+ this.fire("mouseOver", {
67185
+ plugin: this,
67186
+ measurement,
67187
+ event
67188
+ });
67189
+ };
67190
+
67191
+ this._onMouseLeave = (event, measurement) => {
67192
+ this.fire("mouseLeave", {
67193
+ plugin: this,
67194
+ measurement,
67195
+ event
67196
+ });
67197
+ };
67198
+
67199
+ this._onContextMenu = (event, measurement) => {
67200
+ this.fire("contextMenu", {
67201
+ plugin: this,
67202
+ measurement,
67203
+ event
67204
+ });
67205
+ };
66801
67206
  }
66802
67207
 
66803
67208
  /**
@@ -66872,6 +67277,9 @@ class AngleMeasurementsPlugin extends Plugin {
66872
67277
  cornerVisible: true,
66873
67278
  targetWireVisible: true,
66874
67279
  targetVisible: true,
67280
+ onMouseOver: this._onMouseOver,
67281
+ onMouseLeave: this._onMouseLeave,
67282
+ onContextMenu: this._onContextMenu
66875
67283
  });
66876
67284
  this._measurements[measurement.id] = measurement;
66877
67285
  measurement.on("destroyed", () => {
@@ -66896,6 +67304,17 @@ class AngleMeasurementsPlugin extends Plugin {
66896
67304
  this.fire("measurementDestroyed", measurement);
66897
67305
  }
66898
67306
 
67307
+ /**
67308
+ * Shows all or hides the angle label of each {@link AngleMeasurement}.
67309
+ *
67310
+ * @param {Boolean} labelsShown Whether or not to show the labels.
67311
+ */
67312
+ setLabelsShown(labelsShown) {
67313
+ for (const [key, measurement] of Object.entries(this.measurements)) {
67314
+ measurement.labelShown = labelsShown;
67315
+ }
67316
+ }
67317
+
66899
67318
  /**
66900
67319
  * Destroys all {@link AngleMeasurement}s.
66901
67320
  */
@@ -74472,7 +74891,7 @@ class CustomProjection extends Component {
74472
74891
  this._inverseMatrixDirty = true;
74473
74892
  this._transposedMatrixDirty = true;
74474
74893
  this.glRedraw();
74475
- this.fire("far", this._state.matrix);
74894
+ this.fire("matrix", this._state.matrix);
74476
74895
  }
74477
74896
 
74478
74897
  /**
@@ -80595,7 +81014,7 @@ class DistanceMeasurement extends Component {
80595
81014
  this._wp = new Float64Array(24);
80596
81015
  this._vp = new Float64Array(24);
80597
81016
  this._pp = new Float64Array(24);
80598
- this._cp = new Int16Array(8);
81017
+ this._cp = new Float64Array(8);
80599
81018
 
80600
81019
  this._xAxisLabelCulled = false;
80601
81020
  this._yAxisLabelCulled = false;
@@ -80603,66 +81022,112 @@ class DistanceMeasurement extends Component {
80603
81022
 
80604
81023
  this._color = cfg.color || this.plugin.defaultColor;
80605
81024
 
81025
+ const onMouseOver = cfg.onMouseOver ? (event) => {
81026
+ cfg.onMouseOver(event, this);
81027
+ } : null;
81028
+
81029
+ const onMouseLeave = cfg.onMouseLeave ? (event) => {
81030
+ cfg.onMouseLeave(event, this);
81031
+ } : null;
81032
+
81033
+ const onContextMenu = cfg.onContextMenu ? (event) => {
81034
+ cfg.onContextMenu(event, this);
81035
+ } : null;
81036
+
80606
81037
  this._originDot = new Dot(this._container, {
80607
81038
  fillColor: this._color,
80608
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2: undefined
81039
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2 : undefined,
81040
+ onMouseOver,
81041
+ onMouseLeave,
81042
+ onContextMenu
80609
81043
  });
80610
81044
 
80611
81045
  this._targetDot = new Dot(this._container, {
80612
81046
  fillColor: this._color,
80613
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2: undefined
81047
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2 : undefined,
81048
+ onMouseOver,
81049
+ onMouseLeave,
81050
+ onContextMenu
80614
81051
  });
80615
81052
 
80616
81053
  this._lengthWire = new Wire(this._container, {
80617
81054
  color: this._color,
80618
81055
  thickness: 2,
80619
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1: undefined
81056
+ thicknessClickable: 6,
81057
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1 : undefined,
81058
+ onMouseOver,
81059
+ onMouseLeave,
81060
+ onContextMenu
80620
81061
  });
80621
81062
 
80622
81063
  this._xAxisWire = new Wire(this._container, {
80623
- color: "red",
81064
+ color: "#FF0000",
80624
81065
  thickness: 1,
80625
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1: undefined
81066
+ thicknessClickable: 6,
81067
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1 : undefined,
81068
+ onMouseOver,
81069
+ onMouseLeave,
81070
+ onContextMenu
80626
81071
  });
80627
81072
 
80628
81073
  this._yAxisWire = new Wire(this._container, {
80629
81074
  color: "green",
80630
81075
  thickness: 1,
80631
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1: undefined
81076
+ thicknessClickable: 6,
81077
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1 : undefined,
81078
+ onMouseOver,
81079
+ onMouseLeave,
81080
+ onContextMenu
80632
81081
  });
80633
81082
 
80634
81083
  this._zAxisWire = new Wire(this._container, {
80635
81084
  color: "blue",
80636
81085
  thickness: 1,
80637
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1: undefined
81086
+ thicknessClickable: 6,
81087
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1 : undefined,
81088
+ onMouseOver,
81089
+ onMouseLeave,
81090
+ onContextMenu
80638
81091
  });
80639
81092
 
80640
81093
  this._lengthLabel = new Label(this._container, {
80641
81094
  fillColor: this._color,
80642
81095
  prefix: "",
80643
81096
  text: "",
80644
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 4: undefined
81097
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 4 : undefined,
81098
+ onMouseOver,
81099
+ onMouseLeave,
81100
+ onContextMenu
80645
81101
  });
80646
81102
 
80647
81103
  this._xAxisLabel = new Label(this._container, {
80648
81104
  fillColor: "red",
80649
81105
  prefix: "X",
80650
81106
  text: "",
80651
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 3: undefined
81107
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 3 : undefined,
81108
+ onMouseOver,
81109
+ onMouseLeave,
81110
+ onContextMenu
80652
81111
  });
80653
81112
 
80654
81113
  this._yAxisLabel = new Label(this._container, {
80655
81114
  fillColor: "green",
80656
81115
  prefix: "Y",
80657
81116
  text: "",
80658
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 3: undefined
81117
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 3 : undefined,
81118
+ onMouseOver,
81119
+ onMouseLeave,
81120
+ onContextMenu
80659
81121
  });
80660
81122
 
80661
81123
  this._zAxisLabel = new Label(this._container, {
80662
81124
  fillColor: "blue",
80663
81125
  prefix: "Z",
80664
81126
  text: "",
80665
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 3: undefined
81127
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 3 : undefined,
81128
+ onMouseOver,
81129
+ onMouseLeave,
81130
+ onContextMenu
80666
81131
  });
80667
81132
 
80668
81133
  this._wpDirty = false;
@@ -80674,7 +81139,12 @@ class DistanceMeasurement extends Component {
80674
81139
  this._targetVisible = false;
80675
81140
  this._wireVisible = false;
80676
81141
  this._axisVisible = false;
81142
+ this._xAxisVisible = false;
81143
+ this._yAxisVisible = false;
81144
+ this._zAxisVisible = false;
80677
81145
  this._axisEnabled = true;
81146
+ this._labelsVisible = false;
81147
+ this._clickable = true;
80678
81148
 
80679
81149
  this._originMarker.on("worldPos", (value) => {
80680
81150
  this._originWorld.set(value || [0, 0, 0]);
@@ -80724,6 +81194,7 @@ class DistanceMeasurement extends Component {
80724
81194
  this.targetVisible = cfg.targetVisible;
80725
81195
  this.wireVisible = cfg.wireVisible;
80726
81196
  this.axisVisible = cfg.axisVisible;
81197
+ this.labelsVisible = cfg.labelsVisible;
80727
81198
  }
80728
81199
 
80729
81200
  _update() {
@@ -80833,45 +81304,57 @@ class DistanceMeasurement extends Component {
80833
81304
  this._yAxisWire.setStartAndEnd(cp[2], cp[3], cp[4], cp[5]);
80834
81305
  this._zAxisWire.setStartAndEnd(cp[4], cp[5], cp[6], cp[7]);
80835
81306
 
80836
- this._lengthLabel.setPosOnWire(cp[0], cp[1], cp[6], cp[7]);
80837
- this._xAxisLabel.setPosOnWire(cp[0], cp[1], cp[2], cp[3]);
80838
- this._yAxisLabel.setPosOnWire(cp[2], cp[3], cp[4], cp[5]);
80839
- this._zAxisLabel.setPosOnWire(cp[4], cp[5], cp[6], cp[7]);
81307
+ if (!this.labelsVisible) {
80840
81308
 
80841
- const tilde = this._approximate ? " ~ " : " = ";
81309
+ this._lengthLabel.setCulled(true);
80842
81310
 
80843
- this._length = Math.abs(math.lenVec3(math.subVec3(this._targetWorld, this._originWorld, distVec3)));
80844
- this._lengthLabel.setText(tilde + (this._length * scale).toFixed(2) + unitAbbrev);
81311
+ this._xAxisLabel.setCulled(true);
81312
+ this._yAxisLabel.setCulled(true);
81313
+ this._zAxisLabel.setCulled(true);
80845
81314
 
80846
- const xAxisCanvasLength = Math.abs(lengthWire(cp[0], cp[1], cp[2], cp[3]));
80847
- const yAxisCanvasLength = Math.abs(lengthWire(cp[2], cp[3], cp[4], cp[5]));
80848
- const zAxisCanvasLength = Math.abs(lengthWire(cp[4], cp[5], cp[6], cp[7]));
81315
+ } else {
80849
81316
 
80850
- const labelMinAxisLength = this.plugin.labelMinAxisLength;
81317
+ this._lengthLabel.setPosOnWire(cp[0], cp[1], cp[6], cp[7]);
80851
81318
 
80852
- this._xAxisLabelCulled = (xAxisCanvasLength < labelMinAxisLength);
80853
- this._yAxisLabelCulled = (yAxisCanvasLength < labelMinAxisLength);
80854
- this._zAxisLabelCulled = (zAxisCanvasLength < labelMinAxisLength);
81319
+ this._xAxisLabel.setPosOnWire(cp[0], cp[1], cp[2], cp[3]);
81320
+ this._yAxisLabel.setPosOnWire(cp[2], cp[3], cp[4], cp[5]);
81321
+ this._zAxisLabel.setPosOnWire(cp[4], cp[5], cp[6], cp[7]);
80855
81322
 
80856
- if (!this._xAxisLabelCulled) {
80857
- this._xAxisLabel.setText(tilde + Math.abs((this._targetWorld[0] - this._originWorld[0]) * scale).toFixed(2) + unitAbbrev);
80858
- this._xAxisLabel.setVisible(this.axisVisible);
80859
- } else {
80860
- this._xAxisLabel.setVisible(false);
80861
- }
81323
+ const tilde = this._approximate ? " ~ " : " = ";
80862
81324
 
80863
- if (!this._yAxisLabelCulled) {
80864
- this._yAxisLabel.setText(tilde + Math.abs((this._targetWorld[1] - this._originWorld[1]) * scale).toFixed(2) + unitAbbrev);
80865
- this._yAxisLabel.setVisible(this.axisVisible);
80866
- } else {
80867
- this._yAxisLabel.setVisible(false);
80868
- }
81325
+ this._length = Math.abs(math.lenVec3(math.subVec3(this._targetWorld, this._originWorld, distVec3)));
81326
+ this._lengthLabel.setText(tilde + (this._length * scale).toFixed(2) + unitAbbrev);
80869
81327
 
80870
- if (!this._zAxisLabelCulled) {
80871
- this._zAxisLabel.setText(tilde + Math.abs((this._targetWorld[2] - this._originWorld[2]) * scale).toFixed(2) + unitAbbrev);
80872
- this._zAxisLabel.setVisible(this.axisVisible);
80873
- } else {
80874
- this._zAxisLabel.setVisible(false);
81328
+ const xAxisCanvasLength = Math.abs(lengthWire(cp[0], cp[1], cp[2], cp[3]));
81329
+ const yAxisCanvasLength = Math.abs(lengthWire(cp[2], cp[3], cp[4], cp[5]));
81330
+ const zAxisCanvasLength = Math.abs(lengthWire(cp[4], cp[5], cp[6], cp[7]));
81331
+
81332
+ const labelMinAxisLength = this.plugin.labelMinAxisLength;
81333
+
81334
+ this._xAxisLabelCulled = (xAxisCanvasLength < labelMinAxisLength);
81335
+ this._yAxisLabelCulled = (yAxisCanvasLength < labelMinAxisLength);
81336
+ this._zAxisLabelCulled = (zAxisCanvasLength < labelMinAxisLength);
81337
+
81338
+ if (!this._xAxisLabelCulled) {
81339
+ this._xAxisLabel.setText(tilde + Math.abs((this._targetWorld[0] - this._originWorld[0]) * scale).toFixed(2) + unitAbbrev);
81340
+ this._xAxisLabel.setCulled(!this.axisVisible);
81341
+ } else {
81342
+ this._xAxisLabel.setCulled(true);
81343
+ }
81344
+
81345
+ if (!this._yAxisLabelCulled) {
81346
+ this._yAxisLabel.setText(tilde + Math.abs((this._targetWorld[1] - this._originWorld[1]) * scale).toFixed(2) + unitAbbrev);
81347
+ this._yAxisLabel.setCulled(!this.axisVisible);
81348
+ } else {
81349
+ this._yAxisLabel.setCulled(true);
81350
+ }
81351
+
81352
+ if (!this._zAxisLabelCulled) {
81353
+ this._zAxisLabel.setText(tilde + Math.abs((this._targetWorld[2] - this._originWorld[2]) * scale).toFixed(2) + unitAbbrev);
81354
+ this._zAxisLabel.setCulled(!this.axisVisible);
81355
+ } else {
81356
+ this._zAxisLabel.setCulled(true);
81357
+ }
80875
81358
  }
80876
81359
 
80877
81360
  this._originDot.setVisible(this._visible && this._originVisible);
@@ -80880,7 +81363,7 @@ class DistanceMeasurement extends Component {
80880
81363
  this._yAxisWire.setVisible(this.axisVisible);
80881
81364
  this._zAxisWire.setVisible(this.axisVisible);
80882
81365
  this._lengthWire.setVisible(this.wireVisible);
80883
- this._lengthLabel.setVisible(this.wireVisible);
81366
+ this._lengthLabel.setCulled(!this.wireVisible);
80884
81367
 
80885
81368
  this._cpDirty = false;
80886
81369
  }
@@ -80913,7 +81396,7 @@ class DistanceMeasurement extends Component {
80913
81396
  get approximate() {
80914
81397
  return this._approximate;
80915
81398
  }
80916
-
81399
+
80917
81400
  /**
80918
81401
  * Gets the origin {@link Marker}.
80919
81402
  *
@@ -80961,19 +81444,31 @@ class DistanceMeasurement extends Component {
80961
81444
  * @type {Boolean}
80962
81445
  */
80963
81446
  set visible(value) {
81447
+
80964
81448
  value = value !== undefined ? Boolean(value) : this.plugin.defaultVisible;
81449
+
80965
81450
  this._visible = value;
81451
+
80966
81452
  this._originDot.setVisible(this._visible && this._originVisible);
80967
81453
  this._targetDot.setVisible(this._visible && this._targetVisible);
80968
81454
  this._lengthWire.setVisible(this._visible && this._wireVisible);
80969
81455
  this._lengthLabel.setVisible(this._visible && this._wireVisible);
80970
- var axisVisible = this._visible && this._axisVisible;
80971
- this._xAxisWire.setVisible(axisVisible);
80972
- this._yAxisWire.setVisible(axisVisible);
80973
- this._zAxisWire.setVisible(axisVisible);
80974
- this._xAxisLabel.setVisible(axisVisible && !this._xAxisLabelCulled);
80975
- this._yAxisLabel.setVisible(axisVisible && !this._yAxisLabelCulled);
80976
- this._zAxisLabel.setVisible(axisVisible && !this._zAxisLabelCulled);
81456
+
81457
+ const xAxisVisible = this._visible && this._axisVisible && this._xAxisVisible;
81458
+ const yAxisVisible = this._visible && this._axisVisible && this._yAxisVisible;
81459
+ const zAxisVisible = this._visible && this._axisVisible && this._zAxisVisible;
81460
+
81461
+ this._xAxisWire.setVisible(xAxisVisible);
81462
+ this._yAxisWire.setVisible(yAxisVisible);
81463
+ this._zAxisWire.setVisible(zAxisVisible);
81464
+
81465
+ this._xAxisLabel.setVisible(xAxisVisible && !this._xAxisLabelCulled);
81466
+ this._yAxisLabel.setVisible(yAxisVisible && !this._yAxisLabelCulled);
81467
+ this._zAxisLabel.setVisible(zAxisVisible && !this._zAxisLabelCulled);
81468
+
81469
+ this._cpDirty = true;
81470
+
81471
+ this._needUpdate();
80977
81472
  }
80978
81473
 
80979
81474
  /**
@@ -81026,7 +81521,9 @@ class DistanceMeasurement extends Component {
81026
81521
  }
81027
81522
 
81028
81523
  /**
81029
- * Sets if the axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} are visible.
81524
+ * Sets if the axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} are enabled.
81525
+ *
81526
+ * Wires are only shown if enabled and visible.
81030
81527
  *
81031
81528
  * @type {Boolean}
81032
81529
  */
@@ -81040,20 +81537,26 @@ class DistanceMeasurement extends Component {
81040
81537
  this._xAxisLabel.setVisible(axisVisible && !this._xAxisLabelCulled);
81041
81538
  this._yAxisLabel.setVisible(axisVisible && !this._yAxisLabelCulled);
81042
81539
  this._zAxisLabel.setVisible(axisVisible && !this._zAxisLabelCulled);
81540
+ this._cpDirty = true;
81541
+ this._needUpdate();
81043
81542
  }
81044
81543
 
81045
81544
  /**
81046
- * Gets if the axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} are visible.
81545
+ * Gets if the axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} are enabled.
81546
+ *
81547
+ * Wires are only shown if enabled and visible.
81047
81548
  *
81048
81549
  * @type {Boolean}
81049
81550
  */
81050
81551
  get axisEnabled() {
81051
81552
  return this._axisEnabled;
81052
81553
  }
81053
-
81554
+
81054
81555
  /**
81055
81556
  * Sets if the axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} are visible.
81056
81557
  *
81558
+ * Wires are only shown if enabled and visible.
81559
+ *
81057
81560
  * @type {Boolean}
81058
81561
  */
81059
81562
  set axisVisible(value) {
@@ -81066,17 +81569,105 @@ class DistanceMeasurement extends Component {
81066
81569
  this._xAxisLabel.setVisible(axisVisible && !this._xAxisLabelCulled);
81067
81570
  this._yAxisLabel.setVisible(axisVisible && !this._yAxisLabelCulled);
81068
81571
  this._zAxisLabel.setVisible(axisVisible && !this._zAxisLabelCulled);
81572
+ this._cpDirty = true;
81573
+ this._needUpdate();
81069
81574
  }
81070
81575
 
81071
81576
  /**
81072
81577
  * Gets if the axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} are visible.
81073
81578
  *
81579
+ * Wires are only shown if enabled and visible.
81580
+ *
81074
81581
  * @type {Boolean}
81075
81582
  */
81076
81583
  get axisVisible() {
81077
81584
  return this._axisVisible;
81078
81585
  }
81079
81586
 
81587
+ /**
81588
+ * Sets if the X-axis-aligned wire between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} is visible.
81589
+ *
81590
+ * Wires are only shown if enabled and visible.
81591
+ *
81592
+ * @type {Boolean}
81593
+ */
81594
+ set xAxisVisible(value) {
81595
+ value = value !== undefined ? Boolean(value) : this.plugin.defaultAxisVisible;
81596
+ this._xAxisVisible = value;
81597
+ const axisVisible = this._visible && this._axisVisible && this._xAxisVisible && this._axisEnabled;
81598
+ this._xAxisWire.setVisible(axisVisible);
81599
+ this._xAxisLabel.setVisible(axisVisible && !this._xAxisLabelCulled);
81600
+ this._cpDirty = true;
81601
+ this._needUpdate();
81602
+ }
81603
+
81604
+ /**
81605
+ * Gets if the X-axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} are visible.
81606
+ *
81607
+ * Wires are only shown if enabled and visible.
81608
+ *
81609
+ * @type {Boolean}
81610
+ */
81611
+ get xAxisVisible() {
81612
+ return this._xAxisVisible;
81613
+ }
81614
+
81615
+ /**
81616
+ * Sets if the Y-axis-aligned wire between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} is visible.
81617
+ *
81618
+ * Wires are only shown if enabled and visible.
81619
+ *
81620
+ * @type {Boolean}
81621
+ */
81622
+ set yAxisVisible(value) {
81623
+ value = value !== undefined ? Boolean(value) : this.plugin.defaultAxisVisible;
81624
+ this._yAxisVisible = value;
81625
+ const axisVisible = this._visible && this._axisVisible && this._yAxisVisible && this._axisEnabled;
81626
+ this._yAxisWire.setVisible(axisVisible);
81627
+ this._yAxisLabel.setVisible(axisVisible && !this._yAxisLabelCulled);
81628
+ this._cpDirty = true;
81629
+ this._needUpdate();
81630
+ }
81631
+
81632
+ /**
81633
+ * Gets if the Y-axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} are visible.
81634
+ *
81635
+ * Wires are only shown if enabled and visible.
81636
+ *
81637
+ * @type {Boolean}
81638
+ */
81639
+ get yAxisVisible() {
81640
+ return this._yAxisVisible;
81641
+ }
81642
+
81643
+ /**
81644
+ * Sets if the Z-axis-aligned wire between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} is visible.
81645
+ *
81646
+ * Wires are only shown if enabled and visible.
81647
+ *
81648
+ * @type {Boolean}
81649
+ */
81650
+ set zAxisVisible(value) {
81651
+ value = value !== undefined ? Boolean(value) : this.plugin.defaultAxisVisible;
81652
+ this._zAxisVisible = value;
81653
+ const axisVisible = this._visible && this._axisVisible && this._zAxisVisible && this._axisEnabled;
81654
+ this._zAxisWire.setVisible(axisVisible);
81655
+ this._zAxisLabel.setVisible(axisVisible && !this._zAxisLabelCulled);
81656
+ this._cpDirty = true;
81657
+ this._needUpdate();
81658
+ }
81659
+
81660
+ /**
81661
+ * Gets if the Z-axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} are visible.
81662
+ *
81663
+ * Wires are only shown if enabled and visible.
81664
+ *
81665
+ * @type {Boolean}
81666
+ */
81667
+ get zAxisVisible() {
81668
+ return this._zAxisVisible;
81669
+ }
81670
+
81080
81671
  /**
81081
81672
  * Sets if the direct point-to-point wire between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} is visible.
81082
81673
  *
@@ -81099,6 +81690,78 @@ class DistanceMeasurement extends Component {
81099
81690
  return this._wireVisible;
81100
81691
  }
81101
81692
 
81693
+ /**
81694
+ * Sets if the labels are visible.
81695
+ *
81696
+ * @type {Boolean}
81697
+ */
81698
+ set labelsVisible(value) {
81699
+ value = value !== undefined ? Boolean(value) : this.plugin.defaultLabelsVisible;
81700
+ this._labelsVisible = value;
81701
+ var labelsVisible = this._visible && this._labelsVisible;
81702
+ this._xAxisLabel.setVisible(labelsVisible && !this._xAxisLabelCulled && this._clickable && this._axisEnabled);
81703
+ this._yAxisLabel.setVisible(labelsVisible && !this._yAxisLabelCulled && this._clickable && this._axisEnabled);
81704
+ this._zAxisLabel.setVisible(labelsVisible && !this._zAxisLabelCulled && this._clickable && this._axisEnabled);
81705
+ this._lengthLabel.setVisible(labelsVisible);
81706
+ this._cpDirty = true;
81707
+ this._needUpdate();
81708
+ }
81709
+
81710
+ /**
81711
+ * Gets if the labels are visible.
81712
+ *
81713
+ * @type {Boolean}
81714
+ */
81715
+ get labelsVisible() {
81716
+ return this._labelsVisible;
81717
+ }
81718
+
81719
+ /**
81720
+ * Sets if this DistanceMeasurement appears highlighted.
81721
+ * @param highlighted
81722
+ */
81723
+ setHighlighted(highlighted) {
81724
+ this._originDot.setHighlighted(highlighted);
81725
+ this._targetDot.setHighlighted(highlighted);
81726
+ this._xAxisWire.setHighlighted(highlighted);
81727
+ this._yAxisWire.setHighlighted(highlighted);
81728
+ this._zAxisWire.setHighlighted(highlighted);
81729
+ this._xAxisLabel.setHighlighted(highlighted);
81730
+ this._yAxisLabel.setHighlighted(highlighted);
81731
+ this._zAxisLabel.setHighlighted(highlighted);
81732
+ this._lengthWire.setHighlighted(highlighted);
81733
+ this._lengthLabel.setHighlighted(highlighted);
81734
+ }
81735
+
81736
+ /**
81737
+ * Sets if the wires, dots ad labels will fire "mouseOver" "mouseLeave" and "contextMenu" events.
81738
+ *
81739
+ * @type {Boolean}
81740
+ */
81741
+ set clickable(value) {
81742
+ value = !!value;
81743
+ this._clickable = value;
81744
+ this._originDot.setClickable(this._clickable);
81745
+ this._targetDot.setClickable(this._clickable);
81746
+ this._xAxisWire.setClickable(this._clickable);
81747
+ this._yAxisWire.setClickable(this._clickable);
81748
+ this._zAxisWire.setClickable(this._clickable);
81749
+ this._lengthWire.setClickable(this._clickable);
81750
+ this._xAxisLabel.setClickable(this._clickable);
81751
+ this._yAxisLabel.setClickable(this._clickable);
81752
+ this._zAxisLabel.setClickable(this._clickable);
81753
+ this._lengthLabel.setClickable(this._clickable);
81754
+ }
81755
+
81756
+ /**
81757
+ * Gets if the wires, dots ad labels will fire "mouseOver" "mouseLeave" and "contextMenu" events.
81758
+ *
81759
+ * @type {Boolean}
81760
+ */
81761
+ get clickable() {
81762
+ return this._clickable;
81763
+ }
81764
+
81102
81765
  /**
81103
81766
  * @private
81104
81767
  */
@@ -87033,6 +87696,9 @@ class DistanceMeasurementsControl extends Component {
87033
87696
  this._currentDistanceMeasurementByMouseInittouchState = {
87034
87697
  wireVisible: null,
87035
87698
  axisVisible: null,
87699
+ xAxisVisible: null,
87700
+ yaxisVisible: null,
87701
+ zAxisVisible: null,
87036
87702
  targetVisible: null,
87037
87703
  };
87038
87704
 
@@ -87120,6 +87786,9 @@ class DistanceMeasurementsControl extends Component {
87120
87786
  if (this._currentDistanceMeasurementByMouse) {
87121
87787
  this._currentDistanceMeasurementByMouse.wireVisible = this._currentDistanceMeasurementByMouseInittouchState.wireVisible;
87122
87788
  this._currentDistanceMeasurementByMouse.axisVisible = this._currentDistanceMeasurementByMouseInittouchState.axisVisible && this.plugin.defaultAxisVisible;
87789
+ this._currentDistanceMeasurementByMouse.xAxisVisible = this._currentDistanceMeasurementByMouseInittouchState.xAxisVisible && this.plugin.defaultXAxisVisible;
87790
+ this._currentDistanceMeasurementByMouse.yAxisVisible = this._currentDistanceMeasurementByMouseInittouchState.yAxisVisible && this.plugin.defaultYAxisVisible;
87791
+ this._currentDistanceMeasurementByMouse.zAxisVisible = this._currentDistanceMeasurementByMouseInittouchState.zAxisVisible && this.plugin.defaultZAxisVisible;
87123
87792
  this._currentDistanceMeasurementByMouse.targetVisible = this._currentDistanceMeasurementByMouseInittouchState.targetVisible;
87124
87793
  this._currentDistanceMeasurementByMouse.target.entity = mouseHoverEntity;
87125
87794
  this._currentDistanceMeasurementByMouse.target.worldPos = mouseWorldPos;
@@ -87151,7 +87820,7 @@ class DistanceMeasurementsControl extends Component {
87151
87820
  }
87152
87821
  this._currentDistanceMeasurementByMouse.approximate = false;
87153
87822
  }
87154
-
87823
+ this._currentDistanceMeasurementByMouse.clickable = true;
87155
87824
  this.fire("measurementEnd", this._currentDistanceMeasurementByMouse);
87156
87825
  this._currentDistanceMeasurementByMouse = null;
87157
87826
  } else {
@@ -87184,8 +87853,14 @@ class DistanceMeasurementsControl extends Component {
87184
87853
  approximate: true
87185
87854
  });
87186
87855
  this._currentDistanceMeasurementByMouseInittouchState.axisVisible = this._currentDistanceMeasurementByMouse.axisVisible && this.plugin.defaultAxisVisible;
87856
+
87857
+ this._currentDistanceMeasurementByMouseInittouchState.xAxisVisible = this._currentDistanceMeasurementByMouse.xAxisVisible && this.plugin.defaultXAxisVisible;
87858
+ this._currentDistanceMeasurementByMouseInittouchState.yAxisVisible = this._currentDistanceMeasurementByMouse.yAxisVisible && this.plugin.defaultYAxisVisible;
87859
+ this._currentDistanceMeasurementByMouseInittouchState.zAxisVisible = this._currentDistanceMeasurementByMouse.zAxisVisible && this.plugin.defaultZAxisVisible;
87860
+
87187
87861
  this._currentDistanceMeasurementByMouseInittouchState.wireVisible = this._currentDistanceMeasurementByMouse.wireVisible;
87188
87862
  this._currentDistanceMeasurementByMouseInittouchState.targetVisible = this._currentDistanceMeasurementByMouse.targetVisible;
87863
+ this._currentDistanceMeasurementByMouse.clickable = false;
87189
87864
  this.fire("measurementStart", this._currentDistanceMeasurementByMouse);
87190
87865
  }
87191
87866
  }
@@ -87245,7 +87920,7 @@ class DistanceMeasurementsControl extends Component {
87245
87920
  case SECOND_TOUCH_EXPECTED:
87246
87921
  startDot.setVisible(false);
87247
87922
  this._touchStartMarker.worldPos = pickResult.worldPos;
87248
- plugin.createMeasurement({
87923
+ const measurement = plugin.createMeasurement({
87249
87924
  id: math.createUUID(),
87250
87925
  origin: {
87251
87926
  entity: mouseHoverEntity,
@@ -87257,6 +87932,7 @@ class DistanceMeasurementsControl extends Component {
87257
87932
  },
87258
87933
  approximate: (!pickSurfacePrecisionEnabled)
87259
87934
  });
87935
+ measurement.clickable = true;
87260
87936
  touchState = FIRST_TOUCH_EXPECTED;
87261
87937
  break;
87262
87938
  }
@@ -87358,7 +88034,7 @@ const getCanvasPosFromEvent = function (event, canvasPos) {
87358
88034
  *
87359
88035
  * * [[Example 1: Model with distance measurements](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_modelWithMeasurements)]
87360
88036
  * * [[Example 2: Create distance measurements with mouse](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_createWithMouse)]
87361
- * * [[Example 3: Configuring units and scale](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_unitsAndScale)]
88037
+ * * [[Example 3: Configuring units and scale](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_unitsAndScale)
87362
88038
  *
87363
88039
  * ## Overview
87364
88040
  *
@@ -87481,6 +88157,78 @@ const getCanvasPosFromEvent = function (event, canvasPos) {
87481
88157
  * metrics.units = "meters";
87482
88158
  * metrics.scale = 10.0;
87483
88159
  * ````
88160
+ *
88161
+ * ## Example 4: Attaching Mouse Handlers
88162
+ *
88163
+ * In our fourth example, we'll attach even handlers to our plugin, to catch when the user
88164
+ * hovers or right-clicks over our measurements.
88165
+ *
88166
+ * [[Run example](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_modelWithMeasurements)]
88167
+ *
88168
+ * ````javascript
88169
+ * import {Viewer, XKTLoaderPlugin, DistanceMeasurementsPlugin} from "xeokit-sdk.es.js";
88170
+ *
88171
+ * const viewer = new Viewer({
88172
+ * canvasId: "myCanvas",
88173
+ * transparent: true
88174
+ * });
88175
+ *
88176
+ * viewer.scene.camera.eye = [-2.37, 18.97, -26.12];
88177
+ * viewer.scene.camera.look = [10.97, 5.82, -11.22];
88178
+ * viewer.scene.camera.up = [0.36, 0.83, 0.40];
88179
+ *
88180
+ * const xktLoader = new XKTLoaderPlugin(viewer);
88181
+ *
88182
+ * const distanceMeasurements = new DistanceMeasurementsPlugin(viewer);
88183
+ *
88184
+ * distanceMeasurements.on("mouseOver", (e) => {
88185
+ * e.measurement.setHighlighted(true);
88186
+ * });
88187
+ *
88188
+ * distanceMeasurements.on("mouseLeave", (e) => {
88189
+ * e.measurement.setHighlighted(false);
88190
+ * });
88191
+ *
88192
+ * distanceMeasurements.on("contextMenu", (e) => {
88193
+ * // Show context menu
88194
+ * e.event.preventDefault();
88195
+ * });
88196
+ *
88197
+ * const model = xktLoader.load({
88198
+ * src: "./models/xkt/duplex/duplex.xkt"
88199
+ * });
88200
+ *
88201
+ * model.on("loaded", () => {
88202
+ *
88203
+ * const myMeasurement1 = distanceMeasurements.createMeasurement({
88204
+ * id: "distanceMeasurement1",
88205
+ * origin: {
88206
+ * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FLOH"],
88207
+ * worldPos: [0.044, 5.998, 17.767]
88208
+ * },
88209
+ * target: {
88210
+ * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FLOH"],
88211
+ * worldPos: [4.738, 3.172, 17.768]
88212
+ * },
88213
+ * visible: true,
88214
+ * wireVisible: true
88215
+ * });
88216
+ *
88217
+ * const myMeasurement2 = distanceMeasurements.createMeasurement({
88218
+ * id: "distanceMeasurement2",
88219
+ * origin: {
88220
+ * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FNr2"],
88221
+ * worldPos: [0.457, 2.532, 17.766]
88222
+ * },
88223
+ * target: {
88224
+ * entity: viewer.scene.objects["1CZILmCaHETO8tf3SgGEXu"],
88225
+ * worldPos: [0.436, 0.001, 22.135]
88226
+ * },
88227
+ * visible: true,
88228
+ * wireVisible: true
88229
+ * });
88230
+ * });
88231
+ * ````
87484
88232
  */
87485
88233
  class DistanceMeasurementsPlugin extends Plugin {
87486
88234
 
@@ -87495,10 +88243,14 @@ class DistanceMeasurementsPlugin extends Plugin {
87495
88243
  * @param {boolean} [cfg.defaultOriginVisible=true] The default value of the DistanceMeasurements `originVisible` property.
87496
88244
  * @param {boolean} [cfg.defaultTargetVisible=true] The default value of the DistanceMeasurements `targetVisible` property.
87497
88245
  * @param {boolean} [cfg.defaultWireVisible=true] The default value of the DistanceMeasurements `wireVisible` property.
88246
+ * @param {boolean} [cfg.defaultLabelsVisible=true] The default value of the DistanceMeasurements `labelsVisible` property.
87498
88247
  * @param {boolean} [cfg.defaultAxisVisible=true] The default value of the DistanceMeasurements `axisVisible` property.
87499
- * @param {boolean} [cfg.defaultAxisEnabled=true] The default value of the DistanceMeasurements `axisVisible` property.
88248
+ * @param {boolean} [cfg.defaultXAxisVisible=true] The default value of the DistanceMeasurements `xAxisVisible` property.
88249
+ * @param {boolean} [cfg.defaultYAxisVisible=true] The default value of the DistanceMeasurements `yAxisVisible` property.
88250
+ * @param {boolean} [cfg.defaultZAxisVisible=true] The default value of the DistanceMeasurements `zAxisVisible` property.
87500
88251
  * @param {string} [cfg.defaultColor=#00BBFF] The default color of the length dots, wire and label.
87501
88252
  * @param {number} [cfg.zIndex] If set, the wires, dots and labels will have this zIndex (+1 for dots and +2 for labels).
88253
+ *
87502
88254
  */
87503
88255
  constructor(viewer, cfg = {}) {
87504
88256
 
@@ -87516,9 +88268,37 @@ class DistanceMeasurementsPlugin extends Plugin {
87516
88268
  this.defaultOriginVisible = cfg.defaultOriginVisible !== false;
87517
88269
  this.defaultTargetVisible = cfg.defaultTargetVisible !== false;
87518
88270
  this.defaultWireVisible = cfg.defaultWireVisible !== false;
88271
+ this.defaultLabelsVisible = cfg.defaultLabelsVisible !== false;
87519
88272
  this.defaultAxisVisible = cfg.defaultAxisVisible !== false;
88273
+ this.defaultXAxisVisible = cfg.defaultXAxisVisible !== false;
88274
+ this.defaultYAxisVisible = cfg.defaultYAxisVisible !== false;
88275
+ this.defaultZAxisVisible = cfg.defaultZAxisVisible !== false;
87520
88276
  this.defaultColor = cfg.defaultColor !== undefined ? cfg.defaultColor : "#00BBFF";
87521
88277
  this.zIndex = cfg.zIndex || 10000;
88278
+
88279
+ this._onMouseOver = (event, measurement) => {
88280
+ this.fire("mouseOver", {
88281
+ plugin: this,
88282
+ measurement,
88283
+ event
88284
+ });
88285
+ };
88286
+
88287
+ this._onMouseLeave = (event, measurement) => {
88288
+ this.fire("mouseLeave", {
88289
+ plugin: this,
88290
+ measurement,
88291
+ event
88292
+ });
88293
+ };
88294
+
88295
+ this._onContextMenu = (event, measurement) => {
88296
+ this.fire("contextMenu", {
88297
+ plugin: this,
88298
+ measurement,
88299
+ event
88300
+ });
88301
+ };
87522
88302
  }
87523
88303
 
87524
88304
  /**
@@ -87589,6 +88369,10 @@ class DistanceMeasurementsPlugin extends Plugin {
87589
88369
  * @param {Boolean} [params.targetVisible=true] Whether to initially show the {@link DistanceMeasurement} target.
87590
88370
  * @param {Boolean} [params.wireVisible=true] Whether to initially show the direct point-to-point wire between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
87591
88371
  * @param {Boolean} [params.axisVisible=true] Whether to initially show the axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
88372
+ * @param {Boolean} [params.xAxisVisible=true] Whether to initially show the X-axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
88373
+ * @param {Boolean} [params.yAxisVisible=true] Whether to initially show the Y-axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
88374
+ * @param {Boolean} [params.zAxisVisible=true] Whether to initially show the Z-axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
88375
+ * @param {Boolean} [params.labelsVisible=true] Whether to initially show the labels.
87592
88376
  * @param {string} [params.color] The color of the length dot, wire and label.
87593
88377
  * @returns {DistanceMeasurement} The new {@link DistanceMeasurement}.
87594
88378
  */
@@ -87614,9 +88398,16 @@ class DistanceMeasurementsPlugin extends Plugin {
87614
88398
  visible: params.visible,
87615
88399
  wireVisible: params.wireVisible,
87616
88400
  axisVisible: params.axisVisible !== false && this.defaultAxisVisible !== false,
88401
+ xAxisVisible: params.xAxisVisible !== false && this.defaultXAxisVisible !== false,
88402
+ yAxisVisible: params.yAxisVisible !== false && this.defaultYAxisVisible !== false,
88403
+ zAxisVisible: params.zAxisVisible !== false && this.defaultZAxisVisible !== false,
88404
+ labelsVisible: params.labelsVisible !== false && this.defaultLabelsVisible !== false,
87617
88405
  originVisible: params.originVisible,
87618
88406
  targetVisible: params.targetVisible,
87619
- color: params.color
88407
+ color: params.color,
88408
+ onMouseOver: this._onMouseOver,
88409
+ onMouseLeave: this._onMouseLeave,
88410
+ onContextMenu: this._onContextMenu
87620
88411
  });
87621
88412
  this._measurements[measurement.id] = measurement;
87622
88413
  measurement.on("destroyed", () => {
@@ -87641,6 +88432,18 @@ class DistanceMeasurementsPlugin extends Plugin {
87641
88432
  this.fire("measurementDestroyed", measurement);
87642
88433
  }
87643
88434
 
88435
+ /**
88436
+ * Shows all or hides the angle label of each {@link DistanceMeasurement}.
88437
+ *
88438
+ * @param {Boolean} labelsShown Whether or not to show the labels.
88439
+ */
88440
+ setLabelsShown(labelsShown) {
88441
+ for (const [key, measurement] of Object.entries(this.measurements)) {
88442
+ measurement.labelShown = labelsShown;
88443
+ }
88444
+ }
88445
+
88446
+
87644
88447
  /**
87645
88448
  * Destroys all {@link DistanceMeasurement}s.
87646
88449
  */
@@ -102787,6 +103590,7 @@ class ModelTreeView {
102787
103590
  numEntities: 0,
102788
103591
  numVisibleEntities: 0,
102789
103592
  checked: false,
103593
+ xrayed: false,
102790
103594
  children: []
102791
103595
  };
102792
103596
  this._rootNodes.push(buildingNode);
@@ -102805,6 +103609,7 @@ class ModelTreeView {
102805
103609
  numEntities: 0,
102806
103610
  numVisibleEntities: 0,
102807
103611
  checked: false,
103612
+ xrayed: false,
102808
103613
  children: []
102809
103614
  };
102810
103615
  buildingNode.children.push(storeyNode);
@@ -102829,6 +103634,7 @@ class ModelTreeView {
102829
103634
  numEntities: 0,
102830
103635
  numVisibleEntities: 0,
102831
103636
  checked: false,
103637
+ xrayed: false,
102832
103638
  children: []
102833
103639
  };
102834
103640
  storeyNode.children.push(typeNode);
@@ -102844,6 +103650,7 @@ class ModelTreeView {
102844
103650
  numEntities: 0,
102845
103651
  numVisibleEntities: 0,
102846
103652
  checked: false,
103653
+ xrayed: false,
102847
103654
  children: []
102848
103655
  };
102849
103656
  typeNode.children.push(node);
@@ -102877,6 +103684,7 @@ class ModelTreeView {
102877
103684
  numEntities: 0,
102878
103685
  numVisibleEntities: 0,
102879
103686
  checked: false,
103687
+ xrayed: false,
102880
103688
  children: []
102881
103689
  };
102882
103690
  this._rootNodes.push(rootNode);
@@ -102898,6 +103706,7 @@ class ModelTreeView {
102898
103706
  numEntities: 0,
102899
103707
  numVisibleEntities: 0,
102900
103708
  checked: false,
103709
+ xrayed: false,
102901
103710
  children: []
102902
103711
  };
102903
103712
  rootNode.children.push(typeNode);
@@ -102913,6 +103722,7 @@ class ModelTreeView {
102913
103722
  numEntities: 0,
102914
103723
  numVisibleEntities: 0,
102915
103724
  checked: false,
103725
+ xrayed: false,
102916
103726
  children: []
102917
103727
  };
102918
103728
  typeNode.children.push(node);
@@ -102945,6 +103755,7 @@ class ModelTreeView {
102945
103755
  numEntities: 0,
102946
103756
  numVisibleEntities: 0,
102947
103757
  checked: false,
103758
+ xrayed: false,
102948
103759
  children: []
102949
103760
  };
102950
103761
  if (parent) {
@@ -163207,16 +164018,17 @@ class WebIFCLoaderPlugin extends Plugin {
163207
164018
  ctx.stats.numPropertySets++;
163208
164019
  const relatedObjects = rel.RelatedObjects;
163209
164020
  if (!relatedObjects || relatedObjects.length === 0) {
163210
- for (let i = 0, len = relatedObjects.length; i < len; i++) {
163211
- const relatedObject = relatedObjects[i];
163212
- const metaObjectId = relatedObject.GlobalId.value;
163213
- const metaObject = ctx.metaObjects[metaObjectId];
163214
- if (metaObject) {
163215
- if (!metaObject.propertySetIds) {
163216
- metaObject.propertySetIds = [];
163217
- }
163218
- metaObject.propertySetIds.push(propertySetId);
164021
+ return;
164022
+ }
164023
+ for (let i = 0, len = relatedObjects.length; i < len; i++) {
164024
+ const relatedObject = relatedObjects[i];
164025
+ const metaObjectId = relatedObject.GlobalId.value;
164026
+ const metaObject = ctx.metaObjects[metaObjectId];
164027
+ if (metaObject) {
164028
+ if (!metaObject.propertySetIds) {
164029
+ metaObject.propertySetIds = [];
163219
164030
  }
164031
+ metaObject.propertySetIds.push(propertySetId);
163220
164032
  }
163221
164033
  }
163222
164034
  }
@@ -163623,7 +164435,7 @@ class LASLoaderPlugin extends Plugin {
163623
164435
  * @param {Number|String} value Valid values are 8, 16 and "auto".
163624
164436
  */
163625
164437
  set colorDepth(value) {
163626
- this._colorDepth = !!value;
164438
+ this._colorDepth = value || "auto";
163627
164439
  }
163628
164440
 
163629
164441
  /**
@@ -163659,9 +164471,11 @@ class LASLoaderPlugin extends Plugin {
163659
164471
  }
163660
164472
 
163661
164473
  const options = {
163662
- skip: this._skip,
163663
- fp64: this._fp64,
163664
- colorDepth: this._colorDepth
164474
+ las: {
164475
+ skip: this._skip,
164476
+ fp64: this._fp64,
164477
+ colorDepth: this._colorDepth
164478
+ }
163665
164479
  };
163666
164480
 
163667
164481
  if (params.src) {
@@ -163776,10 +164590,10 @@ class LASLoaderPlugin extends Plugin {
163776
164590
  reject("No positions found in file");
163777
164591
  return;
163778
164592
  }
163779
-
164593
+
163780
164594
  let positionsValue;
163781
164595
  let colorsCompressed;
163782
-
164596
+
163783
164597
  switch (pointsFormatId) {
163784
164598
  case 0:
163785
164599
  positionsValue = readPositions(attributes.POSITION);