public final class Camera

  1. Object
  2. Camera
A perspective or orthographic camera. The camera builds a view matrix from an eye position, a look-at target and an up vector, and a projection matrix from its lens parameters. Combine the two through getViewProjection() which the device multiplies with each model matrix.

Constructors

public Camera()

Methods

public Camera setPerspective(float fovYDegrees, float near, float far)Configures a perspective projection.
public Camera setOrthographic(float height, float near, float far)Configures an orthographic projection.
public Camera setAspect(float aspect)Sets the viewport aspect ratio (width / height).
public Camera setPosition(float x, float y, float z)Sets the eye (camera) world position.
public Camera setTarget(float x, float y, float z)Sets the world space point the camera looks at.
public Camera setUp(float x, float y, float z)Sets the camera up vector.
public float getEyeX()Returns the eye (camera) world space x coordinate.
public float getEyeY()Returns the eye (camera) world space y coordinate.
public float getEyeZ()Returns the eye (camera) world space z coordinate.
public float[] getViewMatrix()Returns the 16 element column-major view matrix.
public float[] getProjectionMatrix()Returns the 16 element column-major projection matrix.
public float[] getViewProjection()Returns the 16 element column-major combined projection * view matrix.

Inherited methods

Constructor details

Camera

public Camera()

Method details

setPerspective

public Camera setPerspective(float fovYDegrees, float near, float far)
Configures a perspective projection.

Parameters

fovYDegrees float
the vertical field of view in degrees
near float
the near clip plane distance
far float
the far clip plane distance

Returns

this camera for chaining

setOrthographic

public Camera setOrthographic(float height, float near, float far)
Configures an orthographic projection.

Parameters

height float
the visible world height; width is derived from the aspect
near float
the near clip plane distance
far float
the far clip plane distance

Returns

this camera for chaining

setAspect

public Camera setAspect(float aspect)
Sets the viewport aspect ratio (width / height). The RenderView normally calls this from Renderer.onResize.

Parameters

aspect float
the width / height ratio

Returns

this camera for chaining

setPosition

public Camera setPosition(float x, float y, float z)
Sets the eye (camera) world position.

setTarget

public Camera setTarget(float x, float y, float z)
Sets the world space point the camera looks at.

setUp

public Camera setUp(float x, float y, float z)
Sets the camera up vector.

getEyeX

public float getEyeX()
Returns the eye (camera) world space x coordinate.

getEyeY

public float getEyeY()
Returns the eye (camera) world space y coordinate.

getEyeZ

public float getEyeZ()
Returns the eye (camera) world space z coordinate.

getViewMatrix

public float[] getViewMatrix()
Returns the 16 element column-major view matrix.

getProjectionMatrix

public float[] getProjectionMatrix()
Returns the 16 element column-major projection matrix.

getViewProjection

public float[] getViewProjection()
Returns the 16 element column-major combined projection * view matrix.