EntityCommandsTweeningExtensions

Trait EntityCommandsTweeningExtensions 

Source
pub trait EntityCommandsTweeningExtensions<'a> {
    // Required methods
    fn move_to(
        self,
        end: Vec3,
        duration: Duration,
        ease_method: impl Into<EaseMethod>,
    ) -> AnimatedEntityCommands<'a, impl TweenCommand>;
    fn move_from(
        self,
        start: Vec3,
        duration: Duration,
        ease_method: impl Into<EaseMethod>,
    ) -> AnimatedEntityCommands<'a, impl TweenCommand>;
    fn scale_to(
        self,
        end: Vec3,
        duration: Duration,
        ease_method: impl Into<EaseMethod>,
    ) -> AnimatedEntityCommands<'a, impl TweenCommand>;
    fn scale_from(
        self,
        start: Vec3,
        duration: Duration,
        ease_method: impl Into<EaseMethod>,
    ) -> AnimatedEntityCommands<'a, impl TweenCommand>;
    fn rotate_x(
        self,
        cycle_duration: Duration,
    ) -> AnimatedEntityCommands<'a, impl TweenCommand>;
    fn rotate_y(
        self,
        cycle_duration: Duration,
    ) -> AnimatedEntityCommands<'a, impl TweenCommand>;
    fn rotate_z(
        self,
        cycle_duration: Duration,
    ) -> AnimatedEntityCommands<'a, impl TweenCommand>;
    fn rotate_x_by(
        self,
        angle: f32,
        duration: Duration,
        ease_method: impl Into<EaseMethod>,
    ) -> AnimatedEntityCommands<'a, impl TweenCommand>;
    fn rotate_y_by(
        self,
        angle: f32,
        duration: Duration,
        ease_method: impl Into<EaseMethod>,
    ) -> AnimatedEntityCommands<'a, impl TweenCommand>;
    fn rotate_z_by(
        self,
        angle: f32,
        duration: Duration,
        ease_method: impl Into<EaseMethod>,
    ) -> AnimatedEntityCommands<'a, impl TweenCommand>;
}
Expand description

Extension trait for EntityCommands, adding animation functionalities for commonly used tweening animations.

This trait extends EntityCommands to provide convenience helpers to common tweening animations like moving the position of an entity by animating its Transform::translation.

One of the major source of convenience provided by these helpers is the fact that some of the data necessary to create the tween animation is automatically derived from the current value of the component at the time when the command is processed. For example, the move_to() helper only requires specifying the end position, and will automatically read the start position from the current Transform::translation value. This avoids having to explicitly access that component to read that value and manually store it into a Lens.

Required Methods§

Source

fn move_to( self, end: Vec3, duration: Duration, ease_method: impl Into<EaseMethod>, ) -> AnimatedEntityCommands<'a, impl TweenCommand>

Queue a new tween animation to move the current entity.

The entity must have a Transform component. The tween animation will be initialized with the current Transform::translation as its starting point, and the given endpoint, duration, and ease method.

Note that the starting point position is saved when the command is applied, generally after the current system when apply_deferred() runs. So any change to Transform::translation between this call and apply_deferred() will be taken into account.

This function is a fire-and-forget convenience helper, and doesn’t give access to the Entity created. To retrieve the entity and control the animation playback, you should spawn a TweenAnim component manually.

§Example
commands.spawn(Transform::default()).move_to(
    Vec3::new(3.5, 0., 0.),
    Duration::from_secs(1),
    EaseFunction::QuadraticIn,
);
Source

fn move_from( self, start: Vec3, duration: Duration, ease_method: impl Into<EaseMethod>, ) -> AnimatedEntityCommands<'a, impl TweenCommand>

Queue a new tween animation to move the current entity.

The entity must have a Transform component. The tween animation will be initialized with the current Transform::translation as its ending point, and the given starting point, duration, and ease method.

