Controls the position, rotation, and scale of a SceneObject. Every SceneObject automatically has a Transform attached.

// Move attached Transform 1 unit up
var transform = script.getTransform();
var pos = transform.getWorldPosition();
pos.y += 1;
transform.setWorldPosition(pos);
// Bind to "Frame Updated" to rotate the object every frame
var transform = script.getTransform();
var rotation = transform.getLocalRotation();
var rotateBy = quat.angleAxis(Math.PI*getDeltaTime(), vec3.up());
rotation = rotation.multiply(rotateBy);
transform.setLocalRotation(rotation);
interface Transform {
    back: vec3;
    down: vec3;
    forward: vec3;
    left: vec3;
    right: vec3;
    segmentScaleCompensate: boolean;
    up: vec3;
    getInvertedWorldTransform(): mat4;
    getLocalPosition(): vec3;
    getLocalRotation(): quat;
    getLocalScale(): vec3;
    getSceneObject(): SceneObject;
    getTypeName(): string;
    getWorldPosition(): vec3;
    getWorldRotation(): quat;
    getWorldScale(): vec3;
    getWorldTransform(): mat4;
    isOfType(type: string): boolean;
    isSame(other: ScriptObject): boolean;
    setLocalPosition(pos: vec3): void;
    setLocalRotation(rotation: quat): void;
    setLocalScale(scale: vec3): void;
    setLocalTransform(transformMat: mat4): void;
    setWorldPosition(pos: vec3): void;
    setWorldRotation(rotation: quat): void;
    setWorldScale(scale: vec3): void;
    setWorldTransform(transformMat: mat4): void;
}

Hierarchy (view full)

Properties

back: vec3

Returns the Transform's back directional vector.

down: vec3

Returns the Transform's down directional vector.

forward: vec3

Returns the Transform's forward directional vector.

left: vec3

Returns the Transform's left directional vector.

right: vec3

Returns the Transform's right directional vector.

segmentScaleCompensate: boolean

When scaling a parent with segment scale enabled, instead of scaling child objects, it creates position offsets. This setting is used when exporting from certain 3d authoring tools.

up: vec3

Returns the Transform's up directional vector.

Methods

  • Returns the Transform's world-to-local transformation matrix.

    Returns mat4

  • Returns the Transform's position relative to its parent.

    Returns vec3

  • Returns the Transform's rotation relative to its parent.

    Returns quat

  • Returns the Transform's scale relative to its parent.

    Returns vec3

  • Returns the Transform's position relative to the world.

    Returns vec3

  • Returns the Transform's rotation relative to the world.

    Returns quat

  • Returns the Transform's scale relative to the world.

    Returns vec3

  • Returns the Transform's local-to-world transformation matrix.

    Returns mat4

  • Returns true if the object matches or derives from the passed in type.

    Parameters

    • type: string

    Returns boolean

  • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

    Parameters

    Returns boolean

  • Sets the Transform's position relative to its parent.

    Parameters

    Returns void

  • Sets the Transform's rotation relative to its parent.

    Parameters

    Returns void

  • Sets the Transform's scale relative to its parent.

    Parameters

    Returns void

  • Sets the Transform's local transformation matrix.

    Parameters

    Returns void

  • Sets the Transform's position relative to the world.

    Parameters

    Returns void

  • Sets the Transform's rotation relative to the world.

    Parameters

    Returns void

  • Sets the Transform's scale relative to the world. This may produce lossy results when parent objects are rotated, so use setLocalScale() instead if possible.

    Parameters

    Returns void

  • Sets the Transform's transformation matrix.

    Parameters

    Returns void