TileShadowNode.html 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>TileShadowNode - 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="Node.html">Node</a> → <a href="ShadowBaseNode.html">ShadowBaseNode</a> → </p>
  13. <h1 translate="no">TileShadowNode</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>A class that extends <code>ShadowBaseNode</code> to implement tiled shadow mapping.
  17. This allows splitting a shadow map into multiple tiles, each with its own light and camera,
  18. to improve shadow quality and performance for large scenes.</p>
  19. <p><strong>Note:</strong> This class does not support <code>VSMShadowMap</code> at the moment.</p></div>
  20. </header>
  21. <article>
  22. <h2 class="subsection-title">Import</h2>
  23. <p><span translate="no">TileShadowNode</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank">Installation#Addons</a>.</p>
  24. <pre><code class="language-js">import { TileShadowNode } from 'three/addons/tsl/shadows/TileShadowNode.js';</code></pre>
  25. <div class="container-overview">
  26. <h2>Constructor</h2>
  27. <h3 class="name name-method" id="TileShadowNode" translate="no">new <a href="#TileShadowNode">TileShadowNode</a><span class="signature">( light : <span class="param-type">Light</span>, options : <span class="param-type">Object</span> )</span> </h3>
  28. <div class="method">
  29. <div class="description">
  30. <p>Creates an instance of <code>TileShadowNode</code>.</p>
  31. </div>
  32. <table class="params">
  33. <tbody>
  34. <tr>
  35. <td class="name"><code>light</code></td>
  36. <td class="description last"><p>The original light source used for shadow mapping.</p></td>
  37. </tr>
  38. <tr>
  39. <td class="name"><code>options</code></td>
  40. <td class="description last"><p>Configuration options for the tiled shadow node.<br/>Default is <code>{}</code>.</p>
  41. <h6>Properties</h6>
  42. <table class="params">
  43. <tbody>
  44. <tr>
  45. <td class="name"><code>tilesX</code></td>
  46. <td class="description last"><p>The number of tiles along the X-axis.<br/>Default is <code>2</code>.</p></td>
  47. </tr>
  48. <tr>
  49. <td class="name"><code>tilesY</code></td>
  50. <td class="description last"><p>The number of tiles along the Y-axis.<br/>Default is <code>2</code>.</p></td>
  51. </tr>
  52. <tr>
  53. <td class="name"><code>resolution</code></td>
  54. <td class="description last"><p>The resolution of the shadow map.</p></td>
  55. </tr>
  56. <tr>
  57. <td class="name"><code>debug</code></td>
  58. <td class="description last"><p>Whether to enable debug mode.<br/>Default is <code>false</code>.</p></td>
  59. </tr>
  60. </tbody>
  61. </table>
  62. </td>
  63. </tr>
  64. </tbody>
  65. </table>
  66. </div>
  67. </div>
  68. <h2 class="subsection-title">Methods</h2>
  69. <h3 class="name name-method" id="disposeLightsAndNodes" translate="no">.<a href="#disposeLightsAndNodes">disposeLightsAndNodes</a><span class="signature">()</span> </h3>
  70. <div class="method">
  71. <div class="description">
  72. <p>Helper method to remove lights and associated nodes/targets.
  73. Used internally during dispose and potential re-initialization.</p>
  74. </div>
  75. </div>
  76. <h3 class="name name-method" id="generateTiles" translate="no">.<a href="#generateTiles">generateTiles</a><span class="signature">( tilesX : <span class="param-type">number</span>, tilesY : <span class="param-type">number</span> )</span><span class="type-signature"> : Array.&lt;Object></span> </h3>
  77. <div class="method">
  78. <div class="description">
  79. <p>Generates the tiles for the shadow map based on the specified number of tiles along the X and Y axes.</p>
  80. </div>
  81. <table class="params">
  82. <tbody>
  83. <tr>
  84. <td class="name"><code>tilesX</code></td>
  85. <td class="description last"><p>The number of tiles along the X-axis.</p></td>
  86. </tr>
  87. <tr>
  88. <td class="name"><code>tilesY</code></td>
  89. <td class="description last"><p>The number of tiles along the Y-axis.</p></td>
  90. </tr>
  91. </tbody>
  92. </table>
  93. <dl class="details">
  94. <dt class="tag-returns"><strong>Returns:</strong> An array of tile objects, each containing the tile's bounds and index.</dt>
  95. </dl>
  96. </div>
  97. <h3 class="name name-method" id="init" translate="no">.<a href="#init">init</a><span class="signature">( builder : <span class="param-type">Builder</span> )</span> </h3>
  98. <div class="method">
  99. <div class="description">
  100. <p>Initializes the tiled shadow node by creating lights, cameras, and shadow maps for each tile.</p>
  101. </div>
  102. <table class="params">
  103. <tbody>
  104. <tr>
  105. <td class="name"><code>builder</code></td>
  106. <td class="description last"><p>The builder used to create render targets and other resources.</p></td>
  107. </tr>
  108. </tbody>
  109. </table>
  110. </div>
  111. <h3 class="name name-method" id="setup" translate="no">.<a href="#setup">setup</a><span class="signature">( builder : <span class="param-type">Builder</span> )</span><span class="type-signature"> : <a href="Node.html">Node</a></span> </h3>
  112. <div class="method">
  113. <div class="description">
  114. <p>Sets up the shadow node for rendering.</p>
  115. </div>
  116. <table class="params">
  117. <tbody>
  118. <tr>
  119. <td class="name"><code>builder</code></td>
  120. <td class="description last"><p>The builder used to set up the shadow node.</p></td>
  121. </tr>
  122. </tbody>
  123. </table>
  124. <dl class="details">
  125. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="ShadowBaseNode.html#setup">ShadowBaseNode#setup</a></dt>
  126. </dl>
  127. <dl class="details">
  128. <dt class="tag-returns"><strong>Returns:</strong> A node representing the shadow value.</dt>
  129. </dl>
  130. </div>
  131. <h3 class="name name-method" id="syncLightTransformation" translate="no">.<a href="#syncLightTransformation">syncLightTransformation</a><span class="signature">( lwLight : <span class="param-type">LwLight</span>, sourceLight : <span class="param-type">Light</span> )</span> </h3>
  132. <div class="method">
  133. <div class="description">
  134. <p>Synchronizes the transformation of a tile light with the source light.</p>
  135. </div>
  136. <table class="params">
  137. <tbody>
  138. <tr>
  139. <td class="name"><code>lwLight</code></td>
  140. <td class="description last"><p>The tile light to synchronize.</p></td>
  141. </tr>
  142. <tr>
  143. <td class="name"><code>sourceLight</code></td>
  144. <td class="description last"><p>The source light to copy transformations from.</p></td>
  145. </tr>
  146. </tbody>
  147. </table>
  148. </div>
  149. <h3 class="name name-method" id="update" translate="no">.<a href="#update">update</a><span class="signature">()</span> </h3>
  150. <div class="method">
  151. <div class="description">
  152. <p>Updates the light transformations and shadow cameras for each tile.</p>
  153. </div>
  154. <dl class="details">
  155. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="ShadowBaseNode.html#update">ShadowBaseNode#update</a></dt>
  156. </dl>
  157. </div>
  158. <h3 class="name name-method" id="updateBefore" translate="no">.<a href="#updateBefore">updateBefore</a><span class="signature">( frame : <span class="param-type">NodeFrame</span> )</span> </h3>
  159. <div class="method">
  160. <div class="description">
  161. <p>The implementation performs the update of the shadow map if necessary.</p>
  162. </div>
  163. <table class="params">
  164. <tbody>
  165. <tr>
  166. <td class="name"><code>frame</code></td>
  167. <td class="description last"><p>A reference to the current node frame.</p></td>
  168. </tr>
  169. </tbody>
  170. </table>
  171. <dl class="details">
  172. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="ShadowBaseNode.html#updateBefore">ShadowBaseNode#updateBefore</a></dt>
  173. </dl>
  174. </div>
  175. <h3 class="name name-method" id="updateLightDirection" translate="no">.<a href="#updateLightDirection">updateLightDirection</a><span class="signature">()</span> </h3>
  176. <div class="method">
  177. <div class="description">
  178. <p>Updates the initial light direction based on the light's target position.</p>
  179. </div>
  180. </div>
  181. <h3 class="name name-method" id="updateShadow" translate="no">.<a href="#updateShadow">updateShadow</a><span class="signature">( frame : <span class="param-type">NodeFrame</span> )</span> </h3>
  182. <div class="method">
  183. <div class="description">
  184. <p>Updates the shadow map rendering.</p>
  185. </div>
  186. <table class="params">
  187. <tbody>
  188. <tr>
  189. <td class="name"><code>frame</code></td>
  190. <td class="description last"><p>A reference to the current node frame.</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/tsl/shadows/TileShadowNode.js" target="_blank" rel="noopener" translate="no">examples/jsm/tsl/shadows/TileShadowNode.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号