@xeokit/xeokit-sdk 2.6.23 → 2.6.26
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 +1010 -642
- package/dist/xeokit-sdk.es.js +1010 -643
- package/dist/xeokit-sdk.es5.js +962 -751
- 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 +25 -34
- package/src/plugins/AngleMeasurementsPlugin/index.js +24 -4
- package/src/plugins/AnnotationsPlugin/Annotation.js +78 -9
- package/src/plugins/AnnotationsPlugin/AnnotationsPlugin.js +9 -24
- package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.js +17 -23
- package/src/plugins/DistanceMeasurementsPlugin/index.js +24 -4
- package/src/plugins/XKTLoaderPlugin/XKTDefaultDataSource.js +0 -1
- package/src/plugins/ZonesPlugin/index.js +28 -52
- package/src/plugins/lib/html/Dot.js +18 -18
- package/src/plugins/lib/ui/index.js +110 -88
- package/src/viewer/scene/CameraControl/CameraControl.js +20 -0
- package/src/viewer/scene/CameraControl/lib/handlers/KeyboardAxisViewHandler.js +1 -1
- package/src/viewer/scene/CameraControl/lib/handlers/KeyboardPanRotateDollyHandler.js +2 -2
- package/src/viewer/scene/geometry/builders/index.js +2 -1
- package/src/viewer/scene/marker/Marker.js +9 -3
- package/src/viewer/scene/scene/Scene.js +4 -3
- package/types/plugins/AngleMeasurementsPlugin/AngleMeasurementsPlugin.d.ts +81 -1
- package/types/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsPlugin.d.ts +81 -0
package/dist/xeokit-sdk.cjs.js
CHANGED
|
@@ -9529,6 +9529,239 @@ class Plugin {
|
|
|
9529
9529
|
}
|
|
9530
9530
|
}
|
|
9531
9531
|
|
|
9532
|
+
const os = {
|
|
9533
|
+
isIphoneSafari() {
|
|
9534
|
+
const userAgent = window.navigator.userAgent;
|
|
9535
|
+
const isIphone = /iPhone/i.test(userAgent);
|
|
9536
|
+
const isSafari = /Safari/i.test(userAgent) && !/Chrome/i.test(userAgent);
|
|
9537
|
+
|
|
9538
|
+
return isIphone && isSafari;
|
|
9539
|
+
}
|
|
9540
|
+
};
|
|
9541
|
+
|
|
9542
|
+
/** @private */
|
|
9543
|
+
class Dot {
|
|
9544
|
+
|
|
9545
|
+
constructor(parentElement, cfg = {}) {
|
|
9546
|
+
|
|
9547
|
+
this._highlightClass = "viewer-ruler-dot-highlighted";
|
|
9548
|
+
|
|
9549
|
+
this._x = 0;
|
|
9550
|
+
this._y = 0;
|
|
9551
|
+
|
|
9552
|
+
this._dot = document.createElement('div');
|
|
9553
|
+
this._dot.className += this._dot.className ? ' viewer-ruler-dot' : 'viewer-ruler-dot';
|
|
9554
|
+
|
|
9555
|
+
this._dotClickable = document.createElement('div');
|
|
9556
|
+
this._dotClickable.className += this._dotClickable.className ? ' viewer-ruler-dot-clickable' : 'viewer-ruler-dot-clickable';
|
|
9557
|
+
|
|
9558
|
+
this._visible = !!cfg.visible;
|
|
9559
|
+
this._culled = false;
|
|
9560
|
+
|
|
9561
|
+
var dot = this._dot;
|
|
9562
|
+
var dotStyle = dot.style;
|
|
9563
|
+
dotStyle["border-radius"] = 25 + "px";
|
|
9564
|
+
dotStyle.border = "solid 2px white";
|
|
9565
|
+
dotStyle.background = "lightgreen";
|
|
9566
|
+
dotStyle.position = "absolute";
|
|
9567
|
+
dotStyle["z-index"] = cfg.zIndex === undefined ? "40000005" : cfg.zIndex ;
|
|
9568
|
+
dotStyle.width = 8 + "px";
|
|
9569
|
+
dotStyle.height = 8 + "px";
|
|
9570
|
+
dotStyle.visibility = cfg.visible !== false ? "visible" : "hidden";
|
|
9571
|
+
dotStyle.top = 0 + "px";
|
|
9572
|
+
dotStyle.left = 0 + "px";
|
|
9573
|
+
dotStyle["box-shadow"] = "0 2px 5px 0 #182A3D;";
|
|
9574
|
+
dotStyle["opacity"] = 1.0;
|
|
9575
|
+
dotStyle["pointer-events"] = "none";
|
|
9576
|
+
if (cfg.onContextMenu) ;
|
|
9577
|
+
parentElement.appendChild(dot);
|
|
9578
|
+
|
|
9579
|
+
var dotClickable = this._dotClickable;
|
|
9580
|
+
var dotClickableStyle = dotClickable.style;
|
|
9581
|
+
dotClickableStyle["border-radius"] = 35 + "px";
|
|
9582
|
+
dotClickableStyle.border = "solid 10px white";
|
|
9583
|
+
dotClickableStyle.position = "absolute";
|
|
9584
|
+
dotClickableStyle["z-index"] = cfg.zIndex === undefined ? "40000007" : (cfg.zIndex + 1);
|
|
9585
|
+
dotClickableStyle.width = 8 + "px";
|
|
9586
|
+
dotClickableStyle.height = 8 + "px";
|
|
9587
|
+
dotClickableStyle.visibility = "visible";
|
|
9588
|
+
dotClickableStyle.top = 0 + "px";
|
|
9589
|
+
dotClickableStyle.left = 0 + "px";
|
|
9590
|
+
dotClickableStyle["opacity"] = 0.0;
|
|
9591
|
+
dotClickableStyle["pointer-events"] = "none";
|
|
9592
|
+
if (cfg.onContextMenu) ;
|
|
9593
|
+
parentElement.appendChild(dotClickable);
|
|
9594
|
+
|
|
9595
|
+
dotClickable.addEventListener('click', (event) => {
|
|
9596
|
+
parentElement.dispatchEvent(new MouseEvent('mouseover', event));
|
|
9597
|
+
});
|
|
9598
|
+
|
|
9599
|
+
if (cfg.onMouseOver) {
|
|
9600
|
+
dotClickable.addEventListener('mouseover', (event) => {
|
|
9601
|
+
cfg.onMouseOver(event, this);
|
|
9602
|
+
parentElement.dispatchEvent(new MouseEvent('mouseover', event));
|
|
9603
|
+
});
|
|
9604
|
+
}
|
|
9605
|
+
|
|
9606
|
+
if (cfg.onMouseLeave) {
|
|
9607
|
+
dotClickable.addEventListener('mouseleave', (event) => {
|
|
9608
|
+
cfg.onMouseLeave(event, this);
|
|
9609
|
+
});
|
|
9610
|
+
}
|
|
9611
|
+
|
|
9612
|
+
if (cfg.onMouseWheel) {
|
|
9613
|
+
dotClickable.addEventListener('wheel', (event) => {
|
|
9614
|
+
cfg.onMouseWheel(event, this);
|
|
9615
|
+
});
|
|
9616
|
+
}
|
|
9617
|
+
|
|
9618
|
+
if (cfg.onMouseDown) {
|
|
9619
|
+
dotClickable.addEventListener('mousedown', (event) => {
|
|
9620
|
+
cfg.onMouseDown(event, this);
|
|
9621
|
+
});
|
|
9622
|
+
}
|
|
9623
|
+
|
|
9624
|
+
if (cfg.onMouseUp) {
|
|
9625
|
+
dotClickable.addEventListener('mouseup', (event) => {
|
|
9626
|
+
cfg.onMouseUp(event, this);
|
|
9627
|
+
});
|
|
9628
|
+
}
|
|
9629
|
+
|
|
9630
|
+
if (cfg.onMouseMove) {
|
|
9631
|
+
dotClickable.addEventListener('mousemove', (event) => {
|
|
9632
|
+
cfg.onMouseMove(event, this);
|
|
9633
|
+
});
|
|
9634
|
+
}
|
|
9635
|
+
|
|
9636
|
+
if (cfg.onTouchstart) {
|
|
9637
|
+
dotClickable.addEventListener('touchstart', (event) => {
|
|
9638
|
+
cfg.onTouchstart(event, this);
|
|
9639
|
+
});
|
|
9640
|
+
}
|
|
9641
|
+
|
|
9642
|
+
if (cfg.onTouchmove) {
|
|
9643
|
+
dotClickable.addEventListener('touchmove', (event) => {
|
|
9644
|
+
cfg.onTouchmove(event, this);
|
|
9645
|
+
});
|
|
9646
|
+
}
|
|
9647
|
+
|
|
9648
|
+
if (cfg.onTouchend) {
|
|
9649
|
+
dotClickable.addEventListener('touchend', (event) => {
|
|
9650
|
+
cfg.onTouchend(event, this);
|
|
9651
|
+
});
|
|
9652
|
+
}
|
|
9653
|
+
|
|
9654
|
+
if (cfg.onContextMenu) {
|
|
9655
|
+
if(os.isIphoneSafari()){
|
|
9656
|
+
dotClickable.addEventListener('touchstart', (event) => {
|
|
9657
|
+
event.preventDefault();
|
|
9658
|
+
if(this._timeout){
|
|
9659
|
+
clearTimeout(this._timeout);
|
|
9660
|
+
this._timeout = null;
|
|
9661
|
+
}
|
|
9662
|
+
this._timeout = setTimeout(() => {
|
|
9663
|
+
event.clientX = event.touches[0].clientX;
|
|
9664
|
+
event.clientY = event.touches[0].clientY;
|
|
9665
|
+
cfg.onContextMenu(event, this);
|
|
9666
|
+
clearTimeout(this._timeout);
|
|
9667
|
+
this._timeout = null;
|
|
9668
|
+
}, 500);
|
|
9669
|
+
});
|
|
9670
|
+
|
|
9671
|
+
dotClickable.addEventListener('touchend', (event) => {
|
|
9672
|
+
event.preventDefault();
|
|
9673
|
+
//stops short touches from calling the timeout
|
|
9674
|
+
if(this._timeout) {
|
|
9675
|
+
clearTimeout(this._timeout);
|
|
9676
|
+
this._timeout = null;
|
|
9677
|
+
}
|
|
9678
|
+
} );
|
|
9679
|
+
|
|
9680
|
+
}
|
|
9681
|
+
else {
|
|
9682
|
+
dotClickable.addEventListener('contextmenu', (event) => {
|
|
9683
|
+
console.log(event);
|
|
9684
|
+
cfg.onContextMenu(event, this);
|
|
9685
|
+
event.preventDefault();
|
|
9686
|
+
event.stopPropagation();
|
|
9687
|
+
console.log("Label context menu");
|
|
9688
|
+
});
|
|
9689
|
+
}
|
|
9690
|
+
|
|
9691
|
+
}
|
|
9692
|
+
|
|
9693
|
+
this.setPos(cfg.x || 0, cfg.y || 0);
|
|
9694
|
+
this.setFillColor(cfg.fillColor);
|
|
9695
|
+
this.setBorderColor(cfg.borderColor);
|
|
9696
|
+
}
|
|
9697
|
+
|
|
9698
|
+
setPos(x, y) {
|
|
9699
|
+
this._x = x;
|
|
9700
|
+
this._y = y;
|
|
9701
|
+
var dotStyle = this._dot.style;
|
|
9702
|
+
dotStyle["left"] = (Math.round(x) - 4) + 'px';
|
|
9703
|
+
dotStyle["top"] = (Math.round(y) - 4) + 'px';
|
|
9704
|
+
|
|
9705
|
+
var dotClickableStyle = this._dotClickable.style;
|
|
9706
|
+
dotClickableStyle["left"] = (Math.round(x) - 9) + 'px';
|
|
9707
|
+
dotClickableStyle["top"] = (Math.round(y) - 9) + 'px';
|
|
9708
|
+
}
|
|
9709
|
+
|
|
9710
|
+
setFillColor(color) {
|
|
9711
|
+
this._dot.style.background = color || "lightgreen";
|
|
9712
|
+
}
|
|
9713
|
+
|
|
9714
|
+
setBorderColor(color) {
|
|
9715
|
+
this._dot.style.border = "solid 2px" + (color || "black");
|
|
9716
|
+
}
|
|
9717
|
+
|
|
9718
|
+
setOpacity(opacity) {
|
|
9719
|
+
this._dot.style.opacity = opacity;
|
|
9720
|
+
}
|
|
9721
|
+
|
|
9722
|
+
setVisible(visible) {
|
|
9723
|
+
if (this._visible === visible) {
|
|
9724
|
+
return;
|
|
9725
|
+
}
|
|
9726
|
+
this._visible = !!visible;
|
|
9727
|
+
this._dot.style.visibility = this._visible && !this._culled ? "visible" : "hidden";
|
|
9728
|
+
}
|
|
9729
|
+
|
|
9730
|
+
setCulled(culled) {
|
|
9731
|
+
if (this._culled === culled) {
|
|
9732
|
+
return;
|
|
9733
|
+
}
|
|
9734
|
+
this._culled = !!culled;
|
|
9735
|
+
this._dot.style.visibility = this._visible && !this._culled ? "visible" : "hidden";
|
|
9736
|
+
}
|
|
9737
|
+
|
|
9738
|
+
setClickable(clickable) {
|
|
9739
|
+
this._dotClickable.style["pointer-events"] = (clickable) ? "all" : "none";
|
|
9740
|
+
}
|
|
9741
|
+
|
|
9742
|
+
setHighlighted(highlighted) {
|
|
9743
|
+
if (this._highlighted === highlighted) {
|
|
9744
|
+
return;
|
|
9745
|
+
}
|
|
9746
|
+
this._highlighted = !!highlighted;
|
|
9747
|
+
if (this._highlighted) {
|
|
9748
|
+
this._dot.classList.add(this._highlightClass);
|
|
9749
|
+
} else {
|
|
9750
|
+
this._dot.classList.remove(this._highlightClass);
|
|
9751
|
+
}
|
|
9752
|
+
}
|
|
9753
|
+
|
|
9754
|
+
destroy() {
|
|
9755
|
+
this.setVisible(false);
|
|
9756
|
+
if (this._dot.parentElement) {
|
|
9757
|
+
this._dot.parentElement.removeChild(this._dot);
|
|
9758
|
+
}
|
|
9759
|
+
if (this._dotClickable.parentElement) {
|
|
9760
|
+
this._dotClickable.parentElement.removeChild(this._dotClickable);
|
|
9761
|
+
}
|
|
9762
|
+
}
|
|
9763
|
+
}
|
|
9764
|
+
|
|
9532
9765
|
const tempVec3a$L = math.vec3();
|
|
9533
9766
|
|
|
9534
9767
|
/**
|
|
@@ -10589,11 +10822,17 @@ class Marker extends Component {
|
|
|
10589
10822
|
return;
|
|
10590
10823
|
}
|
|
10591
10824
|
if (this._onEntityDestroyed !== null) {
|
|
10592
|
-
this._entity.model
|
|
10825
|
+
if (this._entity.model) {
|
|
10826
|
+
this._entity.model.off(this._onEntityDestroyed);
|
|
10827
|
+
} else {
|
|
10828
|
+
this._entity.off(this._onEntityDestroyed);
|
|
10829
|
+
}
|
|
10593
10830
|
this._onEntityDestroyed = null;
|
|
10594
10831
|
}
|
|
10595
10832
|
if (this._onEntityModelDestroyed !== null) {
|
|
10596
|
-
this._entity.model
|
|
10833
|
+
if (this._entity.model) {
|
|
10834
|
+
this._entity.model.off(this._onEntityModelDestroyed);
|
|
10835
|
+
}
|
|
10597
10836
|
this._onEntityModelDestroyed = null;
|
|
10598
10837
|
}
|
|
10599
10838
|
}
|
|
@@ -10605,7 +10844,7 @@ class Marker extends Component {
|
|
|
10605
10844
|
this._onEntityModelDestroyed = null;
|
|
10606
10845
|
});
|
|
10607
10846
|
} else {
|
|
10608
|
-
this._onEntityDestroyed = this._entity.
|
|
10847
|
+
this._onEntityDestroyed = this._entity.on("destroyed", () => {
|
|
10609
10848
|
this._entity = null;
|
|
10610
10849
|
this._onEntityDestroyed = null;
|
|
10611
10850
|
});
|
|
@@ -10774,15 +11013,286 @@ class Marker extends Component {
|
|
|
10774
11013
|
}
|
|
10775
11014
|
}
|
|
10776
11015
|
|
|
10777
|
-
const
|
|
10778
|
-
isIphoneSafari() {
|
|
10779
|
-
const userAgent = window.navigator.userAgent;
|
|
10780
|
-
const isIphone = /iPhone/i.test(userAgent);
|
|
10781
|
-
const isSafari = /Safari/i.test(userAgent) && !/Chrome/i.test(userAgent);
|
|
11016
|
+
const nop = () => { };
|
|
10782
11017
|
|
|
10783
|
-
|
|
11018
|
+
function transformToNode(from, to, vec) {
|
|
11019
|
+
const fromRec = from.getBoundingClientRect();
|
|
11020
|
+
const toRec = to.getBoundingClientRect();
|
|
11021
|
+
vec[0] += fromRec.left - toRec.left;
|
|
11022
|
+
vec[1] += fromRec.top - toRec.top;
|
|
11023
|
+
}
|
|
11024
|
+
class Dot3D extends Marker {
|
|
11025
|
+
constructor(scene, markerCfg, parentElement, cfg = {}) {
|
|
11026
|
+
super(scene, markerCfg);
|
|
11027
|
+
|
|
11028
|
+
const handler = (cfgEvent, componentEvent) => {
|
|
11029
|
+
return event => {
|
|
11030
|
+
if (cfgEvent) {
|
|
11031
|
+
cfgEvent(event);
|
|
11032
|
+
}
|
|
11033
|
+
this.fire(componentEvent, event, true);
|
|
11034
|
+
};
|
|
11035
|
+
};
|
|
11036
|
+
this._dot = new Dot(parentElement, {
|
|
11037
|
+
fillColor: cfg.fillColor,
|
|
11038
|
+
zIndex: cfg.zIndex,
|
|
11039
|
+
onMouseOver: handler(cfg.onMouseOver, "mouseover"),
|
|
11040
|
+
onMouseLeave: handler(cfg.onMouseLeave, "mouseleave"),
|
|
11041
|
+
onMouseWheel: handler(cfg.onMouseWheel, "wheel"),
|
|
11042
|
+
onMouseDown: handler(cfg.onMouseDown, "mousedown"),
|
|
11043
|
+
onMouseUp: handler(cfg.onMouseUp, "mouseup"),
|
|
11044
|
+
onMouseMove: handler(cfg.onMouseMove, "mousemove"),
|
|
11045
|
+
onTouchstart: handler(cfg.onTouchstart, "touchstart"),
|
|
11046
|
+
onTouchmove: handler(cfg.onTouchmove, "touchmove"),
|
|
11047
|
+
onTouchend: handler(cfg.onTouchend, "touchend"),
|
|
11048
|
+
onContextMenu: handler(cfg.onContextMenu, "contextmenu")
|
|
11049
|
+
});
|
|
11050
|
+
|
|
11051
|
+
const updateDotPos = () => {
|
|
11052
|
+
const pos = this.canvasPos.slice();
|
|
11053
|
+
transformToNode(scene.canvas.canvas, parentElement, pos);
|
|
11054
|
+
this._dot.setPos(pos[0], pos[1]);
|
|
11055
|
+
};
|
|
11056
|
+
|
|
11057
|
+
this.on("worldPos", updateDotPos);
|
|
11058
|
+
|
|
11059
|
+
const onViewMatrix = scene.camera.on("viewMatrix", updateDotPos);
|
|
11060
|
+
const onProjMatrix = scene.camera.on("projMatrix", updateDotPos);
|
|
11061
|
+
this._cleanup = () => {
|
|
11062
|
+
scene.camera.off(onViewMatrix);
|
|
11063
|
+
scene.camera.off(onProjMatrix);
|
|
11064
|
+
this._dot.destroy();
|
|
11065
|
+
};
|
|
10784
11066
|
}
|
|
10785
|
-
|
|
11067
|
+
|
|
11068
|
+
setClickable(value) {
|
|
11069
|
+
this._dot.setClickable(value);
|
|
11070
|
+
}
|
|
11071
|
+
|
|
11072
|
+
setCulled(value) {
|
|
11073
|
+
this._dot.setCulled(value);
|
|
11074
|
+
}
|
|
11075
|
+
|
|
11076
|
+
setFillColor(value) {
|
|
11077
|
+
this._dot.setFillColor(value);
|
|
11078
|
+
}
|
|
11079
|
+
|
|
11080
|
+
setHighlighted(value) {
|
|
11081
|
+
this._dot.setHighlighted(value);
|
|
11082
|
+
}
|
|
11083
|
+
|
|
11084
|
+
setOpacity(value) {
|
|
11085
|
+
this._dot.setOpacity(value);
|
|
11086
|
+
}
|
|
11087
|
+
|
|
11088
|
+
setVisible(value) {
|
|
11089
|
+
this._dot.setVisible(value);
|
|
11090
|
+
}
|
|
11091
|
+
|
|
11092
|
+
destroy() {
|
|
11093
|
+
this._cleanup();
|
|
11094
|
+
super.destroy();
|
|
11095
|
+
}
|
|
11096
|
+
|
|
11097
|
+
}
|
|
11098
|
+
|
|
11099
|
+
function activateDraggableDot(dot, cfg) {
|
|
11100
|
+
const extractCFG = function(propName, defaultValue) {
|
|
11101
|
+
if (propName in cfg) {
|
|
11102
|
+
return cfg[propName];
|
|
11103
|
+
} else if (defaultValue !== undefined) {
|
|
11104
|
+
return defaultValue;
|
|
11105
|
+
} else {
|
|
11106
|
+
throw "config missing: " + propName;
|
|
11107
|
+
}
|
|
11108
|
+
};
|
|
11109
|
+
|
|
11110
|
+
const viewer = extractCFG("viewer");
|
|
11111
|
+
const ray2WorldPos = extractCFG("ray2WorldPos");
|
|
11112
|
+
const handleMouseEvents = extractCFG("handleMouseEvents", false);
|
|
11113
|
+
const handleTouchEvents = extractCFG("handleTouchEvents", false);
|
|
11114
|
+
const onStart = extractCFG("onStart", nop);
|
|
11115
|
+
const onMove = extractCFG("onMove", nop);
|
|
11116
|
+
const onEnd = extractCFG("onEnd", nop);
|
|
11117
|
+
|
|
11118
|
+
const scene = viewer.scene;
|
|
11119
|
+
const canvas = scene.canvas.canvas;
|
|
11120
|
+
|
|
11121
|
+
const pickWorldPos = canvasPos => {
|
|
11122
|
+
const origin = math.vec3();
|
|
11123
|
+
const direction = math.vec3();
|
|
11124
|
+
math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, canvasPos, origin, direction);
|
|
11125
|
+
return ray2WorldPos(origin, direction, canvasPos);
|
|
11126
|
+
};
|
|
11127
|
+
|
|
11128
|
+
const onChange = event => {
|
|
11129
|
+
const canvasPos = math.vec2([ event.clientX, event.clientY ]);
|
|
11130
|
+
transformToNode(canvas.ownerDocument.body, canvas, canvasPos);
|
|
11131
|
+
onMove(canvasPos, pickWorldPos(canvasPos));
|
|
11132
|
+
};
|
|
11133
|
+
|
|
11134
|
+
let currentDrag = null;
|
|
11135
|
+
|
|
11136
|
+
const onDragMove = function(event) {
|
|
11137
|
+
const e = currentDrag.matchesEvent(event);
|
|
11138
|
+
if (e)
|
|
11139
|
+
{
|
|
11140
|
+
onChange(e);
|
|
11141
|
+
}
|
|
11142
|
+
};
|
|
11143
|
+
|
|
11144
|
+
const onDragEnd = function(event) {
|
|
11145
|
+
const e = currentDrag.matchesEvent(event);
|
|
11146
|
+
if (e)
|
|
11147
|
+
{
|
|
11148
|
+
dot.setOpacity(idleOpacity);
|
|
11149
|
+
currentDrag.cleanup();
|
|
11150
|
+
onChange(e);
|
|
11151
|
+
onEnd();
|
|
11152
|
+
}
|
|
11153
|
+
};
|
|
11154
|
+
|
|
11155
|
+
const startDrag = function(matchesEvent, cleanupHandlers) {
|
|
11156
|
+
if (currentDrag) {
|
|
11157
|
+
currentDrag.cleanup();
|
|
11158
|
+
}
|
|
11159
|
+
|
|
11160
|
+
dot.setOpacity(1.0);
|
|
11161
|
+
dot.setClickable(false);
|
|
11162
|
+
viewer.cameraControl.active = false;
|
|
11163
|
+
|
|
11164
|
+
currentDrag = {
|
|
11165
|
+
matchesEvent: matchesEvent,
|
|
11166
|
+
cleanup: function() {
|
|
11167
|
+
currentDrag = null;
|
|
11168
|
+
dot.setClickable(true);
|
|
11169
|
+
viewer.cameraControl.active = true;
|
|
11170
|
+
cleanupHandlers();
|
|
11171
|
+
}
|
|
11172
|
+
};
|
|
11173
|
+
|
|
11174
|
+
onStart();
|
|
11175
|
+
};
|
|
11176
|
+
|
|
11177
|
+
const cleanupDotHandlers = [ ];
|
|
11178
|
+
const dot_on = function(event, callback) {
|
|
11179
|
+
const id = dot.on(event, callback);
|
|
11180
|
+
cleanupDotHandlers.push(() => dot.off(id));
|
|
11181
|
+
};
|
|
11182
|
+
|
|
11183
|
+
if (handleMouseEvents)
|
|
11184
|
+
{
|
|
11185
|
+
dot_on("mouseover", () => (! currentDrag) && dot.setOpacity(1.0));
|
|
11186
|
+
dot_on("mouseleave", () => (! currentDrag) && dot.setOpacity(idleOpacity));
|
|
11187
|
+
dot_on("mousedown", event => {
|
|
11188
|
+
if (event.which === 1)
|
|
11189
|
+
{
|
|
11190
|
+
canvas.addEventListener("mousemove", onDragMove);
|
|
11191
|
+
canvas.addEventListener("mouseup", onDragEnd);
|
|
11192
|
+
startDrag(
|
|
11193
|
+
event => (event.which === 1) && event,
|
|
11194
|
+
() => {
|
|
11195
|
+
canvas.removeEventListener("mousemove", onDragMove);
|
|
11196
|
+
canvas.removeEventListener("mouseup", onDragEnd);
|
|
11197
|
+
});
|
|
11198
|
+
}
|
|
11199
|
+
});
|
|
11200
|
+
}
|
|
11201
|
+
|
|
11202
|
+
if (handleTouchEvents)
|
|
11203
|
+
{
|
|
11204
|
+
let touchStartId;
|
|
11205
|
+
dot_on("touchstart", event => {
|
|
11206
|
+
event.preventDefault();
|
|
11207
|
+
if (event.touches.length === 1)
|
|
11208
|
+
{
|
|
11209
|
+
touchStartId = event.touches[0].identifier;
|
|
11210
|
+
startDrag(
|
|
11211
|
+
event => [...event.changedTouches].find(e => e.identifier === touchStartId),
|
|
11212
|
+
() => { touchStartId = null; });
|
|
11213
|
+
}
|
|
11214
|
+
});
|
|
11215
|
+
dot_on("touchmove", event => {
|
|
11216
|
+
event.preventDefault();
|
|
11217
|
+
onDragMove(event);
|
|
11218
|
+
});
|
|
11219
|
+
dot_on("touchend", event => {
|
|
11220
|
+
event.preventDefault();
|
|
11221
|
+
onDragEnd(event);
|
|
11222
|
+
});
|
|
11223
|
+
}
|
|
11224
|
+
|
|
11225
|
+
const idleOpacity = 0.8;
|
|
11226
|
+
dot.setOpacity(idleOpacity);
|
|
11227
|
+
|
|
11228
|
+
return function() {
|
|
11229
|
+
currentDrag && currentDrag.cleanup();
|
|
11230
|
+
cleanupDotHandlers.forEach(c => c());
|
|
11231
|
+
dot.setOpacity(1.0);
|
|
11232
|
+
};
|
|
11233
|
+
}
|
|
11234
|
+
function activateDraggableDots(cfg) {
|
|
11235
|
+
const extractCFG = function(propName, defaultValue) {
|
|
11236
|
+
if (propName in cfg) {
|
|
11237
|
+
return cfg[propName];
|
|
11238
|
+
} else if (defaultValue !== undefined) {
|
|
11239
|
+
return defaultValue;
|
|
11240
|
+
} else {
|
|
11241
|
+
throw "config missing: " + propName;
|
|
11242
|
+
}
|
|
11243
|
+
};
|
|
11244
|
+
|
|
11245
|
+
const viewer = extractCFG("viewer");
|
|
11246
|
+
const handleMouseEvents = extractCFG("handleMouseEvents", false);
|
|
11247
|
+
const handleTouchEvents = extractCFG("handleTouchEvents", false);
|
|
11248
|
+
const pointerLens = extractCFG("pointerLens", null);
|
|
11249
|
+
const dots = extractCFG("dots");
|
|
11250
|
+
const ray2WorldPos = extractCFG("ray2WorldPos");
|
|
11251
|
+
const onEnd = extractCFG("onEnd", nop);
|
|
11252
|
+
|
|
11253
|
+
const updatePointerLens = (pointerLens
|
|
11254
|
+
? function(canvasPos) {
|
|
11255
|
+
pointerLens.visible = !! canvasPos;
|
|
11256
|
+
if (canvasPos)
|
|
11257
|
+
{
|
|
11258
|
+
pointerLens.canvasPos = canvasPos;
|
|
11259
|
+
}
|
|
11260
|
+
}
|
|
11261
|
+
: () => { });
|
|
11262
|
+
|
|
11263
|
+
const cleanups = dots.map(dot => {
|
|
11264
|
+
let initPos;
|
|
11265
|
+
return activateDraggableDot(dot, {
|
|
11266
|
+
handleMouseEvents: handleMouseEvents,
|
|
11267
|
+
handleTouchEvents: handleTouchEvents,
|
|
11268
|
+
viewer: viewer,
|
|
11269
|
+
ray2WorldPos: (orig, dir, canvasPos) => (ray2WorldPos(orig, dir, canvasPos) || initPos),
|
|
11270
|
+
onStart: () => {
|
|
11271
|
+
initPos = dot.worldPos.slice();
|
|
11272
|
+
setOtherDotsActive(false, dot);
|
|
11273
|
+
},
|
|
11274
|
+
onMove: (canvasPos, worldPos) => {
|
|
11275
|
+
updatePointerLens(canvasPos);
|
|
11276
|
+
dot.worldPos = worldPos;
|
|
11277
|
+
},
|
|
11278
|
+
onEnd: () => {
|
|
11279
|
+
if (! onEnd(initPos, dot)) {
|
|
11280
|
+
dot.worldPos = initPos;
|
|
11281
|
+
}
|
|
11282
|
+
updatePointerLens(null);
|
|
11283
|
+
setOtherDotsActive(true, dot);
|
|
11284
|
+
}
|
|
11285
|
+
});
|
|
11286
|
+
});
|
|
11287
|
+
|
|
11288
|
+
const setOtherDotsActive = (active, dot) => dots.forEach(d => (d !== dot) && d.setClickable(active));
|
|
11289
|
+
setOtherDotsActive(true);
|
|
11290
|
+
|
|
11291
|
+
return function() {
|
|
11292
|
+
cleanups.forEach(c => c());
|
|
11293
|
+
updatePointerLens(null);
|
|
11294
|
+
};
|
|
11295
|
+
}
|
|
10786
11296
|
|
|
10787
11297
|
/** @private */
|
|
10788
11298
|
class Wire {
|
|
@@ -11031,229 +11541,6 @@ class Wire {
|
|
|
11031
11541
|
}
|
|
11032
11542
|
}
|
|
11033
11543
|
|
|
11034
|
-
/** @private */
|
|
11035
|
-
class Dot {
|
|
11036
|
-
|
|
11037
|
-
constructor(parentElement, cfg = {}) {
|
|
11038
|
-
|
|
11039
|
-
this._highlightClass = "viewer-ruler-dot-highlighted";
|
|
11040
|
-
|
|
11041
|
-
this._x = 0;
|
|
11042
|
-
this._y = 0;
|
|
11043
|
-
|
|
11044
|
-
this._dot = document.createElement('div');
|
|
11045
|
-
this._dot.className += this._dot.className ? ' viewer-ruler-dot' : 'viewer-ruler-dot';
|
|
11046
|
-
|
|
11047
|
-
this._dotClickable = document.createElement('div');
|
|
11048
|
-
this._dotClickable.className += this._dotClickable.className ? ' viewer-ruler-dot-clickable' : 'viewer-ruler-dot-clickable';
|
|
11049
|
-
|
|
11050
|
-
this._visible = !!cfg.visible;
|
|
11051
|
-
this._culled = false;
|
|
11052
|
-
|
|
11053
|
-
var dot = this._dot;
|
|
11054
|
-
var dotStyle = dot.style;
|
|
11055
|
-
dotStyle["border-radius"] = 25 + "px";
|
|
11056
|
-
dotStyle.border = "solid 2px white";
|
|
11057
|
-
dotStyle.background = "lightgreen";
|
|
11058
|
-
dotStyle.position = "absolute";
|
|
11059
|
-
dotStyle["z-index"] = cfg.zIndex === undefined ? "40000005" : cfg.zIndex ;
|
|
11060
|
-
dotStyle.width = 8 + "px";
|
|
11061
|
-
dotStyle.height = 8 + "px";
|
|
11062
|
-
dotStyle.visibility = cfg.visible !== false ? "visible" : "hidden";
|
|
11063
|
-
dotStyle.top = 0 + "px";
|
|
11064
|
-
dotStyle.left = 0 + "px";
|
|
11065
|
-
dotStyle["box-shadow"] = "0 2px 5px 0 #182A3D;";
|
|
11066
|
-
dotStyle["opacity"] = 1.0;
|
|
11067
|
-
dotStyle["pointer-events"] = "none";
|
|
11068
|
-
if (cfg.onContextMenu) ;
|
|
11069
|
-
parentElement.appendChild(dot);
|
|
11070
|
-
|
|
11071
|
-
var dotClickable = this._dotClickable;
|
|
11072
|
-
var dotClickableStyle = dotClickable.style;
|
|
11073
|
-
dotClickableStyle["border-radius"] = 35 + "px";
|
|
11074
|
-
dotClickableStyle.border = "solid 10px white";
|
|
11075
|
-
dotClickableStyle.position = "absolute";
|
|
11076
|
-
dotClickableStyle["z-index"] = cfg.zIndex === undefined ? "40000007" : (cfg.zIndex + 1);
|
|
11077
|
-
dotClickableStyle.width = 8 + "px";
|
|
11078
|
-
dotClickableStyle.height = 8 + "px";
|
|
11079
|
-
dotClickableStyle.visibility = "visible";
|
|
11080
|
-
dotClickableStyle.top = 0 + "px";
|
|
11081
|
-
dotClickableStyle.left = 0 + "px";
|
|
11082
|
-
dotClickableStyle["opacity"] = 0.0;
|
|
11083
|
-
dotClickableStyle["pointer-events"] = "none";
|
|
11084
|
-
if (cfg.onContextMenu) ;
|
|
11085
|
-
parentElement.appendChild(dotClickable);
|
|
11086
|
-
|
|
11087
|
-
dotClickable.addEventListener('click', (event) => {
|
|
11088
|
-
parentElement.dispatchEvent(new MouseEvent('mouseover', event));
|
|
11089
|
-
});
|
|
11090
|
-
|
|
11091
|
-
if (cfg.onMouseOver) {
|
|
11092
|
-
dotClickable.addEventListener('mouseover', (event) => {
|
|
11093
|
-
cfg.onMouseOver(event, this);
|
|
11094
|
-
parentElement.dispatchEvent(new MouseEvent('mouseover', event));
|
|
11095
|
-
});
|
|
11096
|
-
}
|
|
11097
|
-
|
|
11098
|
-
if (cfg.onMouseLeave) {
|
|
11099
|
-
dotClickable.addEventListener('mouseleave', (event) => {
|
|
11100
|
-
cfg.onMouseLeave(event, this);
|
|
11101
|
-
});
|
|
11102
|
-
}
|
|
11103
|
-
|
|
11104
|
-
if (cfg.onMouseWheel) {
|
|
11105
|
-
dotClickable.addEventListener('wheel', (event) => {
|
|
11106
|
-
cfg.onMouseWheel(event, this);
|
|
11107
|
-
});
|
|
11108
|
-
}
|
|
11109
|
-
|
|
11110
|
-
if (cfg.onMouseDown) {
|
|
11111
|
-
dotClickable.addEventListener('mousedown', (event) => {
|
|
11112
|
-
cfg.onMouseDown(event, this);
|
|
11113
|
-
});
|
|
11114
|
-
}
|
|
11115
|
-
|
|
11116
|
-
if (cfg.onMouseUp) {
|
|
11117
|
-
dotClickable.addEventListener('mouseup', (event) => {
|
|
11118
|
-
cfg.onMouseUp(event, this);
|
|
11119
|
-
});
|
|
11120
|
-
}
|
|
11121
|
-
|
|
11122
|
-
if (cfg.onMouseMove) {
|
|
11123
|
-
dotClickable.addEventListener('mousemove', (event) => {
|
|
11124
|
-
cfg.onMouseMove(event, this);
|
|
11125
|
-
});
|
|
11126
|
-
}
|
|
11127
|
-
|
|
11128
|
-
if (cfg.onContextMenu) {
|
|
11129
|
-
if(os.isIphoneSafari()){
|
|
11130
|
-
dotClickable.addEventListener('touchstart', (event) => {
|
|
11131
|
-
event.preventDefault();
|
|
11132
|
-
if(this._timeout){
|
|
11133
|
-
clearTimeout(this._timeout);
|
|
11134
|
-
this._timeout = null;
|
|
11135
|
-
}
|
|
11136
|
-
this._timeout = setTimeout(() => {
|
|
11137
|
-
event.clientX = event.touches[0].clientX;
|
|
11138
|
-
event.clientY = event.touches[0].clientY;
|
|
11139
|
-
cfg.onContextMenu(event, this);
|
|
11140
|
-
clearTimeout(this._timeout);
|
|
11141
|
-
this._timeout = null;
|
|
11142
|
-
}, 500);
|
|
11143
|
-
});
|
|
11144
|
-
|
|
11145
|
-
dotClickable.addEventListener('touchend', (event) => {
|
|
11146
|
-
event.preventDefault();
|
|
11147
|
-
//stops short touches from calling the timeout
|
|
11148
|
-
if(this._timeout) {
|
|
11149
|
-
clearTimeout(this._timeout);
|
|
11150
|
-
this._timeout = null;
|
|
11151
|
-
}
|
|
11152
|
-
} );
|
|
11153
|
-
|
|
11154
|
-
}
|
|
11155
|
-
else {
|
|
11156
|
-
dotClickable.addEventListener('contextmenu', (event) => {
|
|
11157
|
-
console.log(event);
|
|
11158
|
-
cfg.onContextMenu(event, this);
|
|
11159
|
-
event.preventDefault();
|
|
11160
|
-
event.stopPropagation();
|
|
11161
|
-
console.log("Label context menu");
|
|
11162
|
-
});
|
|
11163
|
-
}
|
|
11164
|
-
|
|
11165
|
-
}
|
|
11166
|
-
|
|
11167
|
-
if (cfg.onTouchstart) {
|
|
11168
|
-
dotClickable.addEventListener('touchstart', (event) => {
|
|
11169
|
-
cfg.onTouchstart(event, this);
|
|
11170
|
-
});
|
|
11171
|
-
}
|
|
11172
|
-
|
|
11173
|
-
if (cfg.onTouchmove) {
|
|
11174
|
-
dotClickable.addEventListener('touchmove', (event) => {
|
|
11175
|
-
cfg.onTouchmove(event, this);
|
|
11176
|
-
});
|
|
11177
|
-
}
|
|
11178
|
-
|
|
11179
|
-
if (cfg.onTouchend) {
|
|
11180
|
-
dotClickable.addEventListener('touchend', (event) => {
|
|
11181
|
-
cfg.onTouchend(event, this);
|
|
11182
|
-
});
|
|
11183
|
-
}
|
|
11184
|
-
|
|
11185
|
-
this.setPos(cfg.x || 0, cfg.y || 0);
|
|
11186
|
-
this.setFillColor(cfg.fillColor);
|
|
11187
|
-
this.setBorderColor(cfg.borderColor);
|
|
11188
|
-
}
|
|
11189
|
-
|
|
11190
|
-
setPos(x, y) {
|
|
11191
|
-
this._x = x;
|
|
11192
|
-
this._y = y;
|
|
11193
|
-
var dotStyle = this._dot.style;
|
|
11194
|
-
dotStyle["left"] = (Math.round(x) - 4) + 'px';
|
|
11195
|
-
dotStyle["top"] = (Math.round(y) - 4) + 'px';
|
|
11196
|
-
|
|
11197
|
-
var dotClickableStyle = this._dotClickable.style;
|
|
11198
|
-
dotClickableStyle["left"] = (Math.round(x) - 9) + 'px';
|
|
11199
|
-
dotClickableStyle["top"] = (Math.round(y) - 9) + 'px';
|
|
11200
|
-
}
|
|
11201
|
-
|
|
11202
|
-
setFillColor(color) {
|
|
11203
|
-
this._dot.style.background = color || "lightgreen";
|
|
11204
|
-
}
|
|
11205
|
-
|
|
11206
|
-
setBorderColor(color) {
|
|
11207
|
-
this._dot.style.border = "solid 2px" + (color || "black");
|
|
11208
|
-
}
|
|
11209
|
-
|
|
11210
|
-
setOpacity(opacity) {
|
|
11211
|
-
this._dot.style.opacity = opacity;
|
|
11212
|
-
}
|
|
11213
|
-
|
|
11214
|
-
setVisible(visible) {
|
|
11215
|
-
if (this._visible === visible) {
|
|
11216
|
-
return;
|
|
11217
|
-
}
|
|
11218
|
-
this._visible = !!visible;
|
|
11219
|
-
this._dot.style.visibility = this._visible && !this._culled ? "visible" : "hidden";
|
|
11220
|
-
}
|
|
11221
|
-
|
|
11222
|
-
setCulled(culled) {
|
|
11223
|
-
if (this._culled === culled) {
|
|
11224
|
-
return;
|
|
11225
|
-
}
|
|
11226
|
-
this._culled = !!culled;
|
|
11227
|
-
this._dot.style.visibility = this._visible && !this._culled ? "visible" : "hidden";
|
|
11228
|
-
}
|
|
11229
|
-
|
|
11230
|
-
setClickable(clickable) {
|
|
11231
|
-
this._dotClickable.style["pointer-events"] = (clickable) ? "all" : "none";
|
|
11232
|
-
}
|
|
11233
|
-
|
|
11234
|
-
setHighlighted(highlighted) {
|
|
11235
|
-
if (this._highlighted === highlighted) {
|
|
11236
|
-
return;
|
|
11237
|
-
}
|
|
11238
|
-
this._highlighted = !!highlighted;
|
|
11239
|
-
if (this._highlighted) {
|
|
11240
|
-
this._dot.classList.add(this._highlightClass);
|
|
11241
|
-
} else {
|
|
11242
|
-
this._dot.classList.remove(this._highlightClass);
|
|
11243
|
-
}
|
|
11244
|
-
}
|
|
11245
|
-
|
|
11246
|
-
destroy() {
|
|
11247
|
-
this.setVisible(false);
|
|
11248
|
-
if (this._dot.parentElement) {
|
|
11249
|
-
this._dot.parentElement.removeChild(this._dot);
|
|
11250
|
-
}
|
|
11251
|
-
if (this._dotClickable.parentElement) {
|
|
11252
|
-
this._dotClickable.parentElement.removeChild(this._dotClickable);
|
|
11253
|
-
}
|
|
11254
|
-
}
|
|
11255
|
-
}
|
|
11256
|
-
|
|
11257
11544
|
/** @private */
|
|
11258
11545
|
class Label {
|
|
11259
11546
|
|
|
@@ -11500,10 +11787,6 @@ class AngleMeasurement extends Component {
|
|
|
11500
11787
|
|
|
11501
11788
|
var scene = this.plugin.viewer.scene;
|
|
11502
11789
|
|
|
11503
|
-
this._originMarker = new Marker(scene, cfg.origin);
|
|
11504
|
-
this._cornerMarker = new Marker(scene, cfg.corner);
|
|
11505
|
-
this._targetMarker = new Marker(scene, cfg.target);
|
|
11506
|
-
|
|
11507
11790
|
this._originWorld = math.vec3();
|
|
11508
11791
|
this._cornerWorld = math.vec3();
|
|
11509
11792
|
this._targetWorld = math.vec3();
|
|
@@ -11543,7 +11826,7 @@ class AngleMeasurement extends Component {
|
|
|
11543
11826
|
this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new MouseEvent('mousemove', event));
|
|
11544
11827
|
};
|
|
11545
11828
|
|
|
11546
|
-
this._originDot = new
|
|
11829
|
+
this._originDot = new Dot3D(scene, cfg.origin, this._container, {
|
|
11547
11830
|
fillColor: this._color,
|
|
11548
11831
|
zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2 : undefined,
|
|
11549
11832
|
onMouseOver,
|
|
@@ -11554,7 +11837,7 @@ class AngleMeasurement extends Component {
|
|
|
11554
11837
|
onMouseMove,
|
|
11555
11838
|
onContextMenu
|
|
11556
11839
|
});
|
|
11557
|
-
this._cornerDot = new
|
|
11840
|
+
this._cornerDot = new Dot3D(scene, cfg.corner, this._container, {
|
|
11558
11841
|
fillColor: this._color,
|
|
11559
11842
|
zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2 : undefined,
|
|
11560
11843
|
onMouseOver,
|
|
@@ -11565,7 +11848,7 @@ class AngleMeasurement extends Component {
|
|
|
11565
11848
|
onMouseMove,
|
|
11566
11849
|
onContextMenu
|
|
11567
11850
|
});
|
|
11568
|
-
this._targetDot = new
|
|
11851
|
+
this._targetDot = new Dot3D(scene, cfg.target, this._container, {
|
|
11569
11852
|
fillColor: this._color,
|
|
11570
11853
|
zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2 : undefined,
|
|
11571
11854
|
onMouseOver,
|
|
@@ -11632,19 +11915,19 @@ class AngleMeasurement extends Component {
|
|
|
11632
11915
|
this._labelsVisible = false;
|
|
11633
11916
|
this._clickable = false;
|
|
11634
11917
|
|
|
11635
|
-
this.
|
|
11918
|
+
this._originDot.on("worldPos", (value) => {
|
|
11636
11919
|
this._originWorld.set(value || [0, 0, 0]);
|
|
11637
11920
|
this._wpDirty = true;
|
|
11638
11921
|
this._needUpdate(0); // No lag
|
|
11639
11922
|
});
|
|
11640
11923
|
|
|
11641
|
-
this.
|
|
11924
|
+
this._cornerDot.on("worldPos", (value) => {
|
|
11642
11925
|
this._cornerWorld.set(value || [0, 0, 0]);
|
|
11643
11926
|
this._wpDirty = true;
|
|
11644
11927
|
this._needUpdate(0); // No lag
|
|
11645
11928
|
});
|
|
11646
11929
|
|
|
11647
|
-
this.
|
|
11930
|
+
this._targetDot.on("worldPos", (value) => {
|
|
11648
11931
|
this._targetWorld.set(value || [0, 0, 0]);
|
|
11649
11932
|
this._wpDirty = true;
|
|
11650
11933
|
this._needUpdate(0); // No lag
|
|
@@ -11750,9 +12033,9 @@ class AngleMeasurement extends Component {
|
|
|
11750
12033
|
if (this._cpDirty) {
|
|
11751
12034
|
|
|
11752
12035
|
const near = -0.3;
|
|
11753
|
-
const zOrigin = this.
|
|
11754
|
-
const zCorner = this.
|
|
11755
|
-
const zTarget = this.
|
|
12036
|
+
const zOrigin = this._originDot.viewPos[2];
|
|
12037
|
+
const zCorner = this._cornerDot.viewPos[2];
|
|
12038
|
+
const zTarget = this._targetDot.viewPos[2];
|
|
11756
12039
|
|
|
11757
12040
|
if (zOrigin > near || zCorner > near || zTarget > near) {
|
|
11758
12041
|
|
|
@@ -11789,10 +12072,6 @@ class AngleMeasurement extends Component {
|
|
|
11789
12072
|
j += 2;
|
|
11790
12073
|
}
|
|
11791
12074
|
|
|
11792
|
-
this._originDot.setPos(cp[0], cp[1]);
|
|
11793
|
-
this._cornerDot.setPos(cp[2], cp[3]);
|
|
11794
|
-
this._targetDot.setPos(cp[4], cp[5]);
|
|
11795
|
-
|
|
11796
12075
|
this._originWire.setStartAndEnd(cp[0], cp[1], cp[2], cp[3]);
|
|
11797
12076
|
this._targetWire.setStartAndEnd(cp[2], cp[3], cp[4], cp[5]);
|
|
11798
12077
|
|
|
@@ -11873,30 +12152,30 @@ class AngleMeasurement extends Component {
|
|
|
11873
12152
|
}
|
|
11874
12153
|
|
|
11875
12154
|
/**
|
|
11876
|
-
* Gets the origin {@link
|
|
12155
|
+
* Gets the origin {@link Dot3D}.
|
|
11877
12156
|
*
|
|
11878
|
-
* @type {
|
|
12157
|
+
* @type {Dot3D}
|
|
11879
12158
|
*/
|
|
11880
12159
|
get origin() {
|
|
11881
|
-
return this.
|
|
12160
|
+
return this._originDot;
|
|
11882
12161
|
}
|
|
11883
12162
|
|
|
11884
12163
|
/**
|
|
11885
|
-
* Gets the corner {@link
|
|
12164
|
+
* Gets the corner {@link Dot3D}.
|
|
11886
12165
|
*
|
|
11887
|
-
* @type {
|
|
12166
|
+
* @type {Dot3D}
|
|
11888
12167
|
*/
|
|
11889
12168
|
get corner() {
|
|
11890
|
-
return this.
|
|
12169
|
+
return this._cornerDot;
|
|
11891
12170
|
}
|
|
11892
12171
|
|
|
11893
12172
|
/**
|
|
11894
|
-
* Gets the target {@link
|
|
12173
|
+
* Gets the target {@link Dot3D}.
|
|
11895
12174
|
*
|
|
11896
|
-
* @type {
|
|
12175
|
+
* @type {Dot3D}
|
|
11897
12176
|
*/
|
|
11898
12177
|
get target() {
|
|
11899
|
-
return this.
|
|
12178
|
+
return this._targetDot;
|
|
11900
12179
|
}
|
|
11901
12180
|
|
|
11902
12181
|
/**
|
|
@@ -11966,7 +12245,7 @@ class AngleMeasurement extends Component {
|
|
|
11966
12245
|
}
|
|
11967
12246
|
|
|
11968
12247
|
/**
|
|
11969
|
-
* Sets if the origin {@link
|
|
12248
|
+
* Sets if the origin {@link Dot3D} is visible.
|
|
11970
12249
|
*
|
|
11971
12250
|
* @type {Boolean}
|
|
11972
12251
|
*/
|
|
@@ -11979,7 +12258,7 @@ class AngleMeasurement extends Component {
|
|
|
11979
12258
|
}
|
|
11980
12259
|
|
|
11981
12260
|
/**
|
|
11982
|
-
* Gets if the origin {@link
|
|
12261
|
+
* Gets if the origin {@link Dot3D} is visible.
|
|
11983
12262
|
*
|
|
11984
12263
|
* @type {Boolean}
|
|
11985
12264
|
*/
|
|
@@ -11988,7 +12267,7 @@ class AngleMeasurement extends Component {
|
|
|
11988
12267
|
}
|
|
11989
12268
|
|
|
11990
12269
|
/**
|
|
11991
|
-
* Sets if the corner {@link
|
|
12270
|
+
* Sets if the corner {@link Dot3D} is visible.
|
|
11992
12271
|
*
|
|
11993
12272
|
* @type {Boolean}
|
|
11994
12273
|
*/
|
|
@@ -12001,7 +12280,7 @@ class AngleMeasurement extends Component {
|
|
|
12001
12280
|
}
|
|
12002
12281
|
|
|
12003
12282
|
/**
|
|
12004
|
-
* Gets if the corner {@link
|
|
12283
|
+
* Gets if the corner {@link Dot3D} is visible.
|
|
12005
12284
|
*
|
|
12006
12285
|
* @type {Boolean}
|
|
12007
12286
|
*/
|
|
@@ -12010,7 +12289,7 @@ class AngleMeasurement extends Component {
|
|
|
12010
12289
|
}
|
|
12011
12290
|
|
|
12012
12291
|
/**
|
|
12013
|
-
* Sets if the target {@link
|
|
12292
|
+
* Sets if the target {@link Dot3D} is visible.
|
|
12014
12293
|
*
|
|
12015
12294
|
* @type {Boolean}
|
|
12016
12295
|
*/
|
|
@@ -12023,7 +12302,7 @@ class AngleMeasurement extends Component {
|
|
|
12023
12302
|
}
|
|
12024
12303
|
|
|
12025
12304
|
/**
|
|
12026
|
-
* Gets if the target {@link
|
|
12305
|
+
* Gets if the target {@link Dot3D} is visible.
|
|
12027
12306
|
*
|
|
12028
12307
|
* @type {Boolean}
|
|
12029
12308
|
*/
|
|
@@ -14103,265 +14382,6 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
|
|
|
14103
14382
|
}
|
|
14104
14383
|
}
|
|
14105
14384
|
|
|
14106
|
-
const nop = () => { };
|
|
14107
|
-
|
|
14108
|
-
function transformToNode(from, to, vec) {
|
|
14109
|
-
const fromRec = from.getBoundingClientRect();
|
|
14110
|
-
const toRec = to.getBoundingClientRect();
|
|
14111
|
-
vec[0] += fromRec.left - toRec.left;
|
|
14112
|
-
vec[1] += fromRec.top - toRec.top;
|
|
14113
|
-
}
|
|
14114
|
-
function createDraggableDot3D(cfg) {
|
|
14115
|
-
const extractCFG = function(propName, defaultValue) {
|
|
14116
|
-
if (propName in cfg) {
|
|
14117
|
-
return cfg[propName];
|
|
14118
|
-
} else if (defaultValue !== undefined) {
|
|
14119
|
-
return defaultValue;
|
|
14120
|
-
} else {
|
|
14121
|
-
throw "config missing: " + propName;
|
|
14122
|
-
}
|
|
14123
|
-
};
|
|
14124
|
-
|
|
14125
|
-
const viewer = extractCFG("viewer");
|
|
14126
|
-
const worldPos = extractCFG("worldPos");
|
|
14127
|
-
const color = extractCFG("color");
|
|
14128
|
-
const ray2WorldPos = extractCFG("ray2WorldPos");
|
|
14129
|
-
const handleMouseEvents = extractCFG("handleMouseEvents", false);
|
|
14130
|
-
const handleTouchEvents = extractCFG("handleTouchEvents", false);
|
|
14131
|
-
const onStart = extractCFG("onStart", nop);
|
|
14132
|
-
const onMove = extractCFG("onMove", nop);
|
|
14133
|
-
const onEnd = extractCFG("onEnd", nop);
|
|
14134
|
-
|
|
14135
|
-
const scene = viewer.scene;
|
|
14136
|
-
const canvas = scene.canvas.canvas;
|
|
14137
|
-
|
|
14138
|
-
const marker = new Marker(scene, {});
|
|
14139
|
-
|
|
14140
|
-
const pickWorldPos = canvasPos => {
|
|
14141
|
-
const origin = math.vec3();
|
|
14142
|
-
const direction = math.vec3();
|
|
14143
|
-
math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, canvasPos, origin, direction);
|
|
14144
|
-
return ray2WorldPos(origin, direction, canvasPos);
|
|
14145
|
-
};
|
|
14146
|
-
|
|
14147
|
-
const onChange = event => {
|
|
14148
|
-
const canvasPos = math.vec2([ event.clientX, event.clientY ]);
|
|
14149
|
-
transformToNode(canvas.ownerDocument.body, canvas, canvasPos);
|
|
14150
|
-
|
|
14151
|
-
const worldPos = pickWorldPos(canvasPos);
|
|
14152
|
-
marker.worldPos = worldPos;
|
|
14153
|
-
updateDotPos();
|
|
14154
|
-
onMove(canvasPos, worldPos);
|
|
14155
|
-
};
|
|
14156
|
-
|
|
14157
|
-
let currentDrag = null;
|
|
14158
|
-
|
|
14159
|
-
const onDragMove = function(event) {
|
|
14160
|
-
const e = currentDrag.matchesEvent(event);
|
|
14161
|
-
if (e)
|
|
14162
|
-
{
|
|
14163
|
-
onChange(e);
|
|
14164
|
-
}
|
|
14165
|
-
};
|
|
14166
|
-
|
|
14167
|
-
const onDragEnd = function(event) {
|
|
14168
|
-
const e = currentDrag.matchesEvent(event);
|
|
14169
|
-
if (e)
|
|
14170
|
-
{
|
|
14171
|
-
dot.setOpacity(idleOpacity);
|
|
14172
|
-
currentDrag.cleanup();
|
|
14173
|
-
onChange(e);
|
|
14174
|
-
onEnd();
|
|
14175
|
-
}
|
|
14176
|
-
};
|
|
14177
|
-
|
|
14178
|
-
const startDrag = function(matchesEvent, cleanupHandlers) {
|
|
14179
|
-
if (currentDrag) {
|
|
14180
|
-
currentDrag.cleanup();
|
|
14181
|
-
}
|
|
14182
|
-
|
|
14183
|
-
dot.setOpacity(1.0);
|
|
14184
|
-
dot.setClickable(false);
|
|
14185
|
-
viewer.cameraControl.active = false;
|
|
14186
|
-
|
|
14187
|
-
currentDrag = {
|
|
14188
|
-
matchesEvent: matchesEvent,
|
|
14189
|
-
cleanup: function() {
|
|
14190
|
-
currentDrag = null;
|
|
14191
|
-
dot.setClickable(true);
|
|
14192
|
-
viewer.cameraControl.active = true;
|
|
14193
|
-
cleanupHandlers();
|
|
14194
|
-
}
|
|
14195
|
-
};
|
|
14196
|
-
|
|
14197
|
-
onStart();
|
|
14198
|
-
};
|
|
14199
|
-
|
|
14200
|
-
const dotCfg = { fillColor: color };
|
|
14201
|
-
|
|
14202
|
-
if (handleMouseEvents)
|
|
14203
|
-
{
|
|
14204
|
-
dotCfg.onMouseOver = () => (! currentDrag) && dot.setOpacity(1.0);
|
|
14205
|
-
dotCfg.onMouseLeave = () => (! currentDrag) && dot.setOpacity(idleOpacity);
|
|
14206
|
-
dotCfg.onMouseDown = event => {
|
|
14207
|
-
if (event.which === 1)
|
|
14208
|
-
{
|
|
14209
|
-
canvas.addEventListener("mousemove", onDragMove);
|
|
14210
|
-
canvas.addEventListener("mouseup", onDragEnd);
|
|
14211
|
-
startDrag(
|
|
14212
|
-
event => (event.which === 1) && event,
|
|
14213
|
-
() => {
|
|
14214
|
-
canvas.removeEventListener("mousemove", onDragMove);
|
|
14215
|
-
canvas.removeEventListener("mouseup", onDragEnd);
|
|
14216
|
-
});
|
|
14217
|
-
}
|
|
14218
|
-
};
|
|
14219
|
-
}
|
|
14220
|
-
|
|
14221
|
-
if (handleTouchEvents)
|
|
14222
|
-
{
|
|
14223
|
-
let touchStartId;
|
|
14224
|
-
dotCfg.onTouchstart = event => {
|
|
14225
|
-
event.preventDefault();
|
|
14226
|
-
if (event.touches.length === 1)
|
|
14227
|
-
{
|
|
14228
|
-
touchStartId = event.touches[0].identifier;
|
|
14229
|
-
startDrag(
|
|
14230
|
-
event => [...event.changedTouches].find(e => e.identifier === touchStartId),
|
|
14231
|
-
() => { touchStartId = null; });
|
|
14232
|
-
}
|
|
14233
|
-
};
|
|
14234
|
-
dotCfg.onTouchmove = event => {
|
|
14235
|
-
event.preventDefault();
|
|
14236
|
-
onDragMove(event);
|
|
14237
|
-
};
|
|
14238
|
-
dotCfg.onTouchend = event => {
|
|
14239
|
-
event.preventDefault();
|
|
14240
|
-
onDragEnd(event);
|
|
14241
|
-
};
|
|
14242
|
-
}
|
|
14243
|
-
|
|
14244
|
-
const dotParent = canvas.ownerDocument.body;
|
|
14245
|
-
const dot = new Dot(dotParent, dotCfg);
|
|
14246
|
-
|
|
14247
|
-
const idleOpacity = 0.5;
|
|
14248
|
-
dot.setOpacity(idleOpacity);
|
|
14249
|
-
|
|
14250
|
-
const updateDotPos = function() {
|
|
14251
|
-
const pos = marker.canvasPos.slice();
|
|
14252
|
-
transformToNode(canvas, dotParent, pos);
|
|
14253
|
-
dot.setPos(pos[0], pos[1]);
|
|
14254
|
-
};
|
|
14255
|
-
|
|
14256
|
-
marker.worldPos = worldPos;
|
|
14257
|
-
updateDotPos();
|
|
14258
|
-
|
|
14259
|
-
const onViewMatrix = scene.camera.on("viewMatrix", updateDotPos);
|
|
14260
|
-
const onProjMatrix = scene.camera.on("projMatrix", updateDotPos);
|
|
14261
|
-
|
|
14262
|
-
return {
|
|
14263
|
-
setActive: value => dot.setClickable(value),
|
|
14264
|
-
getWorldPos: () => marker.worldPos,
|
|
14265
|
-
setWorldPos: pos => { marker.worldPos = pos; updateDotPos(); },
|
|
14266
|
-
destroy: function() {
|
|
14267
|
-
currentDrag && currentDrag.cleanup();
|
|
14268
|
-
scene.camera.off(onViewMatrix);
|
|
14269
|
-
scene.camera.off(onProjMatrix);
|
|
14270
|
-
marker.destroy();
|
|
14271
|
-
dot.destroy();
|
|
14272
|
-
}
|
|
14273
|
-
};
|
|
14274
|
-
}
|
|
14275
|
-
function activateDraggableDots(cfg) {
|
|
14276
|
-
const extractCFG = function(propName, defaultValue) {
|
|
14277
|
-
if (propName in cfg) {
|
|
14278
|
-
return cfg[propName];
|
|
14279
|
-
} else if (defaultValue !== undefined) {
|
|
14280
|
-
return defaultValue;
|
|
14281
|
-
} else {
|
|
14282
|
-
throw "config missing: " + propName;
|
|
14283
|
-
}
|
|
14284
|
-
};
|
|
14285
|
-
|
|
14286
|
-
const viewer = extractCFG("viewer");
|
|
14287
|
-
const handleMouseEvents = extractCFG("handleMouseEvents", false);
|
|
14288
|
-
const handleTouchEvents = extractCFG("handleTouchEvents", false);
|
|
14289
|
-
const snapping = extractCFG("snapping");
|
|
14290
|
-
const pointerLens = extractCFG("pointerLens", null);
|
|
14291
|
-
const color = extractCFG("color");
|
|
14292
|
-
const markers = extractCFG("markers");
|
|
14293
|
-
const onEdit = extractCFG("onEdit", nop);
|
|
14294
|
-
|
|
14295
|
-
const updatePointerLens = (pointerLens
|
|
14296
|
-
? function(canvasPos) {
|
|
14297
|
-
pointerLens.visible = !! canvasPos;
|
|
14298
|
-
if (canvasPos)
|
|
14299
|
-
{
|
|
14300
|
-
pointerLens.canvasPos = canvasPos;
|
|
14301
|
-
}
|
|
14302
|
-
}
|
|
14303
|
-
: () => { });
|
|
14304
|
-
|
|
14305
|
-
const dots = markers.map(marker => {
|
|
14306
|
-
let initDotPos, initMarkerPos;
|
|
14307
|
-
const setCoord = coord => marker.worldPos = coord;
|
|
14308
|
-
|
|
14309
|
-
const dot = createDraggableDot3D({
|
|
14310
|
-
handleMouseEvents: handleMouseEvents,
|
|
14311
|
-
handleTouchEvents: handleTouchEvents,
|
|
14312
|
-
viewer: viewer,
|
|
14313
|
-
worldPos: marker.worldPos,
|
|
14314
|
-
color: color,
|
|
14315
|
-
ray2WorldPos: (orig, dir, canvasPos) => {
|
|
14316
|
-
const tryPickWorldPos = snap => {
|
|
14317
|
-
const pickResult = viewer.scene.pick({
|
|
14318
|
-
canvasPos: canvasPos,
|
|
14319
|
-
snapToEdge: snap,
|
|
14320
|
-
snapToVertex: snap,
|
|
14321
|
-
pickSurface: true // <<------ This causes picking to find the intersection point on the entity
|
|
14322
|
-
});
|
|
14323
|
-
|
|
14324
|
-
// If - when snapping - no pick found, then try w/o snapping
|
|
14325
|
-
return (pickResult && pickResult.worldPos) ? pickResult.worldPos : (snap && tryPickWorldPos(false));
|
|
14326
|
-
};
|
|
14327
|
-
|
|
14328
|
-
return tryPickWorldPos(!!snapping) || initDotPos;
|
|
14329
|
-
},
|
|
14330
|
-
onStart: () => {
|
|
14331
|
-
initDotPos = dot.getWorldPos().slice();
|
|
14332
|
-
initMarkerPos = marker.worldPos.slice();
|
|
14333
|
-
setOtherDotsActive(false, dot);
|
|
14334
|
-
},
|
|
14335
|
-
onMove: (canvasPos, worldPos) => {
|
|
14336
|
-
updatePointerLens(canvasPos);
|
|
14337
|
-
setCoord(worldPos);
|
|
14338
|
-
},
|
|
14339
|
-
onEnd: () => {
|
|
14340
|
-
if (! math.compareVec3(initMarkerPos, marker.worldPos))
|
|
14341
|
-
{
|
|
14342
|
-
onEdit();
|
|
14343
|
-
}
|
|
14344
|
-
else
|
|
14345
|
-
{
|
|
14346
|
-
dot.setWorldPos(initDotPos);
|
|
14347
|
-
setCoord(initMarkerPos);
|
|
14348
|
-
}
|
|
14349
|
-
updatePointerLens(null);
|
|
14350
|
-
setOtherDotsActive(true, dot);
|
|
14351
|
-
}
|
|
14352
|
-
});
|
|
14353
|
-
return dot;
|
|
14354
|
-
});
|
|
14355
|
-
|
|
14356
|
-
const setOtherDotsActive = (active, dot) => dots.forEach(d => (d !== dot) && d.setActive(active));
|
|
14357
|
-
setOtherDotsActive(true);
|
|
14358
|
-
|
|
14359
|
-
return function() {
|
|
14360
|
-
dots.forEach(m => m.destroy());
|
|
14361
|
-
updatePointerLens(null);
|
|
14362
|
-
};
|
|
14363
|
-
}
|
|
14364
|
-
|
|
14365
14385
|
class AngleMeasurementEditControl extends Component {
|
|
14366
14386
|
|
|
14367
14387
|
/**
|
|
@@ -14384,11 +14404,30 @@ class AngleMeasurementEditControl extends Component {
|
|
|
14384
14404
|
viewer: viewer,
|
|
14385
14405
|
handleMouseEvents: handleMouseEvents,
|
|
14386
14406
|
handleTouchEvents: handleTouchEvents,
|
|
14387
|
-
snapping: cfg.snapping,
|
|
14388
14407
|
pointerLens: cfg.pointerLens,
|
|
14389
|
-
|
|
14390
|
-
|
|
14391
|
-
|
|
14408
|
+
dots: [ measurement.origin, measurement.corner, measurement.target ],
|
|
14409
|
+
ray2WorldPos: (orig, dir, canvasPos) => {
|
|
14410
|
+
const tryPickWorldPos = snap => {
|
|
14411
|
+
const pickResult = viewer.scene.pick({
|
|
14412
|
+
canvasPos: canvasPos,
|
|
14413
|
+
snapToEdge: snap,
|
|
14414
|
+
snapToVertex: snap,
|
|
14415
|
+
pickSurface: true // <<------ This causes picking to find the intersection point on the entity
|
|
14416
|
+
});
|
|
14417
|
+
|
|
14418
|
+
// If - when snapping - no pick found, then try w/o snapping
|
|
14419
|
+
return (pickResult && pickResult.worldPos) ? pickResult.worldPos : (snap && tryPickWorldPos(false));
|
|
14420
|
+
};
|
|
14421
|
+
|
|
14422
|
+
return tryPickWorldPos(!!cfg.snapping);
|
|
14423
|
+
},
|
|
14424
|
+
onEnd: (initPos, dot) => {
|
|
14425
|
+
const changed = ! math.compareVec3(initPos, dot.worldPos);
|
|
14426
|
+
if (changed) {
|
|
14427
|
+
this.fire("edited");
|
|
14428
|
+
}
|
|
14429
|
+
return changed;
|
|
14430
|
+
}
|
|
14392
14431
|
});
|
|
14393
14432
|
|
|
14394
14433
|
const destroyCb = measurement.on("destroyed", cleanup);
|
|
@@ -14417,6 +14456,10 @@ class AngleMeasurementEditTouchControl extends AngleMeasurementEditControl {
|
|
|
14417
14456
|
}
|
|
14418
14457
|
}
|
|
14419
14458
|
|
|
14459
|
+
const tempVec3a$K = math.vec3();
|
|
14460
|
+
const tempVec3b$z = math.vec3();
|
|
14461
|
+
const tempVec3c$v = math.vec3();
|
|
14462
|
+
|
|
14420
14463
|
/**
|
|
14421
14464
|
* A {@link Marker} with an HTML label attached to it, managed by an {@link AnnotationsPlugin}.
|
|
14422
14465
|
*
|
|
@@ -14456,6 +14499,9 @@ class Annotation extends Marker {
|
|
|
14456
14499
|
this._marker.addEventListener("click", this._onMouseClickedExternalMarker = () => {
|
|
14457
14500
|
this.plugin.fire("markerClicked", this);
|
|
14458
14501
|
});
|
|
14502
|
+
this._marker.addEventListener("contextmenu", this._onContextMenuExtenalMarker = () => {
|
|
14503
|
+
this.plugin.fire("contextmenu", this);
|
|
14504
|
+
});
|
|
14459
14505
|
this._marker.addEventListener("mouseenter", this._onMouseEnterExternalMarker = () => {
|
|
14460
14506
|
this.plugin.fire("markerMouseEnter", this);
|
|
14461
14507
|
});
|
|
@@ -14483,6 +14529,7 @@ class Annotation extends Marker {
|
|
|
14483
14529
|
this._values = cfg.values || {};
|
|
14484
14530
|
this._layoutDirty = true;
|
|
14485
14531
|
this._visibilityDirty = true;
|
|
14532
|
+
this._labelPosition = 24;
|
|
14486
14533
|
|
|
14487
14534
|
this._buildHTML();
|
|
14488
14535
|
|
|
@@ -14575,6 +14622,10 @@ class Annotation extends Marker {
|
|
|
14575
14622
|
this._marker.addEventListener("click", () => {
|
|
14576
14623
|
this.plugin.fire("markerClicked", this);
|
|
14577
14624
|
});
|
|
14625
|
+
this._marker.addEventListener("contextmenu", e => {
|
|
14626
|
+
e.preventDefault();
|
|
14627
|
+
this.plugin.fire("contextmenu", this);
|
|
14628
|
+
});
|
|
14578
14629
|
this._marker.addEventListener("mouseenter", () => {
|
|
14579
14630
|
this.plugin.fire("markerMouseEnter", this);
|
|
14580
14631
|
});
|
|
@@ -14609,17 +14660,23 @@ class Annotation extends Marker {
|
|
|
14609
14660
|
* @private
|
|
14610
14661
|
*/
|
|
14611
14662
|
_updatePosition() {
|
|
14663
|
+
const px = x => x + "px";
|
|
14612
14664
|
const boundary = this.scene.canvas.boundary;
|
|
14613
|
-
const left = boundary[0];
|
|
14614
|
-
const top
|
|
14615
|
-
const
|
|
14616
|
-
|
|
14617
|
-
|
|
14665
|
+
const left = boundary[0] + this.canvasPos[0];
|
|
14666
|
+
const top = boundary[1] + this.canvasPos[1];
|
|
14667
|
+
const markerRect = this._marker.getBoundingClientRect();
|
|
14668
|
+
const markerWidth = markerRect.width;
|
|
14669
|
+
const markerDir = (this._markerAlign === "right") ? -1 : ((this._markerAlign === "center") ? 0 : 1);
|
|
14670
|
+
const markerCenter = left + markerDir * (markerWidth / 2 - 12);
|
|
14671
|
+
this._marker.style.left = px(markerCenter - markerWidth / 2);
|
|
14672
|
+
this._marker.style.top = px(top - 12);
|
|
14618
14673
|
this._marker.style["z-index"] = 90005 + Math.floor(this._viewPos[2]) + 1;
|
|
14619
|
-
|
|
14620
|
-
const
|
|
14621
|
-
|
|
14622
|
-
|
|
14674
|
+
|
|
14675
|
+
const labelRect = this._label.getBoundingClientRect();
|
|
14676
|
+
const labelWidth = labelRect.width;
|
|
14677
|
+
const labelDir = Math.sign(this._labelPosition);
|
|
14678
|
+
this._label.style.left = px(markerCenter + labelDir * (markerWidth / 2 + Math.abs(this._labelPosition) + labelWidth / 2) - labelWidth / 2);
|
|
14679
|
+
this._label.style.top = px(top - 17);
|
|
14623
14680
|
this._label.style["z-index"] = 90005 + Math.floor(this._viewPos[2]) + 1;
|
|
14624
14681
|
}
|
|
14625
14682
|
|
|
@@ -14636,6 +14693,55 @@ class Annotation extends Marker {
|
|
|
14636
14693
|
return template;
|
|
14637
14694
|
}
|
|
14638
14695
|
|
|
14696
|
+
/**
|
|
14697
|
+
* Sets the Marker's worldPos and entity properties based on passed {@link PickResult}
|
|
14698
|
+
*
|
|
14699
|
+
* @param {PickResult} pickResult A PickResult to position the Marker at.
|
|
14700
|
+
*/
|
|
14701
|
+
setFromPickResult(pickResult) {
|
|
14702
|
+
if (!pickResult.worldPos || !pickResult.worldNormal) {
|
|
14703
|
+
this.error("Param 'pickResult' does not have both worldPos and worldNormal");
|
|
14704
|
+
} else {
|
|
14705
|
+
const normalizedWorldNormal = math.normalizeVec3(pickResult.worldNormal, tempVec3a$K);
|
|
14706
|
+
const offset = (this.plugin && this.plugin.surfaceOffset) || 0;
|
|
14707
|
+
const offsetVec = math.mulVec3Scalar(normalizedWorldNormal, offset, tempVec3b$z);
|
|
14708
|
+
const offsetWorldPos = math.addVec3(pickResult.worldPos, offsetVec, tempVec3c$v);
|
|
14709
|
+
this.entity = pickResult.entity;
|
|
14710
|
+
this.worldPos = offsetWorldPos;
|
|
14711
|
+
}
|
|
14712
|
+
}
|
|
14713
|
+
|
|
14714
|
+
/**
|
|
14715
|
+
* Sets the horizontal alignment of the Annotation's marker HTML.
|
|
14716
|
+
*
|
|
14717
|
+
* @param {String} align Either "left", "center", "right" (default "left")
|
|
14718
|
+
*/
|
|
14719
|
+
setMarkerAlign(align) {
|
|
14720
|
+
const valid = [ "left", "center", "right" ];
|
|
14721
|
+
if (! valid.includes(align)) {
|
|
14722
|
+
this.error("Param 'align' should be one of: " + JSON.stringify(valid));
|
|
14723
|
+
} else {
|
|
14724
|
+
this._markerAlign = align;
|
|
14725
|
+
this._updatePosition();
|
|
14726
|
+
}
|
|
14727
|
+
}
|
|
14728
|
+
|
|
14729
|
+
/**
|
|
14730
|
+
* Sets the relative horizontal position of the Annotation's label HTML.
|
|
14731
|
+
*
|
|
14732
|
+
* @param {Number} position Negative - to the left, positive - to the right, otherwise ignore (default 24)
|
|
14733
|
+
*/
|
|
14734
|
+
setLabelPosition(position) {
|
|
14735
|
+
if (typeof position !== "number") {
|
|
14736
|
+
this.error("Param 'position' is not a number");
|
|
14737
|
+
} else if (position === 0) {
|
|
14738
|
+
this.error("Param 'position' is zero");
|
|
14739
|
+
} else {
|
|
14740
|
+
this._labelPosition = position;
|
|
14741
|
+
this._updatePosition();
|
|
14742
|
+
}
|
|
14743
|
+
}
|
|
14744
|
+
|
|
14639
14745
|
/**
|
|
14640
14746
|
* Sets whether or not to show this Annotation's marker.
|
|
14641
14747
|
*
|
|
@@ -14766,6 +14872,7 @@ class Annotation extends Marker {
|
|
|
14766
14872
|
this._marker = null;
|
|
14767
14873
|
} else {
|
|
14768
14874
|
this._marker.removeEventListener("click", this._onMouseClickedExternalMarker);
|
|
14875
|
+
this._marker.removeEventListener("contextmenu", this._onContextMenuExtenalMarker);
|
|
14769
14876
|
this._marker.removeEventListener("mouseenter", this._onMouseEnterExternalMarker);
|
|
14770
14877
|
this._marker.removeEventListener("mouseleave", this._onMouseLeaveExternalMarker);
|
|
14771
14878
|
this._marker = null;
|
|
@@ -14782,10 +14889,6 @@ class Annotation extends Marker {
|
|
|
14782
14889
|
}
|
|
14783
14890
|
}
|
|
14784
14891
|
|
|
14785
|
-
const tempVec3a$K = math.vec3();
|
|
14786
|
-
const tempVec3b$z = math.vec3();
|
|
14787
|
-
const tempVec3c$v = math.vec3();
|
|
14788
|
-
|
|
14789
14892
|
/**
|
|
14790
14893
|
* {@link Viewer} plugin that creates {@link Annotation}s.
|
|
14791
14894
|
*
|
|
@@ -15260,24 +15363,6 @@ class AnnotationsPlugin extends Plugin {
|
|
|
15260
15363
|
this.error("Viewer component with this ID already exists: " + params.id);
|
|
15261
15364
|
delete params.id;
|
|
15262
15365
|
}
|
|
15263
|
-
var worldPos;
|
|
15264
|
-
var entity;
|
|
15265
|
-
params.pickResult = params.pickResult || params.pickRecord;
|
|
15266
|
-
if (params.pickResult) {
|
|
15267
|
-
const pickResult = params.pickResult;
|
|
15268
|
-
if (!pickResult.worldPos || !pickResult.worldNormal) {
|
|
15269
|
-
this.error("Param 'pickResult' does not have both worldPos and worldNormal");
|
|
15270
|
-
} else {
|
|
15271
|
-
const normalizedWorldNormal = math.normalizeVec3(pickResult.worldNormal, tempVec3a$K);
|
|
15272
|
-
const offsetVec = math.mulVec3Scalar(normalizedWorldNormal, this._surfaceOffset, tempVec3b$z);
|
|
15273
|
-
const offsetWorldPos = math.addVec3(pickResult.worldPos, offsetVec, tempVec3c$v);
|
|
15274
|
-
worldPos = offsetWorldPos;
|
|
15275
|
-
entity = pickResult.entity;
|
|
15276
|
-
}
|
|
15277
|
-
} else {
|
|
15278
|
-
worldPos = params.worldPos;
|
|
15279
|
-
entity = params.entity;
|
|
15280
|
-
}
|
|
15281
15366
|
|
|
15282
15367
|
var markerElement = null;
|
|
15283
15368
|
if (params.markerElementId) {
|
|
@@ -15298,8 +15383,6 @@ class AnnotationsPlugin extends Plugin {
|
|
|
15298
15383
|
const annotation = new Annotation(this.viewer.scene, {
|
|
15299
15384
|
id: params.id,
|
|
15300
15385
|
plugin: this,
|
|
15301
|
-
entity: entity,
|
|
15302
|
-
worldPos: worldPos,
|
|
15303
15386
|
container: this._container,
|
|
15304
15387
|
markerElement: markerElement,
|
|
15305
15388
|
labelElement: labelElement,
|
|
@@ -15315,6 +15398,15 @@ class AnnotationsPlugin extends Plugin {
|
|
|
15315
15398
|
projection: params.projection,
|
|
15316
15399
|
visible: (params.visible !== false)
|
|
15317
15400
|
});
|
|
15401
|
+
|
|
15402
|
+
params.pickResult = params.pickResult || params.pickRecord;
|
|
15403
|
+
if (params.pickResult) {
|
|
15404
|
+
annotation.setFromPickResult(params.pickResult);
|
|
15405
|
+
} else {
|
|
15406
|
+
annotation.entity = params.entity;
|
|
15407
|
+
annotation.worldPos = params.worldPos;
|
|
15408
|
+
}
|
|
15409
|
+
|
|
15318
15410
|
this.annotations[annotation.id] = annotation;
|
|
15319
15411
|
annotation.on("destroyed", () => {
|
|
15320
15412
|
delete this.annotations[annotation.id];
|
|
@@ -31723,10 +31815,10 @@ class Scene extends Component {
|
|
|
31723
31815
|
*/
|
|
31724
31816
|
get center() {
|
|
31725
31817
|
if (this._aabbDirty || !this._center) {
|
|
31726
|
-
|
|
31818
|
+
const aabb = this.aabb;
|
|
31819
|
+
if (!this._center) {
|
|
31727
31820
|
this._center = math.vec3();
|
|
31728
31821
|
}
|
|
31729
|
-
const aabb = this.aabb;
|
|
31730
31822
|
this._center[0] = (aabb[0] + aabb[3]) / 2;
|
|
31731
31823
|
this._center[1] = (aabb[1] + aabb[4]) / 2;
|
|
31732
31824
|
this._center[2] = (aabb[2] + aabb[5]) / 2;
|
|
@@ -31801,6 +31893,7 @@ class Scene extends Component {
|
|
|
31801
31893
|
this._aabb[4] = ymax;
|
|
31802
31894
|
this._aabb[5] = zmax;
|
|
31803
31895
|
this._aabbDirty = false;
|
|
31896
|
+
this._center = null;
|
|
31804
31897
|
}
|
|
31805
31898
|
return this._aabb;
|
|
31806
31899
|
}
|
|
@@ -49794,6 +49887,270 @@ function buildPolylineGeometryFromCurve(cfg = {}) {
|
|
|
49794
49887
|
});
|
|
49795
49888
|
}
|
|
49796
49889
|
|
|
49890
|
+
/**
|
|
49891
|
+
* @desc Creates a 3D line {@link Geometry}.
|
|
49892
|
+
*
|
|
49893
|
+
* ## Usage
|
|
49894
|
+
*
|
|
49895
|
+
* In the example below we'll create a {@link Mesh} with a line {@link ReadableGeometry}.
|
|
49896
|
+
*
|
|
49897
|
+
* [[Run this example](https://xeokit.github.io/xeokit-sdk/examples/scenegraph/#buildLineGeometry)]
|
|
49898
|
+
*
|
|
49899
|
+
* ````javascript
|
|
49900
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49901
|
+
* // Import the modules we need for this example
|
|
49902
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49903
|
+
*
|
|
49904
|
+
* import {buildLineGeometry, Viewer, Mesh, ReadableGeometry, PhongMaterial} from "../../dist/xeokit-sdk.min.es.js";
|
|
49905
|
+
*
|
|
49906
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49907
|
+
* // Create a Viewer and arrange the camera
|
|
49908
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49909
|
+
*
|
|
49910
|
+
* const viewer = new Viewer({
|
|
49911
|
+
* canvasId: "myCanvas"
|
|
49912
|
+
* });
|
|
49913
|
+
*
|
|
49914
|
+
* viewer.camera.eye = [0, 0, 8];
|
|
49915
|
+
* viewer.camera.look = [0, 0, 0];
|
|
49916
|
+
* viewer.camera.up = [0, 1, 0];
|
|
49917
|
+
*
|
|
49918
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49919
|
+
* // Create a mesh with simple 2d line shape
|
|
49920
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49921
|
+
*
|
|
49922
|
+
* new Mesh(viewer.scene, {
|
|
49923
|
+
* geometry: new ReadableGeometry(viewer.scene, buildLineGeometry({
|
|
49924
|
+
* startPoint: [-5,-2,0],
|
|
49925
|
+
* endPoint: [-5,2,0],
|
|
49926
|
+
* })),
|
|
49927
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
49928
|
+
* emissive: [0, 1,]
|
|
49929
|
+
* })
|
|
49930
|
+
* });
|
|
49931
|
+
*
|
|
49932
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49933
|
+
* // Create a mesh with simple 2d line shape with black color
|
|
49934
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49935
|
+
*
|
|
49936
|
+
* new Mesh(viewer.scene, {
|
|
49937
|
+
* geometry: new ReadableGeometry(viewer.scene, buildLineGeometry({
|
|
49938
|
+
* startPoint: [-4,-2,0],
|
|
49939
|
+
* endPoint: [-4,2,0],
|
|
49940
|
+
* })),
|
|
49941
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
49942
|
+
* emissive: [0, 0, 0]
|
|
49943
|
+
* })
|
|
49944
|
+
* });
|
|
49945
|
+
*
|
|
49946
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49947
|
+
* // Create a mesh with simple 2d line shape with black color and simple pattern
|
|
49948
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49949
|
+
*
|
|
49950
|
+
* new Mesh(viewer.scene, {
|
|
49951
|
+
* geometry: new ReadableGeometry(viewer.scene, buildLineGeometry({
|
|
49952
|
+
* startPoint: [-3,-2,0],
|
|
49953
|
+
* endPoint: [-3,2,0],
|
|
49954
|
+
* pattern: [0.10],
|
|
49955
|
+
* })),
|
|
49956
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
49957
|
+
* emissive: [0, 0, 0]
|
|
49958
|
+
* })
|
|
49959
|
+
* });
|
|
49960
|
+
*
|
|
49961
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49962
|
+
* // Create a mesh with simple 2d line shape with blue color and simple pattern extended to end
|
|
49963
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49964
|
+
*
|
|
49965
|
+
* new Mesh(viewer.scene, {
|
|
49966
|
+
* geometry: new ReadableGeometry(viewer.scene, buildLineGeometry({
|
|
49967
|
+
* startPoint: [-2,-2,0],
|
|
49968
|
+
* endPoint: [-2,2,0],
|
|
49969
|
+
* pattern: [0.10],
|
|
49970
|
+
* extendToEnd: true,
|
|
49971
|
+
* })),
|
|
49972
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
49973
|
+
* emissive: [0, 0, 1]
|
|
49974
|
+
* })
|
|
49975
|
+
* });
|
|
49976
|
+
*
|
|
49977
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49978
|
+
* // Create a mesh with simple 2d line shape with black color and more complex pattern
|
|
49979
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49980
|
+
*
|
|
49981
|
+
* new Mesh(viewer.scene, {
|
|
49982
|
+
* geometry: new ReadableGeometry(viewer.scene, buildLineGeometry({
|
|
49983
|
+
* startPoint: [-1,-2,0],
|
|
49984
|
+
* endPoint: [-1,2,0],
|
|
49985
|
+
* pattern: [0.15, 0.05],
|
|
49986
|
+
* })),
|
|
49987
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
49988
|
+
* emissive: [0, 0, 0]
|
|
49989
|
+
* })
|
|
49990
|
+
* });
|
|
49991
|
+
*
|
|
49992
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49993
|
+
* // Create a mesh with simple 2d line shape with blue color and more complex pattern extended to end
|
|
49994
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49995
|
+
*
|
|
49996
|
+
* new Mesh(viewer.scene, {
|
|
49997
|
+
* geometry: new ReadableGeometry(viewer.scene, buildLineGeometry({
|
|
49998
|
+
* startPoint: [0,-2,0],
|
|
49999
|
+
* endPoint: [0,2,0],
|
|
50000
|
+
* pattern: [0.15, 0.05],
|
|
50001
|
+
* extendToEnd: true,
|
|
50002
|
+
* })),
|
|
50003
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
50004
|
+
* emissive: [0, 0, 1]
|
|
50005
|
+
* })
|
|
50006
|
+
* });
|
|
50007
|
+
*
|
|
50008
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
50009
|
+
* // Create a mesh with simple 2d line shape with black color and complex pattern
|
|
50010
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
50011
|
+
*
|
|
50012
|
+
* new Mesh(viewer.scene, {
|
|
50013
|
+
* geometry: new ReadableGeometry(viewer.scene, buildLineGeometry({
|
|
50014
|
+
* startPoint: [1,-2,0],
|
|
50015
|
+
* endPoint: [1,2,0],
|
|
50016
|
+
* pattern: [0.15, 0.05, 0.50],
|
|
50017
|
+
* })),
|
|
50018
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
50019
|
+
* emissive: [0, 0, 0]
|
|
50020
|
+
* })
|
|
50021
|
+
* });
|
|
50022
|
+
*
|
|
50023
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
50024
|
+
* // Create a mesh with simple 2d line shape with blue color and complex pattern extended to end
|
|
50025
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
50026
|
+
*
|
|
50027
|
+
* new Mesh(viewer.scene, {
|
|
50028
|
+
* geometry: new ReadableGeometry(viewer.scene, buildLineGeometry({
|
|
50029
|
+
* startPoint: [2,-2,0],
|
|
50030
|
+
* endPoint: [2,2,0],
|
|
50031
|
+
* pattern: [0.15, 0.05, 0.50],
|
|
50032
|
+
* extendToEnd: true,
|
|
50033
|
+
* })),
|
|
50034
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
50035
|
+
* emissive: [0, 0, 1]
|
|
50036
|
+
* })
|
|
50037
|
+
* });
|
|
50038
|
+
*
|
|
50039
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
50040
|
+
* // Create a mesh with simple 3d line shape with white color and simple pattern
|
|
50041
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
50042
|
+
*
|
|
50043
|
+
* new Mesh(viewer.scene, {
|
|
50044
|
+
* geometry: new ReadableGeometry(viewer.scene, buildLineGeometry({
|
|
50045
|
+
* startPoint: [3,-2,-1],
|
|
50046
|
+
* endPoint: [5,2,1],
|
|
50047
|
+
* pattern: [0.10],
|
|
50048
|
+
* })),
|
|
50049
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
50050
|
+
* emissive: [1, 1, 1]
|
|
50051
|
+
* })
|
|
50052
|
+
* });
|
|
50053
|
+
*
|
|
50054
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
50055
|
+
* // Create a mesh with simple 3d line shape with black color and simple dot pattern
|
|
50056
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
50057
|
+
*
|
|
50058
|
+
* new Mesh(viewer.scene, {
|
|
50059
|
+
* geometry: new ReadableGeometry(viewer.scene, buildLineGeometry({
|
|
50060
|
+
* startPoint: [5,-2,-1],
|
|
50061
|
+
* endPoint: [7,2,1],
|
|
50062
|
+
* pattern: [0.03],
|
|
50063
|
+
* })),
|
|
50064
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
50065
|
+
* emissive: [0, 0, 0]
|
|
50066
|
+
* })
|
|
50067
|
+
* });
|
|
50068
|
+
* ````
|
|
50069
|
+
*
|
|
50070
|
+
* @function buildLineGeometry
|
|
50071
|
+
* @param {*} [cfg] Configs
|
|
50072
|
+
* @param {String} [cfg.id] Optional ID, unique among all components in the parent {@link Scene}, generated automatically when omitted.
|
|
50073
|
+
* @param {Number[]} [cfg.startPoint] 3D start point (x0, y0, z0).
|
|
50074
|
+
* @param {Number[]} [cfg.endPoint] 3D end point (x1, y1, z1).
|
|
50075
|
+
* @param {Number[]} [cfg.pattern] Lengths of segments that describe a pattern.
|
|
50076
|
+
* @param {Bool} [cfg.extendToEnd] If true: it will try to make sure the line doesn't end up with a gap, as it will
|
|
50077
|
+
* extend the last segment.
|
|
50078
|
+
* @returns {Object} Configuration for a {@link Geometry} subtype.
|
|
50079
|
+
*/
|
|
50080
|
+
function buildLineGeometry(cfg = {}) {
|
|
50081
|
+
|
|
50082
|
+
if (cfg.startPoint.length !== 3) {
|
|
50083
|
+
throw "Start point should contain 3 elements in array: x, y and z";
|
|
50084
|
+
}
|
|
50085
|
+
if (cfg.endPoint.length !== 3) {
|
|
50086
|
+
throw "End point should contain 3 elements in array: x, y and z";
|
|
50087
|
+
}
|
|
50088
|
+
let indices = [];
|
|
50089
|
+
let points = [];
|
|
50090
|
+
let x0 = cfg.startPoint[0]; let y0 = cfg.startPoint[1]; let z0 = cfg.startPoint[2];
|
|
50091
|
+
let x1 = cfg.endPoint[0]; let y1 = cfg.endPoint[1]; let z1 = cfg.endPoint[2];
|
|
50092
|
+
let lineLength = Math.sqrt((x1- x0)**2 + (y1 - y0)**2 + (z1 - z0)**2);
|
|
50093
|
+
let normalizedDirectionVectorOfLine = [(x1-x0)/lineLength, (y1-y0)/lineLength, (z1-z0)/lineLength];
|
|
50094
|
+
|
|
50095
|
+
if (!cfg.pattern) {
|
|
50096
|
+
indices.push(0);
|
|
50097
|
+
indices.push(1);
|
|
50098
|
+
points.push(x0, y0, z0, x1, y1, z1);
|
|
50099
|
+
}
|
|
50100
|
+
else {
|
|
50101
|
+
let patternsNumber = cfg.pattern.length;
|
|
50102
|
+
let gap = false;
|
|
50103
|
+
let segmentFilled = 0.0;
|
|
50104
|
+
let idOfCurrentPatternLength = 0;
|
|
50105
|
+
let pointIndicesCounter = 0;
|
|
50106
|
+
let currentStartPoint = [x0, y0, z0];
|
|
50107
|
+
let currentPatternLength = cfg.pattern[idOfCurrentPatternLength];
|
|
50108
|
+
points.push(currentStartPoint[0], currentStartPoint[1], currentStartPoint[2]);
|
|
50109
|
+
|
|
50110
|
+
while (currentPatternLength <= (lineLength - segmentFilled)) {
|
|
50111
|
+
let vectorFromCurrentStartPointToCurrentEndPoint = [
|
|
50112
|
+
normalizedDirectionVectorOfLine[0] * currentPatternLength,
|
|
50113
|
+
normalizedDirectionVectorOfLine[1] * currentPatternLength,
|
|
50114
|
+
normalizedDirectionVectorOfLine[2] * currentPatternLength,
|
|
50115
|
+
];
|
|
50116
|
+
let currentEndPoint = [
|
|
50117
|
+
currentStartPoint[0] + vectorFromCurrentStartPointToCurrentEndPoint[0],
|
|
50118
|
+
currentStartPoint[1] + vectorFromCurrentStartPointToCurrentEndPoint[1],
|
|
50119
|
+
currentStartPoint[2] + vectorFromCurrentStartPointToCurrentEndPoint[2],
|
|
50120
|
+
];
|
|
50121
|
+
|
|
50122
|
+
points.push(currentEndPoint[0], currentEndPoint[1], currentEndPoint[2]);
|
|
50123
|
+
|
|
50124
|
+
if (!gap) {
|
|
50125
|
+
indices.push(pointIndicesCounter);
|
|
50126
|
+
indices.push(pointIndicesCounter + 1);
|
|
50127
|
+
}
|
|
50128
|
+
gap = !gap;
|
|
50129
|
+
|
|
50130
|
+
pointIndicesCounter += 1;
|
|
50131
|
+
currentStartPoint = currentEndPoint;
|
|
50132
|
+
idOfCurrentPatternLength += 1;
|
|
50133
|
+
if (idOfCurrentPatternLength >= patternsNumber) {
|
|
50134
|
+
idOfCurrentPatternLength = 0;
|
|
50135
|
+
}
|
|
50136
|
+
segmentFilled += currentPatternLength;
|
|
50137
|
+
currentPatternLength = cfg.pattern[idOfCurrentPatternLength];
|
|
50138
|
+
}
|
|
50139
|
+
|
|
50140
|
+
if (cfg.extendToEnd) {
|
|
50141
|
+
points.push(x1, y1, z1);
|
|
50142
|
+
indices.push(indices.length - 2);
|
|
50143
|
+
indices.push(indices.length - 1);
|
|
50144
|
+
}
|
|
50145
|
+
}
|
|
50146
|
+
|
|
50147
|
+
return utils.apply(cfg, {
|
|
50148
|
+
primitive: "lines",
|
|
50149
|
+
positions: points,
|
|
50150
|
+
indices: indices,
|
|
50151
|
+
});
|
|
50152
|
+
}
|
|
50153
|
+
|
|
49797
50154
|
/**
|
|
49798
50155
|
* A plane-shaped 3D object containing a bitmap image.
|
|
49799
50156
|
*
|
|
@@ -86729,8 +87086,6 @@ class DistanceMeasurement extends Component {
|
|
|
86729
87086
|
this._eventSubs = {};
|
|
86730
87087
|
|
|
86731
87088
|
var scene = this.plugin.viewer.scene;
|
|
86732
|
-
this._originMarker = new Marker(scene, cfg.origin);
|
|
86733
|
-
this._targetMarker = new Marker(scene, cfg.target);
|
|
86734
87089
|
|
|
86735
87090
|
this._originWorld = math.vec3();
|
|
86736
87091
|
this._targetWorld = math.vec3();
|
|
@@ -86776,7 +87131,7 @@ class DistanceMeasurement extends Component {
|
|
|
86776
87131
|
this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent('wheel', event));
|
|
86777
87132
|
};
|
|
86778
87133
|
|
|
86779
|
-
this._originDot = new
|
|
87134
|
+
this._originDot = new Dot3D(scene, cfg.origin, this._container, {
|
|
86780
87135
|
fillColor: this._color,
|
|
86781
87136
|
zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2 : undefined,
|
|
86782
87137
|
onMouseOver,
|
|
@@ -86788,7 +87143,7 @@ class DistanceMeasurement extends Component {
|
|
|
86788
87143
|
onContextMenu
|
|
86789
87144
|
});
|
|
86790
87145
|
|
|
86791
|
-
this._targetDot = new
|
|
87146
|
+
this._targetDot = new Dot3D(scene, cfg.target, this._container, {
|
|
86792
87147
|
fillColor: this._color,
|
|
86793
87148
|
zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2 : undefined,
|
|
86794
87149
|
onMouseOver,
|
|
@@ -86935,13 +87290,13 @@ class DistanceMeasurement extends Component {
|
|
|
86935
87290
|
this._labelsOnWires = false;
|
|
86936
87291
|
this._clickable = false;
|
|
86937
87292
|
|
|
86938
|
-
this.
|
|
87293
|
+
this._originDot.on("worldPos", (value) => {
|
|
86939
87294
|
this._originWorld.set(value || [0,0,0]);
|
|
86940
87295
|
this._wpDirty = true;
|
|
86941
87296
|
this._needUpdate(0); // No lag
|
|
86942
87297
|
});
|
|
86943
87298
|
|
|
86944
|
-
this.
|
|
87299
|
+
this._targetDot.on("worldPos", (value) => {
|
|
86945
87300
|
this._targetWorld.set(value || [0,0,0]);
|
|
86946
87301
|
this._wpDirty = true;
|
|
86947
87302
|
this._needUpdate(0); // No lag
|
|
@@ -87103,8 +87458,8 @@ class DistanceMeasurement extends Component {
|
|
|
87103
87458
|
}
|
|
87104
87459
|
|
|
87105
87460
|
const near = -0.3;
|
|
87106
|
-
const vpz1 = this.
|
|
87107
|
-
const vpz2 = this.
|
|
87461
|
+
const vpz1 = this._originDot.viewPos[2];
|
|
87462
|
+
const vpz2 = this._targetDot.viewPos[2];
|
|
87108
87463
|
|
|
87109
87464
|
if (vpz1 > near || vpz2 > near) {
|
|
87110
87465
|
|
|
@@ -87153,9 +87508,6 @@ class DistanceMeasurement extends Component {
|
|
|
87153
87508
|
j += 2;
|
|
87154
87509
|
}
|
|
87155
87510
|
|
|
87156
|
-
this._originDot.setPos(cp[0], cp[1]);
|
|
87157
|
-
this._targetDot.setPos(cp[6], cp[7]);
|
|
87158
|
-
|
|
87159
87511
|
this._lengthWire.setStartAndEnd(cp[0], cp[1], cp[6], cp[7]);
|
|
87160
87512
|
|
|
87161
87513
|
this._xAxisWire.setStartAndEnd(cp[0], cp[1], cp[2], cp[3]);
|
|
@@ -87297,21 +87649,21 @@ class DistanceMeasurement extends Component {
|
|
|
87297
87649
|
}
|
|
87298
87650
|
|
|
87299
87651
|
/**
|
|
87300
|
-
* Gets the origin {@link
|
|
87652
|
+
* Gets the origin {@link Dot3D}.
|
|
87301
87653
|
*
|
|
87302
|
-
* @type {
|
|
87654
|
+
* @type {Dot3D}
|
|
87303
87655
|
*/
|
|
87304
87656
|
get origin() {
|
|
87305
|
-
return this.
|
|
87657
|
+
return this._originDot;
|
|
87306
87658
|
}
|
|
87307
87659
|
|
|
87308
87660
|
/**
|
|
87309
|
-
* Gets the target {@link
|
|
87661
|
+
* Gets the target {@link Dot3D}.
|
|
87310
87662
|
*
|
|
87311
|
-
* @type {
|
|
87663
|
+
* @type {Dot3D}
|
|
87312
87664
|
*/
|
|
87313
87665
|
get target() {
|
|
87314
|
-
return this.
|
|
87666
|
+
return this._targetDot;
|
|
87315
87667
|
}
|
|
87316
87668
|
|
|
87317
87669
|
/**
|
|
@@ -87380,7 +87732,7 @@ class DistanceMeasurement extends Component {
|
|
|
87380
87732
|
}
|
|
87381
87733
|
|
|
87382
87734
|
/**
|
|
87383
|
-
* Sets if the origin {@link
|
|
87735
|
+
* Sets if the origin {@link Dot3D} is visible.
|
|
87384
87736
|
*
|
|
87385
87737
|
* @type {Boolean}
|
|
87386
87738
|
*/
|
|
@@ -87391,7 +87743,7 @@ class DistanceMeasurement extends Component {
|
|
|
87391
87743
|
}
|
|
87392
87744
|
|
|
87393
87745
|
/**
|
|
87394
|
-
* Gets if the origin {@link
|
|
87746
|
+
* Gets if the origin {@link Dot3D} is visible.
|
|
87395
87747
|
*
|
|
87396
87748
|
* @type {Boolean}
|
|
87397
87749
|
*/
|
|
@@ -87400,7 +87752,7 @@ class DistanceMeasurement extends Component {
|
|
|
87400
87752
|
}
|
|
87401
87753
|
|
|
87402
87754
|
/**
|
|
87403
|
-
* Sets if the target {@link
|
|
87755
|
+
* Sets if the target {@link Dot3D} is visible.
|
|
87404
87756
|
*
|
|
87405
87757
|
* @type {Boolean}
|
|
87406
87758
|
*/
|
|
@@ -87411,7 +87763,7 @@ class DistanceMeasurement extends Component {
|
|
|
87411
87763
|
}
|
|
87412
87764
|
|
|
87413
87765
|
/**
|
|
87414
|
-
* Gets if the target {@link
|
|
87766
|
+
* Gets if the target {@link Dot3D} is visible.
|
|
87415
87767
|
*
|
|
87416
87768
|
* @type {Boolean}
|
|
87417
87769
|
*/
|
|
@@ -89699,11 +90051,30 @@ class DistanceMeasurementEditControl extends Component {
|
|
|
89699
90051
|
viewer: viewer,
|
|
89700
90052
|
handleMouseEvents: handleMouseEvents,
|
|
89701
90053
|
handleTouchEvents: handleTouchEvents,
|
|
89702
|
-
snapping: cfg.snapping,
|
|
89703
90054
|
pointerLens: cfg.pointerLens,
|
|
89704
|
-
|
|
89705
|
-
|
|
89706
|
-
|
|
90055
|
+
dots: [ measurement.origin, measurement.target ],
|
|
90056
|
+
ray2WorldPos: (orig, dir, canvasPos) => {
|
|
90057
|
+
const tryPickWorldPos = snap => {
|
|
90058
|
+
const pickResult = viewer.scene.pick({
|
|
90059
|
+
canvasPos: canvasPos,
|
|
90060
|
+
snapToEdge: snap,
|
|
90061
|
+
snapToVertex: snap,
|
|
90062
|
+
pickSurface: true // <<------ This causes picking to find the intersection point on the entity
|
|
90063
|
+
});
|
|
90064
|
+
|
|
90065
|
+
// If - when snapping - no pick found, then try w/o snapping
|
|
90066
|
+
return (pickResult && pickResult.worldPos) ? pickResult.worldPos : (snap && tryPickWorldPos(false));
|
|
90067
|
+
};
|
|
90068
|
+
|
|
90069
|
+
return tryPickWorldPos(!!cfg.snapping);
|
|
90070
|
+
},
|
|
90071
|
+
onEnd: (initPos, dot) => {
|
|
90072
|
+
const changed = ! math.compareVec3(initPos, dot.worldPos);
|
|
90073
|
+
if (changed) {
|
|
90074
|
+
this.fire("edited");
|
|
90075
|
+
}
|
|
90076
|
+
return changed;
|
|
90077
|
+
}
|
|
89707
90078
|
});
|
|
89708
90079
|
|
|
89709
90080
|
const destroyCb = measurement.on("destroyed", cleanup);
|
|
@@ -96442,7 +96813,7 @@ class KeyboardAxisViewHandler {
|
|
|
96442
96813
|
return;
|
|
96443
96814
|
}
|
|
96444
96815
|
|
|
96445
|
-
if (!states.mouseover) {
|
|
96816
|
+
if (configs.keyboardEnabledOnlyIfMouseover && !states.mouseover) {
|
|
96446
96817
|
return;
|
|
96447
96818
|
}
|
|
96448
96819
|
|
|
@@ -96936,7 +97307,7 @@ class KeyboardPanRotateDollyHandler {
|
|
|
96936
97307
|
if (!(configs.active && configs.pointerEnabled) || (!scene.input.keyboardEnabled)) {
|
|
96937
97308
|
return;
|
|
96938
97309
|
}
|
|
96939
|
-
if (!states.mouseover) {
|
|
97310
|
+
if (configs.keyboardEnabledOnlyIfMouseover && !states.mouseover) {
|
|
96940
97311
|
return;
|
|
96941
97312
|
}
|
|
96942
97313
|
keyDownMap[keyCode] = true;
|
|
@@ -96967,7 +97338,7 @@ class KeyboardPanRotateDollyHandler {
|
|
|
96967
97338
|
return;
|
|
96968
97339
|
}
|
|
96969
97340
|
|
|
96970
|
-
if (!states.mouseover) {
|
|
97341
|
+
if (configs.keyboardEnabledOnlyIfMouseover && !states.mouseover) {
|
|
96971
97342
|
return;
|
|
96972
97343
|
}
|
|
96973
97344
|
|
|
@@ -98608,6 +98979,8 @@ class CameraControl extends Component {
|
|
|
98608
98979
|
snapToEdge: DEFAULT_SNAP_EDGE,
|
|
98609
98980
|
snapRadius: DEFAULT_SNAP_PICK_RADIUS,
|
|
98610
98981
|
|
|
98982
|
+
keyboardEnabledOnlyIfMouseover: true,
|
|
98983
|
+
|
|
98611
98984
|
// Rotation
|
|
98612
98985
|
|
|
98613
98986
|
dragRotationRate: 360.0,
|
|
@@ -98918,6 +99291,24 @@ class CameraControl extends Component {
|
|
|
98918
99291
|
get snapRadius() {
|
|
98919
99292
|
return this._configs.snapRadius;
|
|
98920
99293
|
}
|
|
99294
|
+
|
|
99295
|
+
/**
|
|
99296
|
+
* If `true`, the keyboard shortcuts are enabled ONLY if the mouse is over the canvas.
|
|
99297
|
+
*
|
|
99298
|
+
* @param {boolean} value
|
|
99299
|
+
*/
|
|
99300
|
+
set keyboardEnabledOnlyIfMouseover(value) {
|
|
99301
|
+
this._configs.keyboardEnabledOnlyIfMouseover = !!value;
|
|
99302
|
+
}
|
|
99303
|
+
|
|
99304
|
+
/**
|
|
99305
|
+
* Gets whether the keyboard shortcuts are enabled ONLY if the mouse is over the canvas or ALWAYS.
|
|
99306
|
+
*
|
|
99307
|
+
* @returns {boolean}
|
|
99308
|
+
*/
|
|
99309
|
+
get keyboardEnabledOnlyIfMouseover() {
|
|
99310
|
+
return this._configs.keyboardEnabledOnlyIfMouseover;
|
|
99311
|
+
}
|
|
98921
99312
|
|
|
98922
99313
|
/**
|
|
98923
99314
|
* Sets the current navigation mode.
|
|
@@ -139876,26 +140267,19 @@ class ZonesPolysurfaceTouchControl extends Component {
|
|
|
139876
140267
|
|
|
139877
140268
|
class ZoneEditControl extends Component {
|
|
139878
140269
|
constructor(zone, cfg, handleMouseEvents, handleTouchEvents) {
|
|
139879
|
-
|
|
139880
|
-
const
|
|
140270
|
+
const viewer = zone.plugin.viewer;
|
|
140271
|
+
const scene = viewer.scene;
|
|
140272
|
+
super(scene);
|
|
139881
140273
|
|
|
139882
140274
|
const altitude = zone._geometry.altitude;
|
|
139883
|
-
const pointerLens = cfg && cfg.pointerLens;
|
|
139884
|
-
const updatePointerLens = (pointerLens
|
|
139885
|
-
? function(canvasPos) {
|
|
139886
|
-
pointerLens.visible = !! canvasPos;
|
|
139887
|
-
if (canvasPos)
|
|
139888
|
-
{
|
|
139889
|
-
pointerLens.canvasPos = canvasPos;
|
|
139890
|
-
}
|
|
139891
|
-
}
|
|
139892
|
-
: () => { });
|
|
139893
140275
|
|
|
139894
140276
|
const dots = zone._geometry.planeCoordinates.map(planeCoord => {
|
|
139895
|
-
|
|
139896
|
-
const
|
|
139897
|
-
|
|
139898
|
-
|
|
140277
|
+
const dotParent = scene.canvas.canvas.ownerDocument.body;
|
|
140278
|
+
const dot = new Dot3D(scene, {}, dotParent, { fillColor: zone._color });
|
|
140279
|
+
dot.worldPos = math.vec3([ planeCoord[0], altitude, planeCoord[1] ]);
|
|
140280
|
+
dot.on("worldPos", function() {
|
|
140281
|
+
planeCoord[0] = dot.worldPos[0];
|
|
140282
|
+
planeCoord[1] = dot.worldPos[2];
|
|
139899
140283
|
try {
|
|
139900
140284
|
zone._rebuildMesh();
|
|
139901
140285
|
} catch (e) {
|
|
@@ -139904,46 +140288,29 @@ class ZoneEditControl extends Component {
|
|
|
139904
140288
|
zone._zoneMesh = null;
|
|
139905
140289
|
}
|
|
139906
140290
|
}
|
|
139907
|
-
};
|
|
139908
|
-
|
|
139909
|
-
const dot = createDraggableDot3D({
|
|
139910
|
-
handleMouseEvents: handleMouseEvents,
|
|
139911
|
-
handleTouchEvents: handleTouchEvents,
|
|
139912
|
-
viewer: zone.plugin.viewer,
|
|
139913
|
-
worldPos: math.vec3([ planeCoord[0], altitude, planeCoord[1] ]),
|
|
139914
|
-
color: zone._color,
|
|
139915
|
-
ray2WorldPos: (orig, dir) => planeIntersect(altitude, math.vec3([ 0, 1, 0 ]), orig, dir),
|
|
139916
|
-
onStart: () => {
|
|
139917
|
-
initWorldPos = dot.getWorldPos().slice();
|
|
139918
|
-
initPlaneCoord = planeCoord.slice();
|
|
139919
|
-
set_other_dots_active(false, dot);
|
|
139920
|
-
},
|
|
139921
|
-
onMove: (canvasPos, worldPos) => {
|
|
139922
|
-
updatePointerLens(canvasPos);
|
|
139923
|
-
setPlaneCoord([ worldPos[0], worldPos[2] ]);
|
|
139924
|
-
},
|
|
139925
|
-
onEnd: () => {
|
|
139926
|
-
if (zone._zoneMesh)
|
|
139927
|
-
{
|
|
139928
|
-
self.fire("edited");
|
|
139929
|
-
}
|
|
139930
|
-
else
|
|
139931
|
-
{
|
|
139932
|
-
dot.setWorldPos(initWorldPos);
|
|
139933
|
-
setPlaneCoord(initPlaneCoord);
|
|
139934
|
-
}
|
|
139935
|
-
updatePointerLens(null);
|
|
139936
|
-
set_other_dots_active(true, dot);
|
|
139937
|
-
}
|
|
139938
140291
|
});
|
|
139939
140292
|
return dot;
|
|
139940
140293
|
});
|
|
139941
|
-
|
|
139942
|
-
|
|
140294
|
+
|
|
140295
|
+
const cleanupDrag = activateDraggableDots({
|
|
140296
|
+
viewer: viewer,
|
|
140297
|
+
handleMouseEvents: handleMouseEvents,
|
|
140298
|
+
handleTouchEvents: handleTouchEvents,
|
|
140299
|
+
pointerLens: cfg && cfg.pointerLens,
|
|
140300
|
+
dots: dots,
|
|
140301
|
+
ray2WorldPos: (orig, dir) => planeIntersect(altitude, math.vec3([ 0, 1, 0 ]), orig, dir),
|
|
140302
|
+
onEnd: (initPos, dot) => {
|
|
140303
|
+
if (zone._zoneMesh)
|
|
140304
|
+
{
|
|
140305
|
+
this.fire("edited");
|
|
140306
|
+
}
|
|
140307
|
+
return !! zone._zoneMesh;
|
|
140308
|
+
}
|
|
140309
|
+
});
|
|
139943
140310
|
|
|
139944
140311
|
const cleanup = function() {
|
|
139945
|
-
|
|
139946
|
-
|
|
140312
|
+
cleanupDrag();
|
|
140313
|
+
dots.forEach(d => d.destroy());
|
|
139947
140314
|
};
|
|
139948
140315
|
|
|
139949
140316
|
const destroyCb = zone.on("destroyed", cleanup);
|
|
@@ -140337,6 +140704,7 @@ exports.buildBoxLinesGeometry = buildBoxLinesGeometry;
|
|
|
140337
140704
|
exports.buildBoxLinesGeometryFromAABB = buildBoxLinesGeometryFromAABB;
|
|
140338
140705
|
exports.buildCylinderGeometry = buildCylinderGeometry;
|
|
140339
140706
|
exports.buildGridGeometry = buildGridGeometry;
|
|
140707
|
+
exports.buildLineGeometry = buildLineGeometry;
|
|
140340
140708
|
exports.buildPlaneGeometry = buildPlaneGeometry;
|
|
140341
140709
|
exports.buildPolylineGeometry = buildPolylineGeometry;
|
|
140342
140710
|
exports.buildPolylineGeometryFromCurve = buildPolylineGeometryFromCurve;
|