| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>InteractionManager - Three.js Docs</title>
- <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
- <script src="../scripts/highlight.min.js"></script>
- <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
- <link type="text/css" rel="stylesheet" href="../styles/page.css">
- </head>
- <body>
- <h1 translate="no">InteractionManager</h1>
- <section>
- <header>
- <div class="class-description"><p>Manages interaction for 3D objects independently of the scene graph.</p>
- <p>For objects with an <a href="HTMLTexture.html">HTMLTexture</a>, the manager computes CSS <code>matrix3d</code>
- transforms each frame so the underlying HTML elements stay aligned with
- their meshes. Because the elements are children of the canvas, the browser
- dispatches pointer events to them natively.</p></div>
- <h2>Code Example</h2>
- <div translate="no"><pre><code class="language-js">const interactions = new InteractionManager();
- interactions.connect( renderer, camera );
- // Objects live anywhere in the scene graph
- scene.add( mesh );
- // Register for interaction separately
- interactions.add( mesh );
- // In the animation loop
- interactions.update();
- </code></pre></div>
- </header>
- <article>
- <h2 class="subsection-title">Import</h2>
- <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>
- <pre><code class="language-js">import { InteractionManager } from 'three/addons/interaction/InteractionManager.js';</code></pre>
- <div class="container-overview">
- <h2>Constructor</h2>
- <h3 class="name name-method" id="InteractionManager" translate="no">new <a href="#InteractionManager">InteractionManager</a><span class="signature">()</span> </h3>
- <div class="method">
- </div>
- </div>
- <h2 class="subsection-title">Properties</h2>
- <div class="member">
- <h3 class="name" id="camera" translate="no">.<a href="#camera">camera</a><span class="type-signature"> : <a href="Camera.html">Camera</a></span> </h3>
- <div class="description">
- <p>The camera used for computing the element transforms.</p>
- <p>Default is <code>null</code>.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="element" translate="no">.<a href="#element">element</a><span class="type-signature"> : HTMLCanvasElement</span> </h3>
- <div class="description">
- <p>The canvas element.</p>
- <p>Default is <code>null</code>.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="objects" translate="no">.<a href="#objects">objects</a><span class="type-signature"> : Array.<<a href="Object3D.html">Object3D</a>></span> </h3>
- <div class="description">
- <p>The registered interactive objects.</p>
- </div>
- </div>
- <h2 class="subsection-title">Methods</h2>
- <h3 class="name name-method" id="add" translate="no">.<a href="#add">add</a><span class="signature">( …objects : <span class="param-type"><a href="Object3D.html">Object3D</a></span> )</span><span class="type-signature"> : this</span> </h3>
- <div class="method">
- <div class="description">
- <p>Adds one or more objects to the manager.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong translate="no">objects</strong>
- </td>
- <td class="description last">
- <p>The objects to add.</p>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Stores the renderer and camera needed for computing element transforms.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong translate="no">renderer</strong>
- </td>
- <td class="description last">
- <p>The renderer.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong translate="no">camera</strong>
- </td>
- <td class="description last">
- <p>The camera.</p>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <h3 class="name name-method" id="disconnect" translate="no">.<a href="#disconnect">disconnect</a><span class="signature">()</span> </h3>
- <div class="method">
- <div class="description">
- <p>Disconnects this manager, clearing the renderer and camera references.</p>
- </div>
- </div>
- <h3 class="name name-method" id="remove" translate="no">.<a href="#remove">remove</a><span class="signature">( …objects : <span class="param-type"><a href="Object3D.html">Object3D</a></span> )</span><span class="type-signature"> : this</span> </h3>
- <div class="method">
- <div class="description">
- <p>Removes one or more objects from the manager.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong translate="no">objects</strong>
- </td>
- <td class="description last">
- <p>The objects to remove.</p>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <h3 class="name name-method" id="update" translate="no">.<a href="#update">update</a><span class="signature">()</span> </h3>
- <div class="method">
- <div class="description">
- <p>Updates the element transforms for all registered objects.
- Call this once per frame in the animation loop.</p>
- </div>
- </div>
- <h2 class="subsection-title">Source</h2>
- <p>
- <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>
- </p>
- </article>
- </section>
- <script src="../scripts/linenumber.js"></script>
- <script src="../scripts/page.js"></script>
- </body>
- </html>
|