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

MapControls: support ctrl-drag #14410

Merged
merged 1 commit into from Jul 8, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -11,11 +11,10 @@
// Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default).
// This is very similar to OrbitControls, another set of touch behavior
//
// Orbit - right mouse / touch: two-finger rotate
// Orbit - right mouse, or left mouse + ctrl/metaKey / touch: two-finger rotate
// Zoom - middle mouse, or mousewheel / touch: two-finger spread or squish
// Pan - left mouse, or arrow keys / touch: one-finger move


THREE.MapControls = function ( object, domElement ) {

this.object = object;
@@ -78,7 +77,7 @@ THREE.MapControls = function ( object, domElement ) {
this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 };

// Mouse buttons
this.mouseButtons = { ORBIT: THREE.MOUSE.RIGHT, ZOOM: THREE.MOUSE.MIDDLE, PAN: THREE.MOUSE.LEFT };
this.mouseButtons = { LEFT: THREE.MOUSE.LEFT, MIDDLE: THREE.MOUSE.MIDDLE, RIGHT: THREE.MOUSE.RIGHT };

// for reset
this.target0 = this.target.clone();
@@ -776,17 +775,29 @@ THREE.MapControls = function ( object, domElement ) {

switch ( event.button ) {

case scope.mouseButtons.ORBIT:
case scope.mouseButtons.LEFT:

if ( scope.enableRotate === false ) return;
if ( event.ctrlKey || event.metaKey ) {

This comment has been minimized.

Copy link
@haroldiedema

haroldiedema Jul 3, 2018

Contributor

You should handle the control key separately. Right now when you press the ctrl key while already dragging the mouse, it doesn't change its state to rotate. Similarly, it does not stop rotating when you release the ctrl key while you keep dragging the mouse around.

This comment has been minimized.

Copy link
@WestLangley

WestLangley Jul 3, 2018

Author Collaborator

when you press the ctrl key while already dragging the mouse, it doesn't change its state to rotate.

Why would we prefer that behavior?

As currently implemented, the ctrl key must be pressed first.

This comment has been minimized.

Copy link
@mrdoob

mrdoob Jul 3, 2018

Owner

when you press the ctrl key while already dragging the mouse, it doesn't change its state to rotate.

Why would we prefer that behavior?

That's how Google Maps behaves... 🤔

This comment has been minimized.

Copy link
@mrdoob

mrdoob Jul 3, 2018

Owner

Doesn't need to be addressed in this PR though...

This comment has been minimized.

Copy link
@WestLangley

WestLangley Jul 8, 2018

Author Collaborator

This can be merged, then. It maintains a similar API between MapControls and OrbitControls.

This comment has been minimized.

Copy link
@moroine

moroine Jul 9, 2018

Contributor

Yeah, I think we should keep Orbit & Map core function as close as possible


handleMouseDownRotate( event );
if ( scope.enableRotate === false ) return;

state = STATE.ROTATE;
handleMouseDownRotate( event );

state = STATE.ROTATE;

} else {

if ( scope.enablePan === false ) return;

handleMouseDownPan( event );

state = STATE.PAN;

}

break;

case scope.mouseButtons.ZOOM:
case scope.mouseButtons.MIDDLE:

if ( scope.enableZoom === false ) return;

@@ -796,13 +807,13 @@ THREE.MapControls = function ( object, domElement ) {

break;

case scope.mouseButtons.PAN:
case scope.mouseButtons.RIGHT:

if ( scope.enablePan === false ) return;
if ( scope.enableRotate === false ) return;

handleMouseDownPan( event );
handleMouseDownRotate( event );

state = STATE.PAN;
state = STATE.ROTATE;

break;

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.