| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Refractor - 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>
- <p class="inheritance" translate="no"><a href="EventDispatcher.html">EventDispatcher</a> → <a href="Object3D.html">Object3D</a> → <a href="Mesh.html">Mesh</a> → </p>
- <h1 translate="no">Refractor</h1>
- <section>
- <header>
- <div class="class-description"><p>Can be used to create a flat, refractive surface like for special
- windows or water effects.</p>
- <p>Note that this class can only be used with <a href="WebGLRenderer.html">WebGLRenderer</a>.
- When using <a href="WebGPURenderer.html">WebGPURenderer</a>, use <a href="TSL.html#viewportSharedTexture">viewportSharedTexture</a>.</p></div>
- <h2>Code Example</h2>
- <div translate="no"><pre><code class="language-js">const geometry = new THREE.PlaneGeometry( 100, 100 );
- const refractor = new Refractor( refractorGeometry, {
- color: 0xcbcbcb,
- textureWidth: 1024,
- textureHeight: 1024
- } );
- scene.add( refractor );
- </code></pre></div>
- </header>
- <article>
- <h2 class="subsection-title">Import</h2>
- <p><span translate="no">Refractor</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank">Installation#Addons</a>.</p>
- <pre><code class="language-js">import { Refractor } from 'three/addons/objects/Refractor.js';</code></pre>
- <div class="container-overview">
- <h2>Constructor</h2>
- <h3 class="name name-method" id="Refractor" translate="no">new <a href="#Refractor">Refractor</a><span class="signature">( geometry : <span class="param-type">BufferGeometry</span>, options : <span class="param-type">Refractor~Options</span> )</span> </h3>
- <div class="method">
- <div class="description">
- <p>Constructs a new refractor.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>geometry</code></td>
- <td class="description last"><p>The refractor's geometry.</p></td>
- </tr>
- <tr>
- <td class="name"><code>options</code></td>
- <td class="description last"><p>The configuration options.</p></td>
- </tr>
- </tbody>
- </table>
- </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="PerspectiveCamera.html">PerspectiveCamera</a></span> </h3>
- <div class="description">
- <p>The reflector's virtual camera.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="isRefractor" translate="no">.<a href="#isRefractor">isRefractor</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
- <div class="description">
- <p>This flag can be used for type testing.<br/>Default is <code>true</code>.</p>
- </div>
- </div>
- <h2 class="subsection-title">Methods</h2>
- <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
- <div class="method">
- <div class="description">
- <p>Frees the GPU-related resources allocated by this instance. Call this
- method whenever this instance is no longer used in your app.</p>
- </div>
- </div>
- <h3 class="name name-method" id="getRenderTarget" translate="no">.<a href="#getRenderTarget">getRenderTarget</a><span class="signature">()</span><span class="type-signature"> : <a href="WebGLRenderTarget.html">WebGLRenderTarget</a></span> </h3>
- <div class="method">
- <div class="description">
- <p>Returns the reflector's internal render target.</p>
- </div>
- <dl class="details">
- <dt class="tag-returns"><strong>Returns:</strong> The internal render target</dt>
- </dl>
- </div>
- <h2 class="subsection-title">Type Definitions</h2>
- <div class="member">
- <h3 class="name" id="~Options" translate="no">.<a href="#~Options">Options</a> </h3>
- <div class="description">
- <p>Constructor options of <code>Refractor</code>.</p>
- </div>
- <h5 class="subsection-title">Properties:</h5>
- <table class="props">
- <thead>
- <tr>
- <th>Name</th>
- <th>Type</th>
- <th>Attributes</th>
- <th>Default</th>
- <th class="last">Description</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td class="name"><code>color</code></td>
- <td class="type">
- <span class="param-type">number</span>
- |
- <span class="param-type"><a href="Color.html">Color</a></span>
- |
- <span class="param-type">string</span>
- </td>
- <td class="attributes">
- <optional><br>
- </td>
- <td class="default">
- 0x7F7F7F
- </td>
- <td class="description last"><p>The refractor's color.</p></td>
- </tr>
- <tr>
- <td class="name"><code>textureWidth</code></td>
- <td class="type">
- <span class="param-type">number</span>
- </td>
- <td class="attributes">
- <optional><br>
- </td>
- <td class="default">
- 512
- </td>
- <td class="description last"><p>The texture width. A higher value results in more clear refractions but is also more expensive.</p></td>
- </tr>
- <tr>
- <td class="name"><code>textureHeight</code></td>
- <td class="type">
- <span class="param-type">number</span>
- </td>
- <td class="attributes">
- <optional><br>
- </td>
- <td class="default">
- 512
- </td>
- <td class="description last"><p>The texture height. A higher value results in more clear refractions but is also more expensive.</p></td>
- </tr>
- <tr>
- <td class="name"><code>clipBias</code></td>
- <td class="type">
- <span class="param-type">number</span>
- </td>
- <td class="attributes">
- <optional><br>
- </td>
- <td class="default">
- 0
- </td>
- <td class="description last"><p>The clip bias.</p></td>
- </tr>
- <tr>
- <td class="name"><code>shader</code></td>
- <td class="type">
- <span class="param-type">Object</span>
- </td>
- <td class="attributes">
- <optional><br>
- </td>
- <td class="default">
- </td>
- <td class="description last"><p>Can be used to pass in a custom shader that defines how the refractive view is projected onto the reflector's geometry.</p></td>
- </tr>
- <tr>
- <td class="name"><code>multisample</code></td>
- <td class="type">
- <span class="param-type">number</span>
- </td>
- <td class="attributes">
- <optional><br>
- </td>
- <td class="default">
- 4
- </td>
- <td class="description last"><p>How many samples to use for MSAA. <code>0</code> disables MSAA.</p></td>
- </tr>
- </tbody>
- </table>
- </div>
- <h2 class="subsection-title">Source</h2>
- <p>
- <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/objects/Refractor.js" target="_blank" rel="noopener" translate="no">examples/jsm/objects/Refractor.js</a>
- </p>
- </article>
- </section>
- <script src="../scripts/linenumber.js"></script>
- <script src="../scripts/page.js"></script>
- </body>
- </html>
|