Class Transform

Package: @aspose/3d (v24.12.0)

Transform holds the local position, rotation, and scale of a Node in object space. It provides both direct property access (translation, scaling, rotation) and fluent setter methods (setTranslation, setScale, setEulerAngles, setRotation). All setters invalidate an internal matrix cache; the recomputed matrix is available via transformMatrix.

export class Transform extends A3DObject

Inheritance

A3DObject ← Transform

Examples

Position, rotate, and scale a node using the fluent API.

import { Scene, Node, Mesh } from '@aspose/3d';
import { Vector3, Quaternion } from '@aspose/3d/utilities';

const scene = new Scene();
const node = scene.rootNode.createChildNode('box');

// Fluent chain: translate, scale, then rotate 45° around Y
node.transform
  .setTranslation(0, 1, 0)
  .setScale(2, 2, 2)
  .setEulerAngles(0, Math.PI / 4, 0);

console.log(`Translation: ${node.transform.translation}`);
// Translation: Vector3(0, 1, 0)

Properties

PropertyTypeDefaultDescription
translationVector3(0, 0, 0)Local position of the node in its parent’s coordinate space.
scalingVector3(1, 1, 1)Local scale factors along each axis. Note: the property is scaling, not scale.
rotationQuaternionidentityLocal rotation as a unit quaternion. Setting this also updates eulerAngles.
eulerAnglesVector3(0, 0, 0)Local rotation expressed as Euler angles in radians (pitch, yaw, roll). Setting this also updates rotation.
transformMatrixMatrix4identityThe full local-to-parent transformation matrix. Computed lazily from the TRS properties; can also be set directly to decompose into TRS components.
preRotationVector3(0, 0, 0)Euler rotation applied before the main rotation (used by FBX rigs).
postRotationVector3(0, 0, 0)Euler rotation applied after the main rotation (used by FBX rigs).
scalingOffsetVector3(0, 0, 0)Translation offset applied before the scaling pivot (FBX-compatible).
scalingPivotVector3(0, 0, 0)Pivot point around which scaling is applied.
rotationOffsetVector3(0, 0, 0)Translation offset applied before the rotation pivot.
rotationPivotVector3(0, 0, 0)Pivot point around which rotation is applied.
geometricTranslationVector3(0, 0, 0)Geometric translation applied after the node transform (affects geometry, not children).
geometricScalingVector3(1, 1, 1)Geometric scale applied after the node transform (affects geometry, not children).
geometricRotationVector3(0, 0, 0)Geometric rotation applied after the node transform (affects geometry, not children).

Methods

setTranslation(tx, ty, tz)

Sets the local translation and returns this for method chaining.

setTranslation(tx: number, ty: number, tz: number): Transform

Parameters

tx number — X component of the translation.

ty number — Y component of the translation.

tz number — Z component of the translation.

Returns

Transform — The same Transform instance for chaining.

Examples

import { Scene } from '@aspose/3d';

const scene = new Scene();
const node = scene.rootNode.createChildNode('pivot');
node.transform.setTranslation(10, 0, -5);
console.log(`X: ${node.transform.translation.x}`); // X: 10

setScale(sx, sy, sz)

Sets the local scaling and returns this for method chaining.

setScale(sx: number, sy: number, sz: number): Transform

Parameters

sx number — Scale factor along X.

sy number — Scale factor along Y.

sz number — Scale factor along Z.

Returns

Transform — The same Transform instance for chaining.

Examples

import { Scene } from '@aspose/3d';

const scene = new Scene();
const node = scene.rootNode.createChildNode('big');
node.transform.setScale(3, 3, 3);
console.log(`Scale X: ${node.transform.scaling.x}`); // Scale X: 3

setEulerAngles(rx, ry, rz)

Sets the rotation via Euler angles in radians and returns this. The rotation quaternion is updated automatically.

setEulerAngles(rx: number, ry: number, rz: number): Transform

Parameters

rx number — Pitch (rotation around X axis) in radians.

ry number — Yaw (rotation around Y axis) in radians.

rz number — Roll (rotation around Z axis) in radians.

Returns

Transform — The same Transform instance for chaining.

Examples

import { Scene } from '@aspose/3d';

const scene = new Scene();
const node = scene.rootNode.createChildNode('rotated');
// Rotate 90° around Y axis
node.transform.setEulerAngles(0, Math.PI / 2, 0);
console.log(`Euler Y: ${node.transform.eulerAngles.y.toFixed(4)}`);
// Euler Y: 1.5708

setRotation(rw, rx, ry, rz)

Sets the rotation from quaternion components and returns this. The eulerAngles property is updated automatically.

setRotation(rw: number, rx: number, ry: number, rz: number): Transform

Parameters

rw number — Scalar (w) component of the quaternion.

rx number — X component of the quaternion.

ry number — Y component of the quaternion.

rz number — Z component of the quaternion.

Returns

Transform — The same Transform instance for chaining.


setPreRotation(rx, ry, rz)

Sets the pre-rotation Euler angles in radians and returns this.

setPreRotation(rx: number, ry: number, rz: number): Transform

Returns

Transform


setPostRotation(rx, ry, rz)

Sets the post-rotation Euler angles in radians and returns this.

setPostRotation(rx: number, ry: number, rz: number): Transform

Returns

Transform


setGeometricTranslation(x, y, z)

Sets the geometric translation offset (affects this node’s geometry but not its children) and returns this.

setGeometricTranslation(x: number, y: number, z: number): Transform

Returns

Transform


setGeometricScaling(sx, sy, sz)

Sets the geometric scaling offset and returns this.

setGeometricScaling(sx: number, sy: number, sz: number): Transform

Returns

Transform


setGeometricRotation(rx, ry, rz)

Sets the geometric rotation offset (Euler angles in radians) and returns this.

setGeometricRotation(rx: number, ry: number, rz: number): Transform

Returns

Transform