Skip to main content

Class: CSMRenderer

Constructors​

constructor​

• new CSMRenderer(config?): CSMRenderer

Parameters​

NameType
configPartial<CSMConfig>

Returns​

CSMRenderer

Accessors​

casterDepthMaterial​

• get casterDepthMaterial(): MeshDepthMaterial

The depth material every cascade draws its casters with. A load-time shader warmup compiles it against each kind of caster (plain, instanced, batched) so no depth program is built on a frame the player sees.

Returns​

MeshDepthMaterial


lightLagRadians​

• get lightLagRadians(): number

The angle between the live light and the direction the cascades were last fitted to: how far drawn shadows lag the sun.

Returns​

number


nonCasterExclusion​

• get nonCasterExclusion(): boolean

Returns​

boolean


numCascades​

• get numCascades(): number

Returns​

number


shadowBias​

• get shadowBias(): number

Returns​

number


singleCasterPass​

• get singleCasterPass(): boolean

Returns​

boolean


skipShadowObjects​

• get skipShadowObjects(): readonly Object3D<Object3DEventMap>[]

The skipShadow-flagged objects every depth consumer must hide. The local shadow atlas hides the same list, so casters can never disagree between the sun's maps and a torch's.

Returns​

readonly Object3D<Object3DEventMap>[]

Methods​

addNeverCaster​

▸ addNeverCaster(object): void

Keep object (and its subtree) out of every depth pass, always: a stand-in that only ever draws where real geometry does not, such as the far-terrain layer. Its own shader discards it under the loaded chunks, but a depth pass draws it with the shared depth material and no such test, so it would shade the real ground below it. castShadow alone does not keep it out: the cascades render the whole scene. Holds whether or not the host brackets its passes in hideNonCasters.

Parameters​

NameType
objectObject3D<Object3DEventMap>

Returns​

void


addShadowExclusion​

▸ addShadowExclusion(object): void

Keep object (and its subtree) out of every whole-scene depth pass. Unlike addSkipShadowObject this needs no material flag, so a group can be excluded — the instanced-pool root is registered here because its pools cast only through dedicated passes that render each pool as its own root.

Parameters​

NameType
objectObject3D<Object3DEventMap>

Returns​

void


addSkipShadowObject​

▸ addSkipShadowObject(object): void

Parameters​

NameType
objectObject3D<Object3DEventMap>

Returns​

void


attachShadowLedger​

▸ attachShadowLedger(ledger, nearUnits?, farUnits?): void

Share the per-frame shadow budget with the local light atlas. The near cascade is priority 1 and only records its spend; far cascades ask for a grant where the hard-coded one-far-per-frame rule used to be the only throttle. With no ledger attached (or no local lights active — the ledger grants unconditionally then), behavior is exactly today's.

Parameters​

NameTypeDefault value
ledgerCSMShadowLedgerundefined
nearUnitsnumber4
farUnitsnumber6

Returns​

void


dispose​

▸ dispose(): void

Returns​

void


getCascadeMatrix​

▸ getCascadeMatrix(index): Matrix4

Parameters​

NameType
indexnumber

Returns​

Matrix4


getCascadeSplit​

▸ getCascadeSplit(index): number

Parameters​

NameType
indexnumber

Returns​

number


getDebugState​

▸ getDebugState(): Object

Returns​

Object

NameType
cascadeDirtyboolean[]
cascadeNeedsRenderboolean[]
currentShadowStrengthnumber
isCameraStillboolean
lastFrameLightSwingnumber
lastLightSwingPerSecondnumber
lightLagRadiansnumber

getShadowMap​

▸ getShadowMap(index): Texture<unknown>

Parameters​

NameType
indexnumber

Returns​

Texture<unknown>


getUniforms​

▸ getUniforms(): Object

Returns​

Object

NameType
uCascadeSplitsnumber[]
uNumCascadesnumber
uShadowBiasnumber
uShadowMapsTexture<unknown>[]
uShadowMatricesMatrix4[]
uShadowNormalBiasnumber
uShadowSideFaceBiasScalenumber
uShadowSlopeBiasMinnumber
uShadowSlopeBiasScalenumber
uShadowTopFaceBiasScalenumber

hideNonCasters​

▸ hideNonCasters(scene): void

Hide everything no depth pass may draw, for one shadow frame: the never-casters (registered, or direct children of scene that isMarkedNeverCaster marks), the registered exclusions and every direct child of scene that isNonCasterEffect identifies. Call once before the frame's first depth pass (cascades and local lights alike) and pair with restoreNonCasters.

Parameters​

NameType
sceneScene<Object3DEventMap>

Returns​

void


markAllCascadesForRender​

▸ markAllCascadesForRender(): void

Returns​

void


markCascadesForEntityRender​

▸ markCascadesForEntityRender(): void

Returns​

void


rebuildSkipShadowCache​

▸ rebuildSkipShadowCache(scene): void

Parameters​

NameType
sceneScene<Object3DEventMap>

Returns​

void


removeNeverCaster​

▸ removeNeverCaster(object): void

Parameters​

NameType
objectObject3D<Object3DEventMap>

Returns​

void


removeShadowExclusion​

▸ removeShadowExclusion(object): void

Parameters​

NameType
objectObject3D<Object3DEventMap>

Returns​

void


removeSkipShadowObject​

▸ removeSkipShadowObject(object): void

Parameters​

NameType
objectObject3D<Object3DEventMap>

Returns​

void


render​

▸ render(renderer, scene, entities?, maxEntityShadowDistance?, instancePools?, poolBounds?): void

Parameters​

NameTypeDefault value
rendererWebGLRendererundefined
sceneScene<Object3DEventMap>undefined
entities?Object3D<Object3DEventMap>[]undefined
maxEntityShadowDistancenumberENTITY_SHADOW_DISTANCE
instancePools?Group<Object3DEventMap>[]undefined
poolBounds?readonly Box3[]undefined

Returns​

void


restoreNonCasters​

▸ restoreNonCasters(): void

Returns​

void


setLightDirection​

▸ setLightDirection(direction): void

Parameters​

NameType
directionVector3

Returns​

void


setNonCasterExclusion​

▸ setNonCasterExclusion(isEnabled): void

A/B switch for hideNonCasters (on by default). Off draws see-through scene effects and registered exclusions into every depth pass, as before the audit.

Parameters​

NameType
isEnabledboolean

Returns​

void


setSingleCasterPass​

▸ setSingleCasterPass(isEnabled): void

A/B switch for the single caster pass (on by default). Off draws near entities and pools the old way: once in the whole-scene pass with the generic depth material (instanced pools in their bind pose) and again, on entity-refresh frames, through a reparented batch.

Parameters​

NameType
isEnabledboolean

Returns​

void


update​

▸ update(mainCamera, sunDirection, playerPosition?, shadowStrength?, deltaSeconds?): void

Parameters​

NameTypeDefault valueDescription
mainCameraCameraundefined-
sunDirectionVector3undefined-
playerPosition?Vector3undefined-
shadowStrengthnumber1-
deltaSeconds?numberundefinedTime since the previous update. Measured between calls when omitted; a caller stepping a simulated clock passes its own.

Returns​

void