Reflector.html 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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="getReflectionCamera" translate="no">.<a href="#getReflectionCamera">getReflectionCamera</a><span class="signature">( camera : <span class="param-type"><a href="Camera.html">Camera</a></span> )</span><span class="type-signature"> : <a href="Camera.html">Camera</a></span> </h3>
  88. <div class="method">
  89. <div class="description">
  90. <p>Returns a reflection camera for the given camera. The reflection camera is used to
  91. render the scene from the reflector's view so correct reflections can be produced.</p>
  92. </div>
  93. <table class="params">
  94. <tbody>
  95. <tr>
  96. <td class="name">
  97. <strong translate="no">camera</strong>
  98. </td>
  99. <td class="description last">
  100. <p>The scene's camera.</p>
  101. </td>
  102. </tr>
  103. </tbody>
  104. </table>
  105. <dl class="details">
  106. <dt class="tag-returns"><strong>Returns:</strong> The corresponding reflection camera.</dt>
  107. </dl>
  108. </div>
  109. <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>
  110. <div class="method">
  111. <div class="description">
  112. <p>Returns the reflector's internal render target.</p>
  113. </div>
  114. <dl class="details">
  115. <dt class="tag-returns"><strong>Returns:</strong> The internal render target</dt>
  116. </dl>
  117. </div>
  118. <h2 class="subsection-title">Type Definitions</h2>
  119. <div class="member">
  120. <h3 class="name" id="~Options" translate="no">.<a href="#~Options">Options</a> </h3>
  121. <div class="description">
  122. <p>Constructor options of <code>Reflector</code>.</p>
  123. </div>
  124. <table class="props">
  125. <tbody>
  126. <tr>
  127. <td class="name">
  128. <strong>color</strong>
  129. <br>
  130. <span class="param-type">number</span>
  131. |
  132. <span class="param-type"><a href="Color.html">Color</a></span>
  133. |
  134. <span class="param-type">string</span>
  135. </td>
  136. <td class="description last">
  137. <p>The reflector's color.</p>
  138. <p>Default is <code>0x7F7F7F</code>.</p>
  139. </td>
  140. </tr>
  141. <tr>
  142. <td class="name">
  143. <strong>textureWidth</strong>
  144. <br>
  145. <span class="param-type">number</span>
  146. </td>
  147. <td class="description last">
  148. <p>The texture width. A higher value results in more clear reflections but is also more expensive.</p>
  149. <p>Default is <code>512</code>.</p>
  150. </td>
  151. </tr>
  152. <tr>
  153. <td class="name">
  154. <strong>textureHeight</strong>
  155. <br>
  156. <span class="param-type">number</span>
  157. </td>
  158. <td class="description last">
  159. <p>The texture height. A higher value results in more clear reflections but is also more expensive.</p>
  160. <p>Default is <code>512</code>.</p>
  161. </td>
  162. </tr>
  163. <tr>
  164. <td class="name">
  165. <strong>clipBias</strong>
  166. <br>
  167. <span class="param-type">number</span>
  168. </td>
  169. <td class="description last">
  170. <p>The clip bias.</p>
  171. <p>Default is <code>0</code>.</p>
  172. </td>
  173. </tr>
  174. <tr>
  175. <td class="name">
  176. <strong>shader</strong>
  177. <br>
  178. <span class="param-type">Object</span>
  179. </td>
  180. <td class="description last">
  181. <p>Can be used to pass in a custom shader that defines how the reflective view is projected onto the reflector's geometry.</p>
  182. </td>
  183. </tr>
  184. <tr>
  185. <td class="name">
  186. <strong>multisample</strong>
  187. <br>
  188. <span class="param-type">number</span>
  189. </td>
  190. <td class="description last">
  191. <p>How many samples to use for MSAA. <code>0</code> disables MSAA.</p>
  192. <p>Default is <code>4</code>.</p>
  193. </td>
  194. </tr>
  195. </tbody>
  196. </table>
  197. </div>
  198. <h2 class="subsection-title">Source</h2>
  199. <p>
  200. <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>
  201. </p>
  202. </article>
  203. </section>
  204. <script src="../scripts/linenumber.js"></script>
  205. <script src="../scripts/page.js"></script>
  206. </body>
  207. </html>
粤ICP备19079148号