InteractionManager.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>InteractionManager - 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">InteractionManager</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>Manages interaction for 3D objects independently of the scene graph.</p>
  16. <p>For objects with an <a href="HTMLTexture.html">HTMLTexture</a>, the manager computes CSS <code>matrix3d</code>
  17. transforms each frame so the underlying HTML elements stay aligned with
  18. their meshes. Because the elements are children of the canvas, the browser
  19. dispatches pointer events to them natively.</p></div>
  20. <h2>Code Example</h2>
  21. <div translate="no"><pre><code class="language-js">const interactions = new InteractionManager();
  22. interactions.connect( renderer, camera );
  23. // Objects live anywhere in the scene graph
  24. scene.add( mesh );
  25. // Register for interaction separately
  26. interactions.add( mesh );
  27. // In the animation loop
  28. interactions.update();
  29. </code></pre></div>
  30. </header>
  31. <article>
  32. <h2 class="subsection-title">Import</h2>
  33. <p><span translate="no">InteractionManager</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>
  34. <pre><code class="language-js">import { InteractionManager } from 'three/addons/interaction/InteractionManager.js';</code></pre>
  35. <div class="container-overview">
  36. <h2>Constructor</h2>
  37. <h3 class="name name-method" id="InteractionManager" translate="no">new <a href="#InteractionManager">InteractionManager</a><span class="signature">()</span> </h3>
  38. <div class="method">
  39. </div>
  40. </div>
  41. <h2 class="subsection-title">Properties</h2>
  42. <div class="member">
  43. <h3 class="name" id="camera" translate="no">.<a href="#camera">camera</a><span class="type-signature"> : <a href="Camera.html">Camera</a></span> </h3>
  44. <div class="description">
  45. <p>The camera used for computing the element transforms.</p>
  46. <p>Default is <code>null</code>.</p>
  47. </div>
  48. </div>
  49. <div class="member">
  50. <h3 class="name" id="element" translate="no">.<a href="#element">element</a><span class="type-signature"> : HTMLCanvasElement</span> </h3>
  51. <div class="description">
  52. <p>The canvas element.</p>
  53. <p>Default is <code>null</code>.</p>
  54. </div>
  55. </div>
  56. <div class="member">
  57. <h3 class="name" id="objects" translate="no">.<a href="#objects">objects</a><span class="type-signature"> : Array.&lt;<a href="Object3D.html">Object3D</a>></span> </h3>
  58. <div class="description">
  59. <p>The registered interactive objects.</p>
  60. </div>
  61. </div>
  62. <h2 class="subsection-title">Methods</h2>
  63. <h3 class="name name-method" id="add" translate="no">.<a href="#add">add</a><span class="signature">( &hellip;objects : <span class="param-type"><a href="Object3D.html">Object3D</a></span> )</span><span class="type-signature"> : this</span> </h3>
  64. <div class="method">
  65. <div class="description">
  66. <p>Adds one or more objects to the manager.</p>
  67. </div>
  68. <table class="params">
  69. <tbody>
  70. <tr>
  71. <td class="name">
  72. <strong translate="no">objects</strong>
  73. </td>
  74. <td class="description last">
  75. <p>The objects to add.</p>
  76. </td>
  77. </tr>
  78. </tbody>
  79. </table>
  80. </div>
  81. <h3 class="name name-method" id="connect" translate="no">.<a href="#connect">connect</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>
  82. <div class="method">
  83. <div class="description">
  84. <p>Stores the renderer and camera needed for computing element transforms.</p>
  85. </div>
  86. <table class="params">
  87. <tbody>
  88. <tr>
  89. <td class="name">
  90. <strong translate="no">renderer</strong>
  91. </td>
  92. <td class="description last">
  93. <p>The renderer.</p>
  94. </td>
  95. </tr>
  96. <tr>
  97. <td class="name">
  98. <strong translate="no">camera</strong>
  99. </td>
  100. <td class="description last">
  101. <p>The camera.</p>
  102. </td>
  103. </tr>
  104. </tbody>
  105. </table>
  106. </div>
  107. <h3 class="name name-method" id="disconnect" translate="no">.<a href="#disconnect">disconnect</a><span class="signature">()</span> </h3>
  108. <div class="method">
  109. <div class="description">
  110. <p>Disconnects this manager, clearing the renderer and camera references.</p>
  111. </div>
  112. </div>
  113. <h3 class="name name-method" id="remove" translate="no">.<a href="#remove">remove</a><span class="signature">( &hellip;objects : <span class="param-type"><a href="Object3D.html">Object3D</a></span> )</span><span class="type-signature"> : this</span> </h3>
  114. <div class="method">
  115. <div class="description">
  116. <p>Removes one or more objects from the manager.</p>
  117. </div>
  118. <table class="params">
  119. <tbody>
  120. <tr>
  121. <td class="name">
  122. <strong translate="no">objects</strong>
  123. </td>
  124. <td class="description last">
  125. <p>The objects to remove.</p>
  126. </td>
  127. </tr>
  128. </tbody>
  129. </table>
  130. </div>
  131. <h3 class="name name-method" id="update" translate="no">.<a href="#update">update</a><span class="signature">()</span> </h3>
  132. <div class="method">
  133. <div class="description">
  134. <p>Updates the element transforms for all registered objects.
  135. Call this once per frame in the animation loop.</p>
  136. </div>
  137. </div>
  138. <h2 class="subsection-title">Source</h2>
  139. <p>
  140. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/interaction/InteractionManager.js" translate="no" target="_blank" rel="noopener">examples/jsm/interaction/InteractionManager.js</a>
  141. </p>
  142. </article>
  143. </section>
  144. <script src="../scripts/linenumber.js"></script>
  145. <script src="../scripts/page.js"></script>
  146. </body>
  147. </html>
粤ICP备19079148号