FirstPersonControls.html 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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">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">Object3D</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"><code>object</code></td>
  33. <td class="description last"><p>The object that is managed by the controls.</p></td>
  34. </tr>
  35. <tr>
  36. <td class="name"><code>domElement</code></td>
  37. <td class="description last"><p>The HTML element used for event listeners.<br/>Default is <code>null</code>.</p></td>
  38. </tr>
  39. </tbody>
  40. </table>
  41. </div>
  42. </div>
  43. <h2 class="subsection-title">Properties</h2>
  44. <div class="member">
  45. <h3 class="name" id="activeLook" translate="no">.<a href="#activeLook">activeLook</a><span class="type-signature"> : boolean</span> </h3>
  46. <div class="description">
  47. <p>Whether it's possible to look around or not.<br/>Default is <code>true</code>.</p>
  48. </div>
  49. </div>
  50. <div class="member">
  51. <h3 class="name" id="autoForward" translate="no">.<a href="#autoForward">autoForward</a><span class="type-signature"> : boolean</span> </h3>
  52. <div class="description">
  53. <p>Whether the camera is automatically moved forward or not.<br/>Default is <code>false</code>.</p>
  54. </div>
  55. </div>
  56. <div class="member">
  57. <h3 class="name" id="constrainVertical" translate="no">.<a href="#constrainVertical">constrainVertical</a><span class="type-signature"> : boolean</span> </h3>
  58. <div class="description">
  59. <p>Whether or not looking around is vertically constrained by <code>verticalMin</code> and <code>verticalMax</code>.<br/>Default is <code>false</code>.</p>
  60. </div>
  61. </div>
  62. <div class="member">
  63. <h3 class="name" id="heightCoef" translate="no">.<a href="#heightCoef">heightCoef</a><span class="type-signature"> : number</span> </h3>
  64. <div class="description">
  65. <p>Determines how much faster the camera moves when it's y-component is near <code>heightMax</code>.<br/>Default is <code>1</code>.</p>
  66. </div>
  67. </div>
  68. <div class="member">
  69. <h3 class="name" id="heightMax" translate="no">.<a href="#heightMax">heightMax</a><span class="type-signature"> : number</span> </h3>
  70. <div class="description">
  71. <p>Upper camera height limit used for movement speed adjustment.<br/>Default is <code>1</code>.</p>
  72. </div>
  73. </div>
  74. <div class="member">
  75. <h3 class="name" id="heightMin" translate="no">.<a href="#heightMin">heightMin</a><span class="type-signature"> : number</span> </h3>
  76. <div class="description">
  77. <p>Lower camera height limit used for movement speed adjustment.<br/>Default is <code>0</code>.</p>
  78. </div>
  79. </div>
  80. <div class="member">
  81. <h3 class="name" id="heightSpeed" translate="no">.<a href="#heightSpeed">heightSpeed</a><span class="type-signature"> : boolean</span> </h3>
  82. <div class="description">
  83. <p>Whether or not the camera's height influences the forward movement speed.
  84. Use the properties <code>heightCoef</code>, <code>heightMin</code> and <code>heightMax</code> for configuration.<br/>Default is <code>false</code>.</p>
  85. </div>
  86. </div>
  87. <div class="member">
  88. <h3 class="name" id="lookSpeed" translate="no">.<a href="#lookSpeed">lookSpeed</a><span class="type-signature"> : number</span> </h3>
  89. <div class="description">
  90. <p>The look around speed.<br/>Default is <code>0.005</code>.</p>
  91. </div>
  92. </div>
  93. <div class="member">
  94. <h3 class="name" id="lookVertical" translate="no">.<a href="#lookVertical">lookVertical</a><span class="type-signature"> : boolean</span> </h3>
  95. <div class="description">
  96. <p>Whether it's possible to vertically look around or not.<br/>Default is <code>true</code>.</p>
  97. </div>
  98. </div>
  99. <div class="member">
  100. <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>
  101. <div class="description">
  102. <p>Whether the mouse is pressed down or not.<br/>Default is <code>false</code>.</p>
  103. </div>
  104. </div>
  105. <div class="member">
  106. <h3 class="name" id="movementSpeed" translate="no">.<a href="#movementSpeed">movementSpeed</a><span class="type-signature"> : number</span> </h3>
  107. <div class="description">
  108. <p>The movement speed.<br/>Default is <code>1</code>.</p>
  109. </div>
  110. </div>
  111. <div class="member">
  112. <h3 class="name" id="verticalMax" translate="no">.<a href="#verticalMax">verticalMax</a><span class="type-signature"> : number</span> </h3>
  113. <div class="description">
  114. <p>How far you can vertically look around, upper limit. Range is <code>0</code> to <code>Math.PI</code> in radians.<br/>Default is <code>0</code>.</p>
  115. </div>
  116. </div>
  117. <div class="member">
  118. <h3 class="name" id="verticalMin" translate="no">.<a href="#verticalMin">verticalMin</a><span class="type-signature"> : number</span> </h3>
  119. <div class="description">
  120. <p>How far you can vertically look around, lower limit. Range is <code>0</code> to <code>Math.PI</code> in radians.<br/>Default is <code>0</code>.</p>
  121. </div>
  122. </div>
  123. <h2 class="subsection-title">Methods</h2>
  124. <h3 class="name name-method" id="handleResize" translate="no">.<a href="#handleResize">handleResize</a><span class="signature">()</span> </h3>
  125. <div class="method">
  126. <div class="description">
  127. <p>Must be called if the application window is resized.</p>
  128. </div>
  129. </div>
  130. <h3 class="name name-method" id="lookAt" translate="no">.<a href="#lookAt">lookAt</a><span class="signature">( x : <span class="param-type">number | Vector3</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>
  131. <div class="method">
  132. <div class="description">
  133. <p>Rotates the camera towards the defined target position.</p>
  134. </div>
  135. <table class="params">
  136. <tbody>
  137. <tr>
  138. <td class="name"><code>x</code></td>
  139. <td class="description last"><p>The x coordinate of the target position or alternatively a vector representing the target position.</p></td>
  140. </tr>
  141. <tr>
  142. <td class="name"><code>y</code></td>
  143. <td class="description last"><p>The y coordinate of the target position.</p></td>
  144. </tr>
  145. <tr>
  146. <td class="name"><code>z</code></td>
  147. <td class="description last"><p>The z coordinate of the target position.</p></td>
  148. </tr>
  149. </tbody>
  150. </table>
  151. <dl class="details">
  152. <dt class="tag-returns"><strong>Returns:</strong> A reference to this controls.</dt>
  153. </dl>
  154. </div>
  155. <h2 class="subsection-title">Source</h2>
  156. <p>
  157. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/FirstPersonControls.js" target="_blank" rel="noopener" translate="no">examples/jsm/controls/FirstPersonControls.js</a>
  158. </p>
  159. </article>
  160. </section>
  161. <script src="../scripts/linenumber.js"></script>
  162. <script src="../scripts/page.js"></script>
  163. </body>
  164. </html>
粤ICP备19079148号