TileShadowNode.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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" rel="noopener">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"><a href="Light.html">Light</a></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">
  36. <strong>light</strong>
  37. </td>
  38. <td class="description last">
  39. <p>The original light source used for shadow mapping.</p>
  40. </td>
  41. </tr>
  42. <tr>
  43. <td class="name">
  44. <strong>options</strong>
  45. </td>
  46. <td class="description last">
  47. <p>Configuration options for the tiled shadow node.</p>
  48. <p>Default is <code>{}</code>.</p>
  49. <table class="params">
  50. <tbody>
  51. <tr>
  52. <td class="name">
  53. <strong>tilesX</strong>
  54. </td>
  55. <td class="description last">
  56. <p>The number of tiles along the X-axis.</p>
  57. <p>Default is <code>2</code>.</p>
  58. </td>
  59. </tr>
  60. <tr>
  61. <td class="name">
  62. <strong>tilesY</strong>
  63. </td>
  64. <td class="description last">
  65. <p>The number of tiles along the Y-axis.</p>
  66. <p>Default is <code>2</code>.</p>
  67. </td>
  68. </tr>
  69. <tr>
  70. <td class="name">
  71. <strong>resolution</strong>
  72. </td>
  73. <td class="description last">
  74. <p>The resolution of the shadow map.</p>
  75. </td>
  76. </tr>
  77. <tr>
  78. <td class="name">
  79. <strong>debug</strong>
  80. </td>
  81. <td class="description last">
  82. <p>Whether to enable debug mode.</p>
  83. <p>Default is <code>false</code>.</p>
  84. </td>
  85. </tr>
  86. </tbody>
  87. </table>
  88. </td>
  89. </tr>
  90. </tbody>
  91. </table>
  92. </div>
  93. </div>
  94. <h2 class="subsection-title">Methods</h2>
  95. <h3 class="name name-method" id="disposeLightsAndNodes" translate="no">.<a href="#disposeLightsAndNodes">disposeLightsAndNodes</a><span class="signature">()</span> </h3>
  96. <div class="method">
  97. <div class="description">
  98. <p>Helper method to remove lights and associated nodes/targets.
  99. Used internally during dispose and potential re-initialization.</p>
  100. </div>
  101. </div>
  102. <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>
  103. <div class="method">
  104. <div class="description">
  105. <p>Generates the tiles for the shadow map based on the specified number of tiles along the X and Y axes.</p>
  106. </div>
  107. <table class="params">
  108. <tbody>
  109. <tr>
  110. <td class="name">
  111. <strong>tilesX</strong>
  112. </td>
  113. <td class="description last">
  114. <p>The number of tiles along the X-axis.</p>
  115. </td>
  116. </tr>
  117. <tr>
  118. <td class="name">
  119. <strong>tilesY</strong>
  120. </td>
  121. <td class="description last">
  122. <p>The number of tiles along the Y-axis.</p>
  123. </td>
  124. </tr>
  125. </tbody>
  126. </table>
  127. <dl class="details">
  128. <dt class="tag-returns"><strong>Returns:</strong> An array of tile objects, each containing the tile's bounds and index.</dt>
  129. </dl>
  130. </div>
  131. <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>
  132. <div class="method">
  133. <div class="description">
  134. <p>Initializes the tiled shadow node by creating lights, cameras, and shadow maps for each tile.</p>
  135. </div>
  136. <table class="params">
  137. <tbody>
  138. <tr>
  139. <td class="name">
  140. <strong>builder</strong>
  141. </td>
  142. <td class="description last">
  143. <p>The builder used to create render targets and other resources.</p>
  144. </td>
  145. </tr>
  146. </tbody>
  147. </table>
  148. </div>
  149. <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>
  150. <div class="method">
  151. <div class="description">
  152. <p>Sets up the shadow node for rendering.</p>
  153. </div>
  154. <table class="params">
  155. <tbody>
  156. <tr>
  157. <td class="name">
  158. <strong>builder</strong>
  159. </td>
  160. <td class="description last">
  161. <p>The builder used to set up the shadow node.</p>
  162. </td>
  163. </tr>
  164. </tbody>
  165. </table>
  166. <dl class="details">
  167. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="ShadowBaseNode.html#setup">ShadowBaseNode#setup</a></dt>
  168. </dl>
  169. <dl class="details">
  170. <dt class="tag-returns"><strong>Returns:</strong> A node representing the shadow value.</dt>
  171. </dl>
  172. </div>
  173. <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"><a href="Light.html">Light</a></span> )</span> </h3>
  174. <div class="method">
  175. <div class="description">
  176. <p>Synchronizes the transformation of a tile light with the source light.</p>
  177. </div>
  178. <table class="params">
  179. <tbody>
  180. <tr>
  181. <td class="name">
  182. <strong>lwLight</strong>
  183. </td>
  184. <td class="description last">
  185. <p>The tile light to synchronize.</p>
  186. </td>
  187. </tr>
  188. <tr>
  189. <td class="name">
  190. <strong>sourceLight</strong>
  191. </td>
  192. <td class="description last">
  193. <p>The source light to copy transformations from.</p>
  194. </td>
  195. </tr>
  196. </tbody>
  197. </table>
  198. </div>
  199. <h3 class="name name-method" id="update" translate="no">.<a href="#update">update</a><span class="signature">()</span> </h3>
  200. <div class="method">
  201. <div class="description">
  202. <p>Updates the light transformations and shadow cameras for each tile.</p>
  203. </div>
  204. <dl class="details">
  205. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="ShadowBaseNode.html#update">ShadowBaseNode#update</a></dt>
  206. </dl>
  207. </div>
  208. <h3 class="name name-method" id="updateBefore" translate="no">.<a href="#updateBefore">updateBefore</a><span class="signature">( frame : <span class="param-type"><a href="NodeFrame.html">NodeFrame</a></span> )</span> </h3>
  209. <div class="method">
  210. <div class="description">
  211. <p>The implementation performs the update of the shadow map if necessary.</p>
  212. </div>
  213. <table class="params">
  214. <tbody>
  215. <tr>
  216. <td class="name">
  217. <strong>frame</strong>
  218. </td>
  219. <td class="description last">
  220. <p>A reference to the current node frame.</p>
  221. </td>
  222. </tr>
  223. </tbody>
  224. </table>
  225. <dl class="details">
  226. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="ShadowBaseNode.html#updateBefore">ShadowBaseNode#updateBefore</a></dt>
  227. </dl>
  228. </div>
  229. <h3 class="name name-method" id="updateLightDirection" translate="no">.<a href="#updateLightDirection">updateLightDirection</a><span class="signature">()</span> </h3>
  230. <div class="method">
  231. <div class="description">
  232. <p>Updates the initial light direction based on the light's target position.</p>
  233. </div>
  234. </div>
  235. <h3 class="name name-method" id="updateShadow" translate="no">.<a href="#updateShadow">updateShadow</a><span class="signature">( frame : <span class="param-type"><a href="NodeFrame.html">NodeFrame</a></span> )</span> </h3>
  236. <div class="method">
  237. <div class="description">
  238. <p>Updates the shadow map rendering.</p>
  239. </div>
  240. <table class="params">
  241. <tbody>
  242. <tr>
  243. <td class="name">
  244. <strong>frame</strong>
  245. </td>
  246. <td class="description last">
  247. <p>A reference to the current node frame.</p>
  248. </td>
  249. </tr>
  250. </tbody>
  251. </table>
  252. </div>
  253. <h2 class="subsection-title">Source</h2>
  254. <p>
  255. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/tsl/shadows/TileShadowNode.js" translate="no" target="_blank" rel="noopener">examples/jsm/tsl/shadows/TileShadowNode.js</a>
  256. </p>
  257. </article>
  258. </section>
  259. <script src="../scripts/linenumber.js"></script>
  260. <script src="../scripts/page.js"></script>
  261. </body>
  262. </html>
粤ICP备19079148号