TrackballControls.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>TrackballControls - Three.js Docs</title>
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <script src="../scripts/highlight.min.js"></script>
  8. <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
  9. <link type="text/css" rel="stylesheet" href="../styles/page.css">
  10. </head>
  11. <body>
  12. <p class="inheritance" translate="no"><a href="EventDispatcher.html">EventDispatcher</a> → <a href="Controls.html">Controls</a> → </p>
  13. <h1 translate="no">TrackballControls</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>This class is similar to <a href="OrbitControls.html">OrbitControls</a>. However, it does not maintain a constant camera
  17. <code>up</code> vector. That means if the camera orbits over the “north” and “south” poles, it does not flip
  18. to stay &quot;right side up&quot;.</p></div>
  19. </header>
  20. <article>
  21. <h2 class="subsection-title">Import</h2>
  22. <p><span translate="no">TrackballControls</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank" rel="noopener">Installation#Addons</a>.</p>
  23. <pre><code class="language-js">import { TrackballControls } from 'three/addons/controls/TrackballControls.js';</code></pre>
  24. <div class="container-overview">
  25. <h2>Constructor</h2>
  26. <h3 class="name name-method" id="TrackballControls" translate="no">new <a href="#TrackballControls">TrackballControls</a><span class="signature">( object : <span class="param-type"><a href="Object3D.html">Object3D</a></span>, domElement : <span class="param-type">HTMLElement</span> )</span> </h3>
  27. <div class="method">
  28. <div class="description">
  29. <p>Constructs a new controls instance.</p>
  30. </div>
  31. <table class="params">
  32. <tbody>
  33. <tr>
  34. <td class="name">
  35. <strong>object</strong>
  36. </td>
  37. <td class="description last">
  38. <p>The object that is managed by the controls.</p>
  39. </td>
  40. </tr>
  41. <tr>
  42. <td class="name">
  43. <strong>domElement</strong>
  44. </td>
  45. <td class="description last">
  46. <p>The HTML element used for event listeners.</p>
  47. <p>Default is <code>null</code>.</p>
  48. </td>
  49. </tr>
  50. </tbody>
  51. </table>
  52. </div>
  53. </div>
  54. <h2 class="subsection-title">Properties</h2>
  55. <div class="member">
  56. <h3 class="name" id="dynamicDampingFactor" translate="no">.<a href="#dynamicDampingFactor">dynamicDampingFactor</a><span class="type-signature"> : number</span> </h3>
  57. <div class="description">
  58. <p>Defines the intensity of damping. Only considered if <code>staticMoving</code> is set to <code>false</code>.</p>
  59. <p>Default is <code>0.2</code>.</p>
  60. </div>
  61. </div>
  62. <div class="member">
  63. <h3 class="name" id="keys" translate="no">.<a href="#keys">keys</a><span class="type-signature"> : Array.&lt;string></span> </h3>
  64. <div class="description">
  65. <p>This array holds keycodes for controlling interactions.</p>
  66. <ul>
  67. <li>When the first defined key is pressed, all mouse interactions (left, middle, right) performs orbiting.</li>
  68. <li>When the second defined key is pressed, all mouse interactions (left, middle, right) performs zooming.</li>
  69. <li>When the third defined key is pressed, all mouse interactions (left, middle, right) performs panning.</li>
  70. </ul>
  71. <p>Default is <em>KeyA, KeyS, KeyD</em> which represents A, S, D.</p>
  72. </div>
  73. <dl class="details">
  74. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Controls.html#keys">Controls#keys</a></dt>
  75. </dl>
  76. </div>
  77. <div class="member">
  78. <h3 class="name" id="maxDistance" translate="no">.<a href="#maxDistance">maxDistance</a><span class="type-signature"> : number</span> </h3>
  79. <div class="description">
  80. <p>How far you can dolly out (perspective camera only).</p>
  81. <p>Default is <code>Infinity</code>.</p>
  82. </div>
  83. </div>
  84. <div class="member">
  85. <h3 class="name" id="maxZoom" translate="no">.<a href="#maxZoom">maxZoom</a><span class="type-signature"> : number</span> </h3>
  86. <div class="description">
  87. <p>How far you can zoom out (orthographic camera only).</p>
  88. <p>Default is <code>Infinity</code>.</p>
  89. </div>
  90. </div>
  91. <div class="member">
  92. <h3 class="name" id="minDistance" translate="no">.<a href="#minDistance">minDistance</a><span class="type-signature"> : number</span> </h3>
  93. <div class="description">
  94. <p>How far you can dolly in (perspective camera only).</p>
  95. <p>Default is <code>0</code>.</p>
  96. </div>
  97. </div>
  98. <div class="member">
  99. <h3 class="name" id="minZoom" translate="no">.<a href="#minZoom">minZoom</a><span class="type-signature"> : number</span> </h3>
  100. <div class="description">
  101. <p>How far you can zoom in (orthographic camera only).</p>
  102. <p>Default is <code>0</code>.</p>
  103. </div>
  104. </div>
  105. <div class="member">
  106. <h3 class="name" id="mouseButtons" translate="no">.<a href="#mouseButtons">mouseButtons</a><span class="type-signature"> : Object</span> </h3>
  107. <div class="description">
  108. <p>This object contains references to the mouse actions used by the controls.</p>
  109. <pre><code class="language-js">controls.mouseButtons = {
  110. LEFT: THREE.MOUSE.ROTATE,
  111. MIDDLE: THREE.MOUSE.DOLLY,
  112. RIGHT: THREE.MOUSE.PAN
  113. }
  114. </code></pre>
  115. </div>
  116. <dl class="details">
  117. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Controls.html#mouseButtons">Controls#mouseButtons</a></dt>
  118. </dl>
  119. </div>
  120. <div class="member">
  121. <h3 class="name" id="noPan" translate="no">.<a href="#noPan">noPan</a><span class="type-signature"> : boolean</span> </h3>
  122. <div class="description">
  123. <p>Whether panning is disabled or not.</p>
  124. <p>Default is <code>false</code>.</p>
  125. </div>
  126. </div>
  127. <div class="member">
  128. <h3 class="name" id="noRotate" translate="no">.<a href="#noRotate">noRotate</a><span class="type-signature"> : boolean</span> </h3>
  129. <div class="description">
  130. <p>Whether rotation is disabled or not.</p>
  131. <p>Default is <code>false</code>.</p>
  132. </div>
  133. </div>
  134. <div class="member">
  135. <h3 class="name" id="noZoom" translate="no">.<a href="#noZoom">noZoom</a><span class="type-signature"> : boolean</span> </h3>
  136. <div class="description">
  137. <p>Whether zooming is disabled or not.</p>
  138. <p>Default is <code>false</code>.</p>
  139. </div>
  140. </div>
  141. <div class="member">
  142. <h3 class="name" id="panSpeed" translate="no">.<a href="#panSpeed">panSpeed</a><span class="type-signature"> : number</span> </h3>
  143. <div class="description">
  144. <p>The pan speed.</p>
  145. <p>Default is <code>0.3</code>.</p>
  146. </div>
  147. </div>
  148. <div class="member">
  149. <h3 class="name" id="rotateSpeed" translate="no">.<a href="#rotateSpeed">rotateSpeed</a><span class="type-signature"> : number</span> </h3>
  150. <div class="description">
  151. <p>The rotation speed.</p>
  152. <p>Default is <code>1</code>.</p>
  153. </div>
  154. </div>
  155. <div class="member">
  156. <h3 class="name" id="screen" translate="no">.<a href="#screen">screen</a><span class="type-signature"> : Object</span> <span class="type-signature">(readonly) </span></h3>
  157. <div class="description">
  158. <p>Represents the properties of the screen. Automatically set when <code>handleResize()</code> is called.</p>
  159. </div>
  160. </div>
  161. <div class="member">
  162. <h3 class="name" id="staticMoving" translate="no">.<a href="#staticMoving">staticMoving</a><span class="type-signature"> : boolean</span> </h3>
  163. <div class="description">
  164. <p>Whether damping is disabled or not.</p>
  165. <p>Default is <code>false</code>.</p>
  166. </div>
  167. </div>
  168. <div class="member">
  169. <h3 class="name" id="target" translate="no">.<a href="#target">target</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  170. <div class="description">
  171. <p>The focus point of the controls.</p>
  172. </div>
  173. </div>
  174. <div class="member">
  175. <h3 class="name" id="zoomSpeed" translate="no">.<a href="#zoomSpeed">zoomSpeed</a><span class="type-signature"> : number</span> </h3>
  176. <div class="description">
  177. <p>The zoom speed.</p>
  178. <p>Default is <code>1.2</code>.</p>
  179. </div>
  180. </div>
  181. <h2 class="subsection-title">Methods</h2>
  182. <h3 class="name name-method" id="handleResize" translate="no">.<a href="#handleResize">handleResize</a><span class="signature">()</span> </h3>
  183. <div class="method">
  184. <div class="description">
  185. <p>Must be called if the application window is resized.</p>
  186. </div>
  187. </div>
  188. <h3 class="name name-method" id="reset" translate="no">.<a href="#reset">reset</a><span class="signature">()</span> </h3>
  189. <div class="method">
  190. <div class="description">
  191. <p>Resets the controls to its initial state.</p>
  192. </div>
  193. </div>
  194. <h2 class="subsection-title">Events</h2>
  195. <h3 class="name name-method" id="event:change" translate="no">.<a href="#event:change">change</a> </h3>
  196. <div class="method">
  197. <div class="description">
  198. <p>Fires when the camera has been transformed by the controls.</p>
  199. </div>
  200. <h5>Type:</h5>
  201. <ul>
  202. <li>
  203. <span class="param-type">Object</span>
  204. </li>
  205. </ul>
  206. </div>
  207. <h3 class="name name-method" id="event:end" translate="no">.<a href="#event:end">end</a> </h3>
  208. <div class="method">
  209. <div class="description">
  210. <p>Fires when an interaction has finished.</p>
  211. </div>
  212. <h5>Type:</h5>
  213. <ul>
  214. <li>
  215. <span class="param-type">Object</span>
  216. </li>
  217. </ul>
  218. </div>
  219. <h3 class="name name-method" id="event:start" translate="no">.<a href="#event:start">start</a> </h3>
  220. <div class="method">
  221. <div class="description">
  222. <p>Fires when an interaction was initiated.</p>
  223. </div>
  224. <h5>Type:</h5>
  225. <ul>
  226. <li>
  227. <span class="param-type">Object</span>
  228. </li>
  229. </ul>
  230. </div>
  231. <h2 class="subsection-title">Source</h2>
  232. <p>
  233. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/TrackballControls.js" translate="no" target="_blank" rel="noopener">examples/jsm/controls/TrackballControls.js</a>
  234. </p>
  235. </article>
  236. </section>
  237. <script src="../scripts/linenumber.js"></script>
  238. <script src="../scripts/page.js"></script>
  239. </body>
  240. </html>
粤ICP备19079148号