Class: Transform

Core.Transform(x, y, z)

This class is used to store transformations, which is done by the 3 properties: position, rotation and scale. Remember: Angels of rotations are specified in radians! Like Core.Vec, Core.Transform is designed to work on the current reference. Be sure to create copies if needed!

Constructor

new Transform(x, y, z)

Constructs a new Transform object with a optional initial position. Also look at Transform.from for more options when constructing transform objects
Parameters:
Name Type Default Description
x number 0 The x component of the position
y number 0 The y component of the position
z number 0 The z component of the position
Example
// create a transform object with an initial position of 0,10,0
const transform = new Transform(0, 10, 0);
transform.rotation.z = Math.PI; // rotate around the z axis by 180°
transform.move(0,-10); // move to center

Members

position :Core.Vec

The position component of the transformation.

rotation :Core.Vec

The rotation component of the transformation.

scale :Vec

The scale component of the transformation.

Methods

add(translation, rotationnullable, scalenullable)

Adds the given properties to this object.
Parameters:
Name Type Attributes Description
translation Core.Vec The translation to add
rotation Core.Vec <nullable>
The rotation to add
scale Core.Vec <nullable>
The scale to add
Returns:
The reference to this Transform object.

matrix() :Matrix

Gets a transformation matrix of this object. Also referred as "model" or "world" matrix.
Returns:

move(x, y, z)

Moves this Transform by the amount of the given axes.
Parameters:
Name Type Default Description
x number 0 The amount to move on the x-axis.
y number 0 The amount to move on the y-axis.
z number 0 The amount to move on the z-axis.
Returns:
The reference to this Transform object.

rotate(x, y, z)

Rotates this Transform by the amount of the given axes.
Parameters:
Name Type Default Description
x number 0 The amount to rotate on the x-axis.
y number 0 The amount to rotate on the y-axis.
z number 0 The amount to rotate on the z-axis.
Returns:
The reference to this Transform object.

setTo(position, rotationnullable, scalenullable) :Core.Transform

Sets the given properties on this object. If omitted they won't be set.
Parameters:
Name Type Attributes Description
position Core.Vec The postion of the transformation
rotation Core.Vec <nullable>
The rotation of the transformation
scale Core.Vec <nullable>
The scale of the transformation
Returns:
The reference to this Transform object.

size(x, y, z)

Scales this Transform by the amount of the given axes.
Parameters:
Name Type Default Description
x number 1 The amount to scale on the x-axis.
y number 1 The amount to scale on the y-axis.
z number 1 The amount to scale on the z-axis.
Returns:
The reference to this Transform object.

(static) from(position, rotationnullable, scalenullable) :Core.Transform

Constructs a transform object and sets the given properties
Parameters:
Name Type Attributes Description
position Core.Vec The postion of the transformation
rotation Core.Vec <nullable>
The rotation of the transformation
scale Core.Vec <nullable>
The scale of the transformation
Returns:
The created Transform object.