rafx_visibility/geometry/
transform.rs1use glam::{Mat4, Quat, Vec3};
2
3#[derive(Copy, Clone, Debug, PartialEq)]
4pub struct Transform {
5 pub translation: Vec3,
6 pub rotation: Quat,
7 pub scale: Vec3,
8}
9
10impl Transform {
11 pub fn as_mat4(&self) -> Mat4 {
12 Mat4::from_scale_rotation_translation(self.scale, self.rotation, self.translation)
13 }
14
15 pub fn look_at(
16 &self,
17 look_at: Vec3,
18 up: Vec3,
19 ) -> Mat4 {
20 Mat4::look_at_lh(
21 self.translation,
22 look_at,
23 Mat4::from_rotation_translation(self.rotation, self.translation).transform_vector3(up),
24 )
25 }
26}
27
28impl Default for Transform {
29 fn default() -> Self {
30 Transform {
31 translation: Vec3::ZERO,
32 rotation: Quat::IDENTITY,
33 scale: Vec3::ONE,
34 }
35 }
36}