pub struct ValueAccessorReadWriteAnimate<T> { /* private fields */ }
Expand description

A ValueAccessor is used to set/get/animate a component value. bool and i64 types will be set to target directly when using animate.

Example:

let ball_mesh = ...;
let ball_entity = Entity::create("ball");
ball_entity.render().mesh().set(ball_mesh);
ball_entity
    .transform()
    .position() // ValueAccessor returned here
    .set(Vec3::ZERO);
let duration = 1.0; // Duration is in seconds
ball_entity
    .transform()
    .position() // ValueAccessor returned here
    .animate(Vec3::new(0.0, 2.5, -40.0), duration);

Implementations§

source§

impl<T> ValueAccessorReadWriteAnimate<T>where ValueConverter: ValueConverterTrait<T>,

source

pub fn new(id: Entity, component: ComponentType, param: u32) -> Selfwhere T: Sized,

Create a new value accessor for a specific entity, component and parameter.

source

pub fn set(&self, v: T)

Sets the value to v.

Will panic if it receives an invalid value, such as a NaN or unnormalized quaternion.

source

pub fn try_set(&self, v: T) -> Result<(), EntityValueError>

Tries to set the value to v, returns EntityValueError if it failed.

In contrast to set this function will return an error if it receives an invalid value, such as a NaN or unnormalized quaternion. Useful to use if you don’t want to panic because of unknown user input.

source

pub fn get(&self) -> T

Returns the current value.

source

pub fn animate(&self, v: T, duration: f32)

Will linearly animate / transition the value from the current value to the target v using duration (in seconds).

Will stop and continue from any ongoing animation.

Note: bools and integers (also all kinds of entity references) will be set to their target directly, however delay can be used to delay the set of the value.

source

pub fn animate_smooth(&self, v: T, duration: f32, smoothing: f32)

Will linearly animate / transition the value from the current value to the

Will stop and continue from any ongoing animation. A smoothing constant of 0 means no smoothing, higher value means more smoothing (i.e. the value will take a longer time to change).

Useful if you want to smoothen out discontinuities when animating to new targets, cancelling the old animation.

Note: bools and integers (also all kinds of entity references) will be set to their target directly, however delay can be used to delay the set of the value.

source

pub fn build_animation(&self) -> AnimationBuilder<T>

Starts setting up an animation of this value.

Call methods on the returned AnimationBuilder to configure it.

Trait Implementations§

source§

impl<T> ValueAccessorAnimateTrait<T> for ValueAccessorReadWriteAnimate<T>where ValueConverter: ValueConverterTrait<T>,

Implementation of trait for animating component values

source§

fn animate(&self, v: T, duration: f32)

Will linearly animate / transition the value from the current value to the target v using duration (in seconds).

Will stop and continue from any ongoing animation.

Note: bools and integers (also all kinds of entity references) will be set to their target directly, however delay can be used to delay the set of the value.

source§

fn animate_smooth(&self, v: T, duration: f32, smoothing: f32)

Will linearly animate / transition the value from the current value to the

Will stop and continue from any ongoing animation. A smoothing constant of 0 means no smoothing, higher value means more smoothing (i.e. the value will take a longer time to change).

Useful if you want to smoothen out discontinuities when animating to new targets, cancelling the old animation.

Note: bools and integers (also all kinds of entity references) will be set to their target directly, however delay can be used to delay the set of the value.

source§

fn build_animation(&self) -> AnimationBuilder<T>

Starts setting up an animation of this value.

Call methods on the returned AnimationBuilder to configure it.

source§

impl<T> ValueAccessorReadTrait<T> for ValueAccessorReadWriteAnimate<T>where ValueConverter: ValueConverterTrait<T>,

Implementation of trait for reading component values

source§

fn get(&self) -> T

Returns the current value.

source§

impl<T> ValueAccessorWriteTrait<T> for ValueAccessorReadWriteAnimate<T>where ValueConverter: ValueConverterTrait<T>,

Implementation of trait for writing component values

source§

fn set(&self, v: T)

Sets the value to v.

Will panic if it receives an invalid value, such as a NaN or unnormalized quaternion.

source§

fn try_set(&self, v: T) -> Result<(), EntityValueError>

Tries to set the value to v, returns EntityValueError if it failed.

In contrast to set this function will return an error if it receives an invalid value, such as a NaN or unnormalized quaternion. Useful to use if you don’t want to panic because of unknown user input.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.