struct
Mat4
pub struct Mat4 {
pub m: [f32; 16],
}A 4×4 matrix stored column-major (m[col * 4 + row]), as WebGL expects.
Fields
Methods
perspective
pub fn perspective(fovy: f32, aspect: f32, near: f32, far: f32) -> Mat4OpenGL-style perspective projection (fovy in radians).
orthographic
pub fn orthographic(left: f32, right: f32, bottom: f32, top: f32, near: f32, far: f32) -> Mat4OpenGL-style orthographic projection of a view-space box.
look_at
pub fn look_at(eye: Vec3, target: Vec3, up: Vec3) -> Mat4View matrix for a camera at eye looking at target.
transform_point
pub fn transform_point(&self, p: Vec3) -> Vec3Transform a point, including the perspective divide.
transform_w
pub fn transform_w(&self, p: Vec3) -> f32The clip-space w of a transformed point (negative ⇒ behind camera).
transform_direction
pub fn transform_direction(&self, d: Vec3) -> Vec3Transform a direction (no translation, no divide).
from_quat
pub fn from_quat(q: [f32; 4]) -> Mat4Rotation from a unit quaternion (x, y, z, w) (glTF's order).
from_trs
pub fn from_trs(t: Vec3, r: [f32; 4], s: Vec3) -> Mat4Translation × rotation (quaternion) × scale.
axis_scale
pub fn axis_scale(&self) -> Vec3How much it scales along each of its own axes (the lengths of its first three columns).
normal_matrix
pub fn normal_matrix(&self) -> [f32; 9]The 3×3 normal matrix (inverse transpose of the upper left), as nine column-major values.