1
0

VRButton.html 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>VRButton - 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. <h1 translate="no">VRButton</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>A utility class for creating a button that allows to initiate
  16. immersive VR sessions based on WebXR. The button can be created
  17. with a factory method and then appended ot the website's DOM.</p></div>
  18. <h2>Code Example</h2>
  19. <div translate="no"><pre><code class="language-js">document.body.appendChild( VRButton.createButton( renderer ) );
  20. </code></pre></div>
  21. </header>
  22. <article>
  23. <h2 class="subsection-title">Import</h2>
  24. <p><span translate="no">VRButton</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>
  25. <pre><code class="language-js">import { VRButton } from 'three/addons/webxr/VRButton.js';</code></pre>
  26. <div class="container-overview">
  27. <div class="method">
  28. </div>
  29. </div>
  30. <h2 class="subsection-title">Properties</h2>
  31. <div class="member">
  32. <h3 class="name" id=".xrSessionIsGranted" translate="no">.<a href="#.xrSessionIsGranted">xrSessionIsGranted</a><span class="type-signature"> : boolean</span> </h3>
  33. <div class="description">
  34. <p>Whether a XR session has been granted or not.</p>
  35. <p>Default is <code>false</code>.</p>
  36. </div>
  37. </div>
  38. <h2 class="subsection-title">Static Methods</h2>
  39. <h3 class="name name-method" id=".createButton" translate="no">.<a href="#.createButton">createButton</a><span class="signature">( renderer : <span class="param-type"><a href="WebGLRenderer.html">WebGLRenderer</a> | <a href="WebGPURenderer.html">WebGPURenderer</a></span>, sessionInit : <span class="param-type">XRSessionInit</span> )</span><span class="type-signature"> : HTMLElement</span> </h3>
  40. <div class="method">
  41. <div class="description">
  42. <p>Constructs a new VR button.</p>
  43. </div>
  44. <table class="params">
  45. <tbody>
  46. <tr>
  47. <td class="name">
  48. <strong>renderer</strong>
  49. </td>
  50. <td class="description last">
  51. <p>The renderer.</p>
  52. </td>
  53. </tr>
  54. <tr>
  55. <td class="name">
  56. <strong>sessionInit</strong>
  57. </td>
  58. <td class="description last">
  59. <p>The a configuration object for the AR session.</p>
  60. </td>
  61. </tr>
  62. </tbody>
  63. </table>
  64. <dl class="details">
  65. <dt class="tag-returns"><strong>Returns:</strong> The button or an error message if <code>immersive-ar</code> isn't supported.</dt>
  66. </dl>
  67. </div>
  68. <h3 class="name name-method" id=".registerSessionGrantedListener" translate="no">.<a href="#.registerSessionGrantedListener">registerSessionGrantedListener</a><span class="signature">()</span> </h3>
  69. <div class="method">
  70. <div class="description">
  71. <p>Registers a <code>sessiongranted</code> event listener. When a session is granted, the VRButton#xrSessionIsGranted
  72. flag will evaluate to <code>true</code>. This method is automatically called by the module itself so there
  73. should be no need to use it on app level.</p>
  74. </div>
  75. </div>
  76. <h2 class="subsection-title">Source</h2>
  77. <p>
  78. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/webxr/VRButton.js" translate="no" target="_blank" rel="noopener">examples/jsm/webxr/VRButton.js</a>
  79. </p>
  80. </article>
  81. </section>
  82. <script src="../scripts/linenumber.js"></script>
  83. <script src="../scripts/page.js"></script>
  84. </body>
  85. </html>
粤ICP备19079148号