@xeokit/xeokit-sdk 2.6.0-beta-13 → 2.6.0-beta-15
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/web-ifc.wasm +0 -0
- package/dist/xeokit-sdk.cjs.js +152 -84
- package/dist/xeokit-sdk.es.js +152 -84
- package/dist/xeokit-sdk.es5.js +38 -38
- package/dist/xeokit-sdk.min.cjs.js +4 -4
- package/dist/xeokit-sdk.min.es.js +3 -3
- package/dist/xeokit-sdk.min.es5.js +3 -3
- package/package.json +1 -1
- package/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsMouseControl.js +6 -3
- package/src/plugins/AngleMeasurementsPlugin/AngleMeasurementsTouchControl.js +10 -3
- package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsMouseControl.js +5 -3
- package/src/plugins/DistanceMeasurementsPlugin/DistanceMeasurementsTouchControl.js +22 -8
- package/src/plugins/GLTFLoaderPlugin/GLTFLoaderPlugin.js +1 -1
- package/src/plugins/GLTFLoaderPlugin/GLTFSceneModelLoader.js +22 -16
- package/src/plugins/SectionPlanesPlugin/Control.js +70 -35
- package/src/viewer/scene/CameraControl/lib/controllers/PickController.js +1 -0
- package/src/viewer/scene/CameraControl/lib/handlers/MousePanRotateDollyHandler.js +12 -12
- package/src/viewer/scene/model/SceneModel.js +1 -1
package/dist/xeokit-sdk.es5.js
CHANGED
|
@@ -3015,7 +3015,7 @@ _this19._initMarkerDiv();_this19._onMouseHoverSurface=null;_this19._onHoverNothi
|
|
|
3015
3015
|
*/function get(){return this._snapping;}/**
|
|
3016
3016
|
* Activates this AngleMeasurementsMouseControl, ready to respond to input.
|
|
3017
3017
|
*/,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 _this20=this;if(this._active){return;}if(!this.markerDiv){this._initMarkerDiv();// if the marker is destroyed after deactivation, we recreate it
|
|
3018
|
-
}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));};var pagePos=math.vec2();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;}_this20.markerDiv.style.background="greenyellow";_this20.markerDiv.style.border="2px solid green";}else{if(pointerLens){pointerLens.visible=true;pointerLens.canvasPos=event.canvasPos;pointerLens.snappedCanvasPos=event.canvasPos;pointerLens.snapped=false;}_this20.markerDiv.style.background="pink";_this20.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(_this20._mouseState){case MOUSE_FINDING_ORIGIN:if(_this20._canvasToPagePos){_this20._canvasToPagePos(canvas,canvasPos,pagePos);_this20.markerDiv.style.left="".concat(pagePos[0]-5,"px");_this20.markerDiv.style.top="".concat(pagePos[1]-5,"px");}else{_this20.markerDiv.style.left="".concat(getLeft(canvas)+canvasPos[0]-5,"px");_this20.markerDiv.style.top="".concat(getTop(canvas)+canvasPos[1]-5,"px");}break;case MOUSE_FINDING_CORNER:if(_this20._currentAngleMeasurement){_this20._currentAngleMeasurement.originWireVisible=true;_this20._currentAngleMeasurement.targetWireVisible=false;_this20._currentAngleMeasurement.cornerVisible=true;_this20._currentAngleMeasurement.angleVisible=false;_this20._currentAngleMeasurement.corner.worldPos=event.worldPos;_this20._currentAngleMeasurement.corner.entity=event.entity;}_this20.markerDiv.style.left="-10000px";_this20.markerDiv.style.top="-10000px";canvas.style.cursor="pointer";break;case MOUSE_FINDING_TARGET:if(_this20._currentAngleMeasurement){_this20._currentAngleMeasurement.targetWireVisible=true;_this20._currentAngleMeasurement.targetVisible=true;_this20._currentAngleMeasurement.angleVisible=true;_this20._currentAngleMeasurement.target.worldPos=event.worldPos;_this20._currentAngleMeasurement.target.entity=event.entity;}_this20.markerDiv.style.left="-10000px";_this20.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(_this20._mouseState){case MOUSE_FINDING_ORIGIN:if(mouseHovering){_this20._currentAngleMeasurement=_this20.angleMeasurementsPlugin.createMeasurement({id:math.createUUID(),origin:{worldPos:mouseWorldPos},corner:{worldPos:mouseWorldPos},target:{worldPos:mouseWorldPos},approximate:true});_this20._currentAngleMeasurement.clickable=false;_this20._currentAngleMeasurement.originVisible=true;_this20._currentAngleMeasurement.originWireVisible=true;_this20._currentAngleMeasurement.cornerVisible=false;_this20._currentAngleMeasurement.targetWireVisible=false;_this20._currentAngleMeasurement.targetVisible=false;_this20._currentAngleMeasurement.angleVisible=false;_this20._currentAngleMeasurement.origin.entity=hoveredEntity;_this20._mouseState=MOUSE_FINDING_CORNER;_this20.angleMeasurementsPlugin.fire("measurementStart",_this20._currentAngleMeasurement);}break;case MOUSE_FINDING_CORNER:if(mouseHovering){_this20._currentAngleMeasurement.targetWireVisible=false;_this20._currentAngleMeasurement.targetVisible=true;_this20._currentAngleMeasurement.angleVisible=true;_this20._currentAngleMeasurement.corner.entity=hoveredEntity;_this20._mouseState=MOUSE_FINDING_TARGET;}else{if(_this20._currentAngleMeasurement){_this20._currentAngleMeasurement.destroy();_this20._currentAngleMeasurement=null;hoveredEntity=null;_this20._mouseState=MOUSE_FINDING_ORIGIN;_this20.angleMeasurementsPlugin.fire("measurementCancel",_this20._currentAngleMeasurement);}}break;case MOUSE_FINDING_TARGET:if(mouseHovering){_this20._currentAngleMeasurement.targetVisible=true;_this20._currentAngleMeasurement.angleVisible=true;_this20._currentAngleMeasurement.target.entity=hoveredEntity;_this20._currentAngleMeasurement.clickable=true;hoveredEntity=null;_this20.angleMeasurementsPlugin.fire("measurementEnd",_this20._currentAngleMeasurement);_this20._currentAngleMeasurement=null;_this20._mouseState=MOUSE_FINDING_ORIGIN;}else{if(_this20._currentAngleMeasurement){_this20._currentAngleMeasurement.destroy();_this20._currentAngleMeasurement=null;hoveredEntity=null;_this20._mouseState=MOUSE_FINDING_ORIGIN;_this20.angleMeasurementsPlugin.fire("measurementCancel",_this20._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;}_this20.markerDiv.style.left="-100px";_this20.markerDiv.style.top="-100px";if(_this20._currentAngleMeasurement){switch(_this20._mouseState){case MOUSE_FINDING_ORIGIN:_this20._currentAngleMeasurement.originVisible=false;break;case MOUSE_FINDING_CORNER:_this20._currentAngleMeasurement.cornerVisible=false;_this20._currentAngleMeasurement.originWireVisible=false;_this20._currentAngleMeasurement.targetVisible=false;_this20._currentAngleMeasurement.targetWireVisible=false;_this20._currentAngleMeasurement.angleVisible=false;break;case MOUSE_FINDING_TARGET:_this20._currentAngleMeasurement.targetVisible=false;_this20._currentAngleMeasurement.targetWireVisible=false;_this20._currentAngleMeasurement.angleVisible=false;break;}canvas.style.cursor="default";}});this._active=true;}/**
|
|
3018
|
+
}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));};var pagePos=math.vec2();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;}_this20.markerDiv.style.background="greenyellow";_this20.markerDiv.style.border="2px solid green";}else{if(pointerLens){pointerLens.visible=true;pointerLens.canvasPos=event.canvasPos;pointerLens.snappedCanvasPos=event.canvasPos;pointerLens.snapped=false;}_this20.markerDiv.style.background="pink";_this20.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(_this20._mouseState){case MOUSE_FINDING_ORIGIN:if(_this20._canvasToPagePos){_this20._canvasToPagePos(canvas,canvasPos,pagePos);_this20.markerDiv.style.left="".concat(pagePos[0]-5,"px");_this20.markerDiv.style.top="".concat(pagePos[1]-5,"px");}else{_this20.markerDiv.style.left="".concat(getLeft(canvas)+canvasPos[0]-5,"px");_this20.markerDiv.style.top="".concat(getTop(canvas)+canvasPos[1]-5,"px");}break;case MOUSE_FINDING_CORNER:if(_this20._currentAngleMeasurement){_this20._currentAngleMeasurement.originWireVisible=true;_this20._currentAngleMeasurement.targetWireVisible=false;_this20._currentAngleMeasurement.cornerVisible=true;_this20._currentAngleMeasurement.angleVisible=false;_this20._currentAngleMeasurement.corner.worldPos=event.worldPos;_this20._currentAngleMeasurement.corner.entity=event.entity;}_this20.markerDiv.style.left="-10000px";_this20.markerDiv.style.top="-10000px";canvas.style.cursor="pointer";break;case MOUSE_FINDING_TARGET:if(_this20._currentAngleMeasurement){_this20._currentAngleMeasurement.targetWireVisible=true;_this20._currentAngleMeasurement.targetVisible=true;_this20._currentAngleMeasurement.angleVisible=true;_this20._currentAngleMeasurement.target.worldPos=event.worldPos;_this20._currentAngleMeasurement.target.entity=event.entity;}_this20.markerDiv.style.left="-10000px";_this20.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(_this20._mouseState){case MOUSE_FINDING_ORIGIN:if(mouseHovering){_this20._currentAngleMeasurement=_this20.angleMeasurementsPlugin.createMeasurement({id:math.createUUID(),origin:{worldPos:mouseWorldPos,entity:hoveredEntity},corner:{worldPos:mouseWorldPos,entity:hoveredEntity},target:{worldPos:mouseWorldPos,entity:hoveredEntity},approximate:true});_this20._currentAngleMeasurement.clickable=false;_this20._currentAngleMeasurement.originVisible=true;_this20._currentAngleMeasurement.originWireVisible=true;_this20._currentAngleMeasurement.cornerVisible=false;_this20._currentAngleMeasurement.targetWireVisible=false;_this20._currentAngleMeasurement.targetVisible=false;_this20._currentAngleMeasurement.angleVisible=false;_this20._currentAngleMeasurement.origin.entity=hoveredEntity;_this20._mouseState=MOUSE_FINDING_CORNER;_this20.angleMeasurementsPlugin.fire("measurementStart",_this20._currentAngleMeasurement);}break;case MOUSE_FINDING_CORNER:if(mouseHovering){_this20._currentAngleMeasurement.targetWireVisible=false;_this20._currentAngleMeasurement.targetVisible=true;_this20._currentAngleMeasurement.angleVisible=true;_this20._currentAngleMeasurement.corner.entity=hoveredEntity;_this20._mouseState=MOUSE_FINDING_TARGET;}else{if(_this20._currentAngleMeasurement){_this20._currentAngleMeasurement.destroy();_this20._currentAngleMeasurement=null;hoveredEntity=null;_this20._mouseState=MOUSE_FINDING_ORIGIN;_this20.angleMeasurementsPlugin.fire("measurementCancel",_this20._currentAngleMeasurement);}}break;case MOUSE_FINDING_TARGET:if(mouseHovering){_this20._currentAngleMeasurement.targetVisible=true;_this20._currentAngleMeasurement.angleVisible=true;_this20._currentAngleMeasurement.target.entity=hoveredEntity;_this20._currentAngleMeasurement.clickable=true;hoveredEntity=null;_this20.angleMeasurementsPlugin.fire("measurementEnd",_this20._currentAngleMeasurement);_this20._currentAngleMeasurement=null;_this20._mouseState=MOUSE_FINDING_ORIGIN;}else{if(_this20._currentAngleMeasurement){_this20._currentAngleMeasurement.destroy();_this20._currentAngleMeasurement=null;hoveredEntity=null;_this20._mouseState=MOUSE_FINDING_ORIGIN;_this20.angleMeasurementsPlugin.fire("measurementCancel",_this20._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;}_this20.markerDiv.style.left="-100px";_this20.markerDiv.style.top="-100px";if(_this20._currentAngleMeasurement){switch(_this20._mouseState){case MOUSE_FINDING_ORIGIN:_this20._currentAngleMeasurement.originVisible=false;break;case MOUSE_FINDING_CORNER:_this20._currentAngleMeasurement.cornerVisible=false;_this20._currentAngleMeasurement.originWireVisible=false;_this20._currentAngleMeasurement.targetVisible=false;_this20._currentAngleMeasurement.targetWireVisible=false;_this20._currentAngleMeasurement.angleVisible=false;break;case MOUSE_FINDING_TARGET:_this20._currentAngleMeasurement.targetVisible=false;_this20._currentAngleMeasurement.targetWireVisible=false;_this20._currentAngleMeasurement.angleVisible=false;break;}canvas.style.cursor="default";}});this._active=true;}/**
|
|
3019
3019
|
* Deactivates this AngleMeasurementsMouseControl, making it unresponsive to input.
|
|
3020
3020
|
*
|
|
3021
3021
|
* Destroys any {@link AngleMeasurement} under construction by this AngleMeasurementsMouseControl.
|
|
@@ -3236,7 +3236,7 @@ _this19._initMarkerDiv();_this19._onMouseHoverSurface=null;_this19._onHoverNothi
|
|
|
3236
3236
|
* start, corner or end point will cause the point to snap to the nearest vertex or edge. A quick
|
|
3237
3237
|
* touch-release will immediately set the point at the tapped position on the object surface.
|
|
3238
3238
|
*
|
|
3239
|
-
* [[Run example](/examples/measurement/#angle_createWithTouch_snapping)]
|
|
3239
|
+
* [[Run example](https://xeokit.github.io/xeokit-sdk/examples/measurement/#angle_createWithTouch_snapping)]
|
|
3240
3240
|
*
|
|
3241
3241
|
* ````javascript
|
|
3242
3242
|
* import {Viewer, XKTLoaderPlugin, AngleMeasurementsPlugin, AngleMeasurementsTouchControl} from "xeokit-sdk.es.js";
|
|
@@ -3359,7 +3359,7 @@ _this19._initMarkerDiv();_this19._onMouseHoverSurface=null;_this19._onHoverNothi
|
|
|
3359
3359
|
cancel();return;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this24._snapToVertex,snapToEdge:_this24._snapToEdge});if(snapPickResult&&snapPickResult.snapped){pointerWorldPos.set(snapPickResult.worldPos);_this24.pointerCircle.start(snapPickResult.snappedCanvasPos);}else{var pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){pointerWorldPos.set(pickResult.worldPos);_this24.pointerCircle.start(pickResult.canvasPos);}else{return;}}longTouchTimeout=setTimeout(function(){if(currentNumTouches!==1||touchMoveCanvasPos[0]>touchStartCanvasPos[0]+touchTolerance||touchMoveCanvasPos[0]<touchStartCanvasPos[0]-touchTolerance||touchMoveCanvasPos[1]>touchStartCanvasPos[1]+touchTolerance||touchMoveCanvasPos[1]<touchStartCanvasPos[1]-touchTolerance){return;// Has moved
|
|
3360
3360
|
}// Long touch
|
|
3361
3361
|
if(_this24.pointerLens){_this24.pointerLens.visible=true;_this24.pointerLens.canvasPos=touchStartCanvasPos;_this24.pointerLens.cursorPos=touchStartCanvasPos;}if(_this24.pointerLens){_this24.pointerLens.canvasPos=touchMoveCanvasPos;_this24.pointerLens.snapped=false;}if(_this24.pointerLens){_this24.pointerLens.cursorPos=snapPickResult.canvasPos;_this24.pointerLens.snapped=true;}// pointerWorldPos.set(snapPickResult.worldPos);
|
|
3362
|
-
if(!_this24._currentAngleMeasurement){_this24._currentAngleMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:snapPickResult.worldPos},corner:{worldPos:snapPickResult.worldPos},target:{worldPos:snapPickResult.worldPos}});_this24._currentAngleMeasurement.clickable=false;_this24._currentAngleMeasurement.originVisible=true;_this24._currentAngleMeasurement.originWireVisible=false;_this24._currentAngleMeasurement.cornerVisible=false;_this24._currentAngleMeasurement.cornerWireVisible=false;_this24._currentAngleMeasurement.targetVisible=false;_this24._currentAngleMeasurement.targetWireVisible=false;_this24._currentAngleMeasurement.angleVisible=false;}else{_this24._currentAngleMeasurement.origin.worldPos=pointerWorldPos;}_this24.angleMeasurementsPlugin.fire("measurementStart",_this24._currentAngleMeasurement);// if (this.pointerLens) {
|
|
3362
|
+
if(!_this24._currentAngleMeasurement){_this24._currentAngleMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity},corner:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity},target:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity}});_this24._currentAngleMeasurement.clickable=false;_this24._currentAngleMeasurement.originVisible=true;_this24._currentAngleMeasurement.originWireVisible=false;_this24._currentAngleMeasurement.cornerVisible=false;_this24._currentAngleMeasurement.cornerWireVisible=false;_this24._currentAngleMeasurement.targetVisible=false;_this24._currentAngleMeasurement.targetWireVisible=false;_this24._currentAngleMeasurement.angleVisible=false;}else{_this24._currentAngleMeasurement.origin.worldPos=pointerWorldPos;}_this24.angleMeasurementsPlugin.fire("measurementStart",_this24._currentAngleMeasurement);// if (this.pointerLens) {
|
|
3363
3363
|
// this.pointerLens.cursorPos = pickResult.canvasPos;
|
|
3364
3364
|
// this.pointerLens.snapped = false;
|
|
3365
3365
|
// }
|
|
@@ -3369,13 +3369,13 @@ touchId=touch.identifier;break;case WAITING_FOR_CORNER_TOUCH_START:if(currentNum
|
|
|
3369
3369
|
clearTimeout(longTouchTimeout);longTouchTimeout=null;return;}if(currentNumTouches===1){// One finger down
|
|
3370
3370
|
longTouchTimeout=setTimeout(function(){longTouchTimeout=null;if(currentNumTouches!==1||touchMoveCanvasPos[0]>touchStartCanvasPos[0]+touchTolerance||touchMoveCanvasPos[0]<touchStartCanvasPos[0]-touchTolerance||touchMoveCanvasPos[1]>touchStartCanvasPos[1]+touchTolerance||touchMoveCanvasPos[1]<touchStartCanvasPos[1]-touchTolerance){// Has moved
|
|
3371
3371
|
return;}// Long touch
|
|
3372
|
-
if(_this24.pointerLens){_this24.pointerLens.visible=true;_this24.pointerLens.canvasPos=touchStartCanvasPos;_this24.pointerLens.snapped=false;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this24._snapToVertex,snapToEdge:_this24._snapToEdge});if(snapPickResult&&snapPickResult.snapped){if(_this24.pointerLens){_this24.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this24.pointerLens.snapped=true;}_this24.pointerCircle.start(snapPickResult.snappedCanvasPos);pointerWorldPos.set(snapPickResult.worldPos);_this24._currentAngleMeasurement.corner.worldPos=snapPickResult.worldPos;_this24._currentAngleMeasurement.originVisible=true;_this24._currentAngleMeasurement.originWireVisible=true;_this24._currentAngleMeasurement.cornerVisible=true;_this24._currentAngleMeasurement.cornerWireVisible=false;_this24._currentAngleMeasurement.targetVisible=false;_this24._currentAngleMeasurement.targetWireVisible=false;_this24._currentAngleMeasurement.angleVisible=false;_this24.angleMeasurementsPlugin.fire("measurementStart",_this24._currentAngleMeasurement);}else{var _pickResult2=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(_pickResult2&&_pickResult2.worldPos){if(_this24.pointerLens){_this24.pointerLens.cursorPos=_pickResult2.canvasPos;_this24.pointerLens.snapped=false;}_this24.pointerCircle.start(_pickResult2.canvasPos);pointerWorldPos.set(_pickResult2.worldPos);_this24._currentAngleMeasurement.corner.worldPos=_pickResult2.worldPos;_this24._currentAngleMeasurement.originVisible=true;_this24._currentAngleMeasurement.originWireVisible=true;_this24._currentAngleMeasurement.cornerVisible=true;_this24._currentAngleMeasurement.cornerWireVisible=false;_this24._currentAngleMeasurement.targetVisible=false;_this24._currentAngleMeasurement.targetWireVisible=false;_this24._currentAngleMeasurement.angleVisible=false;_this24.angleMeasurementsPlugin.fire("measurementStart",_this24._currentAngleMeasurement);}else{if(_this24.pointerLens){_this24.pointerLens.cursorPos=null;_this24.pointerLens.snapped=false;}}}_this24._touchState=WAITING_FOR_CORNER_LONG_TOUCH_END;// console.log("touchstart: this._touchState= WAITING_FOR_CORNER_TOUCH_START -> WAITING_FOR_CORNER_LONG_TOUCH_END")
|
|
3372
|
+
if(_this24.pointerLens){_this24.pointerLens.visible=true;_this24.pointerLens.canvasPos=touchStartCanvasPos;_this24.pointerLens.snapped=false;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this24._snapToVertex,snapToEdge:_this24._snapToEdge});if(snapPickResult&&snapPickResult.snapped){if(_this24.pointerLens){_this24.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this24.pointerLens.snapped=true;}_this24.pointerCircle.start(snapPickResult.snappedCanvasPos);pointerWorldPos.set(snapPickResult.worldPos);_this24._currentAngleMeasurement.corner.worldPos=snapPickResult.worldPos;_this24._currentAngleMeasurement.corner.entity=snapPickResult.entity;_this24._currentAngleMeasurement.originVisible=true;_this24._currentAngleMeasurement.originWireVisible=true;_this24._currentAngleMeasurement.cornerVisible=true;_this24._currentAngleMeasurement.cornerWireVisible=false;_this24._currentAngleMeasurement.targetVisible=false;_this24._currentAngleMeasurement.targetWireVisible=false;_this24._currentAngleMeasurement.angleVisible=false;_this24.angleMeasurementsPlugin.fire("measurementStart",_this24._currentAngleMeasurement);}else{var _pickResult2=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(_pickResult2&&_pickResult2.worldPos){if(_this24.pointerLens){_this24.pointerLens.cursorPos=_pickResult2.canvasPos;_this24.pointerLens.snapped=false;}_this24.pointerCircle.start(_pickResult2.canvasPos);pointerWorldPos.set(_pickResult2.worldPos);_this24._currentAngleMeasurement.corner.worldPos=_pickResult2.worldPos;_this24._currentAngleMeasurement.corner.entity=_pickResult2.entity;_this24._currentAngleMeasurement.originVisible=true;_this24._currentAngleMeasurement.originWireVisible=true;_this24._currentAngleMeasurement.cornerVisible=true;_this24._currentAngleMeasurement.cornerWireVisible=false;_this24._currentAngleMeasurement.targetVisible=false;_this24._currentAngleMeasurement.targetWireVisible=false;_this24._currentAngleMeasurement.angleVisible=false;_this24.angleMeasurementsPlugin.fire("measurementStart",_this24._currentAngleMeasurement);}else{if(_this24.pointerLens){_this24.pointerLens.cursorPos=null;_this24.pointerLens.snapped=false;}}}_this24._touchState=WAITING_FOR_CORNER_LONG_TOUCH_END;// console.log("touchstart: this._touchState= WAITING_FOR_CORNER_TOUCH_START -> WAITING_FOR_CORNER_LONG_TOUCH_END")
|
|
3373
3373
|
disableCameraMouseControl();},_this24._longTouchTimeoutMs);_this24._touchState=WAITING_FOR_CORNER_QUICK_TOUCH_END;// console.log("touchstart: this._touchState= WAITING_FOR_CORNER_TOUCH_START -> WAITING_FOR_CORNER_QUICK_TOUCH_END")
|
|
3374
3374
|
}touchId=touch.identifier;break;case WAITING_FOR_TARGET_TOUCH_START$1:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
3375
3375
|
clearTimeout(longTouchTimeout);longTouchTimeout=null;return;}if(currentNumTouches===1){// One finger down
|
|
3376
3376
|
longTouchTimeout=setTimeout(function(){longTouchTimeout=null;if(currentNumTouches!==1||touchMoveCanvasPos[0]>touchStartCanvasPos[0]+touchTolerance||touchMoveCanvasPos[0]<touchStartCanvasPos[0]-touchTolerance||touchMoveCanvasPos[1]>touchStartCanvasPos[1]+touchTolerance||touchMoveCanvasPos[1]<touchStartCanvasPos[1]-touchTolerance){// Has moved
|
|
3377
3377
|
return;}// Long touch
|
|
3378
|
-
if(_this24.pointerLens){_this24.pointerLens.visible=true;_this24.pointerLens.canvasPos=touchStartCanvasPos;_this24.pointerLens.snapped=false;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this24._snapToVertex,snapToEdge:_this24._snapToEdge});if(snapPickResult&&snapPickResult.snapped){if(_this24.pointerLens){_this24.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this24.pointerLens.snapped=true;}_this24.pointerCircle.start(snapPickResult.snappedCanvasPos);pointerWorldPos.set(snapPickResult.worldPos);_this24._currentAngleMeasurement.target.worldPos=snapPickResult.worldPos;_this24._currentAngleMeasurement.originVisible=true;_this24._currentAngleMeasurement.originWireVisible=true;_this24._currentAngleMeasurement.cornerVisible=true;_this24._currentAngleMeasurement.cornerWireVisible=true;_this24._currentAngleMeasurement.targetVisible=true;_this24._currentAngleMeasurement.targetWireVisible=true;_this24._currentAngleMeasurement.angleVisible=true;_this24.angleMeasurementsPlugin.fire("measurementStart",_this24._currentAngleMeasurement);}else{var _pickResult3=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(_pickResult3&&_pickResult3.worldPos){if(_this24.pointerLens){_this24.pointerLens.cursorPos=_pickResult3.canvasPos;_this24.pointerLens.snapped=false;}_this24.pointerCircle.start(_pickResult3.canvasPos);pointerWorldPos.set(_pickResult3.worldPos);_this24._currentAngleMeasurement.target.worldPos=_pickResult3.worldPos;_this24._currentAngleMeasurement.originVisible=true;_this24._currentAngleMeasurement.originWireVisible=true;_this24._currentAngleMeasurement.cornerVisible=true;_this24._currentAngleMeasurement.cornerWireVisible=true;_this24._currentAngleMeasurement.targetVisible=true;_this24._currentAngleMeasurement.targetWireVisible=true;_this24._currentAngleMeasurement.angleVisible=true;_this24.angleMeasurementsPlugin.fire("measurementStart",_this24._currentAngleMeasurement);}else{if(_this24.pointerLens){_this24.pointerLens.cursorPos=null;_this24.pointerLens.snapped=false;}}}_this24._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END$1;// console.log("touchstart: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_LONG_TOUCH_END")
|
|
3378
|
+
if(_this24.pointerLens){_this24.pointerLens.visible=true;_this24.pointerLens.canvasPos=touchStartCanvasPos;_this24.pointerLens.snapped=false;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this24._snapToVertex,snapToEdge:_this24._snapToEdge});if(snapPickResult&&snapPickResult.snapped){if(_this24.pointerLens){_this24.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this24.pointerLens.snapped=true;}_this24.pointerCircle.start(snapPickResult.snappedCanvasPos);pointerWorldPos.set(snapPickResult.worldPos);_this24._currentAngleMeasurement.target.worldPos=snapPickResult.worldPos;_this24._currentAngleMeasurement.target.entity=snapPickResult.entity;_this24._currentAngleMeasurement.originVisible=true;_this24._currentAngleMeasurement.originWireVisible=true;_this24._currentAngleMeasurement.cornerVisible=true;_this24._currentAngleMeasurement.cornerWireVisible=true;_this24._currentAngleMeasurement.targetVisible=true;_this24._currentAngleMeasurement.targetWireVisible=true;_this24._currentAngleMeasurement.angleVisible=true;_this24.angleMeasurementsPlugin.fire("measurementStart",_this24._currentAngleMeasurement);}else{var _pickResult3=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(_pickResult3&&_pickResult3.worldPos){if(_this24.pointerLens){_this24.pointerLens.cursorPos=_pickResult3.canvasPos;_this24.pointerLens.snapped=false;}_this24.pointerCircle.start(_pickResult3.canvasPos);pointerWorldPos.set(_pickResult3.worldPos);_this24._currentAngleMeasurement.target.worldPos=_pickResult3.worldPos;_this24._currentAngleMeasurement.target.entity=_pickResult3.entity;_this24._currentAngleMeasurement.originVisible=true;_this24._currentAngleMeasurement.originWireVisible=true;_this24._currentAngleMeasurement.cornerVisible=true;_this24._currentAngleMeasurement.cornerWireVisible=true;_this24._currentAngleMeasurement.targetVisible=true;_this24._currentAngleMeasurement.targetWireVisible=true;_this24._currentAngleMeasurement.angleVisible=true;_this24.angleMeasurementsPlugin.fire("measurementStart",_this24._currentAngleMeasurement);}else{if(_this24.pointerLens){_this24.pointerLens.cursorPos=null;_this24.pointerLens.snapped=false;}}}_this24._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END$1;// console.log("touchstart: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_LONG_TOUCH_END")
|
|
3379
3379
|
disableCameraMouseControl();},_this24._longTouchTimeoutMs);_this24._touchState=WAITING_FOR_TARGET_QUICK_TOUCH_END$1;// console.log("touchstart: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_QUICK_TOUCH_END")
|
|
3380
3380
|
}touchId=touch.identifier;break;default:if(longTouchTimeout!==null){clearTimeout(longTouchTimeout);longTouchTimeout=null;}_this24._touchState=TOUCH_CANCELING$1;// console.log("touchstart: this._touchState= default -> TOUCH_CANCELING")
|
|
3381
3381
|
return;}},{passive:true});canvas.addEventListener("touchmove",function(event){_this24.pointerCircle.stop();var currentNumTouches=event.touches.length;if(currentNumTouches!==1||event.changedTouches.length!==1){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}return;}var touch=event.touches[0];var touchX=touch.clientX;var touchY=touch.clientY;if(touch.identifier!==touchId){return;}touchMoveCanvasPos.set([touchX,touchY]);var snapPickResult;var pickResult;switch(_this24._touchState){case WAITING_FOR_ORIGIN_LONG_TOUCH_END$1:if(_this24.pointerLens){_this24.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this24._snapToVertex,snapToEdge:_this24._snapToEdge});if(snapPickResult&&snapPickResult.snapped){if(_this24.pointerLens){_this24.pointerLens.snappedCanvasPos=snapPickResult.snappedCanvasPos;_this24.pointerLens.snapped=true;}pointerWorldPos.set(snapPickResult.worldPos);_this24._currentAngleMeasurement.origin.worldPos=snapPickResult.worldPos;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this24.pointerLens){_this24.pointerLens.cursorPos=pickResult.canvasPos;_this24.pointerLens.snapped=false;}pointerWorldPos.set(pickResult.worldPos);_this24._currentAngleMeasurement.origin.worldPos=pickResult.worldPos;}else{if(_this24.pointerLens){_this24.pointerLens.cursorPos=null;_this24.pointerLens.snapped=false;}}}_this24._touchState=WAITING_FOR_ORIGIN_LONG_TOUCH_END$1;// console.log("touchmove: this._touchState= WAITING_FOR_ORIGIN_LONG_TOUCH_END -> WAITING_FOR_ORIGIN_LONG_TOUCH_END")
|
|
@@ -18477,7 +18477,7 @@ if(!this._textureTranscoder){this.error("[createTexture] Can't create texture fr
|
|
|
18477
18477
|
* @param {Number[]} [cfg.rotation=[0,0,0]] Rotation of the transform as Euler angles given in degrees, for each of the X, Y and Z axis.
|
|
18478
18478
|
* @param {Number[]} [cfg.matrix=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]] Modelling transform matrix. Overrides the ````position````, ````scale```` and ````rotation```` parameters.
|
|
18479
18479
|
* @returns {SceneModelTransform} The new transform.
|
|
18480
|
-
*/},{key:"createTransform",value:function createTransform(cfg){if(cfg.id===undefined||cfg.id===null){this.error("[createTransform] SceneModel.createTransform() config missing: id");return;}if(this._transforms[cfg.id]){this.error("[createTransform] SceneModel already has a transform with this ID: ".concat(cfg.id));return;}var parentTransform;if(
|
|
18480
|
+
*/},{key:"createTransform",value:function createTransform(cfg){if(cfg.id===undefined||cfg.id===null){this.error("[createTransform] SceneModel.createTransform() config missing: id");return;}if(this._transforms[cfg.id]){this.error("[createTransform] SceneModel already has a transform with this ID: ".concat(cfg.id));return;}var parentTransform;if(cfg.parentTransformId){parentTransform=this._transforms[cfg.parentTransformId];if(!parentTransform){this.error("[createTransform] SceneModel.createTransform() config missing: id");return;}}var transform=new SceneModelTransform({id:cfg.id,model:this,parentTransform:parentTransform,matrix:cfg.matrix,position:cfg.position,scale:cfg.scale,rotation:cfg.rotation,quaternion:cfg.quaternion});this._transforms[transform.id]=transform;return transform;}/**
|
|
18481
18481
|
* Creates a new {@link SceneModelMesh} within this SceneModel.
|
|
18482
18482
|
*
|
|
18483
18483
|
* * It prepares and saves data for a SceneModelMesh {@link SceneModel#meshes} creation. SceneModelMesh will be created only once the SceneModelEntity (which references this particular SceneModelMesh) will be created.
|
|
@@ -19404,7 +19404,7 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._targetDot.s
|
|
|
19404
19404
|
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsMouseControl.
|
|
19405
19405
|
*/function get(){return this._snapping;}/**
|
|
19406
19406
|
* Activates this DistanceMeasurementsMouseControl, ready to respond to input.
|
|
19407
|
-
*/,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 _this85=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));};var pagePos=math.vec2();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(_this85._mouseState===MOUSE_FIRST_CLICK_EXPECTED){if(_this85._canvasToPagePos){_this85._canvasToPagePos(canvas,canvasPos,pagePos);_this85._markerDiv.style.left="".concat(pagePos[0]-5,"px");_this85._markerDiv.style.top="".concat(pagePos[1]-5,"px");}else{_this85._markerDiv.style.left="".concat(getLeft(canvas)+canvasPos[0]-5,"px");_this85._markerDiv.style.top="".concat(getTop(canvas)+canvasPos[1]-5,"px");}_this85._markerDiv.style.background="pink";if(event.snappedToVertex||event.snappedToEdge){if(_this85.pointerLens){_this85.pointerLens.visible=true;_this85.pointerLens.canvasPos=event.canvasPos;_this85.pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;_this85.pointerLens.snapped=true;}_this85._markerDiv.style.background="greenyellow";_this85._markerDiv.style.border="2px solid green";}else{if(_this85.pointerLens){_this85.pointerLens.visible=true;_this85.pointerLens.canvasPos=event.canvasPos;_this85.pointerLens.snappedCanvasPos=event.canvasPos;_this85.pointerLens.snapped=false;}_this85._markerDiv.style.background="pink";_this85._markerDiv.style.border="2px solid red";}hoveredEntity=event.entity;}else{_this85._markerDiv.style.left="-10000px";_this85._markerDiv.style.top="-10000px";}canvas.style.cursor="pointer";if(_this85._currentDistanceMeasurement){_this85._currentDistanceMeasurement.wireVisible=_this85._currentDistanceMeasurementInitState.wireVisible;_this85._currentDistanceMeasurement.axisVisible=_this85._currentDistanceMeasurementInitState.axisVisible&&_this85.distanceMeasurementsPlugin.defaultAxisVisible;_this85._currentDistanceMeasurement.xAxisVisible=_this85._currentDistanceMeasurementInitState.xAxisVisible&&_this85.distanceMeasurementsPlugin.defaultXAxisVisible;_this85._currentDistanceMeasurement.yAxisVisible=_this85._currentDistanceMeasurementInitState.yAxisVisible&&_this85.distanceMeasurementsPlugin.defaultYAxisVisible;_this85._currentDistanceMeasurement.zAxisVisible=_this85._currentDistanceMeasurementInitState.zAxisVisible&&_this85.distanceMeasurementsPlugin.defaultZAxisVisible;_this85._currentDistanceMeasurement.targetVisible=_this85._currentDistanceMeasurementInitState.targetVisible;_this85._currentDistanceMeasurement.target.worldPos=pointerWorldPos.slice();_this85._markerDiv.style.left="-10000px";_this85._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(_this85._currentDistanceMeasurement){if(mouseHovering){_this85._currentDistanceMeasurement.target.entity=hoveredEntity;hoveredEntity=null;_this85._currentDistanceMeasurement.clickable=true;_this85.distanceMeasurementsPlugin.fire("measurementEnd",_this85._currentDistanceMeasurement);_this85._currentDistanceMeasurement=null;}else{_this85._currentDistanceMeasurement.destroy();_this85.distanceMeasurementsPlugin.fire("measurementCancel",_this85._currentDistanceMeasurement);_this85._currentDistanceMeasurement=null;hoveredEntity=null;}}else{if(mouseHovering){_this85._currentDistanceMeasurement=distanceMeasurementsPlugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pointerWorldPos.slice()},target:{worldPos:pointerWorldPos.slice()},approximate:true});_this85._currentDistanceMeasurementInitState.axisVisible=_this85._currentDistanceMeasurement.axisVisible&&_this85.distanceMeasurementsPlugin.defaultAxisVisible;_this85._currentDistanceMeasurementInitState.xAxisVisible=_this85._currentDistanceMeasurement.xAxisVisible&&_this85.distanceMeasurementsPlugin.defaultXAxisVisible;_this85._currentDistanceMeasurementInitState.yAxisVisible=_this85._currentDistanceMeasurement.yAxisVisible&&_this85.distanceMeasurementsPlugin.defaultYAxisVisible;_this85._currentDistanceMeasurementInitState.zAxisVisible=_this85._currentDistanceMeasurement.zAxisVisible&&_this85.distanceMeasurementsPlugin.defaultZAxisVisible;_this85._currentDistanceMeasurementInitState.wireVisible=_this85._currentDistanceMeasurement.wireVisible;_this85._currentDistanceMeasurementInitState.targetVisible=_this85._currentDistanceMeasurement.targetVisible;_this85._currentDistanceMeasurement.clickable=false;_this85._currentDistanceMeasurement.origin.entity=hoveredEntity;hoveredEntity=null;_this85.fire("measurementStart",_this85._currentDistanceMeasurement);}}});this._onCameraControlHoverSnapOrSurfaceOff=cameraControl.on(this._snapping?"hoverSnapOrSurfaceOff":"hoverOff",function(event){if(_this85.pointerLens){_this85.pointerLens.visible=true;_this85.pointerLens.canvasPos=event.canvasPos;_this85.pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;}mouseHovering=false;_this85._markerDiv.style.left="-100px";_this85._markerDiv.style.top="-100px";if(_this85._currentDistanceMeasurement){_this85._currentDistanceMeasurement.wireVisible=false;_this85._currentDistanceMeasurement.targetVisible=false;_this85._currentDistanceMeasurement.axisVisible=false;}canvas.style.cursor="default";});this._active=true;}/**
|
|
19407
|
+
*/,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 _this85=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));};var pagePos=math.vec2();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(_this85._mouseState===MOUSE_FIRST_CLICK_EXPECTED){if(_this85._canvasToPagePos){_this85._canvasToPagePos(canvas,canvasPos,pagePos);_this85._markerDiv.style.left="".concat(pagePos[0]-5,"px");_this85._markerDiv.style.top="".concat(pagePos[1]-5,"px");}else{_this85._markerDiv.style.left="".concat(getLeft(canvas)+canvasPos[0]-5,"px");_this85._markerDiv.style.top="".concat(getTop(canvas)+canvasPos[1]-5,"px");}_this85._markerDiv.style.background="pink";if(event.snappedToVertex||event.snappedToEdge){if(_this85.pointerLens){_this85.pointerLens.visible=true;_this85.pointerLens.canvasPos=event.canvasPos;_this85.pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;_this85.pointerLens.snapped=true;}_this85._markerDiv.style.background="greenyellow";_this85._markerDiv.style.border="2px solid green";}else{if(_this85.pointerLens){_this85.pointerLens.visible=true;_this85.pointerLens.canvasPos=event.canvasPos;_this85.pointerLens.snappedCanvasPos=event.canvasPos;_this85.pointerLens.snapped=false;}_this85._markerDiv.style.background="pink";_this85._markerDiv.style.border="2px solid red";}hoveredEntity=event.entity;}else{_this85._markerDiv.style.left="-10000px";_this85._markerDiv.style.top="-10000px";}canvas.style.cursor="pointer";if(_this85._currentDistanceMeasurement){_this85._currentDistanceMeasurement.wireVisible=_this85._currentDistanceMeasurementInitState.wireVisible;_this85._currentDistanceMeasurement.axisVisible=_this85._currentDistanceMeasurementInitState.axisVisible&&_this85.distanceMeasurementsPlugin.defaultAxisVisible;_this85._currentDistanceMeasurement.xAxisVisible=_this85._currentDistanceMeasurementInitState.xAxisVisible&&_this85.distanceMeasurementsPlugin.defaultXAxisVisible;_this85._currentDistanceMeasurement.yAxisVisible=_this85._currentDistanceMeasurementInitState.yAxisVisible&&_this85.distanceMeasurementsPlugin.defaultYAxisVisible;_this85._currentDistanceMeasurement.zAxisVisible=_this85._currentDistanceMeasurementInitState.zAxisVisible&&_this85.distanceMeasurementsPlugin.defaultZAxisVisible;_this85._currentDistanceMeasurement.targetVisible=_this85._currentDistanceMeasurementInitState.targetVisible;_this85._currentDistanceMeasurement.target.worldPos=pointerWorldPos.slice();_this85._markerDiv.style.left="-10000px";_this85._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(_this85._currentDistanceMeasurement){if(mouseHovering){_this85._currentDistanceMeasurement.target.entity=hoveredEntity;hoveredEntity=null;_this85._currentDistanceMeasurement.clickable=true;_this85.distanceMeasurementsPlugin.fire("measurementEnd",_this85._currentDistanceMeasurement);_this85._currentDistanceMeasurement=null;}else{_this85._currentDistanceMeasurement.destroy();_this85.distanceMeasurementsPlugin.fire("measurementCancel",_this85._currentDistanceMeasurement);_this85._currentDistanceMeasurement=null;hoveredEntity=null;}}else{if(mouseHovering){_this85._currentDistanceMeasurement=distanceMeasurementsPlugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pointerWorldPos.slice(),entity:hoveredEntity},target:{worldPos:pointerWorldPos.slice(),entity:hoveredEntity},approximate:true});_this85._currentDistanceMeasurementInitState.axisVisible=_this85._currentDistanceMeasurement.axisVisible&&_this85.distanceMeasurementsPlugin.defaultAxisVisible;_this85._currentDistanceMeasurementInitState.xAxisVisible=_this85._currentDistanceMeasurement.xAxisVisible&&_this85.distanceMeasurementsPlugin.defaultXAxisVisible;_this85._currentDistanceMeasurementInitState.yAxisVisible=_this85._currentDistanceMeasurement.yAxisVisible&&_this85.distanceMeasurementsPlugin.defaultYAxisVisible;_this85._currentDistanceMeasurementInitState.zAxisVisible=_this85._currentDistanceMeasurement.zAxisVisible&&_this85.distanceMeasurementsPlugin.defaultZAxisVisible;_this85._currentDistanceMeasurementInitState.wireVisible=_this85._currentDistanceMeasurement.wireVisible;_this85._currentDistanceMeasurementInitState.targetVisible=_this85._currentDistanceMeasurement.targetVisible;_this85._currentDistanceMeasurement.clickable=false;_this85._currentDistanceMeasurement.origin.entity=hoveredEntity;hoveredEntity=null;_this85.distanceMeasurementsPlugin.fire("measurementStart",_this85._currentDistanceMeasurement);}}});this._onCameraControlHoverSnapOrSurfaceOff=cameraControl.on(this._snapping?"hoverSnapOrSurfaceOff":"hoverOff",function(event){if(_this85.pointerLens){_this85.pointerLens.visible=true;_this85.pointerLens.canvasPos=event.canvasPos;_this85.pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;}mouseHovering=false;_this85._markerDiv.style.left="-100px";_this85._markerDiv.style.top="-100px";if(_this85._currentDistanceMeasurement){_this85._currentDistanceMeasurement.wireVisible=false;_this85._currentDistanceMeasurement.targetVisible=false;_this85._currentDistanceMeasurement.axisVisible=false;}canvas.style.cursor="default";});this._active=true;}/**
|
|
19408
19408
|
* Deactivates this DistanceMeasurementsMouseControl, making it unresponsive to input.
|
|
19409
19409
|
*
|
|
19410
19410
|
* Destroys any {@link DistanceMeasurement} under construction by this DistanceMeasurementsMouseControl.
|
|
@@ -19645,7 +19645,7 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._targetDot.s
|
|
|
19645
19645
|
* start or end point will cause the point to snap to the nearest vertex or edge. A quick
|
|
19646
19646
|
* touch-release will immediately set the point at the tapped position on the object surface.
|
|
19647
19647
|
*
|
|
19648
|
-
* [[Run example](/examples/measurement/#distance_createWithTouch_snapping)]
|
|
19648
|
+
* [[Run example](https://xeokit.github.io/xeokit-sdk/examples/measurement/#distance_createWithTouch_snapping)]
|
|
19649
19649
|
*
|
|
19650
19650
|
* ````javascript
|
|
19651
19651
|
* import {Viewer, XKTLoaderPlugin, DistanceMeasurementsPlugin, DistanceMeasurementsTouchControl} from "xeokit-sdk.es.js";
|
|
@@ -19810,7 +19810,7 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._targetDot.s
|
|
|
19810
19810
|
cancel();return;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this89._snapToVertex,snapToEdge:_this89._snapToEdge});if(snapPickResult&&snapPickResult.snapped){pointerWorldPos.set(snapPickResult.worldPos);_this89.pointerCircle.start(snapPickResult.snappedCanvasPos);}else{var pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){pointerWorldPos.set(pickResult.worldPos);_this89.pointerCircle.start(pickResult.canvasPos);}else{return;}}longTouchTimeout=setTimeout(function(){if(currentNumTouches!==1||touchMoveCanvasPos[0]>touchStartCanvasPos[0]+touchTolerance||touchMoveCanvasPos[0]<touchStartCanvasPos[0]-touchTolerance||touchMoveCanvasPos[1]>touchStartCanvasPos[1]+touchTolerance||touchMoveCanvasPos[1]<touchStartCanvasPos[1]-touchTolerance){return;// Has moved
|
|
19811
19811
|
}// Long touch
|
|
19812
19812
|
if(_this89.pointerLens){_this89.pointerLens.visible=true;_this89.pointerLens.canvasPos=touchStartCanvasPos;_this89.pointerLens.cursorPos=touchStartCanvasPos;}if(_this89.pointerLens){_this89.pointerLens.canvasPos=touchMoveCanvasPos;_this89.pointerLens.snapped=false;}if(_this89.pointerLens){_this89.pointerLens.cursorPos=snapPickResult.canvasPos;_this89.pointerLens.snapped=true;}// pointerWorldPos.set(snapPickResult.snappedWorldPos);
|
|
19813
|
-
if(!_this89._currentDistanceMeasurement){_this89._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pointerWorldPos},target:{worldPos:pointerWorldPos}});_this89._currentDistanceMeasurement.labelsVisible=false;_this89._currentDistanceMeasurement.xAxisVisible=false;_this89._currentDistanceMeasurement.yAxisVisible=false;_this89._currentDistanceMeasurement.zAxisVisible=false;_this89._currentDistanceMeasurement.wireVisible=false;_this89._currentDistanceMeasurement.originVisible=true;_this89._currentDistanceMeasurement.targetVisible=false;_this89._currentDistanceMeasurement.clickable=false;}else{_this89._currentDistanceMeasurement.origin.worldPos=pointerWorldPos;}_this89.distanceMeasurementsPlugin.fire("measurementStart",_this89._currentDistanceMeasurement);// if (this.pointerLens) {
|
|
19813
|
+
if(!_this89._currentDistanceMeasurement){_this89._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pointerWorldPos,entity:snapPickResult.entity},target:{worldPos:pointerWorldPos,entity:snapPickResult.entity}});_this89._currentDistanceMeasurement.labelsVisible=false;_this89._currentDistanceMeasurement.xAxisVisible=false;_this89._currentDistanceMeasurement.yAxisVisible=false;_this89._currentDistanceMeasurement.zAxisVisible=false;_this89._currentDistanceMeasurement.wireVisible=false;_this89._currentDistanceMeasurement.originVisible=true;_this89._currentDistanceMeasurement.targetVisible=false;_this89._currentDistanceMeasurement.clickable=false;}else{_this89._currentDistanceMeasurement.origin.worldPos=pointerWorldPos;}_this89.distanceMeasurementsPlugin.fire("measurementStart",_this89._currentDistanceMeasurement);// if (this.pointerLens) {
|
|
19814
19814
|
// this.pointerLens.cursorPos = pickResult.canvasPos;
|
|
19815
19815
|
// this.pointerLens.snapped = false;
|
|
19816
19816
|
// }
|
|
@@ -19820,21 +19820,21 @@ touchId=touch.identifier;break;case WAITING_FOR_TARGET_TOUCH_START:if(currentNum
|
|
|
19820
19820
|
clearTimeout(longTouchTimeout);longTouchTimeout=null;return;}if(currentNumTouches===1){// One finger down
|
|
19821
19821
|
longTouchTimeout=setTimeout(function(){longTouchTimeout=null;if(currentNumTouches!==1||touchMoveCanvasPos[0]>touchStartCanvasPos[0]+touchTolerance||touchMoveCanvasPos[0]<touchStartCanvasPos[0]-touchTolerance||touchMoveCanvasPos[1]>touchStartCanvasPos[1]+touchTolerance||touchMoveCanvasPos[1]<touchStartCanvasPos[1]-touchTolerance){// Has moved
|
|
19822
19822
|
return;}// Long touch
|
|
19823
|
-
if(_this89.pointerLens){_this89.pointerLens.visible=true;_this89.pointerLens.canvasPos=touchStartCanvasPos;_this89.pointerLens.snapped=false;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this89._snapToVertex,snapToEdge:_this89._snapToEdge});if(snapPickResult&&snapPickResult.snapped){if(_this89.pointerLens){_this89.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this89.pointerLens.snapped=true;}_this89.pointerCircle.start(snapPickResult.snappedCanvasPos);pointerWorldPos.set(snapPickResult.worldPos);_this89._currentDistanceMeasurement.target.worldPos=snapPickResult.worldPos;_this89._currentDistanceMeasurement.targetVisible=true;_this89._currentDistanceMeasurement.wireVisible=true;_this89._currentDistanceMeasurement.labelsVisible=true;_this89.distanceMeasurementsPlugin.fire("measurementStart",_this89._currentDistanceMeasurement);}else{var _pickResult6=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(_pickResult6&&_pickResult6.worldPos){if(_this89.pointerLens){_this89.pointerLens.cursorPos=_pickResult6.canvasPos;_this89.pointerLens.snapped=false;}_this89.pointerCircle.start(_pickResult6.canvasPos);pointerWorldPos.set(_pickResult6.worldPos);_this89._currentDistanceMeasurement.target.worldPos=_pickResult6.worldPos;_this89._currentDistanceMeasurement.targetVisible=true;_this89._currentDistanceMeasurement.wireVisible=true;_this89._currentDistanceMeasurement.labelsVisible=true;_this89.distanceMeasurementsPlugin.fire("measurementStart",_this89._currentDistanceMeasurement);}else{if(_this89.pointerLens){_this89.pointerLens.cursorPos=null;_this89.pointerLens.snapped=false;}}}_this89._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END;// console.log("touchstart: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_LONG_TOUCH_END")
|
|
19823
|
+
if(_this89.pointerLens){_this89.pointerLens.visible=true;_this89.pointerLens.canvasPos=touchStartCanvasPos;_this89.pointerLens.snapped=false;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this89._snapToVertex,snapToEdge:_this89._snapToEdge});if(snapPickResult&&snapPickResult.snapped){if(_this89.pointerLens){_this89.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this89.pointerLens.snapped=true;}_this89.pointerCircle.start(snapPickResult.snappedCanvasPos);pointerWorldPos.set(snapPickResult.worldPos);_this89._currentDistanceMeasurement.target.worldPos=snapPickResult.worldPos;_this89._currentDistanceMeasurement.target.entity=snapPickResult.entity;_this89._currentDistanceMeasurement.targetVisible=true;_this89._currentDistanceMeasurement.wireVisible=true;_this89._currentDistanceMeasurement.labelsVisible=true;_this89.distanceMeasurementsPlugin.fire("measurementStart",_this89._currentDistanceMeasurement);}else{var _pickResult6=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(_pickResult6&&_pickResult6.worldPos){if(_this89.pointerLens){_this89.pointerLens.cursorPos=_pickResult6.canvasPos;_this89.pointerLens.snapped=false;}_this89.pointerCircle.start(_pickResult6.canvasPos);pointerWorldPos.set(_pickResult6.worldPos);_this89._currentDistanceMeasurement.target.worldPos=_pickResult6.worldPos;_this89._currentDistanceMeasurement.target.entity=_pickResult6.entity;_this89._currentDistanceMeasurement.targetVisible=true;_this89._currentDistanceMeasurement.wireVisible=true;_this89._currentDistanceMeasurement.labelsVisible=true;_this89.distanceMeasurementsPlugin.fire("measurementStart",_this89._currentDistanceMeasurement);}else{if(_this89.pointerLens){_this89.pointerLens.cursorPos=null;_this89.pointerLens.snapped=false;}}}_this89._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END;// console.log("touchstart: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_LONG_TOUCH_END")
|
|
19824
19824
|
disableCameraMouseControl();},_this89._longTouchTimeoutMs);_this89._touchState=WAITING_FOR_TARGET_QUICK_TOUCH_END;// console.log("touchstart: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_QUICK_TOUCH_END")
|
|
19825
19825
|
}touchId=touch.identifier;break;default:if(longTouchTimeout!==null){clearTimeout(longTouchTimeout);longTouchTimeout=null;}_this89._touchState=TOUCH_CANCELING;// console.log("touchstart: this._touchState= default -> TOUCH_CANCELING")
|
|
19826
|
-
return;}},{passive:true});canvas.addEventListener("touchmove",function(event){_this89.pointerCircle.stop();var currentNumTouches=event.touches.length;if(currentNumTouches!==1||event.changedTouches.length!==1){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}return;}var touch=event.touches[0];var touchX=touch.clientX;var touchY=touch.clientY;if(touch.identifier!==touchId){return;}touchMoveCanvasPos.set([touchX,touchY]);var snapPickResult;var pickResult;switch(_this89._touchState){case WAITING_FOR_ORIGIN_LONG_TOUCH_END:if(_this89.pointerLens){_this89.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this89._snapToVertex,snapToEdge:_this89._snapToEdge});if(snapPickResult&&snapPickResult.snapped){if(_this89.pointerLens){_this89.pointerLens.snappedCanvasPos=snapPickResult.snappedCanvasPos;_this89.pointerLens.snapped=true;}pointerWorldPos.set(snapPickResult.worldPos);if(!_this89._currentDistanceMeasurement){_this89._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:snapPickResult.worldPos},target:{worldPos:snapPickResult.worldPos}});_this89._currentDistanceMeasurement.labelsVisible=false;_this89._currentDistanceMeasurement.xAxisVisible=false;_this89._currentDistanceMeasurement.yAxisVisible=false;_this89._currentDistanceMeasurement.zAxisVisible=false;_this89._currentDistanceMeasurement.wireVisible=false;_this89._currentDistanceMeasurement.originVisible=true;_this89._currentDistanceMeasurement.targetVisible=false;_this89._currentDistanceMeasurement.clickable=false;}else{_this89._currentDistanceMeasurement.origin.worldPos=snapPickResult.worldPos;}_this89.distanceMeasurementsPlugin.fire("measurementStart",_this89._currentDistanceMeasurement);}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this89.pointerLens){_this89.pointerLens.cursorPos=pickResult.canvasPos;_this89.pointerLens.snapped=false;}pointerWorldPos.set(pickResult.worldPos);if(!_this89._currentDistanceMeasurement){_this89._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pickResult.worldPos},target:{worldPos:pickResult.worldPos}});_this89._currentDistanceMeasurement.labelsVisible=false;_this89._currentDistanceMeasurement.xAxisVisible=false;_this89._currentDistanceMeasurement.yAxisVisible=false;_this89._currentDistanceMeasurement.zAxisVisible=false;_this89._currentDistanceMeasurement.wireVisible=false;_this89._currentDistanceMeasurement.originVisible=true;_this89._currentDistanceMeasurement.targetVisible=false;_this89._currentDistanceMeasurement.clickable=false;}else{_this89._currentDistanceMeasurement.origin.worldPos=pickResult.worldPos;}_this89.distanceMeasurementsPlugin.fire("measurementStart",_this89._currentDistanceMeasurement);}else{if(_this89.pointerLens){_this89.pointerLens.cursorPos=null;_this89.pointerLens.snapped=false;}}}_this89._touchState=WAITING_FOR_ORIGIN_LONG_TOUCH_END;// console.log("touchmove: this._touchState= WAITING_FOR_ORIGIN_LONG_TOUCH_END -> WAITING_FOR_ORIGIN_LONG_TOUCH_END")
|
|
19826
|
+
return;}},{passive:true});canvas.addEventListener("touchmove",function(event){_this89.pointerCircle.stop();var currentNumTouches=event.touches.length;if(currentNumTouches!==1||event.changedTouches.length!==1){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}return;}var touch=event.touches[0];var touchX=touch.clientX;var touchY=touch.clientY;if(touch.identifier!==touchId){return;}touchMoveCanvasPos.set([touchX,touchY]);var snapPickResult;var pickResult;switch(_this89._touchState){case WAITING_FOR_ORIGIN_LONG_TOUCH_END:if(_this89.pointerLens){_this89.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this89._snapToVertex,snapToEdge:_this89._snapToEdge});if(snapPickResult&&snapPickResult.snapped){if(_this89.pointerLens){_this89.pointerLens.snappedCanvasPos=snapPickResult.snappedCanvasPos;_this89.pointerLens.snapped=true;}pointerWorldPos.set(snapPickResult.worldPos);if(!_this89._currentDistanceMeasurement){_this89._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity},target:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity}});_this89._currentDistanceMeasurement.labelsVisible=false;_this89._currentDistanceMeasurement.xAxisVisible=false;_this89._currentDistanceMeasurement.yAxisVisible=false;_this89._currentDistanceMeasurement.zAxisVisible=false;_this89._currentDistanceMeasurement.wireVisible=false;_this89._currentDistanceMeasurement.originVisible=true;_this89._currentDistanceMeasurement.targetVisible=false;_this89._currentDistanceMeasurement.clickable=false;}else{_this89._currentDistanceMeasurement.origin.worldPos=snapPickResult.worldPos;}_this89.distanceMeasurementsPlugin.fire("measurementStart",_this89._currentDistanceMeasurement);}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this89.pointerLens){_this89.pointerLens.cursorPos=pickResult.canvasPos;_this89.pointerLens.snapped=false;}pointerWorldPos.set(pickResult.worldPos);if(!_this89._currentDistanceMeasurement){_this89._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pickResult.worldPos,entity:pickResult.entity},target:{worldPos:pickResult.worldPos,entity:pickResult.entity}});_this89._currentDistanceMeasurement.labelsVisible=false;_this89._currentDistanceMeasurement.xAxisVisible=false;_this89._currentDistanceMeasurement.yAxisVisible=false;_this89._currentDistanceMeasurement.zAxisVisible=false;_this89._currentDistanceMeasurement.wireVisible=false;_this89._currentDistanceMeasurement.originVisible=true;_this89._currentDistanceMeasurement.targetVisible=false;_this89._currentDistanceMeasurement.clickable=false;}else{_this89._currentDistanceMeasurement.origin.worldPos=pickResult.worldPos;}_this89.distanceMeasurementsPlugin.fire("measurementStart",_this89._currentDistanceMeasurement);}else{if(_this89.pointerLens){_this89.pointerLens.cursorPos=null;_this89.pointerLens.snapped=false;}}}_this89._touchState=WAITING_FOR_ORIGIN_LONG_TOUCH_END;// console.log("touchmove: this._touchState= WAITING_FOR_ORIGIN_LONG_TOUCH_END -> WAITING_FOR_ORIGIN_LONG_TOUCH_END")
|
|
19827
19827
|
break;// case WAITING_FOR_TARGET_TOUCH_START:
|
|
19828
19828
|
// this._touchState = WAITING_FOR_TARGET_TOUCH_START;
|
|
19829
19829
|
// console.log("touchmove: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_TOUCH_START")
|
|
19830
19830
|
// break;
|
|
19831
19831
|
case WAITING_FOR_TARGET_LONG_TOUCH_END:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
19832
19832
|
clearTimeout(longTouchTimeout);longTouchTimeout=null;if(_this89.pointerLens){_this89.pointerLens.visible=false;}_this89._touchState=TOUCH_CANCELING;// console.log("touchmove: this._touchState= QUICK_TOUCH_FINDING_TARGET -> TOUCH_CANCELING")
|
|
19833
|
-
return;}if(_this89.pointerLens){_this89.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this89._snapToVertex,snapToEdge:_this89._snapToEdge});if(snapPickResult&&snapPickResult.worldPos){if(_this89.pointerLens){_this89.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this89.pointerLens.snapped=true;}_this89._currentDistanceMeasurement.target.worldPos=snapPickResult.worldPos;_this89._currentDistanceMeasurement.targetVisible=true;_this89._currentDistanceMeasurement.wireVisible=true;_this89._currentDistanceMeasurement.labelsVisible=true;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this89.pointerLens){_this89.pointerLens.cursorPos=pickResult.canvasPos;_this89.pointerLens.snapped=false;}_this89._currentDistanceMeasurement.target.worldPos=pickResult.worldPos;_this89._currentDistanceMeasurement.targetVisible=true;_this89._currentDistanceMeasurement.wireVisible=true;_this89._currentDistanceMeasurement.labelsVisible=true;}}_this89._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END;break;}},{passive:true});canvas.addEventListener("touchend",this._onCanvasTouchEnd=function(event){_this89.pointerCircle.stop();var numChangedTouches=event.changedTouches.length;if(numChangedTouches!==1){return;}var touch=event.changedTouches[0];var touchX=touch.clientX;var touchY=touch.clientY;if(touch.identifier!==touchId){return;}if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}touchEndCanvasPos.set([touchX,touchY]);switch(_this89._touchState){case WAITING_FOR_ORIGIN_QUICK_TOUCH_END:{if(numChangedTouches!==1||touchX>touchStartCanvasPos[0]+touchTolerance||touchX<touchStartCanvasPos[0]-touchTolerance||touchY>touchStartCanvasPos[1]+touchTolerance||touchY<touchStartCanvasPos[1]-touchTolerance){_this89._touchState=WAITING_FOR_ORIGIN_TOUCH_START;return;}var pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){_this89._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pickResult.worldPos},target:{worldPos:pickResult.worldPos}});_this89._currentDistanceMeasurement.labelsVisible=false;_this89._currentDistanceMeasurement.xAxisVisible=false;_this89._currentDistanceMeasurement.yAxisVisible=false;_this89._currentDistanceMeasurement.zAxisVisible=false;_this89._currentDistanceMeasurement.wireVisible=false;_this89._currentDistanceMeasurement.originVisible=true;_this89._currentDistanceMeasurement.targetVisible=false;_this89._currentDistanceMeasurement.clickable=false;_this89._touchState=WAITING_FOR_TARGET_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_QUICK_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
19833
|
+
return;}if(_this89.pointerLens){_this89.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this89._snapToVertex,snapToEdge:_this89._snapToEdge});if(snapPickResult&&snapPickResult.worldPos){if(_this89.pointerLens){_this89.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this89.pointerLens.snapped=true;}_this89._currentDistanceMeasurement.target.worldPos=snapPickResult.worldPos;_this89._currentDistanceMeasurement.target.entity=snapPickResult.entity;_this89._currentDistanceMeasurement.targetVisible=true;_this89._currentDistanceMeasurement.wireVisible=true;_this89._currentDistanceMeasurement.labelsVisible=true;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this89.pointerLens){_this89.pointerLens.cursorPos=pickResult.canvasPos;_this89.pointerLens.snapped=false;}_this89._currentDistanceMeasurement.target.worldPos=pickResult.worldPos;_this89._currentDistanceMeasurement.target.entity=pickResult.entity;_this89._currentDistanceMeasurement.targetVisible=true;_this89._currentDistanceMeasurement.wireVisible=true;_this89._currentDistanceMeasurement.labelsVisible=true;}}_this89._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END;break;}},{passive:true});canvas.addEventListener("touchend",this._onCanvasTouchEnd=function(event){_this89.pointerCircle.stop();var numChangedTouches=event.changedTouches.length;if(numChangedTouches!==1){return;}var touch=event.changedTouches[0];var touchX=touch.clientX;var touchY=touch.clientY;if(touch.identifier!==touchId){return;}if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}touchEndCanvasPos.set([touchX,touchY]);switch(_this89._touchState){case WAITING_FOR_ORIGIN_QUICK_TOUCH_END:{if(numChangedTouches!==1||touchX>touchStartCanvasPos[0]+touchTolerance||touchX<touchStartCanvasPos[0]-touchTolerance||touchY>touchStartCanvasPos[1]+touchTolerance||touchY<touchStartCanvasPos[1]-touchTolerance){_this89._touchState=WAITING_FOR_ORIGIN_TOUCH_START;return;}var pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){_this89._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pickResult.worldPos,entity:pickResult.entity},target:{worldPos:pickResult.worldPos,entity:pickResult.entity}});_this89._currentDistanceMeasurement.labelsVisible=false;_this89._currentDistanceMeasurement.xAxisVisible=false;_this89._currentDistanceMeasurement.yAxisVisible=false;_this89._currentDistanceMeasurement.zAxisVisible=false;_this89._currentDistanceMeasurement.wireVisible=false;_this89._currentDistanceMeasurement.originVisible=true;_this89._currentDistanceMeasurement.targetVisible=false;_this89._currentDistanceMeasurement.clickable=false;_this89._touchState=WAITING_FOR_TARGET_TOUCH_START;_this89.distanceMeasurementsPlugin.fire("measurementStart",_this89._currentDistanceMeasurement);// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_QUICK_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
19834
19834
|
}else{if(_this89._currentDistanceMeasurement){_this89._currentDistanceMeasurement.destroy();}_this89._touchState=WAITING_FOR_ORIGIN_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_QUICK_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
19835
19835
|
}}enableCameraMouseControl();break;case WAITING_FOR_ORIGIN_LONG_TOUCH_END:if(_this89.pointerLens){_this89.pointerLens.visible=false;}if(!_this89._currentDistanceMeasurement){if(_this89.pointerLens){_this89.pointerLens.snapped=false;_this89.pointerLens.visible=false;}_this89._touchState=WAITING_FOR_ORIGIN_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_LONG_TOUCH_END (no measurement) -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
19836
19836
|
}else{_this89._touchState=WAITING_FOR_TARGET_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_LONG_TOUCH_END (picked, begin measurement) -> WAITING_FOR_TARGET_TOUCH_START")
|
|
19837
|
-
}enableCameraMouseControl();break;case WAITING_FOR_TARGET_QUICK_TOUCH_END:{if(numChangedTouches!==1||touchX>touchStartCanvasPos[0]+touchTolerance||touchX<touchStartCanvasPos[0]-touchTolerance||touchY>touchStartCanvasPos[1]+touchTolerance||touchY<touchStartCanvasPos[1]-touchTolerance){_this89._touchState=WAITING_FOR_TARGET_TOUCH_START;return;}var _pickResult7=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(_pickResult7&&_pickResult7.worldPos){_this89._currentDistanceMeasurement.target.worldPos=_pickResult7.worldPos;_this89._currentDistanceMeasurement.targetVisible=true;_this89._currentDistanceMeasurement.wireVisible=true;_this89._currentDistanceMeasurement.labelsVisible=true;_this89.distanceMeasurementsPlugin.fire("measurementEnd",_this89._currentDistanceMeasurement);_this89._currentDistanceMeasurement=null;}else{if(_this89._currentDistanceMeasurement){_this89._currentDistanceMeasurement.destroy();_this89._currentDistanceMeasurement=null;}}_this89._touchState=WAITING_FOR_ORIGIN_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
19837
|
+
}enableCameraMouseControl();break;case WAITING_FOR_TARGET_QUICK_TOUCH_END:{if(numChangedTouches!==1||touchX>touchStartCanvasPos[0]+touchTolerance||touchX<touchStartCanvasPos[0]-touchTolerance||touchY>touchStartCanvasPos[1]+touchTolerance||touchY<touchStartCanvasPos[1]-touchTolerance){_this89._touchState=WAITING_FOR_TARGET_TOUCH_START;return;}var _pickResult7=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(_pickResult7&&_pickResult7.worldPos){_this89._currentDistanceMeasurement.target.worldPos=_pickResult7.worldPos;_this89._currentDistanceMeasurement.target.entity=_pickResult7.entity;_this89._currentDistanceMeasurement.targetVisible=true;_this89._currentDistanceMeasurement.wireVisible=true;_this89._currentDistanceMeasurement.labelsVisible=true;_this89.distanceMeasurementsPlugin.fire("measurementEnd",_this89._currentDistanceMeasurement);_this89._currentDistanceMeasurement=null;}else{if(_this89._currentDistanceMeasurement){_this89._currentDistanceMeasurement.destroy();_this89._currentDistanceMeasurement=null;}}_this89._touchState=WAITING_FOR_ORIGIN_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
19838
19838
|
}enableCameraMouseControl();break;case WAITING_FOR_TARGET_LONG_TOUCH_END:if(_this89.pointerLens){_this89.pointerLens.visible=false;}if(!_this89._currentDistanceMeasurement||!_this89._currentDistanceMeasurement.targetVisible){if(_this89._currentDistanceMeasurement){_this89._currentDistanceMeasurement.destroy();_this89._currentDistanceMeasurement=null;}_this89._touchState=WAITING_FOR_ORIGIN_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_TARGET_LONG_TOUCH_END (no target found) -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
19839
19839
|
}else{_this89._currentDistanceMeasurement.clickable=true;_this89.distanceMeasurementsPlugin.fire("measurementEnd",_this89._currentDistanceMeasurement);_this89._currentDistanceMeasurement=null;_this89._touchState=WAITING_FOR_ORIGIN_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_TARGET_LONG_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
19840
19840
|
}enableCameraMouseControl();break;}},{passive:true});this._active=true;}/**
|
|
@@ -22359,17 +22359,17 @@ var eyeLookLen=math.lenVec3(math.subVec3(camera.look,camera.eye,math.vec3()));va
|
|
|
22359
22359
|
* Immediately attempts a pick, if scheduled.
|
|
22360
22360
|
*/_createClass(PickController,[{key:"update",value:function update(){if(!this._configs.pointerEnabled){return;}if(!this.schedulePickEntity&&!this.schedulePickSurface){return;}var hash="".concat(~~this.pickCursorPos[0],"-").concat(~~this.pickCursorPos[1],"-").concat(this.scheduleSnapOrPick,"-").concat(this.schedulePickSurface,"-").concat(this.schedulePickEntity);if(this._lastHash===hash){return;}this.picked=false;this.pickedSurface=false;this.snappedOrPicked=false;this.hoveredSnappedOrSurfaceOff=false;var hasHoverSurfaceSubs=this._cameraControl.hasSubs("hoverSurface");if(this.scheduleSnapOrPick){var snapPickResult=this._scene.pick({canvasPos:this.pickCursorPos,snapRadius:this._configs.snapRadius,snapToVertex:this._configs.snapToVertex,snapToEdge:this._configs.snapToEdge});if(snapPickResult&&(snapPickResult.snappedToEdge||snapPickResult.snappedToVertex)){this.snapPickResult=snapPickResult;this.snappedOrPicked=true;this._needFireEvents++;}else{this.schedulePickSurface=true;// Fallback
|
|
22361
22361
|
this.snapPickResult=null;}}if(this.schedulePickSurface){if(this.pickResult&&this.pickResult.worldPos){var pickResultCanvasPos=this.pickResult.canvasPos;if(pickResultCanvasPos[0]===this.pickCursorPos[0]&&pickResultCanvasPos[1]===this.pickCursorPos[1]){this.picked=true;this.pickedSurface=true;this._needFireEvents+=hasHoverSurfaceSubs?1:0;this.schedulePickEntity=false;this.schedulePickSurface=false;if(this.scheduleSnapOrPick){this.snappedOrPicked=true;}else{this.hoveredSnappedOrSurfaceOff=true;}this.scheduleSnapOrPick=false;return;}}}if(this.schedulePickEntity){if(this.pickResult&&(this.pickResult.canvasPos||this.pickResult.snappedCanvasPos)){var _pickResultCanvasPos=this.pickResult.canvasPos||this.pickResult.snappedCanvasPos;if(_pickResultCanvasPos[0]===this.pickCursorPos[0]&&_pickResultCanvasPos[1]===this.pickCursorPos[1]){this.picked=true;this.pickedSurface=false;this.schedulePickEntity=false;this.schedulePickSurface=false;return;}}}if(this.schedulePickSurface||this.scheduleSnapOrPick&&!this.snapPickResult){this.pickResult=this._scene.pick({pickSurface:true,pickSurfaceNormal:false,canvasPos:this.pickCursorPos});if(this.pickResult){this.picked=true;if(this.scheduleSnapOrPick){this.snappedOrPicked=true;}else{this.pickedSurface=true;}this._needFireEvents++;}else if(this.scheduleSnapOrPick){this.hoveredSnappedOrSurfaceOff=true;this._needFireEvents++;}}else{// schedulePickEntity == true
|
|
22362
|
-
this.pickResult=this._scene.pick({canvasPos:this.pickCursorPos});if(this.pickResult){this.picked=true;this.pickedSurface=false;this._needFireEvents++;}}this.scheduleSnapOrPick=false;this.schedulePickEntity=false;this.schedulePickSurface=false;}},{key:"fireEvents",value:function fireEvents(){if(this._needFireEvents===0){return;}if(this.hoveredSnappedOrSurfaceOff){this._cameraControl.fire("hoverSnapOrSurfaceOff",{canvasPos:this.pickCursorPos,pointerPos:this.pickCursorPos},true);}if(this.snappedOrPicked){if(this.snapPickResult){var pickResult=new PickResult();pickResult.snappedToVertex=this.snapPickResult.snappedToVertex;pickResult.snappedToEdge=this.snapPickResult.snappedToEdge;pickResult.worldPos=this.snapPickResult.worldPos;pickResult.canvasPos=this.pickCursorPos;pickResult.snappedCanvasPos=this.snapPickResult.snappedCanvasPos;this._cameraControl.fire("hoverSnapOrSurface",pickResult,true);this.snapPickResult=null;}else{this._cameraControl.fire("hoverSnapOrSurface",this.pickResult,true);}}if(this.picked&&this.pickResult&&(this.pickResult.entity||this.pickResult.worldPos)){if(this.pickResult.entity){var pickedEntityId=this.pickResult.entity.id;if(this._lastPickedEntityId!==pickedEntityId){if(this._lastPickedEntityId!==undefined){this._cameraControl.fire("hoverOut",{entity:this._scene.objects[this._lastPickedEntityId]},true);}this._cameraControl.fire("hoverEnter",this.pickResult,true);this._lastPickedEntityId=pickedEntityId;}}this._cameraControl.fire("hover",this.pickResult,true);if(this.pickResult.worldPos){this.pickedSurface=true;this._cameraControl.fire("hoverSurface",this.pickResult,true);}}else{if(this._lastPickedEntityId!==undefined){this._cameraControl.fire("hoverOut",{entity:this._scene.objects[this._lastPickedEntityId]},true);this._lastPickedEntityId=undefined;}this._cameraControl.fire("hoverOff",{canvasPos:this.pickCursorPos},true);}this.pickResult=null;this._needFireEvents=0;}}]);return PickController;}();/**
|
|
22362
|
+
this.pickResult=this._scene.pick({canvasPos:this.pickCursorPos});if(this.pickResult){this.picked=true;this.pickedSurface=false;this._needFireEvents++;}}this.scheduleSnapOrPick=false;this.schedulePickEntity=false;this.schedulePickSurface=false;}},{key:"fireEvents",value:function fireEvents(){if(this._needFireEvents===0){return;}if(this.hoveredSnappedOrSurfaceOff){this._cameraControl.fire("hoverSnapOrSurfaceOff",{canvasPos:this.pickCursorPos,pointerPos:this.pickCursorPos},true);}if(this.snappedOrPicked){if(this.snapPickResult){var pickResult=new PickResult();pickResult.entity=this.snapPickResult.entity;pickResult.snappedToVertex=this.snapPickResult.snappedToVertex;pickResult.snappedToEdge=this.snapPickResult.snappedToEdge;pickResult.worldPos=this.snapPickResult.worldPos;pickResult.canvasPos=this.pickCursorPos;pickResult.snappedCanvasPos=this.snapPickResult.snappedCanvasPos;this._cameraControl.fire("hoverSnapOrSurface",pickResult,true);this.snapPickResult=null;}else{this._cameraControl.fire("hoverSnapOrSurface",this.pickResult,true);}}if(this.picked&&this.pickResult&&(this.pickResult.entity||this.pickResult.worldPos)){if(this.pickResult.entity){var pickedEntityId=this.pickResult.entity.id;if(this._lastPickedEntityId!==pickedEntityId){if(this._lastPickedEntityId!==undefined){this._cameraControl.fire("hoverOut",{entity:this._scene.objects[this._lastPickedEntityId]},true);}this._cameraControl.fire("hoverEnter",this.pickResult,true);this._lastPickedEntityId=pickedEntityId;}}this._cameraControl.fire("hover",this.pickResult,true);if(this.pickResult.worldPos){this.pickedSurface=true;this._cameraControl.fire("hoverSurface",this.pickResult,true);}}else{if(this._lastPickedEntityId!==undefined){this._cameraControl.fire("hoverOut",{entity:this._scene.objects[this._lastPickedEntityId]},true);this._lastPickedEntityId=undefined;}this._cameraControl.fire("hoverOff",{canvasPos:this.pickCursorPos},true);}this.pickResult=null;this._needFireEvents=0;}}]);return PickController;}();/**
|
|
22363
22363
|
* @private
|
|
22364
22364
|
*/var canvasPos=math.vec2();var getCanvasPosFromEvent$3=function getCanvasPosFromEvent$3(event,canvasPos){if(!event){event=window.event;canvasPos[0]=event.x;canvasPos[1]=event.y;}else{var element=event.target;var totalOffsetLeft=0;var totalOffsetTop=0;var totalScrollX=0;var totalScrollY=0;while(element.offsetParent){totalOffsetLeft+=element.offsetLeft;totalOffsetTop+=element.offsetTop;totalScrollX+=element.scrollLeft;totalScrollY+=element.scrollTop;element=element.offsetParent;}canvasPos[0]=event.pageX+totalScrollX-totalOffsetLeft;canvasPos[1]=event.pageY+totalScrollY-totalOffsetTop;}return canvasPos;};/**
|
|
22365
22365
|
* @private
|
|
22366
22366
|
*/var MousePanRotateDollyHandler=/*#__PURE__*/function(){function MousePanRotateDollyHandler(scene,controllers,configs,states,updates){_classCallCheck(this,MousePanRotateDollyHandler);this._scene=scene;var pickController=controllers.pickController;var lastX=0;var lastY=0;var lastXDown=0;var lastYDown=0;var mouseDownLeft;var mouseDownMiddle;var mouseDownRight;var mouseDownPicked=false;var pickedWorldPos=math.vec3();var mouseMovedOnCanvasSinceLastWheel=true;var canvas=this._scene.canvas.canvas;var keyDown=[];document.addEventListener("keydown",this._documentKeyDownHandler=function(e){if(!(configs.active&&configs.pointerEnabled)||!scene.input.keyboardEnabled){return;}var keyCode=e.keyCode;keyDown[keyCode]=true;});document.addEventListener("keyup",this._documentKeyUpHandler=function(e){if(!(configs.active&&configs.pointerEnabled)||!scene.input.keyboardEnabled){return;}var keyCode=e.keyCode;keyDown[keyCode]=false;});function setMousedownState(){var pick=arguments.length>0&&arguments[0]!==undefined?arguments[0]:true;canvas.style.cursor="move";setMousedownPositions();if(pick){setMousedownPick();}}function setMousedownPositions(){lastX=states.pointerCanvasPos[0];lastY=states.pointerCanvasPos[1];lastXDown=states.pointerCanvasPos[0];lastYDown=states.pointerCanvasPos[1];}function setMousedownPick(){pickController.pickCursorPos=states.pointerCanvasPos;pickController.schedulePickSurface=true;pickController.update();if(pickController.picked&&pickController.pickedSurface&&pickController.pickResult&&pickController.pickResult.worldPos){mouseDownPicked=true;pickedWorldPos.set(pickController.pickResult.worldPos);}else{mouseDownPicked=false;}}canvas.addEventListener("mousedown",this._mouseDownHandler=function(e){if(!(configs.active&&configs.pointerEnabled)){return;}switch(e.which){case 1:// Left button
|
|
22367
22367
|
if(keyDown[scene.input.KEY_SHIFT]||configs.planView){mouseDownLeft=true;setMousedownState();}else{mouseDownLeft=true;setMousedownState(false);}break;case 2:// Middle/both buttons
|
|
22368
22368
|
mouseDownMiddle=true;setMousedownState();break;case 3:// Right button
|
|
22369
|
-
mouseDownRight=true;if(configs.panRightClick){setMousedownState();}break;}});document.addEventListener("mousemove",this._documentMouseMoveHandler=function(){if(!(configs.active&&configs.pointerEnabled)){return;}if(!mouseDownLeft&&!mouseDownMiddle&&!mouseDownRight){return;}// Scaling drag-rotate to canvas boundary
|
|
22370
|
-
var canvasBoundary=scene.canvas.boundary;var canvasWidth=canvasBoundary[2];var canvasHeight=canvasBoundary[3];var x=states.pointerCanvasPos[0];var y=states.pointerCanvasPos[1];var panning=keyDown[scene.input.KEY_SHIFT]||configs.planView||!configs.panRightClick&&mouseDownMiddle||configs.panRightClick&&mouseDownRight;
|
|
22371
|
-
if(camera.projection==="perspective"){var depth=Math.abs(mouseDownPicked?math.lenVec3(math.subVec3(pickedWorldPos,scene.camera.eye,[])):scene.camera.eyeLookDist);var targetDistance=depth*Math.tan(camera.perspective.fov/2*Math.PI/180.0);updates.panDeltaX+=1.5*
|
|
22372
|
-
if(configs.firstPerson){updates.rotateDeltaY-=
|
|
22369
|
+
mouseDownRight=true;if(configs.panRightClick){setMousedownState();}break;}});document.addEventListener("mousemove",this._documentMouseMoveHandler=function(e){if(!(configs.active&&configs.pointerEnabled)){return;}if(!mouseDownLeft&&!mouseDownMiddle&&!mouseDownRight){return;}// Scaling drag-rotate to canvas boundary
|
|
22370
|
+
var canvasBoundary=scene.canvas.boundary;var canvasWidth=canvasBoundary[2];var canvasHeight=canvasBoundary[3];var x=states.pointerCanvasPos[0];var y=states.pointerCanvasPos[1];var panning=keyDown[scene.input.KEY_SHIFT]||configs.planView||!configs.panRightClick&&mouseDownMiddle||configs.panRightClick&&mouseDownRight;var xDelta=document.pointerLockElement?e.movementX:x-lastX;var yDelta=document.pointerLockElement?e.movementY:y-lastY;if(panning){var camera=scene.camera;// We use only canvasHeight here so that aspect ratio does not distort speed
|
|
22371
|
+
if(camera.projection==="perspective"){var depth=Math.abs(mouseDownPicked?math.lenVec3(math.subVec3(pickedWorldPos,scene.camera.eye,[])):scene.camera.eyeLookDist);var targetDistance=depth*Math.tan(camera.perspective.fov/2*Math.PI/180.0);updates.panDeltaX+=1.5*xDelta*targetDistance/canvasHeight;updates.panDeltaY+=1.5*yDelta*targetDistance/canvasHeight;}else{updates.panDeltaX+=0.5*camera.ortho.scale*(xDelta/canvasHeight);updates.panDeltaY+=0.5*camera.ortho.scale*(yDelta/canvasHeight);}}else if(mouseDownLeft&&!mouseDownMiddle&&!mouseDownRight){if(!configs.planView){// No rotating in plan-view mode
|
|
22372
|
+
if(configs.firstPerson){updates.rotateDeltaY-=xDelta/canvasWidth*configs.dragRotationRate/2;updates.rotateDeltaX+=yDelta/canvasHeight*(configs.dragRotationRate/4);}else{updates.rotateDeltaY-=xDelta/canvasWidth*(configs.dragRotationRate*1.5);updates.rotateDeltaX+=yDelta/canvasHeight*(configs.dragRotationRate*1.5);}}}lastX=x;lastY=y;});canvas.addEventListener("mousemove",this._canvasMouseMoveHandler=function(e){if(!(configs.active&&configs.pointerEnabled)){return;}if(!states.mouseover){return;}mouseMovedOnCanvasSinceLastWheel=true;});document.addEventListener("mouseup",this._documentMouseUpHandler=function(e){if(!(configs.active&&configs.pointerEnabled)){return;}switch(e.which){case 1:// Left button
|
|
22373
22373
|
mouseDownLeft=false;mouseDownMiddle=false;mouseDownRight=false;break;case 2:// Middle/both buttons
|
|
22374
22374
|
mouseDownLeft=false;mouseDownMiddle=false;mouseDownRight=false;break;case 3:// Right button
|
|
22375
22375
|
mouseDownLeft=false;mouseDownMiddle=false;mouseDownRight=false;break;}});canvas.addEventListener("mouseup",this._mouseUpHandler=function(e){if(!(configs.active&&configs.pointerEnabled)){return;}switch(e.which){case 3:// Right button
|
|
@@ -24460,7 +24460,7 @@ for(var _i492=0,len=plugins.length;_i492<len;_i492++){var plugin=plugins[_i492];
|
|
|
24460
24460
|
sceneModel.fire("loaded",true,false);});if(ok){ok();}},function(msg){plugin.error(msg);if(error){error(msg);}sceneModel.fire("error",msg);});}},{key:"parse",value:function parse(plugin,gltf,metaModelJSON,options,sceneModel,ok,error){options=options||{};parseGLTF(plugin,"",gltf,metaModelJSON,options,sceneModel,function(){sceneModel.scene.fire("modelLoaded",sceneModel.id);// FIXME: Assumes listeners know order of these two events
|
|
24461
24461
|
sceneModel.fire("loaded",true,false);if(ok){ok();}});}}]);return GLTFSceneModelLoader;}();function getMetaModelCorrections(metaModelJSON){var eachRootStats={};var eachChildRoot={};var metaObjects=metaModelJSON.metaObjects||[];var metaObjectsMap={};for(var _i508=0,len=metaObjects.length;_i508<len;_i508++){var metaObject=metaObjects[_i508];metaObjectsMap[metaObject.id]=metaObject;}for(var _i509=0,_len108=metaObjects.length;_i509<_len108;_i509++){var _metaObject12=metaObjects[_i509];if(_metaObject12.parent!==undefined&&_metaObject12.parent!==null){var metaObjectParent=metaObjectsMap[_metaObject12.parent];if(_metaObject12.type===metaObjectParent.type){var rootMetaObject=metaObjectParent;while(rootMetaObject.parent&&metaObjectsMap[rootMetaObject.parent].type===rootMetaObject.type){rootMetaObject=metaObjectsMap[rootMetaObject.parent];}var rootStats=eachRootStats[rootMetaObject.id]||(eachRootStats[rootMetaObject.id]={numChildren:0,countChildren:0});rootStats.numChildren++;eachChildRoot[_metaObject12.id]=rootMetaObject;}}}return{metaObjectsMap:metaObjectsMap,eachRootStats:eachRootStats,eachChildRoot:eachChildRoot};}function loadGLTF(plugin,src,metaModelJSON,options,sceneModel,ok,error){var spinner=plugin.viewer.scene.canvas.spinner;spinner.processes++;var isGLB=src.split('.').pop()==="glb";if(isGLB){plugin.dataSource.getGLB(src,function(arrayBuffer){// OK
|
|
24462
24462
|
options.basePath=getBasePath(src);parseGLTF(plugin,src,arrayBuffer,metaModelJSON,options,sceneModel,ok);spinner.processes--;},function(err){spinner.processes--;error(err);});}else{plugin.dataSource.getGLTF(src,function(gltf){// OK
|
|
24463
|
-
options.basePath=getBasePath(src);parseGLTF(plugin,src,gltf,metaModelJSON,options,sceneModel,ok);spinner.processes--;},function(err){spinner.processes--;error(err);});}}function getBasePath(src){var i=src.lastIndexOf("/");return i!==0?src.substring(0,i+1):"";}function parseGLTF(plugin,src,gltf,metaModelJSON,options,sceneModel,ok){var spinner=plugin.viewer.scene.canvas.spinner;spinner.processes++;parse$3(gltf,GLTFLoader,{baseUri:options.basePath}).then(function(gltfData){var ctx={src:src,metaModelCorrections:metaModelJSON?getMetaModelCorrections(metaModelJSON):null,loadBuffer:options.loadBuffer,basePath:options.basePath,handlenode:options.handlenode,gltfData:gltfData,scene:sceneModel.scene,plugin:plugin,sceneModel:sceneModel,//geometryCreated: {},
|
|
24463
|
+
options.basePath=getBasePath(src);parseGLTF(plugin,src,gltf,metaModelJSON,options,sceneModel,ok);spinner.processes--;},function(err){spinner.processes--;error(err);});}}function getBasePath(src){var i=src.lastIndexOf("/");return i!==0?src.substring(0,i+1):"";}function parseGLTF(plugin,src,gltf,metaModelJSON,options,sceneModel,ok){var spinner=plugin.viewer.scene.canvas.spinner;spinner.processes++;parse$3(gltf,GLTFLoader,{baseUri:options.basePath}).then(function(gltfData){var ctx={src:src,metaModelCorrections:metaModelJSON?getMetaModelCorrections(metaModelJSON):null,loadBuffer:options.loadBuffer,basePath:options.basePath,handlenode:options.handlenode,backfaces:!!options.backfaces,gltfData:gltfData,scene:sceneModel.scene,plugin:plugin,sceneModel:sceneModel,//geometryCreated: {},
|
|
24464
24464
|
numObjects:0,nodes:[],nextId:0,log:function log(msg){plugin.log(msg);}};loadTextures(ctx);loadMaterials(ctx);loadDefaultScene(ctx);sceneModel.finalize();spinner.processes--;ok();});}function loadTextures(ctx){var gltfData=ctx.gltfData;var textures=gltfData.textures;if(textures){for(var _i510=0,len=textures.length;_i510<len;_i510++){loadTexture(ctx,textures[_i510]);}}}function loadTexture(ctx,texture){if(!texture.source||!texture.source.image){return;}var textureId="texture-".concat(ctx.nextId++);var minFilter=NearestMipMapLinearFilter;switch(texture.sampler.minFilter){case 9728:minFilter=NearestFilter;break;case 9729:minFilter=LinearFilter;break;case 9984:minFilter=NearestMipMapNearestFilter;break;case 9985:minFilter=LinearMipMapNearestFilter;break;case 9986:minFilter=NearestMipMapLinearFilter;break;case 9987:minFilter=LinearMipMapLinearFilter;break;}var magFilter=LinearFilter;switch(texture.sampler.magFilter){case 9728:magFilter=NearestFilter;break;case 9729:magFilter=LinearFilter;break;}var wrapS=RepeatWrapping;switch(texture.sampler.wrapS){case 33071:wrapS=ClampToEdgeWrapping;break;case 33648:wrapS=MirroredRepeatWrapping;break;case 10497:wrapS=RepeatWrapping;break;}var wrapT=RepeatWrapping;switch(texture.sampler.wrapT){case 33071:wrapT=ClampToEdgeWrapping;break;case 33648:wrapT=MirroredRepeatWrapping;break;case 10497:wrapT=RepeatWrapping;break;}var wrapR=RepeatWrapping;switch(texture.sampler.wrapR){case 33071:wrapR=ClampToEdgeWrapping;break;case 33648:wrapR=MirroredRepeatWrapping;break;case 10497:wrapR=RepeatWrapping;break;}ctx.sceneModel.createTexture({id:textureId,image:texture.source.image,flipY:!!texture.flipY,minFilter:minFilter,magFilter:magFilter,wrapS:wrapS,wrapT:wrapT,wrapR:wrapR,encoding:sRGBEncoding});texture._textureId=textureId;}function loadMaterials(ctx){var gltfData=ctx.gltfData;var materials=gltfData.materials;if(materials){for(var _i511=0,len=materials.length;_i511<len;_i511++){var material=materials[_i511];material._textureSetId=loadTextureSet(ctx,material);material._attributes=loadMaterialAttributes(ctx,material);}}}function loadTextureSet(ctx,material){var textureSetCfg={};if(material.normalTexture){textureSetCfg.normalTextureId=material.normalTexture.texture._textureId;}if(material.occlusionTexture){textureSetCfg.occlusionTextureId=material.occlusionTexture.texture._textureId;}if(material.emissiveTexture){textureSetCfg.emissiveTextureId=material.emissiveTexture.texture._textureId;}// const alphaMode = material.alphaMode;
|
|
24465
24465
|
// switch (alphaMode) {
|
|
24466
24466
|
// case "NORMAL_OPAQUE":
|
|
@@ -24479,15 +24479,15 @@ numObjects:0,nodes:[],nextId:0,log:function log(msg){plugin.log(msg);}};loadText
|
|
|
24479
24479
|
// materialCfg.alphaCutoff = alphaCutoff;
|
|
24480
24480
|
// }
|
|
24481
24481
|
var metallicPBR=material.pbrMetallicRoughness;if(material.pbrMetallicRoughness){var pbrMetallicRoughness=material.pbrMetallicRoughness;var baseColorTexture=pbrMetallicRoughness.baseColorTexture||pbrMetallicRoughness.colorTexture;if(baseColorTexture){if(baseColorTexture.texture){textureSetCfg.colorTextureId=baseColorTexture.texture._textureId;}else{textureSetCfg.colorTextureId=ctx.gltfData.textures[baseColorTexture.index]._textureId;}}if(metallicPBR.metallicRoughnessTexture){textureSetCfg.metallicRoughnessTextureId=metallicPBR.metallicRoughnessTexture.texture._textureId;}}var extensions=material.extensions;if(extensions){var specularPBR=extensions["KHR_materials_pbrSpecularGlossiness"];if(specularPBR){specularPBR.specularTexture;var specularColorTexture=specularPBR.specularColorTexture;if(specularColorTexture!==null&&specularColorTexture!==undefined){textureSetCfg.colorTextureId=ctx.gltfData.textures[specularColorTexture.index]._textureId;}}}if(textureSetCfg.normalTextureId!==undefined||textureSetCfg.occlusionTextureId!==undefined||textureSetCfg.emissiveTextureId!==undefined||textureSetCfg.colorTextureId!==undefined||textureSetCfg.metallicRoughnessTextureId!==undefined){textureSetCfg.id="textureSet-".concat(ctx.nextId++,";");ctx.sceneModel.createTextureSet(textureSetCfg);return textureSetCfg.id;}return null;}function loadMaterialAttributes(ctx,material){// Substitute RGBA for material, to use fast flat shading instead
|
|
24482
|
-
var extensions=material.extensions;var materialAttributes={color:new Float32Array([1,1,1,1]),opacity:1,metallic:0,roughness:1};if(extensions){var specularPBR=extensions["KHR_materials_pbrSpecularGlossiness"];if(specularPBR){var diffuseFactor=specularPBR.diffuseFactor;if(diffuseFactor!==null&&diffuseFactor!==undefined){materialAttributes.color.set(diffuseFactor);}}var common=extensions["KHR_materials_common"];if(common){var technique=common.technique;var values=common.values||{};var blinn=technique==="BLINN";var phong=technique==="PHONG";var lambert=technique==="LAMBERT";var diffuse=values.diffuse;if(diffuse&&(blinn||phong||lambert)){if(!utils.isString(diffuse)){materialAttributes.color.set(diffuse);}}var transparency=values.transparency;if(transparency!==null&&transparency!==undefined){materialAttributes.opacity=transparency;}var transparent=values.transparent;if(transparent!==null&&transparent!==undefined){materialAttributes.opacity=transparent;}}}var metallicPBR=material.pbrMetallicRoughness;if(metallicPBR){var baseColorFactor=metallicPBR.baseColorFactor;if(baseColorFactor){materialAttributes.color[0]=baseColorFactor[0];materialAttributes.color[1]=baseColorFactor[1];materialAttributes.color[2]=baseColorFactor[2];materialAttributes.opacity=baseColorFactor[3];}var metallicFactor=metallicPBR.metallicFactor;if(metallicFactor!==null&&metallicFactor!==undefined){materialAttributes.metallic=metallicFactor;}var roughnessFactor=metallicPBR.roughnessFactor;if(roughnessFactor!==null&&roughnessFactor!==undefined){materialAttributes.roughness=roughnessFactor;}}return materialAttributes;}function loadDefaultScene(ctx){var gltfData=ctx.gltfData;var scene=gltfData.scene||gltfData.scenes[0];if(!scene){error(ctx,"glTF has no default scene");return;}loadScene(ctx,scene);}function loadScene(ctx,scene){var nodes=scene.nodes;if(!nodes){return;}for(var _i512=0,len=nodes.length;_i512<len;_i512++){var _node6=nodes[_i512];countMeshUsage(ctx,_node6);}for(var _i513=0,_len109=nodes.length;_i513<_len109;_i513++){var _node7=nodes[_i513];loadNode(ctx,_node7,0,null);}}function countMeshUsage(ctx,node){var mesh=node.mesh;if(mesh){mesh.instances=mesh.instances?mesh.instances+1:1;}if(node.children){var children=node.children;for(var _i514=0,len=children.length;_i514<len;_i514++){var childNode=children[_i514];if(!childNode){error(ctx,"Node not found: "+_i514);continue;}countMeshUsage(ctx,childNode);}}}var deferredMeshIds=[];function loadNode(ctx,node,depth,matrix){ctx.gltfData;var localMatrix;if(node.matrix){localMatrix=node.matrix;if(matrix){matrix=math.mulMat4(matrix,localMatrix,math.mat4());}else{matrix=localMatrix;}}if(node.translation){localMatrix=math.translationMat4v(node.translation);if(matrix){matrix=math.mulMat4(matrix,localMatrix,math.mat4());}else{matrix=localMatrix;}}if(node.rotation){localMatrix=math.quaternionToMat4(node.rotation);if(matrix){matrix=math.mulMat4(matrix,localMatrix,math.mat4());}else{matrix=localMatrix;}}if(node.scale){localMatrix=math.scalingMat4v(node.scale);if(matrix){matrix=math.mulMat4(matrix,localMatrix,math.mat4());}else{matrix=localMatrix;}}var sceneModel=ctx.sceneModel;if(node.mesh){var _mesh6=node.mesh;if(ctx.handlenode){var actions={};if(!ctx.handlenode(ctx.sceneModel.id,node,actions)){return;}if(actions.createEntity);}var worldMatrix=matrix?matrix.slice():math.identityMat4();var numPrimitives=_mesh6.primitives.length;if(numPrimitives>0){for(var _i515=0;_i515<numPrimitives;_i515++){var _primitive4=_mesh6.primitives[_i515];if(_primitive4.mode<4){continue;}var meshCfg={id:sceneModel.id+"."+ctx.numObjects++};switch(_primitive4.mode){case 0:// POINTS
|
|
24482
|
+
var extensions=material.extensions;var materialAttributes={color:new Float32Array([1,1,1,1]),opacity:1,metallic:0,roughness:1,doubleSided:true};if(extensions){var specularPBR=extensions["KHR_materials_pbrSpecularGlossiness"];if(specularPBR){var diffuseFactor=specularPBR.diffuseFactor;if(diffuseFactor!==null&&diffuseFactor!==undefined){materialAttributes.color.set(diffuseFactor);}}var common=extensions["KHR_materials_common"];if(common){var technique=common.technique;var values=common.values||{};var blinn=technique==="BLINN";var phong=technique==="PHONG";var lambert=technique==="LAMBERT";var diffuse=values.diffuse;if(diffuse&&(blinn||phong||lambert)){if(!utils.isString(diffuse)){materialAttributes.color.set(diffuse);}}var transparency=values.transparency;if(transparency!==null&&transparency!==undefined){materialAttributes.opacity=transparency;}var transparent=values.transparent;if(transparent!==null&&transparent!==undefined){materialAttributes.opacity=transparent;}}}var metallicPBR=material.pbrMetallicRoughness;if(metallicPBR){var baseColorFactor=metallicPBR.baseColorFactor;if(baseColorFactor){materialAttributes.color[0]=baseColorFactor[0];materialAttributes.color[1]=baseColorFactor[1];materialAttributes.color[2]=baseColorFactor[2];materialAttributes.opacity=baseColorFactor[3];}var metallicFactor=metallicPBR.metallicFactor;if(metallicFactor!==null&&metallicFactor!==undefined){materialAttributes.metallic=metallicFactor;}var roughnessFactor=metallicPBR.roughnessFactor;if(roughnessFactor!==null&&roughnessFactor!==undefined){materialAttributes.roughness=roughnessFactor;}}materialAttributes.doubleSided=material.doubleSided!==false;return materialAttributes;}function loadDefaultScene(ctx){var gltfData=ctx.gltfData;var scene=gltfData.scene||gltfData.scenes[0];if(!scene){error(ctx,"glTF has no default scene");return;}loadScene(ctx,scene);}function loadScene(ctx,scene){var nodes=scene.nodes;if(!nodes){return;}for(var _i512=0,len=nodes.length;_i512<len;_i512++){var _node6=nodes[_i512];countMeshUsage(ctx,_node6);}for(var _i513=0,_len109=nodes.length;_i513<_len109;_i513++){var _node7=nodes[_i513];loadNode(ctx,_node7,0,null);}}function countMeshUsage(ctx,node){var mesh=node.mesh;if(mesh){mesh.instances=mesh.instances?mesh.instances+1:1;}if(node.children){var children=node.children;for(var _i514=0,len=children.length;_i514<len;_i514++){var childNode=children[_i514];if(!childNode){error(ctx,"Node not found: "+_i514);continue;}countMeshUsage(ctx,childNode);}}}var deferredMeshIds=[];function loadNode(ctx,node,depth,matrix){ctx.gltfData;var localMatrix;if(node.matrix){localMatrix=node.matrix;if(matrix){matrix=math.mulMat4(matrix,localMatrix,math.mat4());}else{matrix=localMatrix;}}if(node.translation){localMatrix=math.translationMat4v(node.translation);if(matrix){matrix=math.mulMat4(matrix,localMatrix,math.mat4());}else{matrix=localMatrix;}}if(node.rotation){localMatrix=math.quaternionToMat4(node.rotation);if(matrix){matrix=math.mulMat4(matrix,localMatrix,math.mat4());}else{matrix=localMatrix;}}if(node.scale){localMatrix=math.scalingMat4v(node.scale);if(matrix){matrix=math.mulMat4(matrix,localMatrix,math.mat4());}else{matrix=localMatrix;}}var sceneModel=ctx.sceneModel;if(node.mesh){var _mesh6=node.mesh;if(ctx.handlenode){var actions={};if(!ctx.handlenode(ctx.sceneModel.id,node,actions)){return;}if(actions.createEntity);}var worldMatrix=matrix?matrix.slice():math.identityMat4();var numPrimitives=_mesh6.primitives.length;if(numPrimitives>0){for(var _i515=0;_i515<numPrimitives;_i515++){var _primitive4=_mesh6.primitives[_i515];if(_primitive4.mode<4){continue;}var meshCfg={id:sceneModel.id+"."+ctx.numObjects++};var material=_primitive4.material;if(material){meshCfg.textureSetId=material._textureSetId;meshCfg.color=material._attributes.color;meshCfg.opacity=material._attributes.opacity;meshCfg.metallic=material._attributes.metallic;meshCfg.roughness=material._attributes.roughness;}else{meshCfg.color=new Float32Array([1.0,1.0,1.0]);meshCfg.opacity=1.0;}var backfaces=ctx.backfaces!==false||material.doubleSided!==false;switch(_primitive4.mode){case 0:// POINTS
|
|
24483
24483
|
meshCfg.primitive="points";break;case 1:// LINES
|
|
24484
24484
|
meshCfg.primitive="lines";break;case 2:// LINE_LOOP
|
|
24485
24485
|
meshCfg.primitive="lines";break;case 3:// LINE_STRIP
|
|
24486
24486
|
meshCfg.primitive="lines";break;case 4:// TRIANGLES
|
|
24487
|
-
meshCfg.primitive="triangles";break;case 5:// TRIANGLE_STRIP
|
|
24488
|
-
meshCfg.primitive="triangles";break;case 6:// TRIANGLE_FAN
|
|
24489
|
-
meshCfg.primitive="triangles";break;default:meshCfg.primitive="triangles";}var POSITION=_primitive4.attributes.POSITION;if(!POSITION){continue;}meshCfg.localPositions=POSITION.value;meshCfg.positions=new Float64Array(meshCfg.localPositions.length);if(_primitive4.attributes.NORMAL){meshCfg.normals=_primitive4.attributes.NORMAL.value;}if(_primitive4.attributes.TEXCOORD_0){meshCfg.uv=_primitive4.attributes.TEXCOORD_0.value;}if(_primitive4.indices){meshCfg.indices=_primitive4.indices.value;}math.transformPositions3(worldMatrix,meshCfg.localPositions,meshCfg.positions);var origin=math.vec3();var rtcNeeded=worldToRTCPositions(meshCfg.positions,meshCfg.positions,origin);// Small cellsize guarantees better accuracy
|
|
24490
|
-
if(rtcNeeded){meshCfg.origin=origin;}
|
|
24487
|
+
meshCfg.primitive=backfaces?"triangles":"solid";break;case 5:// TRIANGLE_STRIP
|
|
24488
|
+
meshCfg.primitive=backfaces?"triangles":"solid";break;case 6:// TRIANGLE_FAN
|
|
24489
|
+
meshCfg.primitive=backfaces?"triangles":"solid";break;default:meshCfg.primitive=backfaces?"triangles":"solid";}var POSITION=_primitive4.attributes.POSITION;if(!POSITION){continue;}meshCfg.localPositions=POSITION.value;meshCfg.positions=new Float64Array(meshCfg.localPositions.length);if(_primitive4.attributes.NORMAL){meshCfg.normals=_primitive4.attributes.NORMAL.value;}if(_primitive4.attributes.TEXCOORD_0){meshCfg.uv=_primitive4.attributes.TEXCOORD_0.value;}if(_primitive4.indices){meshCfg.indices=_primitive4.indices.value;}math.transformPositions3(worldMatrix,meshCfg.localPositions,meshCfg.positions);var origin=math.vec3();var rtcNeeded=worldToRTCPositions(meshCfg.positions,meshCfg.positions,origin);// Small cellsize guarantees better accuracy
|
|
24490
|
+
if(rtcNeeded){meshCfg.origin=origin;}// if (createEntity) {
|
|
24491
24491
|
// if (createEntity.colorize) {
|
|
24492
24492
|
// meshCfg.color = createEntity.colorize;
|
|
24493
24493
|
// }
|
|
@@ -24731,7 +24731,7 @@ sceneModel.createEntity({id:entityId,meshIds:deferredMeshIds});deferredMeshIds.l
|
|
|
24731
24731
|
* @param {Boolean} [params.saoEnabled=true] Indicates if Scalable Ambient Obscurance (SAO) is enabled for the model. SAO is configured by the Scene's {@link SAO} component. Only works when {@link SAO#enabled} is also ````true````
|
|
24732
24732
|
* @param {Boolean} [params.pbrEnabled=true] Indicates if physically-based rendering (PBR) is enabled for the model. Overrides ````colorTextureEnabled````. Only works when {@link Scene#pbrEnabled} is also ````true````.
|
|
24733
24733
|
* @param {Boolean} [params.colorTextureEnabled=true] Indicates if base color texture rendering is enabled for the model. Overridden by ````pbrEnabled````. Only works when {@link Scene#colorTextureEnabled} is also ````true````.
|
|
24734
|
-
* @param {Boolean} [params.backfaces=
|
|
24734
|
+
* @param {Boolean} [params.backfaces=true] When true, always show backfaces, even on objects for which the glTF material is single-sided. When false, only show backfaces on geometries whenever the glTF material is double-sided.
|
|
24735
24735
|
* @param {Number} [params.edgeThreshold=10] When xraying, highlighting, selecting or edging, this is the threshold angle between normals of adjacent triangles, below which their shared wireframe edge is not drawn.
|
|
24736
24736
|
* @param {Boolean} [params.dtxEnabled=true] When ````true```` (default) use data textures (DTX), where appropriate, to
|
|
24737
24737
|
* represent the returned model. Set false to always use vertex buffer objects (VBOs). Note that DTX is only applicable
|
|
@@ -25169,7 +25169,7 @@ this._ignoreNextSectionPlaneDirUpdate=false;this._createNodes();this._bindEvents
|
|
|
25169
25169
|
*/},{key:"setCulled",value:function setCulled(culled){var id;for(id in this._displayMeshes){if(this._displayMeshes.hasOwnProperty(id)){this._displayMeshes[id].culled=culled;}}if(!culled){for(id in this._affordanceMeshes){if(this._affordanceMeshes.hasOwnProperty(id)){this._affordanceMeshes[id].culled=culled;}}}}/**
|
|
25170
25170
|
* Builds the Entities that represent this Control.
|
|
25171
25171
|
* @private
|
|
25172
|
-
*/},{key:"_createNodes",value:function _createNodes(){var NO_STATE_INHERIT=false;var scene=this._viewer.scene;var radius=1.0;var handleTubeRadius=0.06;var hoopRadius=radius-0.2;var tubeRadius=0.01;var arrowRadius=0.07;this._rootNode=new Node$2(scene,{position:[0,0,0],scale:[5,5,5]});var rootNode=this._rootNode;var shapes={// Reusable geometries
|
|
25172
|
+
*/},{key:"_createNodes",value:function _createNodes(){var NO_STATE_INHERIT=false;var scene=this._viewer.scene;var radius=1.0;var handleTubeRadius=0.06;var hoopRadius=radius-0.2;var tubeRadius=0.01;var arrowRadius=0.07;this._rootNode=new Node$2(scene,{position:[0,0,0],scale:[5,5,5],isObject:false});var rootNode=this._rootNode;var shapes={// Reusable geometries
|
|
25173
25173
|
arrowHead:new ReadableGeometry(rootNode,buildCylinderGeometry({radiusTop:0.001,radiusBottom:arrowRadius,radialSegments:32,heightSegments:1,height:0.2,openEnded:false})),arrowHeadBig:new ReadableGeometry(rootNode,buildCylinderGeometry({radiusTop:0.001,radiusBottom:0.09,radialSegments:32,heightSegments:1,height:0.25,openEnded:false})),arrowHeadHandle:new ReadableGeometry(rootNode,buildCylinderGeometry({radiusTop:0.09,radiusBottom:0.09,radialSegments:8,heightSegments:1,height:0.37,openEnded:false})),curve:new ReadableGeometry(rootNode,buildTorusGeometry({radius:hoopRadius,tube:tubeRadius,radialSegments:64,tubeSegments:14,arc:Math.PI*2.0/4.0})),curveHandle:new ReadableGeometry(rootNode,buildTorusGeometry({radius:hoopRadius,tube:handleTubeRadius,radialSegments:64,tubeSegments:14,arc:Math.PI*2.0/4.0})),hoop:new ReadableGeometry(rootNode,buildTorusGeometry({radius:hoopRadius,tube:tubeRadius,radialSegments:64,tubeSegments:8,arc:Math.PI*2.0})),axis:new ReadableGeometry(rootNode,buildCylinderGeometry({radiusTop:tubeRadius,radiusBottom:tubeRadius,radialSegments:20,heightSegments:1,height:radius,openEnded:false})),axisHandle:new ReadableGeometry(rootNode,buildCylinderGeometry({radiusTop:0.08,radiusBottom:0.08,radialSegments:20,heightSegments:1,height:radius,openEnded:false}))};var materials={// Reusable materials
|
|
25174
25174
|
pickable:new PhongMaterial(rootNode,{// Invisible material for pickable handles, which define a pickable 3D area
|
|
25175
25175
|
diffuse:[1,1,0],alpha:0,// Invisible
|
|
@@ -25180,35 +25180,35 @@ edges:false,fill:true,fillColor:[0,0,1],fillAlpha:0.2}),center:new PhongMaterial
|
|
|
25180
25180
|
-0.5,-0.5,0.0,-0.5,0.5,0.0,// 1
|
|
25181
25181
|
0.5,0.5,-0.0,0.5,-0.5,-0.0,// 2
|
|
25182
25182
|
-0.5,-0.5,-0.0,-0.5,0.5,-0.0// 3
|
|
25183
|
-
],indices:[0,1,2,2,3,0]}),material:new PhongMaterial(rootNode,{emissive:[0,0.0,0],diffuse:[0,0,0],backfaces:true}),opacity:0.6,ghosted:true,ghostMaterial:new EmphasisMaterial(rootNode,{edges:false,filled:true,fillColor:[1,1,0],edgeColor:[0,0,0],fillAlpha:0.1,backfaces:true}),pickable:false,collidable:true,clippable:false,visible:false,scale:[2.4,2.4,1]}),NO_STATE_INHERIT),planeFrame:rootNode.addChild(new Mesh(rootNode,{// Visible frame
|
|
25183
|
+
],indices:[0,1,2,2,3,0]}),material:new PhongMaterial(rootNode,{emissive:[0,0.0,0],diffuse:[0,0,0],backfaces:true}),opacity:0.6,ghosted:true,ghostMaterial:new EmphasisMaterial(rootNode,{edges:false,filled:true,fillColor:[1,1,0],edgeColor:[0,0,0],fillAlpha:0.1,backfaces:true}),pickable:false,collidable:true,clippable:false,visible:false,scale:[2.4,2.4,1],isObject:false}),NO_STATE_INHERIT),planeFrame:rootNode.addChild(new Mesh(rootNode,{// Visible frame
|
|
25184
25184
|
geometry:new ReadableGeometry(rootNode,buildTorusGeometry({center:[0,0,0],radius:1.7,tube:tubeRadius*2,radialSegments:4,tubeSegments:4,arc:Math.PI*2.0})),material:new PhongMaterial(rootNode,{emissive:[0,0,0],diffuse:[0,0,0],specular:[0,0,0],shininess:0}),//highlighted: true,
|
|
25185
|
-
highlightMaterial:new EmphasisMaterial(rootNode,{edges:false,edgeColor:[0.0,0.0,0.0],filled:true,fillColor:[0.8,0.8,0.8],fillAlpha:1.0}),pickable:false,collidable:false,clippable:false,visible:false,scale:[1,1,.1],rotation:[0,0,45]}),NO_STATE_INHERIT),//----------------------------------------------------------------------------------------------------------
|
|
25185
|
+
highlightMaterial:new EmphasisMaterial(rootNode,{edges:false,edgeColor:[0.0,0.0,0.0],filled:true,fillColor:[0.8,0.8,0.8],fillAlpha:1.0}),pickable:false,collidable:false,clippable:false,visible:false,scale:[1,1,.1],rotation:[0,0,45],isObject:false}),NO_STATE_INHERIT),//----------------------------------------------------------------------------------------------------------
|
|
25186
25186
|
//
|
|
25187
25187
|
//----------------------------------------------------------------------------------------------------------
|
|
25188
25188
|
xCurve:rootNode.addChild(new Mesh(rootNode,{// Red hoop about Y-axis
|
|
25189
|
-
geometry:shapes.curve,material:materials.red,matrix:function(){var rotate2=math.rotationMat4v(90*math.DEGTORAD,[0,1,0],math.identityMat4());var rotate1=math.rotationMat4v(270*math.DEGTORAD,[1,0,0],math.identityMat4());return math.mulMat4(rotate1,rotate2,math.identityMat4());}(),pickable:false,collidable:true,clippable:false,backfaces:true,visible:false}),NO_STATE_INHERIT),xCurveHandle:rootNode.addChild(new Mesh(rootNode,{// Red hoop about Y-axis
|
|
25190
|
-
geometry:shapes.curveHandle,material:materials.pickable,matrix:function(){var rotate2=math.rotationMat4v(90*math.DEGTORAD,[0,1,0],math.identityMat4());var rotate1=math.rotationMat4v(270*math.DEGTORAD,[1,0,0],math.identityMat4());return math.mulMat4(rotate1,rotate2,math.identityMat4());}(),pickable:true,collidable:true,clippable:false,backfaces:true,visible:false}),NO_STATE_INHERIT),xCurveArrow1:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHead,material:materials.red,matrix:function(){var translate=math.translateMat4c(0.,-0.07,-0.8,math.identityMat4());var scale=math.scaleMat4v([0.6,0.6,0.6],math.identityMat4());var rotate=math.rotationMat4v(0*math.DEGTORAD,[0,0,1],math.identityMat4());return math.mulMat4(math.mulMat4(translate,scale,math.identityMat4()),rotate,math.identityMat4());}(),pickable:true,collidable:true,clippable:false,visible:false}),NO_STATE_INHERIT),xCurveArrow2:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHead,material:materials.red,matrix:function(){var translate=math.translateMat4c(0.0,-0.8,-0.07,math.identityMat4());var scale=math.scaleMat4v([0.6,0.6,0.6],math.identityMat4());var rotate=math.rotationMat4v(90*math.DEGTORAD,[1,0,0],math.identityMat4());return math.mulMat4(math.mulMat4(translate,scale,math.identityMat4()),rotate,math.identityMat4());}(),pickable:true,collidable:true,clippable:false,visible:false}),NO_STATE_INHERIT),//----------------------------------------------------------------------------------------------------------
|
|
25189
|
+
geometry:shapes.curve,material:materials.red,matrix:function(){var rotate2=math.rotationMat4v(90*math.DEGTORAD,[0,1,0],math.identityMat4());var rotate1=math.rotationMat4v(270*math.DEGTORAD,[1,0,0],math.identityMat4());return math.mulMat4(rotate1,rotate2,math.identityMat4());}(),pickable:false,collidable:true,clippable:false,backfaces:true,visible:false,isObject:false}),NO_STATE_INHERIT),xCurveHandle:rootNode.addChild(new Mesh(rootNode,{// Red hoop about Y-axis
|
|
25190
|
+
geometry:shapes.curveHandle,material:materials.pickable,matrix:function(){var rotate2=math.rotationMat4v(90*math.DEGTORAD,[0,1,0],math.identityMat4());var rotate1=math.rotationMat4v(270*math.DEGTORAD,[1,0,0],math.identityMat4());return math.mulMat4(rotate1,rotate2,math.identityMat4());}(),pickable:true,collidable:true,clippable:false,backfaces:true,visible:false,isObject:false}),NO_STATE_INHERIT),xCurveArrow1:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHead,material:materials.red,matrix:function(){var translate=math.translateMat4c(0.,-0.07,-0.8,math.identityMat4());var scale=math.scaleMat4v([0.6,0.6,0.6],math.identityMat4());var rotate=math.rotationMat4v(0*math.DEGTORAD,[0,0,1],math.identityMat4());return math.mulMat4(math.mulMat4(translate,scale,math.identityMat4()),rotate,math.identityMat4());}(),pickable:true,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT),xCurveArrow2:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHead,material:materials.red,matrix:function(){var translate=math.translateMat4c(0.0,-0.8,-0.07,math.identityMat4());var scale=math.scaleMat4v([0.6,0.6,0.6],math.identityMat4());var rotate=math.rotationMat4v(90*math.DEGTORAD,[1,0,0],math.identityMat4());return math.mulMat4(math.mulMat4(translate,scale,math.identityMat4()),rotate,math.identityMat4());}(),pickable:true,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT),//----------------------------------------------------------------------------------------------------------
|
|
25191
25191
|
//
|
|
25192
25192
|
//----------------------------------------------------------------------------------------------------------
|
|
25193
|
-
yCurve:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.curve,material:materials.green,rotation:[-90,0,0],pickable:false,collidable:true,clippable:false,backfaces:true,visible:false}),NO_STATE_INHERIT),yCurveHandle:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.curveHandle,material:materials.pickable,rotation:[-90,0,0],pickable:true,collidable:true,clippable:false,backfaces:true,visible:false}),NO_STATE_INHERIT),yCurveArrow1:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHead,material:materials.green,matrix:function(){var translate=math.translateMat4c(0.07,0,-0.8,math.identityMat4());var scale=math.scaleMat4v([0.6,0.6,0.6],math.identityMat4());var rotate=math.rotationMat4v(90*math.DEGTORAD,[0,0,1],math.identityMat4());return math.mulMat4(math.mulMat4(translate,scale,math.identityMat4()),rotate,math.identityMat4());}(),pickable:true,collidable:true,clippable:false,visible:false}),NO_STATE_INHERIT),yCurveArrow2:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHead,material:materials.green,matrix:function(){var translate=math.translateMat4c(0.8,0.0,-0.07,math.identityMat4());var scale=math.scaleMat4v([0.6,0.6,0.6],math.identityMat4());var rotate=math.rotationMat4v(90*math.DEGTORAD,[1,0,0],math.identityMat4());return math.mulMat4(math.mulMat4(translate,scale,math.identityMat4()),rotate,math.identityMat4());}(),pickable:true,collidable:true,clippable:false,visible:false}),NO_STATE_INHERIT),//----------------------------------------------------------------------------------------------------------
|
|
25193
|
+
yCurve:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.curve,material:materials.green,rotation:[-90,0,0],pickable:false,collidable:true,clippable:false,backfaces:true,visible:false,isObject:false}),NO_STATE_INHERIT),yCurveHandle:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.curveHandle,material:materials.pickable,rotation:[-90,0,0],pickable:true,collidable:true,clippable:false,backfaces:true,visible:false,isObject:false}),NO_STATE_INHERIT),yCurveArrow1:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHead,material:materials.green,matrix:function(){var translate=math.translateMat4c(0.07,0,-0.8,math.identityMat4());var scale=math.scaleMat4v([0.6,0.6,0.6],math.identityMat4());var rotate=math.rotationMat4v(90*math.DEGTORAD,[0,0,1],math.identityMat4());return math.mulMat4(math.mulMat4(translate,scale,math.identityMat4()),rotate,math.identityMat4());}(),pickable:true,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT),yCurveArrow2:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHead,material:materials.green,matrix:function(){var translate=math.translateMat4c(0.8,0.0,-0.07,math.identityMat4());var scale=math.scaleMat4v([0.6,0.6,0.6],math.identityMat4());var rotate=math.rotationMat4v(90*math.DEGTORAD,[1,0,0],math.identityMat4());return math.mulMat4(math.mulMat4(translate,scale,math.identityMat4()),rotate,math.identityMat4());}(),pickable:true,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT),//----------------------------------------------------------------------------------------------------------
|
|
25194
25194
|
//
|
|
25195
25195
|
//----------------------------------------------------------------------------------------------------------
|
|
25196
25196
|
zCurve:rootNode.addChild(new Mesh(rootNode,{// Blue hoop about Z-axis
|
|
25197
|
-
geometry:shapes.curve,material:materials.blue,matrix:math.rotationMat4v(180*math.DEGTORAD,[1,0,0],math.identityMat4()),pickable:false,collidable:true,clippable:false,visible:false}),NO_STATE_INHERIT),zCurveHandle:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.curveHandle,material:materials.pickable,matrix:math.rotationMat4v(180*math.DEGTORAD,[1,0,0],math.identityMat4()),pickable:true,collidable:true,clippable:false,visible:false}),NO_STATE_INHERIT),zCurveCurveArrow1:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHead,material:materials.blue,matrix:function(){var translate=math.translateMat4c(.8,-0.07,0,math.identityMat4());var scale=math.scaleMat4v([0.6,0.6,0.6],math.identityMat4());return math.mulMat4(translate,scale,math.identityMat4());}(),pickable:true,collidable:true,clippable:false,visible:false}),NO_STATE_INHERIT),zCurveArrow2:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHead,material:materials.blue,matrix:function(){var translate=math.translateMat4c(.05,-0.8,0,math.identityMat4());var scale=math.scaleMat4v([0.6,0.6,0.6],math.identityMat4());var rotate=math.rotationMat4v(90*math.DEGTORAD,[0,0,1],math.identityMat4());return math.mulMat4(math.mulMat4(translate,scale,math.identityMat4()),rotate,math.identityMat4());}(),pickable:true,collidable:true,clippable:false,visible:false}),NO_STATE_INHERIT),//----------------------------------------------------------------------------------------------------------
|
|
25197
|
+
geometry:shapes.curve,material:materials.blue,matrix:math.rotationMat4v(180*math.DEGTORAD,[1,0,0],math.identityMat4()),pickable:false,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT),zCurveHandle:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.curveHandle,material:materials.pickable,matrix:math.rotationMat4v(180*math.DEGTORAD,[1,0,0],math.identityMat4()),pickable:true,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT),zCurveCurveArrow1:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHead,material:materials.blue,matrix:function(){var translate=math.translateMat4c(.8,-0.07,0,math.identityMat4());var scale=math.scaleMat4v([0.6,0.6,0.6],math.identityMat4());return math.mulMat4(translate,scale,math.identityMat4());}(),pickable:true,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT),zCurveArrow2:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHead,material:materials.blue,matrix:function(){var translate=math.translateMat4c(.05,-0.8,0,math.identityMat4());var scale=math.scaleMat4v([0.6,0.6,0.6],math.identityMat4());var rotate=math.rotationMat4v(90*math.DEGTORAD,[0,0,1],math.identityMat4());return math.mulMat4(math.mulMat4(translate,scale,math.identityMat4()),rotate,math.identityMat4());}(),pickable:true,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT),//----------------------------------------------------------------------------------------------------------
|
|
25198
25198
|
//
|
|
25199
25199
|
//----------------------------------------------------------------------------------------------------------
|
|
25200
|
-
center:rootNode.addChild(new Mesh(rootNode,{geometry:new ReadableGeometry(rootNode,buildSphereGeometry({radius:0.05})),material:materials.center,pickable:false,collidable:true,clippable:false,visible:false}),NO_STATE_INHERIT),//----------------------------------------------------------------------------------------------------------
|
|
25200
|
+
center:rootNode.addChild(new Mesh(rootNode,{geometry:new ReadableGeometry(rootNode,buildSphereGeometry({radius:0.05})),material:materials.center,pickable:false,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT),//----------------------------------------------------------------------------------------------------------
|
|
25201
25201
|
//
|
|
25202
25202
|
//----------------------------------------------------------------------------------------------------------
|
|
25203
|
-
xAxisArrow:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHead,material:materials.red,matrix:function(){var translate=math.translateMat4c(0,radius+.1,0,math.identityMat4());var rotate=math.rotationMat4v(-90*math.DEGTORAD,[0,0,1],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),pickable:false,collidable:true,clippable:false,visible:false}),NO_STATE_INHERIT),xAxisArrowHandle:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHeadHandle,material:materials.pickable,matrix:function(){var translate=math.translateMat4c(0,radius+.1,0,math.identityMat4());var rotate=math.rotationMat4v(-90*math.DEGTORAD,[0,0,1],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),pickable:true,collidable:true,clippable:false,visible:false}),NO_STATE_INHERIT),xAxis:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.axis,material:materials.red,matrix:function(){var translate=math.translateMat4c(0,radius/2,0,math.identityMat4());var rotate=math.rotationMat4v(-90*math.DEGTORAD,[0,0,1],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),pickable:false,collidable:true,clippable:false,visible:false}),NO_STATE_INHERIT),xAxisHandle:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.axisHandle,material:materials.pickable,matrix:function(){var translate=math.translateMat4c(0,radius/2,0,math.identityMat4());var rotate=math.rotationMat4v(-90*math.DEGTORAD,[0,0,1],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),pickable:true,collidable:true,clippable:false,visible:false}),NO_STATE_INHERIT),//----------------------------------------------------------------------------------------------------------
|
|
25203
|
+
xAxisArrow:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHead,material:materials.red,matrix:function(){var translate=math.translateMat4c(0,radius+.1,0,math.identityMat4());var rotate=math.rotationMat4v(-90*math.DEGTORAD,[0,0,1],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),pickable:false,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT),xAxisArrowHandle:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHeadHandle,material:materials.pickable,matrix:function(){var translate=math.translateMat4c(0,radius+.1,0,math.identityMat4());var rotate=math.rotationMat4v(-90*math.DEGTORAD,[0,0,1],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),pickable:true,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT),xAxis:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.axis,material:materials.red,matrix:function(){var translate=math.translateMat4c(0,radius/2,0,math.identityMat4());var rotate=math.rotationMat4v(-90*math.DEGTORAD,[0,0,1],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),pickable:false,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT),xAxisHandle:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.axisHandle,material:materials.pickable,matrix:function(){var translate=math.translateMat4c(0,radius/2,0,math.identityMat4());var rotate=math.rotationMat4v(-90*math.DEGTORAD,[0,0,1],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),pickable:true,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT),//----------------------------------------------------------------------------------------------------------
|
|
25204
25204
|
//
|
|
25205
25205
|
//----------------------------------------------------------------------------------------------------------
|
|
25206
|
-
yAxisArrow:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHead,material:materials.green,matrix:function(){var translate=math.translateMat4c(0,radius+.1,0,math.identityMat4());var rotate=math.rotationMat4v(180*math.DEGTORAD,[1,0,0],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),pickable:false,collidable:true,clippable:false,visible:false}),NO_STATE_INHERIT),yAxisArrowHandle:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHeadHandle,material:materials.pickable,matrix:function(){var translate=math.translateMat4c(0,radius+.1,0,math.identityMat4());var rotate=math.rotationMat4v(180*math.DEGTORAD,[1,0,0],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),pickable:true,collidable:true,clippable:false,visible:false,opacity:0.2}),NO_STATE_INHERIT),yShaft:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.axis,material:materials.green,position:[0,-radius/2,0],pickable:false,collidable:true,clippable:false,visible:false}),NO_STATE_INHERIT),yShaftHandle:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.axisHandle,material:materials.pickable,position:[0,-radius/2,0],pickable:true,collidable:true,clippable:false,visible:false}),NO_STATE_INHERIT),//----------------------------------------------------------------------------------------------------------
|
|
25206
|
+
yAxisArrow:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHead,material:materials.green,matrix:function(){var translate=math.translateMat4c(0,radius+.1,0,math.identityMat4());var rotate=math.rotationMat4v(180*math.DEGTORAD,[1,0,0],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),pickable:false,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT),yAxisArrowHandle:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHeadHandle,material:materials.pickable,matrix:function(){var translate=math.translateMat4c(0,radius+.1,0,math.identityMat4());var rotate=math.rotationMat4v(180*math.DEGTORAD,[1,0,0],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),pickable:true,collidable:true,clippable:false,visible:false,opacity:0.2,isObject:false}),NO_STATE_INHERIT),yShaft:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.axis,material:materials.green,position:[0,-radius/2,0],pickable:false,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT),yShaftHandle:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.axisHandle,material:materials.pickable,position:[0,-radius/2,0],pickable:true,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT),//----------------------------------------------------------------------------------------------------------
|
|
25207
25207
|
//
|
|
25208
25208
|
//----------------------------------------------------------------------------------------------------------
|
|
25209
|
-
zAxisArrow:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHead,material:materials.blue,matrix:function(){var translate=math.translateMat4c(0,radius+.1,0,math.identityMat4());var rotate=math.rotationMat4v(-90*math.DEGTORAD,[0.8,0,0],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),pickable:false,collidable:true,clippable:false,visible:false}),NO_STATE_INHERIT),zAxisArrowHandle:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHeadHandle,material:materials.pickable,matrix:function(){var translate=math.translateMat4c(0,radius+.1,0,math.identityMat4());var rotate=math.rotationMat4v(-90*math.DEGTORAD,[0.8,0,0],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),pickable:true,collidable:true,clippable:false,visible:false}),NO_STATE_INHERIT),zShaft:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.axis,material:materials.blue,matrix:function(){var translate=math.translateMat4c(0,radius/2,0,math.identityMat4());var rotate=math.rotationMat4v(-90*math.DEGTORAD,[1,0,0],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),clippable:false,pickable:false,collidable:true,visible:false}),NO_STATE_INHERIT),zAxisHandle:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.axisHandle,material:materials.pickable,matrix:function(){var translate=math.translateMat4c(0,radius/2,0,math.identityMat4());var rotate=math.rotationMat4v(-90*math.DEGTORAD,[1,0,0],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),clippable:false,pickable:true,collidable:true,visible:false}),NO_STATE_INHERIT)};this._affordanceMeshes={planeFrame:rootNode.addChild(new Mesh(rootNode,{geometry:new ReadableGeometry(rootNode,buildTorusGeometry({center:[0,0,0],radius:2,tube:tubeRadius,radialSegments:4,tubeSegments:4,arc:Math.PI*2.0})),material:new PhongMaterial(rootNode,{ambient:[1,1,1],diffuse:[0,0,0],emissive:[1,1,0]}),highlighted:true,highlightMaterial:new EmphasisMaterial(rootNode,{edges:false,filled:true,fillColor:[1,1,0],fillAlpha:1.0}),pickable:false,collidable:false,clippable:false,visible:false,scale:[1,1,1],rotation:[0,0,45]}),NO_STATE_INHERIT),xHoop:rootNode.addChild(new Mesh(rootNode,{// Full
|
|
25210
|
-
geometry:shapes.hoop,material:materials.red,highlighted:true,highlightMaterial:materials.highlightRed,matrix:function(){var rotate2=math.rotationMat4v(90*math.DEGTORAD,[0,1,0],math.identityMat4());var rotate1=math.rotationMat4v(270*math.DEGTORAD,[1,0,0],math.identityMat4());return math.mulMat4(rotate1,rotate2,math.identityMat4());}(),pickable:false,collidable:true,clippable:false,visible:false}),NO_STATE_INHERIT),yHoop:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.hoop,material:materials.green,highlighted:true,highlightMaterial:materials.highlightGreen,rotation:[-90,0,0],pickable:false,collidable:true,clippable:false,visible:false}),NO_STATE_INHERIT),zHoop:rootNode.addChild(new Mesh(rootNode,{// Blue hoop about Z-axis
|
|
25211
|
-
geometry:shapes.hoop,material:materials.blue,highlighted:true,highlightMaterial:materials.highlightBlue,matrix:math.rotationMat4v(180*math.DEGTORAD,[1,0,0],math.identityMat4()),pickable:false,collidable:true,clippable:false,backfaces:true,visible:false}),NO_STATE_INHERIT),xAxisArrow:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHeadBig,material:materials.red,matrix:function(){var translate=math.translateMat4c(0,radius+.1,0,math.identityMat4());var rotate=math.rotationMat4v(-90*math.DEGTORAD,[0,0,1],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),pickable:false,collidable:true,clippable:false,visible:false}),NO_STATE_INHERIT),yAxisArrow:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHeadBig,material:materials.green,matrix:function(){var translate=math.translateMat4c(0,radius+.1,0,math.identityMat4());var rotate=math.rotationMat4v(180*math.DEGTORAD,[1,0,0],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),pickable:false,collidable:true,clippable:false,visible:false}),NO_STATE_INHERIT),zAxisArrow:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHeadBig,material:materials.blue,matrix:function(){var translate=math.translateMat4c(0,radius+.1,0,math.identityMat4());var rotate=math.rotationMat4v(-90*math.DEGTORAD,[0.8,0,0],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),pickable:false,collidable:true,clippable:false,visible:false}),NO_STATE_INHERIT)};}},{key:"_bindEvents",value:function _bindEvents(){var _this133=this;var self=this;var grabbed=false;var DRAG_ACTIONS={none:-1,xTranslate:0,yTranslate:1,zTranslate:2,xRotate:3,yRotate:4,zRotate:5};var rootNode=this._rootNode;var nextDragAction=null;// As we hover grabbed an arrow or hoop, self is the action we would do if we then dragged it.
|
|
25209
|
+
zAxisArrow:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHead,material:materials.blue,matrix:function(){var translate=math.translateMat4c(0,radius+.1,0,math.identityMat4());var rotate=math.rotationMat4v(-90*math.DEGTORAD,[0.8,0,0],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),pickable:false,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT),zAxisArrowHandle:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHeadHandle,material:materials.pickable,matrix:function(){var translate=math.translateMat4c(0,radius+.1,0,math.identityMat4());var rotate=math.rotationMat4v(-90*math.DEGTORAD,[0.8,0,0],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),pickable:true,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT),zShaft:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.axis,material:materials.blue,matrix:function(){var translate=math.translateMat4c(0,radius/2,0,math.identityMat4());var rotate=math.rotationMat4v(-90*math.DEGTORAD,[1,0,0],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),clippable:false,pickable:false,collidable:true,visible:false,isObject:false}),NO_STATE_INHERIT),zAxisHandle:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.axisHandle,material:materials.pickable,matrix:function(){var translate=math.translateMat4c(0,radius/2,0,math.identityMat4());var rotate=math.rotationMat4v(-90*math.DEGTORAD,[1,0,0],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),clippable:false,pickable:true,collidable:true,visible:false,isObject:false}),NO_STATE_INHERIT)};this._affordanceMeshes={planeFrame:rootNode.addChild(new Mesh(rootNode,{geometry:new ReadableGeometry(rootNode,buildTorusGeometry({center:[0,0,0],radius:2,tube:tubeRadius,radialSegments:4,tubeSegments:4,arc:Math.PI*2.0})),material:new PhongMaterial(rootNode,{ambient:[1,1,1],diffuse:[0,0,0],emissive:[1,1,0]}),highlighted:true,highlightMaterial:new EmphasisMaterial(rootNode,{edges:false,filled:true,fillColor:[1,1,0],fillAlpha:1.0}),pickable:false,collidable:false,clippable:false,visible:false,scale:[1,1,1],rotation:[0,0,45],isObject:false}),NO_STATE_INHERIT),xHoop:rootNode.addChild(new Mesh(rootNode,{// Full
|
|
25210
|
+
geometry:shapes.hoop,material:materials.red,highlighted:true,highlightMaterial:materials.highlightRed,matrix:function(){var rotate2=math.rotationMat4v(90*math.DEGTORAD,[0,1,0],math.identityMat4());var rotate1=math.rotationMat4v(270*math.DEGTORAD,[1,0,0],math.identityMat4());return math.mulMat4(rotate1,rotate2,math.identityMat4());}(),pickable:false,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT),yHoop:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.hoop,material:materials.green,highlighted:true,highlightMaterial:materials.highlightGreen,rotation:[-90,0,0],pickable:false,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT),zHoop:rootNode.addChild(new Mesh(rootNode,{// Blue hoop about Z-axis
|
|
25211
|
+
geometry:shapes.hoop,material:materials.blue,highlighted:true,highlightMaterial:materials.highlightBlue,matrix:math.rotationMat4v(180*math.DEGTORAD,[1,0,0],math.identityMat4()),pickable:false,collidable:true,clippable:false,backfaces:true,visible:false,isObject:false}),NO_STATE_INHERIT),xAxisArrow:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHeadBig,material:materials.red,matrix:function(){var translate=math.translateMat4c(0,radius+.1,0,math.identityMat4());var rotate=math.rotationMat4v(-90*math.DEGTORAD,[0,0,1],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),pickable:false,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT),yAxisArrow:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHeadBig,material:materials.green,matrix:function(){var translate=math.translateMat4c(0,radius+.1,0,math.identityMat4());var rotate=math.rotationMat4v(180*math.DEGTORAD,[1,0,0],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),pickable:false,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT),zAxisArrow:rootNode.addChild(new Mesh(rootNode,{geometry:shapes.arrowHeadBig,material:materials.blue,matrix:function(){var translate=math.translateMat4c(0,radius+.1,0,math.identityMat4());var rotate=math.rotationMat4v(-90*math.DEGTORAD,[0.8,0,0],math.identityMat4());return math.mulMat4(rotate,translate,math.identityMat4());}(),pickable:false,collidable:true,clippable:false,visible:false,isObject:false}),NO_STATE_INHERIT)};}},{key:"_bindEvents",value:function _bindEvents(){var _this133=this;var self=this;var grabbed=false;var DRAG_ACTIONS={none:-1,xTranslate:0,yTranslate:1,zTranslate:2,xRotate:3,yRotate:4,zRotate:5};var rootNode=this._rootNode;var nextDragAction=null;// As we hover grabbed an arrow or hoop, self is the action we would do if we then dragged it.
|
|
25212
25212
|
var dragAction=null;// Action we're doing while we drag an arrow or hoop.
|
|
25213
25213
|
var lastCanvasPos=math.vec2();var xBaseAxis=math.vec3([1,0,0]);var yBaseAxis=math.vec3([0,1,0]);var zBaseAxis=math.vec3([0,0,1]);var canvas=this._viewer.scene.canvas.canvas;var camera=this._viewer.camera;var scene=this._viewer.scene;{// Keep gizmo screen size constant
|
|
25214
25214
|
var _tempVec3a=math.vec3([0,0,0]);var lastDist=-1;this._onCameraViewMatrix=scene.camera.on("viewMatrix",function(){});this._onCameraProjMatrix=scene.camera.on("projMatrix",function(){});this._onSceneTick=scene.on("tick",function(){var dist=Math.abs(math.lenVec3(math.subVec3(scene.camera.eye,_this133._pos,_tempVec3a)));if(dist!==lastDist){if(camera.projection==="perspective"){var worldSize=Math.tan(camera.perspective.fov*math.DEGTORAD)*dist;var size=0.07*worldSize;rootNode.scale=[size,size,size];lastDist=dist;}}if(camera.projection==="ortho"){var _worldSize=camera.ortho.scale/10;var _size=_worldSize;rootNode.scale=[_size,_size,_size];lastDist=dist;}});}var getClickCoordsWithinElement=function(){var canvasPos=new Float64Array(2);return function(event){if(!event){event=window.event;canvasPos[0]=event.x;canvasPos[1]=event.y;}else{var element=event.target;var totalOffsetLeft=0;var totalOffsetTop=0;while(element.offsetParent){totalOffsetLeft+=element.offsetLeft;totalOffsetTop+=element.offsetTop;element=element.offsetParent;}canvasPos[0]=event.pageX-totalOffsetLeft;canvasPos[1]=event.pageY-totalOffsetTop;}return canvasPos;};}();var localToWorldVec=function(){var mat=math.mat4();return function(localVec,worldVec){math.quaternionToMat4(self._rootNode.quaternion,mat);math.transformVec3(mat,localVec,worldVec);math.normalizeVec3(worldVec);return worldVec;};}();var getTranslationPlane=function(){var planeNormal=math.vec3();return function(worldAxis){var absX=Math.abs(worldAxis[0]);if(absX>Math.abs(worldAxis[1])&&absX>Math.abs(worldAxis[2])){math.cross3Vec3(worldAxis,[0,1,0],planeNormal);}else{math.cross3Vec3(worldAxis,[1,0,0],planeNormal);}math.cross3Vec3(planeNormal,worldAxis,planeNormal);math.normalizeVec3(planeNormal);return planeNormal;};}();var dragTranslateSectionPlane=function(){var p1=math.vec3();var p2=math.vec3();var worldAxis=math.vec4();return function(baseAxis,fromMouse,toMouse){localToWorldVec(baseAxis,worldAxis);var planeNormal=getTranslationPlane(worldAxis,fromMouse,toMouse);getPointerPlaneIntersect(fromMouse,planeNormal,p1);getPointerPlaneIntersect(toMouse,planeNormal,p2);math.subVec3(p2,p1);var dot=math.dotVec3(p2,worldAxis);self._pos[0]+=worldAxis[0]*dot;self._pos[1]+=worldAxis[1]*dot;self._pos[2]+=worldAxis[2]*dot;self._rootNode.position=self._pos;if(self._sectionPlane){self._sectionPlane.pos=self._pos;}};}();var dragRotateSectionPlane=function(){var p1=math.vec4();var p2=math.vec4();var c=math.vec4();var worldAxis=math.vec4();return function(baseAxis,fromMouse,toMouse){localToWorldVec(baseAxis,worldAxis);var hasData=getPointerPlaneIntersect(fromMouse,worldAxis,p1)&&getPointerPlaneIntersect(toMouse,worldAxis,p2);if(!hasData){// Find intersections with view plane and project down to origin
|