@xeokit/xeokit-sdk 2.6.0-beta-6 → 2.6.0-beta-7
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 +12 -17
- package/dist/xeokit-sdk.es.js +12 -17
- package/dist/xeokit-sdk.es5.js +2 -3
- package/dist/xeokit-sdk.min.cjs.js +2 -2
- package/dist/xeokit-sdk.min.es.js +2 -2
- package/dist/xeokit-sdk.min.es5.js +2 -2
- package/package.json +1 -1
- package/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsMouseControl.js +7 -7
- package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsMouseControl.js +5 -10
- package/src/plugins/GLTFLoaderPlugin/GLTFDefaultDataSource.js +1 -1
- package/src/viewer/Plugin.js +1 -1
- package/src/viewer/Viewer.js +1 -1
- package/src/viewer/scene/model/vbo/batching/triangles/renderers/EdgesEmphasisRenderer.js +1 -1
- package/src/viewer/scene/utils/FileLoader.js +1 -1
- package/src/viewer/scene/utils.js +1 -1
package/dist/xeokit-sdk.cjs.js
CHANGED
|
@@ -12170,6 +12170,10 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
|
|
|
12170
12170
|
const mouseWorldPos = math.vec3();
|
|
12171
12171
|
const mouseHoverCanvasPos = math.vec2();
|
|
12172
12172
|
this._currentAngleMeasurement = null;
|
|
12173
|
+
|
|
12174
|
+
const getTop = el => el.offsetTop + (el.offsetParent && getTop(el.offsetParent));
|
|
12175
|
+
const getLeft = el => el.offsetLeft + (el.offsetParent && getLeft(el.offsetParent));
|
|
12176
|
+
|
|
12173
12177
|
this._onMouseHoverSurface = cameraControl.on(
|
|
12174
12178
|
this._snapping
|
|
12175
12179
|
? "hoverSnapOrSurface"
|
|
@@ -12201,13 +12205,9 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
|
|
|
12201
12205
|
mouseHoverCanvasPos.set(canvasPos);
|
|
12202
12206
|
switch (this._mouseState) {
|
|
12203
12207
|
case MOUSE_FINDING_ORIGIN:
|
|
12204
|
-
|
|
12205
|
-
|
|
12206
|
-
|
|
12207
|
-
const canvasLeftEdge = canvasBoundRect.left + scrollLeft;
|
|
12208
|
-
const canvasTopEdge = canvasBoundRect.top + scrollTop;
|
|
12209
|
-
this.markerDiv.style.left = `${canvasLeftEdge + canvasPos[0] - 5}px`;
|
|
12210
|
-
this.markerDiv.style.top = `${canvasTopEdge + canvasPos[1] - 5}px`;
|
|
12208
|
+
this.markerDiv.style.left = `${getLeft(canvas) + canvasPos[0] - 5}px`;
|
|
12209
|
+
this.markerDiv.style.top = `${getTop(canvas) + canvasPos[1] - 5}px`;
|
|
12210
|
+
|
|
12211
12211
|
break;
|
|
12212
12212
|
case MOUSE_FINDING_CORNER:
|
|
12213
12213
|
if (this._currentAngleMeasurement) {
|
|
@@ -85987,6 +85987,9 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
|
|
|
85987
85987
|
|
|
85988
85988
|
this._mouseState = MOUSE_FIRST_CLICK_EXPECTED;
|
|
85989
85989
|
|
|
85990
|
+
const getTop = el => el.offsetTop + (el.offsetParent && getTop(el.offsetParent));
|
|
85991
|
+
const getLeft = el => el.offsetLeft + (el.offsetParent && getLeft(el.offsetParent));
|
|
85992
|
+
|
|
85990
85993
|
this._onCameraControlHoverSnapOrSurface = cameraControl.on(
|
|
85991
85994
|
this._snapping
|
|
85992
85995
|
? "hoverSnapOrSurface"
|
|
@@ -85997,16 +86000,8 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
|
|
|
85997
86000
|
pointerCanvasPos.set(event.canvasPos);
|
|
85998
86001
|
if (this._mouseState === MOUSE_FIRST_CLICK_EXPECTED) {
|
|
85999
86002
|
|
|
86000
|
-
|
|
86001
|
-
|
|
86002
|
-
const canvasBoundRect = canvas.getBoundingClientRect();
|
|
86003
|
-
const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
|
|
86004
|
-
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
86005
|
-
const canvasLeftEdge = canvasBoundRect.left + scrollLeft;
|
|
86006
|
-
const canvasTopEdge = canvasBoundRect.top + scrollTop;
|
|
86007
|
-
|
|
86008
|
-
this._markerDiv.style.left = `${canvasLeftEdge + canvasPos[0] - 5}px`;
|
|
86009
|
-
this._markerDiv.style.top = `${canvasTopEdge + canvasPos[1] - 5}px`;
|
|
86003
|
+
this._markerDiv.style.left = `${getLeft(canvas) + canvasPos[0] - 5}px`;
|
|
86004
|
+
this._markerDiv.style.top = `${getTop(canvas) + canvasPos[1] - 5}px`;
|
|
86010
86005
|
|
|
86011
86006
|
this._markerDiv.style.background = "pink";
|
|
86012
86007
|
if (event.snappedToVertex || event.snappedToEdge) {
|
package/dist/xeokit-sdk.es.js
CHANGED
|
@@ -12166,6 +12166,10 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
|
|
|
12166
12166
|
const mouseWorldPos = math.vec3();
|
|
12167
12167
|
const mouseHoverCanvasPos = math.vec2();
|
|
12168
12168
|
this._currentAngleMeasurement = null;
|
|
12169
|
+
|
|
12170
|
+
const getTop = el => el.offsetTop + (el.offsetParent && getTop(el.offsetParent));
|
|
12171
|
+
const getLeft = el => el.offsetLeft + (el.offsetParent && getLeft(el.offsetParent));
|
|
12172
|
+
|
|
12169
12173
|
this._onMouseHoverSurface = cameraControl.on(
|
|
12170
12174
|
this._snapping
|
|
12171
12175
|
? "hoverSnapOrSurface"
|
|
@@ -12197,13 +12201,9 @@ class AngleMeasurementsMouseControl extends AngleMeasurementsControl {
|
|
|
12197
12201
|
mouseHoverCanvasPos.set(canvasPos);
|
|
12198
12202
|
switch (this._mouseState) {
|
|
12199
12203
|
case MOUSE_FINDING_ORIGIN:
|
|
12200
|
-
|
|
12201
|
-
|
|
12202
|
-
|
|
12203
|
-
const canvasLeftEdge = canvasBoundRect.left + scrollLeft;
|
|
12204
|
-
const canvasTopEdge = canvasBoundRect.top + scrollTop;
|
|
12205
|
-
this.markerDiv.style.left = `${canvasLeftEdge + canvasPos[0] - 5}px`;
|
|
12206
|
-
this.markerDiv.style.top = `${canvasTopEdge + canvasPos[1] - 5}px`;
|
|
12204
|
+
this.markerDiv.style.left = `${getLeft(canvas) + canvasPos[0] - 5}px`;
|
|
12205
|
+
this.markerDiv.style.top = `${getTop(canvas) + canvasPos[1] - 5}px`;
|
|
12206
|
+
|
|
12207
12207
|
break;
|
|
12208
12208
|
case MOUSE_FINDING_CORNER:
|
|
12209
12209
|
if (this._currentAngleMeasurement) {
|
|
@@ -85983,6 +85983,9 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
|
|
|
85983
85983
|
|
|
85984
85984
|
this._mouseState = MOUSE_FIRST_CLICK_EXPECTED;
|
|
85985
85985
|
|
|
85986
|
+
const getTop = el => el.offsetTop + (el.offsetParent && getTop(el.offsetParent));
|
|
85987
|
+
const getLeft = el => el.offsetLeft + (el.offsetParent && getLeft(el.offsetParent));
|
|
85988
|
+
|
|
85986
85989
|
this._onCameraControlHoverSnapOrSurface = cameraControl.on(
|
|
85987
85990
|
this._snapping
|
|
85988
85991
|
? "hoverSnapOrSurface"
|
|
@@ -85993,16 +85996,8 @@ class DistanceMeasurementsMouseControl extends DistanceMeasurementsControl {
|
|
|
85993
85996
|
pointerCanvasPos.set(event.canvasPos);
|
|
85994
85997
|
if (this._mouseState === MOUSE_FIRST_CLICK_EXPECTED) {
|
|
85995
85998
|
|
|
85996
|
-
|
|
85997
|
-
|
|
85998
|
-
const canvasBoundRect = canvas.getBoundingClientRect();
|
|
85999
|
-
const scrollLeft = window.pageXOffset || document.documentElement.scrollLeft;
|
|
86000
|
-
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
86001
|
-
const canvasLeftEdge = canvasBoundRect.left + scrollLeft;
|
|
86002
|
-
const canvasTopEdge = canvasBoundRect.top + scrollTop;
|
|
86003
|
-
|
|
86004
|
-
this._markerDiv.style.left = `${canvasLeftEdge + canvasPos[0] - 5}px`;
|
|
86005
|
-
this._markerDiv.style.top = `${canvasTopEdge + canvasPos[1] - 5}px`;
|
|
85999
|
+
this._markerDiv.style.left = `${getLeft(canvas) + canvasPos[0] - 5}px`;
|
|
86000
|
+
this._markerDiv.style.top = `${getTop(canvas) + canvasPos[1] - 5}px`;
|
|
86006
86001
|
|
|
86007
86002
|
this._markerDiv.style.background = "pink";
|
|
86008
86003
|
if (event.snappedToVertex || event.snappedToEdge) {
|
package/dist/xeokit-sdk.es5.js
CHANGED
|
@@ -2988,7 +2988,7 @@ _this18._initMarkerDiv();_this18._onMouseHoverSurface=null;_this18._onHoverNothi
|
|
|
2988
2988
|
*/function get(){return this._snapping;}/**
|
|
2989
2989
|
* Activates this AngleMeasurementsMouseControl, ready to respond to input.
|
|
2990
2990
|
*/,set:function set(snapping){if(snapping!==this._snapping){this._snapping=snapping;this.deactivate();this.activate();}else{this._snapping=snapping;}}},{key:"activate",value:function activate(){var _this19=this;if(this._active){return;}if(!this.markerDiv){this._initMarkerDiv();// if the marker is destroyed after deactivation, we recreate it
|
|
2991
|
-
}this.angleMeasurementsPlugin;var scene=this.scene;scene.input;var canvas=scene.canvas.canvas;var clickTolerance=20;var cameraControl=this.angleMeasurementsPlugin.viewer.cameraControl;var pointerLens=this.pointerLens;var mouseHovering=false;var hoveredEntity=null;var lastMouseCanvasX=0;var lastMouseCanvasY=0;var mouseWorldPos=math.vec3();var mouseHoverCanvasPos=math.vec2();this._currentAngleMeasurement=null;this._onMouseHoverSurface=cameraControl.on(this._snapping?"hoverSnapOrSurface":"hoverSurface",function(event){if(event.snappedToVertex||event.snappedToEdge){if(pointerLens){pointerLens.visible=true;pointerLens.canvasPos=event.canvasPos;pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;pointerLens.snapped=true;}_this19.markerDiv.style.background="greenyellow";_this19.markerDiv.style.border="2px solid green";}else{if(pointerLens){pointerLens.visible=true;pointerLens.canvasPos=event.canvasPos;pointerLens.snappedCanvasPos=event.canvasPos;pointerLens.snapped=false;}_this19.markerDiv.style.background="pink";_this19.markerDiv.style.border="2px solid red";}var canvasPos=event.snappedCanvasPos||event.canvasPos;mouseHovering=true;hoveredEntity=event.entity;mouseWorldPos.set(event.worldPos);mouseHoverCanvasPos.set(canvasPos);switch(_this19._mouseState){case MOUSE_FINDING_ORIGIN:
|
|
2991
|
+
}this.angleMeasurementsPlugin;var scene=this.scene;scene.input;var canvas=scene.canvas.canvas;var clickTolerance=20;var cameraControl=this.angleMeasurementsPlugin.viewer.cameraControl;var pointerLens=this.pointerLens;var mouseHovering=false;var hoveredEntity=null;var lastMouseCanvasX=0;var lastMouseCanvasY=0;var mouseWorldPos=math.vec3();var mouseHoverCanvasPos=math.vec2();this._currentAngleMeasurement=null;var getTop=function getTop(el){return el.offsetTop+(el.offsetParent&&getTop(el.offsetParent));};var getLeft=function getLeft(el){return el.offsetLeft+(el.offsetParent&&getLeft(el.offsetParent));};this._onMouseHoverSurface=cameraControl.on(this._snapping?"hoverSnapOrSurface":"hoverSurface",function(event){if(event.snappedToVertex||event.snappedToEdge){if(pointerLens){pointerLens.visible=true;pointerLens.canvasPos=event.canvasPos;pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;pointerLens.snapped=true;}_this19.markerDiv.style.background="greenyellow";_this19.markerDiv.style.border="2px solid green";}else{if(pointerLens){pointerLens.visible=true;pointerLens.canvasPos=event.canvasPos;pointerLens.snappedCanvasPos=event.canvasPos;pointerLens.snapped=false;}_this19.markerDiv.style.background="pink";_this19.markerDiv.style.border="2px solid red";}var canvasPos=event.snappedCanvasPos||event.canvasPos;mouseHovering=true;hoveredEntity=event.entity;mouseWorldPos.set(event.worldPos);mouseHoverCanvasPos.set(canvasPos);switch(_this19._mouseState){case MOUSE_FINDING_ORIGIN:_this19.markerDiv.style.left="".concat(getLeft(canvas)+canvasPos[0]-5,"px");_this19.markerDiv.style.top="".concat(getTop(canvas)+canvasPos[1]-5,"px");break;case MOUSE_FINDING_CORNER:if(_this19._currentAngleMeasurement){_this19._currentAngleMeasurement.originWireVisible=true;_this19._currentAngleMeasurement.targetWireVisible=false;_this19._currentAngleMeasurement.cornerVisible=true;_this19._currentAngleMeasurement.angleVisible=false;_this19._currentAngleMeasurement.corner.worldPos=event.worldPos;_this19._currentAngleMeasurement.corner.entity=event.entity;}_this19.markerDiv.style.left="-10000px";_this19.markerDiv.style.top="-10000px";canvas.style.cursor="pointer";break;case MOUSE_FINDING_TARGET:if(_this19._currentAngleMeasurement){_this19._currentAngleMeasurement.targetWireVisible=true;_this19._currentAngleMeasurement.targetVisible=true;_this19._currentAngleMeasurement.angleVisible=true;_this19._currentAngleMeasurement.target.worldPos=event.worldPos;_this19._currentAngleMeasurement.target.entity=event.entity;}_this19.markerDiv.style.left="-10000px";_this19.markerDiv.style.top="-10000px";canvas.style.cursor="pointer";break;}});canvas.addEventListener('mousedown',this._onMouseDown=function(e){if(e.which!==1){return;}lastMouseCanvasX=e.clientX;lastMouseCanvasY=e.clientY;});canvas.addEventListener("mouseup",this._onMouseUp=function(e){if(e.which!==1){return;}if(e.clientX>lastMouseCanvasX+clickTolerance||e.clientX<lastMouseCanvasX-clickTolerance||e.clientY>lastMouseCanvasY+clickTolerance||e.clientY<lastMouseCanvasY-clickTolerance){return;}switch(_this19._mouseState){case MOUSE_FINDING_ORIGIN:if(mouseHovering){_this19._currentAngleMeasurement=_this19.angleMeasurementsPlugin.createMeasurement({id:math.createUUID(),origin:{worldPos:mouseWorldPos},corner:{worldPos:mouseWorldPos},target:{worldPos:mouseWorldPos},approximate:true});_this19._currentAngleMeasurement.clickable=false;_this19._currentAngleMeasurement.originVisible=true;_this19._currentAngleMeasurement.originWireVisible=true;_this19._currentAngleMeasurement.cornerVisible=false;_this19._currentAngleMeasurement.targetWireVisible=false;_this19._currentAngleMeasurement.targetVisible=false;_this19._currentAngleMeasurement.angleVisible=false;_this19._currentAngleMeasurement.origin.entity=hoveredEntity;_this19._mouseState=MOUSE_FINDING_CORNER;_this19.angleMeasurementsPlugin.fire("measurementStart",_this19._currentAngleMeasurement);}break;case MOUSE_FINDING_CORNER:if(mouseHovering){_this19._currentAngleMeasurement.targetWireVisible=false;_this19._currentAngleMeasurement.targetVisible=true;_this19._currentAngleMeasurement.angleVisible=true;_this19._currentAngleMeasurement.corner.entity=hoveredEntity;_this19._mouseState=MOUSE_FINDING_TARGET;}else{if(_this19._currentAngleMeasurement){_this19._currentAngleMeasurement.destroy();_this19._currentAngleMeasurement=null;hoveredEntity=null;_this19._mouseState=MOUSE_FINDING_ORIGIN;_this19.angleMeasurementsPlugin.fire("measurementCancel",_this19._currentAngleMeasurement);}}break;case MOUSE_FINDING_TARGET:if(mouseHovering){_this19._currentAngleMeasurement.targetVisible=true;_this19._currentAngleMeasurement.angleVisible=true;_this19._currentAngleMeasurement.target.entity=hoveredEntity;_this19._currentAngleMeasurement.clickable=true;hoveredEntity=null;_this19.angleMeasurementsPlugin.fire("measurementEnd",_this19._currentAngleMeasurement);_this19._currentAngleMeasurement=null;_this19._mouseState=MOUSE_FINDING_ORIGIN;}else{if(_this19._currentAngleMeasurement){_this19._currentAngleMeasurement.destroy();_this19._currentAngleMeasurement=null;hoveredEntity=null;_this19._mouseState=MOUSE_FINDING_ORIGIN;_this19.angleMeasurementsPlugin.fire("measurementCancel",_this19._currentAngleMeasurement);}}break;}});this._onMouseHoverOff=cameraControl.on(this._snapping?"hoverSnapOrSurfaceOff":"hoverOff",function(event){mouseHovering=false;if(pointerLens){pointerLens.visible=true;pointerLens.pointerPos=event.canvasPos;pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;pointerLens.snapped=false;}_this19.markerDiv.style.left="-100px";_this19.markerDiv.style.top="-100px";if(_this19._currentAngleMeasurement){switch(_this19._mouseState){case MOUSE_FINDING_ORIGIN:_this19._currentAngleMeasurement.originVisible=false;break;case MOUSE_FINDING_CORNER:_this19._currentAngleMeasurement.cornerVisible=false;_this19._currentAngleMeasurement.originWireVisible=false;_this19._currentAngleMeasurement.targetVisible=false;_this19._currentAngleMeasurement.targetWireVisible=false;_this19._currentAngleMeasurement.angleVisible=false;break;case MOUSE_FINDING_TARGET:_this19._currentAngleMeasurement.targetVisible=false;_this19._currentAngleMeasurement.targetWireVisible=false;_this19._currentAngleMeasurement.angleVisible=false;break;}canvas.style.cursor="default";}});this._active=true;}/**
|
|
2992
2992
|
* Deactivates this AngleMeasurementsMouseControl, making it unresponsive to input.
|
|
2993
2993
|
*
|
|
2994
2994
|
* Destroys any {@link AngleMeasurement} under construction by this AngleMeasurementsMouseControl.
|
|
@@ -19250,8 +19250,7 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._targetDot.s
|
|
|
19250
19250
|
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsMouseControl.
|
|
19251
19251
|
*/function get(){return this._snapping;}/**
|
|
19252
19252
|
* Activates this DistanceMeasurementsMouseControl, ready to respond to input.
|
|
19253
|
-
*/,set:function set(snapping){if(snapping!==this._snapping){this._snapping=snapping;this.deactivate();this.activate();}else{this._snapping=snapping;}}},{key:"activate",value:function activate(){var _this82=this;if(this._active){return;}if(!this._markerDiv){this._initMarkerDiv();}this.fire("activated",true);var distanceMeasurementsPlugin=this.distanceMeasurementsPlugin;var scene=this.scene;var cameraControl=distanceMeasurementsPlugin.viewer.cameraControl;var canvas=scene.canvas.canvas;scene.input;var mouseHovering=false;var pointerWorldPos=math.vec3();var pointerCanvasPos=math.vec2();var pointerDownCanvasX;var pointerDownCanvasY;var clickTolerance=20;var hoveredEntity=null;this._mouseState=MOUSE_FIRST_CLICK_EXPECTED;this._onCameraControlHoverSnapOrSurface=cameraControl.on(this._snapping?"hoverSnapOrSurface":"hoverSurface",function(event){var canvasPos=event.snappedCanvasPos||event.canvasPos;mouseHovering=true;pointerWorldPos.set(event.worldPos);pointerCanvasPos.set(event.canvasPos);if(_this82._mouseState===MOUSE_FIRST_CLICK_EXPECTED){
|
|
19254
|
-
var canvasBoundRect=canvas.getBoundingClientRect();var scrollLeft=window.pageXOffset||document.documentElement.scrollLeft;var scrollTop=window.pageYOffset||document.documentElement.scrollTop;var canvasLeftEdge=canvasBoundRect.left+scrollLeft;var canvasTopEdge=canvasBoundRect.top+scrollTop;_this82._markerDiv.style.left="".concat(canvasLeftEdge+canvasPos[0]-5,"px");_this82._markerDiv.style.top="".concat(canvasTopEdge+canvasPos[1]-5,"px");_this82._markerDiv.style.background="pink";if(event.snappedToVertex||event.snappedToEdge){if(_this82.pointerLens){_this82.pointerLens.visible=true;_this82.pointerLens.canvasPos=event.canvasPos;_this82.pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;_this82.pointerLens.snapped=true;}_this82._markerDiv.style.background="greenyellow";_this82._markerDiv.style.border="2px solid green";}else{if(_this82.pointerLens){_this82.pointerLens.visible=true;_this82.pointerLens.canvasPos=event.canvasPos;_this82.pointerLens.snappedCanvasPos=event.canvasPos;_this82.pointerLens.snapped=false;}_this82._markerDiv.style.background="pink";_this82._markerDiv.style.border="2px solid red";}hoveredEntity=event.entity;}else{_this82._markerDiv.style.left="-10000px";_this82._markerDiv.style.top="-10000px";}canvas.style.cursor="pointer";if(_this82._currentDistanceMeasurement){_this82._currentDistanceMeasurement.wireVisible=_this82._currentDistanceMeasurementInitState.wireVisible;_this82._currentDistanceMeasurement.axisVisible=_this82._currentDistanceMeasurementInitState.axisVisible&&_this82.distanceMeasurementsPlugin.defaultAxisVisible;_this82._currentDistanceMeasurement.xAxisVisible=_this82._currentDistanceMeasurementInitState.xAxisVisible&&_this82.distanceMeasurementsPlugin.defaultXAxisVisible;_this82._currentDistanceMeasurement.yAxisVisible=_this82._currentDistanceMeasurementInitState.yAxisVisible&&_this82.distanceMeasurementsPlugin.defaultYAxisVisible;_this82._currentDistanceMeasurement.zAxisVisible=_this82._currentDistanceMeasurementInitState.zAxisVisible&&_this82.distanceMeasurementsPlugin.defaultZAxisVisible;_this82._currentDistanceMeasurement.targetVisible=_this82._currentDistanceMeasurementInitState.targetVisible;_this82._currentDistanceMeasurement.target.worldPos=pointerWorldPos.slice();_this82._markerDiv.style.left="-10000px";_this82._markerDiv.style.top="-10000px";}});canvas.addEventListener('mousedown',this._onMouseDown=function(e){if(e.which!==1){return;}pointerDownCanvasX=e.clientX;pointerDownCanvasY=e.clientY;});canvas.addEventListener("mouseup",this._onMouseUp=function(e){if(e.which!==1){return;}if(e.clientX>pointerDownCanvasX+clickTolerance||e.clientX<pointerDownCanvasX-clickTolerance||e.clientY>pointerDownCanvasY+clickTolerance||e.clientY<pointerDownCanvasY-clickTolerance){return;}if(_this82._currentDistanceMeasurement){if(mouseHovering){_this82._currentDistanceMeasurement.target.entity=hoveredEntity;hoveredEntity=null;_this82._currentDistanceMeasurement.clickable=true;_this82.distanceMeasurementsPlugin.fire("measurementEnd",_this82._currentDistanceMeasurement);_this82._currentDistanceMeasurement=null;}else{_this82._currentDistanceMeasurement.destroy();_this82.distanceMeasurementsPlugin.fire("measurementCancel",_this82._currentDistanceMeasurement);_this82._currentDistanceMeasurement=null;hoveredEntity=null;}}else{if(mouseHovering){_this82._currentDistanceMeasurement=distanceMeasurementsPlugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pointerWorldPos.slice()},target:{worldPos:pointerWorldPos.slice()},approximate:true});_this82._currentDistanceMeasurementInitState.axisVisible=_this82._currentDistanceMeasurement.axisVisible&&_this82.distanceMeasurementsPlugin.defaultAxisVisible;_this82._currentDistanceMeasurementInitState.xAxisVisible=_this82._currentDistanceMeasurement.xAxisVisible&&_this82.distanceMeasurementsPlugin.defaultXAxisVisible;_this82._currentDistanceMeasurementInitState.yAxisVisible=_this82._currentDistanceMeasurement.yAxisVisible&&_this82.distanceMeasurementsPlugin.defaultYAxisVisible;_this82._currentDistanceMeasurementInitState.zAxisVisible=_this82._currentDistanceMeasurement.zAxisVisible&&_this82.distanceMeasurementsPlugin.defaultZAxisVisible;_this82._currentDistanceMeasurementInitState.wireVisible=_this82._currentDistanceMeasurement.wireVisible;_this82._currentDistanceMeasurementInitState.targetVisible=_this82._currentDistanceMeasurement.targetVisible;_this82._currentDistanceMeasurement.clickable=false;_this82._currentDistanceMeasurement.origin.entity=hoveredEntity;hoveredEntity=null;_this82.fire("measurementStart",_this82._currentDistanceMeasurement);}}});this._onCameraControlHoverSnapOrSurfaceOff=cameraControl.on(this._snapping?"hoverSnapOrSurfaceOff":"hoverOff",function(event){if(_this82.pointerLens){_this82.pointerLens.visible=true;_this82.pointerLens.canvasPos=event.canvasPos;_this82.pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;}mouseHovering=false;_this82._markerDiv.style.left="-100px";_this82._markerDiv.style.top="-100px";if(_this82._currentDistanceMeasurement){_this82._currentDistanceMeasurement.wireVisible=false;_this82._currentDistanceMeasurement.targetVisible=false;_this82._currentDistanceMeasurement.axisVisible=false;}canvas.style.cursor="default";});this._active=true;}/**
|
|
19253
|
+
*/,set:function set(snapping){if(snapping!==this._snapping){this._snapping=snapping;this.deactivate();this.activate();}else{this._snapping=snapping;}}},{key:"activate",value:function activate(){var _this82=this;if(this._active){return;}if(!this._markerDiv){this._initMarkerDiv();}this.fire("activated",true);var distanceMeasurementsPlugin=this.distanceMeasurementsPlugin;var scene=this.scene;var cameraControl=distanceMeasurementsPlugin.viewer.cameraControl;var canvas=scene.canvas.canvas;scene.input;var mouseHovering=false;var pointerWorldPos=math.vec3();var pointerCanvasPos=math.vec2();var pointerDownCanvasX;var pointerDownCanvasY;var clickTolerance=20;var hoveredEntity=null;this._mouseState=MOUSE_FIRST_CLICK_EXPECTED;var getTop=function getTop(el){return el.offsetTop+(el.offsetParent&&getTop(el.offsetParent));};var getLeft=function getLeft(el){return el.offsetLeft+(el.offsetParent&&getLeft(el.offsetParent));};this._onCameraControlHoverSnapOrSurface=cameraControl.on(this._snapping?"hoverSnapOrSurface":"hoverSurface",function(event){var canvasPos=event.snappedCanvasPos||event.canvasPos;mouseHovering=true;pointerWorldPos.set(event.worldPos);pointerCanvasPos.set(event.canvasPos);if(_this82._mouseState===MOUSE_FIRST_CLICK_EXPECTED){_this82._markerDiv.style.left="".concat(getLeft(canvas)+canvasPos[0]-5,"px");_this82._markerDiv.style.top="".concat(getTop(canvas)+canvasPos[1]-5,"px");_this82._markerDiv.style.background="pink";if(event.snappedToVertex||event.snappedToEdge){if(_this82.pointerLens){_this82.pointerLens.visible=true;_this82.pointerLens.canvasPos=event.canvasPos;_this82.pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;_this82.pointerLens.snapped=true;}_this82._markerDiv.style.background="greenyellow";_this82._markerDiv.style.border="2px solid green";}else{if(_this82.pointerLens){_this82.pointerLens.visible=true;_this82.pointerLens.canvasPos=event.canvasPos;_this82.pointerLens.snappedCanvasPos=event.canvasPos;_this82.pointerLens.snapped=false;}_this82._markerDiv.style.background="pink";_this82._markerDiv.style.border="2px solid red";}hoveredEntity=event.entity;}else{_this82._markerDiv.style.left="-10000px";_this82._markerDiv.style.top="-10000px";}canvas.style.cursor="pointer";if(_this82._currentDistanceMeasurement){_this82._currentDistanceMeasurement.wireVisible=_this82._currentDistanceMeasurementInitState.wireVisible;_this82._currentDistanceMeasurement.axisVisible=_this82._currentDistanceMeasurementInitState.axisVisible&&_this82.distanceMeasurementsPlugin.defaultAxisVisible;_this82._currentDistanceMeasurement.xAxisVisible=_this82._currentDistanceMeasurementInitState.xAxisVisible&&_this82.distanceMeasurementsPlugin.defaultXAxisVisible;_this82._currentDistanceMeasurement.yAxisVisible=_this82._currentDistanceMeasurementInitState.yAxisVisible&&_this82.distanceMeasurementsPlugin.defaultYAxisVisible;_this82._currentDistanceMeasurement.zAxisVisible=_this82._currentDistanceMeasurementInitState.zAxisVisible&&_this82.distanceMeasurementsPlugin.defaultZAxisVisible;_this82._currentDistanceMeasurement.targetVisible=_this82._currentDistanceMeasurementInitState.targetVisible;_this82._currentDistanceMeasurement.target.worldPos=pointerWorldPos.slice();_this82._markerDiv.style.left="-10000px";_this82._markerDiv.style.top="-10000px";}});canvas.addEventListener('mousedown',this._onMouseDown=function(e){if(e.which!==1){return;}pointerDownCanvasX=e.clientX;pointerDownCanvasY=e.clientY;});canvas.addEventListener("mouseup",this._onMouseUp=function(e){if(e.which!==1){return;}if(e.clientX>pointerDownCanvasX+clickTolerance||e.clientX<pointerDownCanvasX-clickTolerance||e.clientY>pointerDownCanvasY+clickTolerance||e.clientY<pointerDownCanvasY-clickTolerance){return;}if(_this82._currentDistanceMeasurement){if(mouseHovering){_this82._currentDistanceMeasurement.target.entity=hoveredEntity;hoveredEntity=null;_this82._currentDistanceMeasurement.clickable=true;_this82.distanceMeasurementsPlugin.fire("measurementEnd",_this82._currentDistanceMeasurement);_this82._currentDistanceMeasurement=null;}else{_this82._currentDistanceMeasurement.destroy();_this82.distanceMeasurementsPlugin.fire("measurementCancel",_this82._currentDistanceMeasurement);_this82._currentDistanceMeasurement=null;hoveredEntity=null;}}else{if(mouseHovering){_this82._currentDistanceMeasurement=distanceMeasurementsPlugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pointerWorldPos.slice()},target:{worldPos:pointerWorldPos.slice()},approximate:true});_this82._currentDistanceMeasurementInitState.axisVisible=_this82._currentDistanceMeasurement.axisVisible&&_this82.distanceMeasurementsPlugin.defaultAxisVisible;_this82._currentDistanceMeasurementInitState.xAxisVisible=_this82._currentDistanceMeasurement.xAxisVisible&&_this82.distanceMeasurementsPlugin.defaultXAxisVisible;_this82._currentDistanceMeasurementInitState.yAxisVisible=_this82._currentDistanceMeasurement.yAxisVisible&&_this82.distanceMeasurementsPlugin.defaultYAxisVisible;_this82._currentDistanceMeasurementInitState.zAxisVisible=_this82._currentDistanceMeasurement.zAxisVisible&&_this82.distanceMeasurementsPlugin.defaultZAxisVisible;_this82._currentDistanceMeasurementInitState.wireVisible=_this82._currentDistanceMeasurement.wireVisible;_this82._currentDistanceMeasurementInitState.targetVisible=_this82._currentDistanceMeasurement.targetVisible;_this82._currentDistanceMeasurement.clickable=false;_this82._currentDistanceMeasurement.origin.entity=hoveredEntity;hoveredEntity=null;_this82.fire("measurementStart",_this82._currentDistanceMeasurement);}}});this._onCameraControlHoverSnapOrSurfaceOff=cameraControl.on(this._snapping?"hoverSnapOrSurfaceOff":"hoverOff",function(event){if(_this82.pointerLens){_this82.pointerLens.visible=true;_this82.pointerLens.canvasPos=event.canvasPos;_this82.pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;}mouseHovering=false;_this82._markerDiv.style.left="-100px";_this82._markerDiv.style.top="-100px";if(_this82._currentDistanceMeasurement){_this82._currentDistanceMeasurement.wireVisible=false;_this82._currentDistanceMeasurement.targetVisible=false;_this82._currentDistanceMeasurement.axisVisible=false;}canvas.style.cursor="default";});this._active=true;}/**
|
|
19255
19254
|
* Deactivates this DistanceMeasurementsMouseControl, making it unresponsive to input.
|
|
19256
19255
|
*
|
|
19257
19256
|
* Destroys any {@link DistanceMeasurement} under construction by this DistanceMeasurementsMouseControl.
|