From 142c0c0af8940ba479ec430bc9477944995e1b12 Mon Sep 17 00:00:00 2001 From: bwhitt7 Date: Fri, 16 Sep 2022 16:00:47 -0400 Subject: [PATCH] Added links from transform examples to doc (#1934) --- crates/bevy_transform/src/components/global_transform.rs | 2 ++ crates/bevy_transform/src/components/transform.rs | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/crates/bevy_transform/src/components/global_transform.rs b/crates/bevy_transform/src/components/global_transform.rs index 66d2ea03fb7a5..bc038a8b89fa2 100644 --- a/crates/bevy_transform/src/components/global_transform.rs +++ b/crates/bevy_transform/src/components/global_transform.rs @@ -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), #[derive(Component, Debug, PartialEq, Clone, Copy, Reflect)] #[reflect(Component, PartialEq)] pub struct GlobalTransform(Affine3A); diff --git a/crates/bevy_transform/src/components/transform.rs b/crates/bevy_transform/src/components/transform.rs index 3920499622ae2..19226110aa34b 100644 --- a/crates/bevy_transform/src/components/transform.rs +++ b/crates/bevy_transform/src/components/transform.rs @@ -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 { @@ -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, } @@ -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) #[inline] pub const fn from_xyz(x: f32, y: f32, z: f32) -> Self { Self::from_translation(Vec3::new(x, y, z)) @@ -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;