How to add animations files to a gltf model using R3F?

Hello everyone)

Please tell me how to add animations to the gltf model.

export const useAvatar = () => {
    const avatar = useGLTF("/assets/avatars/y-bot.gltf");
    const {actions, names} = useAnimations(avatar.animations, avatar.scene);

    const {animations} = useCollection("Animations"); // array of links to animation files on firebase

    return {avatar, actions, names};
}

currently avatar.animations === . I get the animations separately and want to add them to the model only when needed

here’s a demo

2 Likes

Wow, that’s a really cool example. Thanks) I took your R3f course on Udemy. I really liked it)

1 Like