Skip to content

Latest commit

 

History

History
447 lines (193 loc) · 12 KB

File metadata and controls

447 lines (193 loc) · 12 KB

Transform

Summary

Represents a position, rotation and scale in one object

Class Properties

NameReturn TypeDescription
identityTransform
Read-only
A transform that does nothing. No translation, rotation or scaling

Instance Properties

NameReturn TypeDescription
inverseTransform
Read-only
The inverse of this transform
upVector3
Read-only
A translation of 1 in the y axis
downVector3
Read-only
A translation of -1 in the y axis
rightVector3
Read-only
A translation of 1 in the x axis
leftVector3
Read-only
A translation of -1 in the x axis
forwardVector3
Read-only
A translation of 1 in the z axis
backVector3
Read-only
A translation of -1 in the z axis
positionVector3
Read/Write
Get or set the position of this transform
rotationRotation
Read/Write
Get or set the rotation of this transform
scalenumber
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
translationVector3The translation amount
rotationRotationThe rotation amount
scalenumberThe 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
translationVector3The translation amount
rotationRotationThe rotation amount

Example

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

Transform:New(translation)

Creates a new translation transform

Returns: Transform

Parameters:

NameTypeDefaultDescription
translationVector3The 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
translationVector3The translation amount
scalenumberThe 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
xnumberThe x translation amount
ynumberThe y translation amount
znumberThe z translation amount

Example

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

Transform:Position(position)

Creates a new translation transform

Returns: Transform

Parameters:

NameTypeDefaultDescription
positionVector3The Vector3 position

Example

myTransform = Transform:Position(myVector3)

Transform:Rotation(x, y, z)

Creates a new rotation transform

Returns: Transform

Parameters:

NameTypeDefaultDescription
xnumberThe x rotation amount
ynumberThe y rotation amount
znumberThe z rotation amount

Example

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

Transform:Rotation(rotation)

Creates a new rotation transform

Returns: Transform

Parameters:

NameTypeDefaultDescription
rotationRotationThe rotation

Example

myTransform = Transform:Rotation(myRotation)

Transform:Scale(amount)

Creates a new scale transform

Returns: Transform

Parameters:

NameTypeDefaultDescription
amountnumberThe 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
aTransformThe first transform
bTransformThe second transform
tnumberThe 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
transformTransformThe transform to apply

Example

newTransform = myTransform:TransformBy(myOtherTransform)

transform:TranslateBy(translation)

Applies a translation to this transform

Returns: Transform

Parameters:

NameTypeDefaultDescription
translationVector3The 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
xnumberThe x translation to apply
ynumberThe y translation to apply
znumberThe z translation to apply

Example

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

transform:RotateBy(rotation)

Applies a rotation to this transform

Returns: Transform

Parameters:

NameTypeDefaultDescription
rotationRotationThe rotation to apply

Example

newTransform = myTransform:RotateBy(Rotation.left)

transform:RotateBy(x, y, z)

Applies a rotation to this transform

Returns: Transform

Parameters:

NameTypeDefaultDescription
xnumberThe x rotation to apply
ynumberThe y rotation to apply
znumberThe z rotation to apply

Example

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

transform:ScaleBy(scale)

Applies a scale to this transform

Returns: Transform

Parameters:

NameTypeDefaultDescription
scalenumberThe 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
otherTransformThe Transform to apply to this one

Example

newTransform = myTransform:Multiply(Transform.up)