OrbitControls.html 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css" />
  9. </head>
  10. <body>
  11. <h1>[name]</h1>
  12. <p class="desc">
  13. Orbit controls allow the camera to orbit around a target.<br>
  14. To use this, as with all files in the /examples directory, you will have to
  15. include the file seperately in your HTML.
  16. </p>
  17. <h2>Example</h2>
  18. <p>[example:misc_controls_orbit misc / controls / orbit ]</p>
  19. <code>
  20. var renderer = new THREE.WebGLRenderer();
  21. renderer.setSize( window.innerWidth, window.innerHeight );
  22. document.body.appendChild( renderer.domElement );
  23. var scene = new THREE.Scene();
  24. var camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 );
  25. var controls = new THREE.OrbitControls( camera, renderer.domElement );
  26. //controls.update() must be called after any manual changes to the camera's transform
  27. camera.position.set( 0, 20, 100 );
  28. controls.update();
  29. function animate() {
  30. requestAnimationFrame( animate );
  31. // required if controls.enableDamping or controls.autoRotate are set to true
  32. controls.update();
  33. renderer.render( scene, camera );
  34. }
  35. </code>
  36. <h2>Constructor</h2>
  37. <h3>[name]( [param:Camera object], [param:HTMLDOMElement domElement] )</h3>
  38. <p>
  39. [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>
  40. [page:HTMLDOMElement domElement]: The HTML element used for event listeners.
  41. </p>
  42. <h2>Properties</h2>
  43. <h3>[property:Boolean autoRotate]</h3>
  44. <p>
  45. Set to true to automatically rotate around the target.<br> Note that if this is enabled, you must call [page:.update]
  46. () in your animation loop.
  47. </p>
  48. <h3>[property:Float autoRotateSpeed]</h3>
  49. <p>
  50. How fast to rotate around the target if [property:Boolean autoRotate] is true. Default is 2.0, which equates to 30 seconds
  51. per rotation at 60fps.<br> Note that if [property:Boolean autoRotate] is enabled, you must call [page:.update]
  52. () in your animation loop.
  53. </p>
  54. <h3>
  55. [property:Float dampingFactor]</h3>
  56. <p>
  57. The damping inertia used if [property:Boolean enableDamping] is set to true.<br> Note that for this to work, you must
  58. call [page:.update] () in your animation loop.
  59. </p>
  60. <h3>[property:HTMLDOMElement domElement]</h3>
  61. <p>
  62. The HTMLDOMElement used to listen for mouse / touch events. This must be passed in the constructor; changing it here will
  63. not set up new event listeners.
  64. </p>
  65. <h3>[property:Boolean enabled]</h3>
  66. <p>
  67. Whether or not the controls are enabled.
  68. </p>
  69. <h3>[property:Boolean enableDamping]</h3>
  70. <p>
  71. Set to true to enable damping (inertia), which can be used to give a sense of weight to the controls. Default is false.<br>
  72. Note that if this is enabled, you must call [page:.update] () in your animation loop.
  73. </p>
  74. <h3>[property:Boolean enableKeys]</h3>
  75. <p>
  76. Enable or disable the use of keyboard controls.
  77. </p>
  78. <h3>[property:Boolean enablePan]</h3>
  79. <p>
  80. Enable or disable camera panning. Default is true.
  81. </p>
  82. <h3>[property:Boolean enableRotate]</h3>
  83. <p>
  84. Enable or disable horizontal and vertical rotation of the camera. Default is true.<br>
  85. Note that it is possible to disable a single axis by setting the min and max of the
  86. [page:.minPolarAngle polar angle] or [page:.minAzimuthAngle azimuth angle] to the same value,
  87. which will cause the vertical or horizontal rotation to be fixed at that value.
  88. </p>
  89. <h3>[property:Boolean enableZoom]</h3>
  90. <p>
  91. Enable or disable zooming (dollying) of the camera.
  92. </p>
  93. <h3>[property:Float keyPanSpeed]</h3>
  94. <p>
  95. How fast to pan the camera when the keyboard is used. Default is 7.0 pixels per keypress.
  96. </p>
  97. <h3>[property:Object keys]</h3>
  98. <p>
  99. This object contains references to the keycodes for controlling camera panning. Default is the 4 arrow keys.
  100. <code>
  101. controls.keys = {
  102. LEFT: 37, //left arrow
  103. UP: 38, // up arrow
  104. RIGHT: 39, // right arrow
  105. BOTTOM: 40 // down arrow
  106. }
  107. </code> See [link:https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode this page] for a full
  108. list of keycodes.
  109. </p>
  110. <h3>[property:Float maxAzimuthAngle]</h3>
  111. <p>
  112. How far you can orbit horizontally, upper limit. Range is - Math.PI to Math.PI ( or Infinity for no limit ) and default is
  113. Infinity;
  114. </p>
  115. <h3>[property:Float maxDistance]</h3>
  116. <p>
  117. How far you can dolly out ( [page:PerspectiveCamera] only ). Default is Infinity.
  118. </p>
  119. <h3>[property:Float maxPolarAngle]</h3>
  120. <p>
  121. How far you can orbit vertically, upper limit. Range is 0 to Math.PI radians, and default is Math.PI.
  122. </p>
  123. <h3>[property:Float maxZoom]</h3>
  124. <p>
  125. How far you can zoom out ( [page:OrthographicCamera] only ). Default is Infinity.
  126. </p>
  127. <h3>[property:Float minAzimuthAngle]</h3>
  128. <p>
  129. How far you can orbit horizontally, lower limit. Range is - Math.PI to Math.PI ( or - Infinity for no limit ) and default
  130. is - Infinity;
  131. </p>
  132. <h3>[property:Float minDistance]</h3>
  133. <p>
  134. How far you can dolly in ( [page:PerspectiveCamera] only ). Default is 0.
  135. </p>
  136. <h3>[property:Float minPolarAngle]</h3>
  137. <p>
  138. How far you can orbit vertically, lower limit. Range is 0 to Math.PI radians, and default is 0.
  139. </p>
  140. <h3>[property:Float minZoom]</h3>
  141. <p>
  142. How far you can zoom in ( [page:OrthographicCamera] only ). Default is 0.
  143. </p>
  144. <h3>
  145. [property:Object mouseButtons]</h3>
  146. <p>
  147. This object contains references to the mouse actions used by the controls.
  148. <code>
  149. controls.mouseButtons = {
  150. LEFT: THREE.MOUSE.ROTATE,
  151. MIDDLE: THREE.MOUSE.DOLLY,
  152. RIGHT: THREE.MOUSE.PAN
  153. }
  154. </code>
  155. </p>
  156. <h3>[property:Camera object]</h3>
  157. <p>
  158. The camera being controlled.
  159. </p>
  160. <h3>[property:Float panSpeed]</h3>
  161. <p>
  162. Speed of panning. Default is 1.
  163. </p>
  164. <h3>[property:Vector3 position0]</h3>
  165. <p>
  166. Used internally by the [method:saveState] and [method:reset] methods.
  167. </p>
  168. <h3>[property:Float rotateSpeed]</h3>
  169. <p>
  170. Speed of rotation. Default is 1.
  171. </p>
  172. <h3>[property:Boolean screenSpacePanning]</h3>
  173. <p>
  174. Defines how the camera's position is translated when panning. If true, the camera pans in screen space.
  175. Otherwise, the camera pans in the plane orthogonal to the camera's up direction. Default is false.
  176. </p>
  177. <h3>[property:Vector3 target0]</h3>
  178. <p>
  179. Used internally by the [method:saveState] and [method:reset] methods.
  180. </p>
  181. <h3>[property:Vector3 target]</h3>
  182. <p>
  183. The focus point of the controls, the [page:.object] orbits around this. It can be updated manually at any point to change
  184. the focus of the controls.
  185. </p>
  186. <h3>[property:Object touches]</h3>
  187. <p>
  188. This object contains references to the touch actions used by the controls.
  189. <code>
  190. controls.touches = {
  191. ONE: THREE.TOUCH.ROTATE,
  192. TWO: THREE.TOUCH.DOLLY_PAN
  193. }
  194. </code>
  195. </p>
  196. <h3>[property:Float zoom0]</h3>
  197. <p>
  198. Used internally by the [method:saveState] and [method:reset] methods.
  199. </p>
  200. <h3>[property:Float zoomSpeed]</h3>
  201. <p>
  202. Speed of zooming / dollying. Default is 1.
  203. </p>
  204. <h2>Methods</h2>
  205. <h3>[method:null dispose] ()</h3>
  206. <p>
  207. Remove all the event listeners.
  208. </p>
  209. <h3>[method:radians getAzimuthalAngle] ()</h3>
  210. <p>
  211. Get the current horizontal rotation, in radians.
  212. </p>
  213. <h3>[method:radians getPolarAngle] ()</h3>
  214. <p>
  215. Get the current vertical rotation, in radians.
  216. </p>
  217. <h3>[method:null reset] ()</h3>
  218. <p>
  219. Reset the controls to their state from either the last time the [page:.saveState] was called, or the initial state.
  220. </p>
  221. <h3>[method:null saveState] ()</h3>
  222. <p>
  223. Save the current state of the controls. This can later be recovered with [page:.reset].
  224. </p>
  225. <h3>[method:Boolean update] ()</h3>
  226. <p>
  227. Update the controls. Must be called after any manual changes to the camera's transform,
  228. or in the update loop if [page:.autoRotate] or [page:.enableDamping] are set.
  229. </p>
  230. <h2>Source</h2>
  231. <p>
  232. [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/OrbitControls.js examples/js/controls/OrbitControls.js]
  233. </p>
  234. </body>
  235. </html>