Replies: 2 comments 1 reply
-
Animation names are optional, so we don't have a guarantee that there is one. It's also not possible in the current asset system to have two labels for the same asset. So in a case where multiple animations but some without names, there would be a mixed of names and index with holes... Exposing the indexes is the only way for now to have something consistent... Also, if you load the whole gltf, you will have access to animations by name |
Beta Was this translation helpful? Give feedback.
1 reply
-
I ended up writing a little deno script to find the indices: const animations = ["Foo","Bar"]
let buff = await Deno.readFile('my-file.gltf')
let txt = new TextDecoder().decode(buff)
let gltf = JSON.parse(txt)
const indices = animations.reduce((acc, name) => {
acc[name] = gltf.animations.findIndex(anim => anim.name === name)
return acc
}, {})
console.dir(indices) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello. Does anyone know why GLTF loader uses indices instead of names to reference animations?
Relevant code (https://github.com/bevyengine/bevy/blob/main/crates/bevy_gltf/src/loader.rs#LL205C28-L205C28):
Because of this, to get a handle to an
AnimationClip
you have to do something like this:I could not find any discussion regarding this or any comment explaining why it was implemented this way.
This does not seem very friendly for developers, since there's no way to know which animation occupies which index without going through each one and checking manually or using a separate system to figure that out.
Beta Was this translation helpful? Give feedback.
All reactions