MapControls.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { MOUSE, TOUCH } from 'three';
  2. import { OrbitControls } from './OrbitControls.js';
  3. /**
  4. * This class is intended for transforming a camera over a map from bird's eye perspective.
  5. * The class shares its implementation with {@link OrbitControls} but uses a specific preset
  6. * for mouse/touch interaction and disables screen space panning by default.
  7. *
  8. * - Orbit: Right mouse, or left mouse + ctrl/meta/shiftKey / touch: two-finger rotate.
  9. * - Zoom: Middle mouse, or mousewheel / touch: two-finger spread or squish.
  10. * - Pan: Left mouse, or arrow keys / touch: one-finger move.
  11. *
  12. * @augments OrbitControls
  13. */
  14. class MapControls extends OrbitControls {
  15. constructor( object, domElement ) {
  16. super( object, domElement );
  17. /**
  18. * Overwritten and set to `false` to pan orthogonal to world-space direction `camera.up`.
  19. *
  20. * @type {boolean}
  21. * @default false
  22. */
  23. this.screenSpacePanning = false;
  24. /**
  25. * This object contains references to the mouse actions used by the controls.
  26. *
  27. * ```js
  28. * controls.mouseButtons = {
  29. * LEFT: THREE.MOUSE.PAN,
  30. * MIDDLE: THREE.MOUSE.DOLLY,
  31. * RIGHT: THREE.MOUSE.ROTATE
  32. * }
  33. * ```
  34. * @type {Object}
  35. */
  36. this.mouseButtons = { LEFT: MOUSE.PAN, MIDDLE: MOUSE.DOLLY, RIGHT: MOUSE.ROTATE };
  37. /**
  38. * This object contains references to the touch actions used by the controls.
  39. *
  40. * ```js
  41. * controls.mouseButtons = {
  42. * ONE: THREE.TOUCH.PAN,
  43. * TWO: THREE.TOUCH.DOLLY_ROTATE
  44. * }
  45. * ```
  46. * @type {Object}
  47. */
  48. this.touches = { ONE: TOUCH.PAN, TWO: TOUCH.DOLLY_ROTATE };
  49. }
  50. }
  51. export { MapControls };
粤ICP备19079148号