Skip to main content
Version: 0.12.0 (latest)

UePerspectiveCamera

The UePerspectiveCamera class creates a 3D camera with a perspective projection in Unique Engine.
In perspective projection, objects appear smaller as they get farther from the camera, mimicking how human eyes perceive depth.

It inherits from UeCamera, meaning it includes all camera functionality plus scene graph features from UeObject3D.

Constructor​

new UePerspectiveCamera(data = {})

Data parameters​

KeyTypeDefaultDescription
fovnumber60Field of view in degrees
nearnumber0.1Near clipping plane
farnumber2000Far clipping plane
viewnumber0Viewport to assign this camera to
aspectnumberview_wport[view] / view_hport[view]Aspect ratio (width/height)
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
isPerspectiveCamerabooleantrueIndicates that this is a perspective camera
typestring"PerspectiveCamera"Object type
fovnumber60Field of view in degrees
aspectnumberwidth/heightAspect ratio of the viewport
nearnumber0.1Near clipping plane distance
farnumber2000Far clipping plane distance
cameraCameracamera_create()The underlying GameMaker camera object
targetUeVector3(0,1,0)The current look-at target position
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​

updateProjectionMatrix()​

updateProjectionMatrix()

Updates the camera's projection matrix using perspective projection based on fov, aspect, near, and far values.

updateMatrixWorld()​

updateMatrixWorld()

Inherited from UeCamera. Updates the view matrix based on position, target, and up vector.

dispose()​

dispose()

Inherited from UeCamera. Cleans up the camera resource.

Notes​

  • The camera projection is built using matrix_build_projection_perspective_fov()

  • The default updateMatrixWorld() function uses matrix_build_lookat() to orient the camera toward target, with up-vector (0, 0, -1), which means that the camera is rotated 90° degrees downwards

  • Objects farther from the camera appear smaller, creating realistic depth perception

  • This is the most commonly used camera type for 3D games and applications

  • Perspective cameras are used internally for point-light shadow faces: six perspective cameras with fov = 90 are created by UePointLightShadow to render omnidirectional shadow maps. Ensure updateProjectionMatrix() and updateMatrixWorld() are correctly called when the camera parameters change.

Example​

const camera = new UePerspectiveCamera({
x: 100, y: 80, z: 100,
xt: 0, yt: 0, zt: 0,
fov: 75,
near: 0.1,
far: 1000
});