XRButton.html 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>XRButton - 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">XRButton</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>A utility class for creating a button that allows to initiate
  16. immersive XR sessions based on WebXR. The button can be created
  17. with a factory method and then appended ot the website's DOM.</p>
  18. <p>Compared to <a href="ARButton.html">ARButton</a> and <a href="VRButton.html">VRButton</a>, this class will
  19. try to offer an immersive AR session first. If the device does not
  20. support this type of session, it uses an immersive VR session.</p></div>
  21. <h2>Code Example</h2>
  22. <div translate="no"><pre><code class="language-js">document.body.appendChild( XRButton.createButton( renderer ) );
  23. </code></pre></div>
  24. </header>
  25. <article>
  26. <h2 class="subsection-title">Import</h2>
  27. <p><span translate="no">XRButton</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank">Installation#Addons</a>.</p>
  28. <pre><code class="language-js">import { XRButton } from 'three/addons/webxr/XRButton.js';</code></pre>
  29. <div class="container-overview">
  30. <div class="method">
  31. </div>
  32. </div>
  33. <h2 class="subsection-title">Static Methods</h2>
  34. <h3 class="name name-method" id=".createButton" translate="no">.<a href="#.createButton">createButton</a><span class="signature">( renderer : <span class="param-type">WebGLRenderer | WebGPURenderer</span>, sessionInit : <span class="param-type">XRSessionInit</span> )</span><span class="type-signature"> : HTMLElement</span> </h3>
  35. <div class="method">
  36. <div class="description">
  37. <p>Constructs a new XR button.</p>
  38. </div>
  39. <table class="params">
  40. <tbody>
  41. <tr>
  42. <td class="name"><code>renderer</code></td>
  43. <td class="description last"><p>The renderer.</p></td>
  44. </tr>
  45. <tr>
  46. <td class="name"><code>sessionInit</code></td>
  47. <td class="description last"><p>The a configuration object for the AR session.</p></td>
  48. </tr>
  49. </tbody>
  50. </table>
  51. <dl class="details">
  52. <dt class="tag-returns"><strong>Returns:</strong> The button or an error message if WebXR isn't supported.</dt>
  53. </dl>
  54. </div>
  55. <h2 class="subsection-title">Source</h2>
  56. <p>
  57. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/webxr/XRButton.js" target="_blank" rel="noopener" translate="no">examples/jsm/webxr/XRButton.js</a>
  58. </p>
  59. </article>
  60. </section>
  61. <script src="../scripts/linenumber.js"></script>
  62. <script src="../scripts/page.js"></script>
  63. </body>
  64. </html>
粤ICP备19079148号