mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 04:33:37 +00:00
Add more transform relative vectors (#1300)
* Add more transform relative vectors (#1298) * Add inverse of relative directions (#1298)
This commit is contained in:
parent
40b5bbd028
commit
7e368e0b78
2 changed files with 50 additions and 0 deletions
|
@ -74,11 +74,36 @@ impl GlobalTransform {
|
|||
Mat4::from_scale_rotation_translation(self.scale, self.rotation, self.translation)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn right(&self) -> Vec3 {
|
||||
self.rotation * Vec3::unit_x()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn left(&self) -> Vec3 {
|
||||
-self.right()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn up(&self) -> Vec3 {
|
||||
self.rotation * Vec3::unit_y()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn down(&self) -> Vec3 {
|
||||
-self.up()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn forward(&self) -> Vec3 {
|
||||
self.rotation * Vec3::unit_z()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn backward(&self) -> Vec3 {
|
||||
-self.forward()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
/// Rotate the transform by the given rotation
|
||||
pub fn rotate(&mut self, rotation: Quat) {
|
||||
|
|
|
@ -74,11 +74,36 @@ impl Transform {
|
|||
Mat4::from_scale_rotation_translation(self.scale, self.rotation, self.translation)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn right(&self) -> Vec3 {
|
||||
self.rotation * Vec3::unit_x()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn left(&self) -> Vec3 {
|
||||
-self.right()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn up(&self) -> Vec3 {
|
||||
self.rotation * Vec3::unit_y()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn down(&self) -> Vec3 {
|
||||
-self.up()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn forward(&self) -> Vec3 {
|
||||
self.rotation * Vec3::unit_z()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn backward(&self) -> Vec3 {
|
||||
-self.forward()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
/// Rotate the transform by the given rotation
|
||||
pub fn rotate(&mut self, rotation: Quat) {
|
||||
|
|
Loading…
Reference in a new issue