Transform

Summary

Represents a position, rotation and scale in one object

Class Properties

NameReturn TypeDescription

identity

Transform Read-only

A transform that does nothing. No translation, rotation or scaling

Instance Properties

NameReturn TypeDescription

inverse

Transform Read-only

The inverse of this transform

up

Vector3 Read-only

A translation of 1 in the y axis

down

Vector3 Read-only

A translation of -1 in the y axis

right

Vector3 Read-only

A translation of 1 in the x axis

left

Vector3 Read-only

A translation of -1 in the x axis

forward

Vector3 Read-only

A translation of 1 in the z axis

back

Vector3 Read-only

A translation of -1 in the z axis

position

Vector3 Read/Write

Get or set the position of this transform

rotation

Rotation Read/Write

Get or set the rotation of this transform

scale

number Read/Write

Get or set the scale of this transform

Class Methods

Transform:New(translation, rotation, scale)

Creates a new translation, rotation and scale transform

Returns: Transform

Parameters:

NameTypeDefaultDescription

translation

The translation amount

rotation

The rotation amount

scale

number

The scale amount

Example

myTransform = Transform:New(Vector3(1, 2, 3), Rotation.identity, 2)

Transform:New(translation, rotation)

Creates a new translation and rotation transform

Returns: Transform

Parameters:

NameTypeDefaultDescription

translation

The translation amount

rotation

The rotation amount

Example

myTransform = Transform:New(Vector3(1, 2, 3), Rotation.identity)

Transform:New(translation)

Creates a new translation transform

Returns: Transform

Parameters:

NameTypeDefaultDescription

translation

The translation amount

Example

myTransform = Transform:New(Vector3(1, 2, 3))

Transform:New(translation, scale)

Creates a new translation and scale transform

Returns: Transform

Parameters:

NameTypeDefaultDescription

translation

The translation amount

scale

number

The scale amount

Example

myTransform = Transform:New(Vector3(1, 2, 3), 2)

Transform:Position(x, y, z)

Creates a new translation transform

Returns: Transform

Parameters:

NameTypeDefaultDescription

x

number

The x translation amount

y

number

The y translation amount

z

number

The z translation amount

Example

myTransform = Transform:Position(1, 2, 3)

Transform:Position(position)

Creates a new translation transform

Returns: Transform

Parameters:

NameTypeDefaultDescription

position

The Vector3 position

Example

myTransform = Transform:Position(myVector3)

Transform:Rotation(x, y, z)

Creates a new rotation transform

Returns: Transform

Parameters:

NameTypeDefaultDescription

x

number

The x rotation amount

y

number

The y rotation amount

z

number

The z rotation amount

Example

myTransform = Transform:Rotation(1, 2, 3)

Transform:Rotation(rotation)

Creates a new rotation transform

Returns: Transform

Parameters:

NameTypeDefaultDescription

rotation

The rotation

Example

myTransform = Transform:Rotation(myRotation)

Transform:Scale(amount)

Creates a new scale transform

Returns: Transform

Parameters:

NameTypeDefaultDescription

amount

number

The scale amount

Example

myTransform = Transform:Scale(2)

Transform:Lerp(a, b, t)

Interpolates between two transforms

Returns: Transform (A transform that blends between a and b based on the value of t)

Parameters:

NameTypeDefaultDescription

a

The first transform

b

The second transform

t

number

The value between 0 and 1 that controls how far between a and b the new transform is

Example

newTransform = Transform:Lerp(transformA, transformB, 0.25)

Instance Methods

transform:TransformBy(transform)

Applies another transform to this transform

Returns: Transform

Parameters:

NameTypeDefaultDescription

transform

The transform to apply

Example

newTransform = myTransform:TransformBy(myOtherTransform)

transform:TranslateBy(translation)

Applies a translation to this transform

Returns: Transform

Parameters:

NameTypeDefaultDescription

translation

The translation to apply

Example

newTransform = myTransform:TranslateBy(Vector3.up * 3)

transform:TranslateBy(x, y, z)

Applies a translation to this transform

Returns: Transform

Parameters:

NameTypeDefaultDescription

x

number

The x translation to apply

y

number

The y translation to apply

z

number

The z translation to apply

Example

newTransform = myTransform:TranslateBy(1, 2, 3)

transform:RotateBy(rotation)

Applies a rotation to this transform

Returns: Transform

Parameters:

NameTypeDefaultDescription

rotation

The rotation to apply

Example

newTransform = myTransform:RotateBy(Rotation.left)

transform:RotateBy(x, y, z)

Applies a rotation to this transform

Returns: Transform

Parameters:

NameTypeDefaultDescription

x

number

The x rotation to apply

y

number

The y rotation to apply

z

number

The z rotation to apply

Example

newTransform = myTransform:RotateBy(45, 0, 0)

transform:ScaleBy(scale)

Applies a scale to this transform

Returns: Transform

Parameters:

NameTypeDefaultDescription

scale

number

The scale value to apply

Example

newTransform = myTransform:ScaleBy(2)

transform:Multiply(other)

Combines another transform with this one (Does the same as "TransformBy")

Returns: Transform

Parameters:

NameTypeDefaultDescription

other

The Transform to apply to this one

Example

newTransform = myTransform:Multiply(Transform.up)

Last updated