Transform

Reference

class Transform
module:
position: Vector3

The position of the transform.

rotation: Quaternion

The rotation of the transform.

scale: Vector3

The scale of the transform.

static new()

Creates a new transform object.

Returns:

The new Transform object.

Return type:

Transform

static new(position, rotation, scale)

Creates a transform object from existing position, rotation, and scale.

Parameters:
Returns:

The new Transform object.

Return type:

Transform

static fromJson(json)

Creates a transform object from JSON.

Parameters:

json (str) – The JSON string.

Returns:

The new Transform object.

Return type:

Transform

static fromData(data)

Creates a transform object from data.

Parameters:

data (table) – The data object containing position, rotation, and scale.

Returns:

The new Transform object.

Return type:

Transform

toData()

Converts the transform into a table representation.

Returns:

The data table.

Return type:

table

moveTo(x, y, z)

Moves the transform to a new position.

Parameters:
  • x (number or Vector3) – The x coordinate or a Vector3 position.

  • y (number) – The y coordinate (if x is a number).

  • z (number) – The z coordinate (if x is a number).

moveBy(x, y, z)

Moves the transform by a given offset.

Parameters:
  • x (number or Vector3) – The x offset or a Vector3 offset.

  • y (number) – The y offset (if x is a number).

  • z (number) – The z offset (if x is a number).

lookAt(x, y, z, up)

Rotates the transform to look at a target position.

Parameters:
  • x (number or Vector3) – The target x coordinate or a Vector3 target.

  • y (number) – The target y coordinate (if x is a number).

  • z (number) – The target z coordinate (if x is a number).

  • up (Vector3) – The up direction (default is Vector3(0,1,0)).

rotateTo(x, y, z)

Rotates the transform to a specific rotation.

Parameters:
  • x (number or Vector3) – The x rotation or a Vector3 rotation.

  • y (number) – The y rotation (if x is a number).

  • z (number) – The z rotation (if x is a number).

rotateBy(x, y, z)

Rotates the transform by a given amount.

Parameters:
  • x (number or Vector3) – The x rotation or a Vector3 rotation.

  • y (number) – The y rotation (if x is a number).

  • z (number) – The z rotation (if x is a number).

Examples