Open pop opened 2 years ago
Ping @inodentry for Cheatbook relevance.
The unofficial Bevy Cheatsheet makes it seem like this feature currently exists , but when I looked through the code this does not seem to be supported.
I got caught by this, wasted a lot of time trying to figure out what I was doing wrong...
Oh I had that in a commit but it seems I never pushed it in a PR...
It's a small change to add scenes accessible directly by their name, here: https://github.com/bevyengine/bevy/blob/997eae61854b362c10810884966ac605121e04d7/crates/bevy_gltf/src/loader.rs#L299-L301
You would need to add something like
load_context.set_labeled_asset(&format!("Scene-{}", name), LoadedAsset::new(Scene::new(world)));
The LoadedAsset::new(Scene::new(world))
part should probably called only once, so saved it in a temporary variable on line 297 and introduce a way to "alias" names.
And ideally, the same could be done for all kind of assets available from a gltf with names (materials, meshes, nodes).
Also, if someone more aware of the rendering rework could chime in, but it seems this change should be done on branch pipelined-rendering
I've fixed the misleading information in Cheatbook. Also, now there is a complete page on GLTF which goes into detail about the format and the current state of support in Bevy.
If there is anything still missing/incorrect/misleading, please file issues! :)
I don't want to waste people's time by not documenting things correctly.
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:
Could become:
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. 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 , but when I looked through the code this does not seem to be supported. Instead of correcting the cookbook, I think it's worth adding the feature.