TrsTransform
Transform defined by translation, rotation, and scale components.
TRS transform represents a placement in world space composed as translation times rotation times scale. It is used to position cameras and renderable objects through their transform property. The matrix is computed lazily and cached.
const transform = camera.transform;
transform.setTranslation([0, 0, radius]);
transform.targetTo([0, 0, 0]);Accessors
rotation vec4
A copy of the rotation quaternion.
get rotation(): vec4;translation vec3
A copy of the translation vector.
get translation(): vec3;scale vec3
A copy of the scale vector.
get scale(): vec3;matrix mat4
The composed transform matrix. Recomputed when stale.
get matrix(): mat4;inverse mat4
The inverse of the composed transform matrix.
get inverse(): mat4;Methods
addRotation() void
Composes the given rotation onto the current rotation.
addRotation(q): void;| Parameter | Description |
|---|---|
q: quat | The rotation to apply. |
setRotation() void
Replaces the rotation with the given quaternion.
setRotation(q): void;| Parameter | Description |
|---|---|
q: quat | The new rotation. |
addTranslation() void
Adds the given offset to the translation.
addTranslation(vec): void;| Parameter | Description |
|---|---|
vec: vec3 | The offset to add. |
setTranslation() void
Replaces the translation with the given vector.
setTranslation(vec): void;| Parameter | Description |
|---|---|
vec: vec3 | The new translation. |
addScale() void
Multiplies the scale componentwise by the given vector.
addScale(vec): void;| Parameter | Description |
|---|---|
vec: vec3 | The scale factors to apply. |
setScale() void
Replaces the scale with the given vector.
setScale(vec): void;| Parameter | Description |
|---|---|
vec: vec3 | The new scale. |
targetTo() void
Rotates the transform to face the given target point. Uses +Y as world up.
targetTo(target): void;| Parameter | Description |
|---|---|
target: vec3 | The world-space point to face. |