Reflector.html 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Reflector - 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">Reflector</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>Can be used to create a flat, reflective surface like a mirror.</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="ReflectorNode.html">ReflectorNode</a>.</p></div>
  19. <h2>Code Example</h2>
  20. <div translate="no"><pre><code class="language-js">const geometry = new THREE.PlaneGeometry( 100, 100 );
  21. const reflector = new Reflector( geometry, {
  22. clipBias: 0.003,
  23. textureWidth: window.innerWidth * window.devicePixelRatio,
  24. textureHeight: window.innerHeight * window.devicePixelRatio,
  25. color: 0xc1cbcb
  26. } );
  27. scene.add( reflector );
  28. </code></pre></div>
  29. </header>
  30. <article>
  31. <h2 class="subsection-title">Import</h2>
  32. <p><span translate="no">Reflector</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 { Reflector } from 'three/addons/objects/Reflector.js';</code></pre>
  34. <div class="container-overview">
  35. <h2>Constructor</h2>
  36. <h3 class="name name-method" id="Reflector" translate="no">new <a href="#Reflector">Reflector</a><span class="signature">( geometry : <span class="param-type"><a href="BufferGeometry.html">BufferGeometry</a></span>, options : <span class="param-type"><a href="Reflector.html#~Options">Reflector~Options</a></span> )</span> </h3>
  37. <div class="method">
  38. <div class="description">
  39. <p>Constructs a new reflector.</p>
  40. </div>
  41. <table class="params">
  42. <tbody>
  43. <tr>
  44. <td class="name">
  45. <strong translate="no">geometry</strong>
  46. </td>
  47. <td class="description last">
  48. <p>The reflector's geometry.</p>
  49. </td>
  50. </tr>
  51. <tr>
  52. <td class="name">
  53. <strong translate="no">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="forceUpdate" translate="no">.<a href="#forceUpdate">forceUpdate</a><span class="type-signature"> : boolean</span> </h3>
  66. <div class="description">
  67. <p>Whether to force an update, no matter if the reflector
  68. is in view or not.</p>
  69. <p>Default is <code>false</code>.</p>
  70. </div>
  71. </div>
  72. <div class="member">
  73. <h3 class="name" id="isReflector" translate="no">.<a href="#isReflector">isReflector</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  74. <div class="description">
  75. <p>This flag can be used for type testing.</p>
  76. <p>Default is <code>true</code>.</p>
  77. </div>
  78. </div>
  79. <h2 class="subsection-title">Methods</h2>
  80. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  81. <div class="method">
  82. <div class="description">
  83. <p>Frees the GPU-related resources allocated by this instance. Call this
  84. method whenever this instance is no longer used in your app.</p>
  85. </div>
  86. </div>
  87. <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>
  88. <div class="method">
  89. <div class="description">
  90. <p>Returns the reflector's internal render target.</p>
  91. </div>
  92. <dl class="details">
  93. <dt class="tag-returns"><strong>Returns:</strong> The internal render target</dt>
  94. </dl>
  95. </div>
  96. <h2 class="subsection-title">Type Definitions</h2>
  97. <div class="member">
  98. <h3 class="name" id="~Options" translate="no">.<a href="#~Options">Options</a> </h3>
  99. <div class="description">
  100. <p>Constructor options of <code>Reflector</code>.</p>
  101. </div>
  102. <table class="props">
  103. <tbody>
  104. <tr>
  105. <td class="name">
  106. <strong>color</strong>
  107. <br>
  108. <span class="param-type">number</span>
  109. |
  110. <span class="param-type"><a href="Color.html">Color</a></span>
  111. |
  112. <span class="param-type">string</span>
  113. </td>
  114. <td class="description last">
  115. <p>The reflector's color.</p>
  116. <p>Default is <code>0x7F7F7F</code>.</p>
  117. </td>
  118. </tr>
  119. <tr>
  120. <td class="name">
  121. <strong>textureWidth</strong>
  122. <br>
  123. <span class="param-type">number</span>
  124. </td>
  125. <td class="description last">
  126. <p>The texture width. A higher value results in more clear reflections but is also more expensive.</p>
  127. <p>Default is <code>512</code>.</p>
  128. </td>
  129. </tr>
  130. <tr>
  131. <td class="name">
  132. <strong>textureHeight</strong>
  133. <br>
  134. <span class="param-type">number</span>
  135. </td>
  136. <td class="description last">
  137. <p>The texture height. A higher value results in more clear reflections but is also more expensive.</p>
  138. <p>Default is <code>512</code>.</p>
  139. </td>
  140. </tr>
  141. <tr>
  142. <td class="name">
  143. <strong>clipBias</strong>
  144. <br>
  145. <span class="param-type">number</span>
  146. </td>
  147. <td class="description last">
  148. <p>The clip bias.</p>
  149. <p>Default is <code>0</code>.</p>
  150. </td>
  151. </tr>
  152. <tr>
  153. <td class="name">
  154. <strong>shader</strong>
  155. <br>
  156. <span class="param-type">Object</span>
  157. </td>
  158. <td class="description last">
  159. <p>Can be used to pass in a custom shader that defines how the reflective view is projected onto the reflector's geometry.</p>
  160. </td>
  161. </tr>
  162. <tr>
  163. <td class="name">
  164. <strong>multisample</strong>
  165. <br>
  166. <span class="param-type">number</span>
  167. </td>
  168. <td class="description last">
  169. <p>How many samples to use for MSAA. <code>0</code> disables MSAA.</p>
  170. <p>Default is <code>4</code>.</p>
  171. </td>
  172. </tr>
  173. </tbody>
  174. </table>
  175. </div>
  176. <h2 class="subsection-title">Source</h2>
  177. <p>
  178. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/objects/Reflector.js" translate="no" target="_blank" rel="noopener">examples/jsm/objects/Reflector.js</a>
  179. </p>
  180. </article>
  181. </section>
  182. <script src="../scripts/linenumber.js"></script>
  183. <script src="../scripts/page.js"></script>
  184. </body>
  185. </html>
粤ICP备19079148号