TrackballControls.html 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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:EventDispatcher] &rarr;
  11. <h1>[name]</h1>
  12. <p class="desc">
  13. <p>
  14. [name] is similar to [page:OrbitControls]. However, it does not maintain a constant camera [page:Object3D.up up] vector.
  15. That means if the camera orbits over the “north” and “south” poles, it does not flip to stay "right side up".
  16. </p>
  17. </p>
  18. <h2>Import</h2>
  19. <p>
  20. [name] is an add-on, and must be imported explicitly.
  21. See [link:#manual/introduction/Installation Installation / Addons].
  22. </p>
  23. <code>
  24. import { TrackballControls } from 'three/addons/controls/TrackballControls.js';
  25. </code>
  26. <h2>Examples</h2>
  27. <p>[example:misc_controls_trackball misc / controls / trackball ]</p>
  28. <h2>Constructor</h2>
  29. <h3>[name]( [param:Camera camera], [param:HTMLDOMElement domElement] )</h3>
  30. <p>
  31. <p>
  32. [page:Camera camera]: The camera of the rendered scene.
  33. </p>
  34. <p>
  35. [page:HTMLDOMElement domElement]: The HTML element used for event listeners.
  36. </p>
  37. <p>
  38. Creates a new instance of [name].
  39. </p>
  40. </p>
  41. <h2>Events</h2>
  42. <h3>change</h3>
  43. <p>
  44. Fires when the camera has been transformed by the controls.
  45. </p>
  46. <h3>start</h3>
  47. <p>
  48. Fires when an interaction (e.g. touch) was initiated.
  49. </p>
  50. <h3>end</h3>
  51. <p>
  52. Fires when an interaction has finished.
  53. </p>
  54. <h2>Properties</h2>
  55. <h3>[property:HTMLDOMElement domElement]</h3>
  56. <p>
  57. The HTMLDOMElement used to listen for mouse / touch events. This must be passed in the constructor; changing it here will
  58. not set up new event listeners.
  59. </p>
  60. <h3>[property:Number dynamicDampingFactor]</h3>
  61. <p>
  62. Defines the intensity of damping. Only considered if [page:.staticMoving staticMoving] is set to `false`. Default is `0.2`.
  63. </p>
  64. <h3>[property:Boolean enabled]</h3>
  65. <p>
  66. Whether or not the controls are enabled.
  67. </p>
  68. <h3>[property:Array keys]</h3>
  69. <p>
  70. This array holds keycodes for controlling interactions.
  71. <ul>
  72. <li>When the first defined key is pressed, all mouse interactions (left, middle, right) performs orbiting.</li>
  73. <li>When the second defined key is pressed, all mouse interactions (left, middle, right) performs zooming.</li>
  74. <li>When the third defined key is pressed, all mouse interactions (left, middle, right) performs panning.</li>
  75. </ul>
  76. Default is *KeyA, KeyS, KeyD* which represents A, S, D.
  77. </p>
  78. <h3>[property:Number maxDistance]</h3>
  79. <p>
  80. How far you can dolly out ( [page:PerspectiveCamera] only ). Default is `Infinity`.
  81. </p>
  82. <h3>[property:Number minDistance]</h3>
  83. <p>
  84. How far you can dolly in ( [page:PerspectiveCamera] only ). Default is *0*.
  85. </p>
  86. <h3>[property:Float maxZoom]</h3>
  87. <p>
  88. How far you can zoom out ( [page:OrthographicCamera] only ). Default is `Infinity`.
  89. </p>
  90. <h3>[property:Float minZoom]</h3>
  91. <p>
  92. How far you can zoom in ( [page:OrthographicCamera] only ). Default is *0*.
  93. </p>
  94. <h3>
  95. [property:Object mouseButtons]</h3>
  96. <p>
  97. This object contains references to the mouse actions used by the controls.
  98. <ul>
  99. <li>.LEFT is assigned with `THREE.MOUSE.ROTATE`</li>
  100. <li>.MIDDLE is assigned with `THREE.MOUSE.ZOOM`</li>
  101. <li>.RIGHT is assigned with `THREE.MOUSE.PAN`</li>
  102. </ul>
  103. </p>
  104. <h3>[property:Boolean noPan]</h3>
  105. <p>
  106. Whether or not panning is disabled. Default is `false`.
  107. </p>
  108. <h3>[property:Boolean noRotate]</h3>
  109. <p>
  110. Whether or not rotation is disabled. Default is `false`.
  111. </p>
  112. <h3>[property:Boolean noZoom]</h3>
  113. <p>
  114. Whether or not zooming is disabled. Default is `false`.
  115. </p>
  116. <h3>[property:Camera object]</h3>
  117. <p>
  118. The camera being controlled.
  119. </p>
  120. <h3>[property:Number panSpeed]</h3>
  121. <p>
  122. The pan speed. Default is `0.3`.
  123. </p>
  124. <h3>[property:Number rotateSpeed]</h3>
  125. <p>
  126. The rotation speed. Default is `1.0`.
  127. </p>
  128. <h3>[property:Object screen]</h3>
  129. <p>
  130. Represents the properties of the screen. Automatically set when [page:.handleResize handleResize]() is called.
  131. <ul>
  132. <li>left: Represents the offset in pixels to the screen's left boundary.</li>
  133. <li>top: Represents the offset in pixels to the screen's top boundary.</li>
  134. <li>width: Represents the screen width in pixels.</li>
  135. <li>height: Represents the screen height in pixels.</li>
  136. </ul>
  137. </p>
  138. <h3>[property:Boolean staticMoving]</h3>
  139. <p>
  140. Whether or not damping is disabled. Default is `false`.
  141. </p>
  142. <h3>[property:Number zoomSpeed]</h3>
  143. <p>
  144. The zoom speed. Default is `1.2`.
  145. </p>
  146. <h2>Methods</h2>
  147. <h3>[method:undefined checkDistances] ()</h3>
  148. <p>
  149. Ensures the controls stay in the range [minDistance, maxDistance]. Called by [page:.update update]().
  150. </p>
  151. <h3>[method:undefined dispose] ()</h3>
  152. <p>
  153. Should be called if the controls is no longer required.
  154. </p>
  155. <h3>[method:undefined handleResize] ()</h3>
  156. <p>
  157. Should be called if the application window is resized.
  158. </p>
  159. <h3>[method:undefined panCamera] ()</h3>
  160. <p>
  161. Performs panning if necessary. Called by [page:.update update]().
  162. </p>
  163. <h3>[method:undefined reset] ()</h3>
  164. <p>
  165. Resets the controls to its initial state.
  166. </p>
  167. <h3>[method:undefined rotateCamera] ()</h3>
  168. <p>
  169. Rotates the camera if necessary. Called by [page:.update update]().
  170. </p>
  171. <h3>[method:undefined update] ()</h3>
  172. <p>
  173. Updates the controls. Usually called in the animation loop.
  174. </p>
  175. <h3>[method:undefined zoomCamera] ()</h3>
  176. <p>
  177. Performs zooming if necessary. Called by [page:.update update]().
  178. </p>
  179. <h2>Source</h2>
  180. <p>
  181. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/TrackballControls.js examples/jsm/controls/TrackballControls.js]
  182. </p>
  183. </body>
  184. </html>