# SceneScript Class Mat4

Mat4 utility class used for creating a 4 dimensional identity matrix which can be used for matrix manipulations.

# Constructors

# constructor(): Mat4

Creates an identity matrix.

# Static Functions

# static identity(): Mat4

Creates an identity matrix.

# static fromTranslation(v: Vec2|Vec3): Mat4

Creates a translation matrix from a Vec2 or Vec3.

# static fromScale(v: Number|Vec3): Mat4

Creates a uniform or per-axis scale matrix.

# static fromRotation(angle: Number, axis: Vec3): Mat4

Creates a rotation matrix around an arbitrary axis. Angle is in degrees.

# static fromEuler(x: Number|Vec3, y?: Number, z?: Number): Mat4

Creates a rotation matrix from Euler angles in degrees.

# static fromBasis(right: Vec3, up: Vec3, forward: Vec3): Mat4

Creates a matrix from three orthonormal basis vectors (column-wise).

# static lookAt(eye: Vec3, center: Vec3, up: Vec3): Mat4

Creates a view matrix from an eye position, a target center and an up vector.

# static compose(translation: Vec3, rotation: Vec3, scale: Vec3): Mat4

Composes a transform as T * R * S, with rotation as Euler angles in degrees.

# Functions

# translation(position?: Vec2|Vec3): Vec3

If position is specified, it will change the translation vector of the matrix and return nothing. If position is not specified, it will return the current translation vector.

# right(): Vec3

Gets right vector. (Red axis)

# up(): Vec3

Gets up vector. (Green axis)

# forward(): Vec3

Gets forward vector. (Blue axis)

# add(other: Mat4): Mat4

Element-wise matrix addition.

# subtract(other: Mat4): Mat4

Element-wise matrix subtraction.

# multiply(value: Mat4|Vec4|Number): Mat4|Vec4

Multiplies with another matrix, a Vec4, or a scalar.

# translate(v: Vec2|Vec3): Mat4

Right-multiplies by a translation. Equivalent to this * fromTranslation(v).

# rotate(angle: Number, axis: Vec3): Mat4

Right-multiplies by a rotation around an arbitrary axis. Angle is in degrees.

# scale(v: Number|Vec3): Mat4

Right-multiplies by a scale (uniform or per-axis).

# transformPoint(v: Vec3): Vec3

Transforms a point (treated as having w = 1).

# transformDirection(v: Vec3): Vec3

Transforms a direction vector (treated as having w = 0, ignoring translation).

# transpose(): Mat4

Returns the transposed matrix.

# inverse(): Mat4

Returns the inverse matrix.

# determinant(): Number

Returns the determinant.

# extractEuler(): Vec3

Extracts Euler angles in degrees as a Vec3.

# normalMatrix(): Mat3

Returns the 3x3 normal matrix (transpose of the inverse of the upper-left 3x3).

# decompose(): Object

Decomposes the matrix into translation, Euler rotation (degrees) and scale. Returns an object of shape { translation: Vec3, rotation: Vec3, scale: Vec3 }.

# copy(): Mat4

Makes a simple copy of the matrix.

# equals(other: Mat4): Boolean

Checks if one matrix is equal (with epsilon) to another matrix.

# toString(): String

Converts components to a string representation that Wallpaper Engine understands.