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 <103079612+bwhitt7@users.noreply.github.com>
This commit is contained in:
parent
1a2aedd165
commit
2eb9dd9dd9
@ -25,6 +25,12 @@ 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.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// - [`global_vs_local_translation`]
|
||||
///
|
||||
/// [`global_vs_local_translation`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/global_vs_local_translation.rs
|
||||
#[derive(Component, Debug, PartialEq, Clone, Copy, Reflect)]
|
||||
#[reflect(Component, PartialEq)]
|
||||
pub struct GlobalTransform(Affine3A);
|
||||
|
||||
@ -26,14 +26,34 @@ 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`]
|
||||
/// - [`global_vs_local_translation`]
|
||||
///
|
||||
/// [`global_vs_local_translation`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/global_vs_local_translation.rs
|
||||
/// [`transform`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/transform.rs
|
||||
#[derive(Component, Debug, PartialEq, Clone, Copy, Reflect)]
|
||||
#[reflect(Component, Default, PartialEq)]
|
||||
pub struct Transform {
|
||||
/// Position of the entity. In 2d, the last value of the `Vec3` is used for z-ordering.
|
||||
///
|
||||
/// See the [`translations`] example for usage.
|
||||
///
|
||||
/// [`translations`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/translation.rs
|
||||
pub translation: Vec3,
|
||||
/// Rotation of the entity.
|
||||
///
|
||||
/// See the [`3d_rotation`] example for usage.
|
||||
///
|
||||
/// [`3d_rotation`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/3d_rotation.rs
|
||||
pub rotation: Quat,
|
||||
/// Scale of the entity.
|
||||
///
|
||||
/// See the [`scale`] example for usage.
|
||||
///
|
||||
/// [`scale`]: https://github.com/bevyengine/bevy/blob/latest/examples/transforms/scale.rs
|
||||
pub scale: Vec3,
|
||||
}
|
||||
|
||||
@ -201,6 +221,12 @@ 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.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// - [`3d_rotation`]
|
||||
///
|
||||
/// [`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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user