FirstPersonControls.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. <h1>[name]</h1>
  11. <p class="desc">
  12. This class is an alternative implementation of [page:FlyControls].
  13. </p>
  14. <h2>Import</h2>
  15. <p>
  16. [name] is an add-on, and must be imported explicitly.
  17. See [link:#manual/introduction/Installation Installation / Addons].
  18. </p>
  19. <code>
  20. import { FirstPersonControls } from 'three/addons/controls/FirstPersonControls.js';
  21. </code>
  22. <h2>Examples</h2>
  23. <p>[example:webgl_geometry_terrain webgl / geometry / terrain ]</p>
  24. <h2>Constructor</h2>
  25. <h3>[name]( [param:Camera object], [param:HTMLDOMElement domElement] )</h3>
  26. <p>
  27. <p>
  28. [page:Camera object]: The camera to be controlled.
  29. </p>
  30. <p>
  31. [page:HTMLDOMElement domElement]: The HTML element used for event listeners.
  32. </p>
  33. <p>
  34. Creates a new instance of [name].
  35. </p>
  36. </p>
  37. <h2>Properties</h2>
  38. <h3>[property:Boolean activeLook]</h3>
  39. <p>
  40. Whether or not it's possible to look around. Default is `true`.
  41. </p>
  42. <h3>[property:Boolean autoForward]</h3>
  43. <p>
  44. Whether or not the camera is automatically moved forward. Default is `false`.
  45. </p>
  46. <h3>[property:Boolean constrainVertical]</h3>
  47. <p>
  48. Whether or not looking around is vertically constrained by [[page:.verticalMin], [page:.verticalMax]]. Default is `false`.
  49. </p>
  50. <h3>[property:HTMLDOMElement domElement]</h3>
  51. <p>
  52. The HTMLDOMElement used to listen for mouse / touch events. This must be passed in the constructor; changing it here will
  53. not set up new event listeners.
  54. </p>
  55. <h3>[property:Boolean enabled]</h3>
  56. <p>
  57. Whether or not the controls are enabled. Default is `true`.
  58. </p>
  59. <h3>[property:Number heightCoef]</h3>
  60. <p>
  61. Determines how much faster the camera moves when it's y-component is near [page:.heightMax]. Default is *1*.
  62. </p>
  63. <h3>[property:Number heightMax]</h3>
  64. <p>
  65. Upper camera height limit used for movement speed adjustment. Default is *1*.
  66. </p>
  67. <h3>[property:Number heightMin]</h3>
  68. <p>
  69. Lower camera height limit used for movement speed adjustment. Default is *0*.
  70. </p>
  71. <h3>[property:Boolean heightSpeed]</h3>
  72. <p>
  73. Whether or not the camera's height influences the forward movement speed. Default is `false`.
  74. Use the properties [page:.heightCoef], [page:.heightMin] and [page:.heightMax] for configuration.
  75. </p>
  76. <h3>[property:Boolean lookVertical]</h3>
  77. <p>
  78. Whether or not it's possible to vertically look around. Default is `true`.
  79. </p>
  80. <h3>[property:Number lookSpeed]</h3>
  81. <p>
  82. The look around speed. Default is `0.005`.
  83. </p>
  84. <h3>[property:Boolean mouseDragOn]</h3>
  85. <p>
  86. Whether or not the mouse is pressed down. Read-only property.
  87. </p>
  88. <h3>[property:Number movementSpeed]</h3>
  89. <p>
  90. The movement speed. Default is *1*.
  91. </p>
  92. <h3>[property:Camera object]</h3>
  93. <p>
  94. The camera to be controlled.
  95. </p>
  96. <h3>[property:Number verticalMax]</h3>
  97. <p>
  98. How far you can vertically look around, upper limit. Range is 0 to Math.PI radians. Default is `Math.PI`.
  99. </p>
  100. <h3>[property:Number verticalMin]</h3>
  101. <p>
  102. How far you can vertically look around, lower limit. Range is 0 to Math.PI radians. Default is *0*.
  103. </p>
  104. <h2>Methods</h2>
  105. <h3>[method:undefined dispose] ()</h3>
  106. <p>
  107. Should be called if the controls is no longer required.
  108. </p>
  109. <h3>[method:undefined handleResize] ()</h3>
  110. <p>
  111. Should be called if the application window is resized.
  112. </p>
  113. <h3>[method:FirstPersonControls lookAt]( [param:Vector3 vector] )<br />
  114. [method:FirstPersonControls lookAt]( [param:Float x], [param:Float y], [param:Float z] )</h3>
  115. <p>
  116. <p>
  117. <p>
  118. vector - A vector representing the target position.
  119. </p>
  120. <p>
  121. Optionally, the x, y, z components of the world space position.
  122. </p>
  123. </p>
  124. <p>
  125. Ensures the controls orient the camera towards the defined target position.
  126. </p>
  127. </p>
  128. <h3>[method:undefined update] ( [param:Number delta] )</h3>
  129. <p>
  130. <p>
  131. [page:Number delta]: Time delta value.
  132. </p>
  133. <p>
  134. Updates the controls. Usually called in the animation loop.
  135. </p>
  136. </p>
  137. <h2>Source</h2>
  138. <p>
  139. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/FirstPersonControls.js examples/jsm/controls/FirstPersonControls.js]
  140. </p>
  141. </body>
  142. </html>