| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>CSM - Three.js Docs</title>
- <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
- <script src="../scripts/highlight.min.js"></script>
- <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
- <link type="text/css" rel="stylesheet" href="../styles/page.css">
- </head>
- <body>
- <h1 translate="no">CSM</h1>
- <section>
- <header>
- <div class="class-description"><p>An implementation of Cascade Shadow Maps (CSM).</p>
- <p>This module can only be used with <a href="WebGLRenderer.html">WebGLRenderer</a>. When using <a href="WebGPURenderer.html">WebGPURenderer</a>,
- use <a href="CSMShadowNode.html">CSMShadowNode</a> instead.</p></div>
- </header>
- <article>
- <h2 class="subsection-title">Import</h2>
- <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>
- <pre><code class="language-js">import { CSM } from 'three/addons/csm/CSM.js';</code></pre>
- <div class="container-overview">
- <h2>Constructor</h2>
- <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>
- <div class="method">
- <div class="description">
- <p>Constructs a new CSM instance.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>data</strong>
- </td>
- <td class="description last">
- <p>The CSM data.</p>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- <h2 class="subsection-title">Classes</h2>
- <dl>
- <dt><a href="CSM.html">CSM</a></dt>
- <dd></dd>
- </dl>
- <h2 class="subsection-title">Properties</h2>
- <div class="member">
- <h3 class="name" id="breaks" translate="no">.<a href="#breaks">breaks</a><span class="type-signature"> : Array.<number></span> </h3>
- <div class="description">
- <p>An array of numbers in the range <code>[0,1]</code> the defines how the
- mainCSM frustum should be split up.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="camera" translate="no">.<a href="#camera">camera</a><span class="type-signature"> : <a href="Camera.html">Camera</a></span> </h3>
- <div class="description">
- <p>The scene's camera.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="cascades" translate="no">.<a href="#cascades">cascades</a><span class="type-signature"> : number</span> </h3>
- <div class="description">
- <p>The number of cascades.</p>
- <p>Default is <code>3</code>.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="customSplitsCallback" translate="no">.<a href="#customSplitsCallback">customSplitsCallback</a><span class="type-signature"> : function</span> </h3>
- <div class="description">
- <p>Custom split callback when using <code>mode='custom'</code>.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="fade" translate="no">.<a href="#fade">fade</a><span class="type-signature"> : boolean</span> </h3>
- <div class="description">
- <p>Whether to fade between cascades or not.</p>
- <p>Default is <code>false</code>.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="frustums" translate="no">.<a href="#frustums">frustums</a><span class="type-signature"> : Array.<<a href="CSMFrustum.html">CSMFrustum</a>></span> </h3>
- <div class="description">
- <p>An array of frustums representing the cascades.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="lightDirection" translate="no">.<a href="#lightDirection">lightDirection</a><span class="type-signature"> : <a href="Vector3.html">Vector3</a></span> </h3>
- <div class="description">
- <p>The light direction.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="lightFar" translate="no">.<a href="#lightFar">lightFar</a><span class="type-signature"> : number</span> </h3>
- <div class="description">
- <p>The light far value.</p>
- <p>Default is <code>2000</code>.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="lightIntensity" translate="no">.<a href="#lightIntensity">lightIntensity</a><span class="type-signature"> : number</span> </h3>
- <div class="description">
- <p>The light intensity.</p>
- <p>Default is <code>3</code>.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="lightMargin" translate="no">.<a href="#lightMargin">lightMargin</a><span class="type-signature"> : number</span> </h3>
- <div class="description">
- <p>The light margin.</p>
- <p>Default is <code>200</code>.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="lightNear" translate="no">.<a href="#lightNear">lightNear</a><span class="type-signature"> : number</span> </h3>
- <div class="description">
- <p>The light near value.</p>
- <p>Default is <code>1</code>.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="lights" translate="no">.<a href="#lights">lights</a><span class="type-signature"> : Array.<<a href="DirectionalLight.html">DirectionalLight</a>></span> </h3>
- <div class="description">
- <p>An array of directional lights which cast the shadows for
- the different cascades. There is one directional light for each
- cascade.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="mainFrustum" translate="no">.<a href="#mainFrustum">mainFrustum</a><span class="type-signature"> : <a href="CSMFrustum.html">CSMFrustum</a></span> </h3>
- <div class="description">
- <p>The main frustum.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="maxFar" translate="no">.<a href="#maxFar">maxFar</a><span class="type-signature"> : number</span> </h3>
- <div class="description">
- <p>The maximum far value.</p>
- <p>Default is <code>100000</code>.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="mode" translate="no">.<a href="#mode">mode</a><span class="type-signature"> : 'practical' | 'uniform' | 'logarithmic' | 'custom'</span> </h3>
- <div class="description">
- <p>The frustum split mode.</p>
- <p>Default is <code>'practical'</code>.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="parent" translate="no">.<a href="#parent">parent</a><span class="type-signature"> : <a href="Object3D.html">Object3D</a></span> </h3>
- <div class="description">
- <p>The parent object, usually the scene.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="shaders" translate="no">.<a href="#shaders">shaders</a><span class="type-signature"> : Map.<<a href="Material.html">Material</a>, Object></span> </h3>
- <div class="description">
- <p>A Map holding enhanced material shaders.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="shadowBias" translate="no">.<a href="#shadowBias">shadowBias</a><span class="type-signature"> : number</span> </h3>
- <div class="description">
- <p>The shadow bias.</p>
- <p>Default is <code>0.000001</code>.</p>
- </div>
- </div>
- <div class="member">
- <h3 class="name" id="shadowMapSize" translate="no">.<a href="#shadowMapSize">shadowMapSize</a><span class="type-signature"> : number</span> </h3>
- <div class="description">
- <p>The shadow map size.</p>
- <p>Default is <code>2048</code>.</p>
- </div>
- </div>
- <h2 class="subsection-title">Methods</h2>
- <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
- <div class="method">
- <div class="description">
- <p>Frees the GPU-related resources allocated by this instance. Call this
- method whenever this instance is no longer used in your app.</p>
- </div>
- </div>
- <h3 class="name name-method" id="remove" translate="no">.<a href="#remove">remove</a><span class="signature">()</span> </h3>
- <div class="method">
- <div class="description">
- <p>Applications must call this method when they remove the CSM usage from their scene.</p>
- </div>
- </div>
- <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>
- <div class="method">
- <div class="description">
- <p>Applications must call this method for all materials that should be affected by CSM.</p>
- </div>
- <table class="params">
- <tbody>
- <tr>
- <td class="name">
- <strong>material</strong>
- </td>
- <td class="description last">
- <p>The material to setup for CSM support.</p>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <h3 class="name name-method" id="update" translate="no">.<a href="#update">update</a><span class="signature">()</span> </h3>
- <div class="method">
- <div class="description">
- <p>Updates the CSM. This method must be called in your animation loop before
- calling <code>renderer.render()</code>.</p>
- </div>
- </div>
- <h3 class="name name-method" id="updateFrustums" translate="no">.<a href="#updateFrustums">updateFrustums</a><span class="signature">()</span> </h3>
- <div class="method">
- <div class="description">
- <p>Applications must call this method every time they change camera or CSM settings.</p>
- </div>
- </div>
- <h2 class="subsection-title">Type Definitions</h2>
- <div class="member">
- <h3 class="name" id="~Data" translate="no">.<a href="#~Data">Data</a> </h3>
- <div class="description">
- <p>Constructor data of <code>CSM</code>.</p>
- </div>
- <table class="props">
- <tbody>
- <tr>
- <td class="name">
- <strong>camera</strong>
- <br>
- <span class="param-type"><a href="Camera.html">Camera</a></span>
- </td>
- <td class="description last">
- <p>The scene's camera.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>parent</strong>
- <br>
- <span class="param-type"><a href="Object3D.html">Object3D</a></span>
- </td>
- <td class="description last">
- <p>The parent object, usually the scene.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>cascades</strong>
- <br>
- <span class="param-type">number</span>
- </td>
- <td class="description last">
- <p>The number of cascades.</p>
- <p>Default is <code>3</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>maxFar</strong>
- <br>
- <span class="param-type">number</span>
- </td>
- <td class="description last">
- <p>The maximum far value.</p>
- <p>Default is <code>100000</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>mode</strong>
- <br>
- <span class="param-type">'practical'</span>
- |
- <span class="param-type">'uniform'</span>
- |
- <span class="param-type">'logarithmic'</span>
- |
- <span class="param-type">'custom'</span>
- </td>
- <td class="description last">
- <p>The frustum split mode.</p>
- <p>Default is <code>'practical'</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>customSplitsCallback</strong>
- <br>
- <span class="param-type">function</span>
- </td>
- <td class="description last">
- <p>Custom split callback when using <code>mode='custom'</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>shadowMapSize</strong>
- <br>
- <span class="param-type">number</span>
- </td>
- <td class="description last">
- <p>The shadow map size.</p>
- <p>Default is <code>2048</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>shadowBias</strong>
- <br>
- <span class="param-type">number</span>
- </td>
- <td class="description last">
- <p>The shadow bias.</p>
- <p>Default is <code>0.000001</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>lightDirection</strong>
- <br>
- <span class="param-type"><a href="Vector3.html">Vector3</a></span>
- </td>
- <td class="description last">
- <p>The light direction.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>lightIntensity</strong>
- <br>
- <span class="param-type">number</span>
- </td>
- <td class="description last">
- <p>The light intensity.</p>
- <p>Default is <code>3</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>lightNear</strong>
- <br>
- <span class="param-type">number</span>
- </td>
- <td class="description last">
- <p>The light near value.</p>
- <p>Default is <code>1</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>lightNear</strong>
- <br>
- <span class="param-type">number</span>
- </td>
- <td class="description last">
- <p>The light far value.</p>
- <p>Default is <code>2000</code>.</p>
- </td>
- </tr>
- <tr>
- <td class="name">
- <strong>lightMargin</strong>
- <br>
- <span class="param-type">number</span>
- </td>
- <td class="description last">
- <p>The light margin.</p>
- <p>Default is <code>200</code>.</p>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <h2 class="subsection-title">Source</h2>
- <p>
- <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>
- </p>
- </article>
- </section>
- <script src="../scripts/linenumber.js"></script>
- <script src="../scripts/page.js"></script>
- </body>
- </html>
|