Skip to main content

MotionPlayer

Struct MotionPlayer 

Source
pub struct MotionPlayer { /* private fields */ }
Expand description

Plays a parsed motion3.json animation against a ModelRuntime.

A player owns playback time and blend weight. It does not update meshes by itself; call ModelRuntime::update_meshes after applying one or more players.

Implementations§

Source§

impl MotionPlayer

Source

pub fn new(motion: Motion3) -> Self

Creates a player at time 0.0 with full weight.

The player follows the motion’s own Loop metadata.

Source

pub fn new_once(motion: Motion3) -> Self

Creates a player that stops at the end, ignoring the motion’s Loop metadata.

Source

pub fn with_looping(motion: Motion3, looping: bool) -> Self

Creates a player with an explicit loop mode.

Source

pub fn motion(&self) -> &Motion3

Returns the motion data owned by this player.

Source

pub fn time(&self) -> f32

Returns the current playback time in seconds.

Source

pub fn weight(&self) -> f32

Returns the player’s global blend weight.

Source

pub fn is_looping(&self) -> bool

Returns whether this player wraps at the motion duration.

Source

pub fn set_weight(&mut self, weight: f32)

Sets the player’s global blend weight, clamped to 0.0..=1.0.

Source

pub fn is_finished(&self) -> bool

Returns whether a one-shot motion has reached its end.

Source

pub fn restart(&mut self)

Restarts playback from the beginning.

Source

pub fn tick(&mut self, delta_seconds: f32)

Advances playback time by delta_seconds.

Negative deltas are treated as zero. Looping motions wrap at their declared duration; non-looping motions stop at the end.

Source

pub fn apply(&self, runtime: &mut ModelRuntime)

Applies the current motion sample to a model runtime.

Curves targeting unknown parameters or parts are ignored. Call ModelRuntime::update_meshes after all motion and expression players have been applied for the frame.

Trait Implementations§

Source§

impl Clone for MotionPlayer

Source§

fn clone(&self) -> MotionPlayer

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MotionPlayer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.