diff --git a/engine/src/scene/content/components/location.rs b/engine/src/scene/content/components/location.rs index 688d914..5609914 100644 --- a/engine/src/scene/content/components/location.rs +++ b/engine/src/scene/content/components/location.rs @@ -13,6 +13,7 @@ pub struct Location { offset: Vector3, position: Vector3, rotation: Rad, + y_rotation: Rad, movement_min_threshold: f32, @@ -29,6 +30,7 @@ impl Clone for Location { offset: self.offset, position: self.position, rotation: self.rotation, + y_rotation: self.y_rotation, movement_min_threshold: 0.4, @@ -49,6 +51,7 @@ impl Location { offset: Vector3::zero(), position: Vector3::zero(), rotation: Rad(0.0), + y_rotation: Rad(0.0), movement_min_threshold: 0.4, @@ -136,6 +139,16 @@ impl Location { } } + pub fn set_y_rotation(&mut self, y_rotation: impl Into>) { + let y_rotation = y_rotation.into(); + + if self.y_rotation != y_rotation { + self.y_rotation = y_rotation; + + self.update_apply().unwrap(); + } + } + pub fn set_position(&mut self, position: Vector3) { if self.position != position { self.position = position; @@ -170,6 +183,7 @@ impl Location { fn update_matrix(&mut self) { self.transformation = Matrix4::from_translation(self.position + self.offset) + * Matrix4::from_angle_y(self.y_rotation) * Matrix4::from_angle_z(self.rotation) * Matrix4::from_nonuniform_scale(self.scale.x, self.scale.y, self.scale.z); }