InteractiveGroup.html 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>InteractiveGroup - 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. <p class="inheritance" translate="no"><a href="EventDispatcher.html">EventDispatcher</a> → <a href="Object3D.html">Object3D</a> → <a href="Group.html">Group</a> → </p>
  13. <h1 translate="no">InteractiveGroup</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>This class can be used to group 3D objects in an interactive group.
  17. The group itself can listen to Pointer, Mouse or XR controller events to
  18. detect selections of descendant 3D objects. If a 3D object is selected,
  19. the respective event is going to dispatched to it.</p></div>
  20. <h2>Code Example</h2>
  21. <div translate="no"><pre><code class="language-js">const group = new InteractiveGroup();
  22. group.listenToPointerEvents( renderer, camera );
  23. group.listenToXRControllerEvents( controller1 );
  24. group.listenToXRControllerEvents( controller2 );
  25. scene.add( group );
  26. // now add objects that should be interactive
  27. group.add( mesh1, mesh2, mesh3 );
  28. </code></pre></div>
  29. </header>
  30. <article>
  31. <h2 class="subsection-title">Import</h2>
  32. <p><span translate="no">InteractiveGroup</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>
  33. <pre><code class="language-js">import { InteractiveGroup } from 'three/addons/interactive/InteractiveGroup.js';</code></pre>
  34. <div class="container-overview">
  35. <h2>Constructor</h2>
  36. <h3 class="name name-method" id="InteractiveGroup" translate="no">new <a href="#InteractiveGroup">InteractiveGroup</a><span class="signature">()</span> </h3>
  37. <div class="method">
  38. </div>
  39. </div>
  40. <h2 class="subsection-title">Properties</h2>
  41. <div class="member">
  42. <h3 class="name" id="camera" translate="no">.<a href="#camera">camera</a><span class="type-signature"> : <a href="Camera.html">Camera</a></span> </h3>
  43. <div class="description">
  44. <p>The camera used for raycasting.</p>
  45. <p>Default is <code>null</code>.</p>
  46. </div>
  47. </div>
  48. <div class="member">
  49. <h3 class="name" id="controllers" translate="no">.<a href="#controllers">controllers</a><span class="type-signature"> : Array.&lt;<a href="Group.html">Group</a>></span> </h3>
  50. <div class="description">
  51. <p>An array of XR controllers.</p>
  52. </div>
  53. </div>
  54. <div class="member">
  55. <h3 class="name" id="element" translate="no">.<a href="#element">element</a><span class="type-signature"> : HTMLElement</span> </h3>
  56. <div class="description">
  57. <p>The internal raycaster.</p>
  58. <p>Default is <code>null</code>.</p>
  59. </div>
  60. </div>
  61. <div class="member">
  62. <h3 class="name" id="raycaster" translate="no">.<a href="#raycaster">raycaster</a><span class="type-signature"> : <a href="Raycaster.html">Raycaster</a></span> </h3>
  63. <div class="description">
  64. <p>The internal raycaster.</p>
  65. </div>
  66. </div>
  67. <h2 class="subsection-title">Methods</h2>
  68. <h3 class="name name-method" id="disconnect" translate="no">.<a href="#disconnect">disconnect</a><span class="signature">()</span> </h3>
  69. <div class="method">
  70. <div class="description">
  71. <p>Disconnects this interactive group from the DOM and all XR controllers.</p>
  72. </div>
  73. </div>
  74. <h3 class="name name-method" id="disconnectXrControllerEvents" translate="no">.<a href="#disconnectXrControllerEvents">disconnectXrControllerEvents</a><span class="signature">()</span> </h3>
  75. <div class="method">
  76. <div class="description">
  77. <p>Disconnects this interactive group from all XR controllers.</p>
  78. </div>
  79. </div>
  80. <h3 class="name name-method" id="disconnectionPointerEvents" translate="no">.<a href="#disconnectionPointerEvents">disconnectionPointerEvents</a><span class="signature">()</span> </h3>
  81. <div class="method">
  82. <div class="description">
  83. <p>Disconnects this interactive group from all Pointer and Mouse Events.</p>
  84. </div>
  85. </div>
  86. <h3 class="name name-method" id="listenToPointerEvents" translate="no">.<a href="#listenToPointerEvents">listenToPointerEvents</a><span class="signature">( renderer : <span class="param-type"><a href="WebGPURenderer.html">WebGPURenderer</a> | <a href="WebGLRenderer.html">WebGLRenderer</a></span>, camera : <span class="param-type"><a href="Camera.html">Camera</a></span> )</span> </h3>
  87. <div class="method">
  88. <div class="description">
  89. <p>Calling this method makes sure the interactive group listens to Pointer and Mouse events.
  90. The target is the <code>domElement</code> of the given renderer. The camera is required for the internal
  91. raycasting so 3D objects can be detected based on the events.</p>
  92. </div>
  93. <table class="params">
  94. <tbody>
  95. <tr>
  96. <td class="name">
  97. <strong>renderer</strong>
  98. </td>
  99. <td class="description last">
  100. <p>The renderer.</p>
  101. </td>
  102. </tr>
  103. <tr>
  104. <td class="name">
  105. <strong>camera</strong>
  106. </td>
  107. <td class="description last">
  108. <p>The camera.</p>
  109. </td>
  110. </tr>
  111. </tbody>
  112. </table>
  113. </div>
  114. <h3 class="name name-method" id="listenToXRControllerEvents" translate="no">.<a href="#listenToXRControllerEvents">listenToXRControllerEvents</a><span class="signature">( controller : <span class="param-type"><a href="Group.html">Group</a></span> )</span> </h3>
  115. <div class="method">
  116. <div class="description">
  117. <p>Calling this method makes sure the interactive group listens to events of
  118. the given XR controller.</p>
  119. </div>
  120. <table class="params">
  121. <tbody>
  122. <tr>
  123. <td class="name">
  124. <strong>controller</strong>
  125. </td>
  126. <td class="description last">
  127. <p>The XR controller.</p>
  128. </td>
  129. </tr>
  130. </tbody>
  131. </table>
  132. </div>
  133. <h2 class="subsection-title">Source</h2>
  134. <p>
  135. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/interactive/InteractiveGroup.js" translate="no" target="_blank" rel="noopener">examples/jsm/interactive/InteractiveGroup.js</a>
  136. </p>
  137. </article>
  138. </section>
  139. <script src="../scripts/linenumber.js"></script>
  140. <script src="../scripts/page.js"></script>
  141. </body>
  142. </html>
粤ICP备19079148号