Support loading GLTF assets by name
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## What problem does this solve or what need does it fill?
To improve ergonomics of loading GLTF assets, Bevy ought to support loading GLTF assets (Mesh/Primitive/Material/Texture/Node/Scene) by Name as well as by Index
## What solution would you like?
Add the ability to fetch assets by name. Something like this:
```rust
let my_gltf_scene_handle = asset_server.load("my_scenes.gltf#Scene1")
```
Could become:
```rust
let my_gltf_scene_handle = asset_server.load("my_scenes.gltf#Scene:'Winter Scene'")
```
This should _probably_ be _additive_. Users can fetch GLTF assets with either Indexing or Naming.
If you think this feature is worth adding, I would be more than happy to implement it! I am enjoying Bevy and would love to contribute. 😄
## What alternative(s) have you considered?
One could use the [`named_scenes` field on the GLTF struct](https://github.com/bevyengine/bevy/blob/6d6bc2a8b4c243a670b34032de8ed9dec7d70d44/crates/bevy_gltf/src/lib.rs#L31). One would load the GLTF asset file and then spawn specific scenes from the already loaded GLTF asset. In my opinion is not as ergonomic as it could be.
## Additional context
The unofficial Bevy Cheatsheet [makes it seem like this feature currently exists](https://bevy-cheatbook.github.io/features/assets.html?highlight=includes%20names/label#assetpath-and-labels) , but [when I looked through the code](https://github.com/bevyengine/bevy/blob/997eae61854b362c10810884966ac605121e04d7/crates/bevy_gltf/src/loader.rs#L554-L580) this does not seem to be supported. Instead of correcting the cookbook, I think it's worth adding the feature.
Contributor guide
Assessment
This issue has not been assessed yet.