1
0

XRControllerModelFactory.html 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>XRControllerModelFactory - 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">XRControllerModelFactory</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>Allows to create controller models for WebXR controllers that can be added as a visual
  16. representation to your scene. <code>XRControllerModelFactory</code> will automatically fetch controller
  17. models that match what the user is holding as closely as possible. The models should be
  18. attached to the object returned from getControllerGrip in order to match the orientation of
  19. the held device.</p>
  20. <p>This module depends on the <a href="https://github.com/immersive-web/webxr-input-profiles/blob/main/packages/motion-controllers/README.md" target="_blank" rel="noopener">motion-controllers</a>
  21. third-part library.</p></div>
  22. <h2>Code Example</h2>
  23. <div translate="no"><pre><code class="language-js">const controllerModelFactory = new XRControllerModelFactory();
  24. const controllerGrip = renderer.xr.getControllerGrip( 0 );
  25. controllerGrip.add( controllerModelFactory.createControllerModel( controllerGrip ) );
  26. scene.add( controllerGrip );
  27. </code></pre></div>
  28. </header>
  29. <article>
  30. <h2 class="subsection-title">Import</h2>
  31. <p><span translate="no">XRControllerModelFactory</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>
  32. <pre><code class="language-js">import { XRControllerModelFactory } from 'three/addons/webxr/XRControllerModelFactory.js';</code></pre>
  33. <div class="container-overview">
  34. <h2>Constructor</h2>
  35. <h3 class="name name-method" id="XRControllerModelFactory" translate="no">new <a href="#XRControllerModelFactory">XRControllerModelFactory</a><span class="signature">( gltfLoader : <span class="param-type"><a href="GLTFLoader.html">GLTFLoader</a></span>, onLoad : <span class="param-type">function</span> )</span> </h3>
  36. <div class="method">
  37. <div class="description">
  38. <p>Constructs a new XR controller model factory.</p>
  39. </div>
  40. <table class="params">
  41. <tbody>
  42. <tr>
  43. <td class="name">
  44. <strong>gltfLoader</strong>
  45. </td>
  46. <td class="description last">
  47. <p>A glTF loader that is used to load controller models.</p>
  48. <p>Default is <code>null</code>.</p>
  49. </td>
  50. </tr>
  51. <tr>
  52. <td class="name">
  53. <strong>onLoad</strong>
  54. </td>
  55. <td class="description last">
  56. <p>A callback that is executed when a controller model has been loaded.</p>
  57. <p>Default is <code>null</code>.</p>
  58. </td>
  59. </tr>
  60. </tbody>
  61. </table>
  62. </div>
  63. </div>
  64. <h2 class="subsection-title">Properties</h2>
  65. <div class="member">
  66. <h3 class="name" id="gltfLoader" translate="no">.<a href="#gltfLoader">gltfLoader</a><span class="type-signature"> : <a href="GLTFLoader.html">GLTFLoader</a></span> </h3>
  67. <div class="description">
  68. <p>A glTF loader that is used to load controller models.</p>
  69. <p>Default is <code>null</code>.</p>
  70. </div>
  71. </div>
  72. <div class="member">
  73. <h3 class="name" id="onLoad" translate="no">.<a href="#onLoad">onLoad</a><span class="type-signature"> : function</span> </h3>
  74. <div class="description">
  75. <p>A callback that is executed when a controller model has been loaded.</p>
  76. <p>Default is <code>null</code>.</p>
  77. </div>
  78. </div>
  79. <div class="member">
  80. <h3 class="name" id="path" translate="no">.<a href="#path">path</a><span class="type-signature"> : string</span> </h3>
  81. <div class="description">
  82. <p>The path to the model repository.</p>
  83. </div>
  84. </div>
  85. <h2 class="subsection-title">Methods</h2>
  86. <h3 class="name name-method" id="createControllerModel" translate="no">.<a href="#createControllerModel">createControllerModel</a><span class="signature">( controller : <span class="param-type"><a href="Group.html">Group</a></span> )</span><span class="type-signature"> : <a href="XRControllerModel.html">XRControllerModel</a></span> </h3>
  87. <div class="method">
  88. <div class="description">
  89. <p>Creates a controller model for the given WebXR controller.</p>
  90. </div>
  91. <table class="params">
  92. <tbody>
  93. <tr>
  94. <td class="name">
  95. <strong>controller</strong>
  96. </td>
  97. <td class="description last">
  98. <p>The controller.</p>
  99. </td>
  100. </tr>
  101. </tbody>
  102. </table>
  103. <dl class="details">
  104. <dt class="tag-returns"><strong>Returns:</strong> The XR controller model.</dt>
  105. </dl>
  106. </div>
  107. <h3 class="name name-method" id="setPath" translate="no">.<a href="#setPath">setPath</a><span class="signature">( path : <span class="param-type">string</span> )</span><span class="type-signature"> : <a href="XRControllerModelFactory.html">XRControllerModelFactory</a></span> </h3>
  108. <div class="method">
  109. <div class="description">
  110. <p>Sets the path to the model repository.</p>
  111. </div>
  112. <table class="params">
  113. <tbody>
  114. <tr>
  115. <td class="name">
  116. <strong>path</strong>
  117. </td>
  118. <td class="description last">
  119. <p>The path to set.</p>
  120. </td>
  121. </tr>
  122. </tbody>
  123. </table>
  124. <dl class="details">
  125. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  126. </dl>
  127. </div>
  128. <h2 class="subsection-title">Source</h2>
  129. <p>
  130. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/webxr/XRControllerModelFactory.js" translate="no" target="_blank" rel="noopener">examples/jsm/webxr/XRControllerModelFactory.js</a>
  131. </p>
  132. </article>
  133. </section>
  134. <script src="../scripts/linenumber.js"></script>
  135. <script src="../scripts/page.js"></script>
  136. </body>
  137. </html>
粤ICP备19079148号