Skip to content

Commit

Permalink
Create MapControls.js (#25608)
Browse files Browse the repository at this point in the history
  • Loading branch information
WestLangley committed Mar 3, 2023
1 parent 3ddaae1 commit f19bad9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 30 deletions.
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

0 comments on commit f19bad9

Please sign in to comment.