Note that the ending point position is saved when the command is applied, generally after the current system when apply_deferred() runs. So any change to Transform::translation between this call and apply_deferred() will be taken into account.

This function is a fire-and-forget convenience helper, and doesn’t give access to the Entity created. To retrieve the entity and control the animation playback, you should spawn a TweenAnim component manually.

§Example
commands.spawn(Transform::default()).move_from(
    Vec3::new(3.5, 0., 0.),
    Duration::from_secs(1),
    EaseFunction::QuadraticIn,
);
Source

fn scale_to( self, end: Vec3, duration: Duration, ease_method: impl Into<EaseMethod>, ) -> AnimatedEntityCommands<'a, impl TweenCommand>

Queue a new tween animation to scale the current entity.

The entity must have a Transform component. The tween animation will be initialized with the current Transform::scale as its starting point, and the given endpoint, duration, and ease method.

Note that the starting point scale is saved when the command is applied, generally after the current system when apply_deferred() runs. So any change to Transform::scale between this call and apply_deferred() will be taken into account.

This function is a fire-and-forget convenience helper, and doesn’t give access to the Entity created. To retrieve the entity and control the animation playback, you should spawn a TweenAnim component manually.

§Example
commands.spawn(Transform::default()).scale_to(
    Vec3::splat(2.), // 200% size
    Duration::from_secs(1),
    EaseFunction::QuadraticIn,
);
Source

fn scale_from( self, start: Vec3, duration: Duration, ease_method: impl Into<EaseMethod>, ) -> AnimatedEntityCommands<'a, impl TweenCommand>

Queue a new tween animation to scale the current entity.

The entity must have a Transform component. The tween animation will be initialized with the current Transform::scale as its ending point, and the given start scale, duration, and ease method.

Note that the ending point scale is saved when the command is applied, generally after the current system when apply_deferred() runs. So any change to Transform::scale between this call and apply_deferred() will be taken into account.

This function is a fire-and-forget convenience helper, and doesn’t give access to the Entity created. To retrieve the entity and control the animation playback, you should spawn a TweenAnim component manually.

§Example
commands.spawn(Transform::default()).scale_from(
    Vec3::splat(0.8), // 80% size
    Duration::from_secs(1),
    EaseFunction::QuadraticIn,
);
Source

fn rotate_x( self, cycle_duration: Duration, ) -> AnimatedEntityCommands<'a, impl TweenCommand>

Queue a new tween animation to rotate the current entity around its X axis continuously (repeats forever, linearly).

The entity must have a Transform component.

This function is a fire-and-forget convenience helper, and doesn’t give access to the Entity created. To retrieve the entity and control the animation playback, you should spawn a TweenAnim component manually.

§Example
commands
    .spawn(Transform::default())
    .rotate_x(Duration::from_secs(1));
Source

fn rotate_y( self, cycle_duration: Duration, ) -> AnimatedEntityCommands<'a, impl TweenCommand>

Queue a new tween animation to rotate the current entity around its Y axis continuously (repeats forever, linearly).

The entity must have a Transform component.

This function is a fire-and-forget convenience helper, and doesn’t give access to the Entity created. To retrieve the entity and control the animation playback, you should spawn a TweenAnim component manually.

§Example
commands
    .spawn(Transform::default())
    .rotate_y(Duration::from_secs(1));
Source

fn rotate_z( self, cycle_duration: Duration, ) -> AnimatedEntityCommands<'a, impl TweenCommand>

Queue a new tween animation to rotate the current entity around its Z axis continuously (repeats forever, linearly).

The entity must have a Transform component.

This function is a fire-and-forget convenience helper, and doesn’t give access to the Entity created. To retrieve the entity and control the animation playback, you should spawn a TweenAnim component manually.

§Example
commands
    .spawn(Transform::default())
    .rotate_z(Duration::from_secs(1));
Source

fn rotate_x_by( self, angle: f32, duration: Duration, ease_method: impl Into<EaseMethod>, ) -> AnimatedEntityCommands<'a, impl TweenCommand>

