Reflector.html 7.6 KB

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