PointerLockControls.html 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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>Example</h2>
  18. <p>[example:misc_controls_pointerlock misc / controls / pointerlock ]</p>
  19. <code>
  20. var controls = new PointerLockControls( camera, document.body );
  21. // add event listener to show/hide a UI (e.g. the game's menu)
  22. controls.addEventListener( 'lock', function () {
  23. menu.style.display = 'none';
  24. } );
  25. controls.addEventListener( 'unlock', function () {
  26. menu.style.display = 'block';
  27. } );
  28. </code>
  29. <h2>Constructor</h2>
  30. <h3>[name]( [param:Camera camera], [param:HTMLDOMElement domElement] )</h3>
  31. <p>
  32. <p>
  33. [page:Camera camera]: The camera of the rendered scene.
  34. </p>
  35. <p>
  36. [page:HTMLDOMElement domElement]: The HTML element used for event listeners.
  37. </p>
  38. <p>
  39. Creates a new instance of [name].
  40. </p>
  41. </p>
  42. <h2>Events</h2>
  43. <h3>change</h3>
  44. <p>
  45. Fires when the user moves the mouse.
  46. </p>
  47. <h3>lock</h3>
  48. <p>
  49. Fires when the pointer lock status is "locked" (in other words: the mouse is captured).
  50. </p>
  51. <h3>unlock</h3>
  52. <p>
  53. Fires when the pointer lock status is "unlocked" (in other words: the mouse is not captured anymore).
  54. </p>
  55. <h2>Properties</h2>
  56. <h3>[property:HTMLDOMElement domElement]</h3>
  57. <p>
  58. The HTMLDOMElement used to listen for mouse / touch events. This must be passed in the constructor; changing it here will
  59. not set up new event listeners.
  60. </p>
  61. <h3>[property:Boolean isLocked]</h3>
  62. <p>
  63. Whether or not the controls are locked.
  64. </p>
  65. <h2>Methods</h2>
  66. <p>See the base [page:EventDispatcher] class for common methods.</p>
  67. <h3>[method:null connect] ()</h3>
  68. <p>
  69. Adds the event listeners of the controls.
  70. </p>
  71. <h3>[method:null disconnect] ()</h3>
  72. <p>
  73. Removes the event listeners of the controls.
  74. </p>
  75. <h3>[method:Vector3 getDirection] ( [param:Vector3 target] )</h3>
  76. <p>
  77. <p>
  78. [page:Vector3 target]: The target vector.
  79. </p>
  80. <p>
  81. Returns the look direction of the camera.
  82. </p>
  83. </p>
  84. <h3>[method:null lock] ()</h3>
  85. <p>
  86. Activates the pointer lock.
  87. </p>
  88. <h3>[method:null moveForward] ( [param:Number distance] )</h3>
  89. <p>
  90. <p>
  91. [page:Number distance]: The signed distance.
  92. </p>
  93. <p>
  94. Moves the camera forward parallel to the xz-plane. Assumes camera.up is y-up.
  95. </p>
  96. </p>
  97. <h3>[method:null moveRight] ( [param:Number distance] )</h3>
  98. <p>
  99. <p>
  100. [page:Number distance]: The signed distance.
  101. </p>
  102. <p>
  103. Moves the camera sidewards parallel to the xz-plane.
  104. </p>
  105. </p>
  106. <h3>[method:null unlock] ()</h3>
  107. <p>
  108. Exits the pointer lock.
  109. </p>
  110. <h2>Source</h2>
  111. <p>
  112. [link:https://github.com/mrdoob/three.js/blob/master/examples/js/controls/PointerLockControls.js examples/js/controls/PointerLockControls.js]
  113. </p>
  114. </body>
  115. </html>