Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Middle Click Drag for Environment Control #789

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions src/three/controls/EnvironmentControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@
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 (
Expand All @@ -294,20 +299,16 @@

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();

}

Expand Down Expand Up @@ -399,6 +400,13 @@

}

// Add mouse click handle in pointerMove
if ( this.state === ZOOM ) {

this.zoomDelta -= 2 * e.movementY;

}

};

const pointerupCallback = e => {
Expand Down Expand Up @@ -1145,7 +1153,7 @@
camera,
state,
zoomPoint,
zoomDirection,

Check warning on line 1156 in src/three/controls/EnvironmentControls.js

View workflow job for this annotation

GitHub Actions / build (18.x)

'zoomDirection' is assigned a value but never used

Check warning on line 1156 in src/three/controls/EnvironmentControls.js

View workflow job for this annotation

GitHub Actions / build (20.x)

'zoomDirection' is assigned a value but never used
zoomDirectionSet,
zoomPointSet,
reorientOnDrag,
Expand Down
6 changes: 6 additions & 0 deletions src/three/controls/PointerTracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,10 @@ export class PointerTracker {

}

isMiddleClicked() {

return Boolean( this.buttons & 4 );

}

}
Loading