Refractor.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Refractor - 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">Refractor</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>Can be used to create a flat, refractive surface like for special
  17. windows or water effects.</p>
  18. <p>Note that this class can only be used with <a href="WebGLRenderer.html">WebGLRenderer</a>.
  19. When using <a href="WebGPURenderer.html">WebGPURenderer</a>, use <a href="TSL.html#viewportSharedTexture">viewportSharedTexture</a>.</p></div>
  20. <h2>Code Example</h2>
  21. <div translate="no"><pre><code class="language-js">const geometry = new THREE.PlaneGeometry( 100, 100 );
  22. const refractor = new Refractor( refractorGeometry, {
  23. color: 0xcbcbcb,
  24. textureWidth: 1024,
  25. textureHeight: 1024
  26. } );
  27. scene.add( refractor );
  28. </code></pre></div>
  29. </header>
  30. <article>
  31. <h2 class="subsection-title">Import</h2>
  32. <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>
  33. <pre><code class="language-js">import { Refractor } from 'three/addons/objects/Refractor.js';</code></pre>
  34. <div class="container-overview">
  35. <h2>Constructor</h2>
  36. <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>
  37. <div class="method">
  38. <div class="description">
  39. <p>Constructs a new refractor.</p>
  40. </div>
  41. <table class="params">
  42. <tbody>
  43. <tr>
  44. <td class="name"><code>geometry</code></td>
  45. <td class="description last"><p>The refractor's geometry.</p></td>
  46. </tr>
  47. <tr>
  48. <td class="name"><code>options</code></td>
  49. <td class="description last"><p>The configuration options.</p></td>
  50. </tr>
  51. </tbody>
  52. </table>
  53. </div>
  54. </div>
  55. <h2 class="subsection-title">Properties</h2>
  56. <div class="member">
  57. <h3 class="name" id="camera" translate="no">.<a href="#camera">camera</a><span class="type-signature"> : <a href="PerspectiveCamera.html">PerspectiveCamera</a></span> </h3>
  58. <div class="description">
  59. <p>The reflector's virtual camera.</p>
  60. </div>
  61. </div>
  62. <div class="member">
  63. <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>
  64. <div class="description">
  65. <p>This flag can be used for type testing.<br/>Default is <code>true</code>.</p>
  66. </div>
  67. </div>
  68. <h2 class="subsection-title">Methods</h2>
  69. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  70. <div class="method">
  71. <div class="description">
  72. <p>Frees the GPU-related resources allocated by this instance. Call this
  73. method whenever this instance is no longer used in your app.</p>
  74. </div>
  75. </div>
  76. <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>
  77. <div class="method">
  78. <div class="description">
  79. <p>Returns the reflector's internal render target.</p>
  80. </div>
  81. <dl class="details">
  82. <dt class="tag-returns"><strong>Returns:</strong> The internal render target</dt>
  83. </dl>
  84. </div>
  85. <h2 class="subsection-title">Type Definitions</h2>
  86. <div class="member">
  87. <h3 class="name" id="~Options" translate="no">.<a href="#~Options">Options</a> </h3>
  88. <div class="description">
  89. <p>Constructor options of <code>Refractor</code>.</p>
  90. </div>
  91. <h5 class="subsection-title">Properties:</h5>
  92. <table class="props">
  93. <thead>
  94. <tr>
  95. <th>Name</th>
  96. <th>Type</th>
  97. <th>Attributes</th>
  98. <th>Default</th>
  99. <th class="last">Description</th>
  100. </tr>
  101. </thead>
  102. <tbody>
  103. <tr>
  104. <td class="name"><code>color</code></td>
  105. <td class="type">
  106. <span class="param-type">number</span>
  107. |
  108. <span class="param-type"><a href="Color.html">Color</a></span>
  109. |
  110. <span class="param-type">string</span>
  111. </td>
  112. <td class="attributes">
  113. &lt;optional><br>
  114. </td>
  115. <td class="default">
  116. 0x7F7F7F
  117. </td>
  118. <td class="description last"><p>The refractor's color.</p></td>
  119. </tr>
  120. <tr>
  121. <td class="name"><code>textureWidth</code></td>
  122. <td class="type">
  123. <span class="param-type">number</span>
  124. </td>
  125. <td class="attributes">
  126. &lt;optional><br>
  127. </td>
  128. <td class="default">
  129. 512
  130. </td>
  131. <td class="description last"><p>The texture width. A higher value results in more clear refractions but is also more expensive.</p></td>
  132. </tr>
  133. <tr>
  134. <td class="name"><code>textureHeight</code></td>
  135. <td class="type">
  136. <span class="param-type">number</span>
  137. </td>
  138. <td class="attributes">
  139. &lt;optional><br>
  140. </td>
  141. <td class="default">
  142. 512
  143. </td>
  144. <td class="description last"><p>The texture height. A higher value results in more clear refractions but is also more expensive.</p></td>
  145. </tr>
  146. <tr>
  147. <td class="name"><code>clipBias</code></td>
  148. <td class="type">
  149. <span class="param-type">number</span>
  150. </td>
  151. <td class="attributes">
  152. &lt;optional><br>
  153. </td>
  154. <td class="default">
  155. 0
  156. </td>
  157. <td class="description last"><p>The clip bias.</p></td>
  158. </tr>
  159. <tr>
  160. <td class="name"><code>shader</code></td>
  161. <td class="type">
  162. <span class="param-type">Object</span>
  163. </td>
  164. <td class="attributes">
  165. &lt;optional><br>
  166. </td>
  167. <td class="default">
  168. </td>
  169. <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>
  170. </tr>
  171. <tr>
  172. <td class="name"><code>multisample</code></td>
  173. <td class="type">
  174. <span class="param-type">number</span>
  175. </td>
  176. <td class="attributes">
  177. &lt;optional><br>
  178. </td>
  179. <td class="default">
  180. 4
  181. </td>
  182. <td class="description last"><p>How many samples to use for MSAA. <code>0</code> disables MSAA.</p></td>
  183. </tr>
  184. </tbody>
  185. </table>
  186. </div>
  187. <h2 class="subsection-title">Source</h2>
  188. <p>
  189. <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>
  190. </p>
  191. </article>
  192. </section>
  193. <script src="../scripts/linenumber.js"></script>
  194. <script src="../scripts/page.js"></script>
  195. </body>
  196. </html>
粤ICP备19079148号