API Reference

Class List

pc.Frustum

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

// 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);

Summary

Methods

containsPoint

Tests whether a point is inside the frustum.

containsSphere

Tests whether a bounding sphere intersects the frustum.

update

Updates the frustum shape based on a view matrix and a projection matrix.

Details

Constructor

Frustum(projectionMatrix, viewMatrix)

Creates a new frustum shape.

// 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);

Parameters

projectionMatrixpc.Mat4

The projection matrix describing the shape of the frustum.

viewMatrixpc.Mat4

The inverse of the world transformation matrix for the frustum.

Methods

containsPoint(point)

Tests whether a point is inside the frustum. Note that points lying in a frustum plane are considered to be outside the frustum.

Parameters

pointpc.Vec3

The point to test.

Returns

boolean

True if the point is inside the frustum, false otherwise.

containsSphere(sphere)

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

spherepc.BoundingSphere

The sphere to test.

Returns

number

0 if the bounding sphere is outside the frustum, 1 if it intersects the frustum and 2 if it is contained by the frustum.

update(projectionMatrix, viewMatrix)

Updates the frustum shape based on a view matrix and a projection matrix.

Parameters

projectionMatrixpc.Mat4

The projection matrix describing the shape of the frustum.

viewMatrixpc.Mat4

The inverse of the world transformation matrix for the frustum.