Skip to content

API Class Camera

github-actions[bot] edited this page Nov 29, 2026 · 8 revisions

Class: Camera

Defined in: src/engine/render/components.ts:159

Renders the scene from its node's position, looking along +Z (left-handed, ADR 0164).

Extends

Constructors

Constructor

new Camera(): Camera;

Returns

Camera

Inherited from

Component.constructor

Properties

backgroundColor

backgroundColor: Color | null = null;

Defined in: src/engine/render/components.ts:170

Clear color; null uses the project's display background color.


depth

depth: number = 0;

Defined in: src/engine/render/components.ts:168

Cameras render in ascending depth order.


far

far: number = 1000;

Defined in: src/engine/render/components.ts:166


fieldOfView

fieldOfView: number = 60;

Defined in: src/engine/render/components.ts:164

Vertical field of view in degrees (perspective).


near

near: number = 0.1;

Defined in: src/engine/render/components.ts:165


orthographicSize

orthographicSize: number = 5;

Defined in: src/engine/render/components.ts:162

Half the vertical view size in world units (orthographic).


pixelPerfect

pixelPerfect: boolean = false;

Defined in: src/engine/render/components.ts:183

Orthographic only. Zooms the view by a whole number so each sprite texel covers an integer number of screen (device) pixels, and snaps the camera's position to that pixel grid (ADR 0014). orthographicSize becomes the minimum half-height wanted.


pixelSnapping

pixelSnapping: boolean = true;

Defined in: src/engine/render/components.ts:185

With pixelPerfect on, sprites' world positions snap to the texel grid (1 / pixelsPerUnit units) when drawn.


projection

projection: Projection = "orthographic";

Defined in: src/engine/render/components.ts:160


targetTexture

targetTexture: string = "";

Defined in: src/engine/render/components.ts:191

A render texture asset (*.rendertexture.json, ADR 0109) to draw into instead of the canvas. Materials, sprites and UI images that name the same asset show what the camera sees (a frame later: cameras drawing into textures draw after the ones on the canvas). Empty: the canvas.


viewportPosition

viewportPosition: Vector2;

Defined in: src/engine/render/components.ts:175

The camera's rectangle on the canvas: the bottom-left corner as fractions of the canvas, like Unity's Viewport Rect (ADR 0056). The default 0,0 / 1,1 covers the whole canvas.


viewportSize

viewportSize: Vector2;

Defined in: src/engine/render/components.ts:177

The camera's rectangle on the canvas: its width and height as fractions of the canvas (ADR 0056).

Accessors

aspect

Get Signature

get aspect(): number;

Defined in: src/engine/render/components.ts:225

Width / height of the camera's viewport rectangle on the canvas (ADR 0073).

Returns

number


enabled

Get Signature

get enabled(): boolean;

Defined in: src/engine/core/Component.ts:62

Returns

boolean

Set Signature

set enabled(value): void;

Defined in: src/engine/core/Component.ts:66

Parameters
value

boolean

Returns

void

Inherited from

Component.enabled


gameObject

Get Signature

get gameObject(): GameObject;

Defined in: src/engine/core/Component.ts:42

Unity-style alias for node.

Returns

GameObject

Inherited from

Component.gameObject


isActiveAndEnabled

Get Signature

get isActiveAndEnabled(): boolean;

Defined in: src/engine/core/Component.ts:73

True when enabled, the node is active in the hierarchy, and the node is in a loaded world.

Returns

boolean

Inherited from

Component.isActiveAndEnabled


node

Get Signature

get node(): GameObject;

Defined in: src/engine/core/Component.ts:37

The node this component is on.

Returns

GameObject

Inherited from

Component.node


owner

Get Signature

get owner(): GameObject;

Defined in: src/engine/core/Component.ts:50

The node this component acts for: the node itself when attached directly, or the parent node when this component lives on a component node (ADR 0009).

Returns

GameObject

Inherited from

Component.owner


time

Get Signature

get time(): Readonly<TimeState>;

Defined in: src/engine/core/Component.ts:98

This component's World's clock (ADR 0032): the same values as Time, but safe to read outside the World's frame too (after an await, say).

Returns

Readonly<TimeState>

Inherited from

Component.time


transform

Get Signature

get transform(): Transform;

Defined in: src/engine/core/Component.ts:56

The Transform of the node this component is on, if it has one.

Returns

Transform

Inherited from

Component.transform


world

Get Signature

get world(): WorldHandle;

Defined in: src/engine/core/Component.ts:87

A handle on this component's World (ADR 0132): the same one Engine.findWorld returns. Load a scene into it, pause, connect or destroy it: this.world.loadScene("scenes/level2.scene.json"). Throws for a World no Engine owns.

Returns

WorldHandle

Inherited from

Component.world


main

Get Signature

get static main(): Camera | null;

Defined in: src/engine/render/components.ts:194

The enabled camera with the lowest depth in the current World (ADR 0032).

Returns

Camera | null

Methods

instantiate()

instantiate(prefabPath, options?): GameObject;

Defined in: src/engine/core/Component.ts:108

Instantiate a prefab in this component's World (ADR 0034), like GameObject.instantiate. Use it in code that may run after an await: by then the frame is over and the current World is the Engine's default one, which may not be this component's. A parent from another World throws.

Parameters

prefabPath

string

options?

InstantiateOptions = {}

Returns

GameObject

Inherited from

Component.instantiate


screenPointToRay()

screenPointToRay(point): Ray;

Defined in: src/engine/render/components.ts:291

The world ray through a canvas point in pixels, origin top-left, as Input.mousePosition (ADR 0073). Perspective rays start at the camera; orthographic rays are parallel to its view direction and start on the camera's plane.

Parameters

point

Vector2

Returns

Ray


viewportPointToRay()

viewportPointToRay(point): Ray;

Defined in: src/engine/render/components.ts:297

Like screenPointToRay, from viewport coordinates 0 to 1 with the origin bottom-left, as in Unity.

Parameters

point

Vector2

Returns

Ray


worldToScreenPoint()

worldToScreenPoint(p): Vector3;

Defined in: src/engine/render/components.ts:306

A world point's place on the canvas: x and y in pixels (origin top-left, like Input.mousePosition), z the distance in front of the camera along its view direction (negative means behind it, where x and y are mirrored and not meaningful) (ADR 0073).

Parameters

p

Vector3

Returns

Vector3

Clone this wiki locally