@xeokit/xeokit-sdk 2.6.54 → 2.6.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/xeokit-sdk.cjs.js +1414 -1786
- package/dist/xeokit-sdk.es.js +1412 -1787
- package/dist/xeokit-sdk.es5.js +732 -725
- package/dist/xeokit-sdk.min.cjs.js +5 -5
- package/dist/xeokit-sdk.min.es.js +5 -5
- package/dist/xeokit-sdk.min.es5.js +4 -4
- package/package.json +1 -1
- package/src/plugins/AngleMeasurementsPlugin/AngleMeasurement.js +155 -415
- package/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsMouseControl.js +1 -1
- package/src/plugins/AnnotationsPlugin/Annotation.js +7 -5
- package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.js +236 -750
- package/src/plugins/StoreyViewsPlugin/StoreyViewsPlugin.js +51 -0
- package/src/plugins/TreeViewPlugin/RenderService.js +2 -1
- package/src/plugins/XKTLoaderPlugin/XKTLoaderPlugin.js +5 -1
- package/src/plugins/ZonesPlugin/ZonesPlugin.js +15 -79
- package/src/plugins/lib/html/Dot.js +14 -41
- package/src/plugins/lib/html/Label.js +10 -37
- package/src/plugins/lib/html/MenuEvent.js +74 -0
- package/src/plugins/lib/html/Wire.js +20 -47
- package/src/plugins/lib/ui/index.js +370 -12
- package/src/viewer/Viewer.js +9 -0
- package/src/viewer/index.js +1 -0
- package/src/viewer/scene/CameraControl/CameraControl.js +38 -0
- package/src/viewer/scene/CameraControl/lib/CameraUpdater.js +5 -4
- package/src/viewer/scene/CameraControl/lib/handlers/KeyboardPanRotateDollyHandler.js +0 -8
- package/src/viewer/scene/CameraControl/lib/handlers/MousePanRotateDollyHandler.js +1 -2
- package/src/viewer/scene/CameraControl/lib/handlers/TouchPanRotateAndDollyHandler.js +2 -1
- package/src/viewer/scene/marker/Marker.js +20 -23
- package/src/viewer/scene/model/SceneModelEntity.js +5 -0
- package/src/viewer/scene/model/vbo/instancing/triangles/VBOInstancingTrianglesLayer.js +1 -1
- package/src/viewer/utils/index.js +1 -0
- package/src/viewer/utils/os.js +8 -1
- package/types/viewer/scene/CameraControl/CameraControl.d.ts +23 -0
- package/types/viewer/scene/models/PerformanceModel/index.d.ts +0 -1
- package/types/viewer/scene/models/SceneModel.d.ts +0 -3
- package/types/viewer/scene/models/SceneModelEntity.d.ts +6 -0
- package/types/viewer/scene/nodes/Node.d.ts +1 -1
package/dist/xeokit-sdk.cjs.js
CHANGED
|
@@ -9573,9 +9573,89 @@ const os = {
|
|
|
9573
9573
|
const isSafari = /Safari/i.test(userAgent) && !/Chrome/i.test(userAgent);
|
|
9574
9574
|
|
|
9575
9575
|
return isIphone && isSafari;
|
|
9576
|
+
},
|
|
9577
|
+
isTouchDevice() {
|
|
9578
|
+
return (
|
|
9579
|
+
'ontouchstart' in window || //works for most devices
|
|
9580
|
+
navigator.maxTouchPoints > 0 || //works for modern touch devices
|
|
9581
|
+
navigator.mxMaxTouchPoints > 0 //works for older microsoft touch devices
|
|
9582
|
+
)
|
|
9576
9583
|
}
|
|
9577
9584
|
};
|
|
9578
9585
|
|
|
9586
|
+
function addContextMenuListener(elem, callback) {
|
|
9587
|
+
if (!elem || !callback) return;
|
|
9588
|
+
|
|
9589
|
+
let timeout = null;
|
|
9590
|
+
const longPressTimer = 500;
|
|
9591
|
+
const MOVE_THRESHOLD = 3;
|
|
9592
|
+
let startX, startY;
|
|
9593
|
+
|
|
9594
|
+
const touchStartHandler = (event) => {
|
|
9595
|
+
event.preventDefault();
|
|
9596
|
+
const touch = event.touches[0];
|
|
9597
|
+
startX = touch.clientX;
|
|
9598
|
+
startY = touch.clientY;
|
|
9599
|
+
|
|
9600
|
+
if (timeout) {
|
|
9601
|
+
clearTimeout(timeout);
|
|
9602
|
+
timeout = null;
|
|
9603
|
+
}
|
|
9604
|
+
|
|
9605
|
+
timeout = setTimeout(() => {
|
|
9606
|
+
event.clientX = touch.clientX;
|
|
9607
|
+
event.clientY = touch.clientY;
|
|
9608
|
+
callback(event);
|
|
9609
|
+
clearTimeout(timeout);
|
|
9610
|
+
timeout = null;
|
|
9611
|
+
}, longPressTimer);
|
|
9612
|
+
};
|
|
9613
|
+
|
|
9614
|
+
const touchMoveHandler = (event) => {
|
|
9615
|
+
if (!timeout) return;
|
|
9616
|
+
const touch = event.touches[0];
|
|
9617
|
+
const deltaX = Math.abs(touch.clientX - startX);
|
|
9618
|
+
const deltaY = Math.abs(touch.clientY - startY);
|
|
9619
|
+
|
|
9620
|
+
if (deltaX > MOVE_THRESHOLD || deltaY > MOVE_THRESHOLD) {
|
|
9621
|
+
clearTimeout(timeout);
|
|
9622
|
+
timeout = null;
|
|
9623
|
+
}
|
|
9624
|
+
};
|
|
9625
|
+
|
|
9626
|
+
const touchEndHandler = (event) => {
|
|
9627
|
+
event.preventDefault();
|
|
9628
|
+
if (timeout) {
|
|
9629
|
+
clearTimeout(timeout);
|
|
9630
|
+
timeout = null;
|
|
9631
|
+
}
|
|
9632
|
+
};
|
|
9633
|
+
|
|
9634
|
+
const contextMenuHandler = (event) => {
|
|
9635
|
+
callback(event);
|
|
9636
|
+
event.preventDefault();
|
|
9637
|
+
event.stopPropagation();
|
|
9638
|
+
};
|
|
9639
|
+
|
|
9640
|
+
if (os.isIphoneSafari()) {
|
|
9641
|
+
elem.addEventListener('touchstart', touchStartHandler);
|
|
9642
|
+
elem.addEventListener('touchmove', touchMoveHandler);
|
|
9643
|
+
elem.addEventListener('touchend', touchEndHandler);
|
|
9644
|
+
} else {
|
|
9645
|
+
elem.addEventListener('contextmenu', contextMenuHandler);
|
|
9646
|
+
}
|
|
9647
|
+
|
|
9648
|
+
return function removeContextMenuListener() {
|
|
9649
|
+
if (os.isIphoneSafari()) {
|
|
9650
|
+
elem.removeEventListener('touchstart', touchStartHandler);
|
|
9651
|
+
elem.removeEventListener('touchmove', touchMoveHandler);
|
|
9652
|
+
elem.removeEventListener('touchend', touchEndHandler);
|
|
9653
|
+
} else {
|
|
9654
|
+
elem.removeEventListener('contextmenu', contextMenuHandler);
|
|
9655
|
+
}
|
|
9656
|
+
};
|
|
9657
|
+
}
|
|
9658
|
+
|
|
9579
9659
|
/** @private */
|
|
9580
9660
|
class Dot {
|
|
9581
9661
|
|
|
@@ -9689,41 +9769,10 @@ class Dot {
|
|
|
9689
9769
|
}
|
|
9690
9770
|
|
|
9691
9771
|
if (cfg.onContextMenu) {
|
|
9692
|
-
|
|
9693
|
-
|
|
9694
|
-
|
|
9695
|
-
|
|
9696
|
-
clearTimeout(this._timeout);
|
|
9697
|
-
this._timeout = null;
|
|
9698
|
-
}
|
|
9699
|
-
this._timeout = setTimeout(() => {
|
|
9700
|
-
event.clientX = event.touches[0].clientX;
|
|
9701
|
-
event.clientY = event.touches[0].clientY;
|
|
9702
|
-
cfg.onContextMenu(event, this);
|
|
9703
|
-
clearTimeout(this._timeout);
|
|
9704
|
-
this._timeout = null;
|
|
9705
|
-
}, 500);
|
|
9706
|
-
});
|
|
9707
|
-
|
|
9708
|
-
dotClickable.addEventListener('touchend', (event) => {
|
|
9709
|
-
event.preventDefault();
|
|
9710
|
-
//stops short touches from calling the timeout
|
|
9711
|
-
if(this._timeout) {
|
|
9712
|
-
clearTimeout(this._timeout);
|
|
9713
|
-
this._timeout = null;
|
|
9714
|
-
}
|
|
9715
|
-
} );
|
|
9716
|
-
|
|
9717
|
-
}
|
|
9718
|
-
else {
|
|
9719
|
-
dotClickable.addEventListener('contextmenu', (event) => {
|
|
9720
|
-
console.log(event);
|
|
9721
|
-
cfg.onContextMenu(event, this);
|
|
9722
|
-
event.preventDefault();
|
|
9723
|
-
event.stopPropagation();
|
|
9724
|
-
console.log("Label context menu");
|
|
9725
|
-
});
|
|
9726
|
-
}
|
|
9772
|
+
const contextMenuCallback = (event) => {
|
|
9773
|
+
cfg.onContextMenu(event, this);
|
|
9774
|
+
};
|
|
9775
|
+
addContextMenuListener(dotClickable, contextMenuCallback);
|
|
9727
9776
|
|
|
9728
9777
|
}
|
|
9729
9778
|
|
|
@@ -9736,12 +9785,12 @@ class Dot {
|
|
|
9736
9785
|
this._x = x;
|
|
9737
9786
|
this._y = y;
|
|
9738
9787
|
var dotStyle = this._dot.style;
|
|
9739
|
-
dotStyle["left"] = (Math.round(x) -
|
|
9740
|
-
dotStyle["top"] = (Math.round(y) -
|
|
9788
|
+
dotStyle["left"] = (Math.round(x) - 6) + 'px';
|
|
9789
|
+
dotStyle["top"] = (Math.round(y) - 6) + 'px';
|
|
9741
9790
|
|
|
9742
9791
|
var dotClickableStyle = this._dotClickable.style;
|
|
9743
|
-
dotClickableStyle["left"] = (Math.round(x) -
|
|
9744
|
-
dotClickableStyle["top"] = (Math.round(y) -
|
|
9792
|
+
dotClickableStyle["left"] = (Math.round(x) - 14) + 'px';
|
|
9793
|
+
dotClickableStyle["top"] = (Math.round(y) - 14) + 'px';
|
|
9745
9794
|
}
|
|
9746
9795
|
|
|
9747
9796
|
setFillColor(color) {
|
|
@@ -9756,12 +9805,16 @@ class Dot {
|
|
|
9756
9805
|
this._dot.style.opacity = opacity;
|
|
9757
9806
|
}
|
|
9758
9807
|
|
|
9808
|
+
_updateVisibility() {
|
|
9809
|
+
this._dot.style.visibility = this._dotClickable.style.visibility = this._visible && !this._culled ? "visible" : "hidden";
|
|
9810
|
+
}
|
|
9811
|
+
|
|
9759
9812
|
setVisible(visible) {
|
|
9760
9813
|
if (this._visible === visible) {
|
|
9761
9814
|
return;
|
|
9762
9815
|
}
|
|
9763
9816
|
this._visible = !!visible;
|
|
9764
|
-
this.
|
|
9817
|
+
this._updateVisibility();
|
|
9765
9818
|
}
|
|
9766
9819
|
|
|
9767
9820
|
setCulled(culled) {
|
|
@@ -9769,7 +9822,7 @@ class Dot {
|
|
|
9769
9822
|
return;
|
|
9770
9823
|
}
|
|
9771
9824
|
this._culled = !!culled;
|
|
9772
|
-
this.
|
|
9825
|
+
this._updateVisibility();
|
|
9773
9826
|
}
|
|
9774
9827
|
|
|
9775
9828
|
setClickable(clickable) {
|
|
@@ -9799,6 +9852,413 @@ class Dot {
|
|
|
9799
9852
|
}
|
|
9800
9853
|
}
|
|
9801
9854
|
|
|
9855
|
+
/** @private */
|
|
9856
|
+
class Label {
|
|
9857
|
+
|
|
9858
|
+
constructor(parentElement, cfg = {}) {
|
|
9859
|
+
|
|
9860
|
+
this._highlightClass = "viewer-ruler-label-highlighted";
|
|
9861
|
+
|
|
9862
|
+
this._prefix = cfg.prefix || "";
|
|
9863
|
+
this._x = 0;
|
|
9864
|
+
this._y = 0;
|
|
9865
|
+
this._visible = true;
|
|
9866
|
+
this._culled = false;
|
|
9867
|
+
|
|
9868
|
+
this._label = document.createElement('div');
|
|
9869
|
+
this._label.className += this._label.className ? ' viewer-ruler-label' : 'viewer-ruler-label';
|
|
9870
|
+
this._timeout = null;
|
|
9871
|
+
|
|
9872
|
+
var label = this._label;
|
|
9873
|
+
var style = label.style;
|
|
9874
|
+
|
|
9875
|
+
style["border-radius"] = 5 + "px";
|
|
9876
|
+
style.color = "white";
|
|
9877
|
+
style.padding = "4px";
|
|
9878
|
+
style.border = "solid 1px";
|
|
9879
|
+
style.background = "lightgreen";
|
|
9880
|
+
style.position = "absolute";
|
|
9881
|
+
style["z-index"] = cfg.zIndex === undefined ? "5000005" : cfg.zIndex;
|
|
9882
|
+
style.width = "auto";
|
|
9883
|
+
style.height = "auto";
|
|
9884
|
+
style.visibility = "visible";
|
|
9885
|
+
style.top = 0 + "px";
|
|
9886
|
+
style.left = 0 + "px";
|
|
9887
|
+
style["pointer-events"] = "all";
|
|
9888
|
+
style["opacity"] = 1.0;
|
|
9889
|
+
if (cfg.onContextMenu) ;
|
|
9890
|
+
label.innerText = "";
|
|
9891
|
+
|
|
9892
|
+
parentElement.appendChild(label);
|
|
9893
|
+
|
|
9894
|
+
this.setPos(cfg.x || 0, cfg.y || 0);
|
|
9895
|
+
this.setFillColor(cfg.fillColor);
|
|
9896
|
+
this.setBorderColor(cfg.fillColor);
|
|
9897
|
+
this.setText(cfg.text);
|
|
9898
|
+
|
|
9899
|
+
if (cfg.onMouseOver) {
|
|
9900
|
+
label.addEventListener('mouseover', (event) => {
|
|
9901
|
+
cfg.onMouseOver(event, this);
|
|
9902
|
+
event.preventDefault();
|
|
9903
|
+
});
|
|
9904
|
+
}
|
|
9905
|
+
|
|
9906
|
+
if (cfg.onMouseLeave) {
|
|
9907
|
+
label.addEventListener('mouseleave', (event) => {
|
|
9908
|
+
cfg.onMouseLeave(event, this);
|
|
9909
|
+
event.preventDefault();
|
|
9910
|
+
});
|
|
9911
|
+
}
|
|
9912
|
+
|
|
9913
|
+
if (cfg.onMouseWheel) {
|
|
9914
|
+
label.addEventListener('wheel', (event) => {
|
|
9915
|
+
cfg.onMouseWheel(event, this);
|
|
9916
|
+
});
|
|
9917
|
+
}
|
|
9918
|
+
|
|
9919
|
+
if (cfg.onMouseDown) {
|
|
9920
|
+
label.addEventListener('mousedown', (event) => {
|
|
9921
|
+
cfg.onMouseDown(event, this);
|
|
9922
|
+
event.stopPropagation();
|
|
9923
|
+
});
|
|
9924
|
+
}
|
|
9925
|
+
|
|
9926
|
+
if (cfg.onMouseUp) {
|
|
9927
|
+
label.addEventListener('mouseup', (event) => {
|
|
9928
|
+
cfg.onMouseUp(event, this);
|
|
9929
|
+
event.stopPropagation();
|
|
9930
|
+
});
|
|
9931
|
+
}
|
|
9932
|
+
|
|
9933
|
+
if (cfg.onMouseMove) {
|
|
9934
|
+
label.addEventListener('mousemove', (event) => {
|
|
9935
|
+
cfg.onMouseMove(event, this);
|
|
9936
|
+
});
|
|
9937
|
+
}
|
|
9938
|
+
|
|
9939
|
+
if (cfg.onContextMenu) {
|
|
9940
|
+
const contextMenuCallback = (event) => {
|
|
9941
|
+
cfg.onContextMenu(event, this);
|
|
9942
|
+
};
|
|
9943
|
+
addContextMenuListener(label, contextMenuCallback);
|
|
9944
|
+
|
|
9945
|
+
}
|
|
9946
|
+
}
|
|
9947
|
+
|
|
9948
|
+
setPos(x, y) {
|
|
9949
|
+
this._x = x;
|
|
9950
|
+
this._y = y;
|
|
9951
|
+
var style = this._label.style;
|
|
9952
|
+
style["left"] = (Math.round(x) - 20) + 'px';
|
|
9953
|
+
style["top"] = (Math.round(y) - 12) + 'px';
|
|
9954
|
+
}
|
|
9955
|
+
|
|
9956
|
+
setPosOnWire(x1, y1, x2, y2) {
|
|
9957
|
+
var x = x1 + ((x2 - x1) * 0.5);
|
|
9958
|
+
var y = y1 + ((y2 - y1) * 0.5);
|
|
9959
|
+
var style = this._label.style;
|
|
9960
|
+
style["left"] = (Math.round(x) - 20) + 'px';
|
|
9961
|
+
style["top"] = (Math.round(y) - 12) + 'px';
|
|
9962
|
+
}
|
|
9963
|
+
|
|
9964
|
+
setPosBetweenWires(x1, y1, x2, y2, x3, y3) {
|
|
9965
|
+
var x = (x1 + x2 + x3) / 3;
|
|
9966
|
+
var y = (y1 + y2 + y3) / 3;
|
|
9967
|
+
var style = this._label.style;
|
|
9968
|
+
style["left"] = (Math.round(x) - 20) + 'px';
|
|
9969
|
+
style["top"] = (Math.round(y) - 12) + 'px';
|
|
9970
|
+
}
|
|
9971
|
+
|
|
9972
|
+
setText(text) {
|
|
9973
|
+
this._label.innerHTML = this._prefix + (text || "");
|
|
9974
|
+
}
|
|
9975
|
+
|
|
9976
|
+
setFillColor(color) {
|
|
9977
|
+
this._fillColor = color || "lightgreen";
|
|
9978
|
+
this._label.style.background =this._fillColor;
|
|
9979
|
+
}
|
|
9980
|
+
|
|
9981
|
+
setBorderColor(color) {
|
|
9982
|
+
this._borderColor = color || "black";
|
|
9983
|
+
this._label.style.border = "solid 1px " + this._borderColor;
|
|
9984
|
+
}
|
|
9985
|
+
|
|
9986
|
+
setOpacity(opacity) {
|
|
9987
|
+
this._label.style.opacity = opacity;
|
|
9988
|
+
}
|
|
9989
|
+
|
|
9990
|
+
_updateVisibility() {
|
|
9991
|
+
this._label.style.visibility = this._visible && !this._culled ? "visible" : "hidden";
|
|
9992
|
+
}
|
|
9993
|
+
|
|
9994
|
+
setVisible(visible) {
|
|
9995
|
+
if (this._visible === visible) {
|
|
9996
|
+
return;
|
|
9997
|
+
}
|
|
9998
|
+
this._visible = !!visible;
|
|
9999
|
+
this._updateVisibility();
|
|
10000
|
+
}
|
|
10001
|
+
|
|
10002
|
+
setCulled(culled) {
|
|
10003
|
+
if (this._culled === culled) {
|
|
10004
|
+
return;
|
|
10005
|
+
}
|
|
10006
|
+
this._culled = !!culled;
|
|
10007
|
+
this._updateVisibility();
|
|
10008
|
+
}
|
|
10009
|
+
|
|
10010
|
+
setHighlighted(highlighted) {
|
|
10011
|
+
if (this._highlighted === highlighted) {
|
|
10012
|
+
return;
|
|
10013
|
+
}
|
|
10014
|
+
this._highlighted = !!highlighted;
|
|
10015
|
+
if (this._highlighted) {
|
|
10016
|
+
this._label.classList.add(this._highlightClass);
|
|
10017
|
+
} else {
|
|
10018
|
+
this._label.classList.remove(this._highlightClass);
|
|
10019
|
+
}
|
|
10020
|
+
}
|
|
10021
|
+
|
|
10022
|
+
setClickable(clickable) {
|
|
10023
|
+
this._label.style["pointer-events"] = (clickable) ? "all" : "none";
|
|
10024
|
+
}
|
|
10025
|
+
|
|
10026
|
+
setPrefix(prefix) {
|
|
10027
|
+
if(this._prefix === prefix){
|
|
10028
|
+
return;
|
|
10029
|
+
}
|
|
10030
|
+
this._prefix = prefix;
|
|
10031
|
+
}
|
|
10032
|
+
|
|
10033
|
+
destroy() {
|
|
10034
|
+
if (this._label.parentElement) {
|
|
10035
|
+
this._label.parentElement.removeChild(this._label);
|
|
10036
|
+
}
|
|
10037
|
+
}
|
|
10038
|
+
|
|
10039
|
+
|
|
10040
|
+
}
|
|
10041
|
+
|
|
10042
|
+
/** @private */
|
|
10043
|
+
class Wire {
|
|
10044
|
+
|
|
10045
|
+
constructor(parentElement, cfg = {}) {
|
|
10046
|
+
|
|
10047
|
+
this._color = cfg.color || "black";
|
|
10048
|
+
this._highlightClass = "viewer-ruler-wire-highlighted";
|
|
10049
|
+
|
|
10050
|
+
this._wire = document.createElement('div');
|
|
10051
|
+
this._wire.className += this._wire.className ? ' viewer-ruler-wire' : 'viewer-ruler-wire';
|
|
10052
|
+
|
|
10053
|
+
this._wireClickable = document.createElement('div');
|
|
10054
|
+
this._wireClickable.className += this._wireClickable.className ? ' viewer-ruler-wire-clickable' : 'viewer-ruler-wire-clickable';
|
|
10055
|
+
|
|
10056
|
+
this._thickness = cfg.thickness || 1.0;
|
|
10057
|
+
this._thicknessClickable = cfg.thicknessClickable || 6.0;
|
|
10058
|
+
|
|
10059
|
+
this._visible = true;
|
|
10060
|
+
this._culled = false;
|
|
10061
|
+
|
|
10062
|
+
var wire = this._wire;
|
|
10063
|
+
var wireStyle = wire.style;
|
|
10064
|
+
|
|
10065
|
+
wireStyle.border = "solid " + this._thickness + "px " + this._color;
|
|
10066
|
+
wireStyle.position = "absolute";
|
|
10067
|
+
wireStyle["z-index"] = cfg.zIndex === undefined ? "2000001" : cfg.zIndex;
|
|
10068
|
+
wireStyle.width = 0 + "px";
|
|
10069
|
+
wireStyle.height = 0 + "px";
|
|
10070
|
+
wireStyle.visibility = "visible";
|
|
10071
|
+
wireStyle.top = 0 + "px";
|
|
10072
|
+
wireStyle.left = 0 + "px";
|
|
10073
|
+
wireStyle['-webkit-transform-origin'] = "0 0";
|
|
10074
|
+
wireStyle['-moz-transform-origin'] = "0 0";
|
|
10075
|
+
wireStyle['-ms-transform-origin'] = "0 0";
|
|
10076
|
+
wireStyle['-o-transform-origin'] = "0 0";
|
|
10077
|
+
wireStyle['transform-origin'] = "0 0";
|
|
10078
|
+
wireStyle['-webkit-transform'] = 'rotate(0deg)';
|
|
10079
|
+
wireStyle['-moz-transform'] = 'rotate(0deg)';
|
|
10080
|
+
wireStyle['-ms-transform'] = 'rotate(0deg)';
|
|
10081
|
+
wireStyle['-o-transform'] = 'rotate(0deg)';
|
|
10082
|
+
wireStyle['transform'] = 'rotate(0deg)';
|
|
10083
|
+
wireStyle["opacity"] = 1.0;
|
|
10084
|
+
wireStyle["pointer-events"] = "none";
|
|
10085
|
+
if (cfg.onContextMenu) ;
|
|
10086
|
+
|
|
10087
|
+
parentElement.appendChild(wire);
|
|
10088
|
+
|
|
10089
|
+
var wireClickable = this._wireClickable;
|
|
10090
|
+
var wireClickableStyle = wireClickable.style;
|
|
10091
|
+
|
|
10092
|
+
wireClickableStyle.border = "solid " + this._thicknessClickable + "px " + this._color;
|
|
10093
|
+
wireClickableStyle.position = "absolute";
|
|
10094
|
+
wireClickableStyle["z-index"] = cfg.zIndex === undefined ? "2000002" : (cfg.zIndex + 1);
|
|
10095
|
+
wireClickableStyle.width = 0 + "px";
|
|
10096
|
+
wireClickableStyle.height = 0 + "px";
|
|
10097
|
+
wireClickableStyle.visibility = "visible";
|
|
10098
|
+
wireClickableStyle.top = 0 + "px";
|
|
10099
|
+
wireClickableStyle.left = 0 + "px";
|
|
10100
|
+
// wireClickableStyle["pointer-events"] = "none";
|
|
10101
|
+
wireClickableStyle['-webkit-transform-origin'] = "0 0";
|
|
10102
|
+
wireClickableStyle['-moz-transform-origin'] = "0 0";
|
|
10103
|
+
wireClickableStyle['-ms-transform-origin'] = "0 0";
|
|
10104
|
+
wireClickableStyle['-o-transform-origin'] = "0 0";
|
|
10105
|
+
wireClickableStyle['transform-origin'] = "0 0";
|
|
10106
|
+
wireClickableStyle['-webkit-transform'] = 'rotate(0deg)';
|
|
10107
|
+
wireClickableStyle['-moz-transform'] = 'rotate(0deg)';
|
|
10108
|
+
wireClickableStyle['-ms-transform'] = 'rotate(0deg)';
|
|
10109
|
+
wireClickableStyle['-o-transform'] = 'rotate(0deg)';
|
|
10110
|
+
wireClickableStyle['transform'] = 'rotate(0deg)';
|
|
10111
|
+
wireClickableStyle["opacity"] = 0.0;
|
|
10112
|
+
wireClickableStyle["pointer-events"] = "none";
|
|
10113
|
+
if (cfg.onContextMenu) ;
|
|
10114
|
+
|
|
10115
|
+
parentElement.appendChild(wireClickable);
|
|
10116
|
+
|
|
10117
|
+
if (cfg.onMouseOver) {
|
|
10118
|
+
wireClickable.addEventListener('mouseover', (event) => {
|
|
10119
|
+
cfg.onMouseOver(event, this);
|
|
10120
|
+
});
|
|
10121
|
+
}
|
|
10122
|
+
|
|
10123
|
+
if (cfg.onMouseLeave) {
|
|
10124
|
+
wireClickable.addEventListener('mouseleave', (event) => {
|
|
10125
|
+
cfg.onMouseLeave(event, this);
|
|
10126
|
+
});
|
|
10127
|
+
}
|
|
10128
|
+
|
|
10129
|
+
if (cfg.onMouseWheel) {
|
|
10130
|
+
wireClickable.addEventListener('wheel', (event) => {
|
|
10131
|
+
cfg.onMouseWheel(event, this);
|
|
10132
|
+
});
|
|
10133
|
+
}
|
|
10134
|
+
|
|
10135
|
+
if (cfg.onMouseDown) {
|
|
10136
|
+
wireClickable.addEventListener('mousedown', (event) => {
|
|
10137
|
+
cfg.onMouseDown(event, this);
|
|
10138
|
+
});
|
|
10139
|
+
}
|
|
10140
|
+
|
|
10141
|
+
if (cfg.onMouseUp) {
|
|
10142
|
+
wireClickable.addEventListener('mouseup', (event) => {
|
|
10143
|
+
cfg.onMouseUp(event, this);
|
|
10144
|
+
});
|
|
10145
|
+
}
|
|
10146
|
+
|
|
10147
|
+
if (cfg.onMouseMove) {
|
|
10148
|
+
wireClickable.addEventListener('mousemove', (event) => {
|
|
10149
|
+
cfg.onMouseMove(event, this);
|
|
10150
|
+
});
|
|
10151
|
+
}
|
|
10152
|
+
|
|
10153
|
+
if (cfg.onContextMenu) {
|
|
10154
|
+
const contextMenuCallback = (event) => {
|
|
10155
|
+
cfg.onContextMenu(event, this);
|
|
10156
|
+
};
|
|
10157
|
+
addContextMenuListener(wireClickable, contextMenuCallback);
|
|
10158
|
+
|
|
10159
|
+
}
|
|
10160
|
+
|
|
10161
|
+
this._x1 = 0;
|
|
10162
|
+
this._y1 = 0;
|
|
10163
|
+
this._x2 = 0;
|
|
10164
|
+
this._y2 = 0;
|
|
10165
|
+
|
|
10166
|
+
this._update();
|
|
10167
|
+
}
|
|
10168
|
+
|
|
10169
|
+
get visible() {
|
|
10170
|
+
return this._wire.style.visibility === "visible";
|
|
10171
|
+
}
|
|
10172
|
+
|
|
10173
|
+
_update() {
|
|
10174
|
+
|
|
10175
|
+
var length = Math.abs(Math.sqrt((this._x1 - this._x2) * (this._x1 - this._x2) + (this._y1 - this._y2) * (this._y1 - this._y2)));
|
|
10176
|
+
var angle = Math.atan2(this._y2 - this._y1, this._x2 - this._x1) * 180.0 / Math.PI;
|
|
10177
|
+
|
|
10178
|
+
var wireStyle = this._wire.style;
|
|
10179
|
+
wireStyle["width"] = Math.round(length) + 'px';
|
|
10180
|
+
wireStyle["left"] = Math.round(this._x1) + 'px';
|
|
10181
|
+
wireStyle["top"] = Math.round(this._y1) + 'px';
|
|
10182
|
+
wireStyle['-webkit-transform'] =
|
|
10183
|
+
wireStyle['-moz-transform'] =
|
|
10184
|
+
wireStyle['-ms-transform'] =
|
|
10185
|
+
wireStyle['-o-transform'] =
|
|
10186
|
+
wireStyle['transform'] = 'rotate(' + angle + 'deg) translate(-' + this._thickness + 'px, -' + this._thickness + 'px)';
|
|
10187
|
+
|
|
10188
|
+
var wireClickableStyle = this._wireClickable.style;
|
|
10189
|
+
wireClickableStyle["width"] = Math.round(length) + 'px';
|
|
10190
|
+
wireClickableStyle["left"] = Math.round(this._x1) + 'px';
|
|
10191
|
+
wireClickableStyle["top"] = Math.round(this._y1) + 'px';
|
|
10192
|
+
wireClickableStyle['-webkit-transform'] =
|
|
10193
|
+
wireClickableStyle['-moz-transform'] =
|
|
10194
|
+
wireClickableStyle['-ms-transform'] =
|
|
10195
|
+
wireClickableStyle['-o-transform'] =
|
|
10196
|
+
wireClickableStyle['transform'] = 'rotate(' + angle + 'deg) translate(-' + this._thicknessClickable + 'px, -' + this._thicknessClickable + 'px)';
|
|
10197
|
+
}
|
|
10198
|
+
|
|
10199
|
+
setStartAndEnd(x1, y1, x2, y2) {
|
|
10200
|
+
this._x1 = x1;
|
|
10201
|
+
this._y1 = y1;
|
|
10202
|
+
this._x2 = x2;
|
|
10203
|
+
this._y2 = y2;
|
|
10204
|
+
this._update();
|
|
10205
|
+
}
|
|
10206
|
+
|
|
10207
|
+
setColor(color) {
|
|
10208
|
+
this._color = color || "black";
|
|
10209
|
+
this._wire.style.border = "solid " + this._thickness + "px " + this._color;
|
|
10210
|
+
}
|
|
10211
|
+
|
|
10212
|
+
setOpacity(opacity) {
|
|
10213
|
+
this._wire.style.opacity = opacity;
|
|
10214
|
+
}
|
|
10215
|
+
|
|
10216
|
+
_updateVisibility() {
|
|
10217
|
+
this._wire.style.visibility = this._wireClickable.style.visibility = this._visible && !this._culled ? "visible" : "hidden";
|
|
10218
|
+
}
|
|
10219
|
+
|
|
10220
|
+
setVisible(visible) {
|
|
10221
|
+
if (this._visible === visible) {
|
|
10222
|
+
return;
|
|
10223
|
+
}
|
|
10224
|
+
this._visible = !!visible;
|
|
10225
|
+
this._updateVisibility();
|
|
10226
|
+
}
|
|
10227
|
+
|
|
10228
|
+
setCulled(culled) {
|
|
10229
|
+
if (this._culled === culled) {
|
|
10230
|
+
return;
|
|
10231
|
+
}
|
|
10232
|
+
this._culled = !!culled;
|
|
10233
|
+
this._updateVisibility();
|
|
10234
|
+
}
|
|
10235
|
+
|
|
10236
|
+
setClickable(clickable) {
|
|
10237
|
+
this._wireClickable.style["pointer-events"] = (clickable) ? "all" : "none";
|
|
10238
|
+
}
|
|
10239
|
+
|
|
10240
|
+
setHighlighted(highlighted) {
|
|
10241
|
+
if (this._highlighted === highlighted) {
|
|
10242
|
+
return;
|
|
10243
|
+
}
|
|
10244
|
+
this._highlighted = !!highlighted;
|
|
10245
|
+
if (this._highlighted) {
|
|
10246
|
+
this._wire.classList.add(this._highlightClass);
|
|
10247
|
+
} else {
|
|
10248
|
+
this._wire.classList.remove(this._highlightClass);
|
|
10249
|
+
}
|
|
10250
|
+
}
|
|
10251
|
+
|
|
10252
|
+
destroy(visible) {
|
|
10253
|
+
if (this._wire.parentElement) {
|
|
10254
|
+
this._wire.parentElement.removeChild(this._wire);
|
|
10255
|
+
}
|
|
10256
|
+
if (this._wireClickable.parentElement) {
|
|
10257
|
+
this._wireClickable.parentElement.removeChild(this._wireClickable);
|
|
10258
|
+
}
|
|
10259
|
+
}
|
|
10260
|
+
}
|
|
10261
|
+
|
|
9802
10262
|
const tempVec3a$L = math.vec3();
|
|
9803
10263
|
const tempVec4$1 = math.vec4();
|
|
9804
10264
|
|
|
@@ -9992,6 +10452,11 @@ class SceneModelEntity {
|
|
|
9992
10452
|
*/
|
|
9993
10453
|
this.model = model;
|
|
9994
10454
|
|
|
10455
|
+
/**
|
|
10456
|
+
* Identifies if it's a SceneModelEntity
|
|
10457
|
+
*/
|
|
10458
|
+
this.isSceneModelEntity = true;
|
|
10459
|
+
|
|
9995
10460
|
/**
|
|
9996
10461
|
* The {@link SceneModelMesh}es belonging to this SceneModelEntity.
|
|
9997
10462
|
*
|
|
@@ -10903,28 +11368,13 @@ class Marker extends Component {
|
|
|
10903
11368
|
* @type {Entity}
|
|
10904
11369
|
*/
|
|
10905
11370
|
set entity(entity) {
|
|
10906
|
-
if (this._entity) {
|
|
10907
|
-
|
|
10908
|
-
return;
|
|
10909
|
-
}
|
|
10910
|
-
if (this._onEntityDestroyed !== null) {
|
|
10911
|
-
if (this._entity.model) {
|
|
10912
|
-
this._entity.model.off(this._onEntityDestroyed);
|
|
10913
|
-
} else {
|
|
10914
|
-
this._entity.off(this._onEntityDestroyed);
|
|
10915
|
-
}
|
|
10916
|
-
this._onEntityDestroyed = null;
|
|
10917
|
-
}
|
|
10918
|
-
if (this._onEntityModelDestroyed !== null) {
|
|
10919
|
-
if (this._entity.model) {
|
|
10920
|
-
this._entity.model.off(this._onEntityModelDestroyed);
|
|
10921
|
-
}
|
|
10922
|
-
this._onEntityModelDestroyed = null;
|
|
10923
|
-
}
|
|
11371
|
+
if (this._entity === entity) {
|
|
11372
|
+
return;
|
|
10924
11373
|
}
|
|
11374
|
+
this._cleanupDestroyedHandlers();
|
|
10925
11375
|
this._entity = entity;
|
|
10926
11376
|
if (this._entity) {
|
|
10927
|
-
if (this._entity
|
|
11377
|
+
if (this._entity.isSceneModelEntity) {
|
|
10928
11378
|
this._onEntityModelDestroyed = this._entity.model.on("destroyed", () => { // SceneModelEntity does not fire events, and cannot exist beyond its VBOSceneModel
|
|
10929
11379
|
this._entity = null; // Marker now may become visible, if it was synched to invisible Entity
|
|
10930
11380
|
this._onEntityModelDestroyed = null;
|
|
@@ -11086,19 +11536,42 @@ class Marker extends Component {
|
|
|
11086
11536
|
this.fire("destroyed", true);
|
|
11087
11537
|
this.scene.camera.off(this._onCameraViewMatrix);
|
|
11088
11538
|
this.scene.camera.off(this._onCameraProjMatrix);
|
|
11539
|
+
this._cleanupDestroyedHandlers();
|
|
11540
|
+
this._renderer.removeMarker(this);
|
|
11541
|
+
super.destroy();
|
|
11542
|
+
}
|
|
11543
|
+
|
|
11544
|
+
_cleanupDestroyedHandlers() {
|
|
11089
11545
|
if (this._entity) {
|
|
11090
11546
|
if (this._onEntityDestroyed !== null) {
|
|
11091
|
-
this._entity.model
|
|
11547
|
+
if (this._entity.model) {
|
|
11548
|
+
this._entity.model.off(this._onEntityDestroyed);
|
|
11549
|
+
} else {
|
|
11550
|
+
this._entity.off(this._onEntityDestroyed);
|
|
11551
|
+
}
|
|
11552
|
+
this._onEntityDestroyed = null;
|
|
11092
11553
|
}
|
|
11093
11554
|
if (this._onEntityModelDestroyed !== null) {
|
|
11094
|
-
this._entity.model
|
|
11555
|
+
if (this._entity.model) {
|
|
11556
|
+
this._entity.model.off(this._onEntityModelDestroyed);
|
|
11557
|
+
}
|
|
11558
|
+
this._onEntityModelDestroyed = null;
|
|
11095
11559
|
}
|
|
11096
11560
|
}
|
|
11097
|
-
this._renderer.removeMarker(this);
|
|
11098
|
-
super.destroy();
|
|
11099
11561
|
}
|
|
11100
11562
|
}
|
|
11101
11563
|
|
|
11564
|
+
const tmpVec2a = math.vec2();
|
|
11565
|
+
const tmpVec2b = math.vec2();
|
|
11566
|
+
const tmpVec2c = math.vec2();
|
|
11567
|
+
const tmpVec2d = math.vec2();
|
|
11568
|
+
const tmpVec3a$2 = math.vec3();
|
|
11569
|
+
const tmpVec3b$2 = math.vec3();
|
|
11570
|
+
const tmpVec4a = math.vec4();
|
|
11571
|
+
const tmpVec4b = math.vec4();
|
|
11572
|
+
const tmpVec4c = math.vec4();
|
|
11573
|
+
const tmpVec4d = math.vec4();
|
|
11574
|
+
|
|
11102
11575
|
const nop = () => { };
|
|
11103
11576
|
|
|
11104
11577
|
function transformToNode(from, to, vec) {
|
|
@@ -11107,10 +11580,124 @@ function transformToNode(from, to, vec) {
|
|
|
11107
11580
|
vec[0] += fromRec.left - toRec.left;
|
|
11108
11581
|
vec[1] += fromRec.top - toRec.top;
|
|
11109
11582
|
}
|
|
11583
|
+
const toClipSpace = (camera, worldPos, p) => {
|
|
11584
|
+
// to homogeneous coords
|
|
11585
|
+
p.set(worldPos);
|
|
11586
|
+
p[3] = 1;
|
|
11587
|
+
|
|
11588
|
+
// to clip space
|
|
11589
|
+
math.mulMat4v4(camera.viewMatrix, p, p);
|
|
11590
|
+
math.mulMat4v4(camera.projMatrix, p, p);
|
|
11591
|
+
};
|
|
11592
|
+
|
|
11593
|
+
const toCanvasSpace = (canvas, parentElement, ndc, p) => {
|
|
11594
|
+
p[0] = (1 + ndc[0]) * 0.5 * canvas.offsetWidth;
|
|
11595
|
+
p[1] = (1 - ndc[1]) * 0.5 * canvas.offsetHeight;
|
|
11596
|
+
transformToNode(canvas, parentElement, p);
|
|
11597
|
+
};
|
|
11598
|
+
|
|
11599
|
+
const clipSegment = (scene, parentElement, start, end, canvasStart, canvasEnd) => {
|
|
11600
|
+
const camera = scene.camera;
|
|
11601
|
+
const canvas = scene.canvas.canvas;
|
|
11602
|
+
|
|
11603
|
+
if (math.distVec3(start, end) < 0.001) {
|
|
11604
|
+
return false;
|
|
11605
|
+
}
|
|
11606
|
+
|
|
11607
|
+
const delta = math.subVec3(end, start, tmpVec3a$2);
|
|
11608
|
+
let s_min = 0.0;
|
|
11609
|
+
let s_max = 1.0;
|
|
11610
|
+
|
|
11611
|
+
for (let plane of scene._sectionPlanesState.sectionPlanes) {
|
|
11612
|
+
const endDot = math.dotVec3(plane.dir, math.subVec3(plane.pos, end, tmpVec3b$2));
|
|
11613
|
+
const startDot = math.dotVec3(plane.dir, math.subVec3(plane.pos, start, tmpVec3b$2));
|
|
11614
|
+
|
|
11615
|
+
if ((startDot > 0) && (endDot > 0)) {
|
|
11616
|
+
return false;
|
|
11617
|
+
} else if ((startDot > 0) || (endDot > 0)) {
|
|
11618
|
+
const denom = math.dotVec3(plane.dir, delta);
|
|
11619
|
+
if (Math.abs(denom) >= 1e-6) {
|
|
11620
|
+
const ratio = math.dotVec3(plane.dir, tmpVec3b$2) / denom;
|
|
11621
|
+
if (startDot > 0) {
|
|
11622
|
+
s_min = Math.max(s_min, ratio);
|
|
11623
|
+
} else {
|
|
11624
|
+
s_max = Math.min(s_max, ratio);
|
|
11625
|
+
}
|
|
11626
|
+
}
|
|
11627
|
+
}
|
|
11628
|
+
}
|
|
11629
|
+
|
|
11630
|
+
const p0 = tmpVec4a;
|
|
11631
|
+
const p1 = tmpVec4b;
|
|
11632
|
+
toClipSpace(camera, (s_min > 0) ? math.addVec3(start, math.mulVec3Scalar(delta, s_min, tmpVec3b$2), tmpVec3b$2) : start, p0);
|
|
11633
|
+
toClipSpace(camera, (s_max < 1) ? math.addVec3(start, math.mulVec3Scalar(delta, s_max, tmpVec3b$2), tmpVec3b$2) : end, p1);
|
|
11634
|
+
|
|
11635
|
+
const p0Behind = ((p0[2] / p0[3]) < -1) || (p0[3] < 0);
|
|
11636
|
+
const p1Behind = ((p1[2] / p1[3]) < -1) || (p1[3] < 0);
|
|
11637
|
+
if (p0Behind && p1Behind) {
|
|
11638
|
+
return false;
|
|
11639
|
+
}
|
|
11640
|
+
|
|
11641
|
+
const t = (p0[3] + p0[2]) / ((p0[3] + p0[2]) - (p1[3] + p1[2]));
|
|
11642
|
+
|
|
11643
|
+
if ((t > 0) && (t < 1)) { //p0Behind || p1Behind) {
|
|
11644
|
+
// Find the intersection of a segment with the near plane in clip space, if it exists."""
|
|
11645
|
+
// Calculate the interpolation factor t where the line segment crosses the near plane
|
|
11646
|
+
const delta = math.subVec4(p1, p0, tmpVec4c);
|
|
11647
|
+
math.mulVec4Scalar(delta, t, delta);
|
|
11648
|
+
math.addVec4(p0, delta, p0Behind ? p0 : p1);
|
|
11649
|
+
}
|
|
11650
|
+
|
|
11651
|
+
// normalize clip space coords
|
|
11652
|
+
math.mulVec4Scalar(p0, 1.0 / p0[3]);
|
|
11653
|
+
math.mulVec4Scalar(p1, 1.0 / p1[3]);
|
|
11654
|
+
|
|
11655
|
+
let t_min = 0.0;
|
|
11656
|
+
let t_max = 1.0;
|
|
11657
|
+
|
|
11658
|
+
// If either point is outside the view frustum, clip the line segment
|
|
11659
|
+
|
|
11660
|
+
for (let i = 0; i < 2; ++i) {
|
|
11661
|
+
const denom = p1[i] - p0[i];
|
|
11662
|
+
|
|
11663
|
+
const l = (-p0[3] - p0[i]) / denom;
|
|
11664
|
+
const r = ( p0[3] - p0[i]) / denom;
|
|
11665
|
+
|
|
11666
|
+
if (denom > 0) {
|
|
11667
|
+
t_min = Math.max(t_min, l);
|
|
11668
|
+
t_max = Math.min(t_max, r);
|
|
11669
|
+
} else {
|
|
11670
|
+
t_min = Math.max(t_min, r);
|
|
11671
|
+
t_max = Math.min(t_max, l);
|
|
11672
|
+
}
|
|
11673
|
+
}
|
|
11674
|
+
|
|
11675
|
+
if (t_min >= t_max) {
|
|
11676
|
+
return false;
|
|
11677
|
+
}
|
|
11678
|
+
|
|
11679
|
+
// Calculate the clipped start and end points
|
|
11680
|
+
const ndcDelta = math.subVec4(p1, p0, tmpVec4c);
|
|
11681
|
+
math.addVec4(p0, math.mulVec4Scalar(ndcDelta, t_max, tmpVec4d), p1);
|
|
11682
|
+
math.addVec4(p0, math.mulVec4Scalar(ndcDelta, t_min, tmpVec4d), p0);
|
|
11683
|
+
|
|
11684
|
+
math.mulVec4Scalar(p0, 1 / p0[3]);
|
|
11685
|
+
math.mulVec4Scalar(p1, 1 / p1[3]);
|
|
11686
|
+
|
|
11687
|
+
toCanvasSpace(canvas, parentElement, p0, canvasStart);
|
|
11688
|
+
toCanvasSpace(canvas, parentElement, p1, canvasEnd);
|
|
11689
|
+
|
|
11690
|
+
return true;
|
|
11691
|
+
};
|
|
11692
|
+
|
|
11110
11693
|
class Dot3D extends Marker {
|
|
11111
11694
|
constructor(scene, markerCfg, parentElement, cfg = {}) {
|
|
11695
|
+
const camera = scene.camera;
|
|
11696
|
+
|
|
11112
11697
|
super(scene, markerCfg);
|
|
11113
11698
|
|
|
11699
|
+
this.__visible = true; // "__" to not interfere with Marker::_visible
|
|
11700
|
+
|
|
11114
11701
|
const handler = (cfgEvent, componentEvent) => {
|
|
11115
11702
|
return event => {
|
|
11116
11703
|
if (cfgEvent) {
|
|
@@ -11120,6 +11707,7 @@ class Dot3D extends Marker {
|
|
|
11120
11707
|
};
|
|
11121
11708
|
};
|
|
11122
11709
|
this._dot = new Dot(parentElement, {
|
|
11710
|
+
borderColor: cfg.borderColor,
|
|
11123
11711
|
fillColor: cfg.fillColor,
|
|
11124
11712
|
zIndex: cfg.zIndex,
|
|
11125
11713
|
onMouseOver: handler(cfg.onMouseOver, "mouseover"),
|
|
@@ -11134,19 +11722,62 @@ class Dot3D extends Marker {
|
|
|
11134
11722
|
onContextMenu: handler(cfg.onContextMenu, "contextmenu")
|
|
11135
11723
|
});
|
|
11136
11724
|
|
|
11725
|
+
const toClipSpace = (worldPos, p) => {
|
|
11726
|
+
// to homogeneous coords
|
|
11727
|
+
p.set(worldPos);
|
|
11728
|
+
p[3] = 1;
|
|
11729
|
+
|
|
11730
|
+
// to clip space
|
|
11731
|
+
math.mulMat4v4(camera.viewMatrix, p, p);
|
|
11732
|
+
math.mulMat4v4(camera.projMatrix, p, p);
|
|
11733
|
+
};
|
|
11734
|
+
|
|
11735
|
+
const toCanvasSpace = ndc => {
|
|
11736
|
+
const canvas = scene.canvas.canvas;
|
|
11737
|
+
ndc[0] = (1 + ndc[0]) * 0.5 * canvas.offsetWidth;
|
|
11738
|
+
ndc[1] = (1 - ndc[1]) * 0.5 * canvas.offsetHeight;
|
|
11739
|
+
transformToNode(canvas, parentElement, ndc);
|
|
11740
|
+
};
|
|
11741
|
+
|
|
11137
11742
|
const updateDotPos = () => {
|
|
11138
|
-
|
|
11139
|
-
|
|
11140
|
-
|
|
11743
|
+
if (! this.__visible) {
|
|
11744
|
+
return;
|
|
11745
|
+
}
|
|
11746
|
+
const p0 = tmpVec4c;
|
|
11747
|
+
toClipSpace(this.worldPos, p0);
|
|
11748
|
+
math.mulVec3Scalar(p0, 1.0 / p0[3]);
|
|
11749
|
+
|
|
11750
|
+
const outsideFrustum = ((p0[3] < 0)
|
|
11751
|
+
||
|
|
11752
|
+
(p0[0] < -1) || (p0[0] > 1)
|
|
11753
|
+
||
|
|
11754
|
+
(p0[1] < -1) || (p0[1] > 1)
|
|
11755
|
+
||
|
|
11756
|
+
(p0[2] < -1) || (p0[2] > 1));
|
|
11757
|
+
const culled = outsideFrustum || scene._sectionPlanesState.sectionPlanes.some(
|
|
11758
|
+
plane => (math.dotVec3(plane.dir, math.subVec3(plane.pos, this.worldPos, tmpVec3a$2)) > 0));
|
|
11759
|
+
|
|
11760
|
+
this._dot.setCulled(culled);
|
|
11761
|
+
if (!culled) {
|
|
11762
|
+
toCanvasSpace(p0);
|
|
11763
|
+
this._dot.setPos(p0[0], p0[1]);
|
|
11764
|
+
}
|
|
11141
11765
|
};
|
|
11142
11766
|
|
|
11143
11767
|
this.on("worldPos", updateDotPos);
|
|
11144
11768
|
|
|
11145
|
-
const onViewMatrix =
|
|
11146
|
-
const onProjMatrix =
|
|
11769
|
+
const onViewMatrix = camera.on("viewMatrix", updateDotPos);
|
|
11770
|
+
const onProjMatrix = camera.on("projMatrix", updateDotPos);
|
|
11771
|
+
const onCanvasBnd = scene.canvas.on("boundary", updateDotPos);
|
|
11772
|
+
const planesUpdate = scene.on("sectionPlaneUpdated", updateDotPos);
|
|
11773
|
+
|
|
11774
|
+
this._updatePosition = updateDotPos;
|
|
11775
|
+
|
|
11147
11776
|
this._cleanup = () => {
|
|
11148
|
-
|
|
11149
|
-
|
|
11777
|
+
camera.off(onViewMatrix);
|
|
11778
|
+
camera.off(onProjMatrix);
|
|
11779
|
+
scene.canvas.off(onCanvasBnd);
|
|
11780
|
+
scene.off(planesUpdate);
|
|
11150
11781
|
this._dot.destroy();
|
|
11151
11782
|
};
|
|
11152
11783
|
}
|
|
@@ -11155,14 +11786,14 @@ class Dot3D extends Marker {
|
|
|
11155
11786
|
this._dot.setClickable(value);
|
|
11156
11787
|
}
|
|
11157
11788
|
|
|
11158
|
-
setCulled(value) {
|
|
11159
|
-
this._dot.setCulled(value);
|
|
11160
|
-
}
|
|
11161
|
-
|
|
11162
11789
|
setFillColor(value) {
|
|
11163
11790
|
this._dot.setFillColor(value);
|
|
11164
11791
|
}
|
|
11165
11792
|
|
|
11793
|
+
setBorderColor(value) {
|
|
11794
|
+
this._dot.setBorderColor(value);
|
|
11795
|
+
}
|
|
11796
|
+
|
|
11166
11797
|
setHighlighted(value) {
|
|
11167
11798
|
this._dot.setHighlighted(value);
|
|
11168
11799
|
}
|
|
@@ -11172,7 +11803,11 @@ class Dot3D extends Marker {
|
|
|
11172
11803
|
}
|
|
11173
11804
|
|
|
11174
11805
|
setVisible(value) {
|
|
11175
|
-
this.
|
|
11806
|
+
if (this.__visible != value) {
|
|
11807
|
+
this.__visible = value;
|
|
11808
|
+
this._updatePosition();
|
|
11809
|
+
this._dot.setVisible(value);
|
|
11810
|
+
}
|
|
11176
11811
|
}
|
|
11177
11812
|
|
|
11178
11813
|
destroy() {
|
|
@@ -11182,6 +11817,189 @@ class Dot3D extends Marker {
|
|
|
11182
11817
|
|
|
11183
11818
|
}
|
|
11184
11819
|
|
|
11820
|
+
class Label3D {
|
|
11821
|
+
constructor(scene, parentElement, cfg) {
|
|
11822
|
+
const camera = scene.camera;
|
|
11823
|
+
|
|
11824
|
+
this._label = new Label(parentElement, cfg);
|
|
11825
|
+
this._start = math.vec3();
|
|
11826
|
+
this._mid = math.vec3();
|
|
11827
|
+
this._end = math.vec3();
|
|
11828
|
+
this._yOff = 0;
|
|
11829
|
+
this._betweenWires = false;
|
|
11830
|
+
this.__visible = true;
|
|
11831
|
+
|
|
11832
|
+
const setPosOnWire = (p0, p1, yOff) => {
|
|
11833
|
+
p0[0] += p1[0];
|
|
11834
|
+
p0[1] += p1[1];
|
|
11835
|
+
math.mulVec2Scalar(p0, .5);
|
|
11836
|
+
this._label.setPos(p0[0], p0[1] + yOff);
|
|
11837
|
+
};
|
|
11838
|
+
|
|
11839
|
+
this._updatePositions = () => {
|
|
11840
|
+
if (! this.__visible) {
|
|
11841
|
+
return;
|
|
11842
|
+
}
|
|
11843
|
+
if (this._betweenWires) {
|
|
11844
|
+
const visibleA = clipSegment(scene, parentElement, this._start, this._mid, tmpVec2a, tmpVec2b);
|
|
11845
|
+
const visibleB = clipSegment(scene, parentElement, this._end, this._mid, tmpVec2c, tmpVec2d);
|
|
11846
|
+
this._label.setCulled(! (visibleA || visibleB));
|
|
11847
|
+
if (visibleA && visibleB) {
|
|
11848
|
+
tmpVec2b[0] += tmpVec2d[0];
|
|
11849
|
+
tmpVec2b[1] += tmpVec2d[1];
|
|
11850
|
+
math.mulVec2Scalar(tmpVec2b, .5);
|
|
11851
|
+
|
|
11852
|
+
tmpVec2b[0] += tmpVec2a[0] + tmpVec2c[0];
|
|
11853
|
+
tmpVec2b[1] += tmpVec2a[1] + tmpVec2c[1];
|
|
11854
|
+
math.mulVec2Scalar(tmpVec2b, 1/3);
|
|
11855
|
+
this._label.setPos(tmpVec2b[0], tmpVec2b[1]);
|
|
11856
|
+
} else if (visibleA) {
|
|
11857
|
+
setPosOnWire(tmpVec2a, tmpVec2b, 0);
|
|
11858
|
+
} else if (visibleB) {
|
|
11859
|
+
setPosOnWire(tmpVec2c, tmpVec2d, 0);
|
|
11860
|
+
}
|
|
11861
|
+
} else {
|
|
11862
|
+
const visible = (clipSegment(scene, parentElement, this._start, this._end, tmpVec2a, tmpVec2b)
|
|
11863
|
+
&&
|
|
11864
|
+
(math.distVec2(tmpVec2a, tmpVec2b) >= this._labelMinAxisLength));
|
|
11865
|
+
this._label.setCulled(!visible);
|
|
11866
|
+
if (visible) {
|
|
11867
|
+
setPosOnWire(tmpVec2a, tmpVec2b, this._yOff);
|
|
11868
|
+
}
|
|
11869
|
+
}
|
|
11870
|
+
};
|
|
11871
|
+
|
|
11872
|
+
const onViewMatrix = camera.on("viewMatrix", this._updatePositions);
|
|
11873
|
+
const onProjMatrix = camera.on("projMatrix", this._updatePositions);
|
|
11874
|
+
const onCanvasBnd = scene.canvas.on("boundary", this._updatePositions);
|
|
11875
|
+
const planesUpdate = scene.on("sectionPlaneUpdated", this._updatePositions);
|
|
11876
|
+
|
|
11877
|
+
this._cleanup = () => {
|
|
11878
|
+
camera.off(onViewMatrix);
|
|
11879
|
+
camera.off(onProjMatrix);
|
|
11880
|
+
scene.canvas.off(onCanvasBnd);
|
|
11881
|
+
scene.off(planesUpdate);
|
|
11882
|
+
this._label.destroy();
|
|
11883
|
+
};
|
|
11884
|
+
}
|
|
11885
|
+
|
|
11886
|
+
setPosOnWire(p0, p1, yOff, labelMinAxisLength) {
|
|
11887
|
+
this._start.set(p0);
|
|
11888
|
+
this._end.set(p1);
|
|
11889
|
+
this._yOff = yOff;
|
|
11890
|
+
this._labelMinAxisLength = labelMinAxisLength;
|
|
11891
|
+
this._betweenWires = false;
|
|
11892
|
+
this._updatePositions();
|
|
11893
|
+
}
|
|
11894
|
+
|
|
11895
|
+
setPosBetween(p0, p1, p2) {
|
|
11896
|
+
this._start.set(p0);
|
|
11897
|
+
this._mid.set(p1);
|
|
11898
|
+
this._end.set(p2);
|
|
11899
|
+
this._betweenWires = true;
|
|
11900
|
+
this._updatePositions();
|
|
11901
|
+
}
|
|
11902
|
+
|
|
11903
|
+
setFillColor(value) {
|
|
11904
|
+
this._label.setFillColor(value);
|
|
11905
|
+
}
|
|
11906
|
+
|
|
11907
|
+
setHighlighted(value) {
|
|
11908
|
+
this._label.setHighlighted(value);
|
|
11909
|
+
}
|
|
11910
|
+
|
|
11911
|
+
setText(value) {
|
|
11912
|
+
this._label.setText(value);
|
|
11913
|
+
}
|
|
11914
|
+
|
|
11915
|
+
setClickable(value) {
|
|
11916
|
+
this._label.setClickable(value);
|
|
11917
|
+
}
|
|
11918
|
+
|
|
11919
|
+
setVisible(value) {
|
|
11920
|
+
if (this.__visible != value) {
|
|
11921
|
+
this.__visible = value;
|
|
11922
|
+
this._updatePositions();
|
|
11923
|
+
this._label.setVisible(value);
|
|
11924
|
+
}
|
|
11925
|
+
}
|
|
11926
|
+
|
|
11927
|
+
destroy() {
|
|
11928
|
+
this._cleanup();
|
|
11929
|
+
}
|
|
11930
|
+
|
|
11931
|
+
}
|
|
11932
|
+
|
|
11933
|
+
class Wire3D {
|
|
11934
|
+
constructor(scene, parentElement, cfg) {
|
|
11935
|
+
const camera = scene.camera;
|
|
11936
|
+
|
|
11937
|
+
this._wire = new Wire(parentElement, cfg);
|
|
11938
|
+
this._start = math.vec3();
|
|
11939
|
+
this._end = math.vec3();
|
|
11940
|
+
this.__visible = true;
|
|
11941
|
+
|
|
11942
|
+
this._updatePositions = () => {
|
|
11943
|
+
if (! this.__visible) {
|
|
11944
|
+
return;
|
|
11945
|
+
}
|
|
11946
|
+
const visible = clipSegment(scene, parentElement, this._start, this._end, tmpVec2a, tmpVec2b);
|
|
11947
|
+
this._wire.setCulled(! visible);
|
|
11948
|
+
if (visible) {
|
|
11949
|
+
this._wire.setStartAndEnd(tmpVec2a[0], tmpVec2a[1], tmpVec2b[0], tmpVec2b[1]);
|
|
11950
|
+
}
|
|
11951
|
+
};
|
|
11952
|
+
|
|
11953
|
+
const onViewMatrix = camera.on("viewMatrix", this._updatePositions);
|
|
11954
|
+
const onProjMatrix = camera.on("projMatrix", this._updatePositions);
|
|
11955
|
+
const onCanvasBnd = scene.canvas.on("boundary", this._updatePositions);
|
|
11956
|
+
const planesUpdate = scene.on("sectionPlaneUpdated", this._updatePositions);
|
|
11957
|
+
|
|
11958
|
+
this._cleanup = () => {
|
|
11959
|
+
camera.off(onViewMatrix);
|
|
11960
|
+
camera.off(onProjMatrix);
|
|
11961
|
+
scene.canvas.off(onCanvasBnd);
|
|
11962
|
+
scene.off(planesUpdate);
|
|
11963
|
+
this._wire.destroy();
|
|
11964
|
+
};
|
|
11965
|
+
}
|
|
11966
|
+
|
|
11967
|
+
setEnds(start, end) {
|
|
11968
|
+
this._start.set(start);
|
|
11969
|
+
this._end.set(end);
|
|
11970
|
+
this._updatePositions();
|
|
11971
|
+
}
|
|
11972
|
+
|
|
11973
|
+
setClickable(value) {
|
|
11974
|
+
this._wire.setClickable(value);
|
|
11975
|
+
}
|
|
11976
|
+
|
|
11977
|
+
setColor(value) {
|
|
11978
|
+
this._wire.setColor(value);
|
|
11979
|
+
}
|
|
11980
|
+
|
|
11981
|
+
setHighlighted(value) {
|
|
11982
|
+
this._wire.setHighlighted(value);
|
|
11983
|
+
}
|
|
11984
|
+
|
|
11985
|
+
setOpacity(value) {
|
|
11986
|
+
this._wire.setOpacity(value);
|
|
11987
|
+
}
|
|
11988
|
+
|
|
11989
|
+
setVisible(value) {
|
|
11990
|
+
if (this.__visible != value) {
|
|
11991
|
+
this.__visible = value;
|
|
11992
|
+
this._updatePositions();
|
|
11993
|
+
this._wire.setVisible(value);
|
|
11994
|
+
}
|
|
11995
|
+
}
|
|
11996
|
+
|
|
11997
|
+
destroy() {
|
|
11998
|
+
this._cleanup();
|
|
11999
|
+
}
|
|
12000
|
+
|
|
12001
|
+
}
|
|
12002
|
+
|
|
11185
12003
|
function activateDraggableDot(dot, cfg) {
|
|
11186
12004
|
const extractCFG = function(propName, defaultValue) {
|
|
11187
12005
|
if (propName in cfg) {
|
|
@@ -11496,469 +12314,8 @@ const touchPointSelector = function(viewer, pointerCircle, ray2WorldPos) {
|
|
|
11496
12314
|
};
|
|
11497
12315
|
};
|
|
11498
12316
|
|
|
11499
|
-
|
|
11500
|
-
|
|
11501
|
-
|
|
11502
|
-
constructor(parentElement, cfg = {}) {
|
|
11503
|
-
|
|
11504
|
-
this._color = cfg.color || "black";
|
|
11505
|
-
this._highlightClass = "viewer-ruler-wire-highlighted";
|
|
11506
|
-
|
|
11507
|
-
this._wire = document.createElement('div');
|
|
11508
|
-
this._wire.className += this._wire.className ? ' viewer-ruler-wire' : 'viewer-ruler-wire';
|
|
11509
|
-
|
|
11510
|
-
this._wireClickable = document.createElement('div');
|
|
11511
|
-
this._wireClickable.className += this._wireClickable.className ? ' viewer-ruler-wire-clickable' : 'viewer-ruler-wire-clickable';
|
|
11512
|
-
|
|
11513
|
-
this._thickness = cfg.thickness || 1.0;
|
|
11514
|
-
this._thicknessClickable = cfg.thicknessClickable || 6.0;
|
|
11515
|
-
|
|
11516
|
-
this._visible = true;
|
|
11517
|
-
this._culled = false;
|
|
11518
|
-
|
|
11519
|
-
var wire = this._wire;
|
|
11520
|
-
var wireStyle = wire.style;
|
|
11521
|
-
|
|
11522
|
-
wireStyle.border = "solid " + this._thickness + "px " + this._color;
|
|
11523
|
-
wireStyle.position = "absolute";
|
|
11524
|
-
wireStyle["z-index"] = cfg.zIndex === undefined ? "2000001" : cfg.zIndex;
|
|
11525
|
-
wireStyle.width = 0 + "px";
|
|
11526
|
-
wireStyle.height = 0 + "px";
|
|
11527
|
-
wireStyle.visibility = "visible";
|
|
11528
|
-
wireStyle.top = 0 + "px";
|
|
11529
|
-
wireStyle.left = 0 + "px";
|
|
11530
|
-
wireStyle['-webkit-transform-origin'] = "0 0";
|
|
11531
|
-
wireStyle['-moz-transform-origin'] = "0 0";
|
|
11532
|
-
wireStyle['-ms-transform-origin'] = "0 0";
|
|
11533
|
-
wireStyle['-o-transform-origin'] = "0 0";
|
|
11534
|
-
wireStyle['transform-origin'] = "0 0";
|
|
11535
|
-
wireStyle['-webkit-transform'] = 'rotate(0deg)';
|
|
11536
|
-
wireStyle['-moz-transform'] = 'rotate(0deg)';
|
|
11537
|
-
wireStyle['-ms-transform'] = 'rotate(0deg)';
|
|
11538
|
-
wireStyle['-o-transform'] = 'rotate(0deg)';
|
|
11539
|
-
wireStyle['transform'] = 'rotate(0deg)';
|
|
11540
|
-
wireStyle["opacity"] = 1.0;
|
|
11541
|
-
wireStyle["pointer-events"] = "none";
|
|
11542
|
-
if (cfg.onContextMenu) ;
|
|
11543
|
-
|
|
11544
|
-
parentElement.appendChild(wire);
|
|
11545
|
-
|
|
11546
|
-
var wireClickable = this._wireClickable;
|
|
11547
|
-
var wireClickableStyle = wireClickable.style;
|
|
11548
|
-
|
|
11549
|
-
wireClickableStyle.border = "solid " + this._thicknessClickable + "px " + this._color;
|
|
11550
|
-
wireClickableStyle.position = "absolute";
|
|
11551
|
-
wireClickableStyle["z-index"] = cfg.zIndex === undefined ? "2000002" : (cfg.zIndex + 1);
|
|
11552
|
-
wireClickableStyle.width = 0 + "px";
|
|
11553
|
-
wireClickableStyle.height = 0 + "px";
|
|
11554
|
-
wireClickableStyle.visibility = "visible";
|
|
11555
|
-
wireClickableStyle.top = 0 + "px";
|
|
11556
|
-
wireClickableStyle.left = 0 + "px";
|
|
11557
|
-
// wireClickableStyle["pointer-events"] = "none";
|
|
11558
|
-
wireClickableStyle['-webkit-transform-origin'] = "0 0";
|
|
11559
|
-
wireClickableStyle['-moz-transform-origin'] = "0 0";
|
|
11560
|
-
wireClickableStyle['-ms-transform-origin'] = "0 0";
|
|
11561
|
-
wireClickableStyle['-o-transform-origin'] = "0 0";
|
|
11562
|
-
wireClickableStyle['transform-origin'] = "0 0";
|
|
11563
|
-
wireClickableStyle['-webkit-transform'] = 'rotate(0deg)';
|
|
11564
|
-
wireClickableStyle['-moz-transform'] = 'rotate(0deg)';
|
|
11565
|
-
wireClickableStyle['-ms-transform'] = 'rotate(0deg)';
|
|
11566
|
-
wireClickableStyle['-o-transform'] = 'rotate(0deg)';
|
|
11567
|
-
wireClickableStyle['transform'] = 'rotate(0deg)';
|
|
11568
|
-
wireClickableStyle["opacity"] = 0.0;
|
|
11569
|
-
wireClickableStyle["pointer-events"] = "none";
|
|
11570
|
-
if (cfg.onContextMenu) ;
|
|
11571
|
-
|
|
11572
|
-
parentElement.appendChild(wireClickable);
|
|
11573
|
-
|
|
11574
|
-
if (cfg.onMouseOver) {
|
|
11575
|
-
wireClickable.addEventListener('mouseover', (event) => {
|
|
11576
|
-
cfg.onMouseOver(event, this);
|
|
11577
|
-
});
|
|
11578
|
-
}
|
|
11579
|
-
|
|
11580
|
-
if (cfg.onMouseLeave) {
|
|
11581
|
-
wireClickable.addEventListener('mouseleave', (event) => {
|
|
11582
|
-
cfg.onMouseLeave(event, this);
|
|
11583
|
-
});
|
|
11584
|
-
}
|
|
11585
|
-
|
|
11586
|
-
if (cfg.onMouseWheel) {
|
|
11587
|
-
wireClickable.addEventListener('wheel', (event) => {
|
|
11588
|
-
cfg.onMouseWheel(event, this);
|
|
11589
|
-
});
|
|
11590
|
-
}
|
|
11591
|
-
|
|
11592
|
-
if (cfg.onMouseDown) {
|
|
11593
|
-
wireClickable.addEventListener('mousedown', (event) => {
|
|
11594
|
-
cfg.onMouseDown(event, this);
|
|
11595
|
-
});
|
|
11596
|
-
}
|
|
11597
|
-
|
|
11598
|
-
if (cfg.onMouseUp) {
|
|
11599
|
-
wireClickable.addEventListener('mouseup', (event) => {
|
|
11600
|
-
cfg.onMouseUp(event, this);
|
|
11601
|
-
});
|
|
11602
|
-
}
|
|
11603
|
-
|
|
11604
|
-
if (cfg.onMouseMove) {
|
|
11605
|
-
wireClickable.addEventListener('mousemove', (event) => {
|
|
11606
|
-
cfg.onMouseMove(event, this);
|
|
11607
|
-
});
|
|
11608
|
-
}
|
|
11609
|
-
|
|
11610
|
-
if (cfg.onContextMenu) {
|
|
11611
|
-
if(os.isIphoneSafari()){
|
|
11612
|
-
wireClickable.addEventListener('touchstart', (event) => {
|
|
11613
|
-
event.preventDefault();
|
|
11614
|
-
if(this._timeout){
|
|
11615
|
-
clearTimeout(this._timeout);
|
|
11616
|
-
this._timeout = null;
|
|
11617
|
-
}
|
|
11618
|
-
this._timeout = setTimeout(() => {
|
|
11619
|
-
event.clientX = event.touches[0].clientX;
|
|
11620
|
-
event.clientY = event.touches[0].clientY;
|
|
11621
|
-
cfg.onContextMenu(event, this);
|
|
11622
|
-
clearTimeout(this._timeout);
|
|
11623
|
-
this._timeout = null;
|
|
11624
|
-
}, 500);
|
|
11625
|
-
});
|
|
11626
|
-
|
|
11627
|
-
wireClickable.addEventListener('touchend', (event) => {
|
|
11628
|
-
event.preventDefault();
|
|
11629
|
-
//stops short touches from calling the timeout
|
|
11630
|
-
if(this._timeout) {
|
|
11631
|
-
clearTimeout(this._timeout);
|
|
11632
|
-
this._timeout = null;
|
|
11633
|
-
}
|
|
11634
|
-
} );
|
|
11635
|
-
|
|
11636
|
-
}
|
|
11637
|
-
else {
|
|
11638
|
-
wireClickable.addEventListener('contextmenu', (event) => {
|
|
11639
|
-
console.log(event);
|
|
11640
|
-
cfg.onContextMenu(event, this);
|
|
11641
|
-
event.preventDefault();
|
|
11642
|
-
event.stopPropagation();
|
|
11643
|
-
console.log("Label context menu");
|
|
11644
|
-
});
|
|
11645
|
-
}
|
|
11646
|
-
|
|
11647
|
-
}
|
|
11648
|
-
|
|
11649
|
-
this._x1 = 0;
|
|
11650
|
-
this._y1 = 0;
|
|
11651
|
-
this._x2 = 0;
|
|
11652
|
-
this._y2 = 0;
|
|
11653
|
-
|
|
11654
|
-
this._update();
|
|
11655
|
-
}
|
|
11656
|
-
|
|
11657
|
-
get visible() {
|
|
11658
|
-
return this._wire.style.visibility === "visible";
|
|
11659
|
-
}
|
|
11660
|
-
|
|
11661
|
-
_update() {
|
|
11662
|
-
|
|
11663
|
-
var length = Math.abs(Math.sqrt((this._x1 - this._x2) * (this._x1 - this._x2) + (this._y1 - this._y2) * (this._y1 - this._y2)));
|
|
11664
|
-
var angle = Math.atan2(this._y2 - this._y1, this._x2 - this._x1) * 180.0 / Math.PI;
|
|
11665
|
-
|
|
11666
|
-
var wireStyle = this._wire.style;
|
|
11667
|
-
wireStyle["width"] = Math.round(length) + 'px';
|
|
11668
|
-
wireStyle["left"] = Math.round(this._x1) + 'px';
|
|
11669
|
-
wireStyle["top"] = Math.round(this._y1) + 'px';
|
|
11670
|
-
wireStyle['-webkit-transform'] = 'rotate(' + angle + 'deg)';
|
|
11671
|
-
wireStyle['-moz-transform'] = 'rotate(' + angle + 'deg)';
|
|
11672
|
-
wireStyle['-ms-transform'] = 'rotate(' + angle + 'deg)';
|
|
11673
|
-
wireStyle['-o-transform'] = 'rotate(' + angle + 'deg)';
|
|
11674
|
-
wireStyle['transform'] = 'rotate(' + angle + 'deg)';
|
|
11675
|
-
|
|
11676
|
-
var wireClickableStyle = this._wireClickable.style;
|
|
11677
|
-
wireClickableStyle["width"] = Math.round(length) + 'px';
|
|
11678
|
-
wireClickableStyle["left"] = Math.round(this._x1) + 'px';
|
|
11679
|
-
wireClickableStyle["top"] = Math.round(this._y1) + 'px';
|
|
11680
|
-
wireClickableStyle['-webkit-transform'] = 'rotate(' + angle + 'deg)';
|
|
11681
|
-
wireClickableStyle['-moz-transform'] = 'rotate(' + angle + 'deg)';
|
|
11682
|
-
wireClickableStyle['-ms-transform'] = 'rotate(' + angle + 'deg)';
|
|
11683
|
-
wireClickableStyle['-o-transform'] = 'rotate(' + angle + 'deg)';
|
|
11684
|
-
wireClickableStyle['transform'] = 'rotate(' + angle + 'deg)';
|
|
11685
|
-
}
|
|
11686
|
-
|
|
11687
|
-
setStartAndEnd(x1, y1, x2, y2) {
|
|
11688
|
-
this._x1 = x1;
|
|
11689
|
-
this._y1 = y1;
|
|
11690
|
-
this._x2 = x2;
|
|
11691
|
-
this._y2 = y2;
|
|
11692
|
-
this._update();
|
|
11693
|
-
}
|
|
11694
|
-
|
|
11695
|
-
setColor(color) {
|
|
11696
|
-
this._color = color || "black";
|
|
11697
|
-
this._wire.style.border = "solid " + this._thickness + "px " + this._color;
|
|
11698
|
-
}
|
|
11699
|
-
|
|
11700
|
-
setOpacity(opacity) {
|
|
11701
|
-
this._wire.style.opacity = opacity;
|
|
11702
|
-
}
|
|
11703
|
-
|
|
11704
|
-
setVisible(visible) {
|
|
11705
|
-
if (this._visible === visible) {
|
|
11706
|
-
return;
|
|
11707
|
-
}
|
|
11708
|
-
this._visible = !!visible;
|
|
11709
|
-
this._wire.style.visibility = this._visible && !this._culled ? "visible" : "hidden";
|
|
11710
|
-
}
|
|
11711
|
-
|
|
11712
|
-
setCulled(culled) {
|
|
11713
|
-
if (this._culled === culled) {
|
|
11714
|
-
return;
|
|
11715
|
-
}
|
|
11716
|
-
this._culled = !!culled;
|
|
11717
|
-
this._wire.style.visibility = this._visible && !this._culled ? "visible" : "hidden";
|
|
11718
|
-
}
|
|
11719
|
-
|
|
11720
|
-
setClickable(clickable) {
|
|
11721
|
-
this._wireClickable.style["pointer-events"] = (clickable) ? "all" : "none";
|
|
11722
|
-
}
|
|
11723
|
-
|
|
11724
|
-
setHighlighted(highlighted) {
|
|
11725
|
-
if (this._highlighted === highlighted) {
|
|
11726
|
-
return;
|
|
11727
|
-
}
|
|
11728
|
-
this._highlighted = !!highlighted;
|
|
11729
|
-
if (this._highlighted) {
|
|
11730
|
-
this._wire.classList.add(this._highlightClass);
|
|
11731
|
-
} else {
|
|
11732
|
-
this._wire.classList.remove(this._highlightClass);
|
|
11733
|
-
}
|
|
11734
|
-
}
|
|
11735
|
-
|
|
11736
|
-
destroy(visible) {
|
|
11737
|
-
if (this._wire.parentElement) {
|
|
11738
|
-
this._wire.parentElement.removeChild(this._wire);
|
|
11739
|
-
}
|
|
11740
|
-
if (this._wireClickable.parentElement) {
|
|
11741
|
-
this._wireClickable.parentElement.removeChild(this._wireClickable);
|
|
11742
|
-
}
|
|
11743
|
-
}
|
|
11744
|
-
}
|
|
11745
|
-
|
|
11746
|
-
/** @private */
|
|
11747
|
-
class Label {
|
|
11748
|
-
|
|
11749
|
-
constructor(parentElement, cfg = {}) {
|
|
11750
|
-
|
|
11751
|
-
this._highlightClass = "viewer-ruler-label-highlighted";
|
|
11752
|
-
|
|
11753
|
-
this._prefix = cfg.prefix || "";
|
|
11754
|
-
this._x = 0;
|
|
11755
|
-
this._y = 0;
|
|
11756
|
-
this._visible = true;
|
|
11757
|
-
this._culled = false;
|
|
11758
|
-
|
|
11759
|
-
this._label = document.createElement('div');
|
|
11760
|
-
this._label.className += this._label.className ? ' viewer-ruler-label' : 'viewer-ruler-label';
|
|
11761
|
-
this._timeout = null;
|
|
11762
|
-
|
|
11763
|
-
var label = this._label;
|
|
11764
|
-
var style = label.style;
|
|
11765
|
-
|
|
11766
|
-
style["border-radius"] = 5 + "px";
|
|
11767
|
-
style.color = "white";
|
|
11768
|
-
style.padding = "4px";
|
|
11769
|
-
style.border = "solid 1px";
|
|
11770
|
-
style.background = "lightgreen";
|
|
11771
|
-
style.position = "absolute";
|
|
11772
|
-
style["z-index"] = cfg.zIndex === undefined ? "5000005" : cfg.zIndex;
|
|
11773
|
-
style.width = "auto";
|
|
11774
|
-
style.height = "auto";
|
|
11775
|
-
style.visibility = "visible";
|
|
11776
|
-
style.top = 0 + "px";
|
|
11777
|
-
style.left = 0 + "px";
|
|
11778
|
-
style["pointer-events"] = "all";
|
|
11779
|
-
style["opacity"] = 1.0;
|
|
11780
|
-
if (cfg.onContextMenu) ;
|
|
11781
|
-
label.innerText = "";
|
|
11782
|
-
|
|
11783
|
-
parentElement.appendChild(label);
|
|
11784
|
-
|
|
11785
|
-
this.setPos(cfg.x || 0, cfg.y || 0);
|
|
11786
|
-
this.setFillColor(cfg.fillColor);
|
|
11787
|
-
this.setBorderColor(cfg.fillColor);
|
|
11788
|
-
this.setText(cfg.text);
|
|
11789
|
-
|
|
11790
|
-
if (cfg.onMouseOver) {
|
|
11791
|
-
label.addEventListener('mouseover', (event) => {
|
|
11792
|
-
cfg.onMouseOver(event, this);
|
|
11793
|
-
event.preventDefault();
|
|
11794
|
-
});
|
|
11795
|
-
}
|
|
11796
|
-
|
|
11797
|
-
if (cfg.onMouseLeave) {
|
|
11798
|
-
label.addEventListener('mouseleave', (event) => {
|
|
11799
|
-
cfg.onMouseLeave(event, this);
|
|
11800
|
-
event.preventDefault();
|
|
11801
|
-
});
|
|
11802
|
-
}
|
|
11803
|
-
|
|
11804
|
-
if (cfg.onMouseWheel) {
|
|
11805
|
-
label.addEventListener('wheel', (event) => {
|
|
11806
|
-
cfg.onMouseWheel(event, this);
|
|
11807
|
-
});
|
|
11808
|
-
}
|
|
11809
|
-
|
|
11810
|
-
if (cfg.onMouseDown) {
|
|
11811
|
-
label.addEventListener('mousedown', (event) => {
|
|
11812
|
-
cfg.onMouseDown(event, this);
|
|
11813
|
-
event.stopPropagation();
|
|
11814
|
-
});
|
|
11815
|
-
}
|
|
11816
|
-
|
|
11817
|
-
if (cfg.onMouseUp) {
|
|
11818
|
-
label.addEventListener('mouseup', (event) => {
|
|
11819
|
-
cfg.onMouseUp(event, this);
|
|
11820
|
-
event.stopPropagation();
|
|
11821
|
-
});
|
|
11822
|
-
}
|
|
11823
|
-
|
|
11824
|
-
if (cfg.onMouseMove) {
|
|
11825
|
-
label.addEventListener('mousemove', (event) => {
|
|
11826
|
-
cfg.onMouseMove(event, this);
|
|
11827
|
-
});
|
|
11828
|
-
}
|
|
11829
|
-
|
|
11830
|
-
if (cfg.onContextMenu) {
|
|
11831
|
-
if(os.isIphoneSafari()){
|
|
11832
|
-
label.addEventListener('touchstart', (event) => {
|
|
11833
|
-
event.preventDefault();
|
|
11834
|
-
if(this._timeout){
|
|
11835
|
-
clearTimeout(this._timeout);
|
|
11836
|
-
this._timeout = null;
|
|
11837
|
-
}
|
|
11838
|
-
this._timeout = setTimeout(() => {
|
|
11839
|
-
event.clientX = event.touches[0].clientX;
|
|
11840
|
-
event.clientY = event.touches[0].clientY;
|
|
11841
|
-
cfg.onContextMenu(event, this);
|
|
11842
|
-
clearTimeout(this._timeout);
|
|
11843
|
-
this._timeout = null;
|
|
11844
|
-
}, 500);
|
|
11845
|
-
});
|
|
11846
|
-
|
|
11847
|
-
label.addEventListener('touchend', (event) => {
|
|
11848
|
-
event.preventDefault();
|
|
11849
|
-
//stops short touches from calling the timeout
|
|
11850
|
-
if(this._timeout) {
|
|
11851
|
-
clearTimeout(this._timeout);
|
|
11852
|
-
this._timeout = null;
|
|
11853
|
-
}
|
|
11854
|
-
} );
|
|
11855
|
-
|
|
11856
|
-
}
|
|
11857
|
-
else {
|
|
11858
|
-
label.addEventListener('contextmenu', (event) => {
|
|
11859
|
-
console.log(event);
|
|
11860
|
-
cfg.onContextMenu(event, this);
|
|
11861
|
-
event.preventDefault();
|
|
11862
|
-
event.stopPropagation();
|
|
11863
|
-
console.log("Label context menu");
|
|
11864
|
-
});
|
|
11865
|
-
}
|
|
11866
|
-
|
|
11867
|
-
}
|
|
11868
|
-
}
|
|
11869
|
-
|
|
11870
|
-
setPos(x, y) {
|
|
11871
|
-
this._x = x;
|
|
11872
|
-
this._y = y;
|
|
11873
|
-
var style = this._label.style;
|
|
11874
|
-
style["left"] = (Math.round(x) - 20) + 'px';
|
|
11875
|
-
style["top"] = (Math.round(y) - 12) + 'px';
|
|
11876
|
-
}
|
|
11877
|
-
|
|
11878
|
-
setPosOnWire(x1, y1, x2, y2) {
|
|
11879
|
-
var x = x1 + ((x2 - x1) * 0.5);
|
|
11880
|
-
var y = y1 + ((y2 - y1) * 0.5);
|
|
11881
|
-
var style = this._label.style;
|
|
11882
|
-
style["left"] = (Math.round(x) - 20) + 'px';
|
|
11883
|
-
style["top"] = (Math.round(y) - 12) + 'px';
|
|
11884
|
-
}
|
|
11885
|
-
|
|
11886
|
-
setPosBetweenWires(x1, y1, x2, y2, x3, y3) {
|
|
11887
|
-
var x = (x1 + x2 + x3) / 3;
|
|
11888
|
-
var y = (y1 + y2 + y3) / 3;
|
|
11889
|
-
var style = this._label.style;
|
|
11890
|
-
style["left"] = (Math.round(x) - 20) + 'px';
|
|
11891
|
-
style["top"] = (Math.round(y) - 12) + 'px';
|
|
11892
|
-
}
|
|
11893
|
-
|
|
11894
|
-
setText(text) {
|
|
11895
|
-
this._label.innerHTML = this._prefix + (text || "");
|
|
11896
|
-
}
|
|
11897
|
-
|
|
11898
|
-
setFillColor(color) {
|
|
11899
|
-
this._fillColor = color || "lightgreen";
|
|
11900
|
-
this._label.style.background =this._fillColor;
|
|
11901
|
-
}
|
|
11902
|
-
|
|
11903
|
-
setBorderColor(color) {
|
|
11904
|
-
this._borderColor = color || "black";
|
|
11905
|
-
this._label.style.border = "solid 1px " + this._borderColor;
|
|
11906
|
-
}
|
|
11907
|
-
|
|
11908
|
-
setOpacity(opacity) {
|
|
11909
|
-
this._label.style.opacity = opacity;
|
|
11910
|
-
}
|
|
11911
|
-
|
|
11912
|
-
setVisible(visible) {
|
|
11913
|
-
if (this._visible === visible) {
|
|
11914
|
-
return;
|
|
11915
|
-
}
|
|
11916
|
-
this._visible = !!visible;
|
|
11917
|
-
this._label.style.visibility = this._visible && !this._culled ? "visible" : "hidden";
|
|
11918
|
-
}
|
|
11919
|
-
|
|
11920
|
-
setCulled(culled) {
|
|
11921
|
-
if (this._culled === culled) {
|
|
11922
|
-
return;
|
|
11923
|
-
}
|
|
11924
|
-
this._culled = !!culled;
|
|
11925
|
-
this._label.style.visibility = this._visible && !this._culled ? "visible" : "hidden";
|
|
11926
|
-
}
|
|
11927
|
-
|
|
11928
|
-
setHighlighted(highlighted) {
|
|
11929
|
-
if (this._highlighted === highlighted) {
|
|
11930
|
-
return;
|
|
11931
|
-
}
|
|
11932
|
-
this._highlighted = !!highlighted;
|
|
11933
|
-
if (this._highlighted) {
|
|
11934
|
-
this._label.classList.add(this._highlightClass);
|
|
11935
|
-
} else {
|
|
11936
|
-
this._label.classList.remove(this._highlightClass);
|
|
11937
|
-
}
|
|
11938
|
-
}
|
|
11939
|
-
|
|
11940
|
-
setClickable(clickable) {
|
|
11941
|
-
this._label.style["pointer-events"] = (clickable) ? "all" : "none";
|
|
11942
|
-
}
|
|
11943
|
-
|
|
11944
|
-
setPrefix(prefix) {
|
|
11945
|
-
if(this._prefix === prefix){
|
|
11946
|
-
return;
|
|
11947
|
-
}
|
|
11948
|
-
this._prefix = prefix;
|
|
11949
|
-
}
|
|
11950
|
-
|
|
11951
|
-
destroy() {
|
|
11952
|
-
if (this._label.parentElement) {
|
|
11953
|
-
this._label.parentElement.removeChild(this._label);
|
|
11954
|
-
}
|
|
11955
|
-
}
|
|
11956
|
-
|
|
11957
|
-
|
|
11958
|
-
}
|
|
11959
|
-
|
|
11960
|
-
var originVec = math.vec3();
|
|
11961
|
-
var targetVec = math.vec3();
|
|
12317
|
+
const tmpVec3a$1 = math.vec3();
|
|
12318
|
+
const tmpVec3b$1 = math.vec3();
|
|
11962
12319
|
|
|
11963
12320
|
/**
|
|
11964
12321
|
* @desc Measures the angle indicated by three 3D points.
|
|
@@ -11972,7 +12329,9 @@ class AngleMeasurement extends Component {
|
|
|
11972
12329
|
*/
|
|
11973
12330
|
constructor(plugin, cfg = {}) {
|
|
11974
12331
|
|
|
11975
|
-
|
|
12332
|
+
const scene = plugin.viewer.scene;
|
|
12333
|
+
|
|
12334
|
+
super(scene, cfg);
|
|
11976
12335
|
|
|
11977
12336
|
/**
|
|
11978
12337
|
* The {@link AngleMeasurementsPlugin} that owns this AngleMeasurement.
|
|
@@ -11980,349 +12339,165 @@ class AngleMeasurement extends Component {
|
|
|
11980
12339
|
*/
|
|
11981
12340
|
this.plugin = plugin;
|
|
11982
12341
|
|
|
11983
|
-
|
|
11984
|
-
if (!
|
|
12342
|
+
const container = cfg.container;
|
|
12343
|
+
if (!container) {
|
|
11985
12344
|
throw "config missing: container";
|
|
11986
12345
|
}
|
|
11987
12346
|
|
|
11988
12347
|
this._color = cfg.color || plugin.defaultColor;
|
|
11989
12348
|
|
|
11990
|
-
|
|
12349
|
+
const channel = function(v) {
|
|
12350
|
+
const listeners = [ ];
|
|
12351
|
+
let value = v !== false;
|
|
12352
|
+
return {
|
|
12353
|
+
reg: (l) => listeners.push(l),
|
|
12354
|
+
get: () => value,
|
|
12355
|
+
set: (v) => {
|
|
12356
|
+
value = v !== false;
|
|
12357
|
+
listeners.forEach(l => l(value));
|
|
12358
|
+
}
|
|
12359
|
+
};
|
|
12360
|
+
};
|
|
11991
12361
|
|
|
11992
|
-
this.
|
|
11993
|
-
this.
|
|
11994
|
-
this.
|
|
12362
|
+
this._visible = channel(cfg.visible);
|
|
12363
|
+
this._originVisible = channel(cfg.originVisible);
|
|
12364
|
+
this._cornerVisible = channel(cfg.cornerVisible);
|
|
12365
|
+
this._targetVisible = channel(cfg.targetVisible);
|
|
12366
|
+
this._originWireVisible = channel(cfg.originWireVisible);
|
|
12367
|
+
this._targetWireVisible = channel(cfg.targetWireVisible);
|
|
12368
|
+
this._angleVisible = channel(cfg.angleVisible);
|
|
12369
|
+
this._labelsVisible = channel();
|
|
12370
|
+
this.labelsVisible = cfg.labelsVisible;
|
|
12371
|
+
this._clickable = channel(false);
|
|
11995
12372
|
|
|
11996
|
-
this.
|
|
11997
|
-
|
|
11998
|
-
|
|
11999
|
-
|
|
12373
|
+
this.approximate = cfg.approximate;
|
|
12374
|
+
|
|
12375
|
+
|
|
12376
|
+
const canvas = scene.canvas.canvas;
|
|
12000
12377
|
|
|
12001
12378
|
const onMouseOver = cfg.onMouseOver ? (event) => {
|
|
12002
12379
|
cfg.onMouseOver(event, this);
|
|
12003
|
-
|
|
12380
|
+
canvas.dispatchEvent(new MouseEvent('mouseover', event));
|
|
12004
12381
|
} : null;
|
|
12005
12382
|
|
|
12006
12383
|
const onMouseLeave = cfg.onMouseLeave ? (event) => {
|
|
12007
12384
|
cfg.onMouseLeave(event, this);
|
|
12008
|
-
|
|
12385
|
+
canvas.dispatchEvent(new MouseEvent('mouseleave', event));
|
|
12009
12386
|
} : null;
|
|
12010
12387
|
|
|
12011
12388
|
const onContextMenu = cfg.onContextMenu ? (event) => {
|
|
12012
12389
|
cfg.onContextMenu(event, this);
|
|
12013
12390
|
} : null;
|
|
12014
12391
|
|
|
12015
|
-
const
|
|
12016
|
-
|
|
12017
|
-
|
|
12392
|
+
const onMouseDown = (event) => canvas.dispatchEvent(new MouseEvent('mousedown', event));
|
|
12393
|
+
const onMouseUp = (event) => canvas.dispatchEvent(new MouseEvent('mouseup', event));
|
|
12394
|
+
const onMouseMove = (event) => canvas.dispatchEvent(new MouseEvent('mousemove', event));
|
|
12395
|
+
const onMouseWheel = (event) => canvas.dispatchEvent(new WheelEvent('wheel', event));
|
|
12018
12396
|
|
|
12019
|
-
const onMouseDown = (event) => {
|
|
12020
|
-
this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent('mousedown', event));
|
|
12021
|
-
} ;
|
|
12022
12397
|
|
|
12023
|
-
|
|
12024
|
-
|
|
12025
|
-
};
|
|
12398
|
+
this._cleanups = [ ];
|
|
12399
|
+
this._drawables = [ ];
|
|
12026
12400
|
|
|
12027
|
-
const
|
|
12028
|
-
|
|
12401
|
+
const registerDrawable = (drawable, visibilityChannels) => {
|
|
12402
|
+
const updateVisibility = () => drawable.setVisible(visibilityChannels.every(ch => ch.get()));
|
|
12403
|
+
visibilityChannels.forEach(ch => ch.reg(updateVisibility));
|
|
12404
|
+
this._drawables.push(drawable);
|
|
12405
|
+
this._cleanups.push(() => drawable.destroy());
|
|
12029
12406
|
};
|
|
12030
12407
|
|
|
12031
|
-
|
|
12032
|
-
|
|
12033
|
-
|
|
12034
|
-
|
|
12035
|
-
|
|
12036
|
-
|
|
12037
|
-
|
|
12038
|
-
|
|
12039
|
-
|
|
12040
|
-
|
|
12041
|
-
|
|
12042
|
-
|
|
12043
|
-
|
|
12044
|
-
|
|
12045
|
-
|
|
12046
|
-
|
|
12047
|
-
|
|
12048
|
-
|
|
12049
|
-
|
|
12050
|
-
|
|
12051
|
-
|
|
12052
|
-
|
|
12053
|
-
|
|
12054
|
-
|
|
12055
|
-
|
|
12056
|
-
|
|
12057
|
-
|
|
12058
|
-
|
|
12059
|
-
|
|
12060
|
-
|
|
12061
|
-
|
|
12062
|
-
|
|
12063
|
-
|
|
12064
|
-
|
|
12065
|
-
|
|
12066
|
-
|
|
12067
|
-
|
|
12068
|
-
|
|
12069
|
-
|
|
12070
|
-
|
|
12071
|
-
|
|
12072
|
-
|
|
12073
|
-
|
|
12074
|
-
|
|
12075
|
-
|
|
12076
|
-
|
|
12077
|
-
|
|
12078
|
-
|
|
12079
|
-
|
|
12080
|
-
|
|
12081
|
-
|
|
12082
|
-
|
|
12083
|
-
|
|
12084
|
-
|
|
12085
|
-
|
|
12086
|
-
|
|
12087
|
-
|
|
12088
|
-
|
|
12089
|
-
|
|
12090
|
-
|
|
12091
|
-
|
|
12092
|
-
|
|
12093
|
-
|
|
12094
|
-
|
|
12095
|
-
onMouseOver,
|
|
12096
|
-
onMouseLeave,
|
|
12097
|
-
onMouseWheel,
|
|
12098
|
-
onMouseDown,
|
|
12099
|
-
onMouseUp,
|
|
12100
|
-
onMouseMove,
|
|
12101
|
-
onContextMenu
|
|
12102
|
-
});
|
|
12103
|
-
|
|
12104
|
-
this._wpDirty = false;
|
|
12105
|
-
this._vpDirty = false;
|
|
12106
|
-
this._cpDirty = false;
|
|
12107
|
-
|
|
12108
|
-
this._visible = false;
|
|
12109
|
-
this._originVisible = false;
|
|
12110
|
-
this._cornerVisible = false;
|
|
12111
|
-
this._targetVisible = false;
|
|
12112
|
-
|
|
12113
|
-
this._originWireVisible = false;
|
|
12114
|
-
this._targetWireVisible = false;
|
|
12115
|
-
|
|
12116
|
-
this._angleVisible = false;
|
|
12117
|
-
this._labelsVisible = false;
|
|
12118
|
-
this._clickable = false;
|
|
12119
|
-
|
|
12120
|
-
this._originDot.on("worldPos", (value) => {
|
|
12121
|
-
this._originWorld.set(value || [0, 0, 0]);
|
|
12122
|
-
this._wpDirty = true;
|
|
12123
|
-
this._needUpdate(0); // No lag
|
|
12124
|
-
});
|
|
12125
|
-
|
|
12126
|
-
this._cornerDot.on("worldPos", (value) => {
|
|
12127
|
-
this._cornerWorld.set(value || [0, 0, 0]);
|
|
12128
|
-
this._wpDirty = true;
|
|
12129
|
-
this._needUpdate(0); // No lag
|
|
12130
|
-
});
|
|
12131
|
-
|
|
12132
|
-
this._targetDot.on("worldPos", (value) => {
|
|
12133
|
-
this._targetWorld.set(value || [0, 0, 0]);
|
|
12134
|
-
this._wpDirty = true;
|
|
12135
|
-
this._needUpdate(0); // No lag
|
|
12136
|
-
});
|
|
12137
|
-
|
|
12138
|
-
this._onViewMatrix = scene.camera.on("viewMatrix", () => {
|
|
12139
|
-
this._vpDirty = true;
|
|
12140
|
-
this._needUpdate(0); // No lag
|
|
12141
|
-
});
|
|
12142
|
-
|
|
12143
|
-
this._onProjMatrix = scene.camera.on("projMatrix", () => {
|
|
12144
|
-
this._cpDirty = true;
|
|
12145
|
-
this._needUpdate();
|
|
12146
|
-
});
|
|
12147
|
-
|
|
12148
|
-
this._onCanvasBoundary = scene.canvas.on("boundary", () => {
|
|
12149
|
-
this._cpDirty = true;
|
|
12150
|
-
this._needUpdate(0); // No lag
|
|
12151
|
-
});
|
|
12152
|
-
|
|
12153
|
-
this._onSectionPlaneUpdated = scene.on("sectionPlaneUpdated", () => {
|
|
12154
|
-
this._sectionPlanesDirty = true;
|
|
12155
|
-
this._needUpdate();
|
|
12156
|
-
});
|
|
12157
|
-
|
|
12158
|
-
this.approximate = cfg.approximate;
|
|
12159
|
-
this.visible = cfg.visible;
|
|
12160
|
-
|
|
12161
|
-
this.originVisible = cfg.originVisible;
|
|
12162
|
-
this.cornerVisible = cfg.cornerVisible;
|
|
12163
|
-
this.targetVisible = cfg.targetVisible;
|
|
12164
|
-
|
|
12165
|
-
this.originWireVisible = cfg.originWireVisible;
|
|
12166
|
-
this.targetWireVisible = cfg.targetWireVisible;
|
|
12408
|
+
const makeWire = (color, thickness, visibilityChannels) => {
|
|
12409
|
+
const wire = new Wire3D(scene, container, {
|
|
12410
|
+
color: color,
|
|
12411
|
+
thickness: thickness,
|
|
12412
|
+
thicknessClickable: 6,
|
|
12413
|
+
zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1 : undefined,
|
|
12414
|
+
onMouseOver,
|
|
12415
|
+
onMouseLeave,
|
|
12416
|
+
onMouseWheel,
|
|
12417
|
+
onMouseDown,
|
|
12418
|
+
onMouseUp,
|
|
12419
|
+
onMouseMove,
|
|
12420
|
+
onContextMenu
|
|
12421
|
+
});
|
|
12422
|
+
registerDrawable(wire, visibilityChannels);
|
|
12423
|
+
return {
|
|
12424
|
+
setEnds: (p0, p1) => wire.setEnds(p0, p1),
|
|
12425
|
+
setColor: value => wire.setColor(value)
|
|
12426
|
+
};
|
|
12427
|
+
};
|
|
12428
|
+
this._originWire = makeWire(this._color || "blue", 1, [ this._visible, this._originWireVisible ]);
|
|
12429
|
+
this._targetWire = makeWire(this._color || "red", 1, [ this._visible, this._targetWireVisible ]);
|
|
12430
|
+
|
|
12431
|
+
const makeLabel = (color, zIndexOffset, visibilityChannels) => {
|
|
12432
|
+
const label = new Label3D(scene, container, {
|
|
12433
|
+
fillColor: color,
|
|
12434
|
+
zIndex: plugin.zIndex + zIndexOffset,
|
|
12435
|
+
onMouseOver,
|
|
12436
|
+
onMouseLeave,
|
|
12437
|
+
onMouseWheel,
|
|
12438
|
+
onMouseDown,
|
|
12439
|
+
onMouseUp,
|
|
12440
|
+
onMouseMove,
|
|
12441
|
+
onContextMenu
|
|
12442
|
+
});
|
|
12443
|
+
registerDrawable(label, visibilityChannels);
|
|
12444
|
+
return {
|
|
12445
|
+
setFillColor: value => label.setFillColor(value),
|
|
12446
|
+
setPosOnWire: (p0, p1, offset) => label.setPosOnWire(p0, p1, offset),
|
|
12447
|
+
setPosBetween: (p0, p1, p2) => label.setPosBetween(p0, p1, p2),
|
|
12448
|
+
setText: str => label.setText(str)
|
|
12449
|
+
};
|
|
12450
|
+
};
|
|
12451
|
+
this._angleLabel = makeLabel(this._color || "#00BBFF", 2, [ this._visible, this._angleVisible, this._labelsVisible ]);
|
|
12452
|
+
|
|
12453
|
+
const makeDot = (cfg, visibilityChannels) => {
|
|
12454
|
+
const dot = new Dot3D(scene, cfg, container, {
|
|
12455
|
+
fillColor: this._color,
|
|
12456
|
+
zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2 : undefined,
|
|
12457
|
+
onMouseOver,
|
|
12458
|
+
onMouseLeave,
|
|
12459
|
+
onMouseWheel,
|
|
12460
|
+
onMouseDown,
|
|
12461
|
+
onMouseUp,
|
|
12462
|
+
onMouseMove,
|
|
12463
|
+
onContextMenu
|
|
12464
|
+
});
|
|
12465
|
+
dot.on("worldPos", () => this._update());
|
|
12466
|
+
registerDrawable(dot, visibilityChannels);
|
|
12467
|
+
return dot;
|
|
12468
|
+
};
|
|
12469
|
+
this._originDot = makeDot(cfg.origin, [ this._visible, this._originVisible ]);
|
|
12470
|
+
this._cornerDot = makeDot(cfg.corner, [ this._visible, this._cornerVisible ]);
|
|
12471
|
+
this._targetDot = makeDot(cfg.target, [ this._visible, this._targetVisible ]);
|
|
12167
12472
|
|
|
12168
|
-
this.
|
|
12169
|
-
this.labelsVisible = cfg.labelsVisible;
|
|
12473
|
+
this._update();
|
|
12170
12474
|
}
|
|
12171
12475
|
|
|
12172
12476
|
_update() {
|
|
12173
|
-
|
|
12174
|
-
if (!this._visible) {
|
|
12477
|
+
if (! this._targetDot) {
|
|
12175
12478
|
return;
|
|
12176
12479
|
}
|
|
12177
12480
|
|
|
12178
|
-
const
|
|
12179
|
-
|
|
12180
|
-
|
|
12181
|
-
|
|
12182
|
-
this._wp[0] = this._originWorld[0];
|
|
12183
|
-
this._wp[1] = this._originWorld[1];
|
|
12184
|
-
this._wp[2] = this._originWorld[2];
|
|
12185
|
-
this._wp[3] = 1.0;
|
|
12186
|
-
|
|
12187
|
-
this._wp[4] = this._cornerWorld[0];
|
|
12188
|
-
this._wp[5] = this._cornerWorld[1];
|
|
12189
|
-
this._wp[6] = this._cornerWorld[2];
|
|
12190
|
-
this._wp[7] = 1.0;
|
|
12191
|
-
|
|
12192
|
-
this._wp[8] = this._targetWorld[0];
|
|
12193
|
-
this._wp[9] = this._targetWorld[1];
|
|
12194
|
-
this._wp[10] = this._targetWorld[2];
|
|
12195
|
-
this._wp[11] = 1.0;
|
|
12196
|
-
|
|
12197
|
-
this._wpDirty = false;
|
|
12198
|
-
this._vpDirty = true;
|
|
12199
|
-
}
|
|
12200
|
-
|
|
12201
|
-
if (this._vpDirty) {
|
|
12202
|
-
|
|
12203
|
-
math.transformPositions4(scene.camera.viewMatrix, this._wp, this._vp);
|
|
12204
|
-
|
|
12205
|
-
this._vp[3] = 1.0;
|
|
12206
|
-
this._vp[7] = 1.0;
|
|
12207
|
-
this._vp[11] = 1.0;
|
|
12208
|
-
|
|
12209
|
-
this._vpDirty = false;
|
|
12210
|
-
this._cpDirty = true;
|
|
12211
|
-
}
|
|
12212
|
-
|
|
12213
|
-
if (this._sectionPlanesDirty) {
|
|
12214
|
-
|
|
12215
|
-
if (this._isSliced(this._wp)) {
|
|
12216
|
-
this._angleLabel.setCulled(true);
|
|
12217
|
-
this._originWire.setCulled(true);
|
|
12218
|
-
this._targetWire.setCulled(true);
|
|
12219
|
-
this._originDot.setCulled(true);
|
|
12220
|
-
this._cornerDot.setCulled(true);
|
|
12221
|
-
this._targetDot.setCulled(true);
|
|
12222
|
-
return;
|
|
12223
|
-
} else {
|
|
12224
|
-
this._angleLabel.setCulled(false);
|
|
12225
|
-
this._originWire.setCulled(false);
|
|
12226
|
-
this._targetWire.setCulled(false);
|
|
12227
|
-
this._originDot.setCulled(false);
|
|
12228
|
-
this._cornerDot.setCulled(false);
|
|
12229
|
-
this._targetDot.setCulled(false);
|
|
12230
|
-
}
|
|
12231
|
-
|
|
12232
|
-
this._sectionPlanesDirty = true;
|
|
12233
|
-
}
|
|
12234
|
-
|
|
12235
|
-
if (this._cpDirty) {
|
|
12236
|
-
|
|
12237
|
-
const near = -0.3;
|
|
12238
|
-
const zOrigin = this._originDot.viewPos[2];
|
|
12239
|
-
const zCorner = this._cornerDot.viewPos[2];
|
|
12240
|
-
const zTarget = this._targetDot.viewPos[2];
|
|
12241
|
-
|
|
12242
|
-
if (zOrigin > near || zCorner > near || zTarget > near) {
|
|
12243
|
-
|
|
12244
|
-
this._originDot.setVisible(false);
|
|
12245
|
-
this._cornerDot.setVisible(false);
|
|
12246
|
-
this._targetDot.setVisible(false);
|
|
12247
|
-
|
|
12248
|
-
this._originWire.setVisible(false);
|
|
12249
|
-
this._targetWire.setVisible(false);
|
|
12250
|
-
|
|
12251
|
-
this._angleLabel.setCulled(true);
|
|
12252
|
-
|
|
12253
|
-
return;
|
|
12254
|
-
}
|
|
12255
|
-
|
|
12256
|
-
math.transformPositions4(scene.camera.project.matrix, this._vp, this._pp);
|
|
12257
|
-
|
|
12258
|
-
var pp = this._pp;
|
|
12259
|
-
var cp = this._cp;
|
|
12260
|
-
|
|
12261
|
-
var canvas = scene.canvas.canvas;
|
|
12262
|
-
var offsets = canvas.getBoundingClientRect();
|
|
12263
|
-
const containerOffsets = this._container.getBoundingClientRect();
|
|
12264
|
-
var top = offsets.top - containerOffsets.top;
|
|
12265
|
-
var left = offsets.left - containerOffsets.left;
|
|
12266
|
-
var aabb = scene.canvas.boundary;
|
|
12267
|
-
var canvasWidth = aabb[2];
|
|
12268
|
-
var canvasHeight = aabb[3];
|
|
12269
|
-
var j = 0;
|
|
12270
|
-
|
|
12271
|
-
for (var i = 0, len = pp.length; i < len; i += 4) {
|
|
12272
|
-
cp[j] = left + Math.floor((1 + pp[i + 0] / pp[i + 3]) * canvasWidth / 2);
|
|
12273
|
-
cp[j + 1] = top + Math.floor((1 - pp[i + 1] / pp[i + 3]) * canvasHeight / 2);
|
|
12274
|
-
j += 2;
|
|
12275
|
-
}
|
|
12276
|
-
|
|
12277
|
-
this._originWire.setStartAndEnd(cp[0], cp[1], cp[2], cp[3]);
|
|
12278
|
-
this._targetWire.setStartAndEnd(cp[2], cp[3], cp[4], cp[5]);
|
|
12279
|
-
|
|
12280
|
-
this._angleLabel.setPosBetweenWires(cp[0], cp[1], cp[2], cp[3], cp[4], cp[5]);
|
|
12281
|
-
|
|
12282
|
-
math.subVec3(this._originWorld, this._cornerWorld, originVec);
|
|
12283
|
-
math.subVec3(this._targetWorld, this._cornerWorld, targetVec);
|
|
12284
|
-
|
|
12285
|
-
var validVecs =
|
|
12286
|
-
(originVec[0] !== 0 || originVec[1] !== 0 || originVec[2] !== 0) &&
|
|
12287
|
-
(targetVec[0] !== 0 || targetVec[1] !== 0 || targetVec[2] !== 0);
|
|
12288
|
-
|
|
12289
|
-
if (validVecs) {
|
|
12290
|
-
|
|
12291
|
-
const tilde = this._approximate ? " ~ " : " = ";
|
|
12292
|
-
|
|
12293
|
-
math.normalizeVec3(originVec);
|
|
12294
|
-
math.normalizeVec3(targetVec);
|
|
12295
|
-
const angle = Math.abs(math.angleVec3(originVec, targetVec));
|
|
12296
|
-
this._angle = angle / math.DEGTORAD;
|
|
12297
|
-
this._angleLabel.setText(tilde + this._angle.toFixed(2) + "°");
|
|
12298
|
-
} else {
|
|
12299
|
-
this._angleLabel.setText("");
|
|
12300
|
-
}
|
|
12481
|
+
const p0 = this._originDot.worldPos;
|
|
12482
|
+
const p1 = this._cornerDot.worldPos;
|
|
12483
|
+
const p2 = this._targetDot.worldPos;
|
|
12301
12484
|
|
|
12302
|
-
|
|
12485
|
+
this._originWire.setEnds(p0, p1);
|
|
12486
|
+
this._targetWire.setEnds(p1, p2);
|
|
12487
|
+
this._angleLabel.setPosBetween(p0, p1, p2);
|
|
12303
12488
|
|
|
12304
|
-
|
|
12305
|
-
|
|
12306
|
-
this._targetDot.setVisible(this._visible && this._targetVisible);
|
|
12489
|
+
math.subVec3(p0, p1, tmpVec3a$1);
|
|
12490
|
+
math.subVec3(p2, p1, tmpVec3b$1);
|
|
12307
12491
|
|
|
12308
|
-
|
|
12309
|
-
|
|
12310
|
-
|
|
12311
|
-
this.
|
|
12312
|
-
|
|
12313
|
-
|
|
12314
|
-
|
|
12315
|
-
|
|
12316
|
-
|
|
12317
|
-
_isSliced(positions) {
|
|
12318
|
-
const sectionPlanes = this.scene._sectionPlanesState.sectionPlanes;
|
|
12319
|
-
for (let i = 0, len = sectionPlanes.length; i < len; i++) {
|
|
12320
|
-
const sectionPlane = sectionPlanes[i];
|
|
12321
|
-
if (math.planeClipsPositions3(sectionPlane.pos, sectionPlane.dir, positions, 4)) {
|
|
12322
|
-
return true
|
|
12323
|
-
}
|
|
12492
|
+
if ((math.lenVec3(tmpVec3a$1) > 0) && (math.lenVec3(tmpVec3b$1) > 0)) {
|
|
12493
|
+
math.normalizeVec3(tmpVec3a$1);
|
|
12494
|
+
math.normalizeVec3(tmpVec3b$1);
|
|
12495
|
+
this._angle = Math.abs(math.angleVec3(tmpVec3a$1, tmpVec3b$1)) * math.RADTODEG;
|
|
12496
|
+
this._angleLabel.setText((this._approximate ? " ~ " : " = ") + this._angle.toFixed(2) + "°");
|
|
12497
|
+
} else {
|
|
12498
|
+
this._angle = undefined;
|
|
12499
|
+
this._angleLabel.setText("");
|
|
12324
12500
|
}
|
|
12325
|
-
return false;
|
|
12326
12501
|
}
|
|
12327
12502
|
|
|
12328
12503
|
/**
|
|
@@ -12338,8 +12513,7 @@ class AngleMeasurement extends Component {
|
|
|
12338
12513
|
return;
|
|
12339
12514
|
}
|
|
12340
12515
|
this._approximate = approximate;
|
|
12341
|
-
this.
|
|
12342
|
-
this._needUpdate(0);
|
|
12516
|
+
this._update();
|
|
12343
12517
|
}
|
|
12344
12518
|
|
|
12345
12519
|
/**
|
|
@@ -12387,7 +12561,6 @@ class AngleMeasurement extends Component {
|
|
|
12387
12561
|
* @type {Number}
|
|
12388
12562
|
*/
|
|
12389
12563
|
get angle() {
|
|
12390
|
-
this._update();
|
|
12391
12564
|
return this._angle;
|
|
12392
12565
|
}
|
|
12393
12566
|
|
|
@@ -12409,14 +12582,13 @@ class AngleMeasurement extends Component {
|
|
|
12409
12582
|
* @type {String}
|
|
12410
12583
|
*/
|
|
12411
12584
|
set color(value) {
|
|
12585
|
+
this._color = value;
|
|
12412
12586
|
this._originDot.setFillColor(value);
|
|
12413
12587
|
this._cornerDot.setFillColor(value);
|
|
12414
12588
|
this._targetDot.setFillColor(value);
|
|
12415
12589
|
this._originWire.setColor(value || "blue");
|
|
12416
12590
|
this._targetWire.setColor(value || "red");
|
|
12417
12591
|
this._angleLabel.setFillColor(value || "#00BBFF");
|
|
12418
|
-
|
|
12419
|
-
this._color = value;
|
|
12420
12592
|
}
|
|
12421
12593
|
|
|
12422
12594
|
/**
|
|
@@ -12425,16 +12597,7 @@ class AngleMeasurement extends Component {
|
|
|
12425
12597
|
* @type {Boolean}
|
|
12426
12598
|
*/
|
|
12427
12599
|
set visible(value) {
|
|
12428
|
-
value
|
|
12429
|
-
this._visible = value;
|
|
12430
|
-
this._originDot.setVisible(this._visible && this._originVisible);
|
|
12431
|
-
this._cornerDot.setVisible(this._visible && this._cornerVisible);
|
|
12432
|
-
this._targetDot.setVisible(this._visible && this._targetVisible);
|
|
12433
|
-
this._originWire.setVisible(this._visible && this._originWireVisible);
|
|
12434
|
-
this._targetWire.setVisible(this._visible && this._targetWireVisible);
|
|
12435
|
-
this._angleLabel.setVisible(this._visible && this._angleVisible);
|
|
12436
|
-
this._cpDirty = true;
|
|
12437
|
-
this._needUpdate();
|
|
12600
|
+
this._visible.set(value);
|
|
12438
12601
|
}
|
|
12439
12602
|
|
|
12440
12603
|
/**
|
|
@@ -12443,7 +12606,7 @@ class AngleMeasurement extends Component {
|
|
|
12443
12606
|
* @type {Boolean}
|
|
12444
12607
|
*/
|
|
12445
12608
|
get visible() {
|
|
12446
|
-
return this._visible;
|
|
12609
|
+
return this._visible.get();
|
|
12447
12610
|
}
|
|
12448
12611
|
|
|
12449
12612
|
/**
|
|
@@ -12452,11 +12615,7 @@ class AngleMeasurement extends Component {
|
|
|
12452
12615
|
* @type {Boolean}
|
|
12453
12616
|
*/
|
|
12454
12617
|
set originVisible(value) {
|
|
12455
|
-
value
|
|
12456
|
-
this._originVisible = value;
|
|
12457
|
-
this._originDot.setVisible(this._visible && this._originVisible);
|
|
12458
|
-
this._cpDirty = true;
|
|
12459
|
-
this._needUpdate();
|
|
12618
|
+
this._originVisible.set(value);
|
|
12460
12619
|
}
|
|
12461
12620
|
|
|
12462
12621
|
/**
|
|
@@ -12465,7 +12624,7 @@ class AngleMeasurement extends Component {
|
|
|
12465
12624
|
* @type {Boolean}
|
|
12466
12625
|
*/
|
|
12467
12626
|
get originVisible() {
|
|
12468
|
-
return this._originVisible;
|
|
12627
|
+
return this._originVisible.get();
|
|
12469
12628
|
}
|
|
12470
12629
|
|
|
12471
12630
|
/**
|
|
@@ -12474,11 +12633,7 @@ class AngleMeasurement extends Component {
|
|
|
12474
12633
|
* @type {Boolean}
|
|
12475
12634
|
*/
|
|
12476
12635
|
set cornerVisible(value) {
|
|
12477
|
-
value
|
|
12478
|
-
this._cornerVisible = value;
|
|
12479
|
-
this._cornerDot.setVisible(this._visible && this._cornerVisible);
|
|
12480
|
-
this._cpDirty = true;
|
|
12481
|
-
this._needUpdate();
|
|
12636
|
+
this._cornerVisible.set(value);
|
|
12482
12637
|
}
|
|
12483
12638
|
|
|
12484
12639
|
/**
|
|
@@ -12487,7 +12642,7 @@ class AngleMeasurement extends Component {
|
|
|
12487
12642
|
* @type {Boolean}
|
|
12488
12643
|
*/
|
|
12489
12644
|
get cornerVisible() {
|
|
12490
|
-
return this._cornerVisible;
|
|
12645
|
+
return this._cornerVisible.get();
|
|
12491
12646
|
}
|
|
12492
12647
|
|
|
12493
12648
|
/**
|
|
@@ -12496,11 +12651,7 @@ class AngleMeasurement extends Component {
|
|
|
12496
12651
|
* @type {Boolean}
|
|
12497
12652
|
*/
|
|
12498
12653
|
set targetVisible(value) {
|
|
12499
|
-
value
|
|
12500
|
-
this._targetVisible = value;
|
|
12501
|
-
this._targetDot.setVisible(this._visible && this._targetVisible);
|
|
12502
|
-
this._cpDirty = true;
|
|
12503
|
-
this._needUpdate();
|
|
12654
|
+
this._targetVisible.set(value);
|
|
12504
12655
|
}
|
|
12505
12656
|
|
|
12506
12657
|
/**
|
|
@@ -12509,7 +12660,7 @@ class AngleMeasurement extends Component {
|
|
|
12509
12660
|
* @type {Boolean}
|
|
12510
12661
|
*/
|
|
12511
12662
|
get targetVisible() {
|
|
12512
|
-
return this._targetVisible;
|
|
12663
|
+
return this._targetVisible.get();
|
|
12513
12664
|
}
|
|
12514
12665
|
|
|
12515
12666
|
/**
|
|
@@ -12518,11 +12669,7 @@ class AngleMeasurement extends Component {
|
|
|
12518
12669
|
* @type {Boolean}
|
|
12519
12670
|
*/
|
|
12520
12671
|
set originWireVisible(value) {
|
|
12521
|
-
value
|
|
12522
|
-
this._originWireVisible = value;
|
|
12523
|
-
this._originWire.setVisible(this._visible && this._originWireVisible);
|
|
12524
|
-
this._cpDirty = true;
|
|
12525
|
-
this._needUpdate();
|
|
12672
|
+
this._originWireVisible.set(value);
|
|
12526
12673
|
}
|
|
12527
12674
|
|
|
12528
12675
|
/**
|
|
@@ -12531,7 +12678,7 @@ class AngleMeasurement extends Component {
|
|
|
12531
12678
|
* @type {Boolean}
|
|
12532
12679
|
*/
|
|
12533
12680
|
get originWireVisible() {
|
|
12534
|
-
return this._originWireVisible;
|
|
12681
|
+
return this._originWireVisible.get();
|
|
12535
12682
|
}
|
|
12536
12683
|
|
|
12537
12684
|
/**
|
|
@@ -12540,11 +12687,7 @@ class AngleMeasurement extends Component {
|
|
|
12540
12687
|
* @type {Boolean}
|
|
12541
12688
|
*/
|
|
12542
12689
|
set targetWireVisible(value) {
|
|
12543
|
-
value
|
|
12544
|
-
this._targetWireVisible = value;
|
|
12545
|
-
this._targetWire.setVisible(this._visible && this._targetWireVisible);
|
|
12546
|
-
this._cpDirty = true;
|
|
12547
|
-
this._needUpdate();
|
|
12690
|
+
this._targetWireVisible.set(value);
|
|
12548
12691
|
}
|
|
12549
12692
|
|
|
12550
12693
|
/**
|
|
@@ -12553,7 +12696,7 @@ class AngleMeasurement extends Component {
|
|
|
12553
12696
|
* @type {Boolean}
|
|
12554
12697
|
*/
|
|
12555
12698
|
get targetWireVisible() {
|
|
12556
|
-
return this._targetWireVisible;
|
|
12699
|
+
return this._targetWireVisible.get();
|
|
12557
12700
|
}
|
|
12558
12701
|
|
|
12559
12702
|
/**
|
|
@@ -12562,11 +12705,7 @@ class AngleMeasurement extends Component {
|
|
|
12562
12705
|
* @type {Boolean}
|
|
12563
12706
|
*/
|
|
12564
12707
|
set angleVisible(value) {
|
|
12565
|
-
value
|
|
12566
|
-
this._angleVisible = value;
|
|
12567
|
-
this._angleLabel.setVisible(this._visible && this._angleVisible);
|
|
12568
|
-
this._cpDirty = true;
|
|
12569
|
-
this._needUpdate();
|
|
12708
|
+
this._angleVisible.set(value);
|
|
12570
12709
|
}
|
|
12571
12710
|
|
|
12572
12711
|
/**
|
|
@@ -12575,7 +12714,7 @@ class AngleMeasurement extends Component {
|
|
|
12575
12714
|
* @type {Boolean}
|
|
12576
12715
|
*/
|
|
12577
12716
|
get angleVisible() {
|
|
12578
|
-
return this._angleVisible;
|
|
12717
|
+
return this._angleVisible.get();
|
|
12579
12718
|
}
|
|
12580
12719
|
|
|
12581
12720
|
/**
|
|
@@ -12584,12 +12723,7 @@ class AngleMeasurement extends Component {
|
|
|
12584
12723
|
* @type {Boolean}
|
|
12585
12724
|
*/
|
|
12586
12725
|
set labelsVisible(value) {
|
|
12587
|
-
value
|
|
12588
|
-
this._labelsVisible = value;
|
|
12589
|
-
var labelsVisible = this._visible && this._labelsVisible;
|
|
12590
|
-
this._angleLabel.setVisible(labelsVisible);
|
|
12591
|
-
this._cpDirty = true;
|
|
12592
|
-
this._needUpdate();
|
|
12726
|
+
this._labelsVisible.set(value !== undefined ? Boolean(value) : this.plugin.defaultLabelsVisible);
|
|
12593
12727
|
}
|
|
12594
12728
|
|
|
12595
12729
|
/**
|
|
@@ -12598,7 +12732,7 @@ class AngleMeasurement extends Component {
|
|
|
12598
12732
|
* @type {Boolean}
|
|
12599
12733
|
*/
|
|
12600
12734
|
get labelsVisible() {
|
|
12601
|
-
return this._labelsVisible;
|
|
12735
|
+
return this._labelsVisible.get();
|
|
12602
12736
|
}
|
|
12603
12737
|
|
|
12604
12738
|
/**
|
|
@@ -12606,12 +12740,7 @@ class AngleMeasurement extends Component {
|
|
|
12606
12740
|
* @param highlighted
|
|
12607
12741
|
*/
|
|
12608
12742
|
setHighlighted(highlighted) {
|
|
12609
|
-
this.
|
|
12610
|
-
this._cornerDot.setHighlighted(highlighted);
|
|
12611
|
-
this._targetDot.setHighlighted(highlighted);
|
|
12612
|
-
this._originWire.setHighlighted(highlighted);
|
|
12613
|
-
this._targetWire.setHighlighted(highlighted);
|
|
12614
|
-
this._angleLabel.setHighlighted(highlighted);
|
|
12743
|
+
this._drawables.forEach(d => d.setHighlighted(highlighted));
|
|
12615
12744
|
}
|
|
12616
12745
|
|
|
12617
12746
|
/**
|
|
@@ -12620,14 +12749,8 @@ class AngleMeasurement extends Component {
|
|
|
12620
12749
|
* @type {Boolean}
|
|
12621
12750
|
*/
|
|
12622
12751
|
set clickable(value) {
|
|
12623
|
-
|
|
12624
|
-
this.
|
|
12625
|
-
this._originDot.setClickable(this._clickable);
|
|
12626
|
-
this._cornerDot.setClickable(this._clickable);
|
|
12627
|
-
this._targetDot.setClickable(this._clickable);
|
|
12628
|
-
this._originWire.setClickable(this._clickable);
|
|
12629
|
-
this._targetWire.setClickable(this._clickable);
|
|
12630
|
-
this._angleLabel.setClickable(this._clickable);
|
|
12752
|
+
this._clickable.set(!!value);
|
|
12753
|
+
this._drawables.forEach(d => d.setClickable(this._clickable.get()));
|
|
12631
12754
|
}
|
|
12632
12755
|
|
|
12633
12756
|
/**
|
|
@@ -12636,38 +12759,14 @@ class AngleMeasurement extends Component {
|
|
|
12636
12759
|
* @type {Boolean}
|
|
12637
12760
|
*/
|
|
12638
12761
|
get clickable() {
|
|
12639
|
-
return this._clickable;
|
|
12762
|
+
return this._clickable.get();
|
|
12640
12763
|
}
|
|
12641
12764
|
|
|
12642
12765
|
/**
|
|
12643
12766
|
* @private
|
|
12644
12767
|
*/
|
|
12645
12768
|
destroy() {
|
|
12646
|
-
|
|
12647
|
-
const scene = this.plugin.viewer.scene;
|
|
12648
|
-
|
|
12649
|
-
if (this._onViewMatrix) {
|
|
12650
|
-
scene.camera.off(this._onViewMatrix);
|
|
12651
|
-
}
|
|
12652
|
-
if (this._onProjMatrix) {
|
|
12653
|
-
scene.camera.off(this._onProjMatrix);
|
|
12654
|
-
}
|
|
12655
|
-
if (this._onCanvasBoundary) {
|
|
12656
|
-
scene.canvas.off(this._onCanvasBoundary);
|
|
12657
|
-
}
|
|
12658
|
-
if (this._onSectionPlaneUpdated) {
|
|
12659
|
-
scene.off(this._onSectionPlaneUpdated);
|
|
12660
|
-
}
|
|
12661
|
-
|
|
12662
|
-
this._originDot.destroy();
|
|
12663
|
-
this._cornerDot.destroy();
|
|
12664
|
-
this._targetDot.destroy();
|
|
12665
|
-
|
|
12666
|
-
this._originWire.destroy();
|
|
12667
|
-
this._targetWire.destroy();
|
|
12668
|
-
|
|
12669
|
-
this._angleLabel.destroy();
|
|
12670
|
-
|
|
12769
|
+
this._cleanups.forEach(cleanup => cleanup());
|
|
12671
12770
|
super.destroy();
|
|
12672
12771
|
}
|
|
12673
12772
|
}
|
|
@@ -13098,7 +13197,7 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
|
|
|
13098
13197
|
mouseHovering = false;
|
|
13099
13198
|
if (pointerLens) {
|
|
13100
13199
|
pointerLens.visible = true;
|
|
13101
|
-
pointerLens.
|
|
13200
|
+
pointerLens.canvasPos = event.canvasPos;
|
|
13102
13201
|
pointerLens.snappedCanvasPos = event.snappedCanvasPos || event.canvasPos;
|
|
13103
13202
|
pointerLens.snapped = false;
|
|
13104
13203
|
}
|
|
@@ -14664,9 +14763,10 @@ class Annotation extends Marker {
|
|
|
14664
14763
|
this._marker.addEventListener("click", this._onMouseClickedExternalMarker = () => {
|
|
14665
14764
|
this.plugin.fire("markerClicked", this);
|
|
14666
14765
|
});
|
|
14667
|
-
this.
|
|
14766
|
+
this._onContextMenuExtenalMarker = () => {
|
|
14668
14767
|
this.plugin.fire("contextmenu", this);
|
|
14669
|
-
}
|
|
14768
|
+
};
|
|
14769
|
+
this._onContextMenuExtenalMarkerRemover = addContextMenuListener(this._markerHTML, this._onContextMenuExtenalMarker);
|
|
14670
14770
|
this._marker.addEventListener("mouseenter", this._onMouseEnterExternalMarker = () => {
|
|
14671
14771
|
this.plugin.fire("markerMouseEnter", this);
|
|
14672
14772
|
});
|
|
@@ -14787,7 +14887,7 @@ class Annotation extends Marker {
|
|
|
14787
14887
|
this._marker.addEventListener("click", () => {
|
|
14788
14888
|
this.plugin.fire("markerClicked", this);
|
|
14789
14889
|
});
|
|
14790
|
-
this._marker
|
|
14890
|
+
addContextMenuListener(this._marker, e => {
|
|
14791
14891
|
e.preventDefault();
|
|
14792
14892
|
this.plugin.fire("contextmenu", this);
|
|
14793
14893
|
});
|
|
@@ -15037,7 +15137,7 @@ class Annotation extends Marker {
|
|
|
15037
15137
|
this._marker = null;
|
|
15038
15138
|
} else {
|
|
15039
15139
|
this._marker.removeEventListener("click", this._onMouseClickedExternalMarker);
|
|
15040
|
-
this.
|
|
15140
|
+
this._onContextMenuExtenalMarkerRemover();
|
|
15041
15141
|
this._marker.removeEventListener("mouseenter", this._onMouseEnterExternalMarker);
|
|
15042
15142
|
this._marker.removeEventListener("mouseleave", this._onMouseLeaveExternalMarker);
|
|
15043
15143
|
this._marker = null;
|
|
@@ -61851,7 +61951,7 @@ class VBOInstancingTrianglesLayer {
|
|
|
61851
61951
|
state.indicesBuf = new ArrayBuf(gl, gl.ELEMENT_ARRAY_BUFFER, new Uint32Array(geometry.indices), geometry.indices.length, 1, gl.STATIC_DRAW);
|
|
61852
61952
|
state.numIndices = geometry.indices.length;
|
|
61853
61953
|
}
|
|
61854
|
-
if (geometry.
|
|
61954
|
+
if (geometry.edgeIndices && geometry.edgeIndices.length > 0) {
|
|
61855
61955
|
state.edgeIndicesBuf = new ArrayBuf(gl, gl.ELEMENT_ARRAY_BUFFER, new Uint32Array(geometry.edgeIndices), geometry.edgeIndices.length, 1, gl.STATIC_DRAW);
|
|
61856
61956
|
}
|
|
61857
61957
|
|
|
@@ -87932,22 +88032,12 @@ function colorizeToRGB(color) {
|
|
|
87932
88032
|
return rgb;
|
|
87933
88033
|
}
|
|
87934
88034
|
|
|
87935
|
-
const
|
|
87936
|
-
const
|
|
87937
|
-
|
|
87938
|
-
|
|
87939
|
-
|
|
87940
|
-
|
|
87941
|
-
return Math.sqrt(a * a + b * b);
|
|
87942
|
-
};
|
|
87943
|
-
|
|
87944
|
-
function determineMeasurementOrientation(A, B, distance) {
|
|
87945
|
-
const yDiff = Math.abs(B[1] - A[1]);
|
|
87946
|
-
|
|
87947
|
-
return yDiff > distance ? 'Vertical' : 'Horizontal';
|
|
87948
|
-
}
|
|
87949
|
-
|
|
87950
|
-
// function findDistance
|
|
88035
|
+
const tmpVec3a = math.vec3();
|
|
88036
|
+
const tmpVec3b = math.vec3();
|
|
88037
|
+
const tmpVec3c = math.vec3();
|
|
88038
|
+
math.vec4();
|
|
88039
|
+
math.vec4();
|
|
88040
|
+
math.vec4();
|
|
87951
88041
|
|
|
87952
88042
|
/**
|
|
87953
88043
|
* @desc Measures the distance between two 3D points.
|
|
@@ -87961,7 +88051,9 @@ class DistanceMeasurement extends Component {
|
|
|
87961
88051
|
*/
|
|
87962
88052
|
constructor(plugin, cfg = {}) {
|
|
87963
88053
|
|
|
87964
|
-
|
|
88054
|
+
const scene = plugin.viewer.scene;
|
|
88055
|
+
|
|
88056
|
+
super(scene, cfg);
|
|
87965
88057
|
|
|
87966
88058
|
/**
|
|
87967
88059
|
* The {@link DistanceMeasurementsPlugin} that owns this DistanceMeasurement.
|
|
@@ -87969,597 +88061,251 @@ class DistanceMeasurement extends Component {
|
|
|
87969
88061
|
*/
|
|
87970
88062
|
this.plugin = plugin;
|
|
87971
88063
|
|
|
87972
|
-
|
|
87973
|
-
if (!
|
|
88064
|
+
const container = cfg.container;
|
|
88065
|
+
if (!container) {
|
|
87974
88066
|
throw "config missing: container";
|
|
87975
88067
|
}
|
|
87976
88068
|
|
|
87977
|
-
this.
|
|
87978
|
-
|
|
87979
|
-
var scene = this.plugin.viewer.scene;
|
|
88069
|
+
this._color = cfg.color || plugin.defaultColor;
|
|
87980
88070
|
|
|
87981
|
-
|
|
87982
|
-
|
|
88071
|
+
const channel = function(v, defaultIfUndefined) {
|
|
88072
|
+
const listeners = [ ];
|
|
88073
|
+
let value = v !== undefined ? Boolean(v) : defaultIfUndefined;
|
|
88074
|
+
return {
|
|
88075
|
+
reg: (l) => listeners.push(l),
|
|
88076
|
+
get: () => value,
|
|
88077
|
+
set: (v) => {
|
|
88078
|
+
value = v !== undefined ? Boolean(v) : defaultIfUndefined;
|
|
88079
|
+
listeners.forEach(l => l(value));
|
|
88080
|
+
}
|
|
88081
|
+
};
|
|
88082
|
+
};
|
|
87983
88083
|
|
|
87984
|
-
this.
|
|
87985
|
-
this.
|
|
87986
|
-
this.
|
|
87987
|
-
this.
|
|
88084
|
+
this._visible = channel(cfg.visible, plugin.defaultVisible);
|
|
88085
|
+
this._originVisible = channel(cfg.originVisible, plugin.defaultOriginVisible);
|
|
88086
|
+
this._targetVisible = channel(cfg.targetVisible, plugin.defaultTargetVisible);
|
|
88087
|
+
this._axisVisible = channel(cfg.axisVisible, plugin.defaultAxisVisible);
|
|
88088
|
+
this._xAxisVisible = channel(cfg.xAxisVisible, plugin.defaultAxisVisible);
|
|
88089
|
+
this._yAxisVisible = channel(cfg.yAxisVisible, plugin.defaultAxisVisible);
|
|
88090
|
+
this._zAxisVisible = channel(cfg.zAxisVisible, plugin.defaultAxisVisible);
|
|
88091
|
+
this._axisEnabled = channel(true, plugin.defaultAxisVisible);
|
|
88092
|
+
this._wireVisible = channel(cfg.wireVisible, plugin.defaultWireVisible);
|
|
88093
|
+
this._xLabelEnabled = channel(cfg.xLabelEnabled, plugin.defaultXLabelEnabled);
|
|
88094
|
+
this._yLabelEnabled = channel(cfg.yLabelEnabled, plugin.defaultYLabelEnabled);
|
|
88095
|
+
this._zLabelEnabled = channel(cfg.zLabelEnabled, plugin.defaultZLabelEnabled);
|
|
88096
|
+
this._lengthLabelEnabled = channel(cfg.lengthLabelEnabled, plugin.defaultLengthLabelEnabled);
|
|
88097
|
+
this._labelsVisible = channel(cfg.labelsVisible, plugin.defaultLabelsVisible);
|
|
88098
|
+
this._clickable = channel(false, false);
|
|
88099
|
+
this._labelsOnWires = channel(cfg.labelsOnWires, plugin.defaultLabelsOnWires);
|
|
88100
|
+
this._useRotationAdjustment = channel(cfg.useRotationAdjustment, plugin.useRotationAdjustment);
|
|
88101
|
+
|
|
88102
|
+
this._axesBasis = math.identityMat4();
|
|
88103
|
+
this.approximate = cfg.approximate;
|
|
87988
88104
|
|
|
87989
|
-
this._xAxisLabelCulled = false;
|
|
87990
|
-
this._yAxisLabelCulled = false;
|
|
87991
|
-
this._zAxisLabelCulled = false;
|
|
87992
88105
|
|
|
87993
|
-
|
|
88106
|
+
const canvas = scene.canvas.canvas;
|
|
87994
88107
|
|
|
87995
88108
|
const onMouseOver = cfg.onMouseOver ? (event) => {
|
|
87996
88109
|
cfg.onMouseOver(event, this);
|
|
87997
|
-
|
|
88110
|
+
canvas.dispatchEvent(new MouseEvent('mouseover', event));
|
|
87998
88111
|
} : null;
|
|
87999
88112
|
|
|
88000
88113
|
const onMouseLeave = cfg.onMouseLeave ? (event) => {
|
|
88001
88114
|
cfg.onMouseLeave(event, this);
|
|
88002
|
-
|
|
88115
|
+
canvas.dispatchEvent(new MouseEvent('mouseleave', event));
|
|
88003
88116
|
} : null;
|
|
88004
88117
|
|
|
88005
|
-
const onMouseDown = (event) => {
|
|
88006
|
-
this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent('mousedown', event));
|
|
88007
|
-
} ;
|
|
88008
|
-
|
|
88009
|
-
const onMouseUp = (event) => {
|
|
88010
|
-
this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent('mouseup', event));
|
|
88011
|
-
};
|
|
88012
|
-
|
|
88013
|
-
const onMouseMove = (event) => {
|
|
88014
|
-
this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent('mousemove', event));
|
|
88015
|
-
};
|
|
88016
|
-
|
|
88017
88118
|
const onContextMenu = cfg.onContextMenu ? (event) => {
|
|
88018
88119
|
cfg.onContextMenu(event, this);
|
|
88019
88120
|
} : null;
|
|
88020
88121
|
|
|
88021
|
-
const
|
|
88022
|
-
|
|
88023
|
-
|
|
88122
|
+
const onMouseDown = (event) => canvas.dispatchEvent(new MouseEvent('mousedown', event));
|
|
88123
|
+
const onMouseUp = (event) => canvas.dispatchEvent(new MouseEvent('mouseup', event));
|
|
88124
|
+
const onMouseMove = (event) => canvas.dispatchEvent(new MouseEvent('mousemove', event));
|
|
88125
|
+
const onMouseWheel = (event) => canvas.dispatchEvent(new WheelEvent('wheel', event));
|
|
88024
88126
|
|
|
88025
|
-
this._originDot = new Dot3D(scene, cfg.origin, this._container, {
|
|
88026
|
-
fillColor: this._color,
|
|
88027
|
-
zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2 : undefined,
|
|
88028
|
-
onMouseOver,
|
|
88029
|
-
onMouseLeave,
|
|
88030
|
-
onMouseWheel,
|
|
88031
|
-
onMouseDown,
|
|
88032
|
-
onMouseUp,
|
|
88033
|
-
onMouseMove,
|
|
88034
|
-
onContextMenu
|
|
88035
|
-
});
|
|
88036
88127
|
|
|
88037
|
-
this.
|
|
88038
|
-
fillColor: this._color,
|
|
88039
|
-
zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2 : undefined,
|
|
88040
|
-
onMouseOver,
|
|
88041
|
-
onMouseLeave,
|
|
88042
|
-
onMouseWheel,
|
|
88043
|
-
onMouseDown,
|
|
88044
|
-
onMouseUp,
|
|
88045
|
-
onMouseMove,
|
|
88046
|
-
onContextMenu
|
|
88047
|
-
});
|
|
88128
|
+
this._cleanups = [ ];
|
|
88048
88129
|
|
|
88049
|
-
|
|
88050
|
-
|
|
88051
|
-
|
|
88052
|
-
thicknessClickable: 6,
|
|
88053
|
-
zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1 : undefined,
|
|
88054
|
-
onMouseOver,
|
|
88055
|
-
onMouseLeave,
|
|
88056
|
-
onMouseWheel,
|
|
88057
|
-
onMouseDown,
|
|
88058
|
-
onMouseUp,
|
|
88059
|
-
onMouseMove,
|
|
88060
|
-
onContextMenu
|
|
88130
|
+
[ "units", "scale" ].forEach(evt => {
|
|
88131
|
+
const handler = scene.metrics.on("units", () => this._update());
|
|
88132
|
+
this._cleanups.push(() => scene.metrics.off(handler));
|
|
88061
88133
|
});
|
|
88062
88134
|
|
|
88063
|
-
this.
|
|
88064
|
-
color: "#FF0000",
|
|
88065
|
-
thickness: 1,
|
|
88066
|
-
thicknessClickable: 6,
|
|
88067
|
-
zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1 : undefined,
|
|
88068
|
-
onMouseOver,
|
|
88069
|
-
onMouseLeave,
|
|
88070
|
-
onMouseWheel,
|
|
88071
|
-
onMouseDown,
|
|
88072
|
-
onMouseUp,
|
|
88073
|
-
onMouseMove,
|
|
88074
|
-
onContextMenu
|
|
88075
|
-
});
|
|
88135
|
+
this._drawables = [ ];
|
|
88076
88136
|
|
|
88077
|
-
|
|
88078
|
-
|
|
88079
|
-
|
|
88080
|
-
|
|
88081
|
-
|
|
88082
|
-
|
|
88083
|
-
onMouseLeave,
|
|
88084
|
-
onMouseWheel,
|
|
88085
|
-
onMouseDown,
|
|
88086
|
-
onMouseUp,
|
|
88087
|
-
onMouseMove,
|
|
88088
|
-
onContextMenu
|
|
88089
|
-
});
|
|
88090
|
-
|
|
88091
|
-
this._zAxisWire = new Wire(this._container, {
|
|
88092
|
-
color: "blue",
|
|
88093
|
-
thickness: 1,
|
|
88094
|
-
thicknessClickable: 6,
|
|
88095
|
-
zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1 : undefined,
|
|
88096
|
-
onMouseOver,
|
|
88097
|
-
onMouseLeave,
|
|
88098
|
-
onMouseWheel,
|
|
88099
|
-
onMouseDown,
|
|
88100
|
-
onMouseUp,
|
|
88101
|
-
onMouseMove,
|
|
88102
|
-
onContextMenu
|
|
88103
|
-
});
|
|
88137
|
+
const registerDrawable = (drawable, visibilityChannels) => {
|
|
88138
|
+
const updateVisibility = () => drawable.setVisible(visibilityChannels.every(ch => ch.get()));
|
|
88139
|
+
visibilityChannels.forEach(ch => ch.reg(updateVisibility));
|
|
88140
|
+
this._drawables.push(drawable);
|
|
88141
|
+
this._cleanups.push(() => drawable.destroy());
|
|
88142
|
+
};
|
|
88104
88143
|
|
|
88105
|
-
|
|
88106
|
-
|
|
88107
|
-
|
|
88108
|
-
|
|
88109
|
-
|
|
88110
|
-
|
|
88111
|
-
|
|
88112
|
-
|
|
88113
|
-
|
|
88114
|
-
|
|
88115
|
-
|
|
88116
|
-
|
|
88117
|
-
|
|
88144
|
+
const makeWire = (color, thickness, visibilityChannels) => {
|
|
88145
|
+
const wire = new Wire3D(scene, container, {
|
|
88146
|
+
color: color,
|
|
88147
|
+
thickness: thickness,
|
|
88148
|
+
thicknessClickable: 6,
|
|
88149
|
+
zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 1 : undefined,
|
|
88150
|
+
onMouseOver,
|
|
88151
|
+
onMouseLeave,
|
|
88152
|
+
onMouseWheel,
|
|
88153
|
+
onMouseDown,
|
|
88154
|
+
onMouseUp,
|
|
88155
|
+
onMouseMove,
|
|
88156
|
+
onContextMenu
|
|
88157
|
+
});
|
|
88158
|
+
registerDrawable(wire, visibilityChannels);
|
|
88159
|
+
return {
|
|
88160
|
+
setEnds: (p0, p1) => wire.setEnds(p0, p1),
|
|
88161
|
+
setColor: value => wire.setColor(value)
|
|
88162
|
+
};
|
|
88163
|
+
};
|
|
88164
|
+
this._lengthWire = makeWire(this._color, 2, [ this._visible, this._wireVisible ]);
|
|
88165
|
+
this._xAxisWire = makeWire("red", 1, [ this._visible, this._axisEnabled, this._axisVisible, this._xAxisVisible ]);
|
|
88166
|
+
this._yAxisWire = makeWire("green", 1, [ this._visible, this._axisEnabled, this._axisVisible, this._yAxisVisible ]);
|
|
88167
|
+
this._zAxisWire = makeWire("blue", 1, [ this._visible, this._axisEnabled, this._axisVisible, this._zAxisVisible ]);
|
|
88168
|
+
|
|
88169
|
+
const makeLabel = (color, zIndexOffset, visibilityChannels) => {
|
|
88170
|
+
const label = new Label3D(scene, container, {
|
|
88171
|
+
fillColor: color,
|
|
88172
|
+
zIndex: plugin.zIndex !== undefined ? plugin.zIndex + zIndexOffset : undefined,
|
|
88173
|
+
onMouseOver,
|
|
88174
|
+
onMouseLeave,
|
|
88175
|
+
onMouseWheel,
|
|
88176
|
+
onMouseDown,
|
|
88177
|
+
onMouseUp,
|
|
88178
|
+
onMouseMove,
|
|
88179
|
+
onContextMenu
|
|
88180
|
+
});
|
|
88181
|
+
registerDrawable(label, visibilityChannels);
|
|
88182
|
+
return {
|
|
88183
|
+
setFillColor: value => label.setFillColor(value),
|
|
88184
|
+
setPosOnWire: (p0, p1, offset, labelMinAxisLength) => label.setPosOnWire(p0, p1, offset, labelMinAxisLength),
|
|
88185
|
+
setPosBetween: (p0, p1, p2) => label.setPosBetween(p0, p1, p2),
|
|
88186
|
+
setText: str => label.setText(str.replace(/ /g, " "))
|
|
88187
|
+
};
|
|
88188
|
+
};
|
|
88189
|
+
this._lengthLabel = makeLabel(this._color, 4, [ this._visible, this._wireVisible, this._labelsVisible, this._clickable, this._axisEnabled, this._lengthLabelEnabled ]);
|
|
88190
|
+
this._xAxisLabel = makeLabel("red", 3, [ this._visible, this._axisEnabled, this._axisVisible, this._xAxisVisible, this._labelsVisible, this._clickable, this._xLabelEnabled ]);
|
|
88191
|
+
this._yAxisLabel = makeLabel("green", 3, [ this._visible, this._axisEnabled, this._axisVisible, this._yAxisVisible, this._labelsVisible, this._clickable, this._yLabelEnabled ]);
|
|
88192
|
+
this._zAxisLabel = makeLabel("blue", 3, [ this._visible, this._axisEnabled, this._axisVisible, this._zAxisVisible, this._labelsVisible, this._clickable, this._zLabelEnabled ]);
|
|
88193
|
+
|
|
88194
|
+
const makeDot = (cfg, visibilityChannels) => {
|
|
88195
|
+
const dot = new Dot3D(scene, cfg, container, {
|
|
88196
|
+
fillColor: this._color,
|
|
88197
|
+
zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2 : undefined,
|
|
88198
|
+
onMouseOver,
|
|
88199
|
+
onMouseLeave,
|
|
88200
|
+
onMouseWheel,
|
|
88201
|
+
onMouseDown,
|
|
88202
|
+
onMouseUp,
|
|
88203
|
+
onMouseMove,
|
|
88204
|
+
onContextMenu
|
|
88205
|
+
});
|
|
88206
|
+
dot.on("worldPos", () => this._update());
|
|
88207
|
+
registerDrawable(dot, visibilityChannels);
|
|
88208
|
+
return dot;
|
|
88209
|
+
};
|
|
88210
|
+
this._originDot = makeDot(cfg.origin, [ this._visible, this._originVisible ]);
|
|
88211
|
+
this._targetDot = makeDot(cfg.target, [ this._visible, this._targetVisible ]);
|
|
88118
88212
|
|
|
88119
|
-
this.
|
|
88120
|
-
|
|
88121
|
-
prefix: "X",
|
|
88122
|
-
text: "",
|
|
88123
|
-
zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 3 : undefined,
|
|
88124
|
-
onMouseOver,
|
|
88125
|
-
onMouseLeave,
|
|
88126
|
-
onMouseWheel,
|
|
88127
|
-
onMouseDown,
|
|
88128
|
-
onMouseUp,
|
|
88129
|
-
onMouseMove,
|
|
88130
|
-
onContextMenu
|
|
88131
|
-
});
|
|
88213
|
+
this._update();
|
|
88214
|
+
}
|
|
88132
88215
|
|
|
88133
|
-
|
|
88134
|
-
|
|
88135
|
-
|
|
88136
|
-
|
|
88137
|
-
zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 3 : undefined,
|
|
88138
|
-
onMouseOver,
|
|
88139
|
-
onMouseLeave,
|
|
88140
|
-
onMouseWheel,
|
|
88141
|
-
onMouseDown,
|
|
88142
|
-
onMouseUp,
|
|
88143
|
-
onMouseMove,
|
|
88144
|
-
onContextMenu
|
|
88145
|
-
});
|
|
88216
|
+
_update() {
|
|
88217
|
+
if (! this._targetDot) {
|
|
88218
|
+
return;
|
|
88219
|
+
}
|
|
88146
88220
|
|
|
88147
|
-
|
|
88148
|
-
|
|
88149
|
-
|
|
88150
|
-
|
|
88151
|
-
|
|
88152
|
-
onMouseOver,
|
|
88153
|
-
onMouseLeave,
|
|
88154
|
-
onMouseWheel,
|
|
88155
|
-
onMouseDown,
|
|
88156
|
-
onMouseUp,
|
|
88157
|
-
onMouseMove,
|
|
88158
|
-
onContextMenu
|
|
88159
|
-
});
|
|
88221
|
+
const p0 = this._originDot.worldPos;
|
|
88222
|
+
const p1 = this._targetDot.worldPos;
|
|
88223
|
+
const axesBasis = this._axesBasis;
|
|
88224
|
+
const delta = math.subVec3(p1, p0, tmpVec3a);
|
|
88225
|
+
const factors = math.transformVec3(axesBasis, delta, delta);
|
|
88160
88226
|
|
|
88161
|
-
this.
|
|
88162
|
-
this._wpDirty = false;
|
|
88163
|
-
this._vpDirty = false;
|
|
88164
|
-
this._cpDirty = false;
|
|
88165
|
-
this._sectionPlanesDirty = true;
|
|
88227
|
+
const measurementOrientationVertical = this._useRotationAdjustment.get() && Math.abs(delta[1]) > 0;
|
|
88166
88228
|
|
|
88167
|
-
|
|
88168
|
-
this._originVisible = false;
|
|
88169
|
-
this._targetVisible = false;
|
|
88170
|
-
this._useRotationAdjustment = false;
|
|
88171
|
-
this._wireVisible = false;
|
|
88172
|
-
this._axisVisible = false;
|
|
88173
|
-
this._xAxisVisible = false;
|
|
88174
|
-
this._yAxisVisible = false;
|
|
88175
|
-
this._zAxisVisible = false;
|
|
88176
|
-
this._axisEnabled = true;
|
|
88177
|
-
this._xLabelEnabled = false;
|
|
88178
|
-
this._yLabelEnabled = false;
|
|
88179
|
-
this._zLabelEnabled = false;
|
|
88180
|
-
this._lengthLabelEnabled = false;
|
|
88181
|
-
this._labelsVisible = false;
|
|
88182
|
-
this._labelsOnWires = false;
|
|
88183
|
-
this._clickable = false;
|
|
88184
|
-
|
|
88185
|
-
this._originDot.on("worldPos", (value) => {
|
|
88186
|
-
this._originWorld.set(value || [0,0,0]);
|
|
88187
|
-
this._wpDirty = true;
|
|
88188
|
-
this._needUpdate(0); // No lag
|
|
88189
|
-
});
|
|
88229
|
+
const setWireCoordinates = (xEnd, zStart) => {
|
|
88190
88230
|
|
|
88191
|
-
|
|
88192
|
-
|
|
88193
|
-
|
|
88194
|
-
this._needUpdate(0); // No lag
|
|
88195
|
-
});
|
|
88231
|
+
const metrics = this.plugin.viewer.scene.metrics;
|
|
88232
|
+
const scale = metrics.scale;
|
|
88233
|
+
const unit = metrics.unitsInfo[metrics.units].abbrev;
|
|
88196
88234
|
|
|
88197
|
-
|
|
88198
|
-
|
|
88199
|
-
|
|
88200
|
-
|
|
88235
|
+
const setAxisLabelCoords = (label, a, b, offsetIdx) => {
|
|
88236
|
+
if (this._labelsOnWires.get()) {
|
|
88237
|
+
label.setPosOnWire(a, b, 0, this.plugin.labelMinAxisLength);
|
|
88238
|
+
} else {
|
|
88239
|
+
label.setPosOnWire(p0, p1, offsetIdx * 35, 0);
|
|
88240
|
+
}
|
|
88241
|
+
};
|
|
88242
|
+
const unitStr = len => (this._approximate ? " ~ " : " = ") + len.toFixed(2) + unit;
|
|
88201
88243
|
|
|
88202
|
-
|
|
88203
|
-
this.
|
|
88204
|
-
this.
|
|
88205
|
-
});
|
|
88244
|
+
this._xAxisWire.setEnds(p0, xEnd);
|
|
88245
|
+
setAxisLabelCoords(this._xAxisLabel, p0, xEnd, 1);
|
|
88246
|
+
this._xAxisLabel.setText("X" + unitStr(math.distVec3(p0, xEnd) * scale));
|
|
88206
88247
|
|
|
88207
|
-
|
|
88208
|
-
this.
|
|
88209
|
-
this.
|
|
88210
|
-
});
|
|
88248
|
+
this._yAxisWire.setEnds(xEnd, zStart);
|
|
88249
|
+
setAxisLabelCoords(this._yAxisLabel, xEnd, zStart, 2);
|
|
88250
|
+
this._yAxisLabel.setText("Y" + unitStr(math.distVec3(xEnd, zStart) * scale));
|
|
88211
88251
|
|
|
88212
|
-
|
|
88213
|
-
this.
|
|
88214
|
-
this.
|
|
88215
|
-
});
|
|
88252
|
+
this._zAxisWire.setEnds(zStart, p1);
|
|
88253
|
+
setAxisLabelCoords(this._zAxisLabel, zStart, p1, 3);
|
|
88254
|
+
this._zAxisLabel.setText((measurementOrientationVertical ? "" : "Z") + unitStr(math.distVec3(zStart, p1) * scale));
|
|
88216
88255
|
|
|
88217
|
-
|
|
88218
|
-
this.
|
|
88219
|
-
this.
|
|
88220
|
-
|
|
88256
|
+
this._lengthWire.setEnds(p0, p1);
|
|
88257
|
+
setAxisLabelCoords(this._lengthLabel, p0, p1, 0);
|
|
88258
|
+
this._length = math.distVec3(p0, p1) * scale;
|
|
88259
|
+
this._lengthLabel.setText(unitStr(this._length));
|
|
88260
|
+
};
|
|
88221
88261
|
|
|
88222
|
-
|
|
88223
|
-
|
|
88224
|
-
|
|
88225
|
-
|
|
88262
|
+
if (measurementOrientationVertical) {
|
|
88263
|
+
tmpVec3c[0] = p0[0];
|
|
88264
|
+
tmpVec3c[1] = p1[1];
|
|
88265
|
+
tmpVec3c[2] = p0[2];
|
|
88226
88266
|
|
|
88227
|
-
|
|
88228
|
-
|
|
88229
|
-
|
|
88230
|
-
|
|
88267
|
+
setWireCoordinates(p0, tmpVec3c);
|
|
88268
|
+
}
|
|
88269
|
+
else {
|
|
88270
|
+
tmpVec3b[0] = p0[0] + axesBasis[0] * factors[0];
|
|
88271
|
+
tmpVec3b[1] = p0[1] + axesBasis[4] * factors[0];
|
|
88272
|
+
tmpVec3b[2] = p0[2] + axesBasis[8] * factors[0];
|
|
88231
88273
|
|
|
88232
|
-
|
|
88233
|
-
|
|
88234
|
-
|
|
88235
|
-
this.targetVisible = cfg.targetVisible;
|
|
88236
|
-
this.wireVisible = cfg.wireVisible;
|
|
88237
|
-
this.axisVisible = cfg.axisVisible;
|
|
88238
|
-
this.xAxisVisible = cfg.xAxisVisible;
|
|
88239
|
-
this.yAxisVisible = cfg.yAxisVisible;
|
|
88240
|
-
this.zAxisVisible = cfg.zAxisVisible;
|
|
88241
|
-
this.xLabelEnabled = cfg.xLabelEnabled;
|
|
88242
|
-
this.yLabelEnabled = cfg.yLabelEnabled;
|
|
88243
|
-
this.zLabelEnabled = cfg.zLabelEnabled;
|
|
88244
|
-
this.lengthLabelEnabled = cfg.lengthLabelEnabled;
|
|
88245
|
-
this.labelsVisible = cfg.labelsVisible;
|
|
88246
|
-
this.labelsOnWires = cfg.labelsOnWires;
|
|
88247
|
-
this._useRotationAdjustment = cfg.useRotationAdjustment;
|
|
88274
|
+
tmpVec3c[0] = tmpVec3b[0] + axesBasis[1] * factors[1];
|
|
88275
|
+
tmpVec3c[1] = tmpVec3b[1] + axesBasis[5] * factors[1];
|
|
88276
|
+
tmpVec3c[2] = tmpVec3b[2] + axesBasis[9] * factors[1];
|
|
88248
88277
|
|
|
88249
|
-
|
|
88250
|
-
|
|
88251
|
-
*/
|
|
88252
|
-
this._axesBasis = [
|
|
88253
|
-
1, 0, 0, 0,
|
|
88254
|
-
0, 1, 0, 0,
|
|
88255
|
-
0, 0, 1, 0,
|
|
88256
|
-
0, 0, 0, 1,
|
|
88257
|
-
];
|
|
88278
|
+
setWireCoordinates(tmpVec3b, tmpVec3c);
|
|
88279
|
+
}
|
|
88258
88280
|
}
|
|
88259
88281
|
|
|
88260
88282
|
/**
|
|
88261
88283
|
* Sets the axes basis for the measurement.
|
|
88262
|
-
*
|
|
88284
|
+
*
|
|
88263
88285
|
* The value is a 4x4 matrix where each column-vector defines an axis and must have unit length.
|
|
88264
|
-
*
|
|
88286
|
+
*
|
|
88265
88287
|
* This is the ```identity``` matrix by default, meaning the measurement axes are the same as the world axes.
|
|
88266
|
-
*
|
|
88267
|
-
* @param {number[]} value
|
|
88288
|
+
*
|
|
88289
|
+
* @param {number[]} value
|
|
88268
88290
|
*/
|
|
88269
88291
|
set axesBasis(value) {
|
|
88270
|
-
this._axesBasis
|
|
88271
|
-
this.
|
|
88272
|
-
this._needUpdate(0); // No lag
|
|
88292
|
+
this._axesBasis.set(value);
|
|
88293
|
+
this._update();
|
|
88273
88294
|
}
|
|
88274
88295
|
|
|
88275
88296
|
/**
|
|
88276
88297
|
* Gets the axes basis for the measurement.
|
|
88277
|
-
*
|
|
88298
|
+
*
|
|
88278
88299
|
* The value is a 4x4 matrix where each column-vector defines an axis and must have unit length.
|
|
88279
|
-
*
|
|
88300
|
+
*
|
|
88280
88301
|
* This is the ```identity``` matrix by default, meaning the measurement axes are the same as the world axes.
|
|
88281
|
-
*
|
|
88302
|
+
*
|
|
88282
88303
|
* @type {number[]}
|
|
88283
88304
|
*/
|
|
88284
88305
|
get axesBasis() {
|
|
88285
88306
|
return this._axesBasis;
|
|
88286
88307
|
}
|
|
88287
88308
|
|
|
88288
|
-
_update() {
|
|
88289
|
-
|
|
88290
|
-
if (!this._visible) {
|
|
88291
|
-
return;
|
|
88292
|
-
}
|
|
88293
|
-
|
|
88294
|
-
const scene = this.plugin.viewer.scene;
|
|
88295
|
-
|
|
88296
|
-
if (this._wpDirty) {
|
|
88297
|
-
const delta = math.subVec3(
|
|
88298
|
-
this._targetWorld,
|
|
88299
|
-
this._originWorld,
|
|
88300
|
-
tmpVec3
|
|
88301
|
-
);
|
|
88302
|
-
|
|
88303
|
-
/**
|
|
88304
|
-
* The length detected for each measurement axis.
|
|
88305
|
-
*/
|
|
88306
|
-
this._factors = math.transformVec3(this._axesBasis, delta);
|
|
88307
|
-
|
|
88308
|
-
this._measurementOrientation = determineMeasurementOrientation(this._originWorld, this._targetWorld, 0);
|
|
88309
|
-
if (this._measurementOrientation === 'Vertical' && this._useRotationAdjustment) {
|
|
88310
|
-
this._wp[0] = this._originWorld[0];
|
|
88311
|
-
this._wp[1] = this._originWorld[1];
|
|
88312
|
-
this._wp[2] = this._originWorld[2];
|
|
88313
|
-
this._wp[3] = 1.0;
|
|
88314
|
-
|
|
88315
|
-
this._wp[4] = this._originWorld[0]; //x-axis
|
|
88316
|
-
this._wp[5] = this._originWorld[1];
|
|
88317
|
-
this._wp[6] = this._originWorld[2];
|
|
88318
|
-
this._wp[7] = 1.0;
|
|
88319
|
-
|
|
88320
|
-
this._wp[8] = this._originWorld[0]; //x-axis
|
|
88321
|
-
this._wp[9] = this._targetWorld[1]; //y-axis
|
|
88322
|
-
this._wp[10] = this._originWorld[2];
|
|
88323
|
-
this._wp[11] = 1.0;
|
|
88324
|
-
|
|
88325
|
-
this._wp[12] = this._targetWorld[0];
|
|
88326
|
-
this._wp[13] = this._targetWorld[1];
|
|
88327
|
-
this._wp[14] = this._targetWorld[2];
|
|
88328
|
-
this._wp[15] = 1.0;
|
|
88329
|
-
}
|
|
88330
|
-
else {
|
|
88331
|
-
|
|
88332
|
-
this._wp[0] = this._originWorld[0];
|
|
88333
|
-
this._wp[1] = this._originWorld[1];
|
|
88334
|
-
this._wp[2] = this._originWorld[2];
|
|
88335
|
-
this._wp[3] = 1.0;
|
|
88336
|
-
|
|
88337
|
-
this._wp[4] = this._originWorld[0] + this._axesBasis[0]*this._factors[0];
|
|
88338
|
-
this._wp[5] = this._originWorld[1] + this._axesBasis[4]*this._factors[0];
|
|
88339
|
-
this._wp[6] = this._originWorld[2] + this._axesBasis[8]*this._factors[0];
|
|
88340
|
-
this._wp[7] = 1.0;
|
|
88341
|
-
|
|
88342
|
-
this._wp[8] = this._originWorld[0] + this._axesBasis[0]*this._factors[0]+ this._axesBasis[1]*this._factors[1];
|
|
88343
|
-
this._wp[9] = this._originWorld[1] + this._axesBasis[4]*this._factors[0]+ this._axesBasis[5]*this._factors[1];
|
|
88344
|
-
this._wp[10] = this._originWorld[2] + this._axesBasis[8]*this._factors[0]+ this._axesBasis[9]*this._factors[1]; this._wp[11] = 1.0;
|
|
88345
|
-
|
|
88346
|
-
this._wp[12] = this._targetWorld[0];
|
|
88347
|
-
this._wp[13] = this._targetWorld[1];
|
|
88348
|
-
this._wp[14] = this._targetWorld[2];
|
|
88349
|
-
this._wp[15] = 1.0;
|
|
88350
|
-
}
|
|
88351
|
-
|
|
88352
|
-
|
|
88353
|
-
this._wpDirty = false;
|
|
88354
|
-
this._vpDirty = true;
|
|
88355
|
-
}
|
|
88356
|
-
|
|
88357
|
-
if (this._vpDirty) {
|
|
88358
|
-
|
|
88359
|
-
math.transformPositions4(scene.camera.viewMatrix, this._wp, this._vp);
|
|
88360
|
-
|
|
88361
|
-
this._vp[3] = 1.0;
|
|
88362
|
-
this._vp[7] = 1.0;
|
|
88363
|
-
this._vp[11] = 1.0;
|
|
88364
|
-
this._vp[15] = 1.0;
|
|
88365
|
-
|
|
88366
|
-
this._vpDirty = false;
|
|
88367
|
-
this._cpDirty = true;
|
|
88368
|
-
}
|
|
88369
|
-
|
|
88370
|
-
if (this._sectionPlanesDirty) {
|
|
88371
|
-
|
|
88372
|
-
if (this._isSliced(this._originWorld) || this._isSliced(this._targetWorld)) {
|
|
88373
|
-
this._xAxisLabel.setCulled(true);
|
|
88374
|
-
this._yAxisLabel.setCulled(true);
|
|
88375
|
-
this._zAxisLabel.setCulled(true);
|
|
88376
|
-
this._lengthLabel.setCulled(true);
|
|
88377
|
-
this._xAxisWire.setCulled(true);
|
|
88378
|
-
this._yAxisWire.setCulled(true);
|
|
88379
|
-
this._zAxisWire.setCulled(true);
|
|
88380
|
-
this._lengthWire.setCulled(true);
|
|
88381
|
-
this._originDot.setCulled(true);
|
|
88382
|
-
this._targetDot.setCulled(true);
|
|
88383
|
-
return;
|
|
88384
|
-
} else {
|
|
88385
|
-
this._xAxisLabel.setCulled(false);
|
|
88386
|
-
this._yAxisLabel.setCulled(false);
|
|
88387
|
-
this._zAxisLabel.setCulled(false);
|
|
88388
|
-
this._lengthLabel.setCulled(false);
|
|
88389
|
-
this._xAxisWire.setCulled(false);
|
|
88390
|
-
this._yAxisWire.setCulled(false);
|
|
88391
|
-
this._zAxisWire.setCulled(false);
|
|
88392
|
-
this._lengthWire.setCulled(false);
|
|
88393
|
-
this._originDot.setCulled(false);
|
|
88394
|
-
this._targetDot.setCulled(false);
|
|
88395
|
-
}
|
|
88396
|
-
|
|
88397
|
-
this._sectionPlanesDirty = true;
|
|
88398
|
-
}
|
|
88399
|
-
|
|
88400
|
-
const near = -0.3;
|
|
88401
|
-
const vpz1 = this._originDot.viewPos[2];
|
|
88402
|
-
const vpz2 = this._targetDot.viewPos[2];
|
|
88403
|
-
|
|
88404
|
-
if (vpz1 > near || vpz2 > near) {
|
|
88405
|
-
|
|
88406
|
-
this._xAxisLabel.setCulled(true);
|
|
88407
|
-
this._yAxisLabel.setCulled(true);
|
|
88408
|
-
this._zAxisLabel.setCulled(true);
|
|
88409
|
-
this._lengthLabel.setCulled(true);
|
|
88410
|
-
|
|
88411
|
-
this._xAxisWire.setVisible(false);
|
|
88412
|
-
this._yAxisWire.setVisible(false);
|
|
88413
|
-
this._zAxisWire.setVisible(false);
|
|
88414
|
-
this._lengthWire.setVisible(false);
|
|
88415
|
-
|
|
88416
|
-
this._originDot.setVisible(false);
|
|
88417
|
-
this._targetDot.setVisible(false);
|
|
88418
|
-
|
|
88419
|
-
return;
|
|
88420
|
-
}
|
|
88421
|
-
|
|
88422
|
-
if (this._cpDirty) {
|
|
88423
|
-
|
|
88424
|
-
math.transformPositions4(scene.camera.project.matrix, this._vp, this._pp);
|
|
88425
|
-
|
|
88426
|
-
var pp = this._pp;
|
|
88427
|
-
var cp = this._cp;
|
|
88428
|
-
|
|
88429
|
-
var canvas = scene.canvas.canvas;
|
|
88430
|
-
var offsets = canvas.getBoundingClientRect();
|
|
88431
|
-
const containerOffsets = this._container.getBoundingClientRect();
|
|
88432
|
-
var top = offsets.top - containerOffsets.top;
|
|
88433
|
-
var left = offsets.left - containerOffsets.left;
|
|
88434
|
-
var aabb = scene.canvas.boundary;
|
|
88435
|
-
var canvasWidth = aabb[2];
|
|
88436
|
-
var canvasHeight = aabb[3];
|
|
88437
|
-
var j = 0;
|
|
88438
|
-
|
|
88439
|
-
const metrics = this.plugin.viewer.scene.metrics;
|
|
88440
|
-
const scale = metrics.scale;
|
|
88441
|
-
const units = metrics.units;
|
|
88442
|
-
const unitInfo = metrics.unitsInfo[units];
|
|
88443
|
-
const unitAbbrev = unitInfo.abbrev;
|
|
88444
|
-
|
|
88445
|
-
for (var i = 0, len = pp.length; i < len; i += 4) {
|
|
88446
|
-
cp[j] = left + Math.floor((1 + pp[i + 0] / pp[i + 3]) * canvasWidth / 2);
|
|
88447
|
-
cp[j + 1] = top + Math.floor((1 - pp[i + 1] / pp[i + 3]) * canvasHeight / 2);
|
|
88448
|
-
j += 2;
|
|
88449
|
-
}
|
|
88450
|
-
|
|
88451
|
-
this._lengthWire.setStartAndEnd(cp[0], cp[1], cp[6], cp[7]);
|
|
88452
|
-
|
|
88453
|
-
this._xAxisWire.setStartAndEnd(cp[0], cp[1], cp[2], cp[3]);
|
|
88454
|
-
this._yAxisWire.setStartAndEnd(cp[2], cp[3], cp[4], cp[5]);
|
|
88455
|
-
this._zAxisWire.setStartAndEnd(cp[4], cp[5], cp[6], cp[7]);
|
|
88456
|
-
|
|
88457
|
-
if (!this.labelsVisible) {
|
|
88458
|
-
|
|
88459
|
-
this._lengthLabel.setCulled(true);
|
|
88460
|
-
|
|
88461
|
-
this._xAxisLabel.setCulled(true);
|
|
88462
|
-
this._yAxisLabel.setCulled(true);
|
|
88463
|
-
this._zAxisLabel.setCulled(true);
|
|
88464
|
-
|
|
88465
|
-
} else {
|
|
88466
|
-
|
|
88467
|
-
this._lengthLabel.setPosOnWire(cp[0], cp[1], cp[6], cp[7]);
|
|
88468
|
-
|
|
88469
|
-
if (this.labelsOnWires) {
|
|
88470
|
-
this._xAxisLabel.setPosOnWire(cp[0], cp[1], cp[2], cp[3]);
|
|
88471
|
-
this._yAxisLabel.setPosOnWire(cp[2], cp[3], cp[4], cp[5]);
|
|
88472
|
-
this._zAxisLabel.setPosOnWire(cp[4], cp[5], cp[6], cp[7]);
|
|
88473
|
-
} else {
|
|
88474
|
-
const labelOffset = 35;
|
|
88475
|
-
let currentLabelOffset = labelOffset;
|
|
88476
|
-
this._xAxisLabel.setPosOnWire(cp[0], cp[1] + currentLabelOffset, cp[6], cp[7] + currentLabelOffset);
|
|
88477
|
-
currentLabelOffset += labelOffset;
|
|
88478
|
-
this._yAxisLabel.setPosOnWire(cp[0], cp[1] + currentLabelOffset, cp[6], cp[7] + currentLabelOffset);
|
|
88479
|
-
currentLabelOffset += labelOffset;
|
|
88480
|
-
this._zAxisLabel.setPosOnWire(cp[0], cp[1] + currentLabelOffset, cp[6], cp[7] + currentLabelOffset);
|
|
88481
|
-
}
|
|
88482
|
-
|
|
88483
|
-
const tilde = this._approximate ? " ~ " : " = ";
|
|
88484
|
-
|
|
88485
|
-
this._length = Math.abs(math.lenVec3(math.subVec3(this._targetWorld, this._originWorld, distVec3)));
|
|
88486
|
-
this._lengthLabel.setText(tilde + (this._length * scale).toFixed(2) + unitAbbrev);
|
|
88487
|
-
|
|
88488
|
-
const xAxisCanvasLength = Math.abs(lengthWire(cp[0], cp[1], cp[2], cp[3]));
|
|
88489
|
-
const yAxisCanvasLength = Math.abs(lengthWire(cp[2], cp[3], cp[4], cp[5]));
|
|
88490
|
-
const zAxisCanvasLength = Math.abs(lengthWire(cp[4], cp[5], cp[6], cp[7]));
|
|
88491
|
-
|
|
88492
|
-
const labelMinAxisLength = this.plugin.labelMinAxisLength;
|
|
88493
|
-
|
|
88494
|
-
if (this.labelsOnWires){
|
|
88495
|
-
this._xAxisLabelCulled = (xAxisCanvasLength < labelMinAxisLength);
|
|
88496
|
-
this._yAxisLabelCulled = (yAxisCanvasLength < labelMinAxisLength);
|
|
88497
|
-
this._zAxisLabelCulled = (zAxisCanvasLength < labelMinAxisLength);
|
|
88498
|
-
} else {
|
|
88499
|
-
this._xAxisLabelCulled = false;
|
|
88500
|
-
this._yAxisLabelCulled = false;
|
|
88501
|
-
this._zAxisLabelCulled = false;
|
|
88502
|
-
}
|
|
88503
|
-
|
|
88504
|
-
if (!this._xAxisLabelCulled) {
|
|
88505
|
-
this._xAxisLabel.setText(tilde + Math.abs(this._factors[0] * scale).toFixed(2) + unitAbbrev);
|
|
88506
|
-
this._xAxisLabel.setCulled(!this.axisVisible);
|
|
88507
|
-
} else {
|
|
88508
|
-
this._xAxisLabel.setCulled(true);
|
|
88509
|
-
}
|
|
88510
|
-
|
|
88511
|
-
if (!this._yAxisLabelCulled) {
|
|
88512
|
-
this._yAxisLabel.setText(tilde + Math.abs(this._factors[1] * scale).toFixed(2) + unitAbbrev);
|
|
88513
|
-
this._yAxisLabel.setCulled(!this.axisVisible);
|
|
88514
|
-
} else {
|
|
88515
|
-
this._yAxisLabel.setCulled(true);
|
|
88516
|
-
}
|
|
88517
|
-
|
|
88518
|
-
if (!this._zAxisLabelCulled) {
|
|
88519
|
-
if (this._measurementOrientation === 'Vertical' && this._useRotationAdjustment) {
|
|
88520
|
-
this._zAxisLabel.setPrefix("");
|
|
88521
|
-
this._zAxisLabel.setText(tilde + Math.abs(math.lenVec3(math.subVec3(this._targetWorld, [this._originWorld[0], this._targetWorld[1], this._originWorld[2]], distVec3)) * scale).toFixed(2) + unitAbbrev);
|
|
88522
|
-
}
|
|
88523
|
-
else {
|
|
88524
|
-
this._zAxisLabel.setPrefix("Z");
|
|
88525
|
-
this._zAxisLabel.setText(tilde + Math.abs(this._factors[2] * scale).toFixed(2) + unitAbbrev);
|
|
88526
|
-
}
|
|
88527
|
-
this._zAxisLabel.setCulled(!this.axisVisible);
|
|
88528
|
-
} else {
|
|
88529
|
-
this._zAxisLabel.setCulled(true);
|
|
88530
|
-
}
|
|
88531
|
-
}
|
|
88532
|
-
|
|
88533
|
-
// this._xAxisLabel.setVisible(this.axisVisible && this.xAxisVisible);
|
|
88534
|
-
// this._yAxisLabel.setVisible(this.axisVisible && this.yAxisVisible);
|
|
88535
|
-
// this._zAxisLabel.setVisible(this.axisVisible && this.zAxisVisible);
|
|
88536
|
-
// this._lengthLabel.setVisible(false);
|
|
88537
|
-
|
|
88538
|
-
this._originDot.setVisible(this._visible && this._originVisible);
|
|
88539
|
-
this._targetDot.setVisible(this._visible && this._targetVisible);
|
|
88540
|
-
|
|
88541
|
-
this._xAxisWire.setVisible(this.axisVisible && this.xAxisVisible);
|
|
88542
|
-
this._yAxisWire.setVisible(this.axisVisible && this.yAxisVisible);
|
|
88543
|
-
this._zAxisWire.setVisible(this.axisVisible && this.zAxisVisible);
|
|
88544
|
-
|
|
88545
|
-
this._lengthWire.setVisible(this.wireVisible);
|
|
88546
|
-
this._lengthLabel.setCulled(!this.wireVisible);
|
|
88547
|
-
|
|
88548
|
-
this._cpDirty = false;
|
|
88549
|
-
}
|
|
88550
|
-
}
|
|
88551
|
-
|
|
88552
|
-
_isSliced(positions) {
|
|
88553
|
-
const sectionPlanes = this.scene._sectionPlanesState.sectionPlanes;
|
|
88554
|
-
for (let i = 0, len = sectionPlanes.length; i < len; i++) {
|
|
88555
|
-
const sectionPlane = sectionPlanes[i];
|
|
88556
|
-
if (math.planeClipsPositions3(sectionPlane.pos, sectionPlane.dir, positions, 4)) {
|
|
88557
|
-
return true
|
|
88558
|
-
}
|
|
88559
|
-
}
|
|
88560
|
-
return false;
|
|
88561
|
-
}
|
|
88562
|
-
|
|
88563
88309
|
/**
|
|
88564
88310
|
* Sets whether this DistanceMeasurement indicates that its measurement is approximate.
|
|
88565
88311
|
*
|
|
@@ -88573,8 +88319,7 @@ class DistanceMeasurement extends Component {
|
|
|
88573
88319
|
return;
|
|
88574
88320
|
}
|
|
88575
88321
|
this._approximate = approximate;
|
|
88576
|
-
this.
|
|
88577
|
-
this._needUpdate(0);
|
|
88322
|
+
this._update();
|
|
88578
88323
|
}
|
|
88579
88324
|
|
|
88580
88325
|
/**
|
|
@@ -88612,9 +88357,7 @@ class DistanceMeasurement extends Component {
|
|
|
88612
88357
|
* @type {Number}
|
|
88613
88358
|
*/
|
|
88614
88359
|
get length() {
|
|
88615
|
-
this.
|
|
88616
|
-
const scale = this.plugin.viewer.scene.metrics.scale;
|
|
88617
|
-
return this._length * scale;
|
|
88360
|
+
return this._length;
|
|
88618
88361
|
}
|
|
88619
88362
|
|
|
88620
88363
|
get color() {
|
|
@@ -88635,31 +88378,7 @@ class DistanceMeasurement extends Component {
|
|
|
88635
88378
|
* @type {Boolean}
|
|
88636
88379
|
*/
|
|
88637
88380
|
set visible(value) {
|
|
88638
|
-
|
|
88639
|
-
value = value !== undefined ? Boolean(value) : this.plugin.defaultVisible;
|
|
88640
|
-
|
|
88641
|
-
this._visible = value;
|
|
88642
|
-
|
|
88643
|
-
this._originDot.setVisible(this._visible && this._originVisible);
|
|
88644
|
-
this._targetDot.setVisible(this._visible && this._targetVisible);
|
|
88645
|
-
this._lengthWire.setVisible(this._visible && this._wireVisible);
|
|
88646
|
-
this._lengthLabel.setVisible(this._visible && this._wireVisible && this._lengthLabelEnabled);
|
|
88647
|
-
|
|
88648
|
-
const xAxisVisible = this._visible && this._axisVisible && this._xAxisVisible;
|
|
88649
|
-
const yAxisVisible = this._visible && this._axisVisible && this._yAxisVisible;
|
|
88650
|
-
const zAxisVisible = this._visible && this._axisVisible && this._zAxisVisible;
|
|
88651
|
-
|
|
88652
|
-
this._xAxisWire.setVisible(xAxisVisible);
|
|
88653
|
-
this._yAxisWire.setVisible(yAxisVisible);
|
|
88654
|
-
this._zAxisWire.setVisible(zAxisVisible);
|
|
88655
|
-
|
|
88656
|
-
this._xAxisLabel.setVisible(xAxisVisible && !this._xAxisLabelCulled && this._EnabledVisible);
|
|
88657
|
-
this._yAxisLabel.setVisible(yAxisVisible && !this._yAxisLabelCulled && this._yLabelEnabled);
|
|
88658
|
-
this._zAxisLabel.setVisible(zAxisVisible && !this._zAxisLabelCulled && this._zLabelEnabled);
|
|
88659
|
-
|
|
88660
|
-
this._cpDirty = true;
|
|
88661
|
-
|
|
88662
|
-
this._needUpdate();
|
|
88381
|
+
this._visible.set(value);
|
|
88663
88382
|
}
|
|
88664
88383
|
|
|
88665
88384
|
/**
|
|
@@ -88668,7 +88387,7 @@ class DistanceMeasurement extends Component {
|
|
|
88668
88387
|
* @type {Boolean}
|
|
88669
88388
|
*/
|
|
88670
88389
|
get visible() {
|
|
88671
|
-
return this._visible;
|
|
88390
|
+
return this._visible.get();
|
|
88672
88391
|
}
|
|
88673
88392
|
|
|
88674
88393
|
/**
|
|
@@ -88677,9 +88396,7 @@ class DistanceMeasurement extends Component {
|
|
|
88677
88396
|
* @type {Boolean}
|
|
88678
88397
|
*/
|
|
88679
88398
|
set originVisible(value) {
|
|
88680
|
-
|
|
88681
|
-
this._originVisible = value;
|
|
88682
|
-
this._originDot.setVisible(this._visible && this._originVisible);
|
|
88399
|
+
this._originVisible.set(value);
|
|
88683
88400
|
}
|
|
88684
88401
|
|
|
88685
88402
|
/**
|
|
@@ -88688,7 +88405,7 @@ class DistanceMeasurement extends Component {
|
|
|
88688
88405
|
* @type {Boolean}
|
|
88689
88406
|
*/
|
|
88690
88407
|
get originVisible() {
|
|
88691
|
-
return this._originVisible;
|
|
88408
|
+
return this._originVisible.get();
|
|
88692
88409
|
}
|
|
88693
88410
|
|
|
88694
88411
|
/**
|
|
@@ -88697,9 +88414,7 @@ class DistanceMeasurement extends Component {
|
|
|
88697
88414
|
* @type {Boolean}
|
|
88698
88415
|
*/
|
|
88699
88416
|
set targetVisible(value) {
|
|
88700
|
-
|
|
88701
|
-
this._targetVisible = value;
|
|
88702
|
-
this._targetDot.setVisible(this._visible && this._targetVisible);
|
|
88417
|
+
this._targetVisible.set(value);
|
|
88703
88418
|
}
|
|
88704
88419
|
|
|
88705
88420
|
/**
|
|
@@ -88708,7 +88423,7 @@ class DistanceMeasurement extends Component {
|
|
|
88708
88423
|
* @type {Boolean}
|
|
88709
88424
|
*/
|
|
88710
88425
|
get targetVisible() {
|
|
88711
|
-
return this._targetVisible;
|
|
88426
|
+
return this._targetVisible.get();
|
|
88712
88427
|
}
|
|
88713
88428
|
|
|
88714
88429
|
/**
|
|
@@ -88717,8 +88432,8 @@ class DistanceMeasurement extends Component {
|
|
|
88717
88432
|
* @type {Boolean}
|
|
88718
88433
|
*/
|
|
88719
88434
|
set useRotationAdjustment(value) {
|
|
88720
|
-
|
|
88721
|
-
this.
|
|
88435
|
+
this._useRotationAdjustment.set(value);
|
|
88436
|
+
this._update();
|
|
88722
88437
|
}
|
|
88723
88438
|
|
|
88724
88439
|
/**
|
|
@@ -88727,7 +88442,7 @@ class DistanceMeasurement extends Component {
|
|
|
88727
88442
|
* @type {Boolean}
|
|
88728
88443
|
*/
|
|
88729
88444
|
get useRotationAdjustment() {
|
|
88730
|
-
return this._useRotationAdjustment;
|
|
88445
|
+
return this._useRotationAdjustment.get();
|
|
88731
88446
|
}
|
|
88732
88447
|
|
|
88733
88448
|
/**
|
|
@@ -88738,17 +88453,7 @@ class DistanceMeasurement extends Component {
|
|
|
88738
88453
|
* @type {Boolean}
|
|
88739
88454
|
*/
|
|
88740
88455
|
set axisEnabled(value) {
|
|
88741
|
-
|
|
88742
|
-
this._axisEnabled = value;
|
|
88743
|
-
var axisVisible = this._visible && this._axisVisible && this._axisEnabled;
|
|
88744
|
-
this._xAxisWire.setVisible(axisVisible && this._xAxisVisible);
|
|
88745
|
-
this._yAxisWire.setVisible(axisVisible && this._yAxisVisible);
|
|
88746
|
-
this._zAxisWire.setVisible(axisVisible && this._zAxisVisible);
|
|
88747
|
-
this._xAxisLabel.setVisible(axisVisible && !this._xAxisLabelCulled&& this._xAxisVisible && this._xLabelEnabled);
|
|
88748
|
-
this._yAxisLabel.setVisible(axisVisible && !this._yAxisLabelCulled&& this._xAxisVisible && this._yLabelEnabled);
|
|
88749
|
-
this._zAxisLabel.setVisible(axisVisible && !this._zAxisLabelCulled&& this._xAxisVisible && this._zLabelEnabled);
|
|
88750
|
-
this._cpDirty = true;
|
|
88751
|
-
this._needUpdate();
|
|
88456
|
+
this._axisEnabled.set(value);
|
|
88752
88457
|
}
|
|
88753
88458
|
|
|
88754
88459
|
/**
|
|
@@ -88759,7 +88464,7 @@ class DistanceMeasurement extends Component {
|
|
|
88759
88464
|
* @type {Boolean}
|
|
88760
88465
|
*/
|
|
88761
88466
|
get axisEnabled() {
|
|
88762
|
-
return this._axisEnabled;
|
|
88467
|
+
return this._axisEnabled.get();
|
|
88763
88468
|
}
|
|
88764
88469
|
|
|
88765
88470
|
/**
|
|
@@ -88770,17 +88475,7 @@ class DistanceMeasurement extends Component {
|
|
|
88770
88475
|
* @type {Boolean}
|
|
88771
88476
|
*/
|
|
88772
88477
|
set axisVisible(value) {
|
|
88773
|
-
|
|
88774
|
-
this._axisVisible = value;
|
|
88775
|
-
var axisVisible = this._visible && this._axisVisible && this._axisEnabled;
|
|
88776
|
-
this._xAxisWire.setVisible(axisVisible && this._xAxisVisible);
|
|
88777
|
-
this._yAxisWire.setVisible(axisVisible && this._yAxisVisible);
|
|
88778
|
-
this._zAxisWire.setVisible(axisVisible && this._zAxisVisible);
|
|
88779
|
-
this._xAxisLabel.setVisible(axisVisible && !this._xAxisLabelCulled&& this._xAxisVisible);
|
|
88780
|
-
this._yAxisLabel.setVisible(axisVisible && !this._yAxisLabelCulled&& this._yAxisVisible);
|
|
88781
|
-
this._zAxisLabel.setVisible(axisVisible && !this._zAxisLabelCulled&& this._zAxisVisible);
|
|
88782
|
-
this._cpDirty = true;
|
|
88783
|
-
this._needUpdate();
|
|
88478
|
+
this._axisVisible.set(value);
|
|
88784
88479
|
}
|
|
88785
88480
|
|
|
88786
88481
|
/**
|
|
@@ -88791,7 +88486,7 @@ class DistanceMeasurement extends Component {
|
|
|
88791
88486
|
* @type {Boolean}
|
|
88792
88487
|
*/
|
|
88793
88488
|
get axisVisible() {
|
|
88794
|
-
return this._axisVisible;
|
|
88489
|
+
return this._axisVisible.get();
|
|
88795
88490
|
}
|
|
88796
88491
|
|
|
88797
88492
|
/**
|
|
@@ -88802,13 +88497,7 @@ class DistanceMeasurement extends Component {
|
|
|
88802
88497
|
* @type {Boolean}
|
|
88803
88498
|
*/
|
|
88804
88499
|
set xAxisVisible(value) {
|
|
88805
|
-
|
|
88806
|
-
this._xAxisVisible = value;
|
|
88807
|
-
const axisVisible = this._visible && this._axisVisible && this._xAxisVisible && this._axisEnabled;
|
|
88808
|
-
this._xAxisWire.setVisible(axisVisible);
|
|
88809
|
-
this._xAxisLabel.setVisible(axisVisible && !this._xAxisLabelCulled && this._xLabelEnabled);
|
|
88810
|
-
this._cpDirty = true;
|
|
88811
|
-
this._needUpdate();
|
|
88500
|
+
this._xAxisVisible.set(value);
|
|
88812
88501
|
}
|
|
88813
88502
|
|
|
88814
88503
|
/**
|
|
@@ -88819,7 +88508,7 @@ class DistanceMeasurement extends Component {
|
|
|
88819
88508
|
* @type {Boolean}
|
|
88820
88509
|
*/
|
|
88821
88510
|
get xAxisVisible() {
|
|
88822
|
-
return this._xAxisVisible;
|
|
88511
|
+
return this._xAxisVisible.get();
|
|
88823
88512
|
}
|
|
88824
88513
|
|
|
88825
88514
|
/**
|
|
@@ -88830,13 +88519,7 @@ class DistanceMeasurement extends Component {
|
|
|
88830
88519
|
* @type {Boolean}
|
|
88831
88520
|
*/
|
|
88832
88521
|
set yAxisVisible(value) {
|
|
88833
|
-
|
|
88834
|
-
this._yAxisVisible = value;
|
|
88835
|
-
const axisVisible = this._visible && this._axisVisible && this._yAxisVisible && this._axisEnabled;
|
|
88836
|
-
this._yAxisWire.setVisible(axisVisible);
|
|
88837
|
-
this._yAxisLabel.setVisible(axisVisible && !this._yAxisLabelCulled && this._yLabelEnabled);
|
|
88838
|
-
this._cpDirty = true;
|
|
88839
|
-
this._needUpdate();
|
|
88522
|
+
this._yAxisVisible.set(value);
|
|
88840
88523
|
}
|
|
88841
88524
|
|
|
88842
88525
|
/**
|
|
@@ -88847,7 +88530,7 @@ class DistanceMeasurement extends Component {
|
|
|
88847
88530
|
* @type {Boolean}
|
|
88848
88531
|
*/
|
|
88849
88532
|
get yAxisVisible() {
|
|
88850
|
-
return this._yAxisVisible;
|
|
88533
|
+
return this._yAxisVisible.get();
|
|
88851
88534
|
}
|
|
88852
88535
|
|
|
88853
88536
|
/**
|
|
@@ -88858,13 +88541,7 @@ class DistanceMeasurement extends Component {
|
|
|
88858
88541
|
* @type {Boolean}
|
|
88859
88542
|
*/
|
|
88860
88543
|
set zAxisVisible(value) {
|
|
88861
|
-
|
|
88862
|
-
this._zAxisVisible = value;
|
|
88863
|
-
const axisVisible = this._visible && this._axisVisible && this._zAxisVisible && this._axisEnabled;
|
|
88864
|
-
this._zAxisWire.setVisible(axisVisible);
|
|
88865
|
-
this._zAxisLabel.setVisible(axisVisible && !this._zAxisLabelCulled && this._zLabelEnabled);
|
|
88866
|
-
this._cpDirty = true;
|
|
88867
|
-
this._needUpdate();
|
|
88544
|
+
this._zAxisVisible.set(value);
|
|
88868
88545
|
}
|
|
88869
88546
|
|
|
88870
88547
|
/**
|
|
@@ -88875,7 +88552,7 @@ class DistanceMeasurement extends Component {
|
|
|
88875
88552
|
* @type {Boolean}
|
|
88876
88553
|
*/
|
|
88877
88554
|
get zAxisVisible() {
|
|
88878
|
-
return this._zAxisVisible;
|
|
88555
|
+
return this._zAxisVisible.get();
|
|
88879
88556
|
}
|
|
88880
88557
|
|
|
88881
88558
|
/**
|
|
@@ -88884,11 +88561,7 @@ class DistanceMeasurement extends Component {
|
|
|
88884
88561
|
* @type {Boolean}
|
|
88885
88562
|
*/
|
|
88886
88563
|
set wireVisible(value) {
|
|
88887
|
-
|
|
88888
|
-
this._wireVisible = value;
|
|
88889
|
-
var wireVisible = this._visible && this._wireVisible;
|
|
88890
|
-
this._lengthLabel.setVisible(wireVisible && this._lengthLabelEnabled);
|
|
88891
|
-
this._lengthWire.setVisible(wireVisible);
|
|
88564
|
+
this._wireVisible.set(value);
|
|
88892
88565
|
}
|
|
88893
88566
|
|
|
88894
88567
|
/**
|
|
@@ -88897,7 +88570,7 @@ class DistanceMeasurement extends Component {
|
|
|
88897
88570
|
* @type {Boolean}
|
|
88898
88571
|
*/
|
|
88899
88572
|
get wireVisible() {
|
|
88900
|
-
return this._wireVisible;
|
|
88573
|
+
return this._wireVisible.get();
|
|
88901
88574
|
}
|
|
88902
88575
|
|
|
88903
88576
|
/**
|
|
@@ -88906,15 +88579,7 @@ class DistanceMeasurement extends Component {
|
|
|
88906
88579
|
* @type {Boolean}
|
|
88907
88580
|
*/
|
|
88908
88581
|
set labelsVisible(value) {
|
|
88909
|
-
|
|
88910
|
-
this._labelsVisible = value;
|
|
88911
|
-
var labelsVisible = this._visible && this._labelsVisible;
|
|
88912
|
-
this._xAxisLabel.setVisible(labelsVisible && !this._xAxisLabelCulled && this._clickable && this._axisEnabled && this._xLabelEnabled);
|
|
88913
|
-
this._yAxisLabel.setVisible(labelsVisible && !this._yAxisLabelCulled && this._clickable && this._axisEnabled && this._yLabelEnabled);
|
|
88914
|
-
this._zAxisLabel.setVisible(labelsVisible && !this._zAxisLabelCulled && this._clickable && this._axisEnabled && this._zLabelEnabled);
|
|
88915
|
-
this._lengthLabel.setVisible(labelsVisible && this._lengthLabelEnabled);
|
|
88916
|
-
this._cpDirty = true;
|
|
88917
|
-
this._needUpdate();
|
|
88582
|
+
this._labelsVisible.set(value);
|
|
88918
88583
|
}
|
|
88919
88584
|
|
|
88920
88585
|
/**
|
|
@@ -88923,7 +88588,7 @@ class DistanceMeasurement extends Component {
|
|
|
88923
88588
|
* @type {Boolean}
|
|
88924
88589
|
*/
|
|
88925
88590
|
get labelsVisible() {
|
|
88926
|
-
return this._labelsVisible;
|
|
88591
|
+
return this._labelsVisible.get();
|
|
88927
88592
|
}
|
|
88928
88593
|
|
|
88929
88594
|
/**
|
|
@@ -88932,12 +88597,7 @@ class DistanceMeasurement extends Component {
|
|
|
88932
88597
|
* @type {Boolean}
|
|
88933
88598
|
*/
|
|
88934
88599
|
set xLabelEnabled(value) {
|
|
88935
|
-
|
|
88936
|
-
this._xLabelEnabled = value;
|
|
88937
|
-
var labelsVisible = this._visible && this._labelsVisible;
|
|
88938
|
-
this._xAxisLabel.setVisible(labelsVisible && !this._xAxisLabelCulled && this._clickable && this._axisEnabled && this._xLabelEnabled);
|
|
88939
|
-
this._cpDirty = true;
|
|
88940
|
-
this._needUpdate();
|
|
88600
|
+
this._xLabelEnabled.set(value);
|
|
88941
88601
|
}
|
|
88942
88602
|
|
|
88943
88603
|
/**
|
|
@@ -88946,7 +88606,7 @@ class DistanceMeasurement extends Component {
|
|
|
88946
88606
|
* @type {Boolean}
|
|
88947
88607
|
*/
|
|
88948
88608
|
get xLabelEnabled(){
|
|
88949
|
-
return this._xLabelEnabled;
|
|
88609
|
+
return this._xLabelEnabled.get();
|
|
88950
88610
|
}
|
|
88951
88611
|
|
|
88952
88612
|
/**
|
|
@@ -88955,12 +88615,7 @@ class DistanceMeasurement extends Component {
|
|
|
88955
88615
|
* @type {Boolean}
|
|
88956
88616
|
*/
|
|
88957
88617
|
set yLabelEnabled(value) {
|
|
88958
|
-
|
|
88959
|
-
this._yLabelEnabled = value;
|
|
88960
|
-
var labelsVisible = this._visible && this._labelsVisible;
|
|
88961
|
-
this._yAxisLabel.setVisible(labelsVisible && !this._yAxisLabelCulled && this._clickable && this._axisEnabled && this._yLabelEnabled);
|
|
88962
|
-
this._cpDirty = true;
|
|
88963
|
-
this._needUpdate();
|
|
88618
|
+
this._yLabelEnabled.set(value);
|
|
88964
88619
|
}
|
|
88965
88620
|
|
|
88966
88621
|
/**
|
|
@@ -88969,7 +88624,7 @@ class DistanceMeasurement extends Component {
|
|
|
88969
88624
|
* @type {Boolean}
|
|
88970
88625
|
*/
|
|
88971
88626
|
get yLabelEnabled(){
|
|
88972
|
-
return this._yLabelEnabled;
|
|
88627
|
+
return this._yLabelEnabled.get();
|
|
88973
88628
|
}
|
|
88974
88629
|
|
|
88975
88630
|
/**
|
|
@@ -88978,12 +88633,7 @@ class DistanceMeasurement extends Component {
|
|
|
88978
88633
|
* @type {Boolean}
|
|
88979
88634
|
*/
|
|
88980
88635
|
set zLabelEnabled(value) {
|
|
88981
|
-
|
|
88982
|
-
this._zLabelEnabled = value;
|
|
88983
|
-
var labelsVisible = this._visible && this._labelsVisible;
|
|
88984
|
-
this._zAxisLabel.setVisible(labelsVisible && !this._zAxisLabelCulled && this._clickable && this._axisEnabled && this._zLabelEnabled);
|
|
88985
|
-
this._cpDirty = true;
|
|
88986
|
-
this._needUpdate();
|
|
88636
|
+
this._zLabelEnabled.set(value);
|
|
88987
88637
|
}
|
|
88988
88638
|
|
|
88989
88639
|
/**
|
|
@@ -88992,7 +88642,7 @@ class DistanceMeasurement extends Component {
|
|
|
88992
88642
|
* @type {Boolean}
|
|
88993
88643
|
*/
|
|
88994
88644
|
get zLabelEnabled(){
|
|
88995
|
-
return this._zLabelEnabled;
|
|
88645
|
+
return this._zLabelEnabled.get();
|
|
88996
88646
|
}
|
|
88997
88647
|
|
|
88998
88648
|
/**
|
|
@@ -89001,12 +88651,7 @@ class DistanceMeasurement extends Component {
|
|
|
89001
88651
|
* @type {Boolean}
|
|
89002
88652
|
*/
|
|
89003
88653
|
set lengthLabelEnabled(value) {
|
|
89004
|
-
|
|
89005
|
-
this._lengthLabelEnabled = value;
|
|
89006
|
-
var labelsVisible = this._visible && this._labelsVisible;
|
|
89007
|
-
this._lengthLabel.setVisible(labelsVisible && !this._lengthAxisLabelCulled && this._clickable && this._axisEnabled && this._lengthLabelEnabled);
|
|
89008
|
-
this._cpDirty = true;
|
|
89009
|
-
this._needUpdate();
|
|
88654
|
+
this._lengthLabelEnabled.set(value);
|
|
89010
88655
|
}
|
|
89011
88656
|
|
|
89012
88657
|
/**
|
|
@@ -89015,7 +88660,7 @@ class DistanceMeasurement extends Component {
|
|
|
89015
88660
|
* @type {Boolean}
|
|
89016
88661
|
*/
|
|
89017
88662
|
get lengthLabelEnabled(){
|
|
89018
|
-
return this._lengthLabelEnabled;
|
|
88663
|
+
return this._lengthLabelEnabled.get();
|
|
89019
88664
|
}
|
|
89020
88665
|
|
|
89021
88666
|
/**
|
|
@@ -89024,8 +88669,8 @@ class DistanceMeasurement extends Component {
|
|
|
89024
88669
|
* @type {Boolean}
|
|
89025
88670
|
*/
|
|
89026
88671
|
set labelsOnWires(value) {
|
|
89027
|
-
|
|
89028
|
-
this.
|
|
88672
|
+
this._labelsOnWires.set(value);
|
|
88673
|
+
this._update();
|
|
89029
88674
|
}
|
|
89030
88675
|
|
|
89031
88676
|
/**
|
|
@@ -89034,7 +88679,7 @@ class DistanceMeasurement extends Component {
|
|
|
89034
88679
|
* @type {Boolean}
|
|
89035
88680
|
*/
|
|
89036
88681
|
get labelsOnWires() {
|
|
89037
|
-
return this._labelsOnWires;
|
|
88682
|
+
return this._labelsOnWires.get();
|
|
89038
88683
|
}
|
|
89039
88684
|
|
|
89040
88685
|
/**
|
|
@@ -89042,16 +88687,7 @@ class DistanceMeasurement extends Component {
|
|
|
89042
88687
|
* @param highlighted
|
|
89043
88688
|
*/
|
|
89044
88689
|
setHighlighted(highlighted) {
|
|
89045
|
-
this.
|
|
89046
|
-
this._targetDot.setHighlighted(highlighted);
|
|
89047
|
-
this._xAxisWire.setHighlighted(highlighted);
|
|
89048
|
-
this._yAxisWire.setHighlighted(highlighted);
|
|
89049
|
-
this._zAxisWire.setHighlighted(highlighted);
|
|
89050
|
-
this._xAxisLabel.setHighlighted(highlighted);
|
|
89051
|
-
this._yAxisLabel.setHighlighted(highlighted);
|
|
89052
|
-
this._zAxisLabel.setHighlighted(highlighted);
|
|
89053
|
-
this._lengthWire.setHighlighted(highlighted);
|
|
89054
|
-
this._lengthLabel.setHighlighted(highlighted);
|
|
88690
|
+
this._drawables.forEach(d => d.setHighlighted(highlighted));
|
|
89055
88691
|
}
|
|
89056
88692
|
|
|
89057
88693
|
/**
|
|
@@ -89060,18 +88696,8 @@ class DistanceMeasurement extends Component {
|
|
|
89060
88696
|
* @type {Boolean}
|
|
89061
88697
|
*/
|
|
89062
88698
|
set clickable(value) {
|
|
89063
|
-
|
|
89064
|
-
this.
|
|
89065
|
-
this._originDot.setClickable(this._clickable);
|
|
89066
|
-
this._targetDot.setClickable(this._clickable);
|
|
89067
|
-
this._xAxisWire.setClickable(this._clickable);
|
|
89068
|
-
this._yAxisWire.setClickable(this._clickable);
|
|
89069
|
-
this._zAxisWire.setClickable(this._clickable);
|
|
89070
|
-
this._lengthWire.setClickable(this._clickable);
|
|
89071
|
-
this._xAxisLabel.setClickable(this._clickable);
|
|
89072
|
-
this._yAxisLabel.setClickable(this._clickable);
|
|
89073
|
-
this._zAxisLabel.setClickable(this._clickable);
|
|
89074
|
-
this._lengthLabel.setClickable(this._clickable);
|
|
88699
|
+
this._clickable.set(!!value);
|
|
88700
|
+
this._drawables.forEach(d => d.setClickable(this._clickable.get()));
|
|
89075
88701
|
}
|
|
89076
88702
|
|
|
89077
88703
|
/**
|
|
@@ -89080,50 +88706,14 @@ class DistanceMeasurement extends Component {
|
|
|
89080
88706
|
* @type {Boolean}
|
|
89081
88707
|
*/
|
|
89082
88708
|
get clickable() {
|
|
89083
|
-
return this._clickable;
|
|
88709
|
+
return this._clickable.get();
|
|
89084
88710
|
}
|
|
89085
88711
|
|
|
89086
88712
|
/**
|
|
89087
88713
|
* @private
|
|
89088
88714
|
*/
|
|
89089
88715
|
destroy() {
|
|
89090
|
-
|
|
89091
|
-
const scene = this.plugin.viewer.scene;
|
|
89092
|
-
const metrics = scene.metrics;
|
|
89093
|
-
|
|
89094
|
-
if (this._onViewMatrix) {
|
|
89095
|
-
scene.camera.off(this._onViewMatrix);
|
|
89096
|
-
}
|
|
89097
|
-
if (this._onProjMatrix) {
|
|
89098
|
-
scene.camera.off(this._onProjMatrix);
|
|
89099
|
-
}
|
|
89100
|
-
if (this._onCanvasBoundary) {
|
|
89101
|
-
scene.canvas.off(this._onCanvasBoundary);
|
|
89102
|
-
}
|
|
89103
|
-
if (this._onMetricsUnits) {
|
|
89104
|
-
metrics.off(this._onMetricsUnits);
|
|
89105
|
-
}
|
|
89106
|
-
if (this._onMetricsScale) {
|
|
89107
|
-
metrics.off(this._onMetricsScale);
|
|
89108
|
-
}
|
|
89109
|
-
if (this._onMetricsOrigin) {
|
|
89110
|
-
metrics.off(this._onMetricsOrigin);
|
|
89111
|
-
}
|
|
89112
|
-
if (this._onSectionPlaneUpdated) {
|
|
89113
|
-
scene.off(this._onSectionPlaneUpdated);
|
|
89114
|
-
}
|
|
89115
|
-
|
|
89116
|
-
this._originDot.destroy();
|
|
89117
|
-
this._targetDot.destroy();
|
|
89118
|
-
this._xAxisWire.destroy();
|
|
89119
|
-
this._yAxisWire.destroy();
|
|
89120
|
-
this._zAxisWire.destroy();
|
|
89121
|
-
this._lengthLabel.destroy();
|
|
89122
|
-
this._xAxisLabel.destroy();
|
|
89123
|
-
this._yAxisLabel.destroy();
|
|
89124
|
-
this._zAxisLabel.destroy();
|
|
89125
|
-
this._lengthWire.destroy();
|
|
89126
|
-
|
|
88716
|
+
this._cleanups.forEach(cleanup => cleanup());
|
|
89127
88717
|
super.destroy();
|
|
89128
88718
|
}
|
|
89129
88719
|
}
|
|
@@ -97467,7 +97057,6 @@ class MousePanRotateDollyHandler {
|
|
|
97467
97057
|
});
|
|
97468
97058
|
|
|
97469
97059
|
function setMousedownState(pick = true) {
|
|
97470
|
-
canvas.style.cursor = "move";
|
|
97471
97060
|
setMousedownPositions();
|
|
97472
97061
|
if (pick) {
|
|
97473
97062
|
setMousedownPick();
|
|
@@ -97496,7 +97085,7 @@ class MousePanRotateDollyHandler {
|
|
|
97496
97085
|
}
|
|
97497
97086
|
|
|
97498
97087
|
function isPanning() {
|
|
97499
|
-
return cameraControl._isKeyDownForAction(cameraControl.MOUSE_PAN, keyDown);
|
|
97088
|
+
return configs.planView || cameraControl._isKeyDownForAction(cameraControl.MOUSE_PAN, keyDown);
|
|
97500
97089
|
}
|
|
97501
97090
|
|
|
97502
97091
|
function isRotating() {
|
|
@@ -98258,7 +97847,7 @@ class KeyboardPanRotateDollyHandler {
|
|
|
98258
97847
|
|
|
98259
97848
|
const keyDownMap = [];
|
|
98260
97849
|
|
|
98261
|
-
|
|
97850
|
+
scene.canvas.canvas;
|
|
98262
97851
|
|
|
98263
97852
|
let mouseMovedSinceLastKeyboardDolly = true;
|
|
98264
97853
|
|
|
@@ -98274,10 +97863,6 @@ class KeyboardPanRotateDollyHandler {
|
|
|
98274
97863
|
return;
|
|
98275
97864
|
}
|
|
98276
97865
|
keyDownMap[keyCode] = true;
|
|
98277
|
-
|
|
98278
|
-
if (keyCode === input.KEY_SHIFT) {
|
|
98279
|
-
canvas.style.cursor = "move";
|
|
98280
|
-
}
|
|
98281
97866
|
});
|
|
98282
97867
|
|
|
98283
97868
|
this._onSceneKeyUp = input.on("keyup", (keyCode) => {
|
|
@@ -98286,10 +97871,6 @@ class KeyboardPanRotateDollyHandler {
|
|
|
98286
97871
|
}
|
|
98287
97872
|
keyDownMap[keyCode] = false;
|
|
98288
97873
|
|
|
98289
|
-
if (keyCode === input.KEY_SHIFT) {
|
|
98290
|
-
canvas.style.cursor = null;
|
|
98291
|
-
}
|
|
98292
|
-
|
|
98293
97874
|
if (controllers.pivotController.getPivoting()) {
|
|
98294
97875
|
controllers.pivotController.endPivot();
|
|
98295
97876
|
}
|
|
@@ -98446,6 +98027,7 @@ class CameraUpdater {
|
|
|
98446
98027
|
const pickController = controllers.pickController;
|
|
98447
98028
|
const pivotController = controllers.pivotController;
|
|
98448
98029
|
const panController = controllers.panController;
|
|
98030
|
+
const cameraControl = controllers.cameraControl;
|
|
98449
98031
|
|
|
98450
98032
|
let countDown = SCALE_DOLLY_EACH_FRAME; // Decrements on each tick
|
|
98451
98033
|
let dollyDistFactor = 1.0; // Calculated when countDown is zero
|
|
@@ -98570,7 +98152,7 @@ class CameraUpdater {
|
|
|
98570
98152
|
updates.rotateDeltaX *= configs.rotationInertia;
|
|
98571
98153
|
updates.rotateDeltaY *= configs.rotationInertia;
|
|
98572
98154
|
|
|
98573
|
-
cursorType =
|
|
98155
|
+
cursorType = cameraControl._cursors.rotate;
|
|
98574
98156
|
}
|
|
98575
98157
|
|
|
98576
98158
|
//----------------------------------------------------------------------------------------------------------
|
|
@@ -98636,7 +98218,7 @@ class CameraUpdater {
|
|
|
98636
98218
|
camera.pan(vec);
|
|
98637
98219
|
}
|
|
98638
98220
|
|
|
98639
|
-
cursorType =
|
|
98221
|
+
cursorType = cameraControl._cursors.pan;
|
|
98640
98222
|
}
|
|
98641
98223
|
|
|
98642
98224
|
updates.panDeltaX *= configs.panInertia;
|
|
@@ -98650,9 +98232,9 @@ class CameraUpdater {
|
|
|
98650
98232
|
if (dollyDeltaForDist !== 0) {
|
|
98651
98233
|
|
|
98652
98234
|
if (dollyDeltaForDist < 0) {
|
|
98653
|
-
cursorType =
|
|
98235
|
+
cursorType = cameraControl._cursors.dollyForward;
|
|
98654
98236
|
} else {
|
|
98655
|
-
cursorType =
|
|
98237
|
+
cursorType = cameraControl._cursors.dollyBackward;
|
|
98656
98238
|
}
|
|
98657
98239
|
|
|
98658
98240
|
if (configs.firstPerson) {
|
|
@@ -98918,6 +98500,7 @@ class TouchPanRotateAndDollyHandler {
|
|
|
98918
98500
|
canvas.addEventListener("touchend", this._canvasTouchEndHandler = () => {
|
|
98919
98501
|
if (pivotController.getPivoting()) {
|
|
98920
98502
|
pivotController.endPivot();
|
|
98503
|
+
pivotController.hidePivot();
|
|
98921
98504
|
}
|
|
98922
98505
|
});
|
|
98923
98506
|
|
|
@@ -100113,6 +99696,13 @@ class CameraControl extends Component {
|
|
|
100113
99696
|
new KeyboardPanRotateDollyHandler(this.scene, this._controllers, this._configs, this._states, this._updates)
|
|
100114
99697
|
];
|
|
100115
99698
|
|
|
99699
|
+
this._cursors = {
|
|
99700
|
+
dollyForward: "zoom-in",
|
|
99701
|
+
dollyBackward: "zoom-out",
|
|
99702
|
+
rotate: 'grabbing',
|
|
99703
|
+
pan: 'move',
|
|
99704
|
+
};
|
|
99705
|
+
|
|
100116
99706
|
// Applies scheduled updates to the Camera on each Scene "tick" event
|
|
100117
99707
|
|
|
100118
99708
|
this._cameraUpdater = new CameraUpdater(this.scene, this._controllers, this._configs, this._states, this._updates);
|
|
@@ -100474,6 +100064,37 @@ class CameraControl extends Component {
|
|
|
100474
100064
|
this._configs.pointerEnabled = !!value;
|
|
100475
100065
|
}
|
|
100476
100066
|
|
|
100067
|
+
/**
|
|
100068
|
+
* Sets the cursor to be used when a particular action is being performed.
|
|
100069
|
+
*
|
|
100070
|
+
* Accepted actions are:
|
|
100071
|
+
*
|
|
100072
|
+
* * "dollyForward" - when the camera is dollying in the forward direction
|
|
100073
|
+
* * "dollyBackward" - when the camera is dollying in the backward direction
|
|
100074
|
+
* * "pan" - when the camera is being panned
|
|
100075
|
+
* * "rotate" - when the camera is being rotated
|
|
100076
|
+
*
|
|
100077
|
+
* @param {String} action
|
|
100078
|
+
* @param {String} style
|
|
100079
|
+
*/
|
|
100080
|
+
setCursorStyle(action, style) {
|
|
100081
|
+
if (Object.prototype.hasOwnProperty.call(this._cursors, action)) {
|
|
100082
|
+
this._cursors = { ...this._cursors, [action]: style };
|
|
100083
|
+
}
|
|
100084
|
+
else
|
|
100085
|
+
console.warn(`Action '${action}' is not valid for cursor styles.`);
|
|
100086
|
+
}
|
|
100087
|
+
|
|
100088
|
+
/**
|
|
100089
|
+
* Gets the current style for a particular action.
|
|
100090
|
+
*
|
|
100091
|
+
* @param {String} action To get the style for
|
|
100092
|
+
* @returns {String} style set on the cursor for action
|
|
100093
|
+
*/
|
|
100094
|
+
getCursorStyle(action) {
|
|
100095
|
+
return this._cursors[action] || null;
|
|
100096
|
+
}
|
|
100097
|
+
|
|
100477
100098
|
_reset() {
|
|
100478
100099
|
for (let i = 0, len = this._handlers.length; i < len; i++) {
|
|
100479
100100
|
const handler = this._handlers[i];
|
|
@@ -110679,6 +110300,12 @@ class Viewer {
|
|
|
110679
110300
|
}
|
|
110680
110301
|
}
|
|
110681
110302
|
|
|
110303
|
+
// Added to fix label's text offset in an html2canvas capture (See XEOK-151)
|
|
110304
|
+
// based on https://github.com/niklasvh/html2canvas/issues/2775#issuecomment-1316356991
|
|
110305
|
+
const style = document.createElement('style');
|
|
110306
|
+
document.head.appendChild(style);
|
|
110307
|
+
style.sheet?.insertRule('body > div:last-child img { display: inline-block; }');
|
|
110308
|
+
|
|
110682
110309
|
for (let i = 0, len = pluginContainerElements.length; i < len; i++) {
|
|
110683
110310
|
const containerElement = pluginContainerElements[i];
|
|
110684
110311
|
await html2canvas(containerElement, {
|
|
@@ -110691,6 +110318,9 @@ class Viewer {
|
|
|
110691
110318
|
// (implemented to compensate XCD-153 issue)
|
|
110692
110319
|
snapshotCanvas.getContext("2d").resetTransform();
|
|
110693
110320
|
}
|
|
110321
|
+
|
|
110322
|
+
style.remove();
|
|
110323
|
+
|
|
110694
110324
|
if (!params.includeGizmos) {
|
|
110695
110325
|
this.sendToPlugins("snapshotFinished");
|
|
110696
110326
|
}
|
|
@@ -123565,6 +123195,43 @@ class StoreyViewsPlugin extends Plugin {
|
|
|
123565
123195
|
this.modelStoreys[modelId][storeyId] = storey;
|
|
123566
123196
|
}
|
|
123567
123197
|
}
|
|
123198
|
+
this._clipBoundingBoxes();
|
|
123199
|
+
}
|
|
123200
|
+
|
|
123201
|
+
_clipBoundingBoxes() {
|
|
123202
|
+
const storeysList = this.storeysList;
|
|
123203
|
+
const metaScene = this.viewer.metaScene;
|
|
123204
|
+
const camera = this.viewer.camera;
|
|
123205
|
+
const worldUp = camera.worldUp;
|
|
123206
|
+
const xUp = worldUp[0] > worldUp[1] && worldUp[0] > worldUp[2];
|
|
123207
|
+
const yUp = !xUp && worldUp[1] > worldUp[0] && worldUp[1] > worldUp[2];
|
|
123208
|
+
!xUp && !yUp && worldUp[2] > worldUp[0] && worldUp[2] > worldUp[1];
|
|
123209
|
+
|
|
123210
|
+
let bbIndex;
|
|
123211
|
+
|
|
123212
|
+
if(xUp) bbIndex = 0;
|
|
123213
|
+
else if(yUp) bbIndex = 1;
|
|
123214
|
+
else bbIndex = 2;
|
|
123215
|
+
|
|
123216
|
+
for (let i = 0, len = storeysList.length; i < len; i++) {
|
|
123217
|
+
|
|
123218
|
+
const storeyMetaObjectCur = metaScene.metaObjects[storeysList[i].storeyId];
|
|
123219
|
+
const elevationCur = storeyMetaObjectCur.attributes.elevation;
|
|
123220
|
+
|
|
123221
|
+
if(isNaN(elevationCur)) return;
|
|
123222
|
+
|
|
123223
|
+
const bb = storeysList[i].storeyAABB;
|
|
123224
|
+
bb[bbIndex] = Math.max(bb[1], parseFloat(elevationCur));
|
|
123225
|
+
|
|
123226
|
+
if (i > 0) {
|
|
123227
|
+
const storeyMetaObjectNext = metaScene.metaObjects[storeysList[i - 1].storeyId];
|
|
123228
|
+
const elevationNext = storeyMetaObjectNext.attributes.elevation;
|
|
123229
|
+
bb[4] = Math.min(bb[bbIndex + 3], parseFloat(elevationNext));
|
|
123230
|
+
}
|
|
123231
|
+
|
|
123232
|
+
this.storeys[storeysList[i].storeyId].storeyAABB = bb;
|
|
123233
|
+
}
|
|
123234
|
+
|
|
123568
123235
|
}
|
|
123569
123236
|
|
|
123570
123237
|
_deregisterModelStoreys(modelId) {
|
|
@@ -123761,6 +123428,7 @@ class StoreyViewsPlugin extends Plugin {
|
|
|
123761
123428
|
* @param {Number} [options.width=300] Image width in pixels. Height will be automatically determined from this, if not given.
|
|
123762
123429
|
* @param {Number} [options.height=300] Image height in pixels, as an alternative to width. Width will be automatically determined from this, if not given.
|
|
123763
123430
|
* @param {String} [options.format="png"] Image format. Accepted values are "png" and "jpeg".
|
|
123431
|
+
* @param {Boolean} [options.captureSectionPlanes=false] Whether the storey map is sliced or not.
|
|
123764
123432
|
* @returns {StoreyMap} The StoreyMap.
|
|
123765
123433
|
*/
|
|
123766
123434
|
createStoreyMap(storeyId, options = {}) {
|
|
@@ -123777,6 +123445,7 @@ class StoreyViewsPlugin extends Plugin {
|
|
|
123777
123445
|
const aabb = (this._fitStoreyMaps) ? storey.storeyAABB : storey.modelAABB;
|
|
123778
123446
|
const aspect = Math.abs((aabb[5] - aabb[2]) / (aabb[3] - aabb[0]));
|
|
123779
123447
|
const padding = options.padding || 0;
|
|
123448
|
+
const captureSectionPlanes = !!options.captureSectionPlanes;
|
|
123780
123449
|
|
|
123781
123450
|
let width;
|
|
123782
123451
|
let height;
|
|
@@ -123808,6 +123477,9 @@ class StoreyViewsPlugin extends Plugin {
|
|
|
123808
123477
|
this.showStoreyObjects(storeyId, utils.apply(options, {
|
|
123809
123478
|
hideOthers: true
|
|
123810
123479
|
}));
|
|
123480
|
+
|
|
123481
|
+
if (captureSectionPlanes)
|
|
123482
|
+
this._toggleSectionPlanes(false);
|
|
123811
123483
|
|
|
123812
123484
|
this._arrangeStoreyMapCamera(storey);
|
|
123813
123485
|
|
|
@@ -123819,10 +123491,19 @@ class StoreyViewsPlugin extends Plugin {
|
|
|
123819
123491
|
|
|
123820
123492
|
this._objectsMemento.restoreObjects(scene, mask);
|
|
123821
123493
|
this._cameraMemento.restoreCamera(scene);
|
|
123494
|
+
if (captureSectionPlanes)
|
|
123495
|
+
this._toggleSectionPlanes(true);
|
|
123822
123496
|
|
|
123823
123497
|
return new StoreyMap(storeyId, src, format, width, height, padding);
|
|
123824
123498
|
}
|
|
123825
123499
|
|
|
123500
|
+
_toggleSectionPlanes(visible) {
|
|
123501
|
+
const planes = this.viewer.scene.sectionPlanes;
|
|
123502
|
+
for (const key in planes) {
|
|
123503
|
+
planes[key].active = visible;
|
|
123504
|
+
}
|
|
123505
|
+
}
|
|
123506
|
+
|
|
123826
123507
|
_arrangeStoreyMapCamera(storey) {
|
|
123827
123508
|
const viewer = this.viewer;
|
|
123828
123509
|
const scene = viewer.scene;
|
|
@@ -126366,7 +126047,7 @@ class RenderService {
|
|
|
126366
126047
|
nodeElement.appendChild(span);
|
|
126367
126048
|
|
|
126368
126049
|
if (contextmenuHandler) {
|
|
126369
|
-
span
|
|
126050
|
+
addContextMenuListener(span, contextmenuHandler);
|
|
126370
126051
|
}
|
|
126371
126052
|
|
|
126372
126053
|
if (titleClickHandler) {
|
|
@@ -133071,7 +132752,7 @@ parsers[ParserV11.version] = ParserV11;
|
|
|
133071
132752
|
*
|
|
133072
132753
|
* ````javascript
|
|
133073
132754
|
* const sceneModel = xktLoader.load({
|
|
133074
|
-
*
|
|
132755
|
+
* src: "https://xeokit.github.io/xeokit-sdk/assets/models/models/xkt/Schependomlaan.xkt",
|
|
133075
132756
|
* id: "myModel",
|
|
133076
132757
|
* });
|
|
133077
132758
|
* ````
|
|
@@ -133809,6 +133490,10 @@ class XKTLoaderPlugin extends Plugin {
|
|
|
133809
133490
|
}
|
|
133810
133491
|
|
|
133811
133492
|
function getBaseDirectory(filePath) {
|
|
133493
|
+
if (filePath.indexOf('?') > -1) {
|
|
133494
|
+
filePath = filePath.split('?')[0];
|
|
133495
|
+
}
|
|
133496
|
+
|
|
133812
133497
|
const pathArray = filePath.split('/');
|
|
133813
133498
|
pathArray.pop(); // Remove the file name or the last segment of the path
|
|
133814
133499
|
return pathArray.join('/') + '/';
|
|
@@ -140785,105 +140470,45 @@ const triangulateEarClipping = function(planeCoords) {
|
|
|
140785
140470
|
};
|
|
140786
140471
|
|
|
140787
140472
|
const marker3D = function(scene, color) {
|
|
140788
|
-
const
|
|
140789
|
-
|
|
140790
|
-
|
|
140791
|
-
|
|
140792
|
-
|
|
140793
|
-
|
|
140794
|
-
let size = 5;
|
|
140795
|
-
markerDiv.style.background = color;
|
|
140796
|
-
markerDiv.style.border = "2px solid white";
|
|
140797
|
-
markerDiv.style.margin = "0 0";
|
|
140798
|
-
markerDiv.style.zIndex = "100";
|
|
140799
|
-
markerDiv.style.position = "absolute";
|
|
140800
|
-
markerDiv.style.pointerEvents = "none";
|
|
140801
|
-
markerDiv.style.display = "none";
|
|
140802
|
-
|
|
140803
|
-
const marker = new Marker(scene, {});
|
|
140804
|
-
|
|
140805
|
-
const px = x => x + "px";
|
|
140806
|
-
const update = function() {
|
|
140807
|
-
const pos = marker.canvasPos.slice();
|
|
140808
|
-
transformToNode(canvas, markerParent, pos);
|
|
140809
|
-
markerDiv.style.left = px(pos[0] - 3 - size / 2);
|
|
140810
|
-
markerDiv.style.top = px(pos[1] - 3 - size / 2);
|
|
140811
|
-
markerDiv.style.borderRadius = px(size * 2);
|
|
140812
|
-
markerDiv.style.width = px(size);
|
|
140813
|
-
markerDiv.style.height = px(size);
|
|
140814
|
-
};
|
|
140815
|
-
const onViewMatrix = scene.camera.on("viewMatrix", update);
|
|
140816
|
-
const onProjMatrix = scene.camera.on("projMatrix", update);
|
|
140473
|
+
const marker = new Dot3D(scene, {}, scene.canvas.canvas.parentNode, {
|
|
140474
|
+
borderColor: "white",
|
|
140475
|
+
fillColor: color,
|
|
140476
|
+
zIndex: 100
|
|
140477
|
+
});
|
|
140817
140478
|
|
|
140818
140479
|
return {
|
|
140819
140480
|
update: function(worldPos) {
|
|
140820
140481
|
if (worldPos)
|
|
140821
140482
|
{
|
|
140822
140483
|
marker.worldPos = worldPos;
|
|
140823
|
-
update();
|
|
140824
140484
|
}
|
|
140825
|
-
|
|
140826
|
-
},
|
|
140827
|
-
|
|
140828
|
-
setHighlighted: function(h) {
|
|
140829
|
-
size = h ? 10 : 5;
|
|
140830
|
-
update();
|
|
140485
|
+
marker.setVisible(!!worldPos);
|
|
140831
140486
|
},
|
|
140832
140487
|
|
|
140833
|
-
|
|
140834
|
-
|
|
140835
|
-
getWorldPos:
|
|
140836
|
-
|
|
140837
|
-
destroy: function() {
|
|
140838
|
-
markerDiv.parentNode.removeChild(markerDiv);
|
|
140839
|
-
scene.camera.off(onViewMatrix);
|
|
140840
|
-
scene.camera.off(onProjMatrix);
|
|
140841
|
-
marker.destroy();
|
|
140842
|
-
}
|
|
140488
|
+
setHighlighted: h => marker.setHighlighted(h),
|
|
140489
|
+
getCanvasPos: () => marker.canvasPos,
|
|
140490
|
+
getWorldPos: () => marker.worldPos,
|
|
140491
|
+
destroy: () => marker.destroy()
|
|
140843
140492
|
};
|
|
140844
140493
|
};
|
|
140845
140494
|
|
|
140846
140495
|
const wire3D = function(scene, color, startWorldPos) {
|
|
140847
|
-
const
|
|
140848
|
-
|
|
140849
|
-
const startMarker = new Marker(scene, {});
|
|
140850
|
-
startMarker.worldPos = startWorldPos;
|
|
140851
|
-
const endMarker = new Marker(scene, {});
|
|
140852
|
-
const wireParent = canvas.ownerDocument.body;
|
|
140853
|
-
const wire = new Wire(wireParent, {
|
|
140496
|
+
const wire = new Wire3D(scene, scene.canvas.canvas.ownerDocument.body, {
|
|
140854
140497
|
color: color,
|
|
140855
140498
|
thickness: 1,
|
|
140856
140499
|
thicknessClickable: 6
|
|
140857
140500
|
});
|
|
140858
140501
|
wire.setVisible(false);
|
|
140859
|
-
|
|
140860
|
-
const updatePos = function() {
|
|
140861
|
-
const p0 = startMarker.canvasPos.slice();
|
|
140862
|
-
const p1 = endMarker.canvasPos.slice();
|
|
140863
|
-
transformToNode(canvas, wireParent, p0);
|
|
140864
|
-
transformToNode(canvas, wireParent, p1);
|
|
140865
|
-
wire.setStartAndEnd(p0[0], p0[1], p1[0], p1[1]);
|
|
140866
|
-
};
|
|
140867
|
-
const onViewMatrix = scene.camera.on("viewMatrix", updatePos);
|
|
140868
|
-
const onProjMatrix = scene.camera.on("projMatrix", updatePos);
|
|
140869
|
-
|
|
140870
140502
|
return {
|
|
140871
|
-
update:
|
|
140503
|
+
update: endWorldPos => {
|
|
140872
140504
|
if (endWorldPos)
|
|
140873
140505
|
{
|
|
140874
|
-
|
|
140875
|
-
updatePos();
|
|
140506
|
+
wire.setEnds(startWorldPos, endWorldPos);
|
|
140876
140507
|
}
|
|
140877
140508
|
wire.setVisible(!!endWorldPos);
|
|
140878
140509
|
},
|
|
140879
140510
|
|
|
140880
|
-
destroy:
|
|
140881
|
-
scene.camera.off(onViewMatrix);
|
|
140882
|
-
scene.camera.off(onProjMatrix);
|
|
140883
|
-
startMarker.destroy();
|
|
140884
|
-
endMarker.destroy();
|
|
140885
|
-
wire.destroy();
|
|
140886
|
-
}
|
|
140511
|
+
destroy: () => wire.destroy()
|
|
140887
140512
|
};
|
|
140888
140513
|
};
|
|
140889
140514
|
|
|
@@ -142468,6 +142093,7 @@ exports.IntType = IntType;
|
|
|
142468
142093
|
exports.JPEGMediaType = JPEGMediaType;
|
|
142469
142094
|
exports.KTX2TextureTranscoder = KTX2TextureTranscoder;
|
|
142470
142095
|
exports.LASLoaderPlugin = LASLoaderPlugin;
|
|
142096
|
+
exports.Label3D = Label3D;
|
|
142471
142097
|
exports.LambertMaterial = LambertMaterial;
|
|
142472
142098
|
exports.LightMap = LightMap;
|
|
142473
142099
|
exports.LineSet = LineSet;
|
|
@@ -142576,6 +142202,7 @@ exports.VBOGeometry = VBOGeometry;
|
|
|
142576
142202
|
exports.ViewCullPlugin = ViewCullPlugin;
|
|
142577
142203
|
exports.Viewer = Viewer;
|
|
142578
142204
|
exports.WebIFCLoaderPlugin = WebIFCLoaderPlugin;
|
|
142205
|
+
exports.Wire3D = Wire3D;
|
|
142579
142206
|
exports.WorkerPool = WorkerPool$1;
|
|
142580
142207
|
exports.XKTDefaultDataSource = XKTDefaultDataSource;
|
|
142581
142208
|
exports.XKTLoaderPlugin = XKTLoaderPlugin;
|
|
@@ -142615,6 +142242,7 @@ exports.loadOBJGeometry = loadOBJGeometry;
|
|
|
142615
142242
|
exports.math = math;
|
|
142616
142243
|
exports.meshSurfaceArea = meshSurfaceArea;
|
|
142617
142244
|
exports.meshVolume = meshVolume;
|
|
142245
|
+
exports.os = os;
|
|
142618
142246
|
exports.rtcToWorldPos = rtcToWorldPos;
|
|
142619
142247
|
exports.sRGBEncoding = sRGBEncoding;
|
|
142620
142248
|
exports.setFrustum = setFrustum;
|