| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>Water - 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">Water</h1>
- <section>
- <header>
- <div class="class-description"><p>A basic flat, reflective water effect.</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="WaterMesh.html">WaterMesh</a>.</p>
- <p>References:</p>
- <ul>
- <li><a href="https://github.com/Slayvin">Flat mirror for three.js</a></li>
- <li><a href="https://home.adelphi.edu/~stemkoski/">An implementation of water shader based on the flat mirror</a></li>
- <li><a href="http://29a.ch/slides/2012/webglwater/">Water shader explanations in WebGL</a></li>
- </ul></div>
- </header>
- <article>
- <h2 class="subsection-title">Import</h2>
- <p><span translate="no">Water</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 { Water } from 'three/addons/objects/Water.js';</code></pre>
- <div class="container-overview">
- <h2>Constructor</h2>
- <h3 class="name name-method" id="Water" translate="no">new <a href="#Water">Water</a><span class="signature">( geometry : <span class="param-type">BufferGeometry</span>, options : <span class="param-type">Water~Options</span> )</span> </h3>
- <div class="method">
- <div class="description">
- <p>Constructs a new water instance.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name"><code>geometry</code></td>
- <td class="description last"><p>The water'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="isWater" translate="no">.<a href="#isWater">isWater</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">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>Water</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>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 reflections 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 reflections 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>alpha</code></td>
- <td class="type">
- <span class="param-type">number</span>
- </td>
- <td class="attributes">
- <optional><br>
- </td>
- <td class="default">
- 1
- </td>
- <td class="description last"><p>The alpha value.</p></td>
- </tr>
- <tr>
- <td class="name"><code>time</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 time value.</p></td>
- </tr>
- <tr>
- <td class="name"><code>waterNormals</code></td>
- <td class="type">
- <span class="param-type"><a href="Texture.html">Texture</a></span>
- </td>
- <td class="attributes">
- <optional><br>
- <nullable><br>
- </td>
- <td class="default">
- null
- </td>
- <td class="description last"><p>The water's normal map.</p></td>
- </tr>
- <tr>
- <td class="name"><code>sunDirection</code></td>
- <td class="type">
- <span class="param-type"><a href="Vector3.html">Vector3</a></span>
- </td>
- <td class="attributes">
- <optional><br>
- </td>
- <td class="default">
- (0.70707,0.70707,0.0)
- </td>
- <td class="description last"><p>The sun direction.</p></td>
- </tr>
- <tr>
- <td class="name"><code>sunColor</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">
- 0xffffff
- </td>
- <td class="description last"><p>The sun color.</p></td>
- </tr>
- <tr>
- <td class="name"><code>waterColor</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 water color.</p></td>
- </tr>
- <tr>
- <td class="name"><code>eye</code></td>
- <td class="type">
- <span class="param-type"><a href="Vector3.html">Vector3</a></span>
- </td>
- <td class="attributes">
- <optional><br>
- </td>
- <td class="default">
- </td>
- <td class="description last"><p>The eye vector.</p></td>
- </tr>
- <tr>
- <td class="name"><code>distortionScale</code></td>
- <td class="type">
- <span class="param-type">number</span>
- </td>
- <td class="attributes">
- <optional><br>
- </td>
- <td class="default">
- 20
- </td>
- <td class="description last"><p>The distortion scale.</p></td>
- </tr>
- <tr>
- <td class="name"><code>side</code></td>
- <td class="type">
- <span class="param-type"><a href="global.html#FrontSide">FrontSide</a></span>
- |
- <span class="param-type"><a href="global.html#BackSide">BackSide</a></span>
- |
- <span class="param-type"><a href="global.html#DoubleSide">DoubleSide</a></span>
- </td>
- <td class="attributes">
- <optional><br>
- </td>
- <td class="default">
- FrontSide
- </td>
- <td class="description last"><p>The water material's <code>side</code> property.</p></td>
- </tr>
- <tr>
- <td class="name"><code>fog</code></td>
- <td class="type">
- <span class="param-type">boolean</span>
- </td>
- <td class="attributes">
- <optional><br>
- </td>
- <td class="default">
- false
- </td>
- <td class="description last"><p>Whether the water should be affected by fog or not.</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/Water.js" target="_blank" rel="noopener" translate="no">examples/jsm/objects/Water.js</a>
- </p>
- </article>
- </section>
- <script src="../scripts/linenumber.js"></script>
- <script src="../scripts/page.js"></script>
- </body>
- </html>
|