Lens Scripting API

    Class Transform

    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);

    Hierarchy (View Summary, Expand)

    Index

    Constructors

    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

    MMNEPVFCICPMFPCPTTAAATR