Function perspective

  • Computes a 4-by-4 perspective transformation matrix given the angular height of the frustum, the aspect ratio, and the near and far clipping planes. The arguments define a frustum extending in the negative z direction. The given angle is the vertical angle of the frustum, and the horizontal angle is determined to produce the given aspect ratio. The arguments near and far are the distances to the near and far clipping planes. Note that near and far are not z coordinates, but rather they are distances along the negative z-axis. The matrix generated sends the viewing frustum to the unit box. We assume a unit box extending from -1 to 1 in the x and y dimensions and from 0 to 1 in the z dimension.

    Note: If you pass Infinity for zFar then it will produce a projection matrix returns -Infinity for Z when transforming coordinates with Z <= 0 and +Infinity for Z otherwise.

    Type Parameters


    • fieldOfViewYInRadians: number

      The camera angle from top to bottom (in radians).

    • aspect: number

      The aspect ratio width / height.

    • zNear: number

      The depth (negative z coordinate) of the near clipping plane.

    • zFar: number

      The depth (negative z coordinate) of the far clipping plane.

    • Optional dst: T

      matrix to hold result. If not passed a new one is created.

    Returns T

    The perspective matrix.