pub mod mat4 {
pub fn identity() -> [[f32; 4]; 4] {
ultraviolet::Mat4::identity().into()
}
pub fn from_translation(pos: [f32; 3]) -> [[f32; 4]; 4] {
ultraviolet::Mat4::from_translation(pos.into()).into()
}
pub fn from_scale(scale: [f32; 3]) -> [[f32; 4]; 4] {
ultraviolet::Mat4::from_nonuniform_scale(scale.into()).into()
}
pub fn from_rotation(rot: [f32; 3]) -> [[f32; 4]; 4] {
let rx = ultraviolet::Mat4::from_rotation_x(rot[0]);
let ry = ultraviolet::Mat4::from_rotation_y(rot[1]);
let rz = ultraviolet::Mat4::from_rotation_z(rot[2]);
(rx * ry * rz).into()
}
pub fn from_quat(q: [f32; 4]) -> [[f32; 4]; 4] {
let rotor = ultraviolet::Rotor3::from_quaternion_array(q);
rotor.into_matrix().into_homogeneous().into()
}
pub fn multiply(a: [[f32; 4]; 4], b: [[f32; 4]; 4]) -> [[f32; 4]; 4] {
let ma = ultraviolet::Mat4::from(a);
let mb = ultraviolet::Mat4::from(b);
(ma * mb).into()
}
pub fn look_at(eye: [f32; 3], at: [f32; 3], up: [f32; 3]) -> [[f32; 4]; 4] {
ultraviolet::Mat4::look_at(eye.into(), at.into(), up.into()).into()
}
}
pub mod projection {
pub fn perspective_degrees(fov_y_deg: f32, aspect: f32, near: f32, far: f32) -> [[f32; 4]; 4] {
let fov_y_rad = fov_y_deg.to_radians();
ultraviolet::projection::perspective_wgpu_dx(fov_y_rad, aspect, near, far).into()
}
pub fn perspective(fov_y: f32, aspect: f32, near: f32, far: f32) -> [[f32; 4]; 4] {
ultraviolet::projection::perspective_wgpu_dx(fov_y, aspect, near, far).into()
}
}