@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.
@@ -750,9 +750,7 @@ class ContextMenu {
750
750
 
751
751
  item.itemElement.addEventListener("mouseenter", (event) => {
752
752
  event.preventDefault();
753
- if (item.enabled === false) {
754
- return;
755
- }
753
+
756
754
  const subMenu = item.subMenu;
757
755
  if (!subMenu) {
758
756
  if (lastSubMenu) {
@@ -766,6 +764,10 @@ class ContextMenu {
766
764
  lastSubMenu = null;
767
765
  }
768
766
 
767
+ if (item.enabled === false) {
768
+ return;
769
+ }
770
+
769
771
  const itemElement = item.itemElement;
770
772
  const subMenuElement = subMenu.menuElement;
771
773
 
@@ -12642,7 +12644,7 @@ function buildBoxGeometry(cfg = {}) {
12642
12644
  * xSize: 1, // Half-size on each axis
12643
12645
  * ySize: 1,
12644
12646
  * zSize: 1
12645
- * }),
12647
+ * })),
12646
12648
  * material: new PhongMaterial(viewer.scene, {
12647
12649
  * emissive: [0,1,0]
12648
12650
  * })
@@ -65453,37 +65455,91 @@ class Wire {
65453
65455
 
65454
65456
  constructor(parentElement, cfg = {}) {
65455
65457
 
65458
+ this._color = cfg.color || "black";
65459
+ this._highlightClass = "viewer-ruler-wire-highlighted";
65460
+
65456
65461
  this._wire = document.createElement('div');
65457
65462
  this._wire.className += this._wire.className ? ' viewer-ruler-wire' : 'viewer-ruler-wire';
65458
65463
 
65459
- var wire = this._wire;
65460
- var style = wire.style;
65464
+ this._wireClickable = document.createElement('div');
65465
+ this._wireClickable.className += this._wireClickable.className ? ' viewer-ruler-wire-clickable' : 'viewer-ruler-wire-clickable';
65461
65466
 
65462
65467
  this._thickness = cfg.thickness || 1.0;
65468
+ this._thicknessClickable = cfg.thicknessClickable || 6.0;
65463
65469
 
65464
- style.border = "solid " + this._thickness + "px " + (cfg.color || "black");
65465
- style.position = "absolute";
65466
- style["z-index"] = cfg.zIndex === undefined ? "2000001" : cfg.zIndex ;
65467
- style.width = 0 + "px";
65468
- style.height = 0 + "px";
65469
- style.visibility = "visible";
65470
- style.top = 0 + "px";
65471
- style.left = 0 + "px";
65472
- style["pointer-events"] = "none";
65473
- style['-webkit-transform-origin'] = "0 0";
65474
- style['-moz-transform-origin'] = "0 0";
65475
- style['-ms-transform-origin'] = "0 0";
65476
- style['-o-transform-origin'] = "0 0";
65477
- style['transform-origin'] = "0 0";
65478
- style['-webkit-transform'] = 'rotate(0deg)';
65479
- style['-moz-transform'] = 'rotate(0deg)';
65480
- style['-ms-transform'] = 'rotate(0deg)';
65481
- style['-o-transform'] = 'rotate(0deg)';
65482
- style['transform'] = 'rotate(0deg)';
65483
- style["opacity"] = 1.0;
65470
+ var wire = this._wire;
65471
+ var wireStyle = wire.style;
65472
+
65473
+ wireStyle.border = "solid " + this._thickness + "px " + this._color;
65474
+ wireStyle.position = "absolute";
65475
+ wireStyle["z-index"] = cfg.zIndex === undefined ? "2000001" : cfg.zIndex;
65476
+ wireStyle.width = 0 + "px";
65477
+ wireStyle.height = 0 + "px";
65478
+ wireStyle.visibility = "visible";
65479
+ wireStyle.top = 0 + "px";
65480
+ wireStyle.left = 0 + "px";
65481
+ wireStyle['-webkit-transform-origin'] = "0 0";
65482
+ wireStyle['-moz-transform-origin'] = "0 0";
65483
+ wireStyle['-ms-transform-origin'] = "0 0";
65484
+ wireStyle['-o-transform-origin'] = "0 0";
65485
+ wireStyle['transform-origin'] = "0 0";
65486
+ wireStyle['-webkit-transform'] = 'rotate(0deg)';
65487
+ wireStyle['-moz-transform'] = 'rotate(0deg)';
65488
+ wireStyle['-ms-transform'] = 'rotate(0deg)';
65489
+ wireStyle['-o-transform'] = 'rotate(0deg)';
65490
+ wireStyle['transform'] = 'rotate(0deg)';
65491
+ wireStyle["opacity"] = 1.0;
65492
+ if (cfg.onContextMenu) ;
65484
65493
 
65485
65494
  parentElement.appendChild(wire);
65486
65495
 
65496
+ var wireClickable = this._wireClickable;
65497
+ var wireClickableStyle = wireClickable.style;
65498
+
65499
+ wireClickableStyle.border = "solid " + this._thicknessClickable + "px " + this._color;
65500
+ wireClickableStyle.position = "absolute";
65501
+ wireClickableStyle["z-index"] = cfg.zIndex === undefined ? "2000002" : (cfg.zIndex + 1);
65502
+ wireClickableStyle.width = 0 + "px";
65503
+ wireClickableStyle.height = 0 + "px";
65504
+ wireClickableStyle.visibility = "visible";
65505
+ wireClickableStyle.top = 0 + "px";
65506
+ wireClickableStyle.left = 0 + "px";
65507
+ // wireClickableStyle["pointer-events"] = "none";
65508
+ wireClickableStyle['-webkit-transform-origin'] = "0 0";
65509
+ wireClickableStyle['-moz-transform-origin'] = "0 0";
65510
+ wireClickableStyle['-ms-transform-origin'] = "0 0";
65511
+ wireClickableStyle['-o-transform-origin'] = "0 0";
65512
+ wireClickableStyle['transform-origin'] = "0 0";
65513
+ wireClickableStyle['-webkit-transform'] = 'rotate(0deg)';
65514
+ wireClickableStyle['-moz-transform'] = 'rotate(0deg)';
65515
+ wireClickableStyle['-ms-transform'] = 'rotate(0deg)';
65516
+ wireClickableStyle['-o-transform'] = 'rotate(0deg)';
65517
+ wireClickableStyle['transform'] = 'rotate(0deg)';
65518
+ wireClickableStyle["opacity"] = 0.0;
65519
+ wireClickableStyle["pointer-events"] = "all";
65520
+ if (cfg.onContextMenu) ;
65521
+
65522
+ parentElement.appendChild(wireClickable);
65523
+
65524
+ if (cfg.onMouseOver) {
65525
+ wireClickable.addEventListener('mouseover', (event) => {
65526
+ cfg.onMouseOver(event, this);
65527
+ });
65528
+ }
65529
+
65530
+ if (cfg.onMouseLeave) {
65531
+ wireClickable.addEventListener('mouseleave', (event) => {
65532
+ cfg.onMouseLeave(event, this);
65533
+ });
65534
+ }
65535
+
65536
+ if (cfg.onContextMenu) {
65537
+ wireClickable.addEventListener('contextmenu', (event) => {
65538
+ cfg.onContextMenu(event, this);
65539
+ event.preventDefault();
65540
+ });
65541
+ }
65542
+
65487
65543
  this._x1 = 0;
65488
65544
  this._y1 = 0;
65489
65545
  this._x2 = 0;
@@ -65501,16 +65557,25 @@ class Wire {
65501
65557
  var length = Math.abs(Math.sqrt((this._x1 - this._x2) * (this._x1 - this._x2) + (this._y1 - this._y2) * (this._y1 - this._y2)));
65502
65558
  var angle = Math.atan2(this._y2 - this._y1, this._x2 - this._x1) * 180.0 / Math.PI;
65503
65559
 
65504
- var style = this._wire.style;
65505
- style["width"] = Math.round(length) + 'px';
65506
- style["left"] = Math.round(this._x1) + 'px';
65507
- style["top"] = Math.round(this._y1) + 'px';
65508
- style['-webkit-transform'] = 'rotate(' + angle + 'deg)';
65509
- style['-moz-transform'] = 'rotate(' + angle + 'deg)';
65510
- style['-ms-transform'] = 'rotate(' + angle + 'deg)';
65511
- style['-o-transform'] = 'rotate(' + angle + 'deg)';
65512
- style['transform'] = 'rotate(' + angle + 'deg)';
65513
- style["pointer-events"] = "none";
65560
+ var wireStyle = this._wire.style;
65561
+ wireStyle["width"] = Math.round(length) + 'px';
65562
+ wireStyle["left"] = Math.round(this._x1) + 'px';
65563
+ wireStyle["top"] = Math.round(this._y1) + 'px';
65564
+ wireStyle['-webkit-transform'] = 'rotate(' + angle + 'deg)';
65565
+ wireStyle['-moz-transform'] = 'rotate(' + angle + 'deg)';
65566
+ wireStyle['-ms-transform'] = 'rotate(' + angle + 'deg)';
65567
+ wireStyle['-o-transform'] = 'rotate(' + angle + 'deg)';
65568
+ wireStyle['transform'] = 'rotate(' + angle + 'deg)';
65569
+
65570
+ var wireClickableStyle = this._wireClickable.style;
65571
+ wireClickableStyle["width"] = Math.round(length) + 'px';
65572
+ wireClickableStyle["left"] = Math.round(this._x1) + 'px';
65573
+ wireClickableStyle["top"] = Math.round(this._y1) + 'px';
65574
+ wireClickableStyle['-webkit-transform'] = 'rotate(' + angle + 'deg)';
65575
+ wireClickableStyle['-moz-transform'] = 'rotate(' + angle + 'deg)';
65576
+ wireClickableStyle['-ms-transform'] = 'rotate(' + angle + 'deg)';
65577
+ wireClickableStyle['-o-transform'] = 'rotate(' + angle + 'deg)';
65578
+ wireClickableStyle['transform'] = 'rotate(' + angle + 'deg)';
65514
65579
  }
65515
65580
 
65516
65581
  setStartAndEnd(x1, y1, x2, y2) {
@@ -65522,7 +65587,8 @@ class Wire {
65522
65587
  }
65523
65588
 
65524
65589
  setColor(color) {
65525
- this._wire.style.border = "solid " + this._thickness + "px " + (color || "black");
65590
+ this._color = color || "black";
65591
+ this._wire.style.border = "solid " + this._thickness + "px " + this._color;
65526
65592
  }
65527
65593
 
65528
65594
  setOpacity(opacity) {
@@ -65537,8 +65603,25 @@ class Wire {
65537
65603
  this._wire.style.visibility = visible ? "visible" : "hidden";
65538
65604
  }
65539
65605
 
65606
+ setClickable(clickable) {
65607
+ this._wireClickable.style["pointer-events"] = (!!clickable) ? "all" : "none";
65608
+ }
65609
+
65610
+ setHighlighted(highlighted) {
65611
+ if (this._highlighted === highlighted) {
65612
+ return;
65613
+ }
65614
+ this._highlighted = !!highlighted;
65615
+ if (this._highlighted) {
65616
+ this._wire.classList.add(this._highlightClass);
65617
+ } else {
65618
+ this._wire.classList.remove(this._highlightClass);
65619
+ }
65620
+ }
65621
+
65540
65622
  destroy(visible) {
65541
65623
  this._wire.parentElement.removeChild(this._wire);
65624
+ this._wireClickable.parentElement.removeChild(this._wireClickable);
65542
65625
  }
65543
65626
  }
65544
65627
 
@@ -65547,6 +65630,8 @@ class Dot {
65547
65630
 
65548
65631
  constructor(parentElement, cfg = {}) {
65549
65632
 
65633
+ this._highlightClass = "viewer-ruler-dot-highlighted";
65634
+
65550
65635
  this._x = 0;
65551
65636
  this._y = 0;
65552
65637
 
@@ -65554,37 +65639,77 @@ class Dot {
65554
65639
  this._dot = document.createElement('div');
65555
65640
  this._dot.className += this._dot.className ? ' viewer-ruler-dot' : 'viewer-ruler-dot';
65556
65641
 
65642
+ this._dotClickable = document.createElement('div');
65643
+ this._dotClickable.className += this._dotClickable.className ? ' viewer-ruler-dot-clickable' : 'viewer-ruler-dot-clickable';
65644
+
65557
65645
  var dot = this._dot;
65558
- var style = dot.style;
65646
+ var dotStyle = dot.style;
65647
+ dotStyle["border-radius"] = 25 + "px";
65648
+ dotStyle.border = "solid 2px white";
65649
+ dotStyle.background = "lightgreen";
65650
+ dotStyle.position = "absolute";
65651
+ dotStyle["z-index"] = cfg.zIndex === undefined ? "40000005" : cfg.zIndex ;
65652
+ dotStyle.width = 8 + "px";
65653
+ dotStyle.height = 8 + "px";
65654
+ dotStyle.visibility = cfg.visible !== false ? "visible" : "hidden";
65655
+ dotStyle.top = 0 + "px";
65656
+ dotStyle.left = 0 + "px";
65657
+ dotStyle["box-shadow"] = "0 2px 5px 0 #182A3D;";
65658
+ dotStyle["opacity"] = 1.0;
65659
+ dotStyle["pointer-events"] = "none";
65660
+ if (cfg.onContextMenu) ;
65661
+ parentElement.appendChild(dot);
65559
65662
 
65560
- style["border-radius"] = 25 + "px";
65561
- style.border = "solid 2px white";
65562
- style.background = "lightgreen";
65563
- style.position = "absolute";
65564
- style["z-index"] = cfg.zIndex === undefined ? "40000005" : cfg.zIndex ;
65565
- style.width = 8 + "px";
65566
- style.height = 8 + "px";
65567
- style.visibility = cfg.visible !== false ? "visible" : "hidden";
65568
- style.top = 0 + "px";
65569
- style.left = 0 + "px";
65570
- style["box-shadow"] = "0 2px 5px 0 #182A3D;";
65571
- style["pointer-events"] = "none";
65572
- style["opacity"] = 1.0;
65663
+ var dotClickable = this._dotClickable;
65664
+ var dotClickableStyle = dotClickable.style;
65665
+ dotClickableStyle["border-radius"] = 35 + "px";
65666
+ dotClickableStyle.border = "solid 10px white";
65667
+ dotClickableStyle.position = "absolute";
65668
+ dotClickableStyle["z-index"] = cfg.zIndex === undefined ? "40000007" : (cfg.zIndex + 1);
65669
+ dotClickableStyle.width = 8 + "px";
65670
+ dotClickableStyle.height = 8 + "px";
65671
+ dotClickableStyle.visibility = "visible";
65672
+ dotClickableStyle.top = 0 + "px";
65673
+ dotClickableStyle.left = 0 + "px";
65674
+ dotClickableStyle["opacity"] = 0.0;
65675
+ dotClickableStyle["pointer-events"] = "all";
65676
+ if (cfg.onContextMenu) ;
65677
+ parentElement.appendChild(dotClickable);
65678
+
65679
+ if (cfg.onMouseOver) {
65680
+ dotClickable.addEventListener('mouseover', (event) => {
65681
+ cfg.onMouseOver(event, this);
65682
+ });
65683
+ }
65573
65684
 
65574
- parentElement.appendChild(dot);
65685
+ if (cfg.onMouseLeave) {
65686
+ dotClickable.addEventListener('mouseleave', (event) => {
65687
+ cfg.onMouseLeave(event, this);
65688
+ });
65689
+ }
65575
65690
 
65691
+ if (cfg.onContextMenu) {
65692
+ dotClickable.addEventListener('contextmenu', (event) => {
65693
+ cfg.onContextMenu(event, this);
65694
+ event.preventDefault();
65695
+ });
65696
+ }
65697
+
65576
65698
  this.setPos(cfg.x || 0, cfg.y || 0);
65577
65699
  this.setFillColor(cfg.fillColor);
65578
65700
  this.setBorderColor(cfg.borderColor);
65579
- this.setClickable(false);
65580
65701
  }
65581
65702
 
65582
65703
  setPos(x, y) {
65583
65704
  this._x = x;
65584
65705
  this._y = y;
65585
- var style = this._dot.style;
65586
- style["left"] = (Math.round(x) - 5) + 'px';
65587
- style["top"] = (Math.round(y) - 5) + 'px';
65706
+ var dotStyle = this._dot.style;
65707
+ dotStyle["left"] = (Math.round(x) - 4) + 'px';
65708
+ dotStyle["top"] = (Math.round(y) - 4) + 'px';
65709
+
65710
+ var dotClickableStyle = this._dotClickable.style;
65711
+ dotClickableStyle["left"] = (Math.round(x) - 9) + 'px';
65712
+ dotClickableStyle["top"] = (Math.round(y) - 9) + 'px';
65588
65713
  }
65589
65714
 
65590
65715
  setFillColor(color) {
@@ -65608,12 +65733,26 @@ class Dot {
65608
65733
  }
65609
65734
 
65610
65735
  setClickable(clickable) {
65736
+ this._dotClickable.style["pointer-events"] = (!!clickable) ? "all" : "none";
65611
65737
  this._dot.style["pointer-events"] = (!!clickable) ? "all" : "none";
65612
65738
  }
65613
65739
 
65740
+ setHighlighted(highlighted) {
65741
+ if (this._highlighted === highlighted) {
65742
+ return;
65743
+ }
65744
+ this._highlighted = !!highlighted;
65745
+ if (this._highlighted) {
65746
+ this._dot.classList.add(this._highlightClass);
65747
+ } else {
65748
+ this._dot.classList.remove(this._highlightClass);
65749
+ }
65750
+ }
65751
+
65614
65752
  destroy() {
65615
65753
  this.setVisible(false);
65616
65754
  this._dot.parentElement.removeChild(this._dot);
65755
+ this._dotClickable.parentElement.removeChild(this._dotClickable);
65617
65756
  }
65618
65757
  }
65619
65758
 
@@ -65622,10 +65761,13 @@ class Label {
65622
65761
 
65623
65762
  constructor(parentElement, cfg = {}) {
65624
65763
 
65764
+ this._highlightClass = "viewer-ruler-label-highlighted";
65765
+
65625
65766
  this._prefix = cfg.prefix || "";
65626
65767
  this._x = 0;
65627
65768
  this._y = 0;
65628
65769
  this._visible = true;
65770
+ this._culled = false;
65629
65771
 
65630
65772
  this._label = document.createElement('div');
65631
65773
  this._label.className += this._label.className ? ' viewer-ruler-label' : 'viewer-ruler-label';
@@ -65636,7 +65778,7 @@ class Label {
65636
65778
  style["border-radius"] = 5 + "px";
65637
65779
  style.color = "white";
65638
65780
  style.padding = "4px";
65639
- style.border = "solid 0px white";
65781
+ style.border = "solid 1px";
65640
65782
  style.background = "lightgreen";
65641
65783
  style.position = "absolute";
65642
65784
  style["z-index"] = cfg.zIndex === undefined ? "5000005" : cfg.zIndex;
@@ -65645,16 +65787,38 @@ class Label {
65645
65787
  style.visibility = "visible";
65646
65788
  style.top = 0 + "px";
65647
65789
  style.left = 0 + "px";
65648
- style["pointer-events"] = "none";
65790
+ style["pointer-events"] = "all";
65649
65791
  style["opacity"] = 1.0;
65792
+ if (cfg.onContextMenu) ;
65650
65793
  label.innerText = "";
65651
65794
 
65652
65795
  parentElement.appendChild(label);
65653
65796
 
65654
65797
  this.setPos(cfg.x || 0, cfg.y || 0);
65655
65798
  this.setFillColor(cfg.fillColor);
65656
- this.setBorderColor(cfg.borderColor);
65799
+ this.setBorderColor(cfg.fillColor);
65657
65800
  this.setText(cfg.text);
65801
+
65802
+ if (cfg.onMouseOver) {
65803
+ label.addEventListener('mouseover', (event) => {
65804
+ cfg.onMouseOver(event, this);
65805
+ event.preventDefault();
65806
+ });
65807
+ }
65808
+
65809
+ if (cfg.onMouseLeave) {
65810
+ label.addEventListener('mouseleave', (event) => {
65811
+ cfg.onMouseLeave(event, this);
65812
+ event.preventDefault();
65813
+ });
65814
+ }
65815
+
65816
+ if (cfg.onContextMenu) {
65817
+ label.addEventListener('contextmenu', (event) => {
65818
+ cfg.onContextMenu(event, this);
65819
+ event.preventDefault();
65820
+ });
65821
+ }
65658
65822
  }
65659
65823
 
65660
65824
  setPos(x, y) {
@@ -65686,11 +65850,13 @@ class Label {
65686
65850
  }
65687
65851
 
65688
65852
  setFillColor(color) {
65689
- this._label.style.background = color || "lightgreen";
65853
+ this._fillColor = color || "lightgreen";
65854
+ this._label.style.background =this._fillColor;
65690
65855
  }
65691
65856
 
65692
65857
  setBorderColor(color) {
65693
- this._label.style.border = "solid 2px" + (color || "black");
65858
+ this._borderColor = color || "black";
65859
+ this._label.style.border = "solid 1px " + this._borderColor;
65694
65860
  }
65695
65861
 
65696
65862
  setOpacity(opacity) {
@@ -65702,7 +65868,31 @@ class Label {
65702
65868
  return;
65703
65869
  }
65704
65870
  this._visible = !!visible;
65705
- this._label.style.visibility = this._visible ? "visible" : "hidden";
65871
+ this._label.style.visibility = this._visible && !this._culled ? "visible" : "hidden";
65872
+ }
65873
+
65874
+ setCulled(culled) {
65875
+ if (this._culled === culled) {
65876
+ return;
65877
+ }
65878
+ this._culled = !!culled;
65879
+ this._label.style.visibility = this._visible && !this._culled ? "visible" : "hidden";
65880
+ }
65881
+
65882
+ setHighlighted(highlighted) {
65883
+ if (this._highlighted === highlighted) {
65884
+ return;
65885
+ }
65886
+ this._highlighted = !!highlighted;
65887
+ if (this._highlighted) {
65888
+ this._label.classList.add(this._highlightClass);
65889
+ } else {
65890
+ this._label.classList.remove(this._highlightClass);
65891
+ }
65892
+ }
65893
+
65894
+ setClickable(clickable) {
65895
+ this._label.style["pointer-events"] = (!!clickable) ? "all" : "none";
65706
65896
  }
65707
65897
 
65708
65898
  destroy() {
@@ -65755,35 +65945,65 @@ class AngleMeasurement extends Component {
65755
65945
  this._pp = new Float64Array(12);
65756
65946
  this._cp = new Int16Array(6);
65757
65947
 
65948
+ const onMouseOver = cfg.onMouseOver ? (event) => {
65949
+ cfg.onMouseOver(event, this);
65950
+ } : null;
65951
+
65952
+ const onMouseLeave = cfg.onMouseLeave ? (event) => {
65953
+ cfg.onMouseLeave(event, this);
65954
+ } : null;
65955
+
65956
+ const onContextMenu = cfg.onContextMenu ? (event) => {
65957
+ cfg.onContextMenu(event, this);
65958
+ } : null;
65959
+
65758
65960
  this._originDot = new Dot(this._container, {
65759
65961
  fillColor: this._color,
65760
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2: undefined
65962
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2: undefined,
65963
+ onMouseOver,
65964
+ onMouseLeave,
65965
+ onContextMenu
65761
65966
  });
65762
65967
  this._cornerDot = new Dot(this._container, {
65763
65968
  fillColor: this._color,
65764
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2: undefined
65969
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2: undefined,
65970
+ onMouseOver,
65971
+ onMouseLeave,
65972
+ onContextMenu
65765
65973
  });
65766
65974
  this._targetDot = new Dot(this._container, {
65767
65975
  fillColor: this._color,
65768
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2: undefined
65976
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2: undefined,
65977
+ onMouseOver,
65978
+ onMouseLeave,
65979
+ onContextMenu
65769
65980
  });
65770
65981
 
65771
65982
  this._originWire = new Wire(this._container, {
65772
65983
  color: this._color || "blue",
65773
65984
  thickness: 1,
65774
- zIndex: plugin.zIndex
65985
+ zIndex: plugin.zIndex,
65986
+ onMouseOver,
65987
+ onMouseLeave,
65988
+ onContextMenu
65775
65989
  });
65776
65990
  this._targetWire = new Wire(this._container, {
65777
65991
  color: this._color || "red",
65778
65992
  thickness: 1,
65779
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1: undefined
65993
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1: undefined,
65994
+ onMouseOver,
65995
+ onMouseLeave,
65996
+ onContextMenu
65780
65997
  });
65781
65998
 
65782
65999
  this._angleLabel = new Label(this._container, {
65783
66000
  fillColor: this._color || "#00BBFF",
65784
66001
  prefix: "",
65785
66002
  text: "",
65786
- zIndex: plugin.zIndex + 2
66003
+ zIndex: plugin.zIndex + 2,
66004
+ onMouseOver,
66005
+ onMouseLeave,
66006
+ onContextMenu
65787
66007
  });
65788
66008
 
65789
66009
  this._wpDirty = false;
@@ -65799,6 +66019,8 @@ class AngleMeasurement extends Component {
65799
66019
  this._targetWireVisible = false;
65800
66020
 
65801
66021
  this._angleVisible = false;
66022
+ this._labelsVisible = false;
66023
+ this._clickable = true;
65802
66024
 
65803
66025
  this._originMarker.on("worldPos", (value) => {
65804
66026
  this._originWorld.set(value || [0, 0, 0]);
@@ -65844,6 +66066,7 @@ class AngleMeasurement extends Component {
65844
66066
  this.targetWireVisible = cfg.targetWireVisible;
65845
66067
 
65846
66068
  this.angleVisible = cfg.angleVisible;
66069
+ this.labelsVisible = cfg.labelsVisible;
65847
66070
  }
65848
66071
 
65849
66072
  _update() {
@@ -65903,7 +66126,7 @@ class AngleMeasurement extends Component {
65903
66126
  this._originWire.setVisible(false);
65904
66127
  this._targetWire.setVisible(false);
65905
66128
 
65906
- this._angleLabel.setVisible(false);
66129
+ this._angleLabel.setCulled(true);
65907
66130
 
65908
66131
  return;
65909
66132
  }
@@ -65967,7 +66190,7 @@ class AngleMeasurement extends Component {
65967
66190
  this._originWire.setVisible(this._visible && this._originWireVisible);
65968
66191
  this._targetWire.setVisible(this._visible && this._targetWireVisible);
65969
66192
 
65970
- this._angleLabel.setVisible(this._visible && this._angleVisible);
66193
+ this._angleLabel.setCulled(!(this._visible && this._angleVisible && this.labelsVisible));
65971
66194
 
65972
66195
  this._cpDirty = false;
65973
66196
  }
@@ -66081,6 +66304,8 @@ class AngleMeasurement extends Component {
66081
66304
  this._originWire.setVisible(this._visible && this._originWireVisible);
66082
66305
  this._targetWire.setVisible(this._visible && this._targetWireVisible);
66083
66306
  this._angleLabel.setVisible(this._visible && this._angleVisible);
66307
+ this._cpDirty = true;
66308
+ this._needUpdate();
66084
66309
  }
66085
66310
 
66086
66311
  /**
@@ -66101,6 +66326,8 @@ class AngleMeasurement extends Component {
66101
66326
  value = value !== false;
66102
66327
  this._originVisible = value;
66103
66328
  this._originDot.setVisible(this._visible && this._originVisible);
66329
+ this._cpDirty = true;
66330
+ this._needUpdate();
66104
66331
  }
66105
66332
 
66106
66333
  /**
@@ -66121,6 +66348,8 @@ class AngleMeasurement extends Component {
66121
66348
  value = value !== false;
66122
66349
  this._cornerVisible = value;
66123
66350
  this._cornerDot.setVisible(this._visible && this._cornerVisible);
66351
+ this._cpDirty = true;
66352
+ this._needUpdate();
66124
66353
  }
66125
66354
 
66126
66355
  /**
@@ -66141,6 +66370,8 @@ class AngleMeasurement extends Component {
66141
66370
  value = value !== false;
66142
66371
  this._targetVisible = value;
66143
66372
  this._targetDot.setVisible(this._visible && this._targetVisible);
66373
+ this._cpDirty = true;
66374
+ this._needUpdate();
66144
66375
  }
66145
66376
 
66146
66377
  /**
@@ -66161,6 +66392,8 @@ class AngleMeasurement extends Component {
66161
66392
  value = value !== false;
66162
66393
  this._originWireVisible = value;
66163
66394
  this._originWire.setVisible(this._visible && this._originWireVisible);
66395
+ this._cpDirty = true;
66396
+ this._needUpdate();
66164
66397
  }
66165
66398
 
66166
66399
  /**
@@ -66181,6 +66414,8 @@ class AngleMeasurement extends Component {
66181
66414
  value = value !== false;
66182
66415
  this._targetWireVisible = value;
66183
66416
  this._targetWire.setVisible(this._visible && this._targetWireVisible);
66417
+ this._cpDirty = true;
66418
+ this._needUpdate();
66184
66419
  }
66185
66420
 
66186
66421
  /**
@@ -66201,6 +66436,8 @@ class AngleMeasurement extends Component {
66201
66436
  value = value !== false;
66202
66437
  this._angleVisible = value;
66203
66438
  this._angleLabel.setVisible(this._visible && this._angleVisible);
66439
+ this._cpDirty = true;
66440
+ this._needUpdate();
66204
66441
  }
66205
66442
 
66206
66443
  /**
@@ -66212,6 +66449,67 @@ class AngleMeasurement extends Component {
66212
66449
  return this._angleVisible;
66213
66450
  }
66214
66451
 
66452
+ /**
66453
+ * Sets if the labels are visible.
66454
+ *
66455
+ * @type {Boolean}
66456
+ */
66457
+ set labelsVisible(value) {
66458
+ value = value !== undefined ? Boolean(value) : this.plugin.defaultLabelsVisible;
66459
+ this._labelsVisible = value;
66460
+ var labelsVisible = this._visible && this._labelsVisible;
66461
+ this._angleLabel.setVisible(labelsVisible);
66462
+ this._cpDirty = true;
66463
+ this._needUpdate();
66464
+ }
66465
+
66466
+ /**
66467
+ * Gets if the labels are visible.
66468
+ *
66469
+ * @type {Boolean}
66470
+ */
66471
+ get labelsVisible() {
66472
+ return this._labelsVisible;
66473
+ }
66474
+
66475
+ /**
66476
+ * Sets if this DistanceMeasurement appears highlighted.
66477
+ * @param highlighted
66478
+ */
66479
+ setHighlighted(highlighted) {
66480
+ this._originDot.setHighlighted(highlighted);
66481
+ this._cornerDot.setHighlighted(highlighted);
66482
+ this._targetDot.setHighlighted(highlighted);
66483
+ this._originWire.setHighlighted(highlighted);
66484
+ this._targetWire.setHighlighted(highlighted);
66485
+ this._angleLabel.setHighlighted(highlighted);
66486
+ }
66487
+
66488
+ /**
66489
+ * Sets if the wires, dots ad labels will fire "mouseOver" "mouseLeave" and "contextMenu" events.
66490
+ *
66491
+ * @type {Boolean}
66492
+ */
66493
+ set clickable(value) {
66494
+ value = !!value;
66495
+ this._clickable = value;
66496
+ this._originDot.setClickable(this._clickable);
66497
+ this._cornerDot.setClickable(this._clickable);
66498
+ this._targetDot.setClickable(this._clickable);
66499
+ this._originWire.setClickable(this._clickable);
66500
+ this._targetWire.setClickable(this._clickable);
66501
+ this._angleLabel.setClickable(this._clickable);
66502
+ }
66503
+
66504
+ /**
66505
+ * Gets if the wires, dots ad labels will fire "mouseOver" "mouseLeave" and "contextMenu" events.
66506
+ *
66507
+ * @type {Boolean}
66508
+ */
66509
+ get clickable() {
66510
+ return this._clickable;
66511
+ }
66512
+
66215
66513
  /**
66216
66514
  * @private
66217
66515
  */
@@ -66538,6 +66836,7 @@ class AngleMeasurementsControl extends Component {
66538
66836
  this._currentAngleMeasurement.targetWireVisible = false;
66539
66837
  this._currentAngleMeasurement.targetVisible = false;
66540
66838
  this._currentAngleMeasurement.angleVisible = false;
66839
+ this._currentAngleMeasurement.clickable = false;
66541
66840
  this._state = FINDING_CORNER;
66542
66841
  this.fire("measurementStart", this._currentAngleMeasurement);
66543
66842
  break;
@@ -66553,6 +66852,7 @@ class AngleMeasurementsControl extends Component {
66553
66852
  // this._currentAngleMeasurement.approximate = false;
66554
66853
  this._currentAngleMeasurement.targetVisible = true;
66555
66854
  this._currentAngleMeasurement.angleVisible = true;
66855
+ this._currentAngleMeasurement.clickable = true;
66556
66856
  this.fire("measurementEnd", this._currentAngleMeasurement);
66557
66857
  this._currentAngleMeasurement = null;
66558
66858
  this._state = FINDING_ORIGIN;
@@ -66778,6 +67078,85 @@ const getCanvasPosFromEvent$5 = function (event, canvasPos) {
66778
67078
  *
66779
67079
  * angleMeasurements.control.activate(); // <------------ Activate the AngleMeasurementsControl
66780
67080
  * ````
67081
+ *
67082
+ * ## Example 4: Attaching Mouse Handlers
67083
+ *
67084
+ * In our fourth example, we'll attach even handlers to our plugin, to catch when the user
67085
+ * hovers or right-clicks over our measurements.
67086
+ *
67087
+ * [[Run example](https://xeokit.github.io/xeokit-sdk/examples/#measurements_angle_modelWithMeasurements)]
67088
+ *
67089
+ * ````javascript
67090
+ * import {Viewer, XKTLoaderPlugin, AngleMeasurementsPlugin} from "xeokit-sdk.es.js";
67091
+ *
67092
+ * const viewer = new Viewer({
67093
+ * canvasId: "myCanvas",
67094
+ * transparent: true
67095
+ * });
67096
+ *
67097
+ * viewer.scene.camera.eye = [-2.37, 18.97, -26.12];
67098
+ * viewer.scene.camera.look = [10.97, 5.82, -11.22];
67099
+ * viewer.scene.camera.up = [0.36, 0.83, 0.40];
67100
+ *
67101
+ * const xktLoader = new XKTLoaderPlugin(viewer);
67102
+ *
67103
+ * const angleMeasurements = new AngleMeasurementsPlugin(viewer);
67104
+ *
67105
+ * angleMeasurements.on("mouseOver", (e) => {
67106
+ * e.measurement.setHighlighted(true);
67107
+ * });
67108
+ *
67109
+ * angleMeasurements.on("mouseLeave", (e) => {
67110
+ * e.measurement.setHighlighted(false);
67111
+ * });
67112
+ *
67113
+ * angleMeasurements.on("contextMenu", (e) => {
67114
+ * // Show context menu
67115
+ * e.event.preventDefault();
67116
+ * });
67117
+ *
67118
+ * const model = xktLoader.load({
67119
+ * src: "./models/xkt/duplex/duplex.xkt"
67120
+ * });
67121
+ *
67122
+ * model.on("loaded", () => {
67123
+ *
67124
+ * angleMeasurementsPlugin.createMeasurement({
67125
+ * id: "angleMeasurement1",
67126
+ * origin: {
67127
+ * entity: viewer.scene.objects["1CZILmCaHETO8tf3SgGEXu"],
67128
+ * worldPos: [0.4158603637281142, 2.5193106917110457, 17.79972838299403]
67129
+ * },
67130
+ * corner: {
67131
+ * entity: viewer.scene.objects["1CZILmCaHETO8tf3SgGEXu"],
67132
+ * worldPos: [0.41857741956197625,0.0987169929481646,17.799763071093395]
67133
+ * },
67134
+ * target: {
67135
+ * entity: viewer.scene.objects["1CZILmCaHETO8tf3SgGEXu"],
67136
+ * worldPos: [5.235526066859247, 0.11580773869801986, 17.824891550941565]
67137
+ * },
67138
+ * visible: true
67139
+ * });
67140
+ *
67141
+ * angleMeasurementsPlugin.createMeasurement({
67142
+ * id: "angleMeasurement2",
67143
+ * origin: {
67144
+ * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FNr2"],
67145
+ * worldPos: [-0.00003814187850181838, 5.9996748076205115,17.79996871551525]
67146
+ * },
67147
+ * corner: {
67148
+ * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FNqI"],
67149
+ * worldPos: [-0.0005214119318139865, 3.1010044228517595, 17.787656604483363]
67150
+ *
67151
+ * },
67152
+ * target: {
67153
+ * entity: viewer.scene.objects["1s1jVhK8z0pgKYcr9jt7AB"],
67154
+ * worldPos: [ 8.380657312957396, 3.1055697628459553, 17.799220108187185]
67155
+ * },
67156
+ * visible: true
67157
+ * });
67158
+ * });
67159
+ * ````
66781
67160
  */
66782
67161
  class AngleMeasurementsPlugin extends Plugin {
66783
67162
 
@@ -66788,6 +67167,7 @@ class AngleMeasurementsPlugin extends Plugin {
66788
67167
  * @param {String} [cfg.id="AngleMeasurements"] Optional ID for this plugin, so that we can find it within {@link Viewer#plugins}.
66789
67168
  * @param {HTMLElement} [cfg.container] Container DOM element for markers and labels. Defaults to ````document.body````.
66790
67169
  * @param {string} [cfg.defaultColor=null] The default color of the dots, wire and label.
67170
+ * @param {boolean} [cfg.defaultLabelsVisible=true] The default value of {@link AngleMeasurement.labelsVisible}.
66791
67171
  * @param {number} [cfg.zIndex] If set, the wires, dots and labels will have this zIndex (+1 for dots and +2 for labels).
66792
67172
  */
66793
67173
  constructor(viewer, cfg = {}) {
@@ -66800,8 +67180,33 @@ class AngleMeasurementsPlugin extends Plugin {
66800
67180
 
66801
67181
  this._measurements = {};
66802
67182
 
66803
- this.defaultColor = cfg.defaultColor;
67183
+ this.defaultColor = cfg.defaultColor !== undefined ? cfg.defaultColor : "#00BBFF";
67184
+ this.defaultLabelsVisible = cfg.defaultLabelsVisible !== false;
66804
67185
  this.zIndex = cfg.zIndex || 10000;
67186
+
67187
+ this._onMouseOver = (event, measurement) => {
67188
+ this.fire("mouseOver", {
67189
+ plugin: this,
67190
+ measurement,
67191
+ event
67192
+ });
67193
+ };
67194
+
67195
+ this._onMouseLeave = (event, measurement) => {
67196
+ this.fire("mouseLeave", {
67197
+ plugin: this,
67198
+ measurement,
67199
+ event
67200
+ });
67201
+ };
67202
+
67203
+ this._onContextMenu = (event, measurement) => {
67204
+ this.fire("contextMenu", {
67205
+ plugin: this,
67206
+ measurement,
67207
+ event
67208
+ });
67209
+ };
66805
67210
  }
66806
67211
 
66807
67212
  /**
@@ -66876,6 +67281,9 @@ class AngleMeasurementsPlugin extends Plugin {
66876
67281
  cornerVisible: true,
66877
67282
  targetWireVisible: true,
66878
67283
  targetVisible: true,
67284
+ onMouseOver: this._onMouseOver,
67285
+ onMouseLeave: this._onMouseLeave,
67286
+ onContextMenu: this._onContextMenu
66879
67287
  });
66880
67288
  this._measurements[measurement.id] = measurement;
66881
67289
  measurement.on("destroyed", () => {
@@ -66900,6 +67308,17 @@ class AngleMeasurementsPlugin extends Plugin {
66900
67308
  this.fire("measurementDestroyed", measurement);
66901
67309
  }
66902
67310
 
67311
+ /**
67312
+ * Shows all or hides the angle label of each {@link AngleMeasurement}.
67313
+ *
67314
+ * @param {Boolean} labelsShown Whether or not to show the labels.
67315
+ */
67316
+ setLabelsShown(labelsShown) {
67317
+ for (const [key, measurement] of Object.entries(this.measurements)) {
67318
+ measurement.labelShown = labelsShown;
67319
+ }
67320
+ }
67321
+
66903
67322
  /**
66904
67323
  * Destroys all {@link AngleMeasurement}s.
66905
67324
  */
@@ -74476,7 +74895,7 @@ class CustomProjection extends Component {
74476
74895
  this._inverseMatrixDirty = true;
74477
74896
  this._transposedMatrixDirty = true;
74478
74897
  this.glRedraw();
74479
- this.fire("far", this._state.matrix);
74898
+ this.fire("matrix", this._state.matrix);
74480
74899
  }
74481
74900
 
74482
74901
  /**
@@ -80599,7 +81018,7 @@ class DistanceMeasurement extends Component {
80599
81018
  this._wp = new Float64Array(24);
80600
81019
  this._vp = new Float64Array(24);
80601
81020
  this._pp = new Float64Array(24);
80602
- this._cp = new Int16Array(8);
81021
+ this._cp = new Float64Array(8);
80603
81022
 
80604
81023
  this._xAxisLabelCulled = false;
80605
81024
  this._yAxisLabelCulled = false;
@@ -80607,66 +81026,112 @@ class DistanceMeasurement extends Component {
80607
81026
 
80608
81027
  this._color = cfg.color || this.plugin.defaultColor;
80609
81028
 
81029
+ const onMouseOver = cfg.onMouseOver ? (event) => {
81030
+ cfg.onMouseOver(event, this);
81031
+ } : null;
81032
+
81033
+ const onMouseLeave = cfg.onMouseLeave ? (event) => {
81034
+ cfg.onMouseLeave(event, this);
81035
+ } : null;
81036
+
81037
+ const onContextMenu = cfg.onContextMenu ? (event) => {
81038
+ cfg.onContextMenu(event, this);
81039
+ } : null;
81040
+
80610
81041
  this._originDot = new Dot(this._container, {
80611
81042
  fillColor: this._color,
80612
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2: undefined
81043
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2 : undefined,
81044
+ onMouseOver,
81045
+ onMouseLeave,
81046
+ onContextMenu
80613
81047
  });
80614
81048
 
80615
81049
  this._targetDot = new Dot(this._container, {
80616
81050
  fillColor: this._color,
80617
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2: undefined
81051
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2 : undefined,
81052
+ onMouseOver,
81053
+ onMouseLeave,
81054
+ onContextMenu
80618
81055
  });
80619
81056
 
80620
81057
  this._lengthWire = new Wire(this._container, {
80621
81058
  color: this._color,
80622
81059
  thickness: 2,
80623
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1: undefined
81060
+ thicknessClickable: 6,
81061
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1 : undefined,
81062
+ onMouseOver,
81063
+ onMouseLeave,
81064
+ onContextMenu
80624
81065
  });
80625
81066
 
80626
81067
  this._xAxisWire = new Wire(this._container, {
80627
- color: "red",
81068
+ color: "#FF0000",
80628
81069
  thickness: 1,
80629
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1: undefined
81070
+ thicknessClickable: 6,
81071
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1 : undefined,
81072
+ onMouseOver,
81073
+ onMouseLeave,
81074
+ onContextMenu
80630
81075
  });
80631
81076
 
80632
81077
  this._yAxisWire = new Wire(this._container, {
80633
81078
  color: "green",
80634
81079
  thickness: 1,
80635
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1: undefined
81080
+ thicknessClickable: 6,
81081
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1 : undefined,
81082
+ onMouseOver,
81083
+ onMouseLeave,
81084
+ onContextMenu
80636
81085
  });
80637
81086
 
80638
81087
  this._zAxisWire = new Wire(this._container, {
80639
81088
  color: "blue",
80640
81089
  thickness: 1,
80641
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1: undefined
81090
+ thicknessClickable: 6,
81091
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1 : undefined,
81092
+ onMouseOver,
81093
+ onMouseLeave,
81094
+ onContextMenu
80642
81095
  });
80643
81096
 
80644
81097
  this._lengthLabel = new Label(this._container, {
80645
81098
  fillColor: this._color,
80646
81099
  prefix: "",
80647
81100
  text: "",
80648
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 4: undefined
81101
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 4 : undefined,
81102
+ onMouseOver,
81103
+ onMouseLeave,
81104
+ onContextMenu
80649
81105
  });
80650
81106
 
80651
81107
  this._xAxisLabel = new Label(this._container, {
80652
81108
  fillColor: "red",
80653
81109
  prefix: "X",
80654
81110
  text: "",
80655
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 3: undefined
81111
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 3 : undefined,
81112
+ onMouseOver,
81113
+ onMouseLeave,
81114
+ onContextMenu
80656
81115
  });
80657
81116
 
80658
81117
  this._yAxisLabel = new Label(this._container, {
80659
81118
  fillColor: "green",
80660
81119
  prefix: "Y",
80661
81120
  text: "",
80662
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 3: undefined
81121
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 3 : undefined,
81122
+ onMouseOver,
81123
+ onMouseLeave,
81124
+ onContextMenu
80663
81125
  });
80664
81126
 
80665
81127
  this._zAxisLabel = new Label(this._container, {
80666
81128
  fillColor: "blue",
80667
81129
  prefix: "Z",
80668
81130
  text: "",
80669
- zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 3: undefined
81131
+ zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 3 : undefined,
81132
+ onMouseOver,
81133
+ onMouseLeave,
81134
+ onContextMenu
80670
81135
  });
80671
81136
 
80672
81137
  this._wpDirty = false;
@@ -80678,7 +81143,12 @@ class DistanceMeasurement extends Component {
80678
81143
  this._targetVisible = false;
80679
81144
  this._wireVisible = false;
80680
81145
  this._axisVisible = false;
81146
+ this._xAxisVisible = false;
81147
+ this._yAxisVisible = false;
81148
+ this._zAxisVisible = false;
80681
81149
  this._axisEnabled = true;
81150
+ this._labelsVisible = false;
81151
+ this._clickable = true;
80682
81152
 
80683
81153
  this._originMarker.on("worldPos", (value) => {
80684
81154
  this._originWorld.set(value || [0, 0, 0]);
@@ -80728,6 +81198,7 @@ class DistanceMeasurement extends Component {
80728
81198
  this.targetVisible = cfg.targetVisible;
80729
81199
  this.wireVisible = cfg.wireVisible;
80730
81200
  this.axisVisible = cfg.axisVisible;
81201
+ this.labelsVisible = cfg.labelsVisible;
80731
81202
  }
80732
81203
 
80733
81204
  _update() {
@@ -80837,45 +81308,57 @@ class DistanceMeasurement extends Component {
80837
81308
  this._yAxisWire.setStartAndEnd(cp[2], cp[3], cp[4], cp[5]);
80838
81309
  this._zAxisWire.setStartAndEnd(cp[4], cp[5], cp[6], cp[7]);
80839
81310
 
80840
- this._lengthLabel.setPosOnWire(cp[0], cp[1], cp[6], cp[7]);
80841
- this._xAxisLabel.setPosOnWire(cp[0], cp[1], cp[2], cp[3]);
80842
- this._yAxisLabel.setPosOnWire(cp[2], cp[3], cp[4], cp[5]);
80843
- this._zAxisLabel.setPosOnWire(cp[4], cp[5], cp[6], cp[7]);
81311
+ if (!this.labelsVisible) {
80844
81312
 
80845
- const tilde = this._approximate ? " ~ " : " = ";
81313
+ this._lengthLabel.setCulled(true);
80846
81314
 
80847
- this._length = Math.abs(math.lenVec3(math.subVec3(this._targetWorld, this._originWorld, distVec3)));
80848
- this._lengthLabel.setText(tilde + (this._length * scale).toFixed(2) + unitAbbrev);
81315
+ this._xAxisLabel.setCulled(true);
81316
+ this._yAxisLabel.setCulled(true);
81317
+ this._zAxisLabel.setCulled(true);
80849
81318
 
80850
- const xAxisCanvasLength = Math.abs(lengthWire(cp[0], cp[1], cp[2], cp[3]));
80851
- const yAxisCanvasLength = Math.abs(lengthWire(cp[2], cp[3], cp[4], cp[5]));
80852
- const zAxisCanvasLength = Math.abs(lengthWire(cp[4], cp[5], cp[6], cp[7]));
81319
+ } else {
80853
81320
 
80854
- const labelMinAxisLength = this.plugin.labelMinAxisLength;
81321
+ this._lengthLabel.setPosOnWire(cp[0], cp[1], cp[6], cp[7]);
80855
81322
 
80856
- this._xAxisLabelCulled = (xAxisCanvasLength < labelMinAxisLength);
80857
- this._yAxisLabelCulled = (yAxisCanvasLength < labelMinAxisLength);
80858
- this._zAxisLabelCulled = (zAxisCanvasLength < labelMinAxisLength);
81323
+ this._xAxisLabel.setPosOnWire(cp[0], cp[1], cp[2], cp[3]);
81324
+ this._yAxisLabel.setPosOnWire(cp[2], cp[3], cp[4], cp[5]);
81325
+ this._zAxisLabel.setPosOnWire(cp[4], cp[5], cp[6], cp[7]);
80859
81326
 
80860
- if (!this._xAxisLabelCulled) {
80861
- this._xAxisLabel.setText(tilde + Math.abs((this._targetWorld[0] - this._originWorld[0]) * scale).toFixed(2) + unitAbbrev);
80862
- this._xAxisLabel.setVisible(this.axisVisible);
80863
- } else {
80864
- this._xAxisLabel.setVisible(false);
80865
- }
81327
+ const tilde = this._approximate ? " ~ " : " = ";
80866
81328
 
80867
- if (!this._yAxisLabelCulled) {
80868
- this._yAxisLabel.setText(tilde + Math.abs((this._targetWorld[1] - this._originWorld[1]) * scale).toFixed(2) + unitAbbrev);
80869
- this._yAxisLabel.setVisible(this.axisVisible);
80870
- } else {
80871
- this._yAxisLabel.setVisible(false);
80872
- }
81329
+ this._length = Math.abs(math.lenVec3(math.subVec3(this._targetWorld, this._originWorld, distVec3)));
81330
+ this._lengthLabel.setText(tilde + (this._length * scale).toFixed(2) + unitAbbrev);
80873
81331
 
80874
- if (!this._zAxisLabelCulled) {
80875
- this._zAxisLabel.setText(tilde + Math.abs((this._targetWorld[2] - this._originWorld[2]) * scale).toFixed(2) + unitAbbrev);
80876
- this._zAxisLabel.setVisible(this.axisVisible);
80877
- } else {
80878
- this._zAxisLabel.setVisible(false);
81332
+ const xAxisCanvasLength = Math.abs(lengthWire(cp[0], cp[1], cp[2], cp[3]));
81333
+ const yAxisCanvasLength = Math.abs(lengthWire(cp[2], cp[3], cp[4], cp[5]));
81334
+ const zAxisCanvasLength = Math.abs(lengthWire(cp[4], cp[5], cp[6], cp[7]));
81335
+
81336
+ const labelMinAxisLength = this.plugin.labelMinAxisLength;
81337
+
81338
+ this._xAxisLabelCulled = (xAxisCanvasLength < labelMinAxisLength);
81339
+ this._yAxisLabelCulled = (yAxisCanvasLength < labelMinAxisLength);
81340
+ this._zAxisLabelCulled = (zAxisCanvasLength < labelMinAxisLength);
81341
+
81342
+ if (!this._xAxisLabelCulled) {
81343
+ this._xAxisLabel.setText(tilde + Math.abs((this._targetWorld[0] - this._originWorld[0]) * scale).toFixed(2) + unitAbbrev);
81344
+ this._xAxisLabel.setCulled(!this.axisVisible);
81345
+ } else {
81346
+ this._xAxisLabel.setCulled(true);
81347
+ }
81348
+
81349
+ if (!this._yAxisLabelCulled) {
81350
+ this._yAxisLabel.setText(tilde + Math.abs((this._targetWorld[1] - this._originWorld[1]) * scale).toFixed(2) + unitAbbrev);
81351
+ this._yAxisLabel.setCulled(!this.axisVisible);
81352
+ } else {
81353
+ this._yAxisLabel.setCulled(true);
81354
+ }
81355
+
81356
+ if (!this._zAxisLabelCulled) {
81357
+ this._zAxisLabel.setText(tilde + Math.abs((this._targetWorld[2] - this._originWorld[2]) * scale).toFixed(2) + unitAbbrev);
81358
+ this._zAxisLabel.setCulled(!this.axisVisible);
81359
+ } else {
81360
+ this._zAxisLabel.setCulled(true);
81361
+ }
80879
81362
  }
80880
81363
 
80881
81364
  this._originDot.setVisible(this._visible && this._originVisible);
@@ -80884,7 +81367,7 @@ class DistanceMeasurement extends Component {
80884
81367
  this._yAxisWire.setVisible(this.axisVisible);
80885
81368
  this._zAxisWire.setVisible(this.axisVisible);
80886
81369
  this._lengthWire.setVisible(this.wireVisible);
80887
- this._lengthLabel.setVisible(this.wireVisible);
81370
+ this._lengthLabel.setCulled(!this.wireVisible);
80888
81371
 
80889
81372
  this._cpDirty = false;
80890
81373
  }
@@ -80917,7 +81400,7 @@ class DistanceMeasurement extends Component {
80917
81400
  get approximate() {
80918
81401
  return this._approximate;
80919
81402
  }
80920
-
81403
+
80921
81404
  /**
80922
81405
  * Gets the origin {@link Marker}.
80923
81406
  *
@@ -80965,19 +81448,31 @@ class DistanceMeasurement extends Component {
80965
81448
  * @type {Boolean}
80966
81449
  */
80967
81450
  set visible(value) {
81451
+
80968
81452
  value = value !== undefined ? Boolean(value) : this.plugin.defaultVisible;
81453
+
80969
81454
  this._visible = value;
81455
+
80970
81456
  this._originDot.setVisible(this._visible && this._originVisible);
80971
81457
  this._targetDot.setVisible(this._visible && this._targetVisible);
80972
81458
  this._lengthWire.setVisible(this._visible && this._wireVisible);
80973
81459
  this._lengthLabel.setVisible(this._visible && this._wireVisible);
80974
- var axisVisible = this._visible && this._axisVisible;
80975
- this._xAxisWire.setVisible(axisVisible);
80976
- this._yAxisWire.setVisible(axisVisible);
80977
- this._zAxisWire.setVisible(axisVisible);
80978
- this._xAxisLabel.setVisible(axisVisible && !this._xAxisLabelCulled);
80979
- this._yAxisLabel.setVisible(axisVisible && !this._yAxisLabelCulled);
80980
- this._zAxisLabel.setVisible(axisVisible && !this._zAxisLabelCulled);
81460
+
81461
+ const xAxisVisible = this._visible && this._axisVisible && this._xAxisVisible;
81462
+ const yAxisVisible = this._visible && this._axisVisible && this._yAxisVisible;
81463
+ const zAxisVisible = this._visible && this._axisVisible && this._zAxisVisible;
81464
+
81465
+ this._xAxisWire.setVisible(xAxisVisible);
81466
+ this._yAxisWire.setVisible(yAxisVisible);
81467
+ this._zAxisWire.setVisible(zAxisVisible);
81468
+
81469
+ this._xAxisLabel.setVisible(xAxisVisible && !this._xAxisLabelCulled);
81470
+ this._yAxisLabel.setVisible(yAxisVisible && !this._yAxisLabelCulled);
81471
+ this._zAxisLabel.setVisible(zAxisVisible && !this._zAxisLabelCulled);
81472
+
81473
+ this._cpDirty = true;
81474
+
81475
+ this._needUpdate();
80981
81476
  }
80982
81477
 
80983
81478
  /**
@@ -81030,7 +81525,9 @@ class DistanceMeasurement extends Component {
81030
81525
  }
81031
81526
 
81032
81527
  /**
81033
- * Sets if the axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} are visible.
81528
+ * Sets if the axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} are enabled.
81529
+ *
81530
+ * Wires are only shown if enabled and visible.
81034
81531
  *
81035
81532
  * @type {Boolean}
81036
81533
  */
@@ -81044,20 +81541,26 @@ class DistanceMeasurement extends Component {
81044
81541
  this._xAxisLabel.setVisible(axisVisible && !this._xAxisLabelCulled);
81045
81542
  this._yAxisLabel.setVisible(axisVisible && !this._yAxisLabelCulled);
81046
81543
  this._zAxisLabel.setVisible(axisVisible && !this._zAxisLabelCulled);
81544
+ this._cpDirty = true;
81545
+ this._needUpdate();
81047
81546
  }
81048
81547
 
81049
81548
  /**
81050
- * Gets if the axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} are visible.
81549
+ * Gets if the axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} are enabled.
81550
+ *
81551
+ * Wires are only shown if enabled and visible.
81051
81552
  *
81052
81553
  * @type {Boolean}
81053
81554
  */
81054
81555
  get axisEnabled() {
81055
81556
  return this._axisEnabled;
81056
81557
  }
81057
-
81558
+
81058
81559
  /**
81059
81560
  * Sets if the axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} are visible.
81060
81561
  *
81562
+ * Wires are only shown if enabled and visible.
81563
+ *
81061
81564
  * @type {Boolean}
81062
81565
  */
81063
81566
  set axisVisible(value) {
@@ -81070,17 +81573,105 @@ class DistanceMeasurement extends Component {
81070
81573
  this._xAxisLabel.setVisible(axisVisible && !this._xAxisLabelCulled);
81071
81574
  this._yAxisLabel.setVisible(axisVisible && !this._yAxisLabelCulled);
81072
81575
  this._zAxisLabel.setVisible(axisVisible && !this._zAxisLabelCulled);
81576
+ this._cpDirty = true;
81577
+ this._needUpdate();
81073
81578
  }
81074
81579
 
81075
81580
  /**
81076
81581
  * Gets if the axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} are visible.
81077
81582
  *
81583
+ * Wires are only shown if enabled and visible.
81584
+ *
81078
81585
  * @type {Boolean}
81079
81586
  */
81080
81587
  get axisVisible() {
81081
81588
  return this._axisVisible;
81082
81589
  }
81083
81590
 
81591
+ /**
81592
+ * Sets if the X-axis-aligned wire between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} is visible.
81593
+ *
81594
+ * Wires are only shown if enabled and visible.
81595
+ *
81596
+ * @type {Boolean}
81597
+ */
81598
+ set xAxisVisible(value) {
81599
+ value = value !== undefined ? Boolean(value) : this.plugin.defaultAxisVisible;
81600
+ this._xAxisVisible = value;
81601
+ const axisVisible = this._visible && this._axisVisible && this._xAxisVisible && this._axisEnabled;
81602
+ this._xAxisWire.setVisible(axisVisible);
81603
+ this._xAxisLabel.setVisible(axisVisible && !this._xAxisLabelCulled);
81604
+ this._cpDirty = true;
81605
+ this._needUpdate();
81606
+ }
81607
+
81608
+ /**
81609
+ * Gets if the X-axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} are visible.
81610
+ *
81611
+ * Wires are only shown if enabled and visible.
81612
+ *
81613
+ * @type {Boolean}
81614
+ */
81615
+ get xAxisVisible() {
81616
+ return this._xAxisVisible;
81617
+ }
81618
+
81619
+ /**
81620
+ * Sets if the Y-axis-aligned wire between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} is visible.
81621
+ *
81622
+ * Wires are only shown if enabled and visible.
81623
+ *
81624
+ * @type {Boolean}
81625
+ */
81626
+ set yAxisVisible(value) {
81627
+ value = value !== undefined ? Boolean(value) : this.plugin.defaultAxisVisible;
81628
+ this._yAxisVisible = value;
81629
+ const axisVisible = this._visible && this._axisVisible && this._yAxisVisible && this._axisEnabled;
81630
+ this._yAxisWire.setVisible(axisVisible);
81631
+ this._yAxisLabel.setVisible(axisVisible && !this._yAxisLabelCulled);
81632
+ this._cpDirty = true;
81633
+ this._needUpdate();
81634
+ }
81635
+
81636
+ /**
81637
+ * Gets if the Y-axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} are visible.
81638
+ *
81639
+ * Wires are only shown if enabled and visible.
81640
+ *
81641
+ * @type {Boolean}
81642
+ */
81643
+ get yAxisVisible() {
81644
+ return this._yAxisVisible;
81645
+ }
81646
+
81647
+ /**
81648
+ * Sets if the Z-axis-aligned wire between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} is visible.
81649
+ *
81650
+ * Wires are only shown if enabled and visible.
81651
+ *
81652
+ * @type {Boolean}
81653
+ */
81654
+ set zAxisVisible(value) {
81655
+ value = value !== undefined ? Boolean(value) : this.plugin.defaultAxisVisible;
81656
+ this._zAxisVisible = value;
81657
+ const axisVisible = this._visible && this._axisVisible && this._zAxisVisible && this._axisEnabled;
81658
+ this._zAxisWire.setVisible(axisVisible);
81659
+ this._zAxisLabel.setVisible(axisVisible && !this._zAxisLabelCulled);
81660
+ this._cpDirty = true;
81661
+ this._needUpdate();
81662
+ }
81663
+
81664
+ /**
81665
+ * Gets if the Z-axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} are visible.
81666
+ *
81667
+ * Wires are only shown if enabled and visible.
81668
+ *
81669
+ * @type {Boolean}
81670
+ */
81671
+ get zAxisVisible() {
81672
+ return this._zAxisVisible;
81673
+ }
81674
+
81084
81675
  /**
81085
81676
  * Sets if the direct point-to-point wire between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target} is visible.
81086
81677
  *
@@ -81103,6 +81694,78 @@ class DistanceMeasurement extends Component {
81103
81694
  return this._wireVisible;
81104
81695
  }
81105
81696
 
81697
+ /**
81698
+ * Sets if the labels are visible.
81699
+ *
81700
+ * @type {Boolean}
81701
+ */
81702
+ set labelsVisible(value) {
81703
+ value = value !== undefined ? Boolean(value) : this.plugin.defaultLabelsVisible;
81704
+ this._labelsVisible = value;
81705
+ var labelsVisible = this._visible && this._labelsVisible;
81706
+ this._xAxisLabel.setVisible(labelsVisible && !this._xAxisLabelCulled && this._clickable && this._axisEnabled);
81707
+ this._yAxisLabel.setVisible(labelsVisible && !this._yAxisLabelCulled && this._clickable && this._axisEnabled);
81708
+ this._zAxisLabel.setVisible(labelsVisible && !this._zAxisLabelCulled && this._clickable && this._axisEnabled);
81709
+ this._lengthLabel.setVisible(labelsVisible);
81710
+ this._cpDirty = true;
81711
+ this._needUpdate();
81712
+ }
81713
+
81714
+ /**
81715
+ * Gets if the labels are visible.
81716
+ *
81717
+ * @type {Boolean}
81718
+ */
81719
+ get labelsVisible() {
81720
+ return this._labelsVisible;
81721
+ }
81722
+
81723
+ /**
81724
+ * Sets if this DistanceMeasurement appears highlighted.
81725
+ * @param highlighted
81726
+ */
81727
+ setHighlighted(highlighted) {
81728
+ this._originDot.setHighlighted(highlighted);
81729
+ this._targetDot.setHighlighted(highlighted);
81730
+ this._xAxisWire.setHighlighted(highlighted);
81731
+ this._yAxisWire.setHighlighted(highlighted);
81732
+ this._zAxisWire.setHighlighted(highlighted);
81733
+ this._xAxisLabel.setHighlighted(highlighted);
81734
+ this._yAxisLabel.setHighlighted(highlighted);
81735
+ this._zAxisLabel.setHighlighted(highlighted);
81736
+ this._lengthWire.setHighlighted(highlighted);
81737
+ this._lengthLabel.setHighlighted(highlighted);
81738
+ }
81739
+
81740
+ /**
81741
+ * Sets if the wires, dots ad labels will fire "mouseOver" "mouseLeave" and "contextMenu" events.
81742
+ *
81743
+ * @type {Boolean}
81744
+ */
81745
+ set clickable(value) {
81746
+ value = !!value;
81747
+ this._clickable = value;
81748
+ this._originDot.setClickable(this._clickable);
81749
+ this._targetDot.setClickable(this._clickable);
81750
+ this._xAxisWire.setClickable(this._clickable);
81751
+ this._yAxisWire.setClickable(this._clickable);
81752
+ this._zAxisWire.setClickable(this._clickable);
81753
+ this._lengthWire.setClickable(this._clickable);
81754
+ this._xAxisLabel.setClickable(this._clickable);
81755
+ this._yAxisLabel.setClickable(this._clickable);
81756
+ this._zAxisLabel.setClickable(this._clickable);
81757
+ this._lengthLabel.setClickable(this._clickable);
81758
+ }
81759
+
81760
+ /**
81761
+ * Gets if the wires, dots ad labels will fire "mouseOver" "mouseLeave" and "contextMenu" events.
81762
+ *
81763
+ * @type {Boolean}
81764
+ */
81765
+ get clickable() {
81766
+ return this._clickable;
81767
+ }
81768
+
81106
81769
  /**
81107
81770
  * @private
81108
81771
  */
@@ -87037,6 +87700,9 @@ class DistanceMeasurementsControl extends Component {
87037
87700
  this._currentDistanceMeasurementByMouseInittouchState = {
87038
87701
  wireVisible: null,
87039
87702
  axisVisible: null,
87703
+ xAxisVisible: null,
87704
+ yaxisVisible: null,
87705
+ zAxisVisible: null,
87040
87706
  targetVisible: null,
87041
87707
  };
87042
87708
 
@@ -87124,6 +87790,9 @@ class DistanceMeasurementsControl extends Component {
87124
87790
  if (this._currentDistanceMeasurementByMouse) {
87125
87791
  this._currentDistanceMeasurementByMouse.wireVisible = this._currentDistanceMeasurementByMouseInittouchState.wireVisible;
87126
87792
  this._currentDistanceMeasurementByMouse.axisVisible = this._currentDistanceMeasurementByMouseInittouchState.axisVisible && this.plugin.defaultAxisVisible;
87793
+ this._currentDistanceMeasurementByMouse.xAxisVisible = this._currentDistanceMeasurementByMouseInittouchState.xAxisVisible && this.plugin.defaultXAxisVisible;
87794
+ this._currentDistanceMeasurementByMouse.yAxisVisible = this._currentDistanceMeasurementByMouseInittouchState.yAxisVisible && this.plugin.defaultYAxisVisible;
87795
+ this._currentDistanceMeasurementByMouse.zAxisVisible = this._currentDistanceMeasurementByMouseInittouchState.zAxisVisible && this.plugin.defaultZAxisVisible;
87127
87796
  this._currentDistanceMeasurementByMouse.targetVisible = this._currentDistanceMeasurementByMouseInittouchState.targetVisible;
87128
87797
  this._currentDistanceMeasurementByMouse.target.entity = mouseHoverEntity;
87129
87798
  this._currentDistanceMeasurementByMouse.target.worldPos = mouseWorldPos;
@@ -87155,7 +87824,7 @@ class DistanceMeasurementsControl extends Component {
87155
87824
  }
87156
87825
  this._currentDistanceMeasurementByMouse.approximate = false;
87157
87826
  }
87158
-
87827
+ this._currentDistanceMeasurementByMouse.clickable = true;
87159
87828
  this.fire("measurementEnd", this._currentDistanceMeasurementByMouse);
87160
87829
  this._currentDistanceMeasurementByMouse = null;
87161
87830
  } else {
@@ -87188,8 +87857,14 @@ class DistanceMeasurementsControl extends Component {
87188
87857
  approximate: true
87189
87858
  });
87190
87859
  this._currentDistanceMeasurementByMouseInittouchState.axisVisible = this._currentDistanceMeasurementByMouse.axisVisible && this.plugin.defaultAxisVisible;
87860
+
87861
+ this._currentDistanceMeasurementByMouseInittouchState.xAxisVisible = this._currentDistanceMeasurementByMouse.xAxisVisible && this.plugin.defaultXAxisVisible;
87862
+ this._currentDistanceMeasurementByMouseInittouchState.yAxisVisible = this._currentDistanceMeasurementByMouse.yAxisVisible && this.plugin.defaultYAxisVisible;
87863
+ this._currentDistanceMeasurementByMouseInittouchState.zAxisVisible = this._currentDistanceMeasurementByMouse.zAxisVisible && this.plugin.defaultZAxisVisible;
87864
+
87191
87865
  this._currentDistanceMeasurementByMouseInittouchState.wireVisible = this._currentDistanceMeasurementByMouse.wireVisible;
87192
87866
  this._currentDistanceMeasurementByMouseInittouchState.targetVisible = this._currentDistanceMeasurementByMouse.targetVisible;
87867
+ this._currentDistanceMeasurementByMouse.clickable = false;
87193
87868
  this.fire("measurementStart", this._currentDistanceMeasurementByMouse);
87194
87869
  }
87195
87870
  }
@@ -87249,7 +87924,7 @@ class DistanceMeasurementsControl extends Component {
87249
87924
  case SECOND_TOUCH_EXPECTED:
87250
87925
  startDot.setVisible(false);
87251
87926
  this._touchStartMarker.worldPos = pickResult.worldPos;
87252
- plugin.createMeasurement({
87927
+ const measurement = plugin.createMeasurement({
87253
87928
  id: math.createUUID(),
87254
87929
  origin: {
87255
87930
  entity: mouseHoverEntity,
@@ -87261,6 +87936,7 @@ class DistanceMeasurementsControl extends Component {
87261
87936
  },
87262
87937
  approximate: (!pickSurfacePrecisionEnabled)
87263
87938
  });
87939
+ measurement.clickable = true;
87264
87940
  touchState = FIRST_TOUCH_EXPECTED;
87265
87941
  break;
87266
87942
  }
@@ -87362,7 +88038,7 @@ const getCanvasPosFromEvent = function (event, canvasPos) {
87362
88038
  *
87363
88039
  * * [[Example 1: Model with distance measurements](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_modelWithMeasurements)]
87364
88040
  * * [[Example 2: Create distance measurements with mouse](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_createWithMouse)]
87365
- * * [[Example 3: Configuring units and scale](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_unitsAndScale)]
88041
+ * * [[Example 3: Configuring units and scale](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_unitsAndScale)
87366
88042
  *
87367
88043
  * ## Overview
87368
88044
  *
@@ -87485,6 +88161,78 @@ const getCanvasPosFromEvent = function (event, canvasPos) {
87485
88161
  * metrics.units = "meters";
87486
88162
  * metrics.scale = 10.0;
87487
88163
  * ````
88164
+ *
88165
+ * ## Example 4: Attaching Mouse Handlers
88166
+ *
88167
+ * In our fourth example, we'll attach even handlers to our plugin, to catch when the user
88168
+ * hovers or right-clicks over our measurements.
88169
+ *
88170
+ * [[Run example](https://xeokit.github.io/xeokit-sdk/examples/#measurements_distance_modelWithMeasurements)]
88171
+ *
88172
+ * ````javascript
88173
+ * import {Viewer, XKTLoaderPlugin, DistanceMeasurementsPlugin} from "xeokit-sdk.es.js";
88174
+ *
88175
+ * const viewer = new Viewer({
88176
+ * canvasId: "myCanvas",
88177
+ * transparent: true
88178
+ * });
88179
+ *
88180
+ * viewer.scene.camera.eye = [-2.37, 18.97, -26.12];
88181
+ * viewer.scene.camera.look = [10.97, 5.82, -11.22];
88182
+ * viewer.scene.camera.up = [0.36, 0.83, 0.40];
88183
+ *
88184
+ * const xktLoader = new XKTLoaderPlugin(viewer);
88185
+ *
88186
+ * const distanceMeasurements = new DistanceMeasurementsPlugin(viewer);
88187
+ *
88188
+ * distanceMeasurements.on("mouseOver", (e) => {
88189
+ * e.measurement.setHighlighted(true);
88190
+ * });
88191
+ *
88192
+ * distanceMeasurements.on("mouseLeave", (e) => {
88193
+ * e.measurement.setHighlighted(false);
88194
+ * });
88195
+ *
88196
+ * distanceMeasurements.on("contextMenu", (e) => {
88197
+ * // Show context menu
88198
+ * e.event.preventDefault();
88199
+ * });
88200
+ *
88201
+ * const model = xktLoader.load({
88202
+ * src: "./models/xkt/duplex/duplex.xkt"
88203
+ * });
88204
+ *
88205
+ * model.on("loaded", () => {
88206
+ *
88207
+ * const myMeasurement1 = distanceMeasurements.createMeasurement({
88208
+ * id: "distanceMeasurement1",
88209
+ * origin: {
88210
+ * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FLOH"],
88211
+ * worldPos: [0.044, 5.998, 17.767]
88212
+ * },
88213
+ * target: {
88214
+ * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FLOH"],
88215
+ * worldPos: [4.738, 3.172, 17.768]
88216
+ * },
88217
+ * visible: true,
88218
+ * wireVisible: true
88219
+ * });
88220
+ *
88221
+ * const myMeasurement2 = distanceMeasurements.createMeasurement({
88222
+ * id: "distanceMeasurement2",
88223
+ * origin: {
88224
+ * entity: viewer.scene.objects["2O2Fr$t4X7Zf8NOew3FNr2"],
88225
+ * worldPos: [0.457, 2.532, 17.766]
88226
+ * },
88227
+ * target: {
88228
+ * entity: viewer.scene.objects["1CZILmCaHETO8tf3SgGEXu"],
88229
+ * worldPos: [0.436, 0.001, 22.135]
88230
+ * },
88231
+ * visible: true,
88232
+ * wireVisible: true
88233
+ * });
88234
+ * });
88235
+ * ````
87488
88236
  */
87489
88237
  class DistanceMeasurementsPlugin extends Plugin {
87490
88238
 
@@ -87499,10 +88247,14 @@ class DistanceMeasurementsPlugin extends Plugin {
87499
88247
  * @param {boolean} [cfg.defaultOriginVisible=true] The default value of the DistanceMeasurements `originVisible` property.
87500
88248
  * @param {boolean} [cfg.defaultTargetVisible=true] The default value of the DistanceMeasurements `targetVisible` property.
87501
88249
  * @param {boolean} [cfg.defaultWireVisible=true] The default value of the DistanceMeasurements `wireVisible` property.
88250
+ * @param {boolean} [cfg.defaultLabelsVisible=true] The default value of the DistanceMeasurements `labelsVisible` property.
87502
88251
  * @param {boolean} [cfg.defaultAxisVisible=true] The default value of the DistanceMeasurements `axisVisible` property.
87503
- * @param {boolean} [cfg.defaultAxisEnabled=true] The default value of the DistanceMeasurements `axisVisible` property.
88252
+ * @param {boolean} [cfg.defaultXAxisVisible=true] The default value of the DistanceMeasurements `xAxisVisible` property.
88253
+ * @param {boolean} [cfg.defaultYAxisVisible=true] The default value of the DistanceMeasurements `yAxisVisible` property.
88254
+ * @param {boolean} [cfg.defaultZAxisVisible=true] The default value of the DistanceMeasurements `zAxisVisible` property.
87504
88255
  * @param {string} [cfg.defaultColor=#00BBFF] The default color of the length dots, wire and label.
87505
88256
  * @param {number} [cfg.zIndex] If set, the wires, dots and labels will have this zIndex (+1 for dots and +2 for labels).
88257
+ *
87506
88258
  */
87507
88259
  constructor(viewer, cfg = {}) {
87508
88260
 
@@ -87520,9 +88272,37 @@ class DistanceMeasurementsPlugin extends Plugin {
87520
88272
  this.defaultOriginVisible = cfg.defaultOriginVisible !== false;
87521
88273
  this.defaultTargetVisible = cfg.defaultTargetVisible !== false;
87522
88274
  this.defaultWireVisible = cfg.defaultWireVisible !== false;
88275
+ this.defaultLabelsVisible = cfg.defaultLabelsVisible !== false;
87523
88276
  this.defaultAxisVisible = cfg.defaultAxisVisible !== false;
88277
+ this.defaultXAxisVisible = cfg.defaultXAxisVisible !== false;
88278
+ this.defaultYAxisVisible = cfg.defaultYAxisVisible !== false;
88279
+ this.defaultZAxisVisible = cfg.defaultZAxisVisible !== false;
87524
88280
  this.defaultColor = cfg.defaultColor !== undefined ? cfg.defaultColor : "#00BBFF";
87525
88281
  this.zIndex = cfg.zIndex || 10000;
88282
+
88283
+ this._onMouseOver = (event, measurement) => {
88284
+ this.fire("mouseOver", {
88285
+ plugin: this,
88286
+ measurement,
88287
+ event
88288
+ });
88289
+ };
88290
+
88291
+ this._onMouseLeave = (event, measurement) => {
88292
+ this.fire("mouseLeave", {
88293
+ plugin: this,
88294
+ measurement,
88295
+ event
88296
+ });
88297
+ };
88298
+
88299
+ this._onContextMenu = (event, measurement) => {
88300
+ this.fire("contextMenu", {
88301
+ plugin: this,
88302
+ measurement,
88303
+ event
88304
+ });
88305
+ };
87526
88306
  }
87527
88307
 
87528
88308
  /**
@@ -87593,6 +88373,10 @@ class DistanceMeasurementsPlugin extends Plugin {
87593
88373
  * @param {Boolean} [params.targetVisible=true] Whether to initially show the {@link DistanceMeasurement} target.
87594
88374
  * @param {Boolean} [params.wireVisible=true] Whether to initially show the direct point-to-point wire between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
87595
88375
  * @param {Boolean} [params.axisVisible=true] Whether to initially show the axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
88376
+ * @param {Boolean} [params.xAxisVisible=true] Whether to initially show the X-axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
88377
+ * @param {Boolean} [params.yAxisVisible=true] Whether to initially show the Y-axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
88378
+ * @param {Boolean} [params.zAxisVisible=true] Whether to initially show the Z-axis-aligned wires between {@link DistanceMeasurement#origin} and {@link DistanceMeasurement#target}.
88379
+ * @param {Boolean} [params.labelsVisible=true] Whether to initially show the labels.
87596
88380
  * @param {string} [params.color] The color of the length dot, wire and label.
87597
88381
  * @returns {DistanceMeasurement} The new {@link DistanceMeasurement}.
87598
88382
  */
@@ -87618,9 +88402,16 @@ class DistanceMeasurementsPlugin extends Plugin {
87618
88402
  visible: params.visible,
87619
88403
  wireVisible: params.wireVisible,
87620
88404
  axisVisible: params.axisVisible !== false && this.defaultAxisVisible !== false,
88405
+ xAxisVisible: params.xAxisVisible !== false && this.defaultXAxisVisible !== false,
88406
+ yAxisVisible: params.yAxisVisible !== false && this.defaultYAxisVisible !== false,
88407
+ zAxisVisible: params.zAxisVisible !== false && this.defaultZAxisVisible !== false,
88408
+ labelsVisible: params.labelsVisible !== false && this.defaultLabelsVisible !== false,
87621
88409
  originVisible: params.originVisible,
87622
88410
  targetVisible: params.targetVisible,
87623
- color: params.color
88411
+ color: params.color,
88412
+ onMouseOver: this._onMouseOver,
88413
+ onMouseLeave: this._onMouseLeave,
88414
+ onContextMenu: this._onContextMenu
87624
88415
  });
87625
88416
  this._measurements[measurement.id] = measurement;
87626
88417
  measurement.on("destroyed", () => {
@@ -87645,6 +88436,18 @@ class DistanceMeasurementsPlugin extends Plugin {
87645
88436
  this.fire("measurementDestroyed", measurement);
87646
88437
  }
87647
88438
 
88439
+ /**
88440
+ * Shows all or hides the angle label of each {@link DistanceMeasurement}.
88441
+ *
88442
+ * @param {Boolean} labelsShown Whether or not to show the labels.
88443
+ */
88444
+ setLabelsShown(labelsShown) {
88445
+ for (const [key, measurement] of Object.entries(this.measurements)) {
88446
+ measurement.labelShown = labelsShown;
88447
+ }
88448
+ }
88449
+
88450
+
87648
88451
  /**
87649
88452
  * Destroys all {@link DistanceMeasurement}s.
87650
88453
  */
@@ -102791,6 +103594,7 @@ class ModelTreeView {
102791
103594
  numEntities: 0,
102792
103595
  numVisibleEntities: 0,
102793
103596
  checked: false,
103597
+ xrayed: false,
102794
103598
  children: []
102795
103599
  };
102796
103600
  this._rootNodes.push(buildingNode);
@@ -102809,6 +103613,7 @@ class ModelTreeView {
102809
103613
  numEntities: 0,
102810
103614
  numVisibleEntities: 0,
102811
103615
  checked: false,
103616
+ xrayed: false,
102812
103617
  children: []
102813
103618
  };
102814
103619
  buildingNode.children.push(storeyNode);
@@ -102833,6 +103638,7 @@ class ModelTreeView {
102833
103638
  numEntities: 0,
102834
103639
  numVisibleEntities: 0,
102835
103640
  checked: false,
103641
+ xrayed: false,
102836
103642
  children: []
102837
103643
  };
102838
103644
  storeyNode.children.push(typeNode);
@@ -102848,6 +103654,7 @@ class ModelTreeView {
102848
103654
  numEntities: 0,
102849
103655
  numVisibleEntities: 0,
102850
103656
  checked: false,
103657
+ xrayed: false,
102851
103658
  children: []
102852
103659
  };
102853
103660
  typeNode.children.push(node);
@@ -102881,6 +103688,7 @@ class ModelTreeView {
102881
103688
  numEntities: 0,
102882
103689
  numVisibleEntities: 0,
102883
103690
  checked: false,
103691
+ xrayed: false,
102884
103692
  children: []
102885
103693
  };
102886
103694
  this._rootNodes.push(rootNode);
@@ -102902,6 +103710,7 @@ class ModelTreeView {
102902
103710
  numEntities: 0,
102903
103711
  numVisibleEntities: 0,
102904
103712
  checked: false,
103713
+ xrayed: false,
102905
103714
  children: []
102906
103715
  };
102907
103716
  rootNode.children.push(typeNode);
@@ -102917,6 +103726,7 @@ class ModelTreeView {
102917
103726
  numEntities: 0,
102918
103727
  numVisibleEntities: 0,
102919
103728
  checked: false,
103729
+ xrayed: false,
102920
103730
  children: []
102921
103731
  };
102922
103732
  typeNode.children.push(node);
@@ -102949,6 +103759,7 @@ class ModelTreeView {
102949
103759
  numEntities: 0,
102950
103760
  numVisibleEntities: 0,
102951
103761
  checked: false,
103762
+ xrayed: false,
102952
103763
  children: []
102953
103764
  };
102954
103765
  if (parent) {
@@ -163211,16 +164022,17 @@ class WebIFCLoaderPlugin extends Plugin {
163211
164022
  ctx.stats.numPropertySets++;
163212
164023
  const relatedObjects = rel.RelatedObjects;
163213
164024
  if (!relatedObjects || relatedObjects.length === 0) {
163214
- for (let i = 0, len = relatedObjects.length; i < len; i++) {
163215
- const relatedObject = relatedObjects[i];
163216
- const metaObjectId = relatedObject.GlobalId.value;
163217
- const metaObject = ctx.metaObjects[metaObjectId];
163218
- if (metaObject) {
163219
- if (!metaObject.propertySetIds) {
163220
- metaObject.propertySetIds = [];
163221
- }
163222
- metaObject.propertySetIds.push(propertySetId);
164025
+ return;
164026
+ }
164027
+ for (let i = 0, len = relatedObjects.length; i < len; i++) {
164028
+ const relatedObject = relatedObjects[i];
164029
+ const metaObjectId = relatedObject.GlobalId.value;
164030
+ const metaObject = ctx.metaObjects[metaObjectId];
164031
+ if (metaObject) {
164032
+ if (!metaObject.propertySetIds) {
164033
+ metaObject.propertySetIds = [];
163223
164034
  }
164035
+ metaObject.propertySetIds.push(propertySetId);
163224
164036
  }
163225
164037
  }
163226
164038
  }
@@ -163627,7 +164439,7 @@ class LASLoaderPlugin extends Plugin {
163627
164439
  * @param {Number|String} value Valid values are 8, 16 and "auto".
163628
164440
  */
163629
164441
  set colorDepth(value) {
163630
- this._colorDepth = !!value;
164442
+ this._colorDepth = value || "auto";
163631
164443
  }
163632
164444
 
163633
164445
  /**
@@ -163663,9 +164475,11 @@ class LASLoaderPlugin extends Plugin {
163663
164475
  }
163664
164476
 
163665
164477
  const options = {
163666
- skip: this._skip,
163667
- fp64: this._fp64,
163668
- colorDepth: this._colorDepth
164478
+ las: {
164479
+ skip: this._skip,
164480
+ fp64: this._fp64,
164481
+ colorDepth: this._colorDepth
164482
+ }
163669
164483
  };
163670
164484
 
163671
164485
  if (params.src) {
@@ -163780,10 +164594,10 @@ class LASLoaderPlugin extends Plugin {
163780
164594
  reject("No positions found in file");
163781
164595
  return;
163782
164596
  }
163783
-
164597
+
163784
164598
  let positionsValue;
163785
164599
  let colorsCompressed;
163786
-
164600
+
163787
164601
  switch (pointsFormatId) {
163788
164602
  case 0:
163789
164603
  positionsValue = readPositions(attributes.POSITION);