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

Controls: Create MapControls.js #25608

Merged
merged 1 commit into from
Mar 3, 2023
Merged
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
33 changes: 33 additions & 0 deletions examples/jsm/controls/MapControls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {
MOUSE,
TOUCH,
} from 'three';

import { OrbitControls } from './OrbitControls.js';

// MapControls performs orbiting, dollying (zooming), and panning.
// Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default).
//
// Orbit - right mouse, or left mouse + ctrl/meta/shiftKey / 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

class MapControls extends OrbitControls {

constructor( object, domElement ) {

super( object, domElement );

this.screenSpacePanning = false; // pan orthogonal to world-space direction camera.up

this.mouseButtons.LEFT = MOUSE.PAN;
this.mouseButtons.RIGHT = MOUSE.ROTATE;

this.touches.ONE = TOUCH.PAN;
this.touches.TWO = TOUCH.DOLLY_ROTATE;

}

}

export { MapControls };
31 changes: 2 additions & 29 deletions examples/jsm/controls/OrbitControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Vector3
} from 'three';

// This set of controls performs orbiting, dollying (zooming), and panning.
// OrbitControls performs orbiting, dollying (zooming), and panning.
// Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default).
//
// Orbit - left mouse / touch: one-finger move
Expand Down Expand Up @@ -1259,31 +1259,4 @@ class OrbitControls extends EventDispatcher {

}


// This set of controls performs orbiting, dollying (zooming), and panning.
// 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, or left mouse + ctrl/meta/shiftKey / 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

class MapControls extends OrbitControls {

constructor( object, domElement ) {

super( object, domElement );

this.screenSpacePanning = false; // pan orthogonal to world-space direction camera.up

this.mouseButtons.LEFT = MOUSE.PAN;
this.mouseButtons.RIGHT = MOUSE.ROTATE;

this.touches.ONE = TOUCH.PAN;
this.touches.TWO = TOUCH.DOLLY_ROTATE;

}

}

export { OrbitControls, MapControls };
export { OrbitControls };
2 changes: 1 addition & 1 deletion examples/misc_controls_map.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

import { GUI } from 'three/addons/libs/lil-gui.module.min.js';

import { MapControls } from 'three/addons/controls/OrbitControls.js';
import { MapControls } from 'three/addons/controls/MapControls.js';

let camera, controls, scene, renderer;

Expand Down