TrackballControls.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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">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">Object3D</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"><code>object</code></td>
  35. <td class="description last"><p>The object that is managed by the controls.</p></td>
  36. </tr>
  37. <tr>
  38. <td class="name"><code>domElement</code></td>
  39. <td class="description last"><p>The HTML element used for event listeners.<br/>Default is <code>null</code>.</p></td>
  40. </tr>
  41. </tbody>
  42. </table>
  43. </div>
  44. </div>
  45. <h2 class="subsection-title">Properties</h2>
  46. <div class="member">
  47. <h3 class="name" id="dynamicDampingFactor" translate="no">.<a href="#dynamicDampingFactor">dynamicDampingFactor</a><span class="type-signature"> : number</span> </h3>
  48. <div class="description">
  49. <p>Defines the intensity of damping. Only considered if <code>staticMoving</code> is set to <code>false</code>.<br/>Default is <code>0.2</code>.</p>
  50. </div>
  51. </div>
  52. <div class="member">
  53. <h3 class="name" id="keys" translate="no">.<a href="#keys">keys</a><span class="type-signature"> : Array.&lt;string></span> </h3>
  54. <div class="description">
  55. <p>This array holds keycodes for controlling interactions.</p>
  56. <ul>
  57. <li>When the first defined key is pressed, all mouse interactions (left, middle, right) performs orbiting.</li>
  58. <li>When the second defined key is pressed, all mouse interactions (left, middle, right) performs zooming.</li>
  59. <li>When the third defined key is pressed, all mouse interactions (left, middle, right) performs panning.</li>
  60. </ul>
  61. <p>Default is <em>KeyA, KeyS, KeyD</em> which represents A, S, D.</p>
  62. </div>
  63. <dl class="details">
  64. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Controls.html#keys">Controls#keys</a></dt>
  65. </dl>
  66. </div>
  67. <div class="member">
  68. <h3 class="name" id="maxDistance" translate="no">.<a href="#maxDistance">maxDistance</a><span class="type-signature"> : number</span> </h3>
  69. <div class="description">
  70. <p>How far you can dolly out (perspective camera only).<br/>Default is <code>Infinity</code>.</p>
  71. </div>
  72. </div>
  73. <div class="member">
  74. <h3 class="name" id="maxZoom" translate="no">.<a href="#maxZoom">maxZoom</a><span class="type-signature"> : number</span> </h3>
  75. <div class="description">
  76. <p>How far you can zoom out (orthographic camera only).<br/>Default is <code>Infinity</code>.</p>
  77. </div>
  78. </div>
  79. <div class="member">
  80. <h3 class="name" id="minDistance" translate="no">.<a href="#minDistance">minDistance</a><span class="type-signature"> : number</span> </h3>
  81. <div class="description">
  82. <p>How far you can dolly in (perspective camera only).<br/>Default is <code>0</code>.</p>
  83. </div>
  84. </div>
  85. <div class="member">
  86. <h3 class="name" id="minZoom" translate="no">.<a href="#minZoom">minZoom</a><span class="type-signature"> : number</span> </h3>
  87. <div class="description">
  88. <p>How far you can zoom in (orthographic camera only).<br/>Default is <code>0</code>.</p>
  89. </div>
  90. </div>
  91. <div class="member">
  92. <h3 class="name" id="mouseButtons" translate="no">.<a href="#mouseButtons">mouseButtons</a><span class="type-signature"> : Object</span> </h3>
  93. <div class="description">
  94. <p>This object contains references to the mouse actions used by the controls.</p>
  95. <pre><code class="language-js">controls.mouseButtons = {
  96. LEFT: THREE.MOUSE.ROTATE,
  97. MIDDLE: THREE.MOUSE.DOLLY,
  98. RIGHT: THREE.MOUSE.PAN
  99. }
  100. </code></pre>
  101. </div>
  102. <dl class="details">
  103. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Controls.html#mouseButtons">Controls#mouseButtons</a></dt>
  104. </dl>
  105. </div>
  106. <div class="member">
  107. <h3 class="name" id="noPan" translate="no">.<a href="#noPan">noPan</a><span class="type-signature"> : boolean</span> </h3>
  108. <div class="description">
  109. <p>Whether panning is disabled or not.<br/>Default is <code>false</code>.</p>
  110. </div>
  111. </div>
  112. <div class="member">
  113. <h3 class="name" id="noRotate" translate="no">.<a href="#noRotate">noRotate</a><span class="type-signature"> : boolean</span> </h3>
  114. <div class="description">
  115. <p>Whether rotation is disabled or not.<br/>Default is <code>false</code>.</p>
  116. </div>
  117. </div>
  118. <div class="member">
  119. <h3 class="name" id="noZoom" translate="no">.<a href="#noZoom">noZoom</a><span class="type-signature"> : boolean</span> </h3>
  120. <div class="description">
  121. <p>Whether zooming is disabled or not.<br/>Default is <code>false</code>.</p>
  122. </div>
  123. </div>
  124. <div class="member">
  125. <h3 class="name" id="panSpeed" translate="no">.<a href="#panSpeed">panSpeed</a><span class="type-signature"> : number</span> </h3>
  126. <div class="description">
  127. <p>The pan speed.<br/>Default is <code>0.3</code>.</p>
  128. </div>
  129. </div>
  130. <div class="member">
  131. <h3 class="name" id="rotateSpeed" translate="no">.<a href="#rotateSpeed">rotateSpeed</a><span class="type-signature"> : number</span> </h3>
  132. <div class="description">
  133. <p>The rotation speed.<br/>Default is <code>1</code>.</p>
  134. </div>
  135. </div>
  136. <div class="member">
  137. <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>
  138. <div class="description">
  139. <p>Represents the properties of the screen. Automatically set when <code>handleResize()</code> is called.</p>
  140. </div>
  141. </div>
  142. <div class="member">
  143. <h3 class="name" id="staticMoving" translate="no">.<a href="#staticMoving">staticMoving</a><span class="type-signature"> : boolean</span> </h3>
  144. <div class="description">
  145. <p>Whether damping is disabled or not.<br/>Default is <code>false</code>.</p>
  146. </div>
  147. </div>
  148. <div class="member">
  149. <h3 class="name" id="target" translate="no">.<a href="#target">target</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  150. <div class="description">
  151. <p>The focus point of the controls.</p>
  152. </div>
  153. </div>
  154. <div class="member">
  155. <h3 class="name" id="zoomSpeed" translate="no">.<a href="#zoomSpeed">zoomSpeed</a><span class="type-signature"> : number</span> </h3>
  156. <div class="description">
  157. <p>The zoom speed.<br/>Default is <code>1.2</code>.</p>
  158. </div>
  159. </div>
  160. <h2 class="subsection-title">Methods</h2>
  161. <h3 class="name name-method" id="handleResize" translate="no">.<a href="#handleResize">handleResize</a><span class="signature">()</span> </h3>
  162. <div class="method">
  163. <div class="description">
  164. <p>Must be called if the application window is resized.</p>
  165. </div>
  166. </div>
  167. <h3 class="name name-method" id="reset" translate="no">.<a href="#reset">reset</a><span class="signature">()</span> </h3>
  168. <div class="method">
  169. <div class="description">
  170. <p>Resets the controls to its initial state.</p>
  171. </div>
  172. </div>
  173. <h2 class="subsection-title">Events</h2>
  174. <h3 class="name name-method" id="event:change" translate="no">.<a href="#event:change">change</a> </h3>
  175. <div class="method">
  176. <div class="description">
  177. <p>Fires when the camera has been transformed by the controls.</p>
  178. </div>
  179. <h5>Type:</h5>
  180. <ul>
  181. <li>
  182. <span class="param-type">Object</span>
  183. </li>
  184. </ul>
  185. </div>
  186. <h3 class="name name-method" id="event:end" translate="no">.<a href="#event:end">end</a> </h3>
  187. <div class="method">
  188. <div class="description">
  189. <p>Fires when an interaction has finished.</p>
  190. </div>
  191. <h5>Type:</h5>
  192. <ul>
  193. <li>
  194. <span class="param-type">Object</span>
  195. </li>
  196. </ul>
  197. </div>
  198. <h3 class="name name-method" id="event:start" translate="no">.<a href="#event:start">start</a> </h3>
  199. <div class="method">
  200. <div class="description">
  201. <p>Fires when an interaction was initiated.</p>
  202. </div>
  203. <h5>Type:</h5>
  204. <ul>
  205. <li>
  206. <span class="param-type">Object</span>
  207. </li>
  208. </ul>
  209. </div>
  210. <h2 class="subsection-title">Source</h2>
  211. <p>
  212. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/TrackballControls.js" target="_blank" rel="noopener" translate="no">examples/jsm/controls/TrackballControls.js</a>
  213. </p>
  214. </article>
  215. </section>
  216. <script src="../scripts/linenumber.js"></script>
  217. <script src="../scripts/page.js"></script>
  218. </body>
  219. </html>
粤ICP备19079148号