ShadowCameraFit

Source: shadowCameraFit.ts:309

Places and sizes an orthographic depth camera over a camera footprint, so that the shadow map covers the ground the main camera sees, and everything that casts onto it, at the tightest texel the footprint allows.

The fit holds state between frames - the texel grid step and the camera displacement - so one instance belongs to one depth camera.


Constructor

new ShadowCameraFit(params): ShadowCameraFit

Instance Methods

reset()

Drops the state carried between frames, for a camera that has been teleported.

fit( depthCamera: DepthCamera, footprint: CameraFootprint, sunPos: Vec3, ): boolean

Places the depth camera over the footprint and sets its orthographic projection and depth biases.

Parameters

  • depthCamera (DepthCamera) — Orthographic depth camera to fit.
  • footprint (CameraFootprint) — Ground area to cover, taken of the main camera this frame.
  • sunPos (Vec3) — Sun position.

Returns

  • boolean

_getTerrainRelief()

Returns how much higher and how much lower the terrain goes than the four footprint corners.

_getReceiverBoundsPoints()

Returns the points the bounds are fitted to: the four footprint corners, plus the relief they hide, reached by walking each corner along its own view ray. Along the ray, because that is where the hidden terrain lies - pushing the corners sideways instead would widen the bounds for relief that is only ever an estimate.

_getCasterHeight()

Returns the caster height, rounded to a coarse step. It decides where the shadow camera stands, and a camera that jumps every time the terrain range is revised makes the whole map blink.

_quantizeOrthoTexelSize()

Returns the texel size to fit the extent onto, keeping the previous one while it is still large enough.