Queue a new tween animation to rotate the current entity around its X axis by a given angle.

The entity must have a Transform component. The animation applies a rotation on top of the value of the Transform at the time the animation is queued.

This function is a fire-and-forget convenience helper, and doesn’t give access to the Entity created. To retrieve the entity and control the animation playback, you should spawn a TweenAnim component manually.

§Example
commands.spawn(Transform::default()).rotate_x_by(
    std::f32::consts::FRAC_PI_4,
    Duration::from_secs(1),
    EaseFunction::QuadraticIn,
);
Source

fn rotate_y_by( self, angle: f32, duration: Duration, ease_method: impl Into<EaseMethod>, ) -> AnimatedEntityCommands<'a, impl TweenCommand>

Queue a new tween animation to rotate the current entity around its Y axis by a given angle.

The entity must have a Transform component. The animation applies a rotation on top of the value of the Transform at the time the animation is queued.

This function is a fire-and-forget convenience helper, and doesn’t give access to the Entity created. To retrieve the entity and control the animation playback, you should spawn a TweenAnim component manually.

§Example
commands.spawn(Transform::default()).rotate_y_by(
    std::f32::consts::FRAC_PI_4,
    Duration::from_secs(1),
    EaseFunction::QuadraticIn,
);
Source

fn rotate_z_by( self, angle: f32, duration: Duration, ease_method: impl Into<EaseMethod>, ) -> AnimatedEntityCommands<'a, impl TweenCommand>

Queue a new tween animation to rotate the current entity around its Z axis by a given angle.

The entity must have a Transform component. The animation applies a rotation on top of the value of the Transform at the time the animation is queued.

This function is a fire-and-forget convenience helper, and doesn’t give access to the Entity created. To retrieve the entity and control the animation playback, you should spawn a TweenAnim component manually.

§Example
commands.spawn(Transform::default()).rotate_z_by(
    std::f32::consts::FRAC_PI_4,
    Duration::from_secs(1),
    EaseFunction::QuadraticIn,
);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'a> EntityCommandsTweeningExtensions<'a> for EntityCommands<'a>

Source§

fn move_to( self, end: Vec3, duration: Duration, ease_method: impl Into<EaseMethod>, ) -> AnimatedEntityCommands<'a, impl TweenCommand>

Source§

fn move_from( self, start: Vec3, duration: Duration, ease_method: impl Into<EaseMethod>, ) -> AnimatedEntityCommands<'a, impl TweenCommand>

Source§

fn scale_to( self, end: Vec3, duration: Duration, ease_method: impl Into<EaseMethod>, ) -> AnimatedEntityCommands<'a, impl TweenCommand>

Source§

fn scale_from( self, start: Vec3, duration: Duration, ease_method: impl Into<EaseMethod>, ) -> AnimatedEntityCommands<'a, impl TweenCommand>

Source§

fn rotate_x( self, cycle_duration: Duration, ) -> AnimatedEntityCommands<'a, impl TweenCommand>

Source§

fn rotate_y( self, cycle_duration: Duration, ) -> AnimatedEntityCommands<'a, impl TweenCommand>

Source§

fn rotate_z( self, cycle_duration: Duration, ) -> AnimatedEntityCommands<'a, impl TweenCommand>

Source§

fn rotate_x_by( self, angle: f32, duration: Duration, ease_method: impl Into<EaseMethod>, ) -> AnimatedEntityCommands<'a, impl TweenCommand>

Source§

fn rotate_y_by( self, angle: f32, duration: Duration, ease_method: impl Into<EaseMethod>, ) -> AnimatedEntityCommands<'a, impl TweenCommand>

Source§

fn rotate_z_by( self, angle: f32, duration: Duration, ease_method: impl Into<EaseMethod>, ) -> AnimatedEntityCommands<'a, impl TweenCommand>

Implementors§