1
0

MapControls.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body>
  10. [page:OrbitControls] &rarr;
  11. <h1>[name]</h1>
  12. <p class="desc">
  13. [name] is intended for transforming a camera over a map from bird's eye perspective.
  14. The class shares its implementation with [page:OrbitControls] but uses a specific preset for mouse/touch interaction and disables screen space panning by default.
  15. </p>
  16. <h2>Import</h2>
  17. <p>
  18. [name] is an add-on, and must be imported explicitly.
  19. See [link:#manual/introduction/Installation Installation / Addons].
  20. </p>
  21. <code>
  22. import { MapControls } from 'three/addons/controls/MapControls.js';
  23. </code>
  24. <h2>Code Example</h2>
  25. <code>
  26. const renderer = new THREE.WebGLRenderer();
  27. renderer.setSize( window.innerWidth, window.innerHeight );
  28. document.body.appendChild( renderer.domElement );
  29. const scene = new THREE.Scene();
  30. const camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 );
  31. camera.position.set( 0, 20, 100 );
  32. const controls = new MapControls( camera, renderer.domElement );
  33. controls.enableDamping = true;
  34. function animate() {
  35. requestAnimationFrame( animate );
  36. // required if controls.enableDamping or controls.autoRotate are set to true
  37. controls.update();
  38. renderer.render( scene, camera );
  39. }
  40. </code>
  41. <h2>Examples</h2>
  42. <p>[example:misc_controls_map misc / controls / map ]</p>
  43. <h2>Constructor</h2>
  44. <h3>[name]( [param:Camera object], [param:HTMLDOMElement domElement] )</h3>
  45. <p>
  46. [page:Camera object]: (required) The camera to be controlled. The camera must not be a child of another object, unless that object is the scene itself.<br><br>
  47. [page:HTMLDOMElement domElement]: The HTML element used for event listeners.
  48. </p>
  49. <h2>Events</h2>
  50. <p>See the base [page:OrbitControls] class for common events.</p>
  51. <h2>Properties</h2>
  52. <p>See the base [page:OrbitControls] class for common properties.</p>
  53. <h3>
  54. [property:Object mouseButtons]</h3>
  55. <p>
  56. This object contains references to the mouse actions used by the controls.
  57. <code>
  58. controls.mouseButtons = {
  59. LEFT: THREE.MOUSE.PAN,
  60. MIDDLE: THREE.MOUSE.DOLLY,
  61. RIGHT: THREE.MOUSE.ROTATE
  62. }
  63. </code>
  64. </p>
  65. <h3>[property:Boolean screenSpacePanning]</h3>
  66. <p>
  67. Defines how the camera's position is translated when panning. If true, the camera pans in screen space.
  68. Otherwise, the camera pans in the plane orthogonal to the camera's up direction.
  69. Default is `false`.
  70. </p>
  71. <h3>[property:Object touches]</h3>
  72. <p>
  73. This object contains references to the touch actions used by the controls.
  74. <code>
  75. controls.touches = {
  76. ONE: THREE.TOUCH.PAN,
  77. TWO: THREE.TOUCH.DOLLY_ROTATE
  78. }
  79. </code>
  80. </p>
  81. <h2>Methods</h2>
  82. <p>See the base [page:OrbitControls] class for common methods.</p>
  83. <h2>Source</h2>
  84. <p>
  85. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/MapControls.js examples/jsm/controls/MapControls.js]
  86. </p>
  87. </body>
  88. </html>