Reflector.html 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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>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>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. This is used to render
  68. the scene from the mirror's point of view.</p>
  69. </div>
  70. </div>
  71. <div class="member">
  72. <h3 class="name" id="forceUpdate" translate="no">.<a href="#forceUpdate">forceUpdate</a><span class="type-signature"> : boolean</span> </h3>
  73. <div class="description">
  74. <p>Whether to force an update, no matter if the reflector
  75. is in view or not.</p>
  76. <p>Default is <code>false</code>.</p>
  77. </div>
  78. </div>
  79. <div class="member">
  80. <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>
  81. <div class="description">
  82. <p>This flag can be used for type testing.</p>
  83. <p>Default is <code>true</code>.</p>
  84. </div>
  85. </div>
  86. <h2 class="subsection-title">Methods</h2>
  87. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  88. <div class="method">
  89. <div class="description">
  90. <p>Frees the GPU-related resources allocated by this instance. Call this
  91. method whenever this instance is no longer used in your app.</p>
  92. </div>
  93. </div>
  94. <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>
  95. <div class="method">
  96. <div class="description">
  97. <p>Returns the reflector's internal render target.</p>
  98. </div>
  99. <dl class="details">
  100. <dt class="tag-returns"><strong>Returns:</strong> The internal render target</dt>
  101. </dl>
  102. </div>
  103. <h2 class="subsection-title">Type Definitions</h2>
  104. <div class="member">
  105. <h3 class="name" id="~Options" translate="no">.<a href="#~Options">Options</a> </h3>
  106. <div class="description">
  107. <p>Constructor options of <code>Reflector</code>.</p>
  108. </div>
  109. <table class="props">
  110. <tbody>
  111. <tr>
  112. <td class="name">
  113. <strong>color</strong>
  114. <br>
  115. <span class="param-type">number</span>
  116. |
  117. <span class="param-type"><a href="Color.html">Color</a></span>
  118. |
  119. <span class="param-type">string</span>
  120. </td>
  121. <td class="description last">
  122. <p>The reflector's color.</p>
  123. <p>Default is <code>0x7F7F7F</code>.</p>
  124. </td>
  125. </tr>
  126. <tr>
  127. <td class="name">
  128. <strong>textureWidth</strong>
  129. <br>
  130. <span class="param-type">number</span>
  131. </td>
  132. <td class="description last">
  133. <p>The texture width. A higher value results in more clear reflections but is also more expensive.</p>
  134. <p>Default is <code>512</code>.</p>
  135. </td>
  136. </tr>
  137. <tr>
  138. <td class="name">
  139. <strong>textureHeight</strong>
  140. <br>
  141. <span class="param-type">number</span>
  142. </td>
  143. <td class="description last">
  144. <p>The texture height. A higher value results in more clear reflections but is also more expensive.</p>
  145. <p>Default is <code>512</code>.</p>
  146. </td>
  147. </tr>
  148. <tr>
  149. <td class="name">
  150. <strong>clipBias</strong>
  151. <br>
  152. <span class="param-type">number</span>
  153. </td>
  154. <td class="description last">
  155. <p>The clip bias.</p>
  156. <p>Default is <code>0</code>.</p>
  157. </td>
  158. </tr>
  159. <tr>
  160. <td class="name">
  161. <strong>shader</strong>
  162. <br>
  163. <span class="param-type">Object</span>
  164. </td>
  165. <td class="description last">
  166. <p>Can be used to pass in a custom shader that defines how the reflective view is projected onto the reflector's geometry.</p>
  167. </td>
  168. </tr>
  169. <tr>
  170. <td class="name">
  171. <strong>multisample</strong>
  172. <br>
  173. <span class="param-type">number</span>
  174. </td>
  175. <td class="description last">
  176. <p>How many samples to use for MSAA. <code>0</code> disables MSAA.</p>
  177. <p>Default is <code>4</code>.</p>
  178. </td>
  179. </tr>
  180. </tbody>
  181. </table>
  182. </div>
  183. <h2 class="subsection-title">Source</h2>
  184. <p>
  185. <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>
  186. </p>
  187. </article>
  188. </section>
  189. <script src="../scripts/linenumber.js"></script>
  190. <script src="../scripts/page.js"></script>
  191. </body>
  192. </html>
粤ICP备19079148号