1
0

WaterMesh.html 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>WaterMesh - 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">WaterMesh</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="WebGPURenderer.html">WebGPURenderer</a>.
  18. When using <a href="WebGLRenderer.html">WebGLRenderer</a>, use <a href="Water.html">Water</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">WaterMesh</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 { WaterMesh } from 'three/addons/objects/WaterMesh.js';</code></pre>
  30. <div class="container-overview">
  31. <h2>Constructor</h2>
  32. <h3 class="name name-method" id="WaterMesh" translate="no">new <a href="#WaterMesh">WaterMesh</a><span class="signature">( geometry : <span class="param-type">BufferGeometry</span>, options : <span class="param-type">WaterMesh~Options</span> )</span> </h3>
  33. <div class="method">
  34. <div class="description">
  35. <p>Constructs a new water mesh.</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 mesh'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="alpha" translate="no">.<a href="#alpha">alpha</a><span class="type-signature"> : <a href="UniformNode.html">UniformNode</a>.&lt;float></span> </h3>
  54. <div class="description">
  55. <p>The alpha value.<br/>Default is <code>1</code>.</p>
  56. </div>
  57. </div>
  58. <div class="member">
  59. <h3 class="name" id="distortionScale" translate="no">.<a href="#distortionScale">distortionScale</a><span class="type-signature"> : <a href="UniformNode.html">UniformNode</a>.&lt;float></span> </h3>
  60. <div class="description">
  61. <p>The distortion scale.<br/>Default is <code>20</code>.</p>
  62. </div>
  63. </div>
  64. <div class="member">
  65. <h3 class="name" id="isWaterMesh" translate="no">.<a href="#isWaterMesh">isWaterMesh</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  66. <div class="description">
  67. <p>This flag can be used for type testing.<br/>Default is <code>true</code>.</p>
  68. </div>
  69. </div>
  70. <div class="member">
  71. <h3 class="name" id="resolutionScale" translate="no">.<a href="#resolutionScale">resolutionScale</a><span class="type-signature"> : number</span> </h3>
  72. <div class="description">
  73. <p>The effect's resolution scale.<br/>Default is <code>0.5</code>.</p>
  74. </div>
  75. </div>
  76. <div class="member">
  77. <h3 class="name" id="size" translate="no">.<a href="#size">size</a><span class="type-signature"> : <a href="UniformNode.html">UniformNode</a>.&lt;float></span> </h3>
  78. <div class="description">
  79. <p>The size value.<br/>Default is <code>1</code>.</p>
  80. </div>
  81. </div>
  82. <div class="member">
  83. <h3 class="name" id="sunColor" translate="no">.<a href="#sunColor">sunColor</a><span class="type-signature"> : <a href="UniformNode.html">UniformNode</a>.&lt;color></span> </h3>
  84. <div class="description">
  85. <p>The sun color.<br/>Default is <code>0xffffff</code>.</p>
  86. </div>
  87. </div>
  88. <div class="member">
  89. <h3 class="name" id="sunDirection" translate="no">.<a href="#sunDirection">sunDirection</a><span class="type-signature"> : <a href="UniformNode.html">UniformNode</a>.&lt;vec3></span> </h3>
  90. <div class="description">
  91. <p>The sun direction.<br/>Default is <code>(0.70707,0.70707,0.0)</code>.</p>
  92. </div>
  93. </div>
  94. <div class="member">
  95. <h3 class="name" id="waterColor" translate="no">.<a href="#waterColor">waterColor</a><span class="type-signature"> : <a href="UniformNode.html">UniformNode</a>.&lt;color></span> </h3>
  96. <div class="description">
  97. <p>The water color.<br/>Default is <code>0x7f7f7f</code>.</p>
  98. </div>
  99. </div>
  100. <div class="member">
  101. <h3 class="name" id="waterNormals" translate="no">.<a href="#waterNormals">waterNormals</a><span class="type-signature"> : <a href="TextureNode.html">TextureNode</a></span> </h3>
  102. <div class="description">
  103. <p>The water's normal map.</p>
  104. </div>
  105. </div>
  106. <h2 class="subsection-title">Type Definitions</h2>
  107. <div class="member">
  108. <h3 class="name" id="~Options" translate="no">.<a href="#~Options">Options</a> </h3>
  109. <div class="description">
  110. <p>Constructor options of <code>WaterMesh</code>.</p>
  111. </div>
  112. <h5 class="subsection-title">Properties:</h5>
  113. <table class="props">
  114. <thead>
  115. <tr>
  116. <th>Name</th>
  117. <th>Type</th>
  118. <th>Attributes</th>
  119. <th>Default</th>
  120. <th class="last">Description</th>
  121. </tr>
  122. </thead>
  123. <tbody>
  124. <tr>
  125. <td class="name"><code>resolutionScale</code></td>
  126. <td class="type">
  127. <span class="param-type">number</span>
  128. </td>
  129. <td class="attributes">
  130. &lt;optional><br>
  131. </td>
  132. <td class="default">
  133. 0.5
  134. </td>
  135. <td class="description last"><p>The resolution scale.</p></td>
  136. </tr>
  137. <tr>
  138. <td class="name"><code>waterNormals</code></td>
  139. <td class="type">
  140. <span class="param-type"><a href="Texture.html">Texture</a></span>
  141. </td>
  142. <td class="attributes">
  143. &lt;optional><br>
  144. &lt;nullable><br>
  145. </td>
  146. <td class="default">
  147. null
  148. </td>
  149. <td class="description last"><p>The water's normal map.</p></td>
  150. </tr>
  151. <tr>
  152. <td class="name"><code>alpha</code></td>
  153. <td class="type">
  154. <span class="param-type">number</span>
  155. </td>
  156. <td class="attributes">
  157. &lt;optional><br>
  158. </td>
  159. <td class="default">
  160. 1
  161. </td>
  162. <td class="description last"><p>The alpha value.</p></td>
  163. </tr>
  164. <tr>
  165. <td class="name"><code>size</code></td>
  166. <td class="type">
  167. <span class="param-type">number</span>
  168. </td>
  169. <td class="attributes">
  170. &lt;optional><br>
  171. </td>
  172. <td class="default">
  173. 1
  174. </td>
  175. <td class="description last"><p>The size value.</p></td>
  176. </tr>
  177. <tr>
  178. <td class="name"><code>sunColor</code></td>
  179. <td class="type">
  180. <span class="param-type">number</span>
  181. |
  182. <span class="param-type"><a href="Color.html">Color</a></span>
  183. |
  184. <span class="param-type">string</span>
  185. </td>
  186. <td class="attributes">
  187. &lt;optional><br>
  188. </td>
  189. <td class="default">
  190. 0xffffff
  191. </td>
  192. <td class="description last"><p>The sun color.</p></td>
  193. </tr>
  194. <tr>
  195. <td class="name"><code>sunDirection</code></td>
  196. <td class="type">
  197. <span class="param-type"><a href="Vector3.html">Vector3</a></span>
  198. </td>
  199. <td class="attributes">
  200. &lt;optional><br>
  201. </td>
  202. <td class="default">
  203. (0.70707,0.70707,0.0)
  204. </td>
  205. <td class="description last"><p>The sun direction.</p></td>
  206. </tr>
  207. <tr>
  208. <td class="name"><code>waterColor</code></td>
  209. <td class="type">
  210. <span class="param-type">number</span>
  211. |
  212. <span class="param-type"><a href="Color.html">Color</a></span>
  213. |
  214. <span class="param-type">string</span>
  215. </td>
  216. <td class="attributes">
  217. &lt;optional><br>
  218. </td>
  219. <td class="default">
  220. 0x7F7F7F
  221. </td>
  222. <td class="description last"><p>The water color.</p></td>
  223. </tr>
  224. <tr>
  225. <td class="name"><code>distortionScale</code></td>
  226. <td class="type">
  227. <span class="param-type">number</span>
  228. </td>
  229. <td class="attributes">
  230. &lt;optional><br>
  231. </td>
  232. <td class="default">
  233. 20
  234. </td>
  235. <td class="description last"><p>The distortion scale.</p></td>
  236. </tr>
  237. </tbody>
  238. </table>
  239. </div>
  240. <h2 class="subsection-title">Source</h2>
  241. <p>
  242. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/objects/WaterMesh.js" target="_blank" rel="noopener" translate="no">examples/jsm/objects/WaterMesh.js</a>
  243. </p>
  244. </article>
  245. </section>
  246. <script src="../scripts/linenumber.js"></script>
  247. <script src="../scripts/page.js"></script>
  248. </body>
  249. </html>
粤ICP备19079148号