diff --git a/src/three/controls/EnvironmentControls.js b/src/three/controls/EnvironmentControls.js index 8daad63cd..43180789f 100644 --- a/src/three/controls/EnvironmentControls.js +++ b/src/three/controls/EnvironmentControls.js @@ -284,6 +284,11 @@ export class EnvironmentControls extends EventDispatcher { const hit = this._raycast( raycaster ); if ( hit ) { + this.pivotPoint.copy( hit.point ); + this.pivotMesh.position.copy( hit.point ); + this.pivotMesh.updateMatrixWorld(); + this.scene.add( this.pivotMesh ); + // if two fingers, right click, or shift click are being used then we trigger // a rotation action to begin if ( @@ -294,20 +299,16 @@ export class EnvironmentControls extends EventDispatcher { this.setState( pointerTracker.isPointerTouch() ? WAITING : ROTATE ); - this.pivotPoint.copy( hit.point ); - this.pivotMesh.position.copy( hit.point ); - this.pivotMesh.updateMatrixWorld(); - this.scene.add( this.pivotMesh ); - } else if ( pointerTracker.isLeftClicked() ) { // if the clicked point is coming from below the plane then don't perform the drag this.setState( DRAG ); - this.pivotPoint.copy( hit.point ); - this.pivotMesh.position.copy( hit.point ); - this.pivotMesh.updateMatrixWorld(); - this.scene.add( this.pivotMesh ); + } else if ( pointerTracker.isMiddleClicked() ) { + + this.setState( ZOOM ); + this.zoomDirectionSet = false; + this._updateZoomDirection(); } @@ -399,6 +400,13 @@ export class EnvironmentControls extends EventDispatcher { } + // Add mouse click handle in pointerMove + if ( this.state === ZOOM ) { + + this.zoomDelta -= 2 * e.movementY; + + } + }; const pointerupCallback = e => { diff --git a/src/three/controls/PointerTracker.js b/src/three/controls/PointerTracker.js index 72f5d1898..75731d9ee 100644 --- a/src/three/controls/PointerTracker.js +++ b/src/three/controls/PointerTracker.js @@ -254,4 +254,10 @@ export class PointerTracker { } + isMiddleClicked() { + + return Boolean( this.buttons & 4 ); + + } + }