Skip to content

API Class Transform

github-actions[bot] edited this page Nov 28, 2026 · 3 revisions

Class: Transform

Defined in: src/engine/scene/Transform.ts:23

A node's position, rotation and scale (ADR 0008, 0010, 0163).

position, rotation (a quaternion) and scale are local (relative to the parent), as the fields of Unity ECS's LocalTransform, and are live views (ADR 0019): transform.position.x += 1 moves the node. Use .clone() to keep a snapshot. Turn with rotate, rotateX/Y/Z rather than by editing Euler angles. World space: localToWorld (as Unity ECS's LocalToWorld), worldPosition, worldRotation, worldRotation2D and worldScale.

Transform data lives in the World's typed arrays; this class is a facade over it.

Accessors

eulerAngles

Get Signature

get eulerAngles(): Vector3;

Defined in: src/engine/scene/Transform.ts:72

Local rotation as Euler angles in radians, as Unity's localEulerAngles (but radians, ADR 0164): order ZXY (roll, then pitch, then yaw), each read back in [0, 2π). Returns a copy. Reading, changing and writing back works for yaw (y) all the way round but not for pitch (x) past ±π/2, which reads back flipped; turn with rotate, rotateX/Y/Z instead.

Returns

Vector3

Set Signature

set eulerAngles(v): void;

Defined in: src/engine/scene/Transform.ts:73

Parameters
v

Vec3Input

Returns

void


localToWorld

Get Signature

get localToWorld(): LocalToWorld;

Defined in: src/engine/scene/Transform.ts:174

A snapshot of the node's local-to-world matrix (as Unity ECS's LocalToWorld): value, position, rotation, right, up, forward, and transformPoint / inverseTransformPoint to convert points between this node's space and world space.

Returns

LocalToWorld


node

Get Signature

get node(): GameObject;

Defined in: src/engine/scene/Transform.ts:46

Returns

GameObject


position

Get Signature

get position(): Vector3;

Defined in: src/engine/scene/Transform.ts:51

Local position (live view).

Returns

Vector3

Set Signature

set position(v): void;

Defined in: src/engine/scene/Transform.ts:52

Parameters
v

Vec3Input

Returns

void


position2D

Get Signature

get position2D(): Vector2;

Defined in: src/engine/scene/Transform.ts:55

Local x/y position (live view over the same storage as position).

Returns

Vector2

Set Signature

set position2D(v): void;

Defined in: src/engine/scene/Transform.ts:56

Parameters
v

Vector2 | readonly [number, number]

Returns

void


rotation

Get Signature

get rotation(): Quaternion;

Defined in: src/engine/scene/Transform.ts:59

Local rotation (live view).

Returns

Quaternion

Set Signature

set rotation(q): void;

Defined in: src/engine/scene/Transform.ts:60

Parameters
q

Quaternion

Returns

void


rotation2D

Get Signature

get rotation2D(): number;

Defined in: src/engine/scene/Transform.ts:95

Local rotation around Z in radians (-π..π); positive is counter-clockwise on screen.

Returns

number

Set Signature

set rotation2D(angle): void;

Defined in: src/engine/scene/Transform.ts:96

Parameters
angle

number

Returns

void


scale

Get Signature

get scale(): Vector3;

Defined in: src/engine/scene/Transform.ts:63

Local scale (live view).

Returns

Vector3

Set Signature

set scale(v): void;

Defined in: src/engine/scene/Transform.ts:64

Parameters
v

Vec3Input

Returns

void


worldPosition

Get Signature

get worldPosition(): Vector3;

Defined in: src/engine/scene/Transform.ts:99

World-space position. Returns a copy; assigning moves the node.

Returns

Vector3

Set Signature

set worldPosition(v): void;

Defined in: src/engine/scene/Transform.ts:103

Parameters
v

Vec3Input

Returns

void


worldRotation

Get Signature

get worldRotation(): Quaternion;

Defined in: src/engine/scene/Transform.ts:136

World-space rotation. Returns a copy; assigning turns the node.

Returns

Quaternion

Set Signature

set worldRotation(q): void;

Defined in: src/engine/scene/Transform.ts:140

Parameters
q

Quaternion

Returns

void


worldRotation2D

Get Signature

get worldRotation2D(): number;

Defined in: src/engine/scene/Transform.ts:119

World-space rotation around Z in radians (2D), as the node's 2D frame reads it (ADR 0301): a mirrored node carries its mirror on x, so a node scaled (-1, 1) and turned θ reads θ (not θ + π). Assigning turns the node and keeps its mirroring.

Returns

number

Set Signature

set worldRotation2D(angle): void;

Defined in: src/engine/scene/Transform.ts:122

Parameters
angle

number

Returns

void


worldScale

Get Signature

get worldScale(): Vector3;

Defined in: src/engine/scene/Transform.ts:153

World-space scale (lossy, from matrix column lengths).

Returns

Vector3

Methods

rotate()

rotate(rotation, space?): void;

Defined in: src/engine/scene/Transform.ts:82

Turn by rotation, about the parent's axes (rotation = q · rotation, default) or the node's own ("self": rotation = rotation · q). Named after Unity ECS's LocalTransform.Rotate.

Parameters

rotation

Quaternion

space?

"parent" | "self" = "parent"

Returns

void


rotate2D()

rotate2D(angle): void;

Defined in: src/engine/scene/Transform.ts:165

Rotate around Z by angle radians.

Parameters

angle

number

Returns

void


rotateX()

rotateX(angle, space?): void;

Defined in: src/engine/scene/Transform.ts:88

Turn angle radians about the X axis (the parent's, or the node's own with "self"); positive pitches down.

Parameters

angle

number

space?

"parent" | "self" = "parent"

Returns

void


rotateY()

rotateY(angle, space?): void;

Defined in: src/engine/scene/Transform.ts:90

Turn angle radians about the Y axis (the parent's, or the node's own with "self"); positive yaws right.

Parameters

angle

number

space?

"parent" | "self" = "parent"

Returns

void


rotateZ()

rotateZ(angle, space?): void;

Defined in: src/engine/scene/Transform.ts:92

Turn angle radians about the Z axis (the parent's, or the node's own with "self").

Parameters

angle

number

space?

"parent" | "self" = "parent"

Returns

void


translate()

translate(delta, space?): void;

Defined in: src/engine/scene/Transform.ts:159

Move by delta, in local (parent) space by default or world space.

Parameters

delta

Vec3Like

space?

"local" | "world" = "local"

Returns

void

Clone this wiki locally