Camera

class Camera

A view matrix and a projection matrix, used to project world points to the screen.

Set the projection with one of the set functions, place the camera with lookAt, then call updateMatrices. Call it again after any change. project allocates nothing, because it only reads the combined matrix. Results are normalised device coordinates, minus one to one on each axis, with y up. The camera looks down its own negative z, the three.js convention, so a point in front of a camera at z = 10 has a smaller z than 10.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val up: Vector3
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun lookAt(eye: Vector3, target: Vector3, up: Vector3): Camera
Link copied to clipboard
fun project(point: Vector3, target: Vector3): Vector3

point in world space to normalised device coordinates, written into target.

fun project(x: Float, y: Float, z: Float, target: FloatArray, offset: Int = 0)

The same projection for callers that draw in floats. Writes x, y, z into target from offset. Nothing is allocated, so it can run once per vertex per frame.

Link copied to clipboard
fun setOrthographic(left: Double, right: Double, top: Double, bottom: Double, near: Double, far: Double): Camera
Link copied to clipboard
fun setPerspective(left: Double, right: Double, top: Double, bottom: Double, near: Double, far: Double): Camera
Link copied to clipboard
fun setPerspectiveFov(fovDegrees: Double, aspect: Double, near: Double, far: Double): Camera

Vertical field of view in degrees; aspect is width over height.

Link copied to clipboard

Rebuilds the view and the combined matrix from position, target, up, and the projection.