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.
.getFrustum( camera )
camera
— The shadow camera for which to calculate the frustum.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.
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;
getFrustum()
method is not intended to be called directly by the user. It is called internally by LightShadow.update()
.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.