Class: PerspectiveCamera

PerspectiveCamera(fieldOfViewRadians, aspectRatio, near, far)

Perspective camera with a vertical field of view, viewport aspect ratio and near/far clipping planes. The projection matrix is computed on demand, cached and recomputed after the aspect ratio changes.

Constructor

new PerspectiveCamera(fieldOfViewRadians, aspectRatio, near, far)

Creates a perspective camera.
Parameters:
Name Type Description
fieldOfViewRadians number Vertical field of view in radians.
aspectRatio number Viewport aspect ratio (width / height).
near number Distance to the near clipping plane, must be greater than 0.
far number Distance to the far clipping plane, must be greater than near.
Source:
Throws:
  • - If any argument is not a finite number.
    Type
    TypeError
  • - If the field of view, aspect ratio or clipping distances are invalid.
    Type
    RangeError

Classes

PerspectiveCamera

Methods

getProjectionMatrix() → {Float32Array}

Returns the cached projection matrix, rebuilding it when needed.
Source:
Returns:
- Cached projection matrix.
Type
Float32Array

setAspectRatio(aspectRatio) → {void}

Updates the viewport aspect ratio and invalidates the projection cache, when the value changes.
Parameters:
Name Type Description
aspectRatio number New viewport aspect ratio (canvas width divided by canvas height).
Source:
Throws:
  • - If the aspect ratio is not a finite number.
    Type
    TypeError
  • - If the aspect ratio is not positive.
    Type
    RangeError
Returns:
Type
void