Skip to main content

RaylibModelAnimation

Trait RaylibModelAnimation 

Source
pub trait RaylibModelAnimation: AsRef<ModelAnimation> + AsRawMut<ModelAnimation> {
    // Provided methods
    fn frame_poses(&self) -> Vec<&[Transform]> { ... }
    fn frame_poses_iter(&self) -> FramePoseIter<'_>  { ... }
    fn frame_poses_mut(&mut self) -> Vec<&mut [Transform]> { ... }
    fn frame_poses_iter_mut(&mut self) -> FramePoseIterMut<'_>  { ... }
}
Expand description

Extension trait that exposes per-keyframe bone-pose access on a ModelAnimation.

Implemented for both ModelAnimation (borrowed view from a ModelAnimations collection) and WeakModelAnimation. Use the iterator variants (frame_poses_iter / frame_poses_iter_mut) when you only need to walk the frames in order — they avoid the per-frame Vec allocation.

§Examples

use raylib::prelude::*;

let (mut rl, thread) = raylib::init().size(800, 600).title("anim").build();
let anims = rl.load_model_animations(&thread, "assets/character.glb").unwrap();
for pose in anims[0].frame_poses_iter() {
    // pose: &[Transform] — one entry per bone for this keyframe
    let _ = pose.len();
}

§See also

Provided Methods§

Source

fn frame_poses(&self) -> Vec<&[Transform]>

Poses array by frame

Source

fn frame_poses_iter(&self) -> FramePoseIter<'_>

Returns an iterator over each frame’s bone-transform slice (immutable).

Preferred over frame_poses when you only need a sequential walk — yields a &[Transform] per keyframe without allocating an outer Vec.

§Examples
use raylib::prelude::*;

let (mut rl, thread) = raylib::init().size(800, 600).title("anim").build();
let anims = rl.load_model_animations(&thread, "assets/character.glb").unwrap();
let frames: usize = anims[0].frame_poses_iter().count();
println!("{frames} keyframes");
§See also
Source

fn frame_poses_mut(&mut self) -> Vec<&mut [Transform]>

Poses array by frame

Source

fn frame_poses_iter_mut(&mut self) -> FramePoseIterMut<'_>

Returns an iterator over each frame’s bone-transform slice (mutable).

Lets you rewrite the keyframe poses in place — e.g. retarget translations or blend with another clip — without copying the whole pose grid.

§Examples
use raylib::prelude::*;

let (mut rl, thread) = raylib::init().size(800, 600).title("anim").build();
let mut anims = rl.load_model_animations(&thread, "assets/character.glb").unwrap();
for pose in anims.as_mut_slice()[0].frame_poses_iter_mut() {
    for t in pose.iter_mut() {
        t.translation *= 0.5; // halve every bone translation
    }
}
§See also

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§