1
0

Refractor.html 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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" rel="noopener">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"><a href="BufferGeometry.html">BufferGeometry</a></span>, options : <span class="param-type"><a href="Refractor.html#~Options">Refractor~Options</a></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">
  45. <strong>geometry</strong>
  46. </td>
  47. <td class="description last">
  48. <p>The refractor's geometry.</p>
  49. </td>
  50. </tr>
  51. <tr>
  52. <td class="name">
  53. <strong>options</strong>
  54. </td>
  55. <td class="description last">
  56. <p>The configuration options.</p>
  57. </td>
  58. </tr>
  59. </tbody>
  60. </table>
  61. </div>
  62. </div>
  63. <h2 class="subsection-title">Properties</h2>
  64. <div class="member">
  65. <h3 class="name" id="camera" translate="no">.<a href="#camera">camera</a><span class="type-signature"> : <a href="PerspectiveCamera.html">PerspectiveCamera</a></span> </h3>
  66. <div class="description">
  67. <p>The reflector's virtual camera.</p>
  68. </div>
  69. </div>
  70. <div class="member">
  71. <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>
  72. <div class="description">
  73. <p>This flag can be used for type testing.</p>
  74. <p>Default is <code>true</code>.</p>
  75. </div>
  76. </div>
  77. <h2 class="subsection-title">Methods</h2>
  78. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  79. <div class="method">
  80. <div class="description">
  81. <p>Frees the GPU-related resources allocated by this instance. Call this
  82. method whenever this instance is no longer used in your app.</p>
  83. </div>
  84. </div>
  85. <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>
  86. <div class="method">
  87. <div class="description">
  88. <p>Returns the reflector's internal render target.</p>
  89. </div>
  90. <dl class="details">
  91. <dt class="tag-returns"><strong>Returns:</strong> The internal render target</dt>
  92. </dl>
  93. </div>
  94. <h2 class="subsection-title">Type Definitions</h2>
  95. <div class="member">
  96. <h3 class="name" id="~Options" translate="no">.<a href="#~Options">Options</a> </h3>
  97. <div class="description">
  98. <p>Constructor options of <code>Refractor</code>.</p>
  99. </div>
  100. <table class="props">
  101. <tbody>
  102. <tr>
  103. <td class="name">
  104. <strong>color</strong>
  105. <br>
  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="description last">
  113. <p>The refractor's color.</p>
  114. <p>Default is <code>0x7F7F7F</code>.</p>
  115. </td>
  116. </tr>
  117. <tr>
  118. <td class="name">
  119. <strong>textureWidth</strong>
  120. <br>
  121. <span class="param-type">number</span>
  122. </td>
  123. <td class="description last">
  124. <p>The texture width. A higher value results in more clear refractions but is also more expensive.</p>
  125. <p>Default is <code>512</code>.</p>
  126. </td>
  127. </tr>
  128. <tr>
  129. <td class="name">
  130. <strong>textureHeight</strong>
  131. <br>
  132. <span class="param-type">number</span>
  133. </td>
  134. <td class="description last">
  135. <p>The texture height. A higher value results in more clear refractions but is also more expensive.</p>
  136. <p>Default is <code>512</code>.</p>
  137. </td>
  138. </tr>
  139. <tr>
  140. <td class="name">
  141. <strong>clipBias</strong>
  142. <br>
  143. <span class="param-type">number</span>
  144. </td>
  145. <td class="description last">
  146. <p>The clip bias.</p>
  147. <p>Default is <code>0</code>.</p>
  148. </td>
  149. </tr>
  150. <tr>
  151. <td class="name">
  152. <strong>shader</strong>
  153. <br>
  154. <span class="param-type">Object</span>
  155. </td>
  156. <td class="description last">
  157. <p>Can be used to pass in a custom shader that defines how the refractive view is projected onto the reflector's geometry.</p>
  158. </td>
  159. </tr>
  160. <tr>
  161. <td class="name">
  162. <strong>multisample</strong>
  163. <br>
  164. <span class="param-type">number</span>
  165. </td>
  166. <td class="description last">
  167. <p>How many samples to use for MSAA. <code>0</code> disables MSAA.</p>
  168. <p>Default is <code>4</code>.</p>
  169. </td>
  170. </tr>
  171. </tbody>
  172. </table>
  173. </div>
  174. <h2 class="subsection-title">Source</h2>
  175. <p>
  176. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/objects/Refractor.js" translate="no" target="_blank" rel="noopener">examples/jsm/objects/Refractor.js</a>
  177. </p>
  178. </article>
  179. </section>
  180. <script src="../scripts/linenumber.js"></script>
  181. <script src="../scripts/page.js"></script>
  182. </body>
  183. </html>
粤ICP备19079148号