@xeokit/xeokit-sdk 2.6.22 → 2.6.25
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 +1046 -512
- package/dist/xeokit-sdk.es.js +1042 -513
- package/dist/xeokit-sdk.es5.js +957 -742
- 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/AngleMeasurementsMouseControl.js +2 -2
- package/src/plugins/AngleMeasurementsPlugin/index.js +79 -1
- package/src/plugins/AnnotationsPlugin/Annotation.js +31 -0
- package/src/plugins/AnnotationsPlugin/AnnotationsPlugin.js +9 -24
- package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurement.js +17 -23
- package/src/plugins/DistanceMeasurementsPlugin/index.js +79 -1
- package/src/plugins/XKTLoaderPlugin/XKTDefaultDataSource.js +0 -1
- package/src/plugins/ZonesPlugin/index.js +29 -200
- package/src/plugins/lib/html/Dot.js +18 -18
- package/src/plugins/lib/ui/index.js +286 -0
- package/src/viewer/scene/geometry/builders/index.js +2 -1
- package/src/viewer/scene/marker/Marker.js +9 -3
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
|
*/
|
|
@@ -12386,10 +12665,10 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
|
|
|
12386
12665
|
}
|
|
12387
12666
|
|
|
12388
12667
|
_destroyMarkerDiv() {
|
|
12389
|
-
if (this.
|
|
12668
|
+
if (this.markerDiv) {
|
|
12390
12669
|
const element = document.getElementById('myMarkerDiv');
|
|
12391
12670
|
element.parentNode.removeChild(element);
|
|
12392
|
-
this.
|
|
12671
|
+
this.markerDiv = null;
|
|
12393
12672
|
}
|
|
12394
12673
|
}
|
|
12395
12674
|
|
|
@@ -14103,6 +14382,84 @@ class AngleMeasurementsTouchControl extends AngleMeasurementsControl {
|
|
|
14103
14382
|
}
|
|
14104
14383
|
}
|
|
14105
14384
|
|
|
14385
|
+
class AngleMeasurementEditControl extends Component {
|
|
14386
|
+
|
|
14387
|
+
/**
|
|
14388
|
+
* Edits {@link AngleMeasurement} with mouse and/or touch input.
|
|
14389
|
+
*
|
|
14390
|
+
* @param {AngleMeasurement} [measurement] The AngleMeasurement to edit.
|
|
14391
|
+
* @param [cfg] Configuration
|
|
14392
|
+
* @param {PointerLens} [cfg.pointerLens] A PointerLens to use to provide a magnified view of the cursor.
|
|
14393
|
+
* @param {boolean} [cfg.snapping] Whether to enable snap-to-vertex and snap-to-edge.
|
|
14394
|
+
* @param {boolean} [handleMouseEvents] Whether to hangle mouse input.
|
|
14395
|
+
* @param {boolean} [handleTouchEvents] Whether to hangle touch input.
|
|
14396
|
+
*/
|
|
14397
|
+
constructor(measurement, cfg, handleMouseEvents, handleTouchEvents) {
|
|
14398
|
+
|
|
14399
|
+
const viewer = measurement.plugin.viewer;
|
|
14400
|
+
|
|
14401
|
+
super(viewer.scene);
|
|
14402
|
+
|
|
14403
|
+
const cleanup = activateDraggableDots({
|
|
14404
|
+
viewer: viewer,
|
|
14405
|
+
handleMouseEvents: handleMouseEvents,
|
|
14406
|
+
handleTouchEvents: handleTouchEvents,
|
|
14407
|
+
pointerLens: cfg.pointerLens,
|
|
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
|
+
}
|
|
14431
|
+
});
|
|
14432
|
+
|
|
14433
|
+
const destroyCb = measurement.on("destroyed", cleanup);
|
|
14434
|
+
|
|
14435
|
+
this._deactivate = function() {
|
|
14436
|
+
measurement.off("destroyed", destroyCb);
|
|
14437
|
+
cleanup();
|
|
14438
|
+
};
|
|
14439
|
+
}
|
|
14440
|
+
|
|
14441
|
+
deactivate() {
|
|
14442
|
+
this._deactivate();
|
|
14443
|
+
super.destroy();
|
|
14444
|
+
}
|
|
14445
|
+
}
|
|
14446
|
+
|
|
14447
|
+
class AngleMeasurementEditMouseControl extends AngleMeasurementEditControl {
|
|
14448
|
+
constructor(zone, cfg) {
|
|
14449
|
+
super(zone, cfg, true, false);
|
|
14450
|
+
}
|
|
14451
|
+
}
|
|
14452
|
+
|
|
14453
|
+
class AngleMeasurementEditTouchControl extends AngleMeasurementEditControl {
|
|
14454
|
+
constructor(zone, cfg) {
|
|
14455
|
+
super(zone, cfg, false, true);
|
|
14456
|
+
}
|
|
14457
|
+
}
|
|
14458
|
+
|
|
14459
|
+
const tempVec3a$K = math.vec3();
|
|
14460
|
+
const tempVec3b$z = math.vec3();
|
|
14461
|
+
const tempVec3c$v = math.vec3();
|
|
14462
|
+
|
|
14106
14463
|
/**
|
|
14107
14464
|
* A {@link Marker} with an HTML label attached to it, managed by an {@link AnnotationsPlugin}.
|
|
14108
14465
|
*
|
|
@@ -14142,6 +14499,9 @@ class Annotation extends Marker {
|
|
|
14142
14499
|
this._marker.addEventListener("click", this._onMouseClickedExternalMarker = () => {
|
|
14143
14500
|
this.plugin.fire("markerClicked", this);
|
|
14144
14501
|
});
|
|
14502
|
+
this._marker.addEventListener("contextmenu", this._onContextMenuExtenalMarker = () => {
|
|
14503
|
+
this.plugin.fire("contextmenu", this);
|
|
14504
|
+
});
|
|
14145
14505
|
this._marker.addEventListener("mouseenter", this._onMouseEnterExternalMarker = () => {
|
|
14146
14506
|
this.plugin.fire("markerMouseEnter", this);
|
|
14147
14507
|
});
|
|
@@ -14261,6 +14621,10 @@ class Annotation extends Marker {
|
|
|
14261
14621
|
this._marker.addEventListener("click", () => {
|
|
14262
14622
|
this.plugin.fire("markerClicked", this);
|
|
14263
14623
|
});
|
|
14624
|
+
this._marker.addEventListener("contextmenu", e => {
|
|
14625
|
+
e.preventDefault();
|
|
14626
|
+
this.plugin.fire("contextmenu", this);
|
|
14627
|
+
});
|
|
14264
14628
|
this._marker.addEventListener("mouseenter", () => {
|
|
14265
14629
|
this.plugin.fire("markerMouseEnter", this);
|
|
14266
14630
|
});
|
|
@@ -14322,6 +14686,24 @@ class Annotation extends Marker {
|
|
|
14322
14686
|
return template;
|
|
14323
14687
|
}
|
|
14324
14688
|
|
|
14689
|
+
/**
|
|
14690
|
+
* Sets the Marker's worldPos and entity properties based on passed {@link PickResult}
|
|
14691
|
+
*
|
|
14692
|
+
* @param {PickResult} pickResult A PickResult to position the Marker at.
|
|
14693
|
+
*/
|
|
14694
|
+
setFromPickResult(pickResult) {
|
|
14695
|
+
if (!pickResult.worldPos || !pickResult.worldNormal) {
|
|
14696
|
+
this.error("Param 'pickResult' does not have both worldPos and worldNormal");
|
|
14697
|
+
} else {
|
|
14698
|
+
const normalizedWorldNormal = math.normalizeVec3(pickResult.worldNormal, tempVec3a$K);
|
|
14699
|
+
const offset = (this.plugin && this.plugin.surfaceOffset) || 0;
|
|
14700
|
+
const offsetVec = math.mulVec3Scalar(normalizedWorldNormal, offset, tempVec3b$z);
|
|
14701
|
+
const offsetWorldPos = math.addVec3(pickResult.worldPos, offsetVec, tempVec3c$v);
|
|
14702
|
+
this.entity = pickResult.entity;
|
|
14703
|
+
this.worldPos = offsetWorldPos;
|
|
14704
|
+
}
|
|
14705
|
+
}
|
|
14706
|
+
|
|
14325
14707
|
/**
|
|
14326
14708
|
* Sets whether or not to show this Annotation's marker.
|
|
14327
14709
|
*
|
|
@@ -14452,6 +14834,7 @@ class Annotation extends Marker {
|
|
|
14452
14834
|
this._marker = null;
|
|
14453
14835
|
} else {
|
|
14454
14836
|
this._marker.removeEventListener("click", this._onMouseClickedExternalMarker);
|
|
14837
|
+
this._marker.removeEventListener("contextmenu", this._onContextMenuExtenalMarker);
|
|
14455
14838
|
this._marker.removeEventListener("mouseenter", this._onMouseEnterExternalMarker);
|
|
14456
14839
|
this._marker.removeEventListener("mouseleave", this._onMouseLeaveExternalMarker);
|
|
14457
14840
|
this._marker = null;
|
|
@@ -14468,10 +14851,6 @@ class Annotation extends Marker {
|
|
|
14468
14851
|
}
|
|
14469
14852
|
}
|
|
14470
14853
|
|
|
14471
|
-
const tempVec3a$K = math.vec3();
|
|
14472
|
-
const tempVec3b$z = math.vec3();
|
|
14473
|
-
const tempVec3c$v = math.vec3();
|
|
14474
|
-
|
|
14475
14854
|
/**
|
|
14476
14855
|
* {@link Viewer} plugin that creates {@link Annotation}s.
|
|
14477
14856
|
*
|
|
@@ -14946,24 +15325,6 @@ class AnnotationsPlugin extends Plugin {
|
|
|
14946
15325
|
this.error("Viewer component with this ID already exists: " + params.id);
|
|
14947
15326
|
delete params.id;
|
|
14948
15327
|
}
|
|
14949
|
-
var worldPos;
|
|
14950
|
-
var entity;
|
|
14951
|
-
params.pickResult = params.pickResult || params.pickRecord;
|
|
14952
|
-
if (params.pickResult) {
|
|
14953
|
-
const pickResult = params.pickResult;
|
|
14954
|
-
if (!pickResult.worldPos || !pickResult.worldNormal) {
|
|
14955
|
-
this.error("Param 'pickResult' does not have both worldPos and worldNormal");
|
|
14956
|
-
} else {
|
|
14957
|
-
const normalizedWorldNormal = math.normalizeVec3(pickResult.worldNormal, tempVec3a$K);
|
|
14958
|
-
const offsetVec = math.mulVec3Scalar(normalizedWorldNormal, this._surfaceOffset, tempVec3b$z);
|
|
14959
|
-
const offsetWorldPos = math.addVec3(pickResult.worldPos, offsetVec, tempVec3c$v);
|
|
14960
|
-
worldPos = offsetWorldPos;
|
|
14961
|
-
entity = pickResult.entity;
|
|
14962
|
-
}
|
|
14963
|
-
} else {
|
|
14964
|
-
worldPos = params.worldPos;
|
|
14965
|
-
entity = params.entity;
|
|
14966
|
-
}
|
|
14967
15328
|
|
|
14968
15329
|
var markerElement = null;
|
|
14969
15330
|
if (params.markerElementId) {
|
|
@@ -14984,8 +15345,6 @@ class AnnotationsPlugin extends Plugin {
|
|
|
14984
15345
|
const annotation = new Annotation(this.viewer.scene, {
|
|
14985
15346
|
id: params.id,
|
|
14986
15347
|
plugin: this,
|
|
14987
|
-
entity: entity,
|
|
14988
|
-
worldPos: worldPos,
|
|
14989
15348
|
container: this._container,
|
|
14990
15349
|
markerElement: markerElement,
|
|
14991
15350
|
labelElement: labelElement,
|
|
@@ -15001,6 +15360,15 @@ class AnnotationsPlugin extends Plugin {
|
|
|
15001
15360
|
projection: params.projection,
|
|
15002
15361
|
visible: (params.visible !== false)
|
|
15003
15362
|
});
|
|
15363
|
+
|
|
15364
|
+
params.pickResult = params.pickResult || params.pickRecord;
|
|
15365
|
+
if (params.pickResult) {
|
|
15366
|
+
annotation.setFromPickResult(params.pickResult);
|
|
15367
|
+
} else {
|
|
15368
|
+
annotation.entity = params.entity;
|
|
15369
|
+
annotation.worldPos = params.worldPos;
|
|
15370
|
+
}
|
|
15371
|
+
|
|
15004
15372
|
this.annotations[annotation.id] = annotation;
|
|
15005
15373
|
annotation.on("destroyed", () => {
|
|
15006
15374
|
delete this.annotations[annotation.id];
|
|
@@ -49480,6 +49848,270 @@ function buildPolylineGeometryFromCurve(cfg = {}) {
|
|
|
49480
49848
|
});
|
|
49481
49849
|
}
|
|
49482
49850
|
|
|
49851
|
+
/**
|
|
49852
|
+
* @desc Creates a 3D line {@link Geometry}.
|
|
49853
|
+
*
|
|
49854
|
+
* ## Usage
|
|
49855
|
+
*
|
|
49856
|
+
* In the example below we'll create a {@link Mesh} with a line {@link ReadableGeometry}.
|
|
49857
|
+
*
|
|
49858
|
+
* [[Run this example](https://xeokit.github.io/xeokit-sdk/examples/scenegraph/#buildLineGeometry)]
|
|
49859
|
+
*
|
|
49860
|
+
* ````javascript
|
|
49861
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49862
|
+
* // Import the modules we need for this example
|
|
49863
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49864
|
+
*
|
|
49865
|
+
* import {buildLineGeometry, Viewer, Mesh, ReadableGeometry, PhongMaterial} from "../../dist/xeokit-sdk.min.es.js";
|
|
49866
|
+
*
|
|
49867
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49868
|
+
* // Create a Viewer and arrange the camera
|
|
49869
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49870
|
+
*
|
|
49871
|
+
* const viewer = new Viewer({
|
|
49872
|
+
* canvasId: "myCanvas"
|
|
49873
|
+
* });
|
|
49874
|
+
*
|
|
49875
|
+
* viewer.camera.eye = [0, 0, 8];
|
|
49876
|
+
* viewer.camera.look = [0, 0, 0];
|
|
49877
|
+
* viewer.camera.up = [0, 1, 0];
|
|
49878
|
+
*
|
|
49879
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49880
|
+
* // Create a mesh with simple 2d line shape
|
|
49881
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49882
|
+
*
|
|
49883
|
+
* new Mesh(viewer.scene, {
|
|
49884
|
+
* geometry: new ReadableGeometry(viewer.scene, buildLineGeometry({
|
|
49885
|
+
* startPoint: [-5,-2,0],
|
|
49886
|
+
* endPoint: [-5,2,0],
|
|
49887
|
+
* })),
|
|
49888
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
49889
|
+
* emissive: [0, 1,]
|
|
49890
|
+
* })
|
|
49891
|
+
* });
|
|
49892
|
+
*
|
|
49893
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49894
|
+
* // Create a mesh with simple 2d line shape with black color
|
|
49895
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49896
|
+
*
|
|
49897
|
+
* new Mesh(viewer.scene, {
|
|
49898
|
+
* geometry: new ReadableGeometry(viewer.scene, buildLineGeometry({
|
|
49899
|
+
* startPoint: [-4,-2,0],
|
|
49900
|
+
* endPoint: [-4,2,0],
|
|
49901
|
+
* })),
|
|
49902
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
49903
|
+
* emissive: [0, 0, 0]
|
|
49904
|
+
* })
|
|
49905
|
+
* });
|
|
49906
|
+
*
|
|
49907
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49908
|
+
* // Create a mesh with simple 2d line shape with black color and simple pattern
|
|
49909
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49910
|
+
*
|
|
49911
|
+
* new Mesh(viewer.scene, {
|
|
49912
|
+
* geometry: new ReadableGeometry(viewer.scene, buildLineGeometry({
|
|
49913
|
+
* startPoint: [-3,-2,0],
|
|
49914
|
+
* endPoint: [-3,2,0],
|
|
49915
|
+
* pattern: [0.10],
|
|
49916
|
+
* })),
|
|
49917
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
49918
|
+
* emissive: [0, 0, 0]
|
|
49919
|
+
* })
|
|
49920
|
+
* });
|
|
49921
|
+
*
|
|
49922
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49923
|
+
* // Create a mesh with simple 2d line shape with blue color and simple pattern extended to end
|
|
49924
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49925
|
+
*
|
|
49926
|
+
* new Mesh(viewer.scene, {
|
|
49927
|
+
* geometry: new ReadableGeometry(viewer.scene, buildLineGeometry({
|
|
49928
|
+
* startPoint: [-2,-2,0],
|
|
49929
|
+
* endPoint: [-2,2,0],
|
|
49930
|
+
* pattern: [0.10],
|
|
49931
|
+
* extendToEnd: true,
|
|
49932
|
+
* })),
|
|
49933
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
49934
|
+
* emissive: [0, 0, 1]
|
|
49935
|
+
* })
|
|
49936
|
+
* });
|
|
49937
|
+
*
|
|
49938
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49939
|
+
* // Create a mesh with simple 2d line shape with black color and more complex pattern
|
|
49940
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49941
|
+
*
|
|
49942
|
+
* new Mesh(viewer.scene, {
|
|
49943
|
+
* geometry: new ReadableGeometry(viewer.scene, buildLineGeometry({
|
|
49944
|
+
* startPoint: [-1,-2,0],
|
|
49945
|
+
* endPoint: [-1,2,0],
|
|
49946
|
+
* pattern: [0.15, 0.05],
|
|
49947
|
+
* })),
|
|
49948
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
49949
|
+
* emissive: [0, 0, 0]
|
|
49950
|
+
* })
|
|
49951
|
+
* });
|
|
49952
|
+
*
|
|
49953
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49954
|
+
* // Create a mesh with simple 2d line shape with blue color and more complex pattern extended to end
|
|
49955
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49956
|
+
*
|
|
49957
|
+
* new Mesh(viewer.scene, {
|
|
49958
|
+
* geometry: new ReadableGeometry(viewer.scene, buildLineGeometry({
|
|
49959
|
+
* startPoint: [0,-2,0],
|
|
49960
|
+
* endPoint: [0,2,0],
|
|
49961
|
+
* pattern: [0.15, 0.05],
|
|
49962
|
+
* extendToEnd: true,
|
|
49963
|
+
* })),
|
|
49964
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
49965
|
+
* emissive: [0, 0, 1]
|
|
49966
|
+
* })
|
|
49967
|
+
* });
|
|
49968
|
+
*
|
|
49969
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49970
|
+
* // Create a mesh with simple 2d line shape with black color and complex pattern
|
|
49971
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49972
|
+
*
|
|
49973
|
+
* new Mesh(viewer.scene, {
|
|
49974
|
+
* geometry: new ReadableGeometry(viewer.scene, buildLineGeometry({
|
|
49975
|
+
* startPoint: [1,-2,0],
|
|
49976
|
+
* endPoint: [1,2,0],
|
|
49977
|
+
* pattern: [0.15, 0.05, 0.50],
|
|
49978
|
+
* })),
|
|
49979
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
49980
|
+
* emissive: [0, 0, 0]
|
|
49981
|
+
* })
|
|
49982
|
+
* });
|
|
49983
|
+
*
|
|
49984
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49985
|
+
* // Create a mesh with simple 2d line shape with blue color and complex pattern extended to end
|
|
49986
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
49987
|
+
*
|
|
49988
|
+
* new Mesh(viewer.scene, {
|
|
49989
|
+
* geometry: new ReadableGeometry(viewer.scene, buildLineGeometry({
|
|
49990
|
+
* startPoint: [2,-2,0],
|
|
49991
|
+
* endPoint: [2,2,0],
|
|
49992
|
+
* pattern: [0.15, 0.05, 0.50],
|
|
49993
|
+
* extendToEnd: true,
|
|
49994
|
+
* })),
|
|
49995
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
49996
|
+
* emissive: [0, 0, 1]
|
|
49997
|
+
* })
|
|
49998
|
+
* });
|
|
49999
|
+
*
|
|
50000
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
50001
|
+
* // Create a mesh with simple 3d line shape with white color and simple pattern
|
|
50002
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
50003
|
+
*
|
|
50004
|
+
* new Mesh(viewer.scene, {
|
|
50005
|
+
* geometry: new ReadableGeometry(viewer.scene, buildLineGeometry({
|
|
50006
|
+
* startPoint: [3,-2,-1],
|
|
50007
|
+
* endPoint: [5,2,1],
|
|
50008
|
+
* pattern: [0.10],
|
|
50009
|
+
* })),
|
|
50010
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
50011
|
+
* emissive: [1, 1, 1]
|
|
50012
|
+
* })
|
|
50013
|
+
* });
|
|
50014
|
+
*
|
|
50015
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
50016
|
+
* // Create a mesh with simple 3d line shape with black color and simple dot pattern
|
|
50017
|
+
* //------------------------------------------------------------------------------------------------------------------
|
|
50018
|
+
*
|
|
50019
|
+
* new Mesh(viewer.scene, {
|
|
50020
|
+
* geometry: new ReadableGeometry(viewer.scene, buildLineGeometry({
|
|
50021
|
+
* startPoint: [5,-2,-1],
|
|
50022
|
+
* endPoint: [7,2,1],
|
|
50023
|
+
* pattern: [0.03],
|
|
50024
|
+
* })),
|
|
50025
|
+
* material: new PhongMaterial(viewer.scene, {
|
|
50026
|
+
* emissive: [0, 0, 0]
|
|
50027
|
+
* })
|
|
50028
|
+
* });
|
|
50029
|
+
* ````
|
|
50030
|
+
*
|
|
50031
|
+
* @function buildLineGeometry
|
|
50032
|
+
* @param {*} [cfg] Configs
|
|
50033
|
+
* @param {String} [cfg.id] Optional ID, unique among all components in the parent {@link Scene}, generated automatically when omitted.
|
|
50034
|
+
* @param {Number[]} [cfg.startPoint] 3D start point (x0, y0, z0).
|
|
50035
|
+
* @param {Number[]} [cfg.endPoint] 3D end point (x1, y1, z1).
|
|
50036
|
+
* @param {Number[]} [cfg.pattern] Lengths of segments that describe a pattern.
|
|
50037
|
+
* @param {Bool} [cfg.extendToEnd] If true: it will try to make sure the line doesn't end up with a gap, as it will
|
|
50038
|
+
* extend the last segment.
|
|
50039
|
+
* @returns {Object} Configuration for a {@link Geometry} subtype.
|
|
50040
|
+
*/
|
|
50041
|
+
function buildLineGeometry(cfg = {}) {
|
|
50042
|
+
|
|
50043
|
+
if (cfg.startPoint.length !== 3) {
|
|
50044
|
+
throw "Start point should contain 3 elements in array: x, y and z";
|
|
50045
|
+
}
|
|
50046
|
+
if (cfg.endPoint.length !== 3) {
|
|
50047
|
+
throw "End point should contain 3 elements in array: x, y and z";
|
|
50048
|
+
}
|
|
50049
|
+
let indices = [];
|
|
50050
|
+
let points = [];
|
|
50051
|
+
let x0 = cfg.startPoint[0]; let y0 = cfg.startPoint[1]; let z0 = cfg.startPoint[2];
|
|
50052
|
+
let x1 = cfg.endPoint[0]; let y1 = cfg.endPoint[1]; let z1 = cfg.endPoint[2];
|
|
50053
|
+
let lineLength = Math.sqrt((x1- x0)**2 + (y1 - y0)**2 + (z1 - z0)**2);
|
|
50054
|
+
let normalizedDirectionVectorOfLine = [(x1-x0)/lineLength, (y1-y0)/lineLength, (z1-z0)/lineLength];
|
|
50055
|
+
|
|
50056
|
+
if (!cfg.pattern) {
|
|
50057
|
+
indices.push(0);
|
|
50058
|
+
indices.push(1);
|
|
50059
|
+
points.push(x0, y0, z0, x1, y1, z1);
|
|
50060
|
+
}
|
|
50061
|
+
else {
|
|
50062
|
+
let patternsNumber = cfg.pattern.length;
|
|
50063
|
+
let gap = false;
|
|
50064
|
+
let segmentFilled = 0.0;
|
|
50065
|
+
let idOfCurrentPatternLength = 0;
|
|
50066
|
+
let pointIndicesCounter = 0;
|
|
50067
|
+
let currentStartPoint = [x0, y0, z0];
|
|
50068
|
+
let currentPatternLength = cfg.pattern[idOfCurrentPatternLength];
|
|
50069
|
+
points.push(currentStartPoint[0], currentStartPoint[1], currentStartPoint[2]);
|
|
50070
|
+
|
|
50071
|
+
while (currentPatternLength <= (lineLength - segmentFilled)) {
|
|
50072
|
+
let vectorFromCurrentStartPointToCurrentEndPoint = [
|
|
50073
|
+
normalizedDirectionVectorOfLine[0] * currentPatternLength,
|
|
50074
|
+
normalizedDirectionVectorOfLine[1] * currentPatternLength,
|
|
50075
|
+
normalizedDirectionVectorOfLine[2] * currentPatternLength,
|
|
50076
|
+
];
|
|
50077
|
+
let currentEndPoint = [
|
|
50078
|
+
currentStartPoint[0] + vectorFromCurrentStartPointToCurrentEndPoint[0],
|
|
50079
|
+
currentStartPoint[1] + vectorFromCurrentStartPointToCurrentEndPoint[1],
|
|
50080
|
+
currentStartPoint[2] + vectorFromCurrentStartPointToCurrentEndPoint[2],
|
|
50081
|
+
];
|
|
50082
|
+
|
|
50083
|
+
points.push(currentEndPoint[0], currentEndPoint[1], currentEndPoint[2]);
|
|
50084
|
+
|
|
50085
|
+
if (!gap) {
|
|
50086
|
+
indices.push(pointIndicesCounter);
|
|
50087
|
+
indices.push(pointIndicesCounter + 1);
|
|
50088
|
+
}
|
|
50089
|
+
gap = !gap;
|
|
50090
|
+
|
|
50091
|
+
pointIndicesCounter += 1;
|
|
50092
|
+
currentStartPoint = currentEndPoint;
|
|
50093
|
+
idOfCurrentPatternLength += 1;
|
|
50094
|
+
if (idOfCurrentPatternLength >= patternsNumber) {
|
|
50095
|
+
idOfCurrentPatternLength = 0;
|
|
50096
|
+
}
|
|
50097
|
+
segmentFilled += currentPatternLength;
|
|
50098
|
+
currentPatternLength = cfg.pattern[idOfCurrentPatternLength];
|
|
50099
|
+
}
|
|
50100
|
+
|
|
50101
|
+
if (cfg.extendToEnd) {
|
|
50102
|
+
points.push(x1, y1, z1);
|
|
50103
|
+
indices.push(indices.length - 2);
|
|
50104
|
+
indices.push(indices.length - 1);
|
|
50105
|
+
}
|
|
50106
|
+
}
|
|
50107
|
+
|
|
50108
|
+
return utils.apply(cfg, {
|
|
50109
|
+
primitive: "lines",
|
|
50110
|
+
positions: points,
|
|
50111
|
+
indices: indices,
|
|
50112
|
+
});
|
|
50113
|
+
}
|
|
50114
|
+
|
|
49483
50115
|
/**
|
|
49484
50116
|
* A plane-shaped 3D object containing a bitmap image.
|
|
49485
50117
|
*
|
|
@@ -86415,8 +87047,6 @@ class DistanceMeasurement extends Component {
|
|
|
86415
87047
|
this._eventSubs = {};
|
|
86416
87048
|
|
|
86417
87049
|
var scene = this.plugin.viewer.scene;
|
|
86418
|
-
this._originMarker = new Marker(scene, cfg.origin);
|
|
86419
|
-
this._targetMarker = new Marker(scene, cfg.target);
|
|
86420
87050
|
|
|
86421
87051
|
this._originWorld = math.vec3();
|
|
86422
87052
|
this._targetWorld = math.vec3();
|
|
@@ -86462,7 +87092,7 @@ class DistanceMeasurement extends Component {
|
|
|
86462
87092
|
this.plugin.viewer.scene.canvas.canvas.dispatchEvent(new WheelEvent('wheel', event));
|
|
86463
87093
|
};
|
|
86464
87094
|
|
|
86465
|
-
this._originDot = new
|
|
87095
|
+
this._originDot = new Dot3D(scene, cfg.origin, this._container, {
|
|
86466
87096
|
fillColor: this._color,
|
|
86467
87097
|
zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2 : undefined,
|
|
86468
87098
|
onMouseOver,
|
|
@@ -86474,7 +87104,7 @@ class DistanceMeasurement extends Component {
|
|
|
86474
87104
|
onContextMenu
|
|
86475
87105
|
});
|
|
86476
87106
|
|
|
86477
|
-
this._targetDot = new
|
|
87107
|
+
this._targetDot = new Dot3D(scene, cfg.target, this._container, {
|
|
86478
87108
|
fillColor: this._color,
|
|
86479
87109
|
zIndex: plugin.zIndex !== undefined ? plugin.zIndex + 2 : undefined,
|
|
86480
87110
|
onMouseOver,
|
|
@@ -86621,13 +87251,13 @@ class DistanceMeasurement extends Component {
|
|
|
86621
87251
|
this._labelsOnWires = false;
|
|
86622
87252
|
this._clickable = false;
|
|
86623
87253
|
|
|
86624
|
-
this.
|
|
87254
|
+
this._originDot.on("worldPos", (value) => {
|
|
86625
87255
|
this._originWorld.set(value || [0,0,0]);
|
|
86626
87256
|
this._wpDirty = true;
|
|
86627
87257
|
this._needUpdate(0); // No lag
|
|
86628
87258
|
});
|
|
86629
87259
|
|
|
86630
|
-
this.
|
|
87260
|
+
this._targetDot.on("worldPos", (value) => {
|
|
86631
87261
|
this._targetWorld.set(value || [0,0,0]);
|
|
86632
87262
|
this._wpDirty = true;
|
|
86633
87263
|
this._needUpdate(0); // No lag
|
|
@@ -86789,8 +87419,8 @@ class DistanceMeasurement extends Component {
|
|
|
86789
87419
|
}
|
|
86790
87420
|
|
|
86791
87421
|
const near = -0.3;
|
|
86792
|
-
const vpz1 = this.
|
|
86793
|
-
const vpz2 = this.
|
|
87422
|
+
const vpz1 = this._originDot.viewPos[2];
|
|
87423
|
+
const vpz2 = this._targetDot.viewPos[2];
|
|
86794
87424
|
|
|
86795
87425
|
if (vpz1 > near || vpz2 > near) {
|
|
86796
87426
|
|
|
@@ -86839,9 +87469,6 @@ class DistanceMeasurement extends Component {
|
|
|
86839
87469
|
j += 2;
|
|
86840
87470
|
}
|
|
86841
87471
|
|
|
86842
|
-
this._originDot.setPos(cp[0], cp[1]);
|
|
86843
|
-
this._targetDot.setPos(cp[6], cp[7]);
|
|
86844
|
-
|
|
86845
87472
|
this._lengthWire.setStartAndEnd(cp[0], cp[1], cp[6], cp[7]);
|
|
86846
87473
|
|
|
86847
87474
|
this._xAxisWire.setStartAndEnd(cp[0], cp[1], cp[2], cp[3]);
|
|
@@ -86983,21 +87610,21 @@ class DistanceMeasurement extends Component {
|
|
|
86983
87610
|
}
|
|
86984
87611
|
|
|
86985
87612
|
/**
|
|
86986
|
-
* Gets the origin {@link
|
|
87613
|
+
* Gets the origin {@link Dot3D}.
|
|
86987
87614
|
*
|
|
86988
|
-
* @type {
|
|
87615
|
+
* @type {Dot3D}
|
|
86989
87616
|
*/
|
|
86990
87617
|
get origin() {
|
|
86991
|
-
return this.
|
|
87618
|
+
return this._originDot;
|
|
86992
87619
|
}
|
|
86993
87620
|
|
|
86994
87621
|
/**
|
|
86995
|
-
* Gets the target {@link
|
|
87622
|
+
* Gets the target {@link Dot3D}.
|
|
86996
87623
|
*
|
|
86997
|
-
* @type {
|
|
87624
|
+
* @type {Dot3D}
|
|
86998
87625
|
*/
|
|
86999
87626
|
get target() {
|
|
87000
|
-
return this.
|
|
87627
|
+
return this._targetDot;
|
|
87001
87628
|
}
|
|
87002
87629
|
|
|
87003
87630
|
/**
|
|
@@ -87066,7 +87693,7 @@ class DistanceMeasurement extends Component {
|
|
|
87066
87693
|
}
|
|
87067
87694
|
|
|
87068
87695
|
/**
|
|
87069
|
-
* Sets if the origin {@link
|
|
87696
|
+
* Sets if the origin {@link Dot3D} is visible.
|
|
87070
87697
|
*
|
|
87071
87698
|
* @type {Boolean}
|
|
87072
87699
|
*/
|
|
@@ -87077,7 +87704,7 @@ class DistanceMeasurement extends Component {
|
|
|
87077
87704
|
}
|
|
87078
87705
|
|
|
87079
87706
|
/**
|
|
87080
|
-
* Gets if the origin {@link
|
|
87707
|
+
* Gets if the origin {@link Dot3D} is visible.
|
|
87081
87708
|
*
|
|
87082
87709
|
* @type {Boolean}
|
|
87083
87710
|
*/
|
|
@@ -87086,7 +87713,7 @@ class DistanceMeasurement extends Component {
|
|
|
87086
87713
|
}
|
|
87087
87714
|
|
|
87088
87715
|
/**
|
|
87089
|
-
* Sets if the target {@link
|
|
87716
|
+
* Sets if the target {@link Dot3D} is visible.
|
|
87090
87717
|
*
|
|
87091
87718
|
* @type {Boolean}
|
|
87092
87719
|
*/
|
|
@@ -87097,7 +87724,7 @@ class DistanceMeasurement extends Component {
|
|
|
87097
87724
|
}
|
|
87098
87725
|
|
|
87099
87726
|
/**
|
|
87100
|
-
* Gets if the target {@link
|
|
87727
|
+
* Gets if the target {@link Dot3D} is visible.
|
|
87101
87728
|
*
|
|
87102
87729
|
* @type {Boolean}
|
|
87103
87730
|
*/
|
|
@@ -89363,6 +89990,80 @@ class DistanceMeasurementsTouchControl extends DistanceMeasurementsControl {
|
|
|
89363
89990
|
}
|
|
89364
89991
|
}
|
|
89365
89992
|
|
|
89993
|
+
class DistanceMeasurementEditControl extends Component {
|
|
89994
|
+
|
|
89995
|
+
/**
|
|
89996
|
+
* Edits {@link DistanceMeasurement} with mouse and/or touch input.
|
|
89997
|
+
*
|
|
89998
|
+
* @param {DistanceMeasurement} [measurement] The DistanceMeasurement to edit.
|
|
89999
|
+
* @param [cfg] Configuration
|
|
90000
|
+
* @param {PointerLens} [cfg.pointerLens] A PointerLens to use to provide a magnified view of the cursor.
|
|
90001
|
+
* @param {boolean} [cfg.snapping] Whether to enable snap-to-vertex and snap-to-edge.
|
|
90002
|
+
* @param {boolean} [handleMouseEvents] Whether to hangle mouse input.
|
|
90003
|
+
* @param {boolean} [handleTouchEvents] Whether to hangle touch input.
|
|
90004
|
+
*/
|
|
90005
|
+
constructor(measurement, cfg, handleMouseEvents, handleTouchEvents) {
|
|
90006
|
+
|
|
90007
|
+
const viewer = measurement.plugin.viewer;
|
|
90008
|
+
|
|
90009
|
+
super(viewer.scene);
|
|
90010
|
+
|
|
90011
|
+
const cleanup = activateDraggableDots({
|
|
90012
|
+
viewer: viewer,
|
|
90013
|
+
handleMouseEvents: handleMouseEvents,
|
|
90014
|
+
handleTouchEvents: handleTouchEvents,
|
|
90015
|
+
pointerLens: cfg.pointerLens,
|
|
90016
|
+
dots: [ measurement.origin, measurement.target ],
|
|
90017
|
+
ray2WorldPos: (orig, dir, canvasPos) => {
|
|
90018
|
+
const tryPickWorldPos = snap => {
|
|
90019
|
+
const pickResult = viewer.scene.pick({
|
|
90020
|
+
canvasPos: canvasPos,
|
|
90021
|
+
snapToEdge: snap,
|
|
90022
|
+
snapToVertex: snap,
|
|
90023
|
+
pickSurface: true // <<------ This causes picking to find the intersection point on the entity
|
|
90024
|
+
});
|
|
90025
|
+
|
|
90026
|
+
// If - when snapping - no pick found, then try w/o snapping
|
|
90027
|
+
return (pickResult && pickResult.worldPos) ? pickResult.worldPos : (snap && tryPickWorldPos(false));
|
|
90028
|
+
};
|
|
90029
|
+
|
|
90030
|
+
return tryPickWorldPos(!!cfg.snapping);
|
|
90031
|
+
},
|
|
90032
|
+
onEnd: (initPos, dot) => {
|
|
90033
|
+
const changed = ! math.compareVec3(initPos, dot.worldPos);
|
|
90034
|
+
if (changed) {
|
|
90035
|
+
this.fire("edited");
|
|
90036
|
+
}
|
|
90037
|
+
return changed;
|
|
90038
|
+
}
|
|
90039
|
+
});
|
|
90040
|
+
|
|
90041
|
+
const destroyCb = measurement.on("destroyed", cleanup);
|
|
90042
|
+
|
|
90043
|
+
this._deactivate = function() {
|
|
90044
|
+
measurement.off("destroyed", destroyCb);
|
|
90045
|
+
cleanup();
|
|
90046
|
+
};
|
|
90047
|
+
}
|
|
90048
|
+
|
|
90049
|
+
deactivate() {
|
|
90050
|
+
this._deactivate();
|
|
90051
|
+
super.destroy();
|
|
90052
|
+
}
|
|
90053
|
+
}
|
|
90054
|
+
|
|
90055
|
+
class DistanceMeasurementEditMouseControl extends DistanceMeasurementEditControl {
|
|
90056
|
+
constructor(zone, cfg) {
|
|
90057
|
+
super(zone, cfg, true, false);
|
|
90058
|
+
}
|
|
90059
|
+
}
|
|
90060
|
+
|
|
90061
|
+
class DistanceMeasurementEditTouchControl extends DistanceMeasurementEditControl {
|
|
90062
|
+
constructor(zone, cfg) {
|
|
90063
|
+
super(zone, cfg, false, true);
|
|
90064
|
+
}
|
|
90065
|
+
}
|
|
90066
|
+
|
|
89366
90067
|
/**
|
|
89367
90068
|
* {@link Viewer} plugin that makes interaction smoother with large models, by temporarily switching
|
|
89368
90069
|
* the Viewer to faster, lower-quality rendering modes whenever we interact.
|
|
@@ -137935,13 +138636,6 @@ const hex2rgb = function(color) {
|
|
|
137935
138636
|
return [ rgb(0), rgb(2), rgb(4) ];
|
|
137936
138637
|
};
|
|
137937
138638
|
|
|
137938
|
-
const transformToNode = function(from, to, vec) {
|
|
137939
|
-
const fromRec = from.getBoundingClientRect();
|
|
137940
|
-
const toRec = to.getBoundingClientRect();
|
|
137941
|
-
vec[0] += fromRec.left - toRec.left;
|
|
137942
|
-
vec[1] += fromRec.top - toRec.top;
|
|
137943
|
-
};
|
|
137944
|
-
|
|
137945
138639
|
const triangulateEarClipping = function(planeCoords) {
|
|
137946
138640
|
|
|
137947
138641
|
const polygonVertices = [ ];
|
|
@@ -138044,148 +138738,6 @@ const triangulateEarClipping = function(planeCoords) {
|
|
|
138044
138738
|
return [ planeCoords, baseTriangles ];
|
|
138045
138739
|
};
|
|
138046
138740
|
|
|
138047
|
-
const draggableDot3D = function(handleMouseEvents, handleTouchEvents, viewer, worldPos, color, ray2WorldPos, onStart, onMove, onEnd) {
|
|
138048
|
-
const scene = viewer.scene;
|
|
138049
|
-
const canvas = scene.canvas.canvas;
|
|
138050
|
-
|
|
138051
|
-
const marker = new Marker(scene, {});
|
|
138052
|
-
|
|
138053
|
-
const pickWorldPos = canvasPos => {
|
|
138054
|
-
const origin = math.vec3();
|
|
138055
|
-
const direction = math.vec3();
|
|
138056
|
-
math.canvasPosToWorldRay(canvas, scene.camera.viewMatrix, scene.camera.projMatrix, canvasPos, origin, direction);
|
|
138057
|
-
return ray2WorldPos(origin, direction);
|
|
138058
|
-
};
|
|
138059
|
-
|
|
138060
|
-
const onChange = event => {
|
|
138061
|
-
const canvasPos = math.vec2([ event.clientX, event.clientY ]);
|
|
138062
|
-
transformToNode(canvas.ownerDocument.body, canvas, canvasPos);
|
|
138063
|
-
|
|
138064
|
-
const worldPos = pickWorldPos(canvasPos);
|
|
138065
|
-
marker.worldPos = worldPos;
|
|
138066
|
-
updateDotPos();
|
|
138067
|
-
onMove(canvasPos, worldPos);
|
|
138068
|
-
};
|
|
138069
|
-
|
|
138070
|
-
let currentDrag = null;
|
|
138071
|
-
|
|
138072
|
-
const onDragMove = function(event) {
|
|
138073
|
-
const e = currentDrag.matchesEvent(event);
|
|
138074
|
-
if (e)
|
|
138075
|
-
{
|
|
138076
|
-
onChange(e);
|
|
138077
|
-
}
|
|
138078
|
-
};
|
|
138079
|
-
|
|
138080
|
-
const onDragEnd = function(event) {
|
|
138081
|
-
const e = currentDrag.matchesEvent(event);
|
|
138082
|
-
if (e)
|
|
138083
|
-
{
|
|
138084
|
-
dot.setOpacity(idleOpacity);
|
|
138085
|
-
currentDrag.cleanup();
|
|
138086
|
-
onChange(e);
|
|
138087
|
-
onEnd();
|
|
138088
|
-
}
|
|
138089
|
-
};
|
|
138090
|
-
|
|
138091
|
-
const startDrag = function(matchesEvent, cleanupHandlers) {
|
|
138092
|
-
if (currentDrag) {
|
|
138093
|
-
currentDrag.cleanup();
|
|
138094
|
-
}
|
|
138095
|
-
|
|
138096
|
-
dot.setOpacity(1.0);
|
|
138097
|
-
dot.setClickable(false);
|
|
138098
|
-
viewer.cameraControl.active = false;
|
|
138099
|
-
|
|
138100
|
-
currentDrag = {
|
|
138101
|
-
matchesEvent: matchesEvent,
|
|
138102
|
-
cleanup: function() {
|
|
138103
|
-
currentDrag = null;
|
|
138104
|
-
dot.setClickable(true);
|
|
138105
|
-
viewer.cameraControl.active = true;
|
|
138106
|
-
cleanupHandlers();
|
|
138107
|
-
}
|
|
138108
|
-
};
|
|
138109
|
-
|
|
138110
|
-
onStart();
|
|
138111
|
-
};
|
|
138112
|
-
|
|
138113
|
-
const dotCfg = { fillColor: color };
|
|
138114
|
-
|
|
138115
|
-
if (handleMouseEvents)
|
|
138116
|
-
{
|
|
138117
|
-
dotCfg.onMouseOver = () => (! currentDrag) && dot.setOpacity(1.0);
|
|
138118
|
-
dotCfg.onMouseLeave = () => (! currentDrag) && dot.setOpacity(idleOpacity);
|
|
138119
|
-
dotCfg.onMouseDown = event => {
|
|
138120
|
-
if (event.which === 1)
|
|
138121
|
-
{
|
|
138122
|
-
canvas.addEventListener("mousemove", onDragMove);
|
|
138123
|
-
canvas.addEventListener("mouseup", onDragEnd);
|
|
138124
|
-
startDrag(
|
|
138125
|
-
event => (event.which === 1) && event,
|
|
138126
|
-
() => {
|
|
138127
|
-
canvas.removeEventListener("mousemove", onDragMove);
|
|
138128
|
-
canvas.removeEventListener("mouseup", onDragEnd);
|
|
138129
|
-
});
|
|
138130
|
-
}
|
|
138131
|
-
};
|
|
138132
|
-
}
|
|
138133
|
-
|
|
138134
|
-
if (handleTouchEvents)
|
|
138135
|
-
{
|
|
138136
|
-
let touchStartId;
|
|
138137
|
-
dotCfg.onTouchstart = event => {
|
|
138138
|
-
event.preventDefault();
|
|
138139
|
-
if (event.touches.length === 1)
|
|
138140
|
-
{
|
|
138141
|
-
touchStartId = event.touches[0].identifier;
|
|
138142
|
-
startDrag(
|
|
138143
|
-
event => [...event.changedTouches].find(e => e.identifier === touchStartId),
|
|
138144
|
-
() => { touchStartId = null; });
|
|
138145
|
-
}
|
|
138146
|
-
};
|
|
138147
|
-
dotCfg.onTouchmove = event => {
|
|
138148
|
-
event.preventDefault();
|
|
138149
|
-
onDragMove(event);
|
|
138150
|
-
};
|
|
138151
|
-
dotCfg.onTouchend = event => {
|
|
138152
|
-
event.preventDefault();
|
|
138153
|
-
onDragEnd(event);
|
|
138154
|
-
};
|
|
138155
|
-
}
|
|
138156
|
-
|
|
138157
|
-
const dotParent = canvas.ownerDocument.body;
|
|
138158
|
-
const dot = new Dot(dotParent, dotCfg);
|
|
138159
|
-
|
|
138160
|
-
const idleOpacity = 0.5;
|
|
138161
|
-
dot.setOpacity(idleOpacity);
|
|
138162
|
-
|
|
138163
|
-
const updateDotPos = function() {
|
|
138164
|
-
const pos = marker.canvasPos.slice();
|
|
138165
|
-
transformToNode(canvas, dotParent, pos);
|
|
138166
|
-
dot.setPos(pos[0], pos[1]);
|
|
138167
|
-
};
|
|
138168
|
-
|
|
138169
|
-
marker.worldPos = worldPos;
|
|
138170
|
-
updateDotPos();
|
|
138171
|
-
|
|
138172
|
-
const onViewMatrix = scene.camera.on("viewMatrix", updateDotPos);
|
|
138173
|
-
const onProjMatrix = scene.camera.on("projMatrix", updateDotPos);
|
|
138174
|
-
|
|
138175
|
-
return {
|
|
138176
|
-
setActive: value => dot.setClickable(value),
|
|
138177
|
-
getWorldPos: () => marker.worldPos,
|
|
138178
|
-
setWorldPos: pos => { marker.worldPos = pos; updateDotPos(); },
|
|
138179
|
-
destroy: function() {
|
|
138180
|
-
currentDrag && currentDrag.cleanup();
|
|
138181
|
-
scene.camera.off(onViewMatrix);
|
|
138182
|
-
scene.camera.off(onProjMatrix);
|
|
138183
|
-
marker.destroy();
|
|
138184
|
-
dot.destroy();
|
|
138185
|
-
}
|
|
138186
|
-
};
|
|
138187
|
-
};
|
|
138188
|
-
|
|
138189
138741
|
const marker3D = function(scene, color) {
|
|
138190
138742
|
const canvas = scene.canvas.canvas;
|
|
138191
138743
|
|
|
@@ -139656,26 +140208,19 @@ class ZonesPolysurfaceTouchControl extends Component {
|
|
|
139656
140208
|
|
|
139657
140209
|
class ZoneEditControl extends Component {
|
|
139658
140210
|
constructor(zone, cfg, handleMouseEvents, handleTouchEvents) {
|
|
139659
|
-
|
|
139660
|
-
const
|
|
140211
|
+
const viewer = zone.plugin.viewer;
|
|
140212
|
+
const scene = viewer.scene;
|
|
140213
|
+
super(scene);
|
|
139661
140214
|
|
|
139662
140215
|
const altitude = zone._geometry.altitude;
|
|
139663
|
-
const pointerLens = cfg && cfg.pointerLens;
|
|
139664
|
-
const updatePointerLens = (pointerLens
|
|
139665
|
-
? function(canvasPos) {
|
|
139666
|
-
pointerLens.visible = !! canvasPos;
|
|
139667
|
-
if (canvasPos)
|
|
139668
|
-
{
|
|
139669
|
-
pointerLens.canvasPos = canvasPos;
|
|
139670
|
-
}
|
|
139671
|
-
}
|
|
139672
|
-
: () => { });
|
|
139673
140216
|
|
|
139674
140217
|
const dots = zone._geometry.planeCoordinates.map(planeCoord => {
|
|
139675
|
-
|
|
139676
|
-
const
|
|
139677
|
-
|
|
139678
|
-
|
|
140218
|
+
const dotParent = scene.canvas.canvas.ownerDocument.body;
|
|
140219
|
+
const dot = new Dot3D(scene, {}, dotParent, { fillColor: zone._color });
|
|
140220
|
+
dot.worldPos = math.vec3([ planeCoord[0], altitude, planeCoord[1] ]);
|
|
140221
|
+
dot.on("worldPos", function() {
|
|
140222
|
+
planeCoord[0] = dot.worldPos[0];
|
|
140223
|
+
planeCoord[1] = dot.worldPos[2];
|
|
139679
140224
|
try {
|
|
139680
140225
|
zone._rebuildMesh();
|
|
139681
140226
|
} catch (e) {
|
|
@@ -139684,45 +140229,29 @@ class ZoneEditControl extends Component {
|
|
|
139684
140229
|
zone._zoneMesh = null;
|
|
139685
140230
|
}
|
|
139686
140231
|
}
|
|
139687
|
-
};
|
|
139688
|
-
|
|
139689
|
-
const dot = draggableDot3D(
|
|
139690
|
-
handleMouseEvents,
|
|
139691
|
-
handleTouchEvents,
|
|
139692
|
-
zone.plugin.viewer,
|
|
139693
|
-
math.vec3([ planeCoord[0], altitude, planeCoord[1] ]),
|
|
139694
|
-
zone._color,
|
|
139695
|
-
(orig, dir) => planeIntersect(altitude, math.vec3([ 0, 1, 0 ]), orig, dir),
|
|
139696
|
-
() => {
|
|
139697
|
-
initWorldPos = dot.getWorldPos().slice();
|
|
139698
|
-
initPlaneCoord = planeCoord.slice();
|
|
139699
|
-
set_other_dots_active(false, dot);
|
|
139700
|
-
},
|
|
139701
|
-
(canvasPos, worldPos) => {
|
|
139702
|
-
updatePointerLens(canvasPos);
|
|
139703
|
-
setPlaneCoord([ worldPos[0], worldPos[2] ]);
|
|
139704
|
-
},
|
|
139705
|
-
() => {
|
|
139706
|
-
if (zone._zoneMesh)
|
|
139707
|
-
{
|
|
139708
|
-
self.fire("edited");
|
|
139709
|
-
}
|
|
139710
|
-
else
|
|
139711
|
-
{
|
|
139712
|
-
dot.setWorldPos(initWorldPos);
|
|
139713
|
-
setPlaneCoord(initPlaneCoord);
|
|
139714
|
-
}
|
|
139715
|
-
updatePointerLens(null);
|
|
139716
|
-
set_other_dots_active(true, dot);
|
|
139717
|
-
});
|
|
140232
|
+
});
|
|
139718
140233
|
return dot;
|
|
139719
140234
|
});
|
|
139720
|
-
|
|
139721
|
-
|
|
140235
|
+
|
|
140236
|
+
const cleanupDrag = activateDraggableDots({
|
|
140237
|
+
viewer: viewer,
|
|
140238
|
+
handleMouseEvents: handleMouseEvents,
|
|
140239
|
+
handleTouchEvents: handleTouchEvents,
|
|
140240
|
+
pointerLens: cfg && cfg.pointerLens,
|
|
140241
|
+
dots: dots,
|
|
140242
|
+
ray2WorldPos: (orig, dir) => planeIntersect(altitude, math.vec3([ 0, 1, 0 ]), orig, dir),
|
|
140243
|
+
onEnd: (initPos, dot) => {
|
|
140244
|
+
if (zone._zoneMesh)
|
|
140245
|
+
{
|
|
140246
|
+
this.fire("edited");
|
|
140247
|
+
}
|
|
140248
|
+
return !! zone._zoneMesh;
|
|
140249
|
+
}
|
|
140250
|
+
});
|
|
139722
140251
|
|
|
139723
140252
|
const cleanup = function() {
|
|
139724
|
-
|
|
139725
|
-
|
|
140253
|
+
cleanupDrag();
|
|
140254
|
+
dots.forEach(d => d.destroy());
|
|
139726
140255
|
};
|
|
139727
140256
|
|
|
139728
140257
|
const destroyCb = zone.on("destroyed", cleanup);
|
|
@@ -139939,6 +140468,8 @@ class ZoneTranslateTouchControl extends ZoneTranslateControl {
|
|
|
139939
140468
|
|
|
139940
140469
|
exports.AlphaFormat = AlphaFormat;
|
|
139941
140470
|
exports.AmbientLight = AmbientLight;
|
|
140471
|
+
exports.AngleMeasurementEditMouseControl = AngleMeasurementEditMouseControl;
|
|
140472
|
+
exports.AngleMeasurementEditTouchControl = AngleMeasurementEditTouchControl;
|
|
139942
140473
|
exports.AngleMeasurementsControl = AngleMeasurementsControl;
|
|
139943
140474
|
exports.AngleMeasurementsMouseControl = AngleMeasurementsMouseControl;
|
|
139944
140475
|
exports.AngleMeasurementsPlugin = AngleMeasurementsPlugin;
|
|
@@ -139963,6 +140494,8 @@ exports.DefaultLoadingManager = DefaultLoadingManager;
|
|
|
139963
140494
|
exports.DepthFormat = DepthFormat;
|
|
139964
140495
|
exports.DepthStencilFormat = DepthStencilFormat;
|
|
139965
140496
|
exports.DirLight = DirLight;
|
|
140497
|
+
exports.DistanceMeasurementEditMouseControl = DistanceMeasurementEditMouseControl;
|
|
140498
|
+
exports.DistanceMeasurementEditTouchControl = DistanceMeasurementEditTouchControl;
|
|
139966
140499
|
exports.DistanceMeasurementsControl = DistanceMeasurementsControl;
|
|
139967
140500
|
exports.DistanceMeasurementsMouseControl = DistanceMeasurementsMouseControl;
|
|
139968
140501
|
exports.DistanceMeasurementsPlugin = DistanceMeasurementsPlugin;
|
|
@@ -140112,6 +140645,7 @@ exports.buildBoxLinesGeometry = buildBoxLinesGeometry;
|
|
|
140112
140645
|
exports.buildBoxLinesGeometryFromAABB = buildBoxLinesGeometryFromAABB;
|
|
140113
140646
|
exports.buildCylinderGeometry = buildCylinderGeometry;
|
|
140114
140647
|
exports.buildGridGeometry = buildGridGeometry;
|
|
140648
|
+
exports.buildLineGeometry = buildLineGeometry;
|
|
140115
140649
|
exports.buildPlaneGeometry = buildPlaneGeometry;
|
|
140116
140650
|
exports.buildPolylineGeometry = buildPolylineGeometry;
|
|
140117
140651
|
exports.buildPolylineGeometryFromCurve = buildPolylineGeometryFromCurve;
|