Optionalopts: FrustumOptionsinitial parameters; any omitted field uses the class default
aspect ratio (width / height). Camera3d sets this automatically from its viewport on resize.
distance to the far clipping plane.
vertical field of view in radians. Mutating this field requires calling Frustum#update to rebuild the projection matrix — or use Frustum#set to change multiple parameters and update in one call.
distance to the near clipping plane (positive — measured along +Z, the camera's forward direction).
The six bounding planes of this frustum in world space, in order:
left, right, bottom, top, near, far. Each plane is oriented so
its (nx, ny, nz) normal points inward — a point with
positive signed distance to a plane is on the visible side.
Populated by Frustum#setFromViewProjection. Callers that
use Frustum#intersectsSphere or Frustum#containsPoint
must first call setFromViewProjection each frame the camera
moves; otherwise the planes describe a stale frustum.
the perspective projection matrix derived from fov, aspect,
near and far. Rebuilt by Frustum#update.
Test whether a world-space point is inside this frustum. Always run Frustum#setFromViewProjection first.
world x
world y
world z
true if the point is inside (on the positive side of every plane)
Test whether a world-space sphere overlaps this frustum. Conservative — a sphere that touches even one plane's positive side is reported visible. Always run Frustum#setFromViewProjection first so the planes describe the current camera view.
sphere center x in world coords
sphere center y in world coords
sphere center z in world coords
sphere radius in world units
true if the sphere is at least partially inside the frustum
Atomically set all four parameters and rebuild the projection matrix in one call.
vertical field of view in radians
aspect ratio (width / height)
distance to the near clipping plane
distance to the far clipping plane
this Frustum for chaining
Rebuild the six bounding Frustum#planes from the world → clip matrix. Standard Gribb–Hartmann extraction: each plane is one of the six combinations of the matrix's row 3 (the "w" row) ± rows 0, 1, 2.
Call this once per frame after the camera has moved (typically
from Camera3d.update); the planes are then valid in world
space for that frame and can be tested against world-space
bounds via Frustum#intersectsSphere /
Frustum#containsPoint.
Pass projectionMatrix × viewMatrix — column-major /
gl-matrix convention: a world-space point becomes a clip-space
point via clip = projection × view × world, so the combined
matrix is projection × view. The parameter name says
viewProjection for that reason — it's the matrix uploaded to
uProjectionMatrix in the vertex shader (after Camera3d bakes
the per-frame world translate into the view via
container.translate).
the projectionMatrix × viewMatrix matrix
Rebuild Frustum#projectionMatrix from the current
parameter values. Call this after mutating any of fov,
aspect, near, far individually.
The matrix is the standard OpenGL perspective post-multiplied by
scale(1, -1, -1) so that:
pos.z = farther from camera)
A view frustum — the truncated pyramid that defines a perspective camera's visible volume. Holds the four projection parameters (
fov,aspect,near,far) and the matching projection matrix.Used by Camera3d as its source of truth for perspective projection. The matrix follows melonJS conventions: Y-down (sprite at higher
yappears lower on screen, matching Camera2d) and +Z forward (sprite at higherpos.zis farther from the camera and renders smaller). This differs from the OpenGL default of Y-up and -Z forward, but matches the rest of the engine and lets Camera2d code translate directly to Camera3d.Plane-based frustum culling is available via Frustum#planes (rebuilt by Frustum#setFromViewProjection per frame) plus Frustum#containsPoint / Frustum#intersectsSphere for culling tests.
Camera3d.updatecallssetFromViewProjectiononce per frame so itsisVisible(obj)queries against current planes — no per-frame setup needed from user code.Example