Skip to content

Commit 2eb9dd9

Browse files
committed
Adding transform example links to documentation (#5997)
# Objective Working on issue #1934 , with linking examples to the documentation. PR for transform examples. ## Solution Added to the documentation in bevy_transform transform.rs and global_transform.rs utilizing links from examples. [X] 3d_rotations.rs linked to rotate in Transform [X] global_vs_local_translation.rs linked to top of Transform and GlobalTransform documentation [X] scale.rs linked to scale Struct in Transform [X] transform.rs linked to top of Transform documentation [X] translation.rs linked to from_translation in Transform Co-authored-by: bwhitt7 <[email protected]>
1 parent 1a2aedd commit 2eb9dd9

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

crates/bevy_transform/src/components/global_transform.rs

+6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ use bevy_reflect::Reflect;
2525
/// This system runs in stage [`CoreStage::PostUpdate`](crate::CoreStage::PostUpdate). If you
2626
/// update the [`Transform`] of an entity in this stage or after, you will notice a 1 frame lag
2727
/// before the [`GlobalTransform`] is updated.
28+
///
29+
/// # Examples
30+
///
31+
/// - [`global_vs_local_translation`]
32+
///
33+
/// [`global_vs_local_translation`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/global_vs_local_translation.rs
2834
#[derive(Component, Debug, PartialEq, Clone, Copy, Reflect)]
2935
#[reflect(Component, PartialEq)]
3036
pub struct GlobalTransform(Affine3A);

crates/bevy_transform/src/components/transform.rs

+26
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,34 @@ use std::ops::Mul;
2626
/// This system runs in stage [`CoreStage::PostUpdate`](crate::CoreStage::PostUpdate). If you
2727
/// update the [`Transform`] of an entity in this stage or after, you will notice a 1 frame lag
2828
/// before the [`GlobalTransform`] is updated.
29+
///
30+
/// # Examples
31+
///
32+
/// - [`transform`]
33+
/// - [`global_vs_local_translation`]
34+
///
35+
/// [`global_vs_local_translation`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/global_vs_local_translation.rs
36+
/// [`transform`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/transform.rs
2937
#[derive(Component, Debug, PartialEq, Clone, Copy, Reflect)]
3038
#[reflect(Component, Default, PartialEq)]
3139
pub struct Transform {
3240
/// Position of the entity. In 2d, the last value of the `Vec3` is used for z-ordering.
41+
///
42+
/// See the [`translations`] example for usage.
43+
///
44+
/// [`translations`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/translation.rs
3345
pub translation: Vec3,
3446
/// Rotation of the entity.
47+
///
48+
/// See the [`3d_rotation`] example for usage.
49+
///
50+
/// [`3d_rotation`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/3d_rotation.rs
3551
pub rotation: Quat,
3652
/// Scale of the entity.
53+
///
54+
/// See the [`scale`] example for usage.
55+
///
56+
/// [`scale`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/scale.rs
3757
pub scale: Vec3,
3858
}
3959

@@ -201,6 +221,12 @@ impl Transform {
201221
/// Rotates this [`Transform`] by the given rotation.
202222
///
203223
/// If this [`Transform`] has a parent, the `rotation` is relative to the rotation of the parent.
224+
///
225+
/// # Examples
226+
///
227+
/// - [`3d_rotation`]
228+
///
229+
/// [`3d_rotation`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/3d_rotation.rs
204230
#[inline]
205231
pub fn rotate(&mut self, rotation: Quat) {
206232
self.rotation = rotation * self.rotation;

0 commit comments

Comments
 (0)