diff --git a/crates/bevy_transform/src/components/global_transform.rs b/crates/bevy_transform/src/components/global_transform.rs index ceca829bc74f6..8d29c7cd35b27 100644 --- a/crates/bevy_transform/src/components/global_transform.rs +++ b/crates/bevy_transform/src/components/global_transform.rs @@ -105,6 +105,27 @@ impl GlobalTransform { self } + #[doc(hidden)] + #[inline] + pub fn with_translation(mut self, translation: Vec3) -> Self { + self.translation = translation; + self + } + + #[doc(hidden)] + #[inline] + pub fn with_rotation(mut self, rotation: Quat) -> Self { + self.rotation = rotation; + self + } + + #[doc(hidden)] + #[inline] + pub fn with_scale(mut self, scale: Vec3) -> Self { + self.scale = scale; + self + } + /// Returns the 3d affine transformation matrix from this transforms translation, /// rotation, and scale. #[inline] diff --git a/crates/bevy_transform/src/components/transform.rs b/crates/bevy_transform/src/components/transform.rs index f4a538d30ecb8..9799f45df2699 100644 --- a/crates/bevy_transform/src/components/transform.rs +++ b/crates/bevy_transform/src/components/transform.rs @@ -117,6 +117,27 @@ impl Transform { self } + /// Returns this [`Transform`] with a new translation. + #[inline] + pub fn with_translation(mut self, translation: Vec3) -> Self { + self.translation = translation; + self + } + + /// Returns this [`Transform`] with a new rotation. + #[inline] + pub fn with_rotation(mut self, rotation: Quat) -> Self { + self.rotation = rotation; + self + } + + /// Returns this [`Transform`] with a new scale. + #[inline] + pub fn with_scale(mut self, scale: Vec3) -> Self { + self.scale = scale; + self + } + /// Returns the 3d affine transformation matrix from this transforms translation, /// rotation, and scale. #[inline]