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
impl AvatarInstance
Sourcepub fn reset_frame_state(&mut self)
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.
Sourcepub fn set_expression(&mut self, name: impl Into<String>, weight: f32)
pub fn set_expression(&mut self, name: impl Into<String>, weight: f32)
Sets the weight (clamped to 0..=1) of an expression by name.
Sourcepub fn expression_weight(&self, name: &str) -> f32
pub fn expression_weight(&self, name: &str) -> f32
Returns an expression input weight, or zero when it has not been set.
Sourcepub fn clear_expression(&mut self, name: &str)
pub fn clear_expression(&mut self, name: &str)
Removes one expression input by exact name.
Sourcepub fn clear_expressions(&mut self)
pub fn clear_expressions(&mut self)
Removes all expression inputs.
Sourcepub fn set_bone_rotation(&mut self, bone: HumanBone, rotation: Quat)
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.
Sourcepub fn bone_rotation(&self, bone: HumanBone) -> Quat
pub fn bone_rotation(&self, bone: HumanBone) -> Quat
Returns a humanoid bone’s rotation delta, or identity when unset.
Sourcepub fn clear_bone_rotation(&mut self, bone: HumanBone)
pub fn clear_bone_rotation(&mut self, bone: HumanBone)
Removes one humanoid bone rotation delta.
Sourcepub fn clear_bone_rotations(&mut self)
pub fn clear_bone_rotations(&mut self)
Removes all humanoid bone rotation deltas.
Sourcepub fn set_bone_translation(&mut self, bone: HumanBone, translation: Vec3)
pub fn set_bone_translation(&mut self, bone: HumanBone, translation: Vec3)
Sets a local translation override for a humanoid bone.
Sourcepub fn bone_translation(&self, bone: HumanBone) -> Vec3
pub fn bone_translation(&self, bone: HumanBone) -> Vec3
Returns a humanoid bone’s local translation, or zero when unset.
Sourcepub fn clear_bone_translation(&mut self, bone: HumanBone)
pub fn clear_bone_translation(&mut self, bone: HumanBone)
Removes one humanoid bone translation override.
Sourcepub fn clear_bone_translations(&mut self)
pub fn clear_bone_translations(&mut self)
Removes all humanoid bone translation overrides.
Sourcepub fn set_look_at_target(&mut self, target: Option<Vec3>)
pub fn set_look_at_target(&mut self, target: Option<Vec3>)
Sets the world-space gaze target; None disables LookAt.
Sourcepub fn look_at_target(&self) -> Option<Vec3>
pub fn look_at_target(&self) -> Option<Vec3>
Returns the active world-space look-at target.
Sourcepub fn set_look_at_rotation(&mut self, rotation: Option<Quat>)
pub fn set_look_at_rotation(&mut self, rotation: Option<Quat>)
Sets a direct rest-relative head rotation and clears any gaze target.
Sourcepub fn apply_animation(
&mut self,
animation: &VrmAnimation,
time: f32,
avatar: &AvatarAsset,
)
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.
Sourcepub fn evaluate(&self, avatar: &Avatar) -> AvatarEvaluation
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.