GLTF loader loses information about names in heirarchy
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
`bevy_gltf::Gltf` should store names in a way that makes it possible (and hopefully easy) to reconstruct the heirarchy, including names, that was in the gltf json.
Currently, doing anything involving names inside a Gltf scene is very difficult. E.g. if I want to use some special name to mark whether a node is for collisions or for rendering or both, I can't.
Currently, `bevy_gltf::Gltf` stores information in a way makes it impossible to reconstruct the node hierarchy with node names. Names are retained only in a mapping from `name->Handle`, but the heirarchy is stored as copies of child GltfNodes, so their identites are lost:
pub struct GltfNode {
pub children: Vec,
pub mesh: Option>,
pub transform: bevy_transform::prelude::Transform,
}
A workaround is to first load the gltf json using the `gltf` library directly, extract whatever structure is needed, and then use indices to find the corresponding nodes and meshes in the `bevy_gltf::Gltf` data.
Also, it *is* possible to reconstruct the *mesh* names, since meshes are stored as handles in the `GltfNode` heirarchy.
The simplest solution would be to just add `pub name: Option` to `GltfNode`.
Probably better would be to reorganize `struct Gltf` a little bit to avoid the redundancy. E.g. change `children` to a vec of indices instead of copies of the `GltfNode` struct, and generally stick closer to the index-based structure in the gltf file (which is easier to work with than the bevy_gltf transformation of it.). The created `Scene` objects could also get `Name` components where appropriate.
(I'm happy to do make this change unless there's some objection).
Contributor guide
Assessment
This issue has not been assessed yet.