Class: Frustum

pc.Frustum

A frustum is a shape that defines the viewing space of a camera.

Constructor

new Frustum(projectionMatrix, viewMatrix)

Creates a new frustum shape.
Parameters:
Name Type Description
projectionMatrix pc.Mat4 The projection matrix describing the shape of the frustum.
viewMatrix pc.Mat4 The inverse of the world transformation matrix for the frustum.
Source:
Example
// Create a new frustum equivalent to one held by a camera component
var projectionMatrix = entity.camera.projectionMatrix;
var viewMatrix = entity.camera.viewMatrix;
var frustum = new pc.Frustum(projectionMatrix, viewMatrix);

Methods

containsPoint(point) → {Boolean}

Tests whether a point is inside the frustum. Note that points lying in a frustum plane are considered to be outside the frustum.
Parameters:
Name Type Description
point pc.Vec3 The point to test
Source:
Returns:
true if the point is inside the frustum, false otherwise
Type
Boolean

containsSphere(sphere) → {Number}

Tests whether a bounding sphere intersects the frustum. If the sphere is outside the frustum, zero is returned. If the sphere intersects the frustum, 1 is returned. If the sphere is completely inside the frustum, 2 is returned. Note that a sphere touching a frustum plane from the outside is considered to be outside the frustum.
Parameters:
Name Type Description
sphere pc.BoundingSphere The sphere to test
Source:
Returns:
0 if the bounding sphere is outside the frustum, 1 if it intersects the frustum and 2 if it is contained by the frustum
Type
Number

update(projectionMatrix, viewMatrix)

Updates the frustum shape based on a view matrix and a projection matrix.
Parameters:
Name Type Description
projectionMatrix pc.Mat4 The projection matrix describing the shape of the frustum.
viewMatrix pc.Mat4 The inverse of the world transformation matrix for the frustum.
Source: