rhodonite
    Preparing search index...

    Class Transform3D

    Represents a 3D transformation containing position, rotation, and scale components. This class provides a convenient way to handle 3D object transformations with automatic matrix composition and decomposition capabilities.

    const transform = new Transform3D();
    transform.position = Vector3.fromCopyArray([1, 2, 3]);
    transform.scale = Vector3.fromCopyArray([2, 2, 2]);
    transform.rotation = Quaternion.fromEulerAngles(0, Math.PI / 4, 0);
    const matrix = transform.matrix;
    Index
    • get eulerAngles(): IVector3

      Gets a copy of the rotation as Euler angles (XYZ order).

      Returns IVector3

      A cloned Vector3 containing rotation angles in radians [x, y, z]

    • set eulerAngles(vec: IVector3): void

      Sets the rotation using Euler angles (XYZ order).

      Parameters

      • vec: IVector3

        Vector containing rotation angles in radians [x, y, z]

      Returns void

    • get eulerAnglesInner(): Vector3

      Gets the rotation as Euler angles (XYZ order) - direct reference.

      Returns Vector3

      A Vector3 containing rotation angles in radians [x, y, z]

    • get matrix(): IMatrix44

      Gets a copy of the local transformation matrix.

      Returns IMatrix44

      A new Matrix44 representing the composed transformation

    • set matrix(mat: IMatrix44): void

      Sets the transform from a 4x4 transformation matrix. Decomposes the matrix into position, rotation, and scale components.

      Parameters

      • mat: IMatrix44

        The transformation matrix to decompose

      Returns void

    • get matrixInner(): MutableMatrix44

      Gets the local transformation matrix composed from position, rotation, and scale. The matrix is computed as: Translation * Rotation * Scale

      Returns MutableMatrix44

      A MutableMatrix44 representing the composed transformation

    • get position(): MutableVector3

      Gets a copy of the local position vector.

      Returns MutableVector3

      A cloned MutableVector3 representing the position

    • set position(vec: IVector3): void

      Sets the position of the transform.

      Parameters

      Returns void

    • get positionInner(): MutableVector3

      Gets the internal position vector (direct reference).

      Returns MutableVector3

      The internal MutableVector3 position object

    • get rotateMatrix44(): IMatrix44

      Gets the rotation as a 4x4 rotation matrix.

      Returns IMatrix44

      A Matrix44 representing only the rotation component

    • set rotateMatrix44(rotateMatrix: IMatrix44): void

      Sets the rotation using a 4x4 rotation matrix.

      Parameters

      • rotateMatrix: IMatrix44

        The rotation matrix to extract rotation from

      Returns void

    • get rotation(): IQuaternion

      Gets a copy of the local rotation quaternion.

      Returns IQuaternion

      A cloned Quaternion representing the rotation

    • set rotation(quat: IQuaternion): void

      Sets the rotation using a quaternion.

      Parameters

      Returns void

    • get rotationInner(): Quaternion

      Gets the internal rotation quaternion (direct reference).

      Returns Quaternion

      The internal Quaternion rotation object

    • get scale(): IVector3

      Gets a copy of the local scale vector.

      Returns IVector3

      A cloned MutableVector3 representing the scale

    • set scale(vec: IVector3): void

      Sets the scale of the transform.

      Parameters

      Returns void

    • get scaleInner(): MutableVector3

      Gets the internal scale vector (direct reference).

      Returns MutableVector3

      The internal MutableVector3 scale object

    • get updateCount(): number

      Gets the number of times this transform has been updated. This can be useful for optimization and caching purposes.

      Returns number

      The update count as a number

    • Creates a deep copy of this transform.

      Returns Transform3D

      A new Transform3D instance with the same values

    • Efficiently computes the transformation matrix and stores it in the provided matrix. This method avoids memory allocation by reusing an existing matrix object.

      Parameters

      Returns void

    • Rotates the transform to face from one direction to another. Calculates the rotation needed to align the 'from' direction with the 'to' direction.

      Parameters

      • fromVec: Vector3

        The current forward direction

      • toVec: Vector3

        The target direction to face towards

      Returns void

    • Checks if this transform is equal to another transform within a given tolerance.

      Parameters

      • rhs: Transform3D

        The transform to compare against

      • delta: number = Number.EPSILON

        The tolerance for comparison (default: Number.EPSILON)

      Returns boolean

      True if the transforms are equal within the specified tolerance

    • Sets the position using an array of three numbers.

      Parameters

      • array: Array3<number>

        Array containing [x, y, z] position values

      Returns void

    • Sets transform properties from a JSON object. Supports setting position, scale, rotation (as quaternion), and matrix properties.

      Parameters

      • arg: JSON

        JSON object or JSON string containing transform properties

      Returns void

    • Sets the rotation using an array of four numbers representing a quaternion.

      Parameters

      • array: Array4<number>

        Array containing [x, y, z, w] quaternion values

      Returns void

    • Sets the rotation to align with specified up and front vectors. Creates a coordinate system where the Y-axis aligns with the up vector and the Z-axis aligns with the front vector.

      Parameters

      • UpVec: IVector3

        The desired up direction (Y-axis)

      • FrontVec: IVector3

        The desired front direction (Z-axis)

      Returns void

    • Sets the scale using an array of three numbers.

      Parameters

      • array: Array3<number>

        Array containing [x, y, z] scale values

      Returns void

    • Sets multiple transform components at once for optimal performance. This method reduces the cost of automatically updating transform matrices by setting all components in a single operation. Useful for animation and batch updates where performance is critical.

      Note: The provided transform components must be mutually consistent. For example, if a matrix is provided, its decomposed translate, rotate, and scale components should match the individual component arguments.

      Parameters

      Returns void