FirstPersonControls.html 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>FirstPersonControls - 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">FirstPersonControls</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>This class is an alternative implementation of <a href="FlyControls.html">FlyControls</a>.</p></div>
  17. </header>
  18. <article>
  19. <h2 class="subsection-title">Import</h2>
  20. <p><span translate="no">FirstPersonControls</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>
  21. <pre><code class="language-js">import { FirstPersonControls } from 'three/addons/controls/FirstPersonControls.js';</code></pre>
  22. <div class="container-overview">
  23. <h2>Constructor</h2>
  24. <h3 class="name name-method" id="FirstPersonControls" translate="no">new <a href="#FirstPersonControls">FirstPersonControls</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>
  25. <div class="method">
  26. <div class="description">
  27. <p>Constructs a new controls instance.</p>
  28. </div>
  29. <table class="params">
  30. <tbody>
  31. <tr>
  32. <td class="name">
  33. <strong>object</strong>
  34. </td>
  35. <td class="description last">
  36. <p>The object that is managed by the controls.</p>
  37. </td>
  38. </tr>
  39. <tr>
  40. <td class="name">
  41. <strong>domElement</strong>
  42. </td>
  43. <td class="description last">
  44. <p>The HTML element used for event listeners.</p>
  45. <p>Default is <code>null</code>.</p>
  46. </td>
  47. </tr>
  48. </tbody>
  49. </table>
  50. </div>
  51. </div>
  52. <h2 class="subsection-title">Properties</h2>
  53. <div class="member">
  54. <h3 class="name" id="activeLook" translate="no">.<a href="#activeLook">activeLook</a><span class="type-signature"> : boolean</span> </h3>
  55. <div class="description">
  56. <p>Whether it's possible to look around or not.</p>
  57. <p>Default is <code>true</code>.</p>
  58. </div>
  59. </div>
  60. <div class="member">
  61. <h3 class="name" id="autoForward" translate="no">.<a href="#autoForward">autoForward</a><span class="type-signature"> : boolean</span> </h3>
  62. <div class="description">
  63. <p>Whether the camera is automatically moved forward or not.</p>
  64. <p>Default is <code>false</code>.</p>
  65. </div>
  66. </div>
  67. <div class="member">
  68. <h3 class="name" id="constrainVertical" translate="no">.<a href="#constrainVertical">constrainVertical</a><span class="type-signature"> : boolean</span> </h3>
  69. <div class="description">
  70. <p>Whether or not looking around is vertically constrained by <code>verticalMin</code> and <code>verticalMax</code>.</p>
  71. <p>Default is <code>false</code>.</p>
  72. </div>
  73. </div>
  74. <div class="member">
  75. <h3 class="name" id="heightCoef" translate="no">.<a href="#heightCoef">heightCoef</a><span class="type-signature"> : number</span> </h3>
  76. <div class="description">
  77. <p>Determines how much faster the camera moves when it's y-component is near <code>heightMax</code>.</p>
  78. <p>Default is <code>1</code>.</p>
  79. </div>
  80. </div>
  81. <div class="member">
  82. <h3 class="name" id="heightMax" translate="no">.<a href="#heightMax">heightMax</a><span class="type-signature"> : number</span> </h3>
  83. <div class="description">
  84. <p>Upper camera height limit used for movement speed adjustment.</p>
  85. <p>Default is <code>1</code>.</p>
  86. </div>
  87. </div>
  88. <div class="member">
  89. <h3 class="name" id="heightMin" translate="no">.<a href="#heightMin">heightMin</a><span class="type-signature"> : number</span> </h3>
  90. <div class="description">
  91. <p>Lower camera height limit used for movement speed adjustment.</p>
  92. <p>Default is <code>0</code>.</p>
  93. </div>
  94. </div>
  95. <div class="member">
  96. <h3 class="name" id="heightSpeed" translate="no">.<a href="#heightSpeed">heightSpeed</a><span class="type-signature"> : boolean</span> </h3>
  97. <div class="description">
  98. <p>Whether or not the camera's height influences the forward movement speed.
  99. Use the properties <code>heightCoef</code>, <code>heightMin</code> and <code>heightMax</code> for configuration.</p>
  100. <p>Default is <code>false</code>.</p>
  101. </div>
  102. </div>
  103. <div class="member">
  104. <h3 class="name" id="lookSpeed" translate="no">.<a href="#lookSpeed">lookSpeed</a><span class="type-signature"> : number</span> </h3>
  105. <div class="description">
  106. <p>The look around speed.</p>
  107. <p>Default is <code>0.005</code>.</p>
  108. </div>
  109. </div>
  110. <div class="member">
  111. <h3 class="name" id="lookVertical" translate="no">.<a href="#lookVertical">lookVertical</a><span class="type-signature"> : boolean</span> </h3>
  112. <div class="description">
  113. <p>Whether it's possible to vertically look around or not.</p>
  114. <p>Default is <code>true</code>.</p>
  115. </div>
  116. </div>
  117. <div class="member">
  118. <h3 class="name" id="mouseDragOn" translate="no">.<a href="#mouseDragOn">mouseDragOn</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  119. <div class="description">
  120. <p>Whether the mouse is pressed down or not.</p>
  121. <p>Default is <code>false</code>.</p>
  122. </div>
  123. </div>
  124. <div class="member">
  125. <h3 class="name" id="movementSpeed" translate="no">.<a href="#movementSpeed">movementSpeed</a><span class="type-signature"> : number</span> </h3>
  126. <div class="description">
  127. <p>The movement speed.</p>
  128. <p>Default is <code>1</code>.</p>
  129. </div>
  130. </div>
  131. <div class="member">
  132. <h3 class="name" id="verticalMax" translate="no">.<a href="#verticalMax">verticalMax</a><span class="type-signature"> : number</span> </h3>
  133. <div class="description">
  134. <p>How far you can vertically look around, upper limit. Range is <code>0</code> to <code>Math.PI</code> in radians.</p>
  135. <p>Default is <code>0</code>.</p>
  136. </div>
  137. </div>
  138. <div class="member">
  139. <h3 class="name" id="verticalMin" translate="no">.<a href="#verticalMin">verticalMin</a><span class="type-signature"> : number</span> </h3>
  140. <div class="description">
  141. <p>How far you can vertically look around, lower limit. Range is <code>0</code> to <code>Math.PI</code> in radians.</p>
  142. <p>Default is <code>0</code>.</p>
  143. </div>
  144. </div>
  145. <h2 class="subsection-title">Methods</h2>
  146. <h3 class="name name-method" id="handleResize" translate="no">.<a href="#handleResize">handleResize</a><span class="signature">()</span> </h3>
  147. <div class="method">
  148. <div class="description">
  149. <p>Must be called if the application window is resized.</p>
  150. </div>
  151. </div>
  152. <h3 class="name name-method" id="lookAt" translate="no">.<a href="#lookAt">lookAt</a><span class="signature">( x : <span class="param-type">number | <a href="Vector3.html">Vector3</a></span>, y : <span class="param-type">number</span>, z : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="FirstPersonControls.html">FirstPersonControls</a></span> </h3>
  153. <div class="method">
  154. <div class="description">
  155. <p>Rotates the camera towards the defined target position.</p>
  156. </div>
  157. <table class="params">
  158. <tbody>
  159. <tr>
  160. <td class="name">
  161. <strong>x</strong>
  162. </td>
  163. <td class="description last">
  164. <p>The x coordinate of the target position or alternatively a vector representing the target position.</p>
  165. </td>
  166. </tr>
  167. <tr>
  168. <td class="name">
  169. <strong>y</strong>
  170. </td>
  171. <td class="description last">
  172. <p>The y coordinate of the target position.</p>
  173. </td>
  174. </tr>
  175. <tr>
  176. <td class="name">
  177. <strong>z</strong>
  178. </td>
  179. <td class="description last">
  180. <p>The z coordinate of the target position.</p>
  181. </td>
  182. </tr>
  183. </tbody>
  184. </table>
  185. <dl class="details">
  186. <dt class="tag-returns"><strong>Returns:</strong> A reference to this controls.</dt>
  187. </dl>
  188. </div>
  189. <h2 class="subsection-title">Source</h2>
  190. <p>
  191. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/FirstPersonControls.js" translate="no" target="_blank" rel="noopener">examples/jsm/controls/FirstPersonControls.js</a>
  192. </p>
  193. </article>
  194. </section>
  195. <script src="../scripts/linenumber.js"></script>
  196. <script src="../scripts/page.js"></script>
  197. </body>
  198. </html>
粤ICP备19079148号