XRButton.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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" rel="noopener">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"><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>
  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">
  43. <strong>renderer</strong>
  44. </td>
  45. <td class="description last">
  46. <p>The renderer.</p>
  47. </td>
  48. </tr>
  49. <tr>
  50. <td class="name">
  51. <strong>sessionInit</strong>
  52. </td>
  53. <td class="description last">
  54. <p>The a configuration object for the AR session.</p>
  55. </td>
  56. </tr>
  57. </tbody>
  58. </table>
  59. <dl class="details">
  60. <dt class="tag-returns"><strong>Returns:</strong> The button or an error message if WebXR isn't supported.</dt>
  61. </dl>
  62. </div>
  63. <h2 class="subsection-title">Source</h2>
  64. <p>
  65. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/webxr/XRButton.js" translate="no" target="_blank" rel="noopener">examples/jsm/webxr/XRButton.js</a>
  66. </p>
  67. </article>
  68. </section>
  69. <script src="../scripts/linenumber.js"></script>
  70. <script src="../scripts/page.js"></script>
  71. </body>
  72. </html>
粤ICP备19079148号