API

Interface CsmRefitGate<M>

Per-frame refit/partition gate for the CSM static shadow cache.

interface CsmRefitGate<M extends CsmRefitCaster> {
    isDynamic(caster: M): boolean;
    markDynamic(caster: M): void;
    syncCasters(casters: readonly M[]): void;
    update(
        lightDirX: number,
        lightDirY: number,
        lightDirZ: number,
        nowMs: number,
        cameraChanged: boolean,
        force: boolean,
        onPromote: (caster: M) => void,
        onDemote: (caster: M) => void,
    ): CsmRefitDecision;
}

Type Parameters

Index
  • Force a known caster into the dynamic set (bookkeeping only; the caller owns task membership). The engine's static cache no longer calls it (a re-capped caster, or one requeued for a material change, keeps its class); it is kept for external users of the gate.

    Parameters

    • caster: M

    Returns void

  • Adopt a (possibly re-supplied) caster array. Identity-checked, so calling every frame is O(1) while the array is unchanged. New casters start dynamic; departed casters are forgotten; any membership change forces a refit on the next update() (a removed static caster's shadow would otherwise linger in the cache). Reordering or re-supplying the same members does not invalidate the cache.

    Parameters

    • casters: readonly M[]

    Returns void

  • One walk over the synced casters: computes the static/dynamic version sums, promotes churning static casters (via onPromote, immediately), counts quiet frames, and decides refit/overlay. Pending demotions are applied (via onDemote) only inside a refit; they ride refits caused by something else, except that in a world with no other refit cause they may trigger one themselves once overdue by the quiet threshold (see update). No allocation while nothing changes.

    Parameters

    • lightDirX: number
    • lightDirY: number
    • lightDirZ: number
    • nowMs: number
    • cameraChanged: boolean
    • force: boolean
    • onPromote: (caster: M) => void
    • onDemote: (caster: M) => void

    Returns CsmRefitDecision