ThreePipe
    Preparing search index...

    Class CascadedShadowsPlugin

    Cascaded Shadow Maps (CSM) plugin for high-quality directional light shadows across large scenes.

    This plugin implements cascaded shadow mapping to provide better shadow quality across different distances from the camera by splitting the view frustum into multiple cascades, each with its own shadow map at an appropriate resolution.

    Features:

    • Multiple cascade splitting modes: uniform, logarithmic, practical, and custom
    • Automatic light attachment to first directional light found
    • Configurable shadow parameters per light
    • Material extension for proper shadow sampling
    • Optional fade between cascades

    Original three-csm implementation - https://github.com/StrandedKitty/three-csm

    const viewer = new ThreeViewer({
    plugins: [new CascadedShadowsPlugin()]
    })

    const light = new DirectionalLight2(0xffffff, 1.5)
    viewer.scene.addObject(light)

    const csmPlugin = viewer.getPlugin(CascadedShadowsPlugin)!
    csmPlugin.setLightParams({
    cascades: 4,
    shadowMapSize: 1024,
    lightMargin: 100
    }, light)

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _dirty: boolean = false
    _viewer?: ThreeViewer
    _viewerListeners: { preRender: () => void } = ...
    attachToFirstLight: boolean = true

    Automatically attach to first found directional light in the scene if none is attached yet.

    breaks: number[] = []

    Cascade break points in normalized depth [0-1]

    Current camera used for frustum calculations

    constructor: typeof AViewerPluginSync & typeof AViewerPlugin
    customSplitsCallback?: (
        amount: number,
        near: number,
        far: number,
        breaks: number[],
    ) => void

    Custom callback for defining cascade splits when mode is 'custom'

    enabled: boolean = true

    Enable/disable the cascaded shadow maps plugin

    extendedBreaks: (Vector3 | Vector2)[] = []

    Extended break data for shader uniforms

    fade: boolean

    Enable fade between cascades for smoother transitions

    frustums: CSMFrustum[] = []

    Individual frustums for each cascade

    The main directional light that CSM will be applied to

    lights: DirectionalLight[] = []

    Generated directional lights for each cascade

    mainFrustum: CSMFrustum

    Main camera frustum for cascade calculation

    materialExtension: MaterialExtension = ...
    maxFar: number = 100000

    Maximum far distance for shadow calculation

    mode: "uniform" | "logarithmic" | "practical" | "custom" = 'practical'

    Cascade splitting mode: uniform, logarithmic, practical, or custom

    parent: Object3D = ...

    Parent object containing all CSM lights

    uiConfig: UiObjectConfig = ...
    OldPluginType?: string
    PluginType: "CascadedShadowsPlugin" = 'CascadedShadowsPlugin'

    Accessors

    Methods