Skip to main content
Version: 0.11.0

UeCamera

The UeCamera is an abstract base class for all cameras in Unique Engine.
It contains common functionality shared by all camera types and should not be instantiated directly.
Instead, use one of its subclasses like UePerspectiveCamera or UeOrthographicCamera.

Inheritance​

UeObject3D
└─ UeCamera (abstract)
├─ UePerspectiveCamera
└─ UeOrthographicCamera

Constructor​

new UeCamera(data = {})
caution

UeCamera is an abstract base class and should not be instantiated directly.
Use UePerspectiveCamera or UeOrthographicCamera instead.

Data parameters​

KeyTypeDefaultDescription
viewnumber0Viewport to assign this camera to
x, y, znumber0, -100, 0Initial camera position
xt, yt, ztnumber0, 1, 0Look-at target coordinates
upX, upY, upZnumber0, 0, -1Camera up vector

Properties​

PropertyTypeDefaultDescription
isCamerabooleantrueIndicates that this is a camera
typestring"Camera"Object type
cameraCameracamera_create()The underlying GameMaker camera object
viewnumber0The viewport index this camera is assigned to
targetUeVector3(0,1,0)The current look-at target position
upX, upY, upZnumber0,0,-1Camera up vector components
matrixWorldUeMatrix4new UeMatrix4()World transformation matrix of the camera
matrixWorldInverseUeMatrix4new UeMatrix4()Inverse of matrixWorld, used in camera_set_view_mat()
projectionMatrixUeMatrix4new UeMatrix4()Projection matrix, used in camera_set_proj_mat()
projectionMatrixInverseUeMatrix4new UeMatrix4()Inverse of the projection matrix

Methods​

updateMatrixWorld()​

updateMatrixWorld()

Updates the camera's world matrix and view matrix using a lookat transformation.
This method calculates the view matrix based on the camera's position, target, and up vector.

updateProjectionMatrix()​

updateProjectionMatrix()

Updates the camera's projection matrix.
This is an abstract method that must be implemented by subclasses.

dispose()​

dispose()

Destroys the GameMaker camera instance and cleans up resources.

Returns: self (for method chaining)

use()​

use()

Activates this camera for the assigned viewport by calling view_set_camera() and making the view visible.

This is a convenience method that simplifies camera activation.

Returns: self (for method chaining)

Example:

const camera = new UePerspectiveCamera({ view: 0 });
camera.use(); // Activates the camera on view 0

Notes​

  • The camera uses matrix_build_lookat() to orient toward the target
  • The default up vector is (0, 0, -1), which rotates the camera 90° downwards
  • The view matrix is automatically set on the associated viewport

Shadow Camera Requirements

  • Shadow controllers rely on updateProjectionMatrix() and updateMatrixWorld() to compute light-space matrices used for shadow mapping. When extending or subclassing cameras, ensure these methods correctly update projectionMatrix, matrixWorld, and matrixWorldInverse.
  • For directional shadow cameras (orthographic), shadow stability benefits from texel snapping: aligning the orthographic projection to shadow map texel size reduces shimmering during camera movement. Call shadow.updateMatrices() after changing the light or scene bounds.