@xtctwins/tctwins-bimx-viewer 0.1.16 → 0.1.18
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/tctwins-bimx-viewer.min.es.js +328 -232
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -4
- package/types/src/toolbar/MeasureTool.d.ts +12 -2
- package/types/src/toolbar/MeasureTools/MeasureAngleTool.d.ts +14 -1
- package/types/src/toolbar/MeasureTools/MeasureDistanceTool.d.ts +14 -1
|
@@ -2533,51 +2533,51 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._cornerDot.s
|
|
|
2533
2533
|
* @interface
|
|
2534
2534
|
* @abstract
|
|
2535
2535
|
*/var AngleMeasurementsControl=/*#__PURE__*/function(_Component3){function AngleMeasurementsControl(){_classCallCheck(this,AngleMeasurementsControl);return _callSuper(this,AngleMeasurementsControl,arguments);}_inherits(AngleMeasurementsControl,_Component3);return _createClass(AngleMeasurementsControl,[{key:"active",get:/**
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2536
|
+
* Gets if this AngleMeasurementsControl is currently active, where it is responding to input.
|
|
2537
|
+
*
|
|
2538
|
+
* @returns {boolean} True if this AngleMeassurementsControl is active.
|
|
2539
|
+
* @abstract
|
|
2540
|
+
*/function get(){},set:function set(active){}/**
|
|
2541
|
+
* Sets whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsControl.
|
|
2542
|
+
*
|
|
2543
|
+
* This is `true` by default.
|
|
2544
|
+
*
|
|
2545
|
+
* Internally, this deactivates then activates the AngleMeasurementsControl when changed, which means that
|
|
2546
|
+
* it will destroy any AngleMeasurements currently under construction, and incurs some overhead, since it unbinds
|
|
2547
|
+
* and rebinds various input handlers.
|
|
2548
|
+
*
|
|
2549
|
+
* @param {boolean} snapping Whether to enable snap-to-vertex and snap-edge for this AngleMeasurementsControl.
|
|
2550
|
+
*/},{key:"snapping",get:/**
|
|
2551
|
+
* Gets whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsControl.
|
|
2552
|
+
*
|
|
2553
|
+
* This is `true` by default.
|
|
2554
|
+
*
|
|
2555
|
+
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsControl.
|
|
2556
|
+
*/function get(){return true;}/**
|
|
2557
|
+
* Activates this AngleMeasurementsMouseControl, ready to respond to input.
|
|
2558
|
+
*
|
|
2559
|
+
* @abstract
|
|
2560
|
+
*/,set:function set(snapping){}},{key:"activate",value:function activate(){}/**
|
|
2561
|
+
* Deactivates this AngleMeasurementsControl, making it unresponsive to input.
|
|
2562
|
+
*
|
|
2563
|
+
* Destroys any {@link AngleMeasurement} under construction by this AngleMeasurementsControl.
|
|
2564
|
+
*
|
|
2565
|
+
* @abstract
|
|
2566
|
+
*/},{key:"deactivate",value:function deactivate(){}/**
|
|
2567
|
+
* Resets this AngleMeasurementsControl.
|
|
2568
|
+
*
|
|
2569
|
+
* Destroys any {@link AngleMeasurement} under construction by this AngleMeasurementsControl.
|
|
2570
|
+
*
|
|
2571
|
+
* Does nothing if the AngleMeasurementsControl is not active.
|
|
2572
|
+
*
|
|
2573
|
+
* @abstract
|
|
2574
|
+
*/},{key:"reset",value:function reset(){}/**
|
|
2575
|
+
* Destroys this AngleMeasurementsMouseControl.
|
|
2576
|
+
*
|
|
2577
|
+
* Destroys any {@link AngleMeasurement} under construction by this AngleMeasurementsControl.
|
|
2578
|
+
*
|
|
2579
|
+
* @abstract
|
|
2580
|
+
*/},{key:"destroy",value:function destroy(){}}]);}(Component);var MOUSE_FINDING_ORIGIN=0;var MOUSE_FINDING_CORNER=1;var MOUSE_FINDING_TARGET=2;/**
|
|
2581
2581
|
* Creates {@link AngleMeasurement}s in an {@link AngleMeasurementsPlugin} from mouse input.
|
|
2582
2582
|
*
|
|
2583
2583
|
* ## Usage
|
|
@@ -2623,7 +2623,7 @@ s * @param {function} [cfg.canvasToPagePos] Optional function to map canvas-spa
|
|
|
2623
2623
|
* @param {boolean} [cfg.snapping=true] Whether to initially enable snap-to-vertex and snap-to-edge for this AngleMeasurementsMouseControl.
|
|
2624
2624
|
* @param {_offsetX} [cfg._offsetX] _offsetX of the mouse
|
|
2625
2625
|
* @param {_offsetY} [cfg._offsetY] _offsetY of the mouse
|
|
2626
|
-
* */function AngleMeasurementsMouseControl(angleMeasurementsPlugin){var _this11;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,AngleMeasurementsMouseControl);_this11=_callSuper(this,AngleMeasurementsMouseControl,[angleMeasurementsPlugin.viewer.scene]);_this11.cfg=cfg;_this11._canvasToPagePos=cfg.canvasToPagePos;_this11.pointerLens=cfg.pointerLens;_this11._active=false;_this11._mouseState=MOUSE_FINDING_ORIGIN;_this11._currentAngleMeasurement=null;// init markerDiv element (think about making its style configurable)
|
|
2626
|
+
* */function AngleMeasurementsMouseControl(angleMeasurementsPlugin){var _this11;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,AngleMeasurementsMouseControl);_this11=_callSuper(this,AngleMeasurementsMouseControl,[angleMeasurementsPlugin.viewer.scene]);_this11.cfg=cfg;_this11._canvasToPagePos=cfg.canvasToPagePos;_this11.pointerLens=cfg.pointerLens;_this11._active=false;_this11._activate=false;_this11._mouseState=MOUSE_FINDING_ORIGIN;_this11._currentAngleMeasurement=null;// init markerDiv element (think about making its style configurable)
|
|
2627
2627
|
_this11._initMarkerDiv();_this11._onMouseHoverSurface=null;_this11._onHoverNothing=null;_this11._onPickedNothing=null;_this11._onPickedSurface=null;_this11._onInputMouseDown=null;_this11._onInputMouseUp=null;_this11._snapping=cfg.snapping!==false;_this11._attachPlugin(angleMeasurementsPlugin,cfg);_this11._offsetX=cfg._offsetX|0;_this11._offsetY=cfg._offsetY|0;return _this11;}_inherits(AngleMeasurementsMouseControl,_AngleMeasurementsCon);return _createClass(AngleMeasurementsMouseControl,[{key:"_initMarkerDiv",value:function _initMarkerDiv(){var markerDiv=document.createElement("div");markerDiv.setAttribute("id","myAnglePivotMarker");var canvas=this.scene.canvas.canvas;canvas.parentNode.insertBefore(markerDiv,canvas);markerDiv.style.background="black";markerDiv.style.border="2px solid blue";markerDiv.style.borderRadius="10px";markerDiv.style.width="5px";markerDiv.style.height="5px";markerDiv.style.margin="-200px -200px";markerDiv.style.zIndex="100";markerDiv.style.position="absolute";markerDiv.style.pointerEvents="none";this.markerDiv=markerDiv;}},{key:"_destroyMarkerDiv",value:function _destroyMarkerDiv(){if(this.markerDiv){this.markerDiv.parentNode.removeChild(this.markerDiv);this.markerDiv=null;}}},{key:"_attachPlugin",value:function _attachPlugin(angleMeasurementsPlugin){var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};/**
|
|
2628
2628
|
* The {@link AngleMeasurementsPlugin} that owns this AngleMeasurementsMouseControl.
|
|
2629
2629
|
*
|
|
@@ -2644,7 +2644,7 @@ _this11._initMarkerDiv();_this11._onMouseHoverSurface=null;_this11._onHoverNothi
|
|
|
2644
2644
|
* Gets if this AngleMeasurementsMouseControl is currently active, where it is responding to input.
|
|
2645
2645
|
*
|
|
2646
2646
|
* @returns {boolean}
|
|
2647
|
-
*/,set:function set(offsetY){this._offsetY=offsetY;}},{key:"active",get:function get(){return this._active;}/**
|
|
2647
|
+
*/,set:function set(offsetY){this._offsetY=offsetY;}},{key:"active",get:function get(){return this._active;},set:function set(active){this._active=active;}/**
|
|
2648
2648
|
* Sets whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsMouseControl.
|
|
2649
2649
|
*
|
|
2650
2650
|
* This is `true` by default.
|
|
@@ -2660,10 +2660,10 @@ _this11._initMarkerDiv();_this11._onMouseHoverSurface=null;_this11._onHoverNothi
|
|
|
2660
2660
|
* This is `true` by default.
|
|
2661
2661
|
*
|
|
2662
2662
|
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsMouseControl.
|
|
2663
|
-
*/function get(){return this._snapping;}/**
|
|
2663
|
+
*/function get(){return this._snapping;},set:function set(snapping){if(snapping!==this._snapping){this._snapping=snapping;this.deactivate();this.activate();}else{this._snapping=snapping;}}},{key:"mouseState",get:function get(){return this._mouseState;}/**
|
|
2664
2664
|
* Activates this AngleMeasurementsMouseControl, ready to respond to input.
|
|
2665
|
-
*/,set:function set(
|
|
2666
|
-
}var angleMeasurementsPlugin=this.angleMeasurementsPlugin;var hover=false;angleMeasurementsPlugin.on("mouseOver",function(e){hover=true;});angleMeasurementsPlugin.on("mouseLeave",function(e){hover=false;});angleMeasurementsPlugin.on("measureDelete",function(e){hover=false;});var scene=this.scene;scene.input;var canvas=scene.canvas.canvas;var clickTolerance=20;var cameraControl=angleMeasurementsPlugin.viewer.cameraControl;var pointerLens=this.pointerLens;var mouseHovering=false;var hoveredEntity=null;var lastMouseCanvasX=0;var lastMouseCanvasY=0;var mouseWorldPos=math.vec3();var mouseHoverCanvasPos=math.vec2();this._currentAngleMeasurement=null;this._onMouseHoverSurface=cameraControl.on(this._snapping?"hoverSnapOrSurface":"hoverSurface",function(event){if(hover)return;if(event.snappedToVertex||event.snappedToEdge){if(pointerLens){pointerLens.visible=true;pointerLens.canvasPos=event.canvasPos;pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;pointerLens.snapped=true;}_this12.markerDiv.style.background="greenyellow";_this12.markerDiv.style.border="2px solid green";}else{if(pointerLens){pointerLens.visible=true;pointerLens.canvasPos=event.canvasPos;pointerLens.snappedCanvasPos=event.canvasPos;pointerLens.snapped=false;}_this12.markerDiv.style.background="pink";_this12.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(_this12._mouseState){case MOUSE_FINDING_ORIGIN:canvas.getBoundingClientRect();var scrollLeft=window.pageXOffset||document.documentElement.scrollLeft;var scrollTop=window.pageYOffset||document.documentElement.scrollTop;var canvasLeftEdge=scrollLeft;var canvasTopEdge=scrollTop;_this12.markerDiv.style.marginLeft="".concat(_this12._offsetX+canvasLeftEdge+canvasPos[0]-5,"px");_this12.markerDiv.style.marginTop="".concat(_this12._offsetY+canvasTopEdge+canvasPos[1]-5,"px");break;case MOUSE_FINDING_CORNER:if(_this12._currentAngleMeasurement){_this12._currentAngleMeasurement.originWireVisible=true;_this12._currentAngleMeasurement.targetWireVisible=false;_this12._currentAngleMeasurement.cornerVisible=true;_this12._currentAngleMeasurement.angleVisible=false;_this12._currentAngleMeasurement.corner.worldPos=event.worldPos;_this12._currentAngleMeasurement.corner.entity=event.entity;}_this12.markerDiv.style.marginLeft="-10000px";_this12.markerDiv.style.marginTop="-10000px";canvas.style.cursor="pointer";break;case MOUSE_FINDING_TARGET:if(_this12._currentAngleMeasurement){_this12._currentAngleMeasurement.targetWireVisible=true;_this12._currentAngleMeasurement.targetVisible=true;_this12._currentAngleMeasurement.angleVisible=true;_this12._currentAngleMeasurement.target.worldPos=event.worldPos;_this12._currentAngleMeasurement.target.entity=event.entity;}_this12.markerDiv.style.marginLeft="-10000px";_this12.markerDiv.style.marginTop="-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(hover)return;if(e.which!==1){return;}if(e.clientX>lastMouseCanvasX+clickTolerance||e.clientX<lastMouseCanvasX-clickTolerance||e.clientY>lastMouseCanvasY+clickTolerance||e.clientY<lastMouseCanvasY-clickTolerance){return;}switch(_this12._mouseState){case MOUSE_FINDING_ORIGIN:if(mouseHovering){_this12._currentAngleMeasurement=angleMeasurementsPlugin.createMeasurement({id:math.createUUID(),origin:{worldPos:mouseWorldPos},corner:{worldPos:mouseWorldPos},target:{worldPos:mouseWorldPos},precision:angleMeasurementsPlugin.precision,approximate:true});_this12._currentAngleMeasurement.clickable=false;_this12._currentAngleMeasurement.originVisible=true;_this12._currentAngleMeasurement.originWireVisible=true;_this12._currentAngleMeasurement.cornerVisible=false;_this12._currentAngleMeasurement.targetWireVisible=false;_this12._currentAngleMeasurement.targetVisible=false;_this12._currentAngleMeasurement.angleVisible=false;_this12._currentAngleMeasurement.origin.entity=hoveredEntity;_this12._mouseState=MOUSE_FINDING_CORNER;angleMeasurementsPlugin.fire("measurementStart",_this12._currentAngleMeasurement);}break;case MOUSE_FINDING_CORNER:if(mouseHovering){_this12._currentAngleMeasurement.targetWireVisible=false;_this12._currentAngleMeasurement.targetVisible=true;_this12._currentAngleMeasurement.angleVisible=true;_this12._currentAngleMeasurement.corner.entity=hoveredEntity;_this12._mouseState=MOUSE_FINDING_TARGET;}else{if(_this12._currentAngleMeasurement){_this12._currentAngleMeasurement.destroy();_this12._currentAngleMeasurement=null;hoveredEntity=null;_this12._mouseState=MOUSE_FINDING_ORIGIN;angleMeasurementsPlugin.fire("measurementCancel",_this12._currentAngleMeasurement);}}break;case MOUSE_FINDING_TARGET:if(mouseHovering){_this12._currentAngleMeasurement.targetVisible=true;_this12._currentAngleMeasurement.angleVisible=true;_this12._currentAngleMeasurement.target.entity=hoveredEntity;_this12._currentAngleMeasurement.clickable=true;hoveredEntity=null;angleMeasurementsPlugin.fire("measurementEnd",_this12._currentAngleMeasurement);_this12._currentAngleMeasurement=null;_this12._mouseState=MOUSE_FINDING_ORIGIN;}else{if(_this12._currentAngleMeasurement){_this12._currentAngleMeasurement.destroy();_this12._currentAngleMeasurement=null;hoveredEntity=null;_this12._mouseState=MOUSE_FINDING_ORIGIN;angleMeasurementsPlugin.fire("measurementCancel",_this12._currentAngleMeasurement);}}break;}});this._onMouseHoverOff=cameraControl.on(this._snapping?"hoverSnapOrSurfaceOff":"hoverOff",function(event){if(hover)return;mouseHovering=false;if(pointerLens){pointerLens.visible=true;pointerLens.pointerPos=event.canvasPos;pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;pointerLens.snapped=false;}_this12.markerDiv.style.marginLeft="-100px";_this12.markerDiv.style.marginTop="-100px";if(_this12._currentAngleMeasurement){switch(_this12._mouseState){case MOUSE_FINDING_ORIGIN:_this12._currentAngleMeasurement.originVisible=false;break;case MOUSE_FINDING_CORNER:_this12._currentAngleMeasurement.cornerVisible=false;_this12._currentAngleMeasurement.originWireVisible=false;_this12._currentAngleMeasurement.targetVisible=false;_this12._currentAngleMeasurement.targetWireVisible=false;_this12._currentAngleMeasurement.angleVisible=false;break;case MOUSE_FINDING_TARGET:_this12._currentAngleMeasurement.targetVisible=false;_this12._currentAngleMeasurement.targetWireVisible=false;_this12._currentAngleMeasurement.angleVisible=false;break;}canvas.style.cursor="default";}});this.
|
|
2665
|
+
*/,set:function set(state){this._mouseState=state;}},{key:"activate",value:function activate(){var _this12=this;if(this._activate){return;}if(!this.markerDiv){this._initMarkerDiv();// if the marker is destroyed after deactivation, we recreate it
|
|
2666
|
+
}var angleMeasurementsPlugin=this.angleMeasurementsPlugin;var hover=false;angleMeasurementsPlugin.on("mouseOver",function(e){hover=true;});angleMeasurementsPlugin.on("mouseLeave",function(e){hover=false;});angleMeasurementsPlugin.on("measureDelete",function(e){hover=false;});var scene=this.scene;scene.input;var canvas=scene.canvas.canvas;var clickTolerance=20;var cameraControl=angleMeasurementsPlugin.viewer.cameraControl;var pointerLens=this.pointerLens;var mouseHovering=false;var hoveredEntity=null;var lastMouseCanvasX=0;var lastMouseCanvasY=0;var mouseWorldPos=math.vec3();var mouseHoverCanvasPos=math.vec2();this._currentAngleMeasurement=null;this._onMouseHoverSurface=cameraControl.on(this._snapping?"hoverSnapOrSurface":"hoverSurface",function(event){if(!_this12._active){return;}if(hover)return;if(event.snappedToVertex||event.snappedToEdge){if(pointerLens){pointerLens.visible=true;pointerLens.canvasPos=event.canvasPos;pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;pointerLens.snapped=true;}_this12.markerDiv.style.background="greenyellow";_this12.markerDiv.style.border="2px solid green";}else{if(pointerLens){pointerLens.visible=true;pointerLens.canvasPos=event.canvasPos;pointerLens.snappedCanvasPos=event.canvasPos;pointerLens.snapped=false;}_this12.markerDiv.style.background="pink";_this12.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(_this12._mouseState){case MOUSE_FINDING_ORIGIN:canvas.getBoundingClientRect();var scrollLeft=window.pageXOffset||document.documentElement.scrollLeft;var scrollTop=window.pageYOffset||document.documentElement.scrollTop;var canvasLeftEdge=scrollLeft;var canvasTopEdge=scrollTop;_this12.markerDiv.style.marginLeft="".concat(_this12._offsetX+canvasLeftEdge+canvasPos[0]-5,"px");_this12.markerDiv.style.marginTop="".concat(_this12._offsetY+canvasTopEdge+canvasPos[1]-5,"px");break;case MOUSE_FINDING_CORNER:if(_this12._currentAngleMeasurement){_this12._currentAngleMeasurement.originWireVisible=true;_this12._currentAngleMeasurement.targetWireVisible=false;_this12._currentAngleMeasurement.cornerVisible=true;_this12._currentAngleMeasurement.angleVisible=false;_this12._currentAngleMeasurement.corner.worldPos=event.worldPos;_this12._currentAngleMeasurement.corner.entity=event.entity;}_this12.markerDiv.style.marginLeft="-10000px";_this12.markerDiv.style.marginTop="-10000px";canvas.style.cursor="pointer";break;case MOUSE_FINDING_TARGET:if(_this12._currentAngleMeasurement){_this12._currentAngleMeasurement.targetWireVisible=true;_this12._currentAngleMeasurement.targetVisible=true;_this12._currentAngleMeasurement.angleVisible=true;_this12._currentAngleMeasurement.target.worldPos=event.worldPos;_this12._currentAngleMeasurement.target.entity=event.entity;}_this12.markerDiv.style.marginLeft="-10000px";_this12.markerDiv.style.marginTop="-10000px";canvas.style.cursor="pointer";break;}});canvas.addEventListener("mousedown",this._onMouseDown=function(e){if(!_this12._active){return;}if(e.which!==1){return;}lastMouseCanvasX=e.clientX;lastMouseCanvasY=e.clientY;});canvas.addEventListener("mouseup",this._onMouseUp=function(e){if(!_this12._active){return;}if(hover)return;if(e.which!==1){return;}if(e.clientX>lastMouseCanvasX+clickTolerance||e.clientX<lastMouseCanvasX-clickTolerance||e.clientY>lastMouseCanvasY+clickTolerance||e.clientY<lastMouseCanvasY-clickTolerance){return;}switch(_this12._mouseState){case MOUSE_FINDING_ORIGIN:if(mouseHovering){_this12._currentAngleMeasurement=angleMeasurementsPlugin.createMeasurement({id:math.createUUID(),origin:{worldPos:mouseWorldPos},corner:{worldPos:mouseWorldPos},target:{worldPos:mouseWorldPos},precision:angleMeasurementsPlugin.precision,approximate:true});_this12._currentAngleMeasurement.clickable=false;_this12._currentAngleMeasurement.originVisible=true;_this12._currentAngleMeasurement.originWireVisible=true;_this12._currentAngleMeasurement.cornerVisible=false;_this12._currentAngleMeasurement.targetWireVisible=false;_this12._currentAngleMeasurement.targetVisible=false;_this12._currentAngleMeasurement.angleVisible=false;_this12._currentAngleMeasurement.origin.entity=hoveredEntity;_this12._mouseState=MOUSE_FINDING_CORNER;angleMeasurementsPlugin.fire("measurementStart",_this12._currentAngleMeasurement);}break;case MOUSE_FINDING_CORNER:if(mouseHovering){_this12._currentAngleMeasurement.targetWireVisible=false;_this12._currentAngleMeasurement.targetVisible=true;_this12._currentAngleMeasurement.angleVisible=true;_this12._currentAngleMeasurement.corner.entity=hoveredEntity;_this12._mouseState=MOUSE_FINDING_TARGET;}else{if(_this12._currentAngleMeasurement){_this12._currentAngleMeasurement.destroy();_this12._currentAngleMeasurement=null;hoveredEntity=null;_this12._mouseState=MOUSE_FINDING_ORIGIN;angleMeasurementsPlugin.fire("measurementCancel",_this12._currentAngleMeasurement);}}break;case MOUSE_FINDING_TARGET:if(mouseHovering){_this12._currentAngleMeasurement.targetVisible=true;_this12._currentAngleMeasurement.angleVisible=true;_this12._currentAngleMeasurement.target.entity=hoveredEntity;_this12._currentAngleMeasurement.clickable=true;hoveredEntity=null;angleMeasurementsPlugin.fire("measurementEnd",_this12._currentAngleMeasurement);_this12._currentAngleMeasurement=null;_this12._mouseState=MOUSE_FINDING_ORIGIN;}else{if(_this12._currentAngleMeasurement){_this12._currentAngleMeasurement.destroy();_this12._currentAngleMeasurement=null;hoveredEntity=null;_this12._mouseState=MOUSE_FINDING_ORIGIN;angleMeasurementsPlugin.fire("measurementCancel",_this12._currentAngleMeasurement);}}break;}});this._onMouseHoverOff=cameraControl.on(this._snapping?"hoverSnapOrSurfaceOff":"hoverOff",function(event){if(!_this12._active){return;}if(hover)return;mouseHovering=false;if(pointerLens){pointerLens.visible=true;pointerLens.pointerPos=event.canvasPos;pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;pointerLens.snapped=false;}_this12.markerDiv.style.marginLeft="-100px";_this12.markerDiv.style.marginTop="-100px";if(_this12._currentAngleMeasurement){switch(_this12._mouseState){case MOUSE_FINDING_ORIGIN:_this12._currentAngleMeasurement.originVisible=false;break;case MOUSE_FINDING_CORNER:_this12._currentAngleMeasurement.cornerVisible=false;_this12._currentAngleMeasurement.originWireVisible=false;_this12._currentAngleMeasurement.targetVisible=false;_this12._currentAngleMeasurement.targetWireVisible=false;_this12._currentAngleMeasurement.angleVisible=false;break;case MOUSE_FINDING_TARGET:_this12._currentAngleMeasurement.targetVisible=false;_this12._currentAngleMeasurement.targetWireVisible=false;_this12._currentAngleMeasurement.angleVisible=false;break;}canvas.style.cursor="default";}});this._activate=true;}/**
|
|
2667
2667
|
* Deactivates this AngleMeasurementsMouseControl, making it unresponsive to input.
|
|
2668
2668
|
*
|
|
2669
2669
|
* Destroys any {@link AngleMeasurement} under construction by this AngleMeasurementsMouseControl.
|
|
@@ -2967,6 +2967,9 @@ _this11._initMarkerDiv();_this11._onMouseHoverSurface=null;_this11._onHoverNothi
|
|
|
2967
2967
|
*
|
|
2968
2968
|
* @param {Boolean} labelsShown Whether or not to show the labels.
|
|
2969
2969
|
*/},{key:"setLabelsShown",value:function setLabelsShown(labelsShown){for(var _i34=0,_Object$entries=Object.entries(this.measurements);_i34<_Object$entries.length;_i34++){var _Object$entries$_i=_slicedToArray(_Object$entries[_i34],2),key=_Object$entries$_i[0],measurement=_Object$entries$_i[1];measurement.labelShown=labelsShown;}}/**
|
|
2970
|
+
* 控制所有测量对象显示隐藏
|
|
2971
|
+
* @param {*} visible
|
|
2972
|
+
*/},{key:"setMeasurementsShown",value:function setMeasurementsShown(visible){for(var key in this.measurements){this.measurements[key].visible=visible;}}/**
|
|
2970
2973
|
* Destroys all {@link AngleMeasurement}s.
|
|
2971
2974
|
*/},{key:"clear",value:function clear(){var ids=Object.keys(this._measurements);for(var i=0,len=ids.length;i<len;i++){this.destroyMeasurement(ids[i]);}}/**
|
|
2972
2975
|
* Destroys this AngleMeasurementsPlugin.
|
|
@@ -3011,7 +3014,7 @@ _this11._initMarkerDiv();_this11._onMouseHoverSurface=null;_this11._onHoverNothi
|
|
|
3011
3014
|
* @param {boolean} [cfg.snapToVertex=true] Whether to initially enable snap-to-vertex and snap-to-edge for this AngleMeasurementsMouseControl.
|
|
3012
3015
|
* @param {_offsetX} [cfg._offsetX] _offsetX of the mouse
|
|
3013
3016
|
* @param {_offsetY} [cfg._offsetY] _offsetY of the mouse
|
|
3014
|
-
*/function AngleMeasurementsTouchControl(angleMeasurementsPlugin){var _this16;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,AngleMeasurementsTouchControl);_this16=_callSuper(this,AngleMeasurementsTouchControl,[angleMeasurementsPlugin.viewer.scene]);_this16.pointerLens=cfg.pointerLens;_this16.pointerCircle=new PointerCircle(angleMeasurementsPlugin.viewer,{id:"angleMeasure_Circle"});_this16._active=false;_this16._initMarkerDiv();_this16._currentAngleMeasurement=null;_this16._onCanvasTouchStart=null;_this16._onCanvasTouchEnd=null;_this16._longTouchTimeoutMs=300;_this16._snapping=cfg.snapping!==false;_this16._snapToEdge=cfg.snapping!==false;_this16._snapToVertex=cfg.snapping!==false;_this16._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;_this16._attachPlugin(angleMeasurementsPlugin,cfg);_this16._offsetX=cfg._offsetX|0;_this16._offsetY=cfg._offsetY|0;return _this16;}_inherits(AngleMeasurementsTouchControl,_AngleMeasurementsCon2);return _createClass(AngleMeasurementsTouchControl,[{key:"_initMarkerDiv",value:function _initMarkerDiv(){var markerDiv=document.createElement("div");markerDiv.setAttribute("id","myAngleMeasureTouchMarker");var canvas=this.scene.canvas.canvas;canvas.parentNode.insertBefore(markerDiv,canvas);markerDiv.style.background="black";markerDiv.style.border="2px solid blue";markerDiv.style.borderRadius="10px";markerDiv.style.width="5px";markerDiv.style.height="5px";markerDiv.style.margin="-200px -200px";markerDiv.style.zIndex="100";markerDiv.style.position="absolute";markerDiv.style.pointerEvents="none";this.markerDiv=markerDiv;}},{key:"_destroyMarkerDiv",value:function _destroyMarkerDiv(){if(this.markerDiv){this.markerDiv.parentNode.removeChild(this.markerDiv);this.markerDiv=null;}}},{key:"_attachPlugin",value:function _attachPlugin(angleMeasurementsPlugin){/**
|
|
3017
|
+
*/function AngleMeasurementsTouchControl(angleMeasurementsPlugin){var _this16;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,AngleMeasurementsTouchControl);_this16=_callSuper(this,AngleMeasurementsTouchControl,[angleMeasurementsPlugin.viewer.scene]);_this16.pointerLens=cfg.pointerLens;_this16.pointerCircle=new PointerCircle(angleMeasurementsPlugin.viewer,{id:"angleMeasure_Circle"});_this16._active=false;_this16._activate=false;_this16._initMarkerDiv();_this16._currentAngleMeasurement=null;_this16._onCanvasTouchStart=null;_this16._onCanvasTouchEnd=null;_this16._longTouchTimeoutMs=300;_this16._snapping=cfg.snapping!==false;_this16._snapToEdge=cfg.snapping!==false;_this16._snapToVertex=cfg.snapping!==false;_this16._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;_this16._attachPlugin(angleMeasurementsPlugin,cfg);_this16._offsetX=cfg._offsetX|0;_this16._offsetY=cfg._offsetY|0;return _this16;}_inherits(AngleMeasurementsTouchControl,_AngleMeasurementsCon2);return _createClass(AngleMeasurementsTouchControl,[{key:"_initMarkerDiv",value:function _initMarkerDiv(){var markerDiv=document.createElement("div");markerDiv.setAttribute("id","myAngleMeasureTouchMarker");var canvas=this.scene.canvas.canvas;canvas.parentNode.insertBefore(markerDiv,canvas);markerDiv.style.background="black";markerDiv.style.border="2px solid blue";markerDiv.style.borderRadius="10px";markerDiv.style.width="5px";markerDiv.style.height="5px";markerDiv.style.margin="-200px -200px";markerDiv.style.zIndex="100";markerDiv.style.position="absolute";markerDiv.style.pointerEvents="none";this.markerDiv=markerDiv;}},{key:"_destroyMarkerDiv",value:function _destroyMarkerDiv(){if(this.markerDiv){this.markerDiv.parentNode.removeChild(this.markerDiv);this.markerDiv=null;}}},{key:"_attachPlugin",value:function _attachPlugin(angleMeasurementsPlugin){/**
|
|
3015
3018
|
* The {@link AngleMeasurementsPlugin} that owns this AngleMeasurementsTouchControl.
|
|
3016
3019
|
* @type {AngleMeasurementsPlugin}
|
|
3017
3020
|
*/this.angleMeasurementsPlugin=angleMeasurementsPlugin;/**
|
|
@@ -3028,7 +3031,7 @@ _this11._initMarkerDiv();_this11._onMouseHoverSurface=null;_this11._onHoverNothi
|
|
|
3028
3031
|
*/function get(){return this._offsetY;}/** Gets if this AngleMeasurementsTouchControl is currently active, where it is responding to input.
|
|
3029
3032
|
*
|
|
3030
3033
|
* @returns {Boolean}
|
|
3031
|
-
*/,set:function set(offsetY){this._offsetY=offsetY;}},{key:"active",get:function get(){return this._active;}/**
|
|
3034
|
+
*/,set:function set(offsetY){this._offsetY=offsetY;}},{key:"active",get:function get(){return this._active;},set:function set(active){this._active=active;}/**
|
|
3032
3035
|
* Sets whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsMouseControl.
|
|
3033
3036
|
*
|
|
3034
3037
|
* This is `true` by default.
|
|
@@ -3046,7 +3049,7 @@ _this11._initMarkerDiv();_this11._onMouseHoverSurface=null;_this11._onHoverNothi
|
|
|
3046
3049
|
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsMouseControl.
|
|
3047
3050
|
*/function get(){return this._snapping;}/**
|
|
3048
3051
|
* Activates this AngleMeasurementsTouchControl, ready to respond to input.
|
|
3049
|
-
*/,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 _this17=this;if(this.
|
|
3052
|
+
*/,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 _this17=this;if(this._activate){return;}var plugin=this.plugin;var scene=this.scene;var canvas=scene.canvas.canvas;plugin.pointerLens;var pointerWorldPos=math.vec3();var touchTolerance=20;var longTouchTimeout=null;this._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;var touchStartCanvasPos=math.vec2();var touchMoveCanvasPos=math.vec2();var touchEndCanvasPos=math.vec2();var touchId=null;var disableCameraNavigation=function disableCameraNavigation(){_this17.plugin.viewer.cameraControl.active=false;};var enableCameraNavigation=function enableCameraNavigation(){_this17.plugin.viewer.cameraControl.active=true;};var cancel=function cancel(){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}if(_this17._currentAngleMeasurement){_this17._currentAngleMeasurement.destroy();_this17._currentAngleMeasurement=null;}enableCameraNavigation();_this17._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;};canvas.addEventListener("touchstart",this._onCanvasTouchStart=function(event){if(!_this17._active){return;}if(!event.isTrusted)return;var currentNumTouches=event.touches.length;//多指触碰
|
|
3050
3053
|
if(currentNumTouches!==1){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}return;}//touch--0
|
|
3051
3054
|
var touch=event.touches[0];var touchX=touch.clientX;var touchY=touch.clientY;touchStartCanvasPos.set([touchX+_this17.offsetX,touchY+_this17.offsetY]);touchMoveCanvasPos.set([touchX+_this17.offsetX,touchY+_this17.offsetY]);switch(_this17._touchState){case WAITING_FOR_ORIGIN_TOUCH_START$1:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
3052
3055
|
cancel();return;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this17._snapping,snapToEdge:_this17._snapping});if(snapPickResult&&snapPickResult.snapped){pointerWorldPos.set(snapPickResult.worldPos);_this17.pointerCircle.start(snapPickResult.snappedCanvasPos);}else{var pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){pointerWorldPos.set(pickResult.worldPos);_this17.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
|
|
@@ -3071,12 +3074,12 @@ return;}// Long touch
|
|
|
3071
3074
|
if(_this17.pointerLens){_this17.pointerLens.visible=true;_this17.pointerLens.canvasPos=touchStartCanvasPos;_this17.pointerLens.snapped=false;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this17._snapping,snapToEdge:_this17._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this17.pointerLens){_this17.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this17.pointerLens.snapped=true;}_this17.pointerCircle.start(snapPickResult.snappedCanvasPos);pointerWorldPos.set(snapPickResult.worldPos);_this17._currentAngleMeasurement.target.worldPos=snapPickResult.worldPos;_this17._currentAngleMeasurement.target.entity=snapPickResult.entity;_this17._currentAngleMeasurement.originVisible=true;_this17._currentAngleMeasurement.originWireVisible=true;_this17._currentAngleMeasurement.cornerVisible=true;_this17._currentAngleMeasurement.cornerWireVisible=true;_this17._currentAngleMeasurement.targetVisible=true;_this17._currentAngleMeasurement.targetWireVisible=true;_this17._currentAngleMeasurement.angleVisible=true;_this17.angleMeasurementsPlugin.fire("measurementStart",_this17._currentAngleMeasurement);}else{var _pickResult3=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(_pickResult3&&_pickResult3.worldPos){if(_this17.pointerLens){_this17.pointerLens.cursorPos=_pickResult3.canvasPos;_this17.pointerLens.snapped=false;}_this17.pointerCircle.start(_pickResult3.canvasPos);pointerWorldPos.set(_pickResult3.worldPos);_this17._currentAngleMeasurement.target.worldPos=_pickResult3.worldPos;_this17._currentAngleMeasurement.target.entity=_pickResult3.entity;_this17._currentAngleMeasurement.originVisible=true;_this17._currentAngleMeasurement.originWireVisible=true;_this17._currentAngleMeasurement.cornerVisible=true;_this17._currentAngleMeasurement.cornerWireVisible=true;_this17._currentAngleMeasurement.targetVisible=true;_this17._currentAngleMeasurement.targetWireVisible=true;_this17._currentAngleMeasurement.angleVisible=true;plugin.fire("measurementStart",_this17._currentAngleMeasurement);}else{if(_this17.pointerLens){_this17.pointerLens.cursorPos=null;_this17.pointerLens.snapped=false;}}}_this17._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END$1;// console.log("touchstart: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_LONG_TOUCH_END")
|
|
3072
3075
|
disableCameraNavigation();},_this17._longTouchTimeoutMs);_this17._touchState=WAITING_FOR_TARGET_QUICK_TOUCH_END$1;// console.log("touchstart: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_QUICK_TOUCH_END")
|
|
3073
3076
|
}touchId=touch.identifier;break;default:if(longTouchTimeout!==null){clearTimeout(longTouchTimeout);longTouchTimeout=null;}_this17._touchState=TOUCH_CANCELING$1;// console.log("touchstart: this._touchState= default -> TOUCH_CANCELING")
|
|
3074
|
-
return;}},{passive:true});canvas.addEventListener("touchmove",function(event){_this17.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+_this17.offsetX,touchY+_this17.offsetY]);var snapPickResult;var pickResult;switch(_this17._touchState){case WAITING_FOR_ORIGIN_LONG_TOUCH_END$1:if(_this17.pointerLens){_this17.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this17._snapping,snapToEdge:_this17._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this17.pointerLens){_this17.pointerLens.snappedCanvasPos=snapPickResult.snappedCanvasPos;_this17.pointerLens.snapped=true;}pointerWorldPos.set(snapPickResult.worldPos);_this17._currentAngleMeasurement.origin.worldPos=snapPickResult.worldPos;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this17.pointerLens){_this17.pointerLens.cursorPos=pickResult.canvasPos;_this17.pointerLens.snapped=false;}pointerWorldPos.set(pickResult.worldPos);_this17._currentAngleMeasurement.origin.worldPos=pickResult.worldPos;}else{if(_this17.pointerLens){_this17.pointerLens.cursorPos=null;_this17.pointerLens.snapped=false;}}}_this17._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")
|
|
3077
|
+
return;}},{passive:true});canvas.addEventListener("touchmove",function(event){if(!_this17._active){return;}_this17.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+_this17.offsetX,touchY+_this17.offsetY]);var snapPickResult;var pickResult;switch(_this17._touchState){case WAITING_FOR_ORIGIN_LONG_TOUCH_END$1:if(_this17.pointerLens){_this17.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this17._snapping,snapToEdge:_this17._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this17.pointerLens){_this17.pointerLens.snappedCanvasPos=snapPickResult.snappedCanvasPos;_this17.pointerLens.snapped=true;}pointerWorldPos.set(snapPickResult.worldPos);_this17._currentAngleMeasurement.origin.worldPos=snapPickResult.worldPos;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this17.pointerLens){_this17.pointerLens.cursorPos=pickResult.canvasPos;_this17.pointerLens.snapped=false;}pointerWorldPos.set(pickResult.worldPos);_this17._currentAngleMeasurement.origin.worldPos=pickResult.worldPos;}else{if(_this17.pointerLens){_this17.pointerLens.cursorPos=null;_this17.pointerLens.snapped=false;}}}_this17._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")
|
|
3075
3078
|
break;case WAITING_FOR_CORNER_LONG_TOUCH_END:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
3076
3079
|
clearTimeout(longTouchTimeout);longTouchTimeout=null;if(_this17.pointerLens){_this17.pointerLens.visible=false;}_this17._touchState=TOUCH_CANCELING$1;// console.log("touchmove: this._touchState= QUICK_TOUCH_FINDING_CORNER -> TOUCH_CANCELING")
|
|
3077
3080
|
return;}if(_this17.pointerLens){_this17.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this17._snapping,snapToEdge:_this17._snapping});if(snapPickResult&&snapPickResult.worldPos){if(_this17.pointerLens){_this17.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this17.pointerLens.snapped=true;}_this17._currentAngleMeasurement.corner.worldPos=snapPickResult.worldPos;_this17._currentAngleMeasurement.originVisible=true;_this17._currentAngleMeasurement.originWireVisible=true;_this17._currentAngleMeasurement.cornerVisible=true;_this17._currentAngleMeasurement.cornerWireVisible=false;_this17._currentAngleMeasurement.targetVisible=false;_this17._currentAngleMeasurement.targetWireVisible=false;_this17._currentAngleMeasurement.angleVisible=false;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this17.pointerLens){_this17.pointerLens.cursorPos=pickResult.canvasPos;_this17.pointerLens.snapped=false;}_this17._currentAngleMeasurement.corner.worldPos=pickResult.worldPos;_this17._currentAngleMeasurement.originVisible=true;_this17._currentAngleMeasurement.originWireVisible=true;_this17._currentAngleMeasurement.cornerVisible=true;_this17._currentAngleMeasurement.cornerWireVisible=false;_this17._currentAngleMeasurement.targetVisible=false;_this17._currentAngleMeasurement.targetWireVisible=false;_this17._currentAngleMeasurement.angleVisible=false;}}_this17._touchState=WAITING_FOR_CORNER_LONG_TOUCH_END;break;case WAITING_FOR_TARGET_LONG_TOUCH_END$1:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
3078
3081
|
clearTimeout(longTouchTimeout);longTouchTimeout=null;if(_this17.pointerLens){_this17.pointerLens.visible=false;}_this17._touchState=TOUCH_CANCELING$1;// console.log("touchmove: this._touchState= QUICK_TOUCH_FINDING_TARGET -> TOUCH_CANCELING")
|
|
3079
|
-
return;}if(_this17.pointerLens){_this17.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this17._snapping,snapToEdge:_this17._snapping});if(snapPickResult&&snapPickResult.worldPos){if(_this17.pointerLens){_this17.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this17.pointerLens.snapped=true;}_this17._currentAngleMeasurement.target.worldPos=snapPickResult.worldPos;_this17._currentAngleMeasurement.originVisible=true;_this17._currentAngleMeasurement.originWireVisible=true;_this17._currentAngleMeasurement.cornerVisible=true;_this17._currentAngleMeasurement.cornerWireVisible=true;_this17._currentAngleMeasurement.targetVisible=true;_this17._currentAngleMeasurement.targetWireVisible=true;_this17._currentAngleMeasurement.angleVisible=true;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this17.pointerLens){_this17.pointerLens.cursorPos=pickResult.canvasPos;_this17.pointerLens.snapped=false;}_this17._currentAngleMeasurement.target.worldPos=pickResult.worldPos;_this17._currentAngleMeasurement.originVisible=true;_this17._currentAngleMeasurement.originWireVisible=true;_this17._currentAngleMeasurement.cornerVisible=true;_this17._currentAngleMeasurement.cornerWireVisible=true;_this17._currentAngleMeasurement.targetVisible=true;_this17._currentAngleMeasurement.targetWireVisible=true;_this17._currentAngleMeasurement.angleVisible=true;}}_this17._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END$1;break;}},{passive:true});canvas.addEventListener("touchend",this._onCanvasTouchEnd=function(event){_this17.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(_this17._touchState){//起点短按
|
|
3082
|
+
return;}if(_this17.pointerLens){_this17.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this17._snapping,snapToEdge:_this17._snapping});if(snapPickResult&&snapPickResult.worldPos){if(_this17.pointerLens){_this17.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this17.pointerLens.snapped=true;}_this17._currentAngleMeasurement.target.worldPos=snapPickResult.worldPos;_this17._currentAngleMeasurement.originVisible=true;_this17._currentAngleMeasurement.originWireVisible=true;_this17._currentAngleMeasurement.cornerVisible=true;_this17._currentAngleMeasurement.cornerWireVisible=true;_this17._currentAngleMeasurement.targetVisible=true;_this17._currentAngleMeasurement.targetWireVisible=true;_this17._currentAngleMeasurement.angleVisible=true;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this17.pointerLens){_this17.pointerLens.cursorPos=pickResult.canvasPos;_this17.pointerLens.snapped=false;}_this17._currentAngleMeasurement.target.worldPos=pickResult.worldPos;_this17._currentAngleMeasurement.originVisible=true;_this17._currentAngleMeasurement.originWireVisible=true;_this17._currentAngleMeasurement.cornerVisible=true;_this17._currentAngleMeasurement.cornerWireVisible=true;_this17._currentAngleMeasurement.targetVisible=true;_this17._currentAngleMeasurement.targetWireVisible=true;_this17._currentAngleMeasurement.angleVisible=true;}}_this17._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END$1;break;}},{passive:true});canvas.addEventListener("touchend",this._onCanvasTouchEnd=function(event){if(!_this17._active){return;}_this17.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(_this17._touchState){//起点短按
|
|
3080
3083
|
case WAITING_FOR_ORIGIN_QUICK_TOUCH_END$1:{if(numChangedTouches!==1||touchX>touchStartCanvasPos[0]+touchTolerance||touchX<touchStartCanvasPos[0]-touchTolerance||touchY>touchStartCanvasPos[1]+touchTolerance||touchY<touchStartCanvasPos[1]-touchTolerance){_this17._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;return;}var pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){_this17._currentAngleMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pickResult.worldPos},corner:{worldPos:pickResult.worldPos},target:{worldPos:pickResult.worldPos},precision:plugin.precision});// this._currentAngleMeasurement.clickable = false;
|
|
3081
3084
|
_this17._currentAngleMeasurement.originVisible=true;_this17._currentAngleMeasurement.originWireVisible=false;_this17._currentAngleMeasurement.cornerVisible=false;_this17._currentAngleMeasurement.cornerWireVisible=false;_this17._currentAngleMeasurement.targetVisible=false;_this17._currentAngleMeasurement.targetWireVisible=false;_this17._currentAngleMeasurement.angleVisible=false;_this17._touchState=WAITING_FOR_CORNER_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_QUICK_TOUCH_END -> WAITING_FOR_CORNER_TOUCH_START")
|
|
3082
3085
|
}else{if(_this17._currentAngleMeasurement){_this17._currentAngleMeasurement.destroy();_this17._currentAngleMeasurement=null;}_this17._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_QUICK_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
@@ -3093,7 +3096,7 @@ case WAITING_FOR_TARGET_QUICK_TOUCH_END$1:{if(numChangedTouches!==1||touchX>touc
|
|
|
3093
3096
|
}enableCameraNavigation();break;//终点长按
|
|
3094
3097
|
case WAITING_FOR_TARGET_LONG_TOUCH_END$1:if(_this17.pointerLens){_this17.pointerLens.visible=false;}if(!_this17._currentAngleMeasurement||!_this17._currentAngleMeasurement.targetVisible){if(_this17._currentAngleMeasurement){_this17._currentAngleMeasurement.destroy();_this17._currentAngleMeasurement=null;}_this17._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;// console.log("touchend: this._touchState= WAITING_FOR_TARGET_LONG_TOUCH_END (no target found) -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
3095
3098
|
}else{_this17._currentAngleMeasurement.clickable=true;_this17.angleMeasurementsPlugin.fire("measurementEnd",_this17._currentAngleMeasurement);_this17._currentAngleMeasurement=null;_this17._touchState=WAITING_FOR_ORIGIN_TOUCH_START$1;// console.log("touchend: this._touchState= WAITING_FOR_TARGET_LONG_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
3096
|
-
}enableCameraNavigation();break;}},{passive:true});canvas.addEventListener("touchcancel",this._onCanvasTouchEnd);this.
|
|
3099
|
+
}enableCameraNavigation();break;}},{passive:true});canvas.addEventListener("touchcancel",this._onCanvasTouchEnd);this._activate=true;}/**
|
|
3097
3100
|
* Deactivates this AngleMeasurementsTouchControl, making it unresponsive to input.
|
|
3098
3101
|
*
|
|
3099
3102
|
* Destroys any {@link AngleMeasurement} under construction.
|
|
@@ -3818,51 +3821,51 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._targetDot.s
|
|
|
3818
3821
|
* @interface
|
|
3819
3822
|
* @abstract
|
|
3820
3823
|
*/var DistanceMeasurementsControl=/*#__PURE__*/function(_Component5){function DistanceMeasurementsControl(){_classCallCheck(this,DistanceMeasurementsControl);return _callSuper(this,DistanceMeasurementsControl,arguments);}_inherits(DistanceMeasurementsControl,_Component5);return _createClass(DistanceMeasurementsControl,[{key:"active",get:/**
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3824
|
+
* Gets if this DistanceMeasurementsControl is currently active, where it is responding to input.
|
|
3825
|
+
*
|
|
3826
|
+
* @returns {boolean} True if this DistanceMeasurementsControl is active.
|
|
3827
|
+
* @abstract
|
|
3828
|
+
*/function get(){},set:function set(active){}/**
|
|
3829
|
+
* Sets whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsControl.
|
|
3830
|
+
*
|
|
3831
|
+
* This is `true` by default.
|
|
3832
|
+
*
|
|
3833
|
+
* Internally, this deactivates then activates the DistanceMeasurementsControl when changed, which means that
|
|
3834
|
+
* it will destroy any DistanceMeasurements currently under construction, and incurs some overhead, since it unbinds
|
|
3835
|
+
* and rebinds various input handlers.
|
|
3836
|
+
*
|
|
3837
|
+
* @param {boolean} snapping Whether to enable snap-to-vertex and snap-edge for this DistanceMeasurementsControl.
|
|
3838
|
+
*/},{key:"snapping",get:/**
|
|
3839
|
+
* Gets whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsControl.
|
|
3840
|
+
*
|
|
3841
|
+
* This is `true` by default.
|
|
3842
|
+
*
|
|
3843
|
+
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsControl.
|
|
3844
|
+
*/function get(){return true;}/**
|
|
3845
|
+
* Activates this DistanceMeasurementsControl, ready to respond to input.
|
|
3846
|
+
*
|
|
3847
|
+
* @abstract
|
|
3848
|
+
*/,set:function set(snapping){}},{key:"activate",value:function activate(){}/**
|
|
3849
|
+
* Deactivates this DistanceMeasurementsControl, making it unresponsive to input.
|
|
3850
|
+
*
|
|
3851
|
+
* Destroys any {@link DistanceMeasurement} under construction by this DistanceMeasurementsControl.
|
|
3852
|
+
*
|
|
3853
|
+
* @abstract
|
|
3854
|
+
*/},{key:"deactivate",value:function deactivate(){}/**
|
|
3855
|
+
* Resets this DistanceMeasurementsControl.
|
|
3856
|
+
*
|
|
3857
|
+
* Destroys any {@link DistanceMeasurement} under construction by this DistanceMeasurementsControl.
|
|
3858
|
+
*
|
|
3859
|
+
* Does nothing if the DistanceMeasurementsControl is not active.
|
|
3860
|
+
*
|
|
3861
|
+
* @abstract
|
|
3862
|
+
*/},{key:"reset",value:function reset(){}/**
|
|
3863
|
+
* Destroys this DistanceMeasurementsControl.
|
|
3864
|
+
*
|
|
3865
|
+
* Destroys any {@link DistanceMeasurement} under construction by this DistanceMeasurementsControl.
|
|
3866
|
+
*
|
|
3867
|
+
* @abstract
|
|
3868
|
+
*/},{key:"destroy",value:function destroy(){}}]);}(Component);var MOUSE_FIRST_CLICK_EXPECTED=0;/**
|
|
3866
3869
|
* Creates {@link DistanceMeasurement}s in a {@link DistanceMeasurementsPlugin} from mouse input.
|
|
3867
3870
|
*
|
|
3868
3871
|
* ## Usage
|
|
@@ -3907,7 +3910,7 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._targetDot.s
|
|
|
3907
3910
|
* @param {boolean} [cfg.snapping=true] Whether to initially enable snap-to-vertex and snap-to-edge for this DistanceMeasurementsMouseControl.
|
|
3908
3911
|
* @param {_offsetX} [cfg._offsetX] _offsetX of the mouse
|
|
3909
3912
|
* @param {_offsetY} [cfg._offsetY] _offsetY of the mouse
|
|
3910
|
-
*/function DistanceMeasurementsMouseControl(distanceMeasurementsPlugin){var _this23;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,DistanceMeasurementsMouseControl);_this23=_callSuper(this,DistanceMeasurementsMouseControl,[distanceMeasurementsPlugin.viewer.scene]);_this23.cfg=cfg;_this23.pointerLens=cfg.pointerLens;_this23._active=false;_this23._currentDistanceMeasurement=null;_this23._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null};_this23._initMarkerDiv();_this23._onCameraControlHoverSnapOrSurface=null;_this23._onCameraControlHoverSnapOrSurfaceOff=null;_this23._onMouseDown=null;_this23._onMouseUp=null;_this23._onCanvasTouchStart=null;_this23._onCanvasTouchEnd=null;_this23._snapping=cfg.snapping!==false;_this23._mouseState=MOUSE_FIRST_CLICK_EXPECTED;_this23._attachPlugin(distanceMeasurementsPlugin,cfg);_this23._offsetX=cfg._offsetX|0;_this23._offsetY=cfg._offsetY|0;return _this23;}_inherits(DistanceMeasurementsMouseControl,_DistanceMeasurements);return _createClass(DistanceMeasurementsMouseControl,[{key:"_initMarkerDiv",value:function _initMarkerDiv(){var markerDiv=document.createElement("div");markerDiv.setAttribute("id","myDistancePivotMarker");var canvas=this.scene.canvas.canvas;canvas.parentNode.insertBefore(markerDiv,canvas);markerDiv.style.background="black";markerDiv.style.border="2px solid blue";markerDiv.style.borderRadius="10px";markerDiv.style.width="5px";markerDiv.style.height="5px";markerDiv.style.margin="-200px -200px";markerDiv.style.zIndex="100";markerDiv.style.position="absolute";markerDiv.style.pointerEvents="none";this._markerDiv=markerDiv;}},{key:"_destroyMarkerDiv",value:function _destroyMarkerDiv(){if(this._markerDiv){this._markerDiv.parentNode.removeChild(this._markerDiv);this._markerDiv=null;}}},{key:"_attachPlugin",value:function _attachPlugin(distanceMeasurementsPlugin){var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};/**
|
|
3913
|
+
*/function DistanceMeasurementsMouseControl(distanceMeasurementsPlugin){var _this23;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,DistanceMeasurementsMouseControl);_this23=_callSuper(this,DistanceMeasurementsMouseControl,[distanceMeasurementsPlugin.viewer.scene]);_this23.cfg=cfg;_this23.pointerLens=cfg.pointerLens;_this23._active=false;_this23._activate=false;_this23._currentDistanceMeasurement=null;_this23._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null};_this23._initMarkerDiv();_this23._onCameraControlHoverSnapOrSurface=null;_this23._onCameraControlHoverSnapOrSurfaceOff=null;_this23._onMouseDown=null;_this23._onMouseUp=null;_this23._onCanvasTouchStart=null;_this23._onCanvasTouchEnd=null;_this23._snapping=cfg.snapping!==false;_this23._mouseState=MOUSE_FIRST_CLICK_EXPECTED;_this23._attachPlugin(distanceMeasurementsPlugin,cfg);_this23._offsetX=cfg._offsetX|0;_this23._offsetY=cfg._offsetY|0;return _this23;}_inherits(DistanceMeasurementsMouseControl,_DistanceMeasurements);return _createClass(DistanceMeasurementsMouseControl,[{key:"_initMarkerDiv",value:function _initMarkerDiv(){var markerDiv=document.createElement("div");markerDiv.setAttribute("id","myDistancePivotMarker");var canvas=this.scene.canvas.canvas;canvas.parentNode.insertBefore(markerDiv,canvas);markerDiv.style.background="black";markerDiv.style.border="2px solid blue";markerDiv.style.borderRadius="10px";markerDiv.style.width="5px";markerDiv.style.height="5px";markerDiv.style.margin="-200px -200px";markerDiv.style.zIndex="100";markerDiv.style.position="absolute";markerDiv.style.pointerEvents="none";this._markerDiv=markerDiv;}},{key:"_destroyMarkerDiv",value:function _destroyMarkerDiv(){if(this._markerDiv){this._markerDiv.parentNode.removeChild(this._markerDiv);this._markerDiv=null;}}},{key:"_attachPlugin",value:function _attachPlugin(distanceMeasurementsPlugin){var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};/**
|
|
3911
3914
|
* The {@link DistanceMeasurementsPlugin} that owns this DistanceMeasurementsMouseControl.
|
|
3912
3915
|
* @type {DistanceMeasurementsPlugin}
|
|
3913
3916
|
*/this.distanceMeasurementsPlugin=distanceMeasurementsPlugin;/**
|
|
@@ -3925,7 +3928,7 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._targetDot.s
|
|
|
3925
3928
|
* Gets if this DistanceMeasurementsMouseControl is currently active, where it is responding to input.
|
|
3926
3929
|
*
|
|
3927
3930
|
* @returns {boolean} True if this DistanceMeasurementsMouseControl is active.
|
|
3928
|
-
*/,set:function set(offsetY){this._offsetY=offsetY;}},{key:"active",get:function get(){return this._active;}/**
|
|
3931
|
+
*/,set:function set(offsetY){this._offsetY=offsetY;}},{key:"active",get:function get(){return this._active;},set:function set(active){this._active=active;}/**
|
|
3929
3932
|
* Sets whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsMouseControl.
|
|
3930
3933
|
*
|
|
3931
3934
|
* This is `true` by default.
|
|
@@ -3941,9 +3944,9 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._targetDot.s
|
|
|
3941
3944
|
* This is `true` by default.
|
|
3942
3945
|
*
|
|
3943
3946
|
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsMouseControl.
|
|
3944
|
-
*/function get(){return this._snapping;}/**
|
|
3947
|
+
*/function get(){return this._snapping;},set:function set(snapping){if(snapping!==this._snapping){this._snapping=snapping;this.deactivate();this.activate();}else{this._snapping=snapping;}}},{key:"mouseState",get:function get(){return this._mouseState;}/**
|
|
3945
3948
|
* Activates this DistanceMeasurementsMouseControl, ready to respond to input.
|
|
3946
|
-
*/,set:function set(
|
|
3949
|
+
*/,set:function set(state){this._mouseState=state;}},{key:"activate",value:function activate(){var _this24=this;if(this._activate){return;}if(!this._markerDiv){this._initMarkerDiv();}this.fire("activated",true);var distanceMeasurementsPlugin=this.distanceMeasurementsPlugin;var hover=false;distanceMeasurementsPlugin.on("mouseOver",function(e){hover=true;});distanceMeasurementsPlugin.on("mouseLeave",function(e){hover=false;});distanceMeasurementsPlugin.on("measureDelete",function(e){hover=false;});distanceMeasurementsPlugin.on("measurementDestroyed",function(e){});var scene=this.scene;var cameraControl=distanceMeasurementsPlugin.viewer.cameraControl;var canvas=scene.canvas.canvas;scene.input;var mouseHovering=false;var pointerWorldPos=math.vec3();var pointerCanvasPos=math.vec2();var pointerDownCanvasX;var pointerDownCanvasY;var clickTolerance=20;var hoveredEntity=null;this._mouseState=MOUSE_FIRST_CLICK_EXPECTED;this._onCameraControlHoverSnapOrSurface=cameraControl.on(this._snapping?"hoverSnapOrSurface":"hoverSurface",function(event){if(!_this24._active){return;}if(hover)return;var canvasPos=event.snappedCanvasPos||event.canvasPos;mouseHovering=true;pointerWorldPos.set(event.worldPos);pointerCanvasPos.set(event.canvasPos);if(_this24._mouseState===MOUSE_FIRST_CLICK_EXPECTED){canvas.getBoundingClientRect();var scrollLeft=window.pageXOffset||document.documentElement.scrollLeft;var scrollTop=window.pageYOffset||document.documentElement.scrollTop;var canvasLeftEdge=scrollLeft;var canvasTopEdge=scrollTop;_this24._markerDiv.style.marginLeft="".concat(_this24._offsetX+canvasLeftEdge+canvasPos[0]-5,"px");_this24._markerDiv.style.marginTop="".concat(_this24._offsetY+canvasTopEdge+canvasPos[1]-5,"px");_this24._markerDiv.style.background="pink";if(event.snappedToVertex||event.snappedToEdge){if(_this24.pointerLens){_this24.pointerLens.visible=true;_this24.pointerLens.canvasPos=event.canvasPos;_this24.pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;_this24.pointerLens.snapped=true;}_this24._markerDiv.style.background="greenyellow";_this24._markerDiv.style.border="2px solid green";}else{if(_this24.pointerLens){_this24.pointerLens.visible=true;_this24.pointerLens.canvasPos=event.canvasPos;_this24.pointerLens.snappedCanvasPos=event.canvasPos;_this24.pointerLens.snapped=false;}_this24._markerDiv.style.background="pink";_this24._markerDiv.style.border="2px solid red";}hoveredEntity=event.entity;}else{_this24._markerDiv.style.marginLeft="-10000px";_this24._markerDiv.style.marginTop="-10000px";}canvas.style.cursor="pointer";if(_this24._currentDistanceMeasurement){_this24._currentDistanceMeasurement.wireVisible=_this24._currentDistanceMeasurementInitState.wireVisible;_this24._currentDistanceMeasurement.axisVisible=_this24._currentDistanceMeasurementInitState.axisVisible&&_this24.distanceMeasurementsPlugin.defaultAxisVisible;_this24._currentDistanceMeasurement.xAxisVisible=_this24._currentDistanceMeasurementInitState.xAxisVisible&&_this24.distanceMeasurementsPlugin.defaultXAxisVisible;_this24._currentDistanceMeasurement.yAxisVisible=_this24._currentDistanceMeasurementInitState.yAxisVisible&&_this24.distanceMeasurementsPlugin.defaultYAxisVisible;_this24._currentDistanceMeasurement.zAxisVisible=_this24._currentDistanceMeasurementInitState.zAxisVisible&&_this24.distanceMeasurementsPlugin.defaultZAxisVisible;_this24._currentDistanceMeasurement.targetVisible=_this24._currentDistanceMeasurementInitState.targetVisible;_this24._currentDistanceMeasurement.target.worldPos=pointerWorldPos.slice();_this24._markerDiv.style.marginLeft="-10000px";_this24._markerDiv.style.marginTop="-10000px";}});canvas.addEventListener("mousedown",this._onMouseDown=function(e){if(!_this24._active){return;}if(e.which!==1){return;}pointerDownCanvasX=e.clientX;pointerDownCanvasY=e.clientY;});canvas.addEventListener("mouseup",this._onMouseUp=function(e){if(!_this24._active){return;}if(hover)return;if(e.which!==1){return;}if(e.clientX>pointerDownCanvasX+clickTolerance||e.clientX<pointerDownCanvasX-clickTolerance||e.clientY>pointerDownCanvasY+clickTolerance||e.clientY<pointerDownCanvasY-clickTolerance){return;}if(_this24._currentDistanceMeasurement){if(mouseHovering){_this24._currentDistanceMeasurement.target.entity=hoveredEntity;hoveredEntity=null;_this24._currentDistanceMeasurement.clickable=true;_this24.distanceMeasurementsPlugin.fire("measurementEnd",_this24._currentDistanceMeasurement);_this24._currentDistanceMeasurement=null;}else{_this24._currentDistanceMeasurement.destroy();_this24.distanceMeasurementsPlugin.fire("measurementCancel",_this24._currentDistanceMeasurement);_this24._currentDistanceMeasurement=null;hoveredEntity=null;}}else{if(mouseHovering){_this24._currentDistanceMeasurement=distanceMeasurementsPlugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pointerWorldPos.slice()},target:{worldPos:pointerWorldPos.slice()},precision:distanceMeasurementsPlugin.precision,approximate:true});_this24._currentDistanceMeasurementInitState.axisVisible=_this24._currentDistanceMeasurement.axisVisible&&_this24.distanceMeasurementsPlugin.defaultAxisVisible;_this24._currentDistanceMeasurementInitState.xAxisVisible=_this24._currentDistanceMeasurement.xAxisVisible&&_this24.distanceMeasurementsPlugin.defaultXAxisVisible;_this24._currentDistanceMeasurementInitState.yAxisVisible=_this24._currentDistanceMeasurement.yAxisVisible&&_this24.distanceMeasurementsPlugin.defaultYAxisVisible;_this24._currentDistanceMeasurementInitState.zAxisVisible=_this24._currentDistanceMeasurement.zAxisVisible&&_this24.distanceMeasurementsPlugin.defaultZAxisVisible;_this24._currentDistanceMeasurementInitState.wireVisible=_this24._currentDistanceMeasurement.wireVisible;_this24._currentDistanceMeasurementInitState.targetVisible=_this24._currentDistanceMeasurement.targetVisible;_this24._currentDistanceMeasurement.clickable=false;_this24._currentDistanceMeasurement.origin.entity=hoveredEntity;hoveredEntity=null;_this24.fire("measurementStart",_this24._currentDistanceMeasurement);}}});this._onCameraControlHoverSnapOrSurfaceOff=cameraControl.on(this._snapping?"hoverSnapOrSurfaceOff":"hoverOff",function(event){if(!_this24._active){return;}if(_this24.pointerLens){_this24.pointerLens.visible=true;_this24.pointerLens.canvasPos=event.canvasPos;_this24.pointerLens.snappedCanvasPos=event.snappedCanvasPos||event.canvasPos;}mouseHovering=false;_this24._markerDiv.style.marginLeft="-100px";_this24._markerDiv.style.marginTop="-100px";if(_this24._currentDistanceMeasurement){_this24._currentDistanceMeasurement.wireVisible=false;_this24._currentDistanceMeasurement.targetVisible=false;_this24._currentDistanceMeasurement.axisVisible=false;}canvas.style.cursor="default";});this._activate=true;}/**
|
|
3947
3950
|
* Deactivates this DistanceMeasurementsMouseControl, making it unresponsive to input.
|
|
3948
3951
|
*
|
|
3949
3952
|
* Destroys any {@link DistanceMeasurement} under construction by this DistanceMeasurementsMouseControl.
|
|
@@ -4304,6 +4307,9 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._targetDot.s
|
|
|
4304
4307
|
*
|
|
4305
4308
|
* @param {Boolean} labelsShown Whether or not to show the labels.
|
|
4306
4309
|
*/},{key:"setLabelsShown",value:function setLabelsShown(labelsShown){for(var _i36=0,_Object$entries2=Object.entries(this.measurements);_i36<_Object$entries2.length;_i36++){var _Object$entries2$_i=_slicedToArray(_Object$entries2[_i36],2),key=_Object$entries2$_i[0],measurement=_Object$entries2$_i[1];measurement.labelShown=labelsShown;}}/**
|
|
4310
|
+
* 控制所有测量对象显示隐藏
|
|
4311
|
+
* @param {*} visible
|
|
4312
|
+
*/},{key:"setMeasurementsShown",value:function setMeasurementsShown(visible){for(var key in this.measurements){this.measurements[key].visible=visible;}}/**
|
|
4307
4313
|
* Shows all or hides the axis wires of each {@link DistanceMeasurement}.
|
|
4308
4314
|
*
|
|
4309
4315
|
* @param {Boolean} labelsShown Whether or not to show the axis wires.
|
|
@@ -4331,7 +4337,7 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._targetDot.s
|
|
|
4331
4337
|
* @param {_offsetX} [cfg._offsetX] _offsetX of the mouse
|
|
4332
4338
|
* @param {_offsetY} [cfg._offsetY] _offsetY of the mouse
|
|
4333
4339
|
*/function DistanceMeasurementsTouchControl(distanceMeasurementsPlugin){var _this27;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,DistanceMeasurementsTouchControl);_this27=_callSuper(this,DistanceMeasurementsTouchControl,[distanceMeasurementsPlugin.viewer.scene]);_this27.pointerLens=cfg.pointerLens;// this.PointerLens = new PointerLens(distanceMeasurementsPlugin.viewer, { active: true });
|
|
4334
|
-
_this27.pointerCircle=new PointerCircle(distanceMeasurementsPlugin.viewer,{id:"distanceMeasure_Circle"});_this27._active=false;_this27._initMarkerDiv();_this27._currentDistanceMeasurement=null;_this27._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null};_this27._onCanvasTouchStart=null;_this27._onCanvasTouchEnd=null;_this27._longTouchTimeoutMs=300;_this27._snapping=cfg.snapping!==false;_this27._snapToEdge=cfg.snapping!==false;_this27._snapToVertex=cfg.snapping!==false;_this27._touchState=WAITING_FOR_ORIGIN_TOUCH_START;_this27._attachPlugin(distanceMeasurementsPlugin,cfg);_this27._offsetX=cfg._offsetX|0;_this27._offsetY=cfg._offsetY|0;return _this27;}_inherits(DistanceMeasurementsTouchControl,_DistanceMeasurements2);return _createClass(DistanceMeasurementsTouchControl,[{key:"_initMarkerDiv",value:function _initMarkerDiv(){var markerDiv=document.createElement("div");markerDiv.setAttribute("id","myDistanceMeasureTouchMarker");var canvas=this.scene.canvas.canvas;canvas.parentNode.insertBefore(markerDiv,canvas);markerDiv.style.background="black";markerDiv.style.border="2px solid blue";markerDiv.style.borderRadius="10px";markerDiv.style.width="5px";markerDiv.style.height="5px";markerDiv.style.margin="-200px -200px";markerDiv.style.zIndex="100";markerDiv.style.position="absolute";markerDiv.style.pointerEvents="none";this.markerDiv=markerDiv;}},{key:"_destroyMarkerDiv",value:function _destroyMarkerDiv(){if(this.markerDiv){this.markerDiv.parentNode.removeChild(this.markerDiv);this.markerDiv=null;}}},{key:"_attachPlugin",value:function _attachPlugin(distanceMeasurementsPlugin){/**
|
|
4340
|
+
_this27.pointerCircle=new PointerCircle(distanceMeasurementsPlugin.viewer,{id:"distanceMeasure_Circle"});_this27._active=false;_this27._activate=false;_this27._initMarkerDiv();_this27._currentDistanceMeasurement=null;_this27._currentDistanceMeasurementInitState={wireVisible:null,axisVisible:null,xAxisVisible:null,yaxisVisible:null,zAxisVisible:null,targetVisible:null};_this27._onCanvasTouchStart=null;_this27._onCanvasTouchEnd=null;_this27._longTouchTimeoutMs=300;_this27._snapping=cfg.snapping!==false;_this27._snapToEdge=cfg.snapping!==false;_this27._snapToVertex=cfg.snapping!==false;_this27._touchState=WAITING_FOR_ORIGIN_TOUCH_START;_this27._attachPlugin(distanceMeasurementsPlugin,cfg);_this27._offsetX=cfg._offsetX|0;_this27._offsetY=cfg._offsetY|0;return _this27;}_inherits(DistanceMeasurementsTouchControl,_DistanceMeasurements2);return _createClass(DistanceMeasurementsTouchControl,[{key:"_initMarkerDiv",value:function _initMarkerDiv(){var markerDiv=document.createElement("div");markerDiv.setAttribute("id","myDistanceMeasureTouchMarker");var canvas=this.scene.canvas.canvas;canvas.parentNode.insertBefore(markerDiv,canvas);markerDiv.style.background="black";markerDiv.style.border="2px solid blue";markerDiv.style.borderRadius="10px";markerDiv.style.width="5px";markerDiv.style.height="5px";markerDiv.style.margin="-200px -200px";markerDiv.style.zIndex="100";markerDiv.style.position="absolute";markerDiv.style.pointerEvents="none";this.markerDiv=markerDiv;}},{key:"_destroyMarkerDiv",value:function _destroyMarkerDiv(){if(this.markerDiv){this.markerDiv.parentNode.removeChild(this.markerDiv);this.markerDiv=null;}}},{key:"_attachPlugin",value:function _attachPlugin(distanceMeasurementsPlugin){/**
|
|
4335
4341
|
* The {@link DistanceMeasurementsPlugin} that owns this DistanceMeasurementsTouchControl.
|
|
4336
4342
|
* @type {DistanceMeasurementsPlugin}
|
|
4337
4343
|
*/this.distanceMeasurementsPlugin=distanceMeasurementsPlugin;/**
|
|
@@ -4348,7 +4354,7 @@ _this27.pointerCircle=new PointerCircle(distanceMeasurementsPlugin.viewer,{id:"d
|
|
|
4348
4354
|
*/function get(){return this._offsetY;}/** Gets if this DistanceMeasurementsTouchControl is currently active, where it is responding to input.
|
|
4349
4355
|
*
|
|
4350
4356
|
* @returns {Boolean}
|
|
4351
|
-
*/,set:function set(offsetY){this._offsetY=offsetY;}},{key:"active",get:function get(){return this._active;}/**
|
|
4357
|
+
*/,set:function set(offsetY){this._offsetY=offsetY;}},{key:"active",get:function get(){return this._active;},set:function set(active){this._active=active;}/**
|
|
4352
4358
|
* Sets whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsTouchControl.
|
|
4353
4359
|
*
|
|
4354
4360
|
* This is `true` by default.
|
|
@@ -4366,7 +4372,7 @@ _this27.pointerCircle=new PointerCircle(distanceMeasurementsPlugin.viewer,{id:"d
|
|
|
4366
4372
|
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsTouchControl.
|
|
4367
4373
|
*/function get(){return this._snapping;}/**
|
|
4368
4374
|
* Activates this DistanceMeasurementsTouchControl, ready to respond to input.
|
|
4369
|
-
*/,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 _this28=this;if(this.
|
|
4375
|
+
*/,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 _this28=this;if(this._activate){return;}var plugin=this.plugin;var scene=this.scene;var canvas=scene.canvas.canvas;this.pointerLens;var pointerWorldPos=math.vec3();var touchTolerance=20;var longTouchTimeout=null;this._touchState=WAITING_FOR_ORIGIN_TOUCH_START;var touchStartCanvasPos=math.vec2();var touchMoveCanvasPos=math.vec2();var touchEndCanvasPos=math.vec2();var touchId=null;var disableCameraNavigation=function disableCameraNavigation(){_this28.plugin.viewer.cameraControl.active=false;};var enableCameraNavigation=function enableCameraNavigation(){_this28.plugin.viewer.cameraControl.active=true;};var cancel=function cancel(){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}if(_this28._currentDistanceMeasurement){_this28._currentDistanceMeasurement.destroy();_this28._currentDistanceMeasurement=null;}enableCameraNavigation();_this28._touchState=WAITING_FOR_ORIGIN_TOUCH_START;};canvas.addEventListener("touchstart",this._onCanvasTouchStart=function(event){if(!_this28._active){return;}if(!event.isTrusted)return;var currentNumTouches=event.touches.length;if(currentNumTouches!==1){if(longTouchTimeout){clearTimeout(longTouchTimeout);longTouchTimeout=null;}return;}var touch=event.touches[0];var touchX=touch.clientX;var touchY=touch.clientY;touchStartCanvasPos.set([touchX+_this28.offsetX,touchY+_this28.offsetY]);touchMoveCanvasPos.set([touchX+_this28.offsetX,touchY+_this28.offsetY]);switch(_this28._touchState){case WAITING_FOR_ORIGIN_TOUCH_START:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
4370
4376
|
cancel();return;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapping:_this28._snapping,snapToEdge:_this28._snapping});if(snapPickResult&&snapPickResult.snapped){pointerWorldPos.set(snapPickResult.worldPos);_this28.pointerCircle.start(snapPickResult.snappedCanvasPos);}else{var pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){pointerWorldPos.set(pickResult.worldPos);_this28.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
|
|
4371
4377
|
}// Long touch
|
|
4372
4378
|
if(_this28.pointerLens){_this28.pointerLens.visible=true;_this28.pointerLens.canvasPos=touchStartCanvasPos;_this28.pointerLens.cursorPos=touchStartCanvasPos;}if(_this28.pointerLens){_this28.pointerLens.canvasPos=touchMoveCanvasPos;_this28.pointerLens.snapped=false;}if(_this28.pointerLens){_this28.pointerLens.cursorPos=snapPickResult.canvasPos;_this28.pointerLens.snapped=true;}// pointerWorldPos.set(snapPickResult.snappedWorldPos);
|
|
@@ -4383,14 +4389,14 @@ return;}// Long touch
|
|
|
4383
4389
|
if(_this28.pointerLens){_this28.pointerLens.visible=true;_this28.pointerLens.canvasPos=touchStartCanvasPos;_this28.pointerLens.snapped=false;}var snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this28._snapping,snapToEdge:_this28._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this28.pointerLens){_this28.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this28.pointerLens.snapped=true;}_this28.pointerCircle.start(snapPickResult.snappedCanvasPos);pointerWorldPos.set(snapPickResult.worldPos);_this28._currentDistanceMeasurement.target.worldPos=snapPickResult.worldPos;_this28._currentDistanceMeasurement.target.entity=snapPickResult.entity;_this28._currentDistanceMeasurement.targetVisible=true;_this28._currentDistanceMeasurement.wireVisible=true;_this28._currentDistanceMeasurement.labelsVisible=true;_this28.distanceMeasurementsPlugin.fire("measurementStart",_this28._currentDistanceMeasurement);}else{var _pickResult6=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(_pickResult6&&_pickResult6.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=_pickResult6.canvasPos;_this28.pointerLens.snapped=false;}_this28.pointerCircle.start(_pickResult6.canvasPos);pointerWorldPos.set(_pickResult6.worldPos);_this28._currentDistanceMeasurement.target.worldPos=_pickResult6.worldPos;_this28._currentDistanceMeasurement.target.entity=_pickResult6.entity;_this28._currentDistanceMeasurement.targetVisible=true;_this28._currentDistanceMeasurement.wireVisible=true;_this28._currentDistanceMeasurement.labelsVisible=true;_this28.distanceMeasurementsPlugin.fire("measurementStart",_this28._currentDistanceMeasurement);}else{if(_this28.pointerLens){_this28.pointerLens.cursorPos=null;_this28.pointerLens.snapped=false;}}}_this28._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END;// console.log("touchstart: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_LONG_TOUCH_END")
|
|
4384
4390
|
disableCameraNavigation();},_this28._longTouchTimeoutMs);_this28._touchState=WAITING_FOR_TARGET_QUICK_TOUCH_END;// console.log("touchstart: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_QUICK_TOUCH_END")
|
|
4385
4391
|
}touchId=touch.identifier;break;default:if(longTouchTimeout!==null){clearTimeout(longTouchTimeout);longTouchTimeout=null;}_this28._touchState=TOUCH_CANCELING;// console.log("touchstart: this._touchState= default -> TOUCH_CANCELING")
|
|
4386
|
-
return;}},{passive:true});canvas.addEventListener("touchmove",function(event){_this28.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+_this28.offsetX,touchY+_this28.offsetY]);var snapPickResult;var pickResult;switch(_this28._touchState){case WAITING_FOR_ORIGIN_LONG_TOUCH_END:if(_this28.pointerLens){_this28.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this28._snapping,snapToEdge:_this28._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this28.pointerLens){_this28.pointerLens.snappedCanvasPos=snapPickResult.snappedCanvasPos;_this28.pointerLens.snapped=true;}pointerWorldPos.set(snapPickResult.worldPos);if(!_this28._currentDistanceMeasurement){_this28._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity},target:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity},precision:plugin.precision});_this28._currentDistanceMeasurement.labelsVisible=false;_this28._currentDistanceMeasurement.xAxisVisible=false;_this28._currentDistanceMeasurement.yAxisVisible=false;_this28._currentDistanceMeasurement.zAxisVisible=false;_this28._currentDistanceMeasurement.wireVisible=false;_this28._currentDistanceMeasurement.originVisible=true;_this28._currentDistanceMeasurement.targetVisible=false;_this28._currentDistanceMeasurement.clickable=false;}else{_this28._currentDistanceMeasurement.origin.worldPos=snapPickResult.worldPos;}_this28.distanceMeasurementsPlugin.fire("measurementStart",_this28._currentDistanceMeasurement);}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=pickResult.canvasPos;_this28.pointerLens.snapped=false;}pointerWorldPos.set(pickResult.worldPos);if(!_this28._currentDistanceMeasurement){_this28._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pickResult.worldPos,entity:pickResult.entity},target:{worldPos:pickResult.worldPos,entity:pickResult.entity},precision:plugin.precision});_this28._currentDistanceMeasurement.labelsVisible=false;_this28._currentDistanceMeasurement.xAxisVisible=false;_this28._currentDistanceMeasurement.yAxisVisible=false;_this28._currentDistanceMeasurement.zAxisVisible=false;_this28._currentDistanceMeasurement.wireVisible=false;_this28._currentDistanceMeasurement.originVisible=true;_this28._currentDistanceMeasurement.targetVisible=false;_this28._currentDistanceMeasurement.clickable=false;}else{_this28._currentDistanceMeasurement.origin.worldPos=pickResult.worldPos;}_this28.distanceMeasurementsPlugin.fire("measurementStart",_this28._currentDistanceMeasurement);}else{if(_this28.pointerLens){_this28.pointerLens.cursorPos=null;_this28.pointerLens.snapped=false;}}}_this28._touchState=WAITING_FOR_ORIGIN_LONG_TOUCH_END;// console.log("touchmove: this._touchState= WAITING_FOR_ORIGIN_LONG_TOUCH_END -> WAITING_FOR_ORIGIN_LONG_TOUCH_END")
|
|
4392
|
+
return;}},{passive:true});canvas.addEventListener("touchmove",function(event){if(!_this28._active){return;}_this28.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+_this28.offsetX,touchY+_this28.offsetY]);var snapPickResult;var pickResult;switch(_this28._touchState){case WAITING_FOR_ORIGIN_LONG_TOUCH_END:if(_this28.pointerLens){_this28.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this28._snapping,snapToEdge:_this28._snapping});if(snapPickResult&&snapPickResult.snapped){if(_this28.pointerLens){_this28.pointerLens.snappedCanvasPos=snapPickResult.snappedCanvasPos;_this28.pointerLens.snapped=true;}pointerWorldPos.set(snapPickResult.worldPos);if(!_this28._currentDistanceMeasurement){_this28._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity},target:{worldPos:snapPickResult.worldPos,entity:snapPickResult.entity},precision:plugin.precision});_this28._currentDistanceMeasurement.labelsVisible=false;_this28._currentDistanceMeasurement.xAxisVisible=false;_this28._currentDistanceMeasurement.yAxisVisible=false;_this28._currentDistanceMeasurement.zAxisVisible=false;_this28._currentDistanceMeasurement.wireVisible=false;_this28._currentDistanceMeasurement.originVisible=true;_this28._currentDistanceMeasurement.targetVisible=false;_this28._currentDistanceMeasurement.clickable=false;}else{_this28._currentDistanceMeasurement.origin.worldPos=snapPickResult.worldPos;}_this28.distanceMeasurementsPlugin.fire("measurementStart",_this28._currentDistanceMeasurement);}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=pickResult.canvasPos;_this28.pointerLens.snapped=false;}pointerWorldPos.set(pickResult.worldPos);if(!_this28._currentDistanceMeasurement){_this28._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pickResult.worldPos,entity:pickResult.entity},target:{worldPos:pickResult.worldPos,entity:pickResult.entity},precision:plugin.precision});_this28._currentDistanceMeasurement.labelsVisible=false;_this28._currentDistanceMeasurement.xAxisVisible=false;_this28._currentDistanceMeasurement.yAxisVisible=false;_this28._currentDistanceMeasurement.zAxisVisible=false;_this28._currentDistanceMeasurement.wireVisible=false;_this28._currentDistanceMeasurement.originVisible=true;_this28._currentDistanceMeasurement.targetVisible=false;_this28._currentDistanceMeasurement.clickable=false;}else{_this28._currentDistanceMeasurement.origin.worldPos=pickResult.worldPos;}_this28.distanceMeasurementsPlugin.fire("measurementStart",_this28._currentDistanceMeasurement);}else{if(_this28.pointerLens){_this28.pointerLens.cursorPos=null;_this28.pointerLens.snapped=false;}}}_this28._touchState=WAITING_FOR_ORIGIN_LONG_TOUCH_END;// console.log("touchmove: this._touchState= WAITING_FOR_ORIGIN_LONG_TOUCH_END -> WAITING_FOR_ORIGIN_LONG_TOUCH_END")
|
|
4387
4393
|
break;// case WAITING_FOR_TARGET_TOUCH_START:
|
|
4388
4394
|
// this._touchState = WAITING_FOR_TARGET_TOUCH_START;
|
|
4389
4395
|
// console.log("touchmove: this._touchState= WAITING_FOR_TARGET_TOUCH_START -> WAITING_FOR_TARGET_TOUCH_START")
|
|
4390
4396
|
// break;
|
|
4391
4397
|
case WAITING_FOR_TARGET_LONG_TOUCH_END:if(currentNumTouches!==1&&longTouchTimeout!==null){// Two or more fingers down
|
|
4392
4398
|
clearTimeout(longTouchTimeout);longTouchTimeout=null;if(_this28.pointerLens){_this28.pointerLens.visible=false;}_this28._touchState=TOUCH_CANCELING;// console.log("touchmove: this._touchState= QUICK_TOUCH_FINDING_TARGET -> TOUCH_CANCELING")
|
|
4393
|
-
return;}if(_this28.pointerLens){_this28.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this28._snapping,snapToEdge:_this28._snapping});if(snapPickResult&&snapPickResult.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this28.pointerLens.snapped=true;}_this28._currentDistanceMeasurement.target.worldPos=snapPickResult.worldPos;_this28._currentDistanceMeasurement.target.entity=snapPickResult.entity;_this28._currentDistanceMeasurement.targetVisible=true;_this28._currentDistanceMeasurement.wireVisible=true;_this28._currentDistanceMeasurement.labelsVisible=true;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=pickResult.canvasPos;_this28.pointerLens.snapped=false;}_this28._currentDistanceMeasurement.target.worldPos=pickResult.worldPos;_this28._currentDistanceMeasurement.target.entity=pickResult.entity;_this28._currentDistanceMeasurement.targetVisible=true;_this28._currentDistanceMeasurement.wireVisible=true;_this28._currentDistanceMeasurement.labelsVisible=true;}}_this28._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END;break;}},{passive:true});canvas.addEventListener("touchend",this._onCanvasTouchEnd=function(event){_this28.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(_this28._touchState){//等待起点短按
|
|
4399
|
+
return;}if(_this28.pointerLens){_this28.pointerLens.canvasPos=touchMoveCanvasPos;}snapPickResult=scene.pick({canvasPos:touchMoveCanvasPos,snapToVertex:_this28._snapping,snapToEdge:_this28._snapping});if(snapPickResult&&snapPickResult.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=snapPickResult.snappedCanvasPos;_this28.pointerLens.snapped=true;}_this28._currentDistanceMeasurement.target.worldPos=snapPickResult.worldPos;_this28._currentDistanceMeasurement.target.entity=snapPickResult.entity;_this28._currentDistanceMeasurement.targetVisible=true;_this28._currentDistanceMeasurement.wireVisible=true;_this28._currentDistanceMeasurement.labelsVisible=true;}else{pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){if(_this28.pointerLens){_this28.pointerLens.cursorPos=pickResult.canvasPos;_this28.pointerLens.snapped=false;}_this28._currentDistanceMeasurement.target.worldPos=pickResult.worldPos;_this28._currentDistanceMeasurement.target.entity=pickResult.entity;_this28._currentDistanceMeasurement.targetVisible=true;_this28._currentDistanceMeasurement.wireVisible=true;_this28._currentDistanceMeasurement.labelsVisible=true;}}_this28._touchState=WAITING_FOR_TARGET_LONG_TOUCH_END;break;}},{passive:true});canvas.addEventListener("touchend",this._onCanvasTouchEnd=function(event){if(!_this28._active){return;}_this28.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(_this28._touchState){//等待起点短按
|
|
4394
4400
|
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){_this28._touchState=WAITING_FOR_ORIGIN_TOUCH_START;return;}var pickResult=scene.pick({canvasPos:touchMoveCanvasPos,pickSurface:true});if(pickResult&&pickResult.worldPos){_this28._currentDistanceMeasurement=plugin.createMeasurement({id:math.createUUID(),origin:{worldPos:pickResult.worldPos,entity:pickResult.entity},target:{worldPos:pickResult.worldPos,entity:pickResult.entity},precision:plugin.precision});_this28._currentDistanceMeasurement.labelsVisible=false;_this28._currentDistanceMeasurement.xAxisVisible=false;_this28._currentDistanceMeasurement.yAxisVisible=false;_this28._currentDistanceMeasurement.zAxisVisible=false;_this28._currentDistanceMeasurement.wireVisible=false;_this28._currentDistanceMeasurement.originVisible=true;_this28._currentDistanceMeasurement.targetVisible=false;// this._currentDistanceMeasurement.clickable = false;
|
|
4395
4401
|
_this28._touchState=WAITING_FOR_TARGET_TOUCH_START;_this28.distanceMeasurementsPlugin.fire("measurementStart",_this28._currentDistanceMeasurement);// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_QUICK_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
4396
4402
|
}else{if(_this28._currentDistanceMeasurement){_this28._currentDistanceMeasurement.destroy();}_this28._touchState=WAITING_FOR_ORIGIN_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_ORIGIN_QUICK_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
@@ -4402,7 +4408,7 @@ case WAITING_FOR_TARGET_QUICK_TOUCH_END:{if(numChangedTouches!==1||touchX>touchS
|
|
|
4402
4408
|
}enableCameraNavigation();break;//终点长按
|
|
4403
4409
|
case WAITING_FOR_TARGET_LONG_TOUCH_END:if(_this28.pointerLens){_this28.pointerLens.visible=false;}if(!_this28._currentDistanceMeasurement||!_this28._currentDistanceMeasurement.targetVisible){if(_this28._currentDistanceMeasurement){_this28._currentDistanceMeasurement.destroy();_this28._currentDistanceMeasurement=null;}_this28._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")
|
|
4404
4410
|
}else{_this28._currentDistanceMeasurement.clickable=true;_this28.distanceMeasurementsPlugin.fire("measurementEnd",_this28._currentDistanceMeasurement);_this28._currentDistanceMeasurement=null;_this28._touchState=WAITING_FOR_ORIGIN_TOUCH_START;// console.log("touchend: this._touchState= WAITING_FOR_TARGET_LONG_TOUCH_END -> WAITING_FOR_ORIGIN_TOUCH_START")
|
|
4405
|
-
}enableCameraNavigation();break;}},{passive:true});canvas.addEventListener("touchcancel",this._onCanvasTouchEnd);this.
|
|
4411
|
+
}enableCameraNavigation();break;}},{passive:true});canvas.addEventListener("touchcancel",this._onCanvasTouchEnd);this._activate=true;}/**
|
|
4406
4412
|
* Deactivates this DistanceMeasurementsTouchControl, making it unresponsive to input.
|
|
4407
4413
|
*
|
|
4408
4414
|
* Destroys any {@link DistanceMeasurement} under construction.
|
|
@@ -13591,7 +13597,7 @@ var sectionPlane=new SectionPlane(this.viewer.scene,{id:params.id,pos:params.pos
|
|
|
13591
13597
|
* Shows the 3D editing gizmo for a {@link SectionPlane}.
|
|
13592
13598
|
*
|
|
13593
13599
|
* @param {String} id ID of the {@link SectionPlane}.
|
|
13594
|
-
*/},{key:"showControl",value:function showControl(id){var control=this._controls[id];if(!control){this.error("Control not found: "+id);return;}
|
|
13600
|
+
*/},{key:"showControl",value:function showControl(id){var control=this._controls[id];if(!control){this.error("Control not found: "+id);return;}control.setVisible(true);if(this._overview){this._overview.setPlaneSelected(id,true);}this._shownControlId=id;this._shownControlIds=[id];}/**
|
|
13595
13601
|
* 设置剖切对象的尺寸
|
|
13596
13602
|
* @param {*} size
|
|
13597
13603
|
*/},{key:"setControlsSize",value:function setControlsSize(size){for(var id in this._controls){this._controls[id].controlSize=size;}}/**
|
|
@@ -24666,7 +24672,8 @@ mouseDownLeft=false;mouseDownMiddle=false;mouseDownRight=false;break;}});this.ca
|
|
|
24666
24672
|
getCanvasPosFromEvent$3(e,canvasPos);var x=canvasPos[0];var y=canvasPos[1];if(Math.abs(x-lastXDown)<3&&Math.abs(y-lastYDown)<3){controllers.cameraControl.fire("rightClick",{// For context menus
|
|
24667
24673
|
pagePos:[Math.round(e.pageX),Math.round(e.pageY)],canvasPos:canvasPos,event:e},true);}break;}_this123.canvas.style.removeProperty("cursor");});this.canvas.addEventListener("mouseenter",this._mouseEnterHandler=function(){if(!(configs.active&&configs.pointerEnabled)){return;}});var maxElapsed=1/20;var minElapsed=1/60;var secsNowLast=null;var enableMove=true;this._scene.on("collideWithEntity",function(collideWithEntity){enableMove=!collideWithEntity;});this.canvas.addEventListener("wheel",this._mouseWheelHandler=function(e){e.preventDefault();if(!(configs.active&&configs.pointerEnabled)){return;}if(e.deltaY<0&&!enableMove)return;var secsNow=performance.now()/1000.0;var secsElapsed=secsNowLast!==null?secsNow-secsNowLast:0;secsNowLast=secsNow;if(secsElapsed>maxElapsed){secsElapsed=maxElapsed;}if(secsElapsed<minElapsed){secsElapsed=minElapsed;}var delta=Math.max(-1,Math.min(1,-e.deltaY*40));if(delta===0){return;}var normalizedDelta=delta/Math.abs(delta);updates.dollyDelta+=-normalizedDelta*secsElapsed*configs.mouseWheelDollyRate;if(mouseMovedOnCanvasSinceLastWheel){states.followPointerDirty=true;mouseMovedOnCanvasSinceLastWheel=false;}});}return _createClass(MousePanRotateDollyHandler,[{key:"reset",value:function reset(){}},{key:"destroy",value:function destroy(){if(this.canvas!=null){this.canvas.removeEventListener("mousedown",this._mouseDownHandler);this.canvas.removeEventListener("mousemove",this._canvasMouseMoveHandler);this.canvas.removeEventListener("mouseup",this._mouseUpHandler);this.canvas.removeEventListener("mouseenter",this._mouseEnterHandler);this.canvas.removeEventListener("wheel",this._mouseWheelHandler);}document.removeEventListener("keydown",this._documentKeyDownHandler);document.removeEventListener("keyup",this._documentKeyUpHandler);document.removeEventListener("mousemove",this._documentMouseMoveHandler);document.removeEventListener("mouseup",this._documentMouseUpHandler);}}]);}();var center=math.vec3();var tempVec3a=math.vec3();var tempVec3b=math.vec3();var tempVec3c=math.vec3();var tempVec3d=math.vec3();var tempCameraTarget={eye:math.vec3(),look:math.vec3(),up:math.vec3()};/**
|
|
24668
24674
|
* @private
|
|
24669
|
-
*/var KeyboardAxisViewHandler=/*#__PURE__*/function(){function KeyboardAxisViewHandler(scene,controllers,configs,states){_classCallCheck(this,KeyboardAxisViewHandler);this._scene=scene;this.input=scene.input;var cameraControl=controllers.cameraControl;var camera=scene.camera;this._onSceneKeyDown=scene.input.on("keydown",function(){if(!(configs.active&&configs.pointerEnabled)||!scene.input.keyboardEnabled){return;}if(!states.mouseover){return;}var axisViewRight=cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_RIGHT);var axisViewBack=cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_BACK);var axisViewLeft=cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_LEFT);var axisViewFront=cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_FRONT);var axisViewTop=cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_TOP);var axisViewBottom=cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_BOTTOM);if(!axisViewRight&&!axisViewBack&&!axisViewLeft&&!axisViewFront&&!axisViewTop&&!axisViewBottom){return;}var aabb=scene.aabb;var diag=math.getAABB3Diag(aabb);math.getAABB3Center(aabb,center);var perspectiveDist=Math.abs(diag/Math.tan(controllers.cameraFlight.fitFOV*math.DEGTORAD));var orthoScale=diag*1.1;tempCameraTarget.orthoScale=orthoScale
|
|
24675
|
+
*/var KeyboardAxisViewHandler=/*#__PURE__*/function(){function KeyboardAxisViewHandler(scene,controllers,configs,states){_classCallCheck(this,KeyboardAxisViewHandler);this._scene=scene;this.input=scene.input;var cameraControl=controllers.cameraControl;var camera=scene.camera;this._onSceneKeyDown=scene.input.on("keydown",function(){if(!(configs.active&&configs.pointerEnabled)||!scene.input.keyboardEnabled){return;}if(!states.mouseover){return;}var axisViewRight=cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_RIGHT);var axisViewBack=cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_BACK);var axisViewLeft=cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_LEFT);var axisViewFront=cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_FRONT);var axisViewTop=cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_TOP);var axisViewBottom=cameraControl._isKeyDownForAction(cameraControl.AXIS_VIEW_BOTTOM);if(!axisViewRight&&!axisViewBack&&!axisViewLeft&&!axisViewFront&&!axisViewTop&&!axisViewBottom){return;}var aabb=scene.aabb;var diag=math.getAABB3Diag(aabb);math.getAABB3Center(aabb,center);var perspectiveDist=Math.abs(diag/Math.tan(controllers.cameraFlight.fitFOV*math.DEGTORAD));var orthoScale=diag*1.1;tempCameraTarget.orthoScale=orthoScale;// 点击键盘切换相机方向
|
|
24676
|
+
if(axisViewRight){tempCameraTarget.eye.set(math.addVec3(center,math.mulVec3Scalar(camera.worldRight,perspectiveDist,tempVec3a),tempVec3d));tempCameraTarget.look.set(center);tempCameraTarget.up.set(camera.worldUp);}else if(axisViewBack){tempCameraTarget.eye.set(math.addVec3(center,math.mulVec3Scalar(camera.worldForward,perspectiveDist,tempVec3a),tempVec3d));tempCameraTarget.look.set(center);tempCameraTarget.up.set(camera.worldUp);}else if(axisViewLeft){tempCameraTarget.eye.set(math.addVec3(center,math.mulVec3Scalar(camera.worldRight,-perspectiveDist,tempVec3a),tempVec3d));tempCameraTarget.look.set(center);tempCameraTarget.up.set(camera.worldUp);}else if(axisViewFront){tempCameraTarget.eye.set(math.addVec3(center,math.mulVec3Scalar(camera.worldForward,-perspectiveDist,tempVec3a),tempVec3d));tempCameraTarget.look.set(center);tempCameraTarget.up.set(camera.worldUp);}else if(axisViewTop){tempCameraTarget.eye.set(math.addVec3(center,math.mulVec3Scalar(camera.worldUp,perspectiveDist,tempVec3a),tempVec3d));tempCameraTarget.look.set(center);tempCameraTarget.up.set(math.normalizeVec3(math.mulVec3Scalar(camera.worldForward,1,tempVec3b),tempVec3c));}else if(axisViewBottom){tempCameraTarget.eye.set(math.addVec3(center,math.mulVec3Scalar(camera.worldUp,-perspectiveDist,tempVec3a),tempVec3d));tempCameraTarget.look.set(center);tempCameraTarget.up.set(math.normalizeVec3(math.mulVec3Scalar(camera.worldForward,-1,tempVec3b)));}if(!configs.firstPerson&&configs.followPointer){controllers.pivotController.setPivotPos(center);}if(controllers.cameraFlight.duration>0){controllers.cameraFlight.flyTo(tempCameraTarget,function(){if(controllers.pivotController.getPivoting()&&configs.followPointer){controllers.pivotController.showPivot();}});}else{controllers.cameraFlight.jumpTo(tempCameraTarget);if(controllers.pivotController.getPivoting()&&configs.followPointer){controllers.pivotController.showPivot();}}});}return _createClass(KeyboardAxisViewHandler,[{key:"reset",value:function reset(){}},{key:"destroy",value:function destroy(){this.input.off(this._onSceneKeyDown);}}]);}();/**
|
|
24670
24677
|
* @private
|
|
24671
24678
|
*/var MousePickHandler=/*#__PURE__*/function(){function MousePickHandler(scene,controllers,configs,states,updates){var _this124=this;_classCallCheck(this,MousePickHandler);this._scene=scene;var pickController=controllers.pickController;var pivotController=controllers.pivotController;var cameraControl=controllers.cameraControl;this._clicks=0;this._timeout=null;this._lastPickedEntityId=null;var leftDown=false;var rightDown=false;this.canvas=this._scene.canvas.canvas;var tickifiedMouseMoveFn=scene.tickify(this._canvasMouseMoveHandler=function(e){if(!(configs.active&&configs.pointerEnabled)){return;}if(leftDown||rightDown){return;}var hoverSubs=cameraControl.hasSubs("hover");var hoverEnterSubs=cameraControl.hasSubs("hoverEnter");var hoverOutSubs=cameraControl.hasSubs("hoverOut");var hoverOffSubs=cameraControl.hasSubs("hoverOff");var hoverSurfaceSubs=cameraControl.hasSubs("hoverSurface");var hoverSnapOrSurfaceSubs=cameraControl.hasSubs("hoverSnapOrSurface");if(hoverSubs||hoverEnterSubs||hoverOutSubs||hoverOffSubs||hoverSurfaceSubs||hoverSnapOrSurfaceSubs){pickController.pickCursorPos=states.pointerCanvasPos;pickController.schedulePickEntity=true;pickController.schedulePickSurface=hoverSurfaceSubs;pickController.scheduleSnapOrPick=hoverSnapOrSurfaceSubs;pickController.update();if(pickController.pickResult){if(pickController.pickResult.entity){var pickedEntityId=pickController.pickResult.entity.id;if(_this124._lastPickedEntityId!==pickedEntityId){if(_this124._lastPickedEntityId!==undefined){cameraControl.fire("hoverOut",{// Hovered off an entity
|
|
24672
24679
|
entity:scene.objects[_this124._lastPickedEntityId]},true);}cameraControl.fire("hoverEnter",pickController.pickResult,true);// Hovering over a new entity
|
|
@@ -24731,14 +24738,18 @@ pickController.pickCursorPos=states.pointerCanvasPos;pickController.schedulePick
|
|
|
24731
24738
|
// }
|
|
24732
24739
|
},false);}return _createClass(MousePickHandler,[{key:"reset",value:function reset(){this._clicks=0;this._lastPickedEntityId=null;if(this._timeout){window.clearTimeout(this._timeout);this._timeout=null;}}},{key:"destroy",value:function destroy(){if(this.canvas!=null){this.canvas.removeEventListener("mousemove",this._canvasMouseMoveHandler);this.canvas.removeEventListener("mousedown",this._canvasMouseDownHandler);this.canvas.removeEventListener("dblclick",this._canvasDblClickHandler);this.canvas.removeEventListener("mouseup",this._canvasMouseUpHandler);}document.removeEventListener("mouseup",this._documentMouseUpHandler);if(this._timeout){window.clearTimeout(this._timeout);this._timeout=null;}}}]);}();/**
|
|
24733
24740
|
* @private
|
|
24734
|
-
*/var KeyboardPanRotateDollyHandler=/*#__PURE__*/function(){function KeyboardPanRotateDollyHandler(scene,controllers,configs,states,updates){_classCallCheck(this,KeyboardPanRotateDollyHandler);this._scene=scene;this._updates=updates;var input=scene.input;this.input=input;var keyDownMap=[];var canvas=scene.canvas.canvas;var mouseMovedSinceLastKeyboardDolly=true;this._onSceneMouseMove=input.on("mousemove",function(){mouseMovedSinceLastKeyboardDolly=true;});this._onSceneKeyDown=input.on("keydown",function(keyCode){if(!(configs.active&&configs.pointerEnabled)||!scene.input.keyboardEnabled){return;}if(!states.mouseover){return;}keyDownMap[keyCode]=true;if(keyCode===input.KEY_SHIFT){canvas.style.cursor="move";}});this._onSceneKeyUp=input.on("keyup",function(keyCode){if(!(configs.active&&configs.pointerEnabled)||!scene.input.keyboardEnabled){return;}keyDownMap[keyCode]=false;if(keyCode===input.KEY_SHIFT){canvas.style.cursor=null;}if(controllers.pivotController.getPivoting()){controllers.pivotController.endPivot();}
|
|
24741
|
+
*/var KeyboardPanRotateDollyHandler=/*#__PURE__*/function(){function KeyboardPanRotateDollyHandler(scene,controllers,configs,states,updates,moveRate){var _this125=this;_classCallCheck(this,KeyboardPanRotateDollyHandler);this._scene=scene;this._updates=updates;var input=scene.input;this.input=input;var keyDownMap=[];this._movespeed=moveRate?moveRate:1;var canvas=scene.canvas.canvas;var enableSetSpeedUp=false;var enableSetSpeedDown=false;var mouseMovedSinceLastKeyboardDolly=true;this._onSceneMouseMove=input.on("mousemove",function(){mouseMovedSinceLastKeyboardDolly=true;});this._onSceneKeyDown=input.on("keydown",function(keyCode){if(!(configs.active&&configs.pointerEnabled)||!scene.input.keyboardEnabled){return;}if(!states.mouseover){return;}keyDownMap[keyCode]=true;if(keyCode===input.KEY_SHIFT){canvas.style.cursor="move";}if(keyCode===input.KEY_EQUAL_SIGN){if(!enableSetSpeedUp){enableSetSpeedUp=true;console.log("KEY_EQUAL_SIGN",enableSetSpeedUp);}}if(keyCode===input.KEY_DASH){if(!enableSetSpeedDown){enableSetSpeedDown=true;console.log("KEY_DASH",enableSetSpeedDown);}}});this._onSceneKeyUp=input.on("keyup",function(keyCode){if(!(configs.active&&configs.pointerEnabled)||!scene.input.keyboardEnabled){return;}keyDownMap[keyCode]=false;if(keyCode===input.KEY_SHIFT){canvas.style.cursor=null;}if(controllers.pivotController.getPivoting()){controllers.pivotController.endPivot();}if(keyCode===input.KEY_ADD){enableSetSpeedUp=false;}if(keyCode===input.KEY_SUBTRACT){enableSetSpeedDown=false;}});//碰撞停止
|
|
24742
|
+
var enableForward=true;this._scene.on("collideWithEntity",function(collideWithEntity){enableForward=!collideWithEntity;});this._onTick=scene.on("tick",function(e){if(!(configs.active&&configs.pointerEnabled)||!scene.input.keyboardEnabled){return;}if(!states.mouseover){return;}var cameraControl=controllers.cameraControl;var elapsedSecs=e.deltaTime/1000.0;//-------------------------------------------------------------------------------------------------
|
|
24735
24743
|
// Keyboard rotation
|
|
24736
24744
|
//-------------------------------------------------------------------------------------------------
|
|
24737
|
-
if(!configs.planView){var rotateYPos=cameraControl._isKeyDownForAction(cameraControl.ROTATE_Y_POS,keyDownMap);var rotateYNeg=cameraControl._isKeyDownForAction(cameraControl.ROTATE_Y_NEG,keyDownMap);var rotateXPos=cameraControl._isKeyDownForAction(cameraControl.ROTATE_X_POS,keyDownMap);var rotateXNeg=cameraControl._isKeyDownForAction(cameraControl.ROTATE_X_NEG,keyDownMap);var orbitDelta=elapsedSecs*configs.keyboardRotationRate;if(rotateYPos||rotateYNeg||rotateXPos||rotateXNeg){if(!configs.firstPerson&&configs.followPointer){controllers.pivotController.startPivot();}if(rotateYPos){updates.rotateDeltaY+=orbitDelta;}else if(rotateYNeg){updates.rotateDeltaY-=orbitDelta;}if(rotateXPos){updates.rotateDeltaX+=orbitDelta;}else if(rotateXNeg){updates.rotateDeltaX-=orbitDelta;}if(!configs.firstPerson&&configs.followPointer){controllers.pivotController.startPivot();}}}//-------------------------------------------------------------------------------------------------
|
|
24745
|
+
if(!configs.planView){var rotateYPos=cameraControl._isKeyDownForAction(cameraControl.ROTATE_Y_POS,keyDownMap);var rotateYNeg=cameraControl._isKeyDownForAction(cameraControl.ROTATE_Y_NEG,keyDownMap);var rotateXPos=cameraControl._isKeyDownForAction(cameraControl.ROTATE_X_POS,keyDownMap);var rotateXNeg=cameraControl._isKeyDownForAction(cameraControl.ROTATE_X_NEG,keyDownMap);var orbitDelta=elapsedSecs*configs.keyboardRotationRate;if(rotateYPos||rotateYNeg||rotateXPos||rotateXNeg){if(!configs.firstPerson&&configs.followPointer){controllers.pivotController.startPivot();}if(rotateYPos){updates.rotateDeltaY+=orbitDelta*_this125._movespeed;}else if(rotateYNeg){updates.rotateDeltaY-=orbitDelta*_this125._movespeed;}if(rotateXPos){updates.rotateDeltaX+=orbitDelta*_this125._movespeed;}else if(rotateXNeg){updates.rotateDeltaX-=orbitDelta*_this125._movespeed;}if(!configs.firstPerson&&configs.followPointer){controllers.pivotController.startPivot();}}}//-------------------------------------------------------------------------------------------------
|
|
24738
24746
|
// Keyboard panning
|
|
24739
24747
|
//-------------------------------------------------------------------------------------------------
|
|
24740
|
-
if(!keyDownMap[input.KEY_CTRL]&&!keyDownMap[input.KEY_ALT]){var dollyBackwards=cameraControl._isKeyDownForAction(cameraControl.DOLLY_BACKWARDS,keyDownMap);var dollyForwards=cameraControl._isKeyDownForAction(cameraControl.DOLLY_FORWARDS,keyDownMap);if(dollyBackwards||dollyForwards){var dollyDelta=elapsedSecs*configs.keyboardDollyRate;if(!configs.firstPerson&&configs.followPointer){controllers.pivotController.startPivot();}if(dollyForwards){if(!enableForward)return;updates.dollyDelta-=dollyDelta;}else if(dollyBackwards){updates.dollyDelta+=dollyDelta;}if(mouseMovedSinceLastKeyboardDolly){states.followPointerDirty=true;mouseMovedSinceLastKeyboardDolly=false;}}}
|
|
24741
|
-
|
|
24748
|
+
if(!keyDownMap[input.KEY_CTRL]&&!keyDownMap[input.KEY_ALT]){var dollyBackwards=cameraControl._isKeyDownForAction(cameraControl.DOLLY_BACKWARDS,keyDownMap);var dollyForwards=cameraControl._isKeyDownForAction(cameraControl.DOLLY_FORWARDS,keyDownMap);if(dollyBackwards||dollyForwards){var dollyDelta=elapsedSecs*configs.keyboardDollyRate;if(!configs.firstPerson&&configs.followPointer){controllers.pivotController.startPivot();}if(dollyForwards){if(!enableForward)return;updates.dollyDelta-=dollyDelta*_this125._movespeed;}else if(dollyBackwards){updates.dollyDelta+=dollyDelta*_this125._movespeed;}if(mouseMovedSinceLastKeyboardDolly){states.followPointerDirty=true;mouseMovedSinceLastKeyboardDolly=false;}}}// 调整移动速度
|
|
24749
|
+
var speedUP=cameraControl._isKeyDownForAction(cameraControl.SPEED_UP,keyDownMap);var speedDown=cameraControl._isKeyDownForAction(cameraControl.SPEED_DOWN,keyDownMap);if(speedUP||speedDown){if(enableSetSpeedUp){if(_this125._movespeed<2){_this125._movespeed+=0.5;}enableSetSpeedUp=false;}if(enableSetSpeedDown){if(_this125._movespeed>0.5){_this125._movespeed-=0.5;}else{_this125._movespeed-=0.4;}enableSetSpeedDown=false;}}//判断是否能用
|
|
24750
|
+
var panForwards=cameraControl._isKeyDownForAction(cameraControl.PAN_FORWARDS,keyDownMap);var panBackwards=cameraControl._isKeyDownForAction(cameraControl.PAN_BACKWARDS,keyDownMap);var panLeft=cameraControl._isKeyDownForAction(cameraControl.PAN_LEFT,keyDownMap);var panRight=cameraControl._isKeyDownForAction(cameraControl.PAN_RIGHT,keyDownMap);var panUp=cameraControl._isKeyDownForAction(cameraControl.PAN_UP,keyDownMap);var panDown=cameraControl._isKeyDownForAction(cameraControl.PAN_DOWN,keyDownMap);// const panDelta = (keyDownMap[input.KEY_ALT] ? 0.3 : 1.0) * elapsedSecs * configs.keyboardPanRate; // ALT for slower pan rate
|
|
24751
|
+
var panDelta=_this125._movespeed*elapsedSecs*configs.keyboardPanRate;// ALT for slower pan rate
|
|
24752
|
+
if(panForwards||panBackwards||panLeft||panRight||panUp||panDown){if(!configs.firstPerson&&configs.followPointer){controllers.pivotController.startPivot();}if(panDown){updates.panDeltaY+=panDelta;}else if(panUp){updates.panDeltaY+=-panDelta;}if(panRight){updates.panDeltaX+=-panDelta;}else if(panLeft){updates.panDeltaX+=panDelta;}if(panBackwards){updates.panDeltaZ+=panDelta;}else if(panForwards){updates.panDeltaZ+=-panDelta;}}});}return _createClass(KeyboardPanRotateDollyHandler,[{key:"movespeed",get:function get(){return this._movespeed;},set:function set(value){this._movespeed=value;}},{key:"reset",value:function reset(){}},{key:"destroy",value:function destroy(){this._scene.off(this._onTick);this.input.off(this._onSceneMouseMove);this.input.off(this._onSceneKeyDown);this.input.off(this._onSceneKeyUp);}}]);}();var SCALE_DOLLY_EACH_FRAME=1;// Recalculate dolly speed for eye->target distance on each Nth frame
|
|
24742
24753
|
var EPSILON=0.001;var tempVec3=math.vec3();/**
|
|
24743
24754
|
* Handles camera updates on each "tick" that were scheduled by the various controllers.
|
|
24744
24755
|
*
|
|
@@ -24775,7 +24786,7 @@ if(Math.abs(updates.panDeltaX)<EPSILON){updates.panDeltaX=0;}if(Math.abs(updates
|
|
|
24775
24786
|
if(dollyDeltaForDist!==0){if(dollyDeltaForDist<0){cursorType="zoom-in";}else{cursorType="zoom-out";}if(configs.firstPerson){var _verticalEye;var _verticalLook;if(configs.constrainVertical){if(camera.xUp){_verticalEye=camera.eye[0];_verticalLook=camera.look[0];}else if(camera.yUp){_verticalEye=camera.eye[1];_verticalLook=camera.look[1];}else if(camera.zUp){_verticalEye=camera.eye[2];_verticalLook=camera.look[2];}}if(configs.followPointer){var dolliedThroughSurface=panController.dollyToCanvasPos(followPointerWorldPos,states.pointerCanvasPos,-dollyDeltaForDist);if(dolliedThroughSurface){states.followPointerDirty=true;}}else{camera.pan([0,0,dollyDeltaForDist]);camera.ortho.scale=camera.ortho.scale-dollyDeltaForDist;}if(configs.constrainVertical){var _eye=camera.eye;var _look=camera.look;if(camera.xUp){_eye[0]=_verticalEye;_look[0]=_verticalLook;}else if(camera.yUp){_eye[1]=_verticalEye;_look[1]=_verticalLook;}else if(camera.zUp){_eye[2]=_verticalEye;_look[2]=_verticalLook;}camera.eye=_eye;camera.look=_look;}}else if(configs.planView){if(configs.followPointer){var _dolliedThroughSurface=panController.dollyToCanvasPos(followPointerWorldPos,states.pointerCanvasPos,-dollyDeltaForDist);if(_dolliedThroughSurface){states.followPointerDirty=true;}}else{camera.ortho.scale=camera.ortho.scale+dollyDeltaForDist;camera.zoom(dollyDeltaForDist);}}else{// Orbiting
|
|
24776
24787
|
if(configs.followPointer){var _dolliedThroughSurface2=panController.dollyToCanvasPos(followPointerWorldPos,states.pointerCanvasPos,-dollyDeltaForDist);if(_dolliedThroughSurface2){states.followPointerDirty=true;}}else{camera.ortho.scale=camera.ortho.scale+dollyDeltaForDist;camera.zoom(dollyDeltaForDist);}}updates.dollyDelta*=configs.dollyInertia;}pickController.fireEvents();document.body.style.cursor=cursorType;});}return _createClass(CameraUpdater,[{key:"destroy",value:function destroy(){this._scene.off(this._onTick);}}]);}();/**
|
|
24777
24788
|
* @private
|
|
24778
|
-
*/var MouseMiscHandler=/*#__PURE__*/function(){function MouseMiscHandler(scene,controllers,configs,states,updates){var
|
|
24789
|
+
*/var MouseMiscHandler=/*#__PURE__*/function(){function MouseMiscHandler(scene,controllers,configs,states,updates){var _this126=this;_classCallCheck(this,MouseMiscHandler);this._scene=scene;this.canvas=this._scene.canvas.canvas;this.canvas.addEventListener("mouseenter",this._mouseEnterHandler=function(){states.mouseover=true;});this.canvas.addEventListener("mouseleave",this._mouseLeaveHandler=function(){states.mouseover=false;_this126.canvas.style.cursor=null;});document.addEventListener("mousemove",this._mouseMoveHandler=function(e){getCanvasPosFromEvent$2(e,_this126.canvas,states.pointerCanvasPos);});this.canvas.addEventListener("mousedown",this._mouseDownHandler=function(e){if(!(configs.active&&configs.pointerEnabled)){return;}getCanvasPosFromEvent$2(e,_this126.canvas,states.pointerCanvasPos);states.mouseover=true;});this.canvas.addEventListener("mouseup",this._mouseUpHandler=function(e){if(!(configs.active&&configs.pointerEnabled)){return;}});}return _createClass(MouseMiscHandler,[{key:"reset",value:function reset(){}},{key:"destroy",value:function destroy(){//网络问题导致的模型加载失败等情况时,如果切换模型,会找不到canvas
|
|
24779
24790
|
//因此暂时在此加判断
|
|
24780
24791
|
if(this.canvas!=null){this.canvas.removeEventListener("mouseenter",this._mouseEnterHandler);this.canvas.removeEventListener("mouseleave",this._mouseLeaveHandler);this.canvas.removeEventListener("mousedown",this._mouseDownHandler);this.canvas.removeEventListener("mouseup",this._mouseUpHandler);}document.removeEventListener("mousemove",this._mouseMoveHandler);}}]);}();function getCanvasPosFromEvent$2(event,canvas,canvasPos){if(!event){event=window.event;canvasPos[0]=event.x;canvasPos[1]=event.y;}else{var _canvas$getBoundingCl=canvas.getBoundingClientRect(),x=_canvas$getBoundingCl.x,y=_canvas$getBoundingCl.y;canvasPos[0]=event.clientX-x;canvasPos[1]=event.clientY-y;}return canvasPos;}var getCanvasPosFromEvent$1=function getCanvasPosFromEvent$1(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;while(element.offsetParent){totalOffsetLeft+=element.offsetLeft;totalOffsetTop+=element.offsetTop;element=element.offsetParent;}canvasPos[0]=event.pageX-totalOffsetLeft;canvasPos[1]=event.pageY-totalOffsetTop;}return canvasPos;};/**
|
|
24781
24792
|
* @private
|
|
@@ -25287,81 +25298,81 @@ cameraControl.fire("touchPickedNothing");}lastTapTime=currentTime;}tapStartTime=
|
|
|
25287
25298
|
*/var CameraControl=/*#__PURE__*/function(_Component38){/**
|
|
25288
25299
|
* @private
|
|
25289
25300
|
* @constructor
|
|
25290
|
-
*/function CameraControl(owner){var
|
|
25301
|
+
*/function CameraControl(owner){var _this127;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,CameraControl);_this127=_callSuper(this,CameraControl,[owner,cfg]);/**
|
|
25291
25302
|
* Identifies the XX action.
|
|
25292
25303
|
* @final
|
|
25293
25304
|
* @type {Number}
|
|
25294
|
-
*/
|
|
25305
|
+
*/_this127.PAN_LEFT=0;/**
|
|
25295
25306
|
* Identifies the XX action.
|
|
25296
25307
|
* @final
|
|
25297
25308
|
* @type {Number}
|
|
25298
|
-
*/
|
|
25309
|
+
*/_this127.PAN_RIGHT=1;/**
|
|
25299
25310
|
* Identifies the XX action.
|
|
25300
25311
|
* @final
|
|
25301
25312
|
* @type {Number}
|
|
25302
|
-
*/
|
|
25313
|
+
*/_this127.PAN_UP=2;/**
|
|
25303
25314
|
* Identifies the XX action.
|
|
25304
25315
|
* @final
|
|
25305
25316
|
* @type {Number}
|
|
25306
|
-
*/
|
|
25317
|
+
*/_this127.PAN_DOWN=3;/**
|
|
25307
25318
|
* Identifies the XX action.
|
|
25308
25319
|
* @final
|
|
25309
25320
|
* @type {Number}
|
|
25310
|
-
*/
|
|
25321
|
+
*/_this127.PAN_FORWARDS=4;/**
|
|
25311
25322
|
* Identifies the XX action.
|
|
25312
25323
|
* @final
|
|
25313
25324
|
* @type {Number}
|
|
25314
|
-
*/
|
|
25325
|
+
*/_this127.PAN_BACKWARDS=5;/**
|
|
25315
25326
|
* Identifies the XX action.
|
|
25316
25327
|
* @final
|
|
25317
25328
|
* @type {Number}
|
|
25318
|
-
*/
|
|
25329
|
+
*/_this127.ROTATE_X_POS=6;/**
|
|
25319
25330
|
* Identifies the XX action.
|
|
25320
25331
|
* @final
|
|
25321
25332
|
* @type {Number}
|
|
25322
|
-
*/
|
|
25333
|
+
*/_this127.ROTATE_X_NEG=7;/**
|
|
25323
25334
|
* Identifies the XX action.
|
|
25324
25335
|
* @final
|
|
25325
25336
|
* @type {Number}
|
|
25326
|
-
*/
|
|
25337
|
+
*/_this127.ROTATE_Y_POS=8;/**
|
|
25327
25338
|
* Identifies the XX action.
|
|
25328
25339
|
* @final
|
|
25329
25340
|
* @type {Number}
|
|
25330
|
-
*/
|
|
25341
|
+
*/_this127.ROTATE_Y_NEG=9;/**
|
|
25331
25342
|
* Identifies the XX action.
|
|
25332
25343
|
* @final
|
|
25333
25344
|
* @type {Number}
|
|
25334
|
-
*/
|
|
25345
|
+
*/_this127.DOLLY_FORWARDS=10;/**
|
|
25335
25346
|
* Identifies the XX action.
|
|
25336
25347
|
* @final
|
|
25337
25348
|
* @type {Number}
|
|
25338
|
-
*/
|
|
25349
|
+
*/_this127.DOLLY_BACKWARDS=11;/**
|
|
25339
25350
|
* Identifies the XX action.
|
|
25340
25351
|
* @final
|
|
25341
25352
|
* @type {Number}
|
|
25342
|
-
*/
|
|
25353
|
+
*/_this127.AXIS_VIEW_RIGHT=12;/**
|
|
25343
25354
|
* Identifies the XX action.
|
|
25344
25355
|
* @final
|
|
25345
25356
|
* @type {Number}
|
|
25346
|
-
*/
|
|
25357
|
+
*/_this127.AXIS_VIEW_BACK=13;/**
|
|
25347
25358
|
* Identifies the XX action.
|
|
25348
25359
|
* @final
|
|
25349
25360
|
* @type {Number}
|
|
25350
|
-
*/
|
|
25361
|
+
*/_this127.AXIS_VIEW_LEFT=14;/**
|
|
25351
25362
|
* Identifies the XX action.
|
|
25352
25363
|
* @final
|
|
25353
25364
|
* @type {Number}
|
|
25354
|
-
*/
|
|
25365
|
+
*/_this127.AXIS_VIEW_FRONT=15;/**
|
|
25355
25366
|
* Identifies the XX action.
|
|
25356
25367
|
* @final
|
|
25357
25368
|
* @type {Number}
|
|
25358
|
-
*/
|
|
25369
|
+
*/_this127.AXIS_VIEW_TOP=16;/**
|
|
25359
25370
|
* Identifies the XX action.
|
|
25360
25371
|
* @final
|
|
25361
25372
|
* @type {Number}
|
|
25362
|
-
*/
|
|
25363
|
-
|
|
25364
|
-
|
|
25373
|
+
*/_this127.AXIS_VIEW_BOTTOM=17;_this127.SPEED_UP=107;_this127.SPEED_DOWN=109;_this127._keyMap={};// Maps key codes to the above actions
|
|
25374
|
+
_this127.scene.canvas.canvas.oncontextmenu=function(e){e.preventDefault();};// User-settable CameraControl configurations
|
|
25375
|
+
_this127._configs={// Private
|
|
25365
25376
|
longTapTimeout:600,// Millisecs
|
|
25366
25377
|
longTapRadius:5,// Pixels
|
|
25367
25378
|
// General
|
|
@@ -25369,16 +25380,13 @@ active:true,keyboardLayout:"qwerty",navMode:"orbit",planView:false,firstPerson:f
|
|
|
25369
25380
|
dragRotationRate:360.0,keyboardRotationRate:90.0,rotationInertia:0.0,// Panning
|
|
25370
25381
|
keyboardPanRate:1.0,touchPanRate:1.0,panInertia:0.5,// Dollying
|
|
25371
25382
|
keyboardDollyRate:10,mouseWheelDollyRate:100,touchDollyRate:0.2,dollyInertia:0,dollyProximityThreshold:30.0,dollyMinSpeed:0.04};// Current runtime state of the CameraControl
|
|
25372
|
-
|
|
25373
|
-
|
|
25374
|
-
var scene=
|
|
25375
|
-
|
|
25376
|
-
|
|
25377
|
-
|
|
25378
|
-
}else{
|
|
25379
|
-
// if (!this._states.mouseover) return;
|
|
25380
|
-
if(!(_this126._goLeft||_this126._goRight||_this126._goUp||_this126._goDown||_this126._goForward||_this126._goBackward)){// this._inputDirectionCommand = false;
|
|
25381
|
-
return;}if(_this126._goRight){_this126._updates.panDeltaX+=-0.1*_this126._moveRate;}else if(_this126._goLeft){_this126._updates.panDeltaX+=0.1*_this126._moveRate;}if(_this126._goUp){_this126._updates.panDeltaY+=0.1*_this126._moveRate;}else if(_this126._goDown){_this126._updates.panDeltaY+=-0.1*_this126._moveRate;}if(_this126._goForward){_this126._updates.panDeltaZ+=-0.1*_this126._moveRate;}else if(_this126._goBackward){_this126._updates.panDeltaZ+=+0.1*_this126._moveRate;}_this126._inputDirectionCommand=true;});return _this126;}/**
|
|
25383
|
+
_this127._states={pointerCanvasPos:math.vec2(),mouseover:false,followPointerDirty:true,mouseDownClientX:0,mouseDownClientY:0,mouseDownCursorX:0,mouseDownCursorY:0,touchStartTime:null,touchEndTime:null,activeTouches:[],tapStartPos:math.vec2(),tapStartTime:-1,lastTapTime:-1,longTouchTimeout:null};// Updates for CameraUpdater to process on next Scene "tick" event
|
|
25384
|
+
_this127._updates={rotateDeltaX:0,rotateDeltaY:0,panDeltaX:0,panDeltaY:0,panDeltaZ:0,dollyDelta:0};// Controllers to assist input event handlers with controlling the Camera
|
|
25385
|
+
var scene=_this127.scene;_this127._controllers={cameraControl:_this127,pickController:new PickController(_this127,_this127._configs),pivotController:new PivotController(scene,_this127._configs),panController:new PanController(scene),cameraFlight:new CameraFlightAnimation(_this127,{duration:0.5})};// Input event handlers
|
|
25386
|
+
_this127._handlers=[new MouseMiscHandler(_this127.scene,_this127._controllers,_this127._configs,_this127._states,_this127._updates),new TouchPanRotateAndDollyHandler(_this127.scene,_this127._controllers,_this127._configs,_this127._states,_this127._updates),new MousePanRotateDollyHandler(_this127.scene,_this127._controllers,_this127._configs,_this127._states,_this127._updates),new KeyboardAxisViewHandler(_this127.scene,_this127._controllers,_this127._configs,_this127._states,_this127._updates),new MousePickHandler(_this127.scene,_this127._controllers,_this127._configs,_this127._states,_this127._updates),new TouchPickHandler(_this127.scene,_this127._controllers,_this127._configs,_this127._states,_this127._updates),new KeyboardPanRotateDollyHandler(_this127.scene,_this127._controllers,_this127._configs,_this127._states,_this127._updates)];// Applies scheduled updates to the Camera on each Scene "tick" event
|
|
25387
|
+
_this127._cameraUpdater=new CameraUpdater(_this127.scene,_this127._controllers,_this127._configs,_this127._states,_this127._updates);// Set initial user configurations
|
|
25388
|
+
_this127.navMode=cfg.navMode;if(cfg.planView){_this127.planView=cfg.planView;}_this127.constrainVertical=cfg.constrainVertical;if(cfg.keyboardLayout){_this127.keyboardLayout=cfg.keyboardLayout;// Deprecated
|
|
25389
|
+
}else{_this127.keyMap=cfg.keyMap;}_this127.doublePickFlyTo=cfg.doublePickFlyTo;_this127.panRightClick=cfg.panRightClick;_this127.active=cfg.active;_this127.followPointer=cfg.followPointer;_this127.rotationInertia=cfg.rotationInertia;_this127.keyboardPanRate=cfg.keyboardPanRate;_this127.touchPanRate=cfg.touchPanRate;_this127.keyboardRotationRate=cfg.keyboardRotationRate;_this127.dragRotationRate=cfg.dragRotationRate;_this127.touchDollyRate=cfg.touchDollyRate;_this127.dollyInertia=cfg.dollyInertia;_this127.dollyProximityThreshold=cfg.dollyProximityThreshold;_this127.dollyMinSpeed=cfg.dollyMinSpeed;_this127.panInertia=cfg.panInertia;_this127.pointerEnabled=true;_this127.keyboardDollyRate=cfg.keyboardDollyRate;_this127.mouseWheelDollyRate=cfg.mouseWheelDollyRate;_this127._moveRate=1;_this127.scene.on("tick",function(){if(!(_this127._goLeft||_this127._goRight||_this127._goUp||_this127._goDown||_this127._goForward||_this127._goBackward)){return;}if(_this127._goRight){_this127._updates.panDeltaX+=-0.1*_this127._moveRate;}else if(_this127._goLeft){_this127._updates.panDeltaX+=0.1*_this127._moveRate;}if(_this127._goUp){_this127._updates.panDeltaY+=0.1*_this127._moveRate;}else if(_this127._goDown){_this127._updates.panDeltaY+=-0.1*_this127._moveRate;}if(_this127._goForward){_this127._updates.panDeltaZ+=-0.1*_this127._moveRate;}else if(_this127._goBackward){_this127._updates.panDeltaZ+=+0.1*_this127._moveRate;}});return _this127;}/**
|
|
25382
25390
|
* 停止漫游
|
|
25383
25391
|
*/_inherits(CameraControl,_Component38);return _createClass(CameraControl,[{key:"setdirectionChangeCancel",value:function setdirectionChangeCancel(){this._goLeft=false;this._goRight=false;this._goUp=false;this._goDown=false;this._goForward=false;this._goBackward=false;}/**
|
|
25384
25392
|
* 设置漫游移动速率
|
|
@@ -25386,7 +25394,7 @@ return;}if(_this126._goRight){_this126._updates.panDeltaX+=-0.1*_this126._moveRa
|
|
|
25386
25394
|
*/},{key:"moveRate",get:function get(){return this._moveRate;}/**
|
|
25387
25395
|
* 漫游向右
|
|
25388
25396
|
* @param {boolean} go
|
|
25389
|
-
*/,set:function set(rate){this._moveRate=rate;}},{key:"goRight",set:function set(go){this._goRight=go;}/**
|
|
25397
|
+
*/,set:function set(rate){this._moveRate=rate;this._handlers[6].movespeed=rate;}},{key:"goRight",set:function set(go){this._goRight=go;}/**
|
|
25390
25398
|
* 漫游向左
|
|
25391
25399
|
* @param {boolean} go
|
|
25392
25400
|
*/},{key:"goLeft",set:function set(go){this._goLeft=go;}/**
|
|
@@ -25418,7 +25426,11 @@ return;}if(_this126._goRight){_this126._updates.panDeltaX+=-0.1*_this126._moveRa
|
|
|
25418
25426
|
* @param keyDownMap
|
|
25419
25427
|
* @private
|
|
25420
25428
|
*/,set:function set(value){value=value||"qwerty";if(utils.isString(value)){var input=this.scene.input;var keyMap={};switch(value){default:this.error("Unsupported value for 'keyMap': "+value+" defaulting to 'qwerty'");// Intentional fall-through to "qwerty"
|
|
25421
|
-
case"qwerty":keyMap[this.
|
|
25429
|
+
case"qwerty":keyMap[this.PAN_UP]=[input.KEY_E];keyMap[this.PAN_DOWN]=[input.KEY_Q];keyMap[this.PAN_LEFT]=[input.KEY_A,input.KEY_LEFT_ARROW];keyMap[this.PAN_RIGHT]=[input.KEY_D,input.KEY_RIGHT_ARROW];keyMap[this.PAN_FORWARDS]=[input.KEY_W,input.KEY_UP_ARROW];keyMap[this.PAN_BACKWARDS]=[input.KEY_S,input.KEY_DOWN_ARROW];keyMap[this.DOLLY_FORWARDS]=[input.KEY_J];keyMap[this.DOLLY_BACKWARDS]=[input.KEY_K];// keyMap[this.ROTATE_Y_POS] = [input.KEY_LEFT_ARROW];
|
|
25430
|
+
// keyMap[this.ROTATE_Y_NEG] = [input.KEY_RIGHT_ARROW];
|
|
25431
|
+
// keyMap[this.ROTATE_X_NEG] = [input.KEY_UP_ARROW];
|
|
25432
|
+
// keyMap[this.ROTATE_X_POS] = [input.KEY_DOWN_ARROW];
|
|
25433
|
+
keyMap[this.AXIS_VIEW_RIGHT]=[input.KEY_NUM_1];keyMap[this.AXIS_VIEW_BACK]=[input.KEY_NUM_2];keyMap[this.AXIS_VIEW_LEFT]=[input.KEY_NUM_3];keyMap[this.AXIS_VIEW_FRONT]=[input.KEY_NUM_4];keyMap[this.AXIS_VIEW_TOP]=[input.KEY_NUM_5];keyMap[this.AXIS_VIEW_BOTTOM]=[input.KEY_NUM_6];keyMap[this.SPEED_UP]=[input.KEY_EQUAL_SIGN];keyMap[this.SPEED_DOWN]=[input.KEY_DASH];break;case"azerty":keyMap[this.PAN_LEFT]=[input.KEY_Q];keyMap[this.PAN_RIGHT]=[input.KEY_D];keyMap[this.PAN_UP]=[input.KEY_W];keyMap[this.PAN_DOWN]=[input.KEY_X];keyMap[this.PAN_BACKWARDS]=[input.KEY_J];keyMap[this.PAN_FORWARDS]=[input.KEY_K];keyMap[this.DOLLY_FORWARDS]=[input.KEY_Z];keyMap[this.DOLLY_BACKWARDS]=[input.KEY_S];keyMap[this.ROTATE_X_POS]=[input.KEY_DOWN_ARROW];keyMap[this.ROTATE_X_NEG]=[input.KEY_UP_ARROW];keyMap[this.ROTATE_Y_POS]=[input.KEY_A,input.KEY_LEFT_ARROW];keyMap[this.ROTATE_Y_NEG]=[input.KEY_E,input.KEY_RIGHT_ARROW];keyMap[this.AXIS_VIEW_RIGHT]=[input.KEY_NUM_1];keyMap[this.AXIS_VIEW_BACK]=[input.KEY_NUM_2];keyMap[this.AXIS_VIEW_LEFT]=[input.KEY_NUM_3];keyMap[this.AXIS_VIEW_FRONT]=[input.KEY_NUM_4];keyMap[this.AXIS_VIEW_TOP]=[input.KEY_NUM_5];keyMap[this.AXIS_VIEW_BOTTOM]=[input.KEY_NUM_6];keyMap[this.SPEED_UP]=[input.KEY_EQUAL_SIGN];keyMap[this.SPEED_DOWN]=[input.KEY_DASH];break;}this._keyMap=keyMap;}else{var _keyMap=value;this._keyMap=_keyMap;}}},{key:"_isKeyDownForAction",value:function _isKeyDownForAction(action,keyDownMap){var keys=this._keyMap[action];if(!keys){return false;}if(!keyDownMap){keyDownMap=this.scene.input.keyDown;}for(var _i503=0,len=keys.length;_i503<len;_i503++){var key=keys[_i503];if(keyDownMap[key]){return true;}}return false;}/**
|
|
25422
25434
|
* Sets the HTMl element to represent the pivot point when {@link CameraControl#followPointer} is true.
|
|
25423
25435
|
*
|
|
25424
25436
|
* See class comments for an example.
|
|
@@ -26411,7 +26423,7 @@ var documentBackgroundColor=ownerDocument.documentElement?parseColor(context,get
|
|
|
26411
26423
|
* configures renderer logic for the specified number of SectionPlanes, eliminating the need for setting up logic with each SectionPlane creation and thereby enhancing
|
|
26412
26424
|
* responsiveness. It is important to consider that each SectionPlane impacts rendering performance, so it is recommended to set this value to a quantity that aligns with
|
|
26413
26425
|
* your expected usage.
|
|
26414
|
-
*/function Viewer(cfg){var
|
|
26426
|
+
*/function Viewer(cfg){var _this128=this;_classCallCheck(this,Viewer);this.container=cfg.viewerElement;/**
|
|
26415
26427
|
* The Viewer's current language setting.
|
|
26416
26428
|
* @property language
|
|
26417
26429
|
* @deprecated
|
|
@@ -26456,7 +26468,7 @@ var documentBackgroundColor=ownerDocument.documentElement?parseColor(context,get
|
|
|
26456
26468
|
* @property cameraControl
|
|
26457
26469
|
* @type {CameraControl}
|
|
26458
26470
|
*/this.cameraControl=new CameraControl(this.scene,{// panToPointer: true,
|
|
26459
|
-
snapRadius:cfg.snapRadius,doublePickFlyTo:true});this.scene.canvas.on("boundary",function(event){
|
|
26471
|
+
snapRadius:cfg.snapRadius,doublePickFlyTo:true});this.scene.canvas.on("boundary",function(event){_this128.cameraControl.updatePivotElement();});this._plugins=[];/**
|
|
26460
26472
|
* Subscriptions to events sent with {@link fire}.
|
|
26461
26473
|
* @private
|
|
26462
26474
|
*/this._eventSubs={};}/**
|
|
@@ -26933,7 +26945,7 @@ if(plugins.length>0){for(var _i518=0,len=plugins.length;_i518<len;_i518++){var p
|
|
|
26933
26945
|
* @param {String[]} [cfg.includeTypes] When loading metadata, only loads objects that have {@link MetaObject}s with {@link MetaObject#type} values in this list.
|
|
26934
26946
|
* @param {String[]} [cfg.excludeTypes] When loading metadata, never loads objects that have {@link MetaObject}s with {@link MetaObject#type} values in this list.
|
|
26935
26947
|
* @param {Boolean} [cfg.excludeUnclassifiedObjects=false] When loading metadata and this is ````true````, will only load {@link Entity}s that have {@link MetaObject}s (that are not excluded). This is useful when we don't want Entitys in the Scene that are not represented within IFC navigation components, such as {@link TreeViewPlugin}.
|
|
26936
|
-
*/function WebIFCLoaderPlugin(viewer){var
|
|
26948
|
+
*/function WebIFCLoaderPlugin(viewer){var _this129;var cfg=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};_classCallCheck(this,WebIFCLoaderPlugin);_this129=_callSuper(this,WebIFCLoaderPlugin,["ifcLoader",viewer,cfg]);_this129.dataSource=cfg.dataSource;_this129.objectDefaults=cfg.objectDefaults;_this129.includeTypes=cfg.includeTypes;_this129.excludeTypes=cfg.excludeTypes;_this129.excludeUnclassifiedObjects=cfg.excludeUnclassifiedObjects;if(cfg.WebIFC){_this129._webIFC=cfg.WebIFC;_this129._ifcAPI=cfg.IfcAPI;_this129.webIfcFroMOutside=true;}// else {
|
|
26937
26949
|
// this._webIFC = WebIFC;
|
|
26938
26950
|
// this.webIfcFroMOutside = false;
|
|
26939
26951
|
// this._ifcAPI = new this._webIFC.IfcAPI();
|
|
@@ -26949,7 +26961,7 @@ if(plugins.length>0){for(var _i518=0,len=plugins.length;_i518<len;_i518++){var p
|
|
|
26949
26961
|
// this.error(e);
|
|
26950
26962
|
// });
|
|
26951
26963
|
// }
|
|
26952
|
-
return
|
|
26964
|
+
return _this129;}/**
|
|
26953
26965
|
* Gets the ````IFC```` format versions supported by this WebIFCLoaderPlugin.
|
|
26954
26966
|
* @returns {string[]}
|
|
26955
26967
|
*/_inherits(WebIFCLoaderPlugin,_Plugin10);return _createClass(WebIFCLoaderPlugin,[{key:"supportedVersions",get:function get(){return["2x3","4"];}/**
|
|
@@ -27094,13 +27106,13 @@ return _this128;}/**
|
|
|
27094
27106
|
// sceneModel.fire("error", e);
|
|
27095
27107
|
// }
|
|
27096
27108
|
// });
|
|
27097
|
-
return sceneModel;}},{key:"_loadModel",value:function _loadModel(src,params,options,sceneModel){var
|
|
27109
|
+
return sceneModel;}},{key:"_loadModel",value:function _loadModel(src,params,options,sceneModel){var _this130=this;var spinner=this.viewer.scene.canvas.spinner;spinner.processes++;this._dataSource.getIFC(params.src,function(arrayBuffer){_this130._parseModel(arrayBuffer,params,options,sceneModel);spinner.processes--;},function(errMsg){spinner.processes--;_this130.error(errMsg);sceneModel.fire("error",errMsg);});}},{key:"_parseModel",value:function _parseModel(arrayBuffer,params,options,sceneModel){if(sceneModel.destroyed){return;}var stats=params.stats||{};stats.sourceFormat="IFC";stats.schemaVersion="";stats.title="";stats.author="";stats.created="";stats.numMetaObjects=0;stats.numPropertySets=0;stats.numObjects=0;stats.numGeometries=0;stats.numTriangles=0;stats.numVertices=0;if(this.webIfcFroMOutside){if(!this._ifcAPI){throw"WebIFCLoaderPlugin has no WebIFC instance configured - please inject via WebIFCLoaderPlugin constructor";}}else{if(options.wasmPath){this._ifcAPI.SetWasmPath(options.wasmPath);}}var dataArray=new Uint8Array(arrayBuffer);var modelID=this._ifcAPI.OpenModel(dataArray);var modelSchema=this._ifcAPI.GetModelSchema(modelID);var lines=this._ifcAPI.GetLineIDsWithType(modelID,this._webIFC.IFCPROJECT);var ifcProjectId=lines.get(0);var loadMetadata=params.loadMetadata!==false;var useOutsideMetadata=params.metadata!==undefined&¶ms.metadata!==null;var outMetadata;if(useOutsideMetadata){outMetadata=params.metadata;}else outMetadata=null;var metadata=loadMetadata?{id:"",projectId:""+ifcProjectId,author:"",createdAt:"",schema:"",creatingApplication:"",metaObjects:[],propertySets:[]}:outMetadata;var ctx={ifcProjectId:ifcProjectId,modelID:modelID,modelSchema:modelSchema,sceneModel:sceneModel,loadMetadata:loadMetadata,metadata:metadata,metaObjects:useOutsideMetadata?sceneModel.metaObjects:{},options:options,// log: function (msg) {},
|
|
27098
27110
|
nextId:0,stats:stats};if(loadMetadata){if(options.includeTypes){ctx.includeTypes={};for(var _i521=0,len=options.includeTypes.length;_i521<len;_i521++){ctx.includeTypes[options.includeTypes[_i521]]=true;}}if(options.excludeTypes){ctx.excludeTypes={};for(var _i522=0,_len106=options.excludeTypes.length;_i522<_len106;_i522++){ctx.excludeTypes[options.excludeTypes[_i522]]=true;}}this._parseMetaObjects(ctx);this._parsePropertySets(ctx);}this._parseGeometry(ctx);sceneModel.finalize();if(loadMetadata||useOutsideMetadata){var metaModelId=sceneModel.id;this.viewer.metaScene.createMetaModel(metaModelId,ctx.metadata,options);}sceneModel.scene.once("tick",function(){if(sceneModel.destroyed){return;}sceneModel.scene.fire("modelLoaded",sceneModel.id);// FIXME: Assumes listeners know order of these two events
|
|
27099
27111
|
sceneModel.fire("loaded",true,false);// Don't forget the event, for late subscribers
|
|
27100
|
-
});}},{key:"_parseMetaObjects",value:function _parseMetaObjects(ctx){var ifcProject=this._ifcAPI.GetLine(ctx.modelID,ctx.ifcProjectId);this._parseSpatialChildren(ctx,ifcProject);}},{key:"_parseSpatialChildren",value:function _parseSpatialChildren(ctx,ifcElement,parentMetaObjectId){var metaObjectType=this._ifcAPI.GetNameFromTypeCode(ifcElement.type);if(ctx.includeTypes&&!ctx.includeTypes[metaObjectType]){return;}if(ctx.excludeTypes&&ctx.excludeTypes[metaObjectType]){return;}this._createMetaObject(ctx,ifcElement,parentMetaObjectId);var metaObjectId=ifcElement.GlobalId.value;this._parseRelatedItemsOfType(ctx,ifcElement.expressID,"RelatingObject","RelatedObjects",this._webIFC.IFCRELAGGREGATES,metaObjectId);this._parseRelatedItemsOfType(ctx,ifcElement.expressID,"RelatingStructure","RelatedElements",this._webIFC.IFCRELCONTAINEDINSPATIALSTRUCTURE,metaObjectId);}},{key:"_createMetaObject",value:function _createMetaObject(ctx,ifcElement,parentMetaObjectId){var id=ifcElement.GlobalId.value;var metaObjectType;if(this.webIfcFroMOutside)metaObjectType=this._ifcAPI.GetNameFromTypeCode(ifcElement.type);else metaObjectType=ifcElement.__proto__.constructor.name;var metaObjectName=ifcElement.Name&&ifcElement.Name.value!==""?ifcElement.Name.value:metaObjectType;var metaObject={id:id,name:metaObjectName,type:metaObjectType,parent:parentMetaObjectId};ctx.metadata.metaObjects.push(metaObject);ctx.metaObjects[id]=metaObject;ctx.stats.numMetaObjects++;}},{key:"_parseRelatedItemsOfType",value:function _parseRelatedItemsOfType(ctx,id,relation,related,type,parentMetaObjectId){var
|
|
27101
|
-
var flatMeshExpressID=flatMesh.expressID;var placedGeometries=flatMesh.geometries;var meshIds=[];var properties=
|
|
27112
|
+
});}},{key:"_parseMetaObjects",value:function _parseMetaObjects(ctx){var ifcProject=this._ifcAPI.GetLine(ctx.modelID,ctx.ifcProjectId);this._parseSpatialChildren(ctx,ifcProject);}},{key:"_parseSpatialChildren",value:function _parseSpatialChildren(ctx,ifcElement,parentMetaObjectId){var metaObjectType=this._ifcAPI.GetNameFromTypeCode(ifcElement.type);if(ctx.includeTypes&&!ctx.includeTypes[metaObjectType]){return;}if(ctx.excludeTypes&&ctx.excludeTypes[metaObjectType]){return;}this._createMetaObject(ctx,ifcElement,parentMetaObjectId);var metaObjectId=ifcElement.GlobalId.value;this._parseRelatedItemsOfType(ctx,ifcElement.expressID,"RelatingObject","RelatedObjects",this._webIFC.IFCRELAGGREGATES,metaObjectId);this._parseRelatedItemsOfType(ctx,ifcElement.expressID,"RelatingStructure","RelatedElements",this._webIFC.IFCRELCONTAINEDINSPATIALSTRUCTURE,metaObjectId);}},{key:"_createMetaObject",value:function _createMetaObject(ctx,ifcElement,parentMetaObjectId){var id=ifcElement.GlobalId.value;var metaObjectType;if(this.webIfcFroMOutside)metaObjectType=this._ifcAPI.GetNameFromTypeCode(ifcElement.type);else metaObjectType=ifcElement.__proto__.constructor.name;var metaObjectName=ifcElement.Name&&ifcElement.Name.value!==""?ifcElement.Name.value:metaObjectType;var metaObject={id:id,name:metaObjectName,type:metaObjectType,parent:parentMetaObjectId};ctx.metadata.metaObjects.push(metaObject);ctx.metaObjects[id]=metaObject;ctx.stats.numMetaObjects++;}},{key:"_parseRelatedItemsOfType",value:function _parseRelatedItemsOfType(ctx,id,relation,related,type,parentMetaObjectId){var _this131=this;var lines=this._ifcAPI.GetLineIDsWithType(ctx.modelID,type);for(var _i523=0;_i523<lines.size();_i523++){var relID=lines.get(_i523);var rel=this._ifcAPI.GetLine(ctx.modelID,relID);if(rel==null)return;var relatedItems=rel[relation];var foundElement=false;if(Array.isArray(relatedItems)){var values=relatedItems.map(function(item){return item.value;});foundElement=values.includes(id);}else{foundElement=relatedItems.value===id;}if(foundElement){var element=rel[related];if(!Array.isArray(element)){var ifcElement=this._ifcAPI.GetLine(ctx.modelID,element.value);if(ifcElement==null)return;this._parseSpatialChildren(ctx,ifcElement,parentMetaObjectId);}else{element.forEach(function(element2){var ifcElement=_this131._ifcAPI.GetLine(ctx.modelID,element2.value);if(ifcElement==null)return;_this131._parseSpatialChildren(ctx,ifcElement,parentMetaObjectId);});}}}}},{key:"_parsePropertySets",value:function _parsePropertySets(ctx){this.log("start parse property...");var lines=this._ifcAPI.GetLineIDsWithType(ctx.modelID,this._webIFC.IFCRELDEFINESBYPROPERTIES);for(var _i524=0;_i524<lines.size();_i524++){var relID=lines.get(_i524);var rel=this._ifcAPI.GetLine(ctx.modelID,relID,true);if(rel){var relatingPropertyDefinition=rel.RelatingPropertyDefinition;if(!relatingPropertyDefinition){continue;}var propertySetId=relatingPropertyDefinition.GlobalId.value;var props=relatingPropertyDefinition.HasProperties;if(props&&props.length>0){var propertySetType="Default";var propertySetName=relatingPropertyDefinition.Name.value;var properties=[];for(var _i525=0,len=props.length;_i525<len;_i525++){var prop=props[_i525];var name=prop.Name;var nominalValue=prop.NominalValue;if(name&&nominalValue){var property={name:name.value,type:nominalValue.type,value:nominalValue.value,valueType:nominalValue.valueType};if(prop.Description){property.description=prop.Description.value;}else if(nominalValue.description){property.description=nominalValue.description;}properties.push(property);}}var propertySet={id:propertySetId,type:propertySetType,name:propertySetName,properties:properties};ctx.metadata.propertySets.push(propertySet);ctx.stats.numPropertySets++;var relatedObjects=rel.RelatedObjects;if(!relatedObjects||relatedObjects.length===0){return;}for(var _i526=0,_len107=relatedObjects.length;_i526<_len107;_i526++){var relatedObject=relatedObjects[_i526];var metaObjectId=relatedObject.GlobalId.value;var metaObject=ctx.metaObjects[metaObjectId];if(metaObject){if(!metaObject.propertySetIds){metaObject.propertySetIds=[];}metaObject.propertySetIds.push(propertySetId);}}}}}}},{key:"_parseGeometry",value:function _parseGeometry(ctx){var _this132=this;this.log("start parse geometry");this._ifcAPI.StreamAllMeshes(ctx.modelID,function(flatMesh){// TODO: Can we do geometry reuse with web-ifc?
|
|
27113
|
+
var flatMeshExpressID=flatMesh.expressID;var placedGeometries=flatMesh.geometries;var meshIds=[];var properties=_this132._ifcAPI.GetLine(ctx.modelID,flatMeshExpressID);if(properties==null)return;var globalId=properties.GlobalId.value;if(ctx.loadMetadata){var metaObjectId=globalId;var metaObject=ctx.metaObjects[metaObjectId];if(ctx.includeTypes&&(!metaObject||!ctx.includeTypes[metaObject.type])){return;}if(ctx.excludeTypes&&(!metaObject||ctx.excludeTypes[metaObject.type])){return;}}var matrix=math.mat4();var origin=math.vec3();for(var j=0,lenj=placedGeometries.size();j<lenj;j++){var placedGeometry=placedGeometries.get(j);var geometry=_this132._ifcAPI.GetGeometry(ctx.modelID,placedGeometry.geometryExpressID);var vertexData=_this132._ifcAPI.GetVertexArray(geometry.GetVertexData(),geometry.GetVertexDataSize());var indices=_this132._ifcAPI.GetIndexArray(geometry.GetIndexData(),geometry.GetIndexDataSize());// De-interleave vertex arrays
|
|
27102
27114
|
var positions=new Float64Array(vertexData.length/2);var normals=new Float32Array(vertexData.length/2);for(var k=0,l=0,lenk=vertexData.length/6;k<lenk;k++,l+=3){positions[l+0]=vertexData[k*6+0];positions[l+1]=vertexData[k*6+1];positions[l+2]=vertexData[k*6+2];}matrix.set(placedGeometry.flatTransformation);math.transformPositions3(matrix,positions);var rtcNeeded=worldToRTCPositions(positions,positions,origin);if(!ctx.options.autoNormals){for(var _k2=0,_l2=0,_lenk=vertexData.length/6;_k2<_lenk;_k2++,_l2+=3){normals[_l2+0]=vertexData[_k2*6+3];normals[_l2+1]=vertexData[_k2*6+4];normals[_l2+2]=vertexData[_k2*6+5];}}ctx.stats.numGeometries++;ctx.stats.numVertices+=positions.length/3;ctx.stats.numTriangles+=indices.length/3;var meshId="mesh"+ctx.nextId++;ctx.sceneModel.createMesh({id:meshId,primitive:"triangles",// TODO
|
|
27103
|
-
origin:rtcNeeded?origin:null,positions:positions,normals:ctx.options.autoNormals?null:normals,indices:indices,color:[placedGeometry.color.x,placedGeometry.color.y,placedGeometry.color.z],opacity:placedGeometry.color.w});meshIds.push(meshId);}var entityId=ctx.options.globalizeObjectIds?math.globalizeObjectId(ctx.sceneModel.id,globalId):globalId;ctx.sceneModel.createEntity({id:entityId,meshIds:meshIds,isObject:true});ctx.stats.numObjects++;});this._ifcAPI.StreamAllMeshesWithTypes(ctx.modelID,[3856911033],function(mesh,index,total){var flatMeshExpressID=mesh.expressID;var properties=
|
|
27115
|
+
origin:rtcNeeded?origin:null,positions:positions,normals:ctx.options.autoNormals?null:normals,indices:indices,color:[placedGeometry.color.x,placedGeometry.color.y,placedGeometry.color.z],opacity:placedGeometry.color.w});meshIds.push(meshId);}var entityId=ctx.options.globalizeObjectIds?math.globalizeObjectId(ctx.sceneModel.id,globalId):globalId;ctx.sceneModel.createEntity({id:entityId,meshIds:meshIds,isObject:true});ctx.stats.numObjects++;});this._ifcAPI.StreamAllMeshesWithTypes(ctx.modelID,[3856911033],function(mesh,index,total){var flatMeshExpressID=mesh.expressID;var properties=_this132._ifcAPI.GetLine(ctx.modelID,flatMeshExpressID);if(properties==null)return;var globalId=properties.GlobalId.value;var placedGeometries=mesh.geometries;var meshIds=[];var matrix=math.mat4();var origin=math.vec3();for(var j=0,lenj=placedGeometries.size();j<lenj;j++){var placedGeometry=placedGeometries.get(j);var geometry=_this132._ifcAPI.GetGeometry(ctx.modelID,placedGeometry.geometryExpressID);var vertexData=_this132._ifcAPI.GetVertexArray(geometry.GetVertexData(),geometry.GetVertexDataSize());var indices=_this132._ifcAPI.GetIndexArray(geometry.GetIndexData(),geometry.GetIndexDataSize());// De-interleave vertex arrays
|
|
27104
27116
|
var positions=new Float64Array(vertexData.length/2);var normals=new Float32Array(vertexData.length/2);for(var k=0,l=0,lenk=vertexData.length/6;k<lenk;k++,l+=3){positions[l+0]=vertexData[k*6+0];positions[l+1]=vertexData[k*6+1];positions[l+2]=vertexData[k*6+2];}matrix.set(placedGeometry.flatTransformation);math.transformPositions3(matrix,positions);var rtcNeeded=worldToRTCPositions(positions,positions,origin);if(!ctx.options.autoNormals){for(var _k3=0,_l3=0,_lenk2=vertexData.length/6;_k3<_lenk2;_k3++,_l3+=3){normals[_l3+0]=vertexData[_k3*6+3];normals[_l3+1]=vertexData[_k3*6+4];normals[_l3+2]=vertexData[_k3*6+5];}}ctx.stats.numGeometries++;ctx.stats.numVertices+=positions.length/3;ctx.stats.numTriangles+=indices.length/3;var meshId="mesh"+ctx.nextId++;ctx.sceneModel.createMesh({id:meshId,primitive:"triangles",// TODO
|
|
27105
27117
|
origin:rtcNeeded?origin:null,positions:positions,normals:ctx.options.autoNormals?null:normals,indices:indices,color:[placedGeometry.color.x,placedGeometry.color.y,placedGeometry.color.z],opacity:placedGeometry.color.w<1?placedGeometry.color.w:0.1});meshIds.push(meshId);}var entityId=ctx.options.globalizeObjectIds?math.globalizeObjectId(ctx.sceneModel.id,globalId):globalId;ctx.sceneModel.createEntity({id:entityId,meshIds:meshIds,isObject:true});ctx.stats.numObjects++;});}}]);}(Plugin);
|
|
27106
27118
|
|
|
@@ -70027,9 +70039,7 @@ class BIMXViewer extends _Controller__WEBPACK_IMPORTED_MODULE_3__["default"] {
|
|
|
70027
70039
|
*/
|
|
70028
70040
|
_initSingleClickEvent() {
|
|
70029
70041
|
this.viewer.cameraControl.on("mouseDownEntity", (e) => {
|
|
70030
|
-
if (this.
|
|
70031
|
-
return;
|
|
70032
|
-
if (this.sectionTool.getActive() || this.annotationTool.getActive())
|
|
70042
|
+
if (this.measureTool.getActive() || this.sectionTool.getActive() || this.annotationTool.getActive())
|
|
70033
70043
|
return;
|
|
70034
70044
|
e.preventDefault;
|
|
70035
70045
|
const hit = this.viewer.scene.pick({
|
|
@@ -70043,17 +70053,13 @@ class BIMXViewer extends _Controller__WEBPACK_IMPORTED_MODULE_3__["default"] {
|
|
|
70043
70053
|
}
|
|
70044
70054
|
});
|
|
70045
70055
|
this.viewer.cameraControl.on("mouseDownNothing", () => {
|
|
70046
|
-
if (this.
|
|
70047
|
-
return;
|
|
70048
|
-
if (this.sectionTool.getActive() || this.annotationTool.getActive())
|
|
70056
|
+
if (this.measureTool.getActive() || this.sectionTool.getActive() || this.annotationTool.getActive())
|
|
70049
70057
|
return;
|
|
70050
70058
|
this.singleChosedSpace();
|
|
70051
70059
|
this._eventTrigger.emit("pickedNothing");
|
|
70052
70060
|
});
|
|
70053
70061
|
this.viewer.cameraControl.on("touchPicked", (e) => {
|
|
70054
|
-
if (this.
|
|
70055
|
-
return;
|
|
70056
|
-
if (this.sectionTool.getActive() || this.annotationTool.getActive())
|
|
70062
|
+
if (this.measureTool.getActive() || this.sectionTool.getActive() || this.annotationTool.getActive())
|
|
70057
70063
|
return;
|
|
70058
70064
|
e.preventDefault;
|
|
70059
70065
|
const hit = this.viewer.scene.pick({
|
|
@@ -70067,9 +70073,7 @@ class BIMXViewer extends _Controller__WEBPACK_IMPORTED_MODULE_3__["default"] {
|
|
|
70067
70073
|
}
|
|
70068
70074
|
});
|
|
70069
70075
|
this.viewer.cameraControl.on("touchPickedNothing", () => {
|
|
70070
|
-
if (this.
|
|
70071
|
-
return;
|
|
70072
|
-
if (this.sectionTool.getActive() || this.annotationTool.getActive())
|
|
70076
|
+
if (this.measureTool.getActive() || this.sectionTool.getActive() || this.annotationTool.getActive())
|
|
70073
70077
|
return;
|
|
70074
70078
|
this._eventTrigger.emit("pickedNothing");
|
|
70075
70079
|
this.singleChosedSpace();
|
|
@@ -70096,9 +70100,7 @@ class BIMXViewer extends _Controller__WEBPACK_IMPORTED_MODULE_3__["default"] {
|
|
|
70096
70100
|
*/
|
|
70097
70101
|
_initDoubleClickEvent() {
|
|
70098
70102
|
this.viewer.cameraControl.on("doublePicked", (e) => {
|
|
70099
|
-
if (this.
|
|
70100
|
-
return;
|
|
70101
|
-
if (this.sectionTool.getActive() || this.annotationTool.getActive())
|
|
70103
|
+
if (this.measureTool.getActive() || this.sectionTool.getActive() || this.annotationTool.getActive())
|
|
70102
70104
|
return;
|
|
70103
70105
|
e.preventDefault;
|
|
70104
70106
|
const hit = this.viewer.scene.pick({
|
|
@@ -70112,9 +70114,7 @@ class BIMXViewer extends _Controller__WEBPACK_IMPORTED_MODULE_3__["default"] {
|
|
|
70112
70114
|
}
|
|
70113
70115
|
});
|
|
70114
70116
|
this.viewer.cameraControl.on("doublePickedNothing", () => {
|
|
70115
|
-
if (this.
|
|
70116
|
-
return;
|
|
70117
|
-
if (this.sectionTool.getActive() || this.annotationTool.getActive())
|
|
70117
|
+
if (this.measureTool.getActive() || this.sectionTool.getActive() || this.annotationTool.getActive())
|
|
70118
70118
|
return;
|
|
70119
70119
|
this.choseSpace();
|
|
70120
70120
|
this._eventTrigger.emit("doublePickedNothing");
|
|
@@ -71315,9 +71315,7 @@ class BIMXViewer extends _Controller__WEBPACK_IMPORTED_MODULE_3__["default"] {
|
|
|
71315
71315
|
* @param callback
|
|
71316
71316
|
*/
|
|
71317
71317
|
SetMeasureAngleActive(active = !this.measureAngleTool.getActive(), callback = () => { }) {
|
|
71318
|
-
this._measureTool.SetMeasureAngleActive(active);
|
|
71319
|
-
if (callback)
|
|
71320
|
-
callback(this.measureAngleTool.getActive());
|
|
71318
|
+
this._measureTool.SetMeasureAngleActive(active, callback);
|
|
71321
71319
|
}
|
|
71322
71320
|
/**
|
|
71323
71321
|
* 距离测量开关
|
|
@@ -71325,9 +71323,7 @@ class BIMXViewer extends _Controller__WEBPACK_IMPORTED_MODULE_3__["default"] {
|
|
|
71325
71323
|
* @param callback
|
|
71326
71324
|
*/
|
|
71327
71325
|
SetMeasureDistanceActive(active = !this.measureDistanceTool.getActive(), callback = () => { }) {
|
|
71328
|
-
this._measureTool.SetMeasureDistanceActive(active);
|
|
71329
|
-
if (callback)
|
|
71330
|
-
callback(this.measureDistanceTool.getActive());
|
|
71326
|
+
this._measureTool.SetMeasureDistanceActive(active, callback);
|
|
71331
71327
|
}
|
|
71332
71328
|
/**
|
|
71333
71329
|
* 剖切工具开关
|
|
@@ -71336,8 +71332,7 @@ class BIMXViewer extends _Controller__WEBPACK_IMPORTED_MODULE_3__["default"] {
|
|
|
71336
71332
|
*/
|
|
71337
71333
|
SetSectionToolActive(active = !this._sectionTool.getActive(), callback = () => { }) {
|
|
71338
71334
|
this._sectionTool.setActive(active);
|
|
71339
|
-
|
|
71340
|
-
callback(this._sectionTool.getActive());
|
|
71335
|
+
callback(this._sectionTool.getActive());
|
|
71341
71336
|
}
|
|
71342
71337
|
/**
|
|
71343
71338
|
* 隐藏工具开关
|
|
@@ -71542,13 +71537,14 @@ class BIMXViewer extends _Controller__WEBPACK_IMPORTED_MODULE_3__["default"] {
|
|
|
71542
71537
|
done = sizeOrCallback;
|
|
71543
71538
|
const { orbitYawCamera } = this;
|
|
71544
71539
|
const { viewer } = this;
|
|
71540
|
+
const { canvas } = viewer.scene.canvas;
|
|
71545
71541
|
const modelId = this._projectId;
|
|
71546
|
-
const
|
|
71547
|
-
const ctx =
|
|
71542
|
+
const imgcanvas = document.createElement("canvas");
|
|
71543
|
+
const ctx = imgcanvas.getContext("2d");
|
|
71548
71544
|
const canvasWidth = size * 15;
|
|
71549
71545
|
const canvasHeight = size;
|
|
71550
|
-
|
|
71551
|
-
|
|
71546
|
+
imgcanvas.width = canvasWidth;
|
|
71547
|
+
imgcanvas.height = canvasHeight;
|
|
71552
71548
|
const imagesPromises = Array.from({ length: 15 }, () => processImage);
|
|
71553
71549
|
function processImage() {
|
|
71554
71550
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -71562,7 +71558,6 @@ class BIMXViewer extends _Controller__WEBPACK_IMPORTED_MODULE_3__["default"] {
|
|
|
71562
71558
|
}
|
|
71563
71559
|
function getshot(size) {
|
|
71564
71560
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71565
|
-
const { canvas } = viewer.scene.canvas;
|
|
71566
71561
|
const tempCanvas = document.createElement("canvas");
|
|
71567
71562
|
const tempCtx = tempCanvas.getContext("2d");
|
|
71568
71563
|
if (canvas && tempCtx) {
|
|
@@ -71590,7 +71585,7 @@ class BIMXViewer extends _Controller__WEBPACK_IMPORTED_MODULE_3__["default"] {
|
|
|
71590
71585
|
});
|
|
71591
71586
|
}
|
|
71592
71587
|
function handleCanvasResult(download) {
|
|
71593
|
-
const imageData =
|
|
71588
|
+
const imageData = imgcanvas.toDataURL("image/png");
|
|
71594
71589
|
if (download) {
|
|
71595
71590
|
const downloadLink = document.createElement("a");
|
|
71596
71591
|
downloadLink.href = imageData;
|
|
@@ -76240,21 +76235,43 @@ class MeasureTool extends _Controller__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
76240
76235
|
constructor(parent, cfg) {
|
|
76241
76236
|
super(parent);
|
|
76242
76237
|
this._isTouch = false;
|
|
76238
|
+
this._tools = {};
|
|
76239
|
+
this.eventTrigger = parent.eventTrigger;
|
|
76243
76240
|
this._measure_distance_tool = new _MeasureTools_MeasureDistanceTool__WEBPACK_IMPORTED_MODULE_2__["default"](parent, {});
|
|
76244
76241
|
this._measure_angle_tool = new _MeasureTools_MeasureAngleTool__WEBPACK_IMPORTED_MODULE_1__["default"](parent, {});
|
|
76245
|
-
this.
|
|
76246
|
-
|
|
76247
|
-
this._measure_angle_tool.setEnabled(true);
|
|
76248
|
-
this._measure_distance_tool.setEnabled(true);
|
|
76249
|
-
}
|
|
76250
|
-
else {
|
|
76251
|
-
this._measure_angle_tool.setEnabled(false);
|
|
76252
|
-
this._measure_distance_tool.setEnabled(false);
|
|
76253
|
-
}
|
|
76254
|
-
});
|
|
76242
|
+
this._tools["distance"] = this._measure_distance_tool;
|
|
76243
|
+
this._tools["angle"] = this._measure_angle_tool;
|
|
76255
76244
|
this.bimViewer.on("closeAll", () => {
|
|
76256
76245
|
this.setActive(false);
|
|
76257
76246
|
});
|
|
76247
|
+
this.setActive(true);
|
|
76248
|
+
this._initEventHandle();
|
|
76249
|
+
}
|
|
76250
|
+
_initEventHandle() {
|
|
76251
|
+
this.eventTrigger.on("clickAngleMeasure", () => {
|
|
76252
|
+
if (!this.getActiveByType("angle")) {
|
|
76253
|
+
this.setActiveByType("angle", true);
|
|
76254
|
+
this.measureDistanceTool.refreshMouseState();
|
|
76255
|
+
}
|
|
76256
|
+
});
|
|
76257
|
+
this.eventTrigger.on("clickDistanceMeasure", () => {
|
|
76258
|
+
if (!this.getActiveByType("distance")) {
|
|
76259
|
+
this.setActiveByType("distance", true);
|
|
76260
|
+
this.measureAngleTool.refreshMouseState();
|
|
76261
|
+
}
|
|
76262
|
+
});
|
|
76263
|
+
}
|
|
76264
|
+
setActive(active = !this._active) {
|
|
76265
|
+
this._active = active;
|
|
76266
|
+
this._measure_angle_tool.setEnabled(active);
|
|
76267
|
+
this._measure_distance_tool.setEnabled(active);
|
|
76268
|
+
if (!active) {
|
|
76269
|
+
this._measure_angle_tool.setActive(active);
|
|
76270
|
+
this._measure_distance_tool.setActive(active);
|
|
76271
|
+
}
|
|
76272
|
+
}
|
|
76273
|
+
getActive() {
|
|
76274
|
+
return this._active;
|
|
76258
76275
|
}
|
|
76259
76276
|
set isTouch(isTouch) {
|
|
76260
76277
|
this._isTouch = isTouch;
|
|
@@ -76270,15 +76287,30 @@ class MeasureTool extends _Controller__WEBPACK_IMPORTED_MODULE_0__["default"] {
|
|
|
76270
76287
|
get measureDistanceTool() {
|
|
76271
76288
|
return this._measure_distance_tool;
|
|
76272
76289
|
}
|
|
76273
|
-
|
|
76290
|
+
getMeasureToolByType(type) {
|
|
76291
|
+
return this._tools[type];
|
|
76292
|
+
}
|
|
76293
|
+
setActiveByType(type, active = !this._tools[type].getActive()) {
|
|
76294
|
+
this.setAllDisActive();
|
|
76295
|
+
if (active) {
|
|
76296
|
+
this._tools[type].setActive(active);
|
|
76297
|
+
}
|
|
76298
|
+
}
|
|
76299
|
+
getActiveByType(type) {
|
|
76300
|
+
return this._tools[type].getActive();
|
|
76301
|
+
}
|
|
76302
|
+
SetMeasureAngleActive(active = !this._measure_angle_tool.getActive(), callback = () => { }) {
|
|
76274
76303
|
this._measure_angle_tool.setActive(active);
|
|
76275
|
-
|
|
76276
|
-
callback(this._measure_angle_tool.getActive());
|
|
76304
|
+
callback(this._measure_angle_tool.getActive());
|
|
76277
76305
|
}
|
|
76278
|
-
SetMeasureDistanceActive(active = !this._measure_distance_tool.getActive(), callback) {
|
|
76306
|
+
SetMeasureDistanceActive(active = !this._measure_distance_tool.getActive(), callback = () => { }) {
|
|
76279
76307
|
this._measure_distance_tool.setActive(active);
|
|
76280
|
-
|
|
76281
|
-
|
|
76308
|
+
callback(this._measure_distance_tool.getActive());
|
|
76309
|
+
}
|
|
76310
|
+
setAllDisActive() {
|
|
76311
|
+
for (let type in this._tools) {
|
|
76312
|
+
this._tools[type].setActive(false);
|
|
76313
|
+
}
|
|
76282
76314
|
}
|
|
76283
76315
|
setMeasureOffSet(offsetX, offsetY) {
|
|
76284
76316
|
this.measureAngleTool.offsetX = offsetX;
|
|
@@ -76355,36 +76387,50 @@ class MeasureAngleTool extends _Controller__WEBPACK_IMPORTED_MODULE_1__["default
|
|
|
76355
76387
|
this.bimViewer.on("closeAll", () => {
|
|
76356
76388
|
this.setActive(false);
|
|
76357
76389
|
});
|
|
76358
|
-
this.
|
|
76359
|
-
if (active) {
|
|
76360
|
-
this.initSettings();
|
|
76361
|
-
}
|
|
76362
|
-
else {
|
|
76363
|
-
this.stop();
|
|
76364
|
-
}
|
|
76365
|
-
});
|
|
76390
|
+
this._initSettings();
|
|
76366
76391
|
this._initializeMeasure();
|
|
76367
76392
|
}
|
|
76368
|
-
|
|
76393
|
+
setActive(active) {
|
|
76394
|
+
this._active = active;
|
|
76395
|
+
if (active && this.chosedTarget) {
|
|
76396
|
+
this.setMeasureHightlighted(this.chosedTarget, true);
|
|
76397
|
+
}
|
|
76398
|
+
else {
|
|
76399
|
+
this.setAllHightLighted(false);
|
|
76400
|
+
}
|
|
76401
|
+
if (!this._isTouch) {
|
|
76402
|
+
this._angleMeasurementsMouseControl.active = active;
|
|
76403
|
+
}
|
|
76404
|
+
else {
|
|
76405
|
+
this._angleMeasurementsTouchControl.active = active;
|
|
76406
|
+
}
|
|
76407
|
+
}
|
|
76408
|
+
getActive() {
|
|
76409
|
+
return this._active;
|
|
76410
|
+
}
|
|
76411
|
+
_initSettings() {
|
|
76369
76412
|
if (!this._isTouch) {
|
|
76370
76413
|
this._angleMeasurementsMouseControl.activate();
|
|
76414
|
+
this._angleMeasurementsMouseControl.active = false;
|
|
76371
76415
|
}
|
|
76372
76416
|
else {
|
|
76373
76417
|
this._angleMeasurementsTouchControl.activate();
|
|
76418
|
+
this._angleMeasurementsTouchControl.active = false;
|
|
76374
76419
|
}
|
|
76375
76420
|
// this.setPointerLensVisible(true);
|
|
76376
76421
|
// this.setPointerLensActive(true);
|
|
76377
76422
|
}
|
|
76378
76423
|
_initializeMeasure() {
|
|
76379
|
-
let chosedTarget;
|
|
76424
|
+
let chosedTarget = this.chosedTarget;
|
|
76380
76425
|
this._angleMeasurementsPlugin.on("measurementCreated", (e) => {
|
|
76381
76426
|
this.eventTrigger.emit("newAngleMeasure", {
|
|
76382
76427
|
id: e.id
|
|
76383
76428
|
});
|
|
76429
|
+
this.newMeasure = e;
|
|
76384
76430
|
chosedTarget = null;
|
|
76385
76431
|
});
|
|
76386
76432
|
this._angleMeasurementsPlugin.on("measurementEnd", (e) => {
|
|
76387
|
-
if (this.getMeasureResultByID(e.id) === 0
|
|
76433
|
+
if (this.getMeasureResultByID(e.id) === 0) {
|
|
76388
76434
|
this.destroyMeasurementById(e.id);
|
|
76389
76435
|
return;
|
|
76390
76436
|
}
|
|
@@ -76400,6 +76446,8 @@ class MeasureAngleTool extends _Controller__WEBPACK_IMPORTED_MODULE_1__["default
|
|
|
76400
76446
|
e.measurement.setHighlighted(true);
|
|
76401
76447
|
});
|
|
76402
76448
|
this._angleMeasurementsPlugin.on("mouseLeave", (e) => {
|
|
76449
|
+
if (e.angleMeasurement == chosedTarget)
|
|
76450
|
+
return;
|
|
76403
76451
|
e.measurement.setHighlighted(false);
|
|
76404
76452
|
});
|
|
76405
76453
|
this._angleMeasurementsPlugin.on("clickMeasure", (e) => {
|
|
@@ -76499,6 +76547,22 @@ class MeasureAngleTool extends _Controller__WEBPACK_IMPORTED_MODULE_1__["default
|
|
|
76499
76547
|
get offsetY() {
|
|
76500
76548
|
return this._offsetY;
|
|
76501
76549
|
}
|
|
76550
|
+
/**
|
|
76551
|
+
* 重置点击事件流程进度
|
|
76552
|
+
*/
|
|
76553
|
+
refreshMouseState() {
|
|
76554
|
+
this.destroyMeasurementById(this.newMeasure.id);
|
|
76555
|
+
this._angleMeasurementsMouseControl.mouseState = 0;
|
|
76556
|
+
this.setAllHightLighted(false);
|
|
76557
|
+
this.newMeasure = null;
|
|
76558
|
+
}
|
|
76559
|
+
/**
|
|
76560
|
+
* 测量数据显隐设置
|
|
76561
|
+
* @param visible
|
|
76562
|
+
*/
|
|
76563
|
+
setAllVisible(visible) {
|
|
76564
|
+
this._angleMeasurementsPlugin.setMeasurementsShown(visible);
|
|
76565
|
+
}
|
|
76502
76566
|
/**
|
|
76503
76567
|
* 设置是否自动捕捉聚焦
|
|
76504
76568
|
* @param snappingEnabled
|
|
@@ -76534,7 +76598,7 @@ class MeasureAngleTool extends _Controller__WEBPACK_IMPORTED_MODULE_1__["default
|
|
|
76534
76598
|
*/
|
|
76535
76599
|
getMeasureResultByID(id) {
|
|
76536
76600
|
const measure = this.getMeasurementById(id);
|
|
76537
|
-
return measure.angle;
|
|
76601
|
+
return measure ? measure.angle : 0;
|
|
76538
76602
|
}
|
|
76539
76603
|
/**
|
|
76540
76604
|
* 设置指定id测量线的颜色
|
|
@@ -76707,32 +76771,46 @@ class MeasureDistanceTool extends _Controller__WEBPACK_IMPORTED_MODULE_1__["defa
|
|
|
76707
76771
|
this.bimViewer.on("closeAll", () => {
|
|
76708
76772
|
this.setActive(false);
|
|
76709
76773
|
});
|
|
76710
|
-
this.
|
|
76711
|
-
if (active) {
|
|
76712
|
-
this.initSettings();
|
|
76713
|
-
}
|
|
76714
|
-
else {
|
|
76715
|
-
this.stop();
|
|
76716
|
-
}
|
|
76717
|
-
});
|
|
76774
|
+
this._initSettings();
|
|
76718
76775
|
this._initializeMeasure();
|
|
76719
76776
|
}
|
|
76720
|
-
|
|
76777
|
+
setActive(active) {
|
|
76778
|
+
this._active = active;
|
|
76779
|
+
if (active && this.chosedTarget) {
|
|
76780
|
+
this.setMeasureHightlighted(this.chosedTarget, true);
|
|
76781
|
+
}
|
|
76782
|
+
else {
|
|
76783
|
+
this.setAllHightLighted(false);
|
|
76784
|
+
}
|
|
76785
|
+
if (!this._isTouch) {
|
|
76786
|
+
this._distanceMeasurementsMouseControl.active = active;
|
|
76787
|
+
}
|
|
76788
|
+
else {
|
|
76789
|
+
this._distanceMeasurementsTouchControl.active = active;
|
|
76790
|
+
}
|
|
76791
|
+
}
|
|
76792
|
+
getActive() {
|
|
76793
|
+
return this._active;
|
|
76794
|
+
}
|
|
76795
|
+
_initSettings() {
|
|
76721
76796
|
if (!this._isTouch) {
|
|
76722
76797
|
this._distanceMeasurementsMouseControl.activate();
|
|
76798
|
+
this._distanceMeasurementsMouseControl.active = false;
|
|
76723
76799
|
}
|
|
76724
76800
|
else {
|
|
76725
76801
|
this._distanceMeasurementsTouchControl.activate();
|
|
76802
|
+
this._distanceMeasurementsTouchControl.active = false;
|
|
76726
76803
|
}
|
|
76727
76804
|
// this.setPointerLensVisible(true);
|
|
76728
76805
|
// this.setPointerLensActive(true);
|
|
76729
76806
|
}
|
|
76730
76807
|
_initializeMeasure() {
|
|
76731
|
-
let chosedTarget;
|
|
76808
|
+
let chosedTarget = this.chosedTarget;
|
|
76732
76809
|
this._distanceMeasurementsPlugin.on("measurementCreated", (e) => {
|
|
76733
76810
|
this.eventTrigger.emit("newDistanceMeasure", {
|
|
76734
76811
|
id: e.id
|
|
76735
76812
|
});
|
|
76813
|
+
this.newMeasure = e;
|
|
76736
76814
|
chosedTarget = null;
|
|
76737
76815
|
});
|
|
76738
76816
|
this._distanceMeasurementsPlugin.on("measurementEnd", (e) => {
|
|
@@ -76752,6 +76830,8 @@ class MeasureDistanceTool extends _Controller__WEBPACK_IMPORTED_MODULE_1__["defa
|
|
|
76752
76830
|
e.measurement.setHighlighted(true);
|
|
76753
76831
|
});
|
|
76754
76832
|
this._distanceMeasurementsPlugin.on("mouseLeave", (e) => {
|
|
76833
|
+
if (e.distanceMeasurement == chosedTarget)
|
|
76834
|
+
return;
|
|
76755
76835
|
e.measurement.setHighlighted(false);
|
|
76756
76836
|
});
|
|
76757
76837
|
this._distanceMeasurementsPlugin.on("clickMeasure", (e) => {
|
|
@@ -76883,6 +76963,22 @@ class MeasureDistanceTool extends _Controller__WEBPACK_IMPORTED_MODULE_1__["defa
|
|
|
76883
76963
|
get offsetY() {
|
|
76884
76964
|
return this._offsetY;
|
|
76885
76965
|
}
|
|
76966
|
+
/**
|
|
76967
|
+
* 重置点击事件流程进度
|
|
76968
|
+
*/
|
|
76969
|
+
refreshMouseState() {
|
|
76970
|
+
this.destroyMeasurementById(this.newMeasure.id);
|
|
76971
|
+
this._distanceMeasurementsMouseControl.mouseState = 0;
|
|
76972
|
+
this.setAllHightLighted(false);
|
|
76973
|
+
this.newMeasure = null;
|
|
76974
|
+
}
|
|
76975
|
+
/**
|
|
76976
|
+
* 测量数据显隐设置
|
|
76977
|
+
* @param visible
|
|
76978
|
+
*/
|
|
76979
|
+
setAllVisible(visible) {
|
|
76980
|
+
this._distanceMeasurementsPlugin.setMeasurementsShown(visible);
|
|
76981
|
+
}
|
|
76886
76982
|
/**
|
|
76887
76983
|
* 设置是否自动捕捉聚焦
|
|
76888
76984
|
* @param snappingEnabled
|
|
@@ -76918,7 +77014,7 @@ class MeasureDistanceTool extends _Controller__WEBPACK_IMPORTED_MODULE_1__["defa
|
|
|
76918
77014
|
*/
|
|
76919
77015
|
getMeasureResultByID(id) {
|
|
76920
77016
|
const measure = this.getMeasurementById(id);
|
|
76921
|
-
return measure.length;
|
|
77017
|
+
return measure ? measure.length : 0;
|
|
76922
77018
|
}
|
|
76923
77019
|
/**
|
|
76924
77020
|
* 设置指定id测量线的颜色
|
|
@@ -77369,13 +77465,13 @@ class SectionTool extends _Controller__WEBPACK_IMPORTED_MODULE_1__["default"] {
|
|
|
77369
77465
|
this._isTouch = false;
|
|
77370
77466
|
this.on("active", (active) => {
|
|
77371
77467
|
if (active) {
|
|
77468
|
+
this.showControl();
|
|
77372
77469
|
}
|
|
77373
77470
|
else {
|
|
77374
|
-
this.
|
|
77471
|
+
this.hideControl();
|
|
77375
77472
|
}
|
|
77376
77473
|
});
|
|
77377
77474
|
this.bimViewer.on("closeAll", () => {
|
|
77378
|
-
this.clear();
|
|
77379
77475
|
this.setActive(false);
|
|
77380
77476
|
});
|
|
77381
77477
|
this._initSectionMode();
|