class camera

A camera object used for rendering. Can also be used as a component in scenes

scn = scene()
-- Create an entity and attach a perspective camera to it
cam = scn:entity():add(camera.perspective(45, 0.1, 100))
-- Use a camera directly with drawing calls
cam = camera.perspective(45, 0.1, 100)
static ortho(size[, near, far])

A new orthographic camera

Return type:


static perspective(fov[, near, far])

A new perspective camera

Return type:


isOrtho: boolean

Determines if the camera is orthographic or perspective

orthoSize: number

The ortho graphic size (height) of this camera when in orthographic mode

clearMode: enum

The clear mode, which can be one of the following values:

  • camera.none - do not clear the background

  • camera.color - clear the color only

  • camera.depth - clear the depth only

  • camera.depthAndColor - clear both the depth and color

clearColor: color

The color to use when clearing the screen with this camera

fieldOfView: number

The field of view for this camera when in perspective mode

nearPlane: number

The distance of near view plane from the view origin

farPlane: number

The distance of far view plane from the view origin

priority: integer

The priority of the camera when used within a scene (cameras with lower values are drawn first)

projection: mat4

Sets/gets a custom projection matrix

view: mat4

Sets/gets a custom view matrix


Apply this cameras settings to the matrix stack

screenToWorld(x, y, z)

Takes a 2D point on the screen (in points) and a depth value and unprojects this point into 3D space. Useful for things like raycasting from touches


The point at screen position x, y projected z units into the screen in world space

Return type:

number, number, number

worldToScreen(x, y, z)

Takes a 3D point in world space and projects it onto screen coordinates (in points)


The point in world space (x, y, z) projected onto the screen

Return type:

number, number, number