Water.html 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Water - 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="Mesh.html">Mesh</a> → </p>
  13. <h1 translate="no">Water</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>A basic flat, reflective water effect.</p>
  17. <p>Note that this class can only be used with <a href="WebGLRenderer.html">WebGLRenderer</a>.
  18. When using <a href="WebGPURenderer.html">WebGPURenderer</a>, use <a href="WaterMesh.html">WaterMesh</a>.</p>
  19. <p>References:</p>
  20. <ul>
  21. <li><a href="https://github.com/Slayvin">Flat mirror for three.js</a></li>
  22. <li><a href="https://home.adelphi.edu/~stemkoski/">An implementation of water shader based on the flat mirror</a></li>
  23. <li><a href="http://29a.ch/slides/2012/webglwater/">Water shader explanations in WebGL</a></li>
  24. </ul></div>
  25. </header>
  26. <article>
  27. <h2 class="subsection-title">Import</h2>
  28. <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>
  29. <pre><code class="language-js">import { Water } from 'three/addons/objects/Water.js';</code></pre>
  30. <div class="container-overview">
  31. <h2>Constructor</h2>
  32. <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>
  33. <div class="method">
  34. <div class="description">
  35. <p>Constructs a new water instance.</p>
  36. </div>
  37. <table class="params">
  38. <tbody>
  39. <tr>
  40. <td class="name"><code>geometry</code></td>
  41. <td class="description last"><p>The water's geometry.</p></td>
  42. </tr>
  43. <tr>
  44. <td class="name"><code>options</code></td>
  45. <td class="description last"><p>The configuration options.</p></td>
  46. </tr>
  47. </tbody>
  48. </table>
  49. </div>
  50. </div>
  51. <h2 class="subsection-title">Properties</h2>
  52. <div class="member">
  53. <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>
  54. <div class="description">
  55. <p>This flag can be used for type testing.<br/>Default is <code>true</code>.</p>
  56. </div>
  57. </div>
  58. <h2 class="subsection-title">Type Definitions</h2>
  59. <div class="member">
  60. <h3 class="name" id="~Options" translate="no">.<a href="#~Options">Options</a> </h3>
  61. <div class="description">
  62. <p>Constructor options of <code>Water</code>.</p>
  63. </div>
  64. <h5 class="subsection-title">Properties:</h5>
  65. <table class="props">
  66. <thead>
  67. <tr>
  68. <th>Name</th>
  69. <th>Type</th>
  70. <th>Attributes</th>
  71. <th>Default</th>
  72. <th class="last">Description</th>
  73. </tr>
  74. </thead>
  75. <tbody>
  76. <tr>
  77. <td class="name"><code>textureWidth</code></td>
  78. <td class="type">
  79. <span class="param-type">number</span>
  80. </td>
  81. <td class="attributes">
  82. &lt;optional><br>
  83. </td>
  84. <td class="default">
  85. 512
  86. </td>
  87. <td class="description last"><p>The texture width. A higher value results in more clear reflections but is also more expensive.</p></td>
  88. </tr>
  89. <tr>
  90. <td class="name"><code>textureHeight</code></td>
  91. <td class="type">
  92. <span class="param-type">number</span>
  93. </td>
  94. <td class="attributes">
  95. &lt;optional><br>
  96. </td>
  97. <td class="default">
  98. 512
  99. </td>
  100. <td class="description last"><p>The texture height. A higher value results in more clear reflections but is also more expensive.</p></td>
  101. </tr>
  102. <tr>
  103. <td class="name"><code>clipBias</code></td>
  104. <td class="type">
  105. <span class="param-type">number</span>
  106. </td>
  107. <td class="attributes">
  108. &lt;optional><br>
  109. </td>
  110. <td class="default">
  111. 0
  112. </td>
  113. <td class="description last"><p>The clip bias.</p></td>
  114. </tr>
  115. <tr>
  116. <td class="name"><code>alpha</code></td>
  117. <td class="type">
  118. <span class="param-type">number</span>
  119. </td>
  120. <td class="attributes">
  121. &lt;optional><br>
  122. </td>
  123. <td class="default">
  124. 1
  125. </td>
  126. <td class="description last"><p>The alpha value.</p></td>
  127. </tr>
  128. <tr>
  129. <td class="name"><code>time</code></td>
  130. <td class="type">
  131. <span class="param-type">number</span>
  132. </td>
  133. <td class="attributes">
  134. &lt;optional><br>
  135. </td>
  136. <td class="default">
  137. 0
  138. </td>
  139. <td class="description last"><p>The time value.</p></td>
  140. </tr>
  141. <tr>
  142. <td class="name"><code>waterNormals</code></td>
  143. <td class="type">
  144. <span class="param-type"><a href="Texture.html">Texture</a></span>
  145. </td>
  146. <td class="attributes">
  147. &lt;optional><br>
  148. &lt;nullable><br>
  149. </td>
  150. <td class="default">
  151. null
  152. </td>
  153. <td class="description last"><p>The water's normal map.</p></td>
  154. </tr>
  155. <tr>
  156. <td class="name"><code>sunDirection</code></td>
  157. <td class="type">
  158. <span class="param-type"><a href="Vector3.html">Vector3</a></span>
  159. </td>
  160. <td class="attributes">
  161. &lt;optional><br>
  162. </td>
  163. <td class="default">
  164. (0.70707,0.70707,0.0)
  165. </td>
  166. <td class="description last"><p>The sun direction.</p></td>
  167. </tr>
  168. <tr>
  169. <td class="name"><code>sunColor</code></td>
  170. <td class="type">
  171. <span class="param-type">number</span>
  172. |
  173. <span class="param-type"><a href="Color.html">Color</a></span>
  174. |
  175. <span class="param-type">string</span>
  176. </td>
  177. <td class="attributes">
  178. &lt;optional><br>
  179. </td>
  180. <td class="default">
  181. 0xffffff
  182. </td>
  183. <td class="description last"><p>The sun color.</p></td>
  184. </tr>
  185. <tr>
  186. <td class="name"><code>waterColor</code></td>
  187. <td class="type">
  188. <span class="param-type">number</span>
  189. |
  190. <span class="param-type"><a href="Color.html">Color</a></span>
  191. |
  192. <span class="param-type">string</span>
  193. </td>
  194. <td class="attributes">
  195. &lt;optional><br>
  196. </td>
  197. <td class="default">
  198. 0x7F7F7F
  199. </td>
  200. <td class="description last"><p>The water color.</p></td>
  201. </tr>
  202. <tr>
  203. <td class="name"><code>eye</code></td>
  204. <td class="type">
  205. <span class="param-type"><a href="Vector3.html">Vector3</a></span>
  206. </td>
  207. <td class="attributes">
  208. &lt;optional><br>
  209. </td>
  210. <td class="default">
  211. </td>
  212. <td class="description last"><p>The eye vector.</p></td>
  213. </tr>
  214. <tr>
  215. <td class="name"><code>distortionScale</code></td>
  216. <td class="type">
  217. <span class="param-type">number</span>
  218. </td>
  219. <td class="attributes">
  220. &lt;optional><br>
  221. </td>
  222. <td class="default">
  223. 20
  224. </td>
  225. <td class="description last"><p>The distortion scale.</p></td>
  226. </tr>
  227. <tr>
  228. <td class="name"><code>side</code></td>
  229. <td class="type">
  230. <span class="param-type"><a href="global.html#FrontSide">FrontSide</a></span>
  231. |
  232. <span class="param-type"><a href="global.html#BackSide">BackSide</a></span>
  233. |
  234. <span class="param-type"><a href="global.html#DoubleSide">DoubleSide</a></span>
  235. </td>
  236. <td class="attributes">
  237. &lt;optional><br>
  238. </td>
  239. <td class="default">
  240. FrontSide
  241. </td>
  242. <td class="description last"><p>The water material's <code>side</code> property.</p></td>
  243. </tr>
  244. <tr>
  245. <td class="name"><code>fog</code></td>
  246. <td class="type">
  247. <span class="param-type">boolean</span>
  248. </td>
  249. <td class="attributes">
  250. &lt;optional><br>
  251. </td>
  252. <td class="default">
  253. false
  254. </td>
  255. <td class="description last"><p>Whether the water should be affected by fog or not.</p></td>
  256. </tr>
  257. </tbody>
  258. </table>
  259. </div>
  260. <h2 class="subsection-title">Source</h2>
  261. <p>
  262. <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>
  263. </p>
  264. </article>
  265. </section>
  266. <script src="../scripts/linenumber.js"></script>
  267. <script src="../scripts/page.js"></script>
  268. </body>
  269. </html>
粤ICP备19079148号