PointerLockControls.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css" />
  9. </head>
  10. <body>
  11. [page:EventDispatcher] &rarr;
  12. <h1>[name]</h1>
  13. <p class="desc">
  14. The implementation of this class is based on the [link:https://developer.mozilla.org/en-US/docs/Web/API/Pointer_Lock_API Pointer Lock API].
  15. [name] is a perfect choice for first person 3D games.
  16. </p>
  17. <h2>Code Example</h2>
  18. <code>
  19. var controls = new PointerLockControls( camera, document.body );
  20. // add event listener to show/hide a UI (e.g. the game's menu)
  21. controls.addEventListener( 'lock', function () {
  22. menu.style.display = 'none';
  23. } );
  24. controls.addEventListener( 'unlock', function () {
  25. menu.style.display = 'block';
  26. } );
  27. </code>
  28. <h2>Examples</h2>
  29. <p>[example:misc_controls_pointerlock misc / controls / pointerlock ]</p>
  30. <h2>Constructor</h2>
  31. <h3>[name]( [param:Camera camera], [param:HTMLDOMElement domElement] )</h3>
  32. <p>
  33. <p>
  34. [page:Camera camera]: The camera of the rendered scene.
  35. </p>
  36. <p>
  37. [page:HTMLDOMElement domElement]: The HTML element used for event listeners.
  38. </p>
  39. <p>
  40. Creates a new instance of [name].
  41. </p>
  42. </p>
  43. <h2>Events</h2>
  44. <h3>change</h3>
  45. <p>
  46. Fires when the user moves the mouse.
  47. </p>
  48. <h3>lock</h3>
  49. <p>
  50. Fires when the pointer lock status is "locked" (in other words: the mouse is captured).
  51. </p>
  52. <h3>unlock</h3>
  53. <p>
  54. Fires when the pointer lock status is "unlocked" (in other words: the mouse is not captured anymore).
  55. </p>
  56. <h2>Properties</h2>
  57. <h3>[property:HTMLDOMElement domElement]</h3>
  58. <p>
  59. The HTMLDOMElement used to listen for mouse / touch events. This must be passed in the constructor; changing it here will
  60. not set up new event listeners.
  61. </p>
  62. <h3>[property:Boolean isLocked]</h3>
  63. <p>
  64. Whether or not the controls are locked.
  65. </p>
  66. <h3>[property:Float maxPolarAngle]</h3>
  67. <p>
  68. Camera pitch, upper limit. Range is 0 to Math.PI radians. Default is Math.PI.
  69. </p>
  70. <h3>[property:Float minPolarAngle]</h3>
  71. <p>
  72. Camera pitch, lower limit. Range is 0 to Math.PI radians. Default is 0.
  73. </p>
  74. <h2>Methods</h2>
  75. <p>See the base [page:EventDispatcher] class for common methods.</p>
  76. <h3>[method:null connect] ()</h3>
  77. <p>
  78. Adds the event listeners of the controls.
  79. </p>
  80. <h3>[method:null disconnect] ()</h3>
  81. <p>
  82. Removes the event listeners of the controls.
  83. </p>
  84. <h3>[method:Vector3 getDirection] ( [param:Vector3 target] )</h3>
  85. <p>
  86. <p>
  87. [page:Vector3 target]: The target vector.
  88. </p>
  89. <p>
  90. Returns the look direction of the camera.
  91. </p>
  92. </p>
  93. <h3>[method:null lock] ()</h3>
  94. <p>
  95. Activates the pointer lock.
  96. </p>
  97. <h3>[method:null moveForward] ( [param:Number distance] )</h3>
  98. <p>
  99. <p>
  100. [page:Number distance]: The signed distance.
  101. </p>
  102. <p>
  103. Moves the camera forward parallel to the xz-plane. Assumes camera.up is y-up.
  104. </p>
  105. </p>
  106. <h3>[method:null moveRight] ( [param:Number distance] )</h3>
  107. <p>
  108. <p>
  109. [page:Number distance]: The signed distance.
  110. </p>
  111. <p>
  112. Moves the camera sidewards parallel to the xz-plane.
  113. </p>
  114. </p>
  115. <h3>[method:null unlock] ()</h3>
  116. <p>
  117. Exits the pointer lock.
  118. </p>
  119. <h2>Source</h2>
  120. <p>
  121. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/PointerLockControls.js examples/jsm/controls/PointerLockControls.js]
  122. </p>
  123. </body>
  124. </html>