@xtctwins/tctwins-bimx-viewer 0.1.16 → 0.1.17
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.
|
@@ -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.
|
|
@@ -2662,8 +2662,8 @@ _this11._initMarkerDiv();_this11._onMouseHoverSurface=null;_this11._onHoverNothi
|
|
|
2662
2662
|
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this AngleMeasurementsMouseControl.
|
|
2663
2663
|
*/function get(){return this._snapping;}/**
|
|
2664
2664
|
* Activates this AngleMeasurementsMouseControl, ready to respond to input.
|
|
2665
|
-
*/,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 _this12=this;if(this.
|
|
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(snapping){if(snapping!==this._snapping){this._snapping=snapping;this.deactivate();this.activate();}else{this._snapping=snapping;}}},{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){if(!_this12._active){return;}hover=true;});angleMeasurementsPlugin.on("mouseLeave",function(e){if(!_this12._active){return;}hover=false;});angleMeasurementsPlugin.on("measureDelete",function(e){if(!_this12._active){return;}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.
|
|
@@ -3943,7 +3946,7 @@ this._originDot.setVisible(this._visible&&this._originVisible);this._targetDot.s
|
|
|
3943
3946
|
* @returns {boolean} Whether snap-to-vertex and snap-to-edge are enabled for this DistanceMeasurementsMouseControl.
|
|
3944
3947
|
*/function get(){return this._snapping;}/**
|
|
3945
3948
|
* Activates this DistanceMeasurementsMouseControl, ready to respond to input.
|
|
3946
|
-
*/,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 _this24=this;if(this.
|
|
3949
|
+
*/,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 _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){if(!_this24._active){return;}hover=true;});distanceMeasurementsPlugin.on("mouseLeave",function(e){if(!_this24._active){return;}hover=false;});distanceMeasurementsPlugin.on("measureDelete",function(e){if(!_this24._active){return;}hover=false;});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_ADD){enableSetSpeedUp=true;}if(keyCode===input.KEY_SUBTRACT){enableSetSpeedDown=true;}});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){console.log(111);_this125._movespeed+=0.5;}enableSetSpeedUp=false;}if(enableSetSpeedDown){if(_this125._movespeed>0.5){console.log(222);_this125._movespeed-=0.5;}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.SPEED_UP,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.panDeltaZ+=panDelta;}else if(panUp){updates.panDeltaZ+=-panDelta;}if(panRight){updates.panDeltaX+=-panDelta;}else if(panLeft){updates.panDeltaX+=panDelta;}if(panBackwards){updates.panDeltaY+=panDelta;}else if(panForwards){updates.panDeltaY+=-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,7 @@ 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.PAN_LEFT]=[input.KEY_A];keyMap[this.PAN_RIGHT]=[input.KEY_D];keyMap[this.PAN_UP]=[input.KEY_Z];keyMap[this.PAN_DOWN]=[input.KEY_X];keyMap[this.PAN_BACKWARDS]=[];keyMap[this.PAN_FORWARDS]=[];keyMap[this.DOLLY_FORWARDS]=[input.KEY_W
|
|
25429
|
+
case"qwerty":keyMap[this.PAN_LEFT]=[input.KEY_A];keyMap[this.PAN_RIGHT]=[input.KEY_D];keyMap[this.PAN_UP]=[input.KEY_Z];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_W];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_Q,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_ADD];keyMap[this.SPEED_DOWN]=[input.KEY_SUBTRACT];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_ADD];keyMap[this.SPEED_DOWN]=[input.KEY_SUBTRACT];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
25430
|
* Sets the HTMl element to represent the pivot point when {@link CameraControl#followPointer} is true.
|
|
25423
25431
|
*
|
|
25424
25432
|
* See class comments for an example.
|
|
@@ -26411,7 +26419,7 @@ var documentBackgroundColor=ownerDocument.documentElement?parseColor(context,get
|
|
|
26411
26419
|
* configures renderer logic for the specified number of SectionPlanes, eliminating the need for setting up logic with each SectionPlane creation and thereby enhancing
|
|
26412
26420
|
* 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
26421
|
* your expected usage.
|
|
26414
|
-
*/function Viewer(cfg){var
|
|
26422
|
+
*/function Viewer(cfg){var _this128=this;_classCallCheck(this,Viewer);this.container=cfg.viewerElement;/**
|
|
26415
26423
|
* The Viewer's current language setting.
|
|
26416
26424
|
* @property language
|
|
26417
26425
|
* @deprecated
|
|
@@ -26456,7 +26464,7 @@ var documentBackgroundColor=ownerDocument.documentElement?parseColor(context,get
|
|
|
26456
26464
|
* @property cameraControl
|
|
26457
26465
|
* @type {CameraControl}
|
|
26458
26466
|
*/this.cameraControl=new CameraControl(this.scene,{// panToPointer: true,
|
|
26459
|
-
snapRadius:cfg.snapRadius,doublePickFlyTo:true});this.scene.canvas.on("boundary",function(event){
|
|
26467
|
+
snapRadius:cfg.snapRadius,doublePickFlyTo:true});this.scene.canvas.on("boundary",function(event){_this128.cameraControl.updatePivotElement();});this._plugins=[];/**
|
|
26460
26468
|
* Subscriptions to events sent with {@link fire}.
|
|
26461
26469
|
* @private
|
|
26462
26470
|
*/this._eventSubs={};}/**
|
|
@@ -26933,7 +26941,7 @@ if(plugins.length>0){for(var _i518=0,len=plugins.length;_i518<len;_i518++){var p
|
|
|
26933
26941
|
* @param {String[]} [cfg.includeTypes] When loading metadata, only loads objects that have {@link MetaObject}s with {@link MetaObject#type} values in this list.
|
|
26934
26942
|
* @param {String[]} [cfg.excludeTypes] When loading metadata, never loads objects that have {@link MetaObject}s with {@link MetaObject#type} values in this list.
|
|
26935
26943
|
* @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
|
|
26944
|
+
*/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
26945
|
// this._webIFC = WebIFC;
|
|
26938
26946
|
// this.webIfcFroMOutside = false;
|
|
26939
26947
|
// this._ifcAPI = new this._webIFC.IfcAPI();
|
|
@@ -26949,7 +26957,7 @@ if(plugins.length>0){for(var _i518=0,len=plugins.length;_i518<len;_i518++){var p
|
|
|
26949
26957
|
// this.error(e);
|
|
26950
26958
|
// });
|
|
26951
26959
|
// }
|
|
26952
|
-
return
|
|
26960
|
+
return _this129;}/**
|
|
26953
26961
|
* Gets the ````IFC```` format versions supported by this WebIFCLoaderPlugin.
|
|
26954
26962
|
* @returns {string[]}
|
|
26955
26963
|
*/_inherits(WebIFCLoaderPlugin,_Plugin10);return _createClass(WebIFCLoaderPlugin,[{key:"supportedVersions",get:function get(){return["2x3","4"];}/**
|
|
@@ -27094,13 +27102,13 @@ return _this128;}/**
|
|
|
27094
27102
|
// sceneModel.fire("error", e);
|
|
27095
27103
|
// }
|
|
27096
27104
|
// });
|
|
27097
|
-
return sceneModel;}},{key:"_loadModel",value:function _loadModel(src,params,options,sceneModel){var
|
|
27105
|
+
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
27106
|
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
27107
|
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=
|
|
27108
|
+
});}},{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?
|
|
27109
|
+
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
27110
|
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=
|
|
27111
|
+
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
27112
|
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
27113
|
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
27114
|
|
|
@@ -71542,13 +71550,14 @@ class BIMXViewer extends _Controller__WEBPACK_IMPORTED_MODULE_3__["default"] {
|
|
|
71542
71550
|
done = sizeOrCallback;
|
|
71543
71551
|
const { orbitYawCamera } = this;
|
|
71544
71552
|
const { viewer } = this;
|
|
71553
|
+
const { canvas } = viewer.scene.canvas;
|
|
71545
71554
|
const modelId = this._projectId;
|
|
71546
|
-
const
|
|
71547
|
-
const ctx =
|
|
71555
|
+
const imgcanvas = document.createElement("canvas");
|
|
71556
|
+
const ctx = imgcanvas.getContext("2d");
|
|
71548
71557
|
const canvasWidth = size * 15;
|
|
71549
71558
|
const canvasHeight = size;
|
|
71550
|
-
|
|
71551
|
-
|
|
71559
|
+
imgcanvas.width = canvasWidth;
|
|
71560
|
+
imgcanvas.height = canvasHeight;
|
|
71552
71561
|
const imagesPromises = Array.from({ length: 15 }, () => processImage);
|
|
71553
71562
|
function processImage() {
|
|
71554
71563
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -71562,7 +71571,6 @@ class BIMXViewer extends _Controller__WEBPACK_IMPORTED_MODULE_3__["default"] {
|
|
|
71562
71571
|
}
|
|
71563
71572
|
function getshot(size) {
|
|
71564
71573
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71565
|
-
const { canvas } = viewer.scene.canvas;
|
|
71566
71574
|
const tempCanvas = document.createElement("canvas");
|
|
71567
71575
|
const tempCtx = tempCanvas.getContext("2d");
|
|
71568
71576
|
if (canvas && tempCtx) {
|
|
@@ -71590,7 +71598,7 @@ class BIMXViewer extends _Controller__WEBPACK_IMPORTED_MODULE_3__["default"] {
|
|
|
71590
71598
|
});
|
|
71591
71599
|
}
|
|
71592
71600
|
function handleCanvasResult(download) {
|
|
71593
|
-
const imageData =
|
|
71601
|
+
const imageData = imgcanvas.toDataURL("image/png");
|
|
71594
71602
|
if (download) {
|
|
71595
71603
|
const downloadLink = document.createElement("a");
|
|
71596
71604
|
downloadLink.href = imageData;
|
|
@@ -76355,22 +76363,25 @@ class MeasureAngleTool extends _Controller__WEBPACK_IMPORTED_MODULE_1__["default
|
|
|
76355
76363
|
this.bimViewer.on("closeAll", () => {
|
|
76356
76364
|
this.setActive(false);
|
|
76357
76365
|
});
|
|
76366
|
+
this._initSettings();
|
|
76367
|
+
this._initializeMeasure();
|
|
76358
76368
|
this.on("active", (active) => {
|
|
76359
|
-
if (
|
|
76360
|
-
this.
|
|
76369
|
+
if (!this._isTouch) {
|
|
76370
|
+
this._angleMeasurementsMouseControl.active = active;
|
|
76361
76371
|
}
|
|
76362
76372
|
else {
|
|
76363
|
-
this.
|
|
76373
|
+
this._angleMeasurementsTouchControl.active = active;
|
|
76364
76374
|
}
|
|
76365
76375
|
});
|
|
76366
|
-
this._initializeMeasure();
|
|
76367
76376
|
}
|
|
76368
|
-
|
|
76377
|
+
_initSettings() {
|
|
76369
76378
|
if (!this._isTouch) {
|
|
76370
76379
|
this._angleMeasurementsMouseControl.activate();
|
|
76380
|
+
this._angleMeasurementsMouseControl.active = false;
|
|
76371
76381
|
}
|
|
76372
76382
|
else {
|
|
76373
76383
|
this._angleMeasurementsTouchControl.activate();
|
|
76384
|
+
this._angleMeasurementsTouchControl.active = false;
|
|
76374
76385
|
}
|
|
76375
76386
|
// this.setPointerLensVisible(true);
|
|
76376
76387
|
// this.setPointerLensActive(true);
|
|
@@ -76499,6 +76510,13 @@ class MeasureAngleTool extends _Controller__WEBPACK_IMPORTED_MODULE_1__["default
|
|
|
76499
76510
|
get offsetY() {
|
|
76500
76511
|
return this._offsetY;
|
|
76501
76512
|
}
|
|
76513
|
+
/**
|
|
76514
|
+
* 测量数据显隐设置
|
|
76515
|
+
* @param visible
|
|
76516
|
+
*/
|
|
76517
|
+
setAllVisible(visible) {
|
|
76518
|
+
this._angleMeasurementsPlugin.setMeasurementsShown(visible);
|
|
76519
|
+
}
|
|
76502
76520
|
/**
|
|
76503
76521
|
* 设置是否自动捕捉聚焦
|
|
76504
76522
|
* @param snappingEnabled
|
|
@@ -76707,22 +76725,25 @@ class MeasureDistanceTool extends _Controller__WEBPACK_IMPORTED_MODULE_1__["defa
|
|
|
76707
76725
|
this.bimViewer.on("closeAll", () => {
|
|
76708
76726
|
this.setActive(false);
|
|
76709
76727
|
});
|
|
76728
|
+
this._initSettings();
|
|
76729
|
+
this._initializeMeasure();
|
|
76710
76730
|
this.on("active", (active) => {
|
|
76711
|
-
if (
|
|
76712
|
-
this.
|
|
76731
|
+
if (!this._isTouch) {
|
|
76732
|
+
this._distanceMeasurementsMouseControl.active = active;
|
|
76713
76733
|
}
|
|
76714
76734
|
else {
|
|
76715
|
-
this.
|
|
76735
|
+
this._distanceMeasurementsTouchControl.active = active;
|
|
76716
76736
|
}
|
|
76717
76737
|
});
|
|
76718
|
-
this._initializeMeasure();
|
|
76719
76738
|
}
|
|
76720
|
-
|
|
76739
|
+
_initSettings() {
|
|
76721
76740
|
if (!this._isTouch) {
|
|
76722
76741
|
this._distanceMeasurementsMouseControl.activate();
|
|
76742
|
+
this._distanceMeasurementsMouseControl.active = false;
|
|
76723
76743
|
}
|
|
76724
76744
|
else {
|
|
76725
76745
|
this._distanceMeasurementsTouchControl.activate();
|
|
76746
|
+
this._distanceMeasurementsTouchControl.active = false;
|
|
76726
76747
|
}
|
|
76727
76748
|
// this.setPointerLensVisible(true);
|
|
76728
76749
|
// this.setPointerLensActive(true);
|
|
@@ -76883,6 +76904,13 @@ class MeasureDistanceTool extends _Controller__WEBPACK_IMPORTED_MODULE_1__["defa
|
|
|
76883
76904
|
get offsetY() {
|
|
76884
76905
|
return this._offsetY;
|
|
76885
76906
|
}
|
|
76907
|
+
/**
|
|
76908
|
+
* 测量数据显隐设置
|
|
76909
|
+
* @param visible
|
|
76910
|
+
*/
|
|
76911
|
+
setAllVisible(visible) {
|
|
76912
|
+
this._distanceMeasurementsPlugin.setMeasurementsShown(visible);
|
|
76913
|
+
}
|
|
76886
76914
|
/**
|
|
76887
76915
|
* 设置是否自动捕捉聚焦
|
|
76888
76916
|
* @param snappingEnabled
|
|
@@ -77369,13 +77397,13 @@ class SectionTool extends _Controller__WEBPACK_IMPORTED_MODULE_1__["default"] {
|
|
|
77369
77397
|
this._isTouch = false;
|
|
77370
77398
|
this.on("active", (active) => {
|
|
77371
77399
|
if (active) {
|
|
77400
|
+
this.showControl();
|
|
77372
77401
|
}
|
|
77373
77402
|
else {
|
|
77374
|
-
this.
|
|
77403
|
+
this.hideControl();
|
|
77375
77404
|
}
|
|
77376
77405
|
});
|
|
77377
77406
|
this.bimViewer.on("closeAll", () => {
|
|
77378
|
-
this.clear();
|
|
77379
77407
|
this.setActive(false);
|
|
77380
77408
|
});
|
|
77381
77409
|
this._initSectionMode();
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
export const VERSION = "0.1.
|
|
2
|
+
export const VERSION = "0.1.17";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
export const VERSION = "0.1.
|
|
2
|
+
export const VERSION = "0.1.17";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xtctwins/tctwins-bimx-viewer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "BIM viewer built on xtctwins",
|
|
6
6
|
"main": "./dist/tctwins-bimx-viewer.min.es.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@types/ali-oss": "^6.16.11",
|
|
29
29
|
"@typescript-eslint/eslint-plugin": "^6.14.0",
|
|
30
30
|
"@typescript-eslint/parser": "^6.14.0",
|
|
31
|
-
"@xtctwins/tctwins-core": "^1.0.
|
|
31
|
+
"@xtctwins/tctwins-core": "^1.0.49",
|
|
32
32
|
"ali-oss": "^6.18.1",
|
|
33
33
|
"autoprefixer": "^9.8.6",
|
|
34
34
|
"axios": "^1.6.5",
|
|
@@ -16,7 +16,7 @@ export default class MeasureAngleTool extends Controller {
|
|
|
16
16
|
private _offsetY;
|
|
17
17
|
private _isTouch;
|
|
18
18
|
constructor(parent: any, cfg: any);
|
|
19
|
-
|
|
19
|
+
protected _initSettings(): void;
|
|
20
20
|
protected _initializeMeasure(): void;
|
|
21
21
|
set isTouch(isTouch: boolean);
|
|
22
22
|
get isTouch(): boolean;
|
|
@@ -42,6 +42,11 @@ export default class MeasureAngleTool extends Controller {
|
|
|
42
42
|
* @return {number} mouse offset
|
|
43
43
|
*/
|
|
44
44
|
get offsetY(): number;
|
|
45
|
+
/**
|
|
46
|
+
* 测量数据显隐设置
|
|
47
|
+
* @param visible
|
|
48
|
+
*/
|
|
49
|
+
setAllVisible(visible: boolean): void;
|
|
45
50
|
/**
|
|
46
51
|
* 设置是否自动捕捉聚焦
|
|
47
52
|
* @param snappingEnabled
|
|
@@ -18,7 +18,7 @@ export default class MeasureDistanceTool extends Controller {
|
|
|
18
18
|
private _offsetY;
|
|
19
19
|
private _isTouch;
|
|
20
20
|
constructor(parent: any, cfg: any);
|
|
21
|
-
|
|
21
|
+
protected _initSettings(): void;
|
|
22
22
|
protected _initializeMeasure(): void;
|
|
23
23
|
set isTouch(isTouch: boolean);
|
|
24
24
|
get isTouch(): boolean;
|
|
@@ -50,6 +50,11 @@ export default class MeasureDistanceTool extends Controller {
|
|
|
50
50
|
* @return {number} mouse offset
|
|
51
51
|
*/
|
|
52
52
|
get offsetY(): number;
|
|
53
|
+
/**
|
|
54
|
+
* 测量数据显隐设置
|
|
55
|
+
* @param visible
|
|
56
|
+
*/
|
|
57
|
+
setAllVisible(visible: boolean): void;
|
|
53
58
|
/**
|
|
54
59
|
* 设置是否自动捕捉聚焦
|
|
55
60
|
* @param snappingEnabled
|