-
Notifications
You must be signed in to change notification settings - Fork 103
Transform
The Transform class is used in conjunction with renderObject and other mat4.* utility functions. It provides a implementation similar to the OpenGL fixed-functionality stack controller with additional cache optimizations and ability to clear the stack.
Parameters:
- init_mat (optional) - An initial matrix for the transform, if not provided the identity matrix will be used.
Purpose:
Sets the current matrix in the stack to the identity matrix.
Returns:
Transform instance for chaining.
Purpose:
Get an identity matrix.
Returns:
4x4 identity matrix in an array of 16 floats.
Purpose:
Get the matrix for the current transformation.
Returns:
4x4 matrix in an array of 16 floats.
Purpose:
Push the stack controller one level, similar to glPushMatrix()
.
Parameters:
- mat (optional) - a 4x4 matrix of 16 floats to push to the stack at this level, identity matrix is assumed if not supplied.
Returns:
Transform instance for chaining.
Purpose:
Pop a matrix off the stack controller one level, similar to glPopMatrix()
.
Returns:
Transform instance for chaining.
Purpose:
Clear the entire stack regardless of depth.
Returns:
Transform instance for chaining.
Purpose:
Apply a translation to the transform.
Parameters:
-
trans_vec - an vector format
[ x, y, z ]
to translate by. - trans_x - x value to translate.
- trans_y - y value to translate.
- trans_z - z value to translate.
Returns:
Transform instance for chaining.
Purpose:
Apply a scale to the transform.
Parameters:
-
scale_vec - an array format
[ x, y, z ]
to scale each component by. - scale_x - x value to scale.
- scale_y - y value to scale.
- scale_z - z value to scale.
Returns:
Transform instance for chaining.
Purpose:
Apply a rotation to the transform, follows the OpenGL fixed functionality syntax of glRotatef(angle, x, y, z);
or by passing an array performs a standard X,Y,Z rotation of each component.
Parameters:
-
rot_vec - an array format
[ ang_x, ang_y, ang_z ]
to rotate each component by. -
rot_x - amount to apply to the x-axis. i.e.
trans.rotate(45, 1, 0, 0);
-
rot_y - amount to apply to the y-axis. i.e.
trans.rotate(45, 0, 1, 0);
-
rot_z - amount to apply to the z-axis. i.e.
trans.rotate(45, 0, 0, 1);
Returns:
Transform instance for chaining.