Skip to content

Class: Camera

Camera is a component that represents a game camera. Holds camera information such as viewport info, aspect info and the background color. In-game camera position should be managed in the transform.

Hierarchy

Table of contents

Constructors

Properties

Methods

Constructors

constructor

+ new Camera(backgroundColor?: Color, viewportPosition?: Vector, viewportScale?: Vector, virtualScale?: Vector): Camera

Parameters:

Name Type
backgroundColor Color
viewportPosition Vector
viewportScale Vector
virtualScale Vector

Returns: Camera

Inherited from: Component

Properties

backgroundColor

backgroundColor: Color

Background colour for the camera when rendering.


key

key: string

Inherited from: Component.key


viewportPosition

viewportPosition: Vector

Position of the camera's viewport on the screen, with from bottom left (-1, -1) to top right (1, 1) with (0, 0) as the center.


viewportScale

viewportScale: Vector

Scale of the camera's viewport, relative to the canvas/rendering surface. A viewport scale of (1, 1) would take up the entire canvas, while a scale of (0.5, 0.5) would only take up half of the screen (width and height).


virtualScale

virtualScale: Vector

The scale of the camera in terms of world space. A virtual scale of (160, 90) would render 160 world space units wide and 90 world space units tall, centered on the camera's transform position.


KEY

Readonly Static KEY: camera= "camera"


MESSAGE_ADD

Readonly Static MESSAGE_ADD: component_add= "component_add"

Inherited from: Component.MESSAGE_ADD


MESSAGE_REMOVE

Readonly Static MESSAGE_REMOVE: component_remove= "component_remove"

Inherited from: Component.MESSAGE_REMOVE

Methods

Free

Free(): void

Returns: void

Overrides: Component


GetProjectionMatrix

GetProjectionMatrix(): Matrix4D

GetProjectionMatrix builds and returns an orthographic projection for use in rendering, based on the virtual scale defined in the camera.

Returns: Matrix4D

The projection matrix