Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Adding transform example links to documentation #5997

Closed
wants to merge 9 commits into from
Closed
2 changes: 2 additions & 0 deletions crates/bevy_transform/src/components/global_transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ use bevy_reflect::Reflect;
/// This system runs in stage [`CoreStage::PostUpdate`](crate::CoreStage::PostUpdate). If you
/// update the [`Transform`] of an entity in this stage or after, you will notice a 1 frame lag
/// before the [`GlobalTransform`] is updated.
///
/// Example: [transform](https://github.com/bevyengine/bevy/blob/latest/examples/transforms/transform.rs),
bwhitt7 marked this conversation as resolved.
Show resolved Hide resolved
#[derive(Component, Debug, PartialEq, Clone, Copy, Reflect)]
#[reflect(Component, PartialEq)]
pub struct GlobalTransform(Affine3A);
Expand Down
8 changes: 8 additions & 0 deletions crates/bevy_transform/src/components/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ use std::ops::Mul;
/// This system runs in stage [`CoreStage::PostUpdate`](crate::CoreStage::PostUpdate). If you
/// update the [`Transform`] of an entity in this stage or after, you will notice a 1 frame lag
/// before the [`GlobalTransform`] is updated.
///
/// Examples: [transform](https://github.com/bevyengine/bevy/blob/latest/examples/transforms/transform.rs), [global_vs_local_translation.rs](https://github.com/bevyengine/bevy/blob/latest/examples/transforms/global_vs_local_translation.rs)
#[derive(Component, Debug, PartialEq, Clone, Copy, Reflect)]
#[reflect(Component, Default, PartialEq)]
pub struct Transform {
Expand All @@ -34,6 +36,8 @@ pub struct Transform {
/// Rotation of the entity.
pub rotation: Quat,
/// Scale of the entity.
///
/// Example: [scale](https://github.com/bevyengine/bevy/blob/latest/examples/transforms/scale.rs)
pub scale: Vec3,
}

Expand All @@ -48,6 +52,8 @@ impl Transform {
/// Creates a new [`Transform`] at the position `(x, y, z)`. In 2d, the `z` component
/// is used for z-ordering elements: higher `z`-value will be in front of lower
/// `z`-value.
///
/// Example: [translations](https://github.com/bevyengine/bevy/blob/latest/examples/transforms/translation.rs)
bwhitt7 marked this conversation as resolved.
Show resolved Hide resolved
#[inline]
pub const fn from_xyz(x: f32, y: f32, z: f32) -> Self {
Self::from_translation(Vec3::new(x, y, z))
Expand Down Expand Up @@ -201,6 +207,8 @@ impl Transform {
/// Rotates this [`Transform`] by the given rotation.
///
/// If this [`Transform`] has a parent, the `rotation` is relative to the rotation of the parent.
///
/// Example: [3d_rotation](https://github.com/bevyengine/bevy/blob/latest/examples/transforms/3d_rotation.rs)
#[inline]
pub fn rotate(&mut self, rotation: Quat) {
self.rotation = rotation * self.rotation;
Expand Down