Animation separation
I’ve noticed that many users have a need to load models and animations separately—for example, loading the mesh from one GLB file and the animation from another. However, since the glTF specification does not rely entirely on names and instead uses array indices, this can lead to situations where some bones have no names or where names are duplicated.
Therefore, if the bone names exist and are unique, it becomes possible to separate the animation sequence from the model. When loading the animation sequence, the bones can be bound to the model based on their names.
So, is it possible to export the animation as a separate file after loading the glTF into an asset? This would allow for delayed loading later and would be very helpful for projects that require dynamic animation streaming or animation separation.
I’ve looked into this, and it’s not very complicated, but it might require some modifications to Filament’s source code. If this approach is acceptable, I could consider helping implement this functionality. It’s also something I currently need.
If you have an idea on how to do it, maybe you could briefly outline your approach/design here in this issue? And would you like to contribute to this via a PR?
First of all, I have this need myself, and I noticed that quite a few people in the issues have similar needs. So I think this feature is somewhat necessary. I was wondering if we could discuss whether implementing it this way would be reasonable?
There is a key issue here: the glTF standard does not enforce naming requirements for bones. If there are duplicate names or missing names, a glTF loaded lazily will not be able to correctly match the already loaded bones.
So I think the prerequisite for loading the mesh and animation separately is that the bones must have names and those names must be unique.
If this can be ensured, bones can be bound later by their names.
If the above condition is met, the animations in the gltfio library can be saved to a file. The only change is that the references to bones inside would switch from using Entity to using the corresponding names.
When loading the animation, the corresponding Entity can be found by name, and the Animation objects can be reconstructed accordingly.
The overall implementation shouldn’t be too complicated, but it seems there are some limitations as well. @poweifeng
I think it probably makes sense to just adopt a more complete animation system like ozz (https://github.com/guillaumeblanc/ozz-animation) and feed the matrices to filament.
I also tend to think this problem could be solved outside of filament. Maybe what we need to do is add the bare minimum functionality (if missing) that would allow a filament user to implement this themselves outside of filament.