Skip to main content

AvatarInstance

Struct AvatarInstance 

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

Mutable per-frame state of an avatar: expression weights, bone rotations and the look-at target. Feed it to AvatarInstance::evaluate to produce an AvatarEvaluation.

Implementations§

Source§

impl AvatarInstance

Source

pub fn reset_frame_state(&mut self)

Clears every expression weight, bone rotation and look-at target, so the inputs of the next frame fully define the instance state (frame- replace semantics). Without this, switching expressions/bones would accumulate the previous frames’ inputs.

Source

pub fn set_expression(&mut self, name: impl Into<String>, weight: f32)

Sets the weight (clamped to 0..=1) of an expression by name.

Source

pub fn expression_weight(&self, name: &str) -> f32

Returns an expression input weight, or zero when it has not been set.

Source

pub fn clear_expression(&mut self, name: &str)

Removes one expression input by exact name.

Source

pub fn clear_expressions(&mut self)

Removes all expression inputs.

Source

pub fn set_bone_rotation(&mut self, bone: HumanBone, rotation: Quat)

Sets the rotation delta of a humanoid bone (in addition to its rest rotation). Use AvatarInstance::set_bone_rotation for the common case; raw node updates go through the runtime output.

Source

pub fn bone_rotation(&self, bone: HumanBone) -> Quat

Returns a humanoid bone’s rotation delta, or identity when unset.

Source

pub fn clear_bone_rotation(&mut self, bone: HumanBone)

Removes one humanoid bone rotation delta.

Source

pub fn clear_bone_rotations(&mut self)

Removes all humanoid bone rotation deltas.

Source

pub fn set_bone_translation(&mut self, bone: HumanBone, translation: Vec3)

Sets a local translation override for a humanoid bone.

Source

pub fn bone_translation(&self, bone: HumanBone) -> Vec3

Returns a humanoid bone’s local translation, or zero when unset.

Source

pub fn clear_bone_translation(&mut self, bone: HumanBone)

Removes one humanoid bone translation override.

Source

pub fn clear_bone_translations(&mut self)

Removes all humanoid bone translation overrides.

Source

pub fn set_look_at_target(&mut self, target: Option<Vec3>)

Sets the world-space gaze target; None disables LookAt.

Source

pub fn look_at_target(&self) -> Option<Vec3>

Returns the active world-space look-at target.

Source

pub fn set_look_at_rotation(&mut self, rotation: Option<Quat>)

Sets a direct rest-relative head rotation and clears any gaze target.

Source

pub fn apply_animation( &mut self, animation: &VrmAnimation, time: f32, avatar: &AvatarAsset, )

Applies a clip to avatar at time, overwriting its animated controls.

Programmatic rotations are target-local deltas. Loaded VRMA rotations are converted through normalized humanoid space, and their Hips translation is scaled by the ratio of target/source rest-pose heights.

Source

pub fn evaluate(&self, avatar: &Avatar) -> AvatarEvaluation

Evaluates this instance against avatar, folding LookAt, expression overrides/accumulation and bone rotations into one AvatarEvaluation.

This is pure: the instance is only read, the caller keeps control of the shared state.

Trait Implementations§

Source§

impl Clone for AvatarInstance

Source§

fn clone(&self) -> Self

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 AvatarInstance

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for AvatarInstance

Source§

fn default() -> Self

Returns the “default value” for a type. 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.