1
0

CSM.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>CSM - 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. <h1 translate="no">CSM</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>An implementation of Cascade Shadow Maps (CSM).</p>
  16. <p>This module can only be used with <a href="WebGLRenderer.html">WebGLRenderer</a>. When using <a href="WebGPURenderer.html">WebGPURenderer</a>,
  17. use <a href="CSMShadowNode.html">CSMShadowNode</a> instead.</p></div>
  18. </header>
  19. <article>
  20. <h2 class="subsection-title">Import</h2>
  21. <p><span translate="no">CSM</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>
  22. <pre><code class="language-js">import { CSM } from 'three/addons/csm/CSM.js';</code></pre>
  23. <div class="container-overview">
  24. <h2>Constructor</h2>
  25. <h3 class="name name-method" id="CSM" translate="no">new <a href="#CSM">CSM</a><span class="signature">( data : <span class="param-type"><a href="CSM.html#~Data">CSM~Data</a></span> )</span> </h3>
  26. <div class="method">
  27. <div class="description">
  28. <p>Constructs a new CSM instance.</p>
  29. </div>
  30. <table class="params">
  31. <tbody>
  32. <tr>
  33. <td class="name">
  34. <strong>data</strong>
  35. </td>
  36. <td class="description last">
  37. <p>The CSM data.</p>
  38. </td>
  39. </tr>
  40. </tbody>
  41. </table>
  42. </div>
  43. </div>
  44. <h2 class="subsection-title">Classes</h2>
  45. <dl>
  46. <dt><a href="CSM.html">CSM</a></dt>
  47. <dd></dd>
  48. </dl>
  49. <h2 class="subsection-title">Properties</h2>
  50. <div class="member">
  51. <h3 class="name" id="breaks" translate="no">.<a href="#breaks">breaks</a><span class="type-signature"> : Array.&lt;number></span> </h3>
  52. <div class="description">
  53. <p>An array of numbers in the range <code>[0,1]</code> the defines how the
  54. mainCSM frustum should be split up.</p>
  55. </div>
  56. </div>
  57. <div class="member">
  58. <h3 class="name" id="camera" translate="no">.<a href="#camera">camera</a><span class="type-signature"> : <a href="Camera.html">Camera</a></span> </h3>
  59. <div class="description">
  60. <p>The scene's camera.</p>
  61. </div>
  62. </div>
  63. <div class="member">
  64. <h3 class="name" id="cascades" translate="no">.<a href="#cascades">cascades</a><span class="type-signature"> : number</span> </h3>
  65. <div class="description">
  66. <p>The number of cascades.</p>
  67. <p>Default is <code>3</code>.</p>
  68. </div>
  69. </div>
  70. <div class="member">
  71. <h3 class="name" id="customSplitsCallback" translate="no">.<a href="#customSplitsCallback">customSplitsCallback</a><span class="type-signature"> : function</span> </h3>
  72. <div class="description">
  73. <p>Custom split callback when using <code>mode='custom'</code>.</p>
  74. </div>
  75. </div>
  76. <div class="member">
  77. <h3 class="name" id="fade" translate="no">.<a href="#fade">fade</a><span class="type-signature"> : boolean</span> </h3>
  78. <div class="description">
  79. <p>Whether to fade between cascades or not.</p>
  80. <p>Default is <code>false</code>.</p>
  81. </div>
  82. </div>
  83. <div class="member">
  84. <h3 class="name" id="frustums" translate="no">.<a href="#frustums">frustums</a><span class="type-signature"> : Array.&lt;<a href="CSMFrustum.html">CSMFrustum</a>></span> </h3>
  85. <div class="description">
  86. <p>An array of frustums representing the cascades.</p>
  87. </div>
  88. </div>
  89. <div class="member">
  90. <h3 class="name" id="lightDirection" translate="no">.<a href="#lightDirection">lightDirection</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
  91. <div class="description">
  92. <p>The light direction.</p>
  93. </div>
  94. </div>
  95. <div class="member">
  96. <h3 class="name" id="lightFar" translate="no">.<a href="#lightFar">lightFar</a><span class="type-signature"> : number</span> </h3>
  97. <div class="description">
  98. <p>The light far value.</p>
  99. <p>Default is <code>2000</code>.</p>
  100. </div>
  101. </div>
  102. <div class="member">
  103. <h3 class="name" id="lightIntensity" translate="no">.<a href="#lightIntensity">lightIntensity</a><span class="type-signature"> : number</span> </h3>
  104. <div class="description">
  105. <p>The light intensity.</p>
  106. <p>Default is <code>3</code>.</p>
  107. </div>
  108. </div>
  109. <div class="member">
  110. <h3 class="name" id="lightMargin" translate="no">.<a href="#lightMargin">lightMargin</a><span class="type-signature"> : number</span> </h3>
  111. <div class="description">
  112. <p>The light margin.</p>
  113. <p>Default is <code>200</code>.</p>
  114. </div>
  115. </div>
  116. <div class="member">
  117. <h3 class="name" id="lightNear" translate="no">.<a href="#lightNear">lightNear</a><span class="type-signature"> : number</span> </h3>
  118. <div class="description">
  119. <p>The light near value.</p>
  120. <p>Default is <code>1</code>.</p>
  121. </div>
  122. </div>
  123. <div class="member">
  124. <h3 class="name" id="lights" translate="no">.<a href="#lights">lights</a><span class="type-signature"> : Array.&lt;<a href="DirectionalLight.html">DirectionalLight</a>></span> </h3>
  125. <div class="description">
  126. <p>An array of directional lights which cast the shadows for
  127. the different cascades. There is one directional light for each
  128. cascade.</p>
  129. </div>
  130. </div>
  131. <div class="member">
  132. <h3 class="name" id="mainFrustum" translate="no">.<a href="#mainFrustum">mainFrustum</a><span class="type-signature"> : <a href="CSMFrustum.html">CSMFrustum</a></span> </h3>
  133. <div class="description">
  134. <p>The main frustum.</p>
  135. </div>
  136. </div>
  137. <div class="member">
  138. <h3 class="name" id="maxFar" translate="no">.<a href="#maxFar">maxFar</a><span class="type-signature"> : number</span> </h3>
  139. <div class="description">
  140. <p>The maximum far value.</p>
  141. <p>Default is <code>100000</code>.</p>
  142. </div>
  143. </div>
  144. <div class="member">
  145. <h3 class="name" id="mode" translate="no">.<a href="#mode">mode</a><span class="type-signature"> : 'practical' | 'uniform' | 'logarithmic' | 'custom'</span> </h3>
  146. <div class="description">
  147. <p>The frustum split mode.</p>
  148. <p>Default is <code>'practical'</code>.</p>
  149. </div>
  150. </div>
  151. <div class="member">
  152. <h3 class="name" id="parent" translate="no">.<a href="#parent">parent</a><span class="type-signature"> : <a href="Object3D.html">Object3D</a></span> </h3>
  153. <div class="description">
  154. <p>The parent object, usually the scene.</p>
  155. </div>
  156. </div>
  157. <div class="member">
  158. <h3 class="name" id="shaders" translate="no">.<a href="#shaders">shaders</a><span class="type-signature"> : Map.&lt;<a href="Material.html">Material</a>, Object></span> </h3>
  159. <div class="description">
  160. <p>A Map holding enhanced material shaders.</p>
  161. </div>
  162. </div>
  163. <div class="member">
  164. <h3 class="name" id="shadowBias" translate="no">.<a href="#shadowBias">shadowBias</a><span class="type-signature"> : number</span> </h3>
  165. <div class="description">
  166. <p>The shadow bias.</p>
  167. <p>Default is <code>0.000001</code>.</p>
  168. </div>
  169. </div>
  170. <div class="member">
  171. <h3 class="name" id="shadowMapSize" translate="no">.<a href="#shadowMapSize">shadowMapSize</a><span class="type-signature"> : number</span> </h3>
  172. <div class="description">
  173. <p>The shadow map size.</p>
  174. <p>Default is <code>2048</code>.</p>
  175. </div>
  176. </div>
  177. <h2 class="subsection-title">Methods</h2>
  178. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  179. <div class="method">
  180. <div class="description">
  181. <p>Frees the GPU-related resources allocated by this instance. Call this
  182. method whenever this instance is no longer used in your app.</p>
  183. </div>
  184. </div>
  185. <h3 class="name name-method" id="remove" translate="no">.<a href="#remove">remove</a><span class="signature">()</span> </h3>
  186. <div class="method">
  187. <div class="description">
  188. <p>Applications must call this method when they remove the CSM usage from their scene.</p>
  189. </div>
  190. </div>
  191. <h3 class="name name-method" id="setupMaterial" translate="no">.<a href="#setupMaterial">setupMaterial</a><span class="signature">( material : <span class="param-type"><a href="Material.html">Material</a></span> )</span> </h3>
  192. <div class="method">
  193. <div class="description">
  194. <p>Applications must call this method for all materials that should be affected by CSM.</p>
  195. </div>
  196. <table class="params">
  197. <tbody>
  198. <tr>
  199. <td class="name">
  200. <strong>material</strong>
  201. </td>
  202. <td class="description last">
  203. <p>The material to setup for CSM support.</p>
  204. </td>
  205. </tr>
  206. </tbody>
  207. </table>
  208. </div>
  209. <h3 class="name name-method" id="update" translate="no">.<a href="#update">update</a><span class="signature">()</span> </h3>
  210. <div class="method">
  211. <div class="description">
  212. <p>Updates the CSM. This method must be called in your animation loop before
  213. calling <code>renderer.render()</code>.</p>
  214. </div>
  215. </div>
  216. <h3 class="name name-method" id="updateFrustums" translate="no">.<a href="#updateFrustums">updateFrustums</a><span class="signature">()</span> </h3>
  217. <div class="method">
  218. <div class="description">
  219. <p>Applications must call this method every time they change camera or CSM settings.</p>
  220. </div>
  221. </div>
  222. <h2 class="subsection-title">Type Definitions</h2>
  223. <div class="member">
  224. <h3 class="name" id="~Data" translate="no">.<a href="#~Data">Data</a> </h3>
  225. <div class="description">
  226. <p>Constructor data of <code>CSM</code>.</p>
  227. </div>
  228. <table class="props">
  229. <tbody>
  230. <tr>
  231. <td class="name">
  232. <strong>camera</strong>
  233. <br>
  234. <span class="param-type"><a href="Camera.html">Camera</a></span>
  235. </td>
  236. <td class="description last">
  237. <p>The scene's camera.</p>
  238. </td>
  239. </tr>
  240. <tr>
  241. <td class="name">
  242. <strong>parent</strong>
  243. <br>
  244. <span class="param-type"><a href="Object3D.html">Object3D</a></span>
  245. </td>
  246. <td class="description last">
  247. <p>The parent object, usually the scene.</p>
  248. </td>
  249. </tr>
  250. <tr>
  251. <td class="name">
  252. <strong>cascades</strong>
  253. <br>
  254. <span class="param-type">number</span>
  255. </td>
  256. <td class="description last">
  257. <p>The number of cascades.</p>
  258. <p>Default is <code>3</code>.</p>
  259. </td>
  260. </tr>
  261. <tr>
  262. <td class="name">
  263. <strong>maxFar</strong>
  264. <br>
  265. <span class="param-type">number</span>
  266. </td>
  267. <td class="description last">
  268. <p>The maximum far value.</p>
  269. <p>Default is <code>100000</code>.</p>
  270. </td>
  271. </tr>
  272. <tr>
  273. <td class="name">
  274. <strong>mode</strong>
  275. <br>
  276. <span class="param-type">'practical'</span>
  277. |
  278. <span class="param-type">'uniform'</span>
  279. |
  280. <span class="param-type">'logarithmic'</span>
  281. |
  282. <span class="param-type">'custom'</span>
  283. </td>
  284. <td class="description last">
  285. <p>The frustum split mode.</p>
  286. <p>Default is <code>'practical'</code>.</p>
  287. </td>
  288. </tr>
  289. <tr>
  290. <td class="name">
  291. <strong>customSplitsCallback</strong>
  292. <br>
  293. <span class="param-type">function</span>
  294. </td>
  295. <td class="description last">
  296. <p>Custom split callback when using <code>mode='custom'</code>.</p>
  297. </td>
  298. </tr>
  299. <tr>
  300. <td class="name">
  301. <strong>shadowMapSize</strong>
  302. <br>
  303. <span class="param-type">number</span>
  304. </td>
  305. <td class="description last">
  306. <p>The shadow map size.</p>
  307. <p>Default is <code>2048</code>.</p>
  308. </td>
  309. </tr>
  310. <tr>
  311. <td class="name">
  312. <strong>shadowBias</strong>
  313. <br>
  314. <span class="param-type">number</span>
  315. </td>
  316. <td class="description last">
  317. <p>The shadow bias.</p>
  318. <p>Default is <code>0.000001</code>.</p>
  319. </td>
  320. </tr>
  321. <tr>
  322. <td class="name">
  323. <strong>lightDirection</strong>
  324. <br>
  325. <span class="param-type"><a href="Vector3.html">Vector3</a></span>
  326. </td>
  327. <td class="description last">
  328. <p>The light direction.</p>
  329. </td>
  330. </tr>
  331. <tr>
  332. <td class="name">
  333. <strong>lightIntensity</strong>
  334. <br>
  335. <span class="param-type">number</span>
  336. </td>
  337. <td class="description last">
  338. <p>The light intensity.</p>
  339. <p>Default is <code>3</code>.</p>
  340. </td>
  341. </tr>
  342. <tr>
  343. <td class="name">
  344. <strong>lightNear</strong>
  345. <br>
  346. <span class="param-type">number</span>
  347. </td>
  348. <td class="description last">
  349. <p>The light near value.</p>
  350. <p>Default is <code>1</code>.</p>
  351. </td>
  352. </tr>
  353. <tr>
  354. <td class="name">
  355. <strong>lightNear</strong>
  356. <br>
  357. <span class="param-type">number</span>
  358. </td>
  359. <td class="description last">
  360. <p>The light far value.</p>
  361. <p>Default is <code>2000</code>.</p>
  362. </td>
  363. </tr>
  364. <tr>
  365. <td class="name">
  366. <strong>lightMargin</strong>
  367. <br>
  368. <span class="param-type">number</span>
  369. </td>
  370. <td class="description last">
  371. <p>The light margin.</p>
  372. <p>Default is <code>200</code>.</p>
  373. </td>
  374. </tr>
  375. </tbody>
  376. </table>
  377. </div>
  378. <h2 class="subsection-title">Source</h2>
  379. <p>
  380. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/csm/CSM.js" translate="no" target="_blank" rel="noopener">examples/jsm/csm/CSM.js</a>
  381. </p>
  382. </article>
  383. </section>
  384. <script src="../scripts/linenumber.js"></script>
  385. <script src="../scripts/page.js"></script>
  386. </body>
  387. </html>
粤ICP备19079148号