BufferGeometry
Object3D
Raycaster
Camera
CubeCamera
PerspectiveCamera
OrthographicCamera
StereoCamera
Clock
Curve
CurvePath
Path
Shape
ShapePath
ArrowHelper
AxesHelper
BoxHelper
Box3Helper
CameraHelper
DirectionalLightHelper
GridHelper
PolarGridHelper
HemisphereLightHelper
PlaneHelper
PointLightHelper
SkeletonHelper
SpotLightHelper
Light
PointLight
RectAreaLight
SpotLight
DirectionalLight
HemisphereLight
LightShadow
PointLightShadow
AnimationLoader
AudioLoader
BufferGeometryLoader
CompressedTextureLoader
CubeTextureLoader
DataTextureLoader
FileLoader
ImageBitmapLoader
ImageLoader
Loader
LoaderUtils
MaterialLoader
ObjectLoader
TextureLoader
LoadingManager
Material
Box2
Box3
Color
Cylindrical
Euler
Frustum
Interpolant
Line3
MathUtils
Matrix3
Matrix4
Plane
Quaternion
AnimationAction
AnimationClip
AnimationMixer
AnimationObjectGroup
AnimationUtils
keyframeTrack
PropertyBinding
PropertyMixer
BooleanKeyframeTrack
QuaternionKeyframeTrack
StringKeyframeTrack
Audio
AudioAnalyser
AudioContext
AudioListener
PositionalAudio

LightShadow.getFrustum()

The LightShadow.getFrustum() method calculates the frustum for a spot or directional light shadow camera. The frustum is a truncated pyramid-shaped volume that defines the portion of the scene that is visible from the light source.

Syntax

.getFrustum( camera )

Parameters

  • camera — The shadow camera for which to calculate the frustum.

Description

The getFrustum() method is called internally by LightShadow.update() to calculate the frustum for the shadow camera. The frustum will be used to determine which objects in the scene cast shadows.

The frustum is defined by six planes, each of which is represented by a THREE.Plane object. The planes are stored in an array, LightShadow.frustumPlanes. The planes are used to cull objects that are not within the view of the light source, speeding up the rendering process.

Example

const light = new THREE.SpotLight();
const shadow = new THREE.LightShadow( light );
const camera = new THREE.PerspectiveCamera();

// Set up the spot light and shadow camera parameters
light.position.set( 5, 10, 5 );
light.target.position.set( 0, 0, 0 );
light.shadow.mapSize.width = 2048;
light.shadow.mapSize.height = 2048;
light.shadow.radius = 1;

// Update the shadow frustum
shadow.getFrustum( camera );

// Use the shadow object as a material shadow map
material.map = shadow.map;
material.shadow.side = THREE.FrontSide;
material.shadow.bias = -0.001;

Notes

  • The getFrustum() method is not intended to be called directly by the user. It is called internally by LightShadow.update().
  • The LightShadow.frustumPlanes array contains six THREE.Plane objects, one for each face of the frustum. These planes can be used to determine if a point or object is inside or outside the frustum.
  • The frustum calculation is expensive, so it should be updated only when necessary. The frustum should be updated whenever the camera or light position changes, or when the light's shadow properties change.