Capítulo 402 de 859

Chapter 402: CSMShadowNode

Core Idea

An implementation of Cascade Shadow Maps (CSM).

This module can only be used with WebGPURenderer. When using WebGLRenderer, use CSM instead.

Key Concepts

  • breaks : Array.<number>: An array of numbers in the range [0,1] the defines how the mainCSM frustum should be split up.
  • camera : Camera: The scene's camera.
  • cascades : number: The number of cascades.
  • customSplitsCallback : function: Custom split callback when using mode='custom'.
  • fade : boolean: Whether to fade between cascades or not.
  • frustums : Array.<CSMFrustum>: An array of frustums representing the cascades.
  • lightMargin : number: The light margin.
  • lights : Array.<DirectionalLight>: An array of directional lights which cast the shadows for the different cascades. There is one directional light for each cascade.
  • mainFrustum : CSMFrustum: The main frustum.
  • maxFar : number: The maximum far value.

Code Examples

import { CSMShadowNode } from 'three/addons/csm/CSMShadowNode.js';
  • What it demonstrates: Typical usage of CSMShadowNode.

Reference Tables

Constructor

Signature
new CSMShadowNode( light : DirectionalLight, data : CSMShadowNode~Data )

Properties

PropertyDescription
.breaks : Array.<number>An array of numbers in the range [0,1] the defines how the mainCSM frustum should be split up.
.camera : CameraThe scene's camera.
.cascades : numberThe number of cascades.
.customSplitsCallback : functionCustom split callback when using mode='custom'.
.fade : booleanWhether to fade between cascades or not.
.frustums : Array.<CSMFrustum>An array of frustums representing the cascades.
.lightMargin : numberThe light margin.
.lights : Array.<DirectionalLight>An array of directional lights which cast the shadows for the different cascades. There is one directional light for each cascade.
.mainFrustum : CSMFrustumThe main frustum.
.maxFar : numberThe maximum far value.
`.mode : 'practical''uniform'

Methods

MethodDescription
.dispose()Frees the GPU-related resources allocated by this instance. Call this method whenever this instance is no longer used in your app.
.updateFrustums()Applications must call this method every time they change camera or CSM settings.

Key Takeaways

  1. CSMShadowNode extends: EventDispatcher → Node → ShadowBaseNode
  2. Most relevant properties: breaks, camera, cascades, customSplitsCallback.
  3. Key methods: dispose, updateFrustums.

Connects To