bevyengine / bevyengine/bevy

Improve glTF load ergonomics

Open
#20,987 2 comments 0 reactions 0 assignees View on GitHub
A-Assets A-glTF C-Feature D-Modest S-Needs-Design
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?

A quick GitHub search shows the following usages:
- `GltfAssetLabel::Scene(0`: 916 hits
- `GltfAssetLabel::Scene(1`: 11 hits
- `#scene0 language:Rust`: 1.8k hits
- `#scene1 language:Rust`: 70 hits

IME, most people don't want a specific scene in a glTF out of a selection of possible scenes. They just want "the scene" in the glTF. Having to specify scene 0 everywhere is unnecessary noise in most cases IMO.

Let's take a peek at Godot: https://github.com/godotengine/godot/blob/ee87ee8332280a45473e96cc5acf6d9dd6130292/modules/gltf/gltf_document.cpp#L566-L597

This tells us that Godot uses the glTF default scene if present, and scene 0 if not.

## What solution would you like?

Allow this:
```rust
let scene: Handle = assets.load("foo.glb");
```
by loading the default scene if present, and scene 0 if not. Note that a glTF file doesn't *need* any scenes to be valid, so that should result in an error message.

The type system already says that this should be loaded as a scene, so let's use that information :)

## What alternative(s) have you considered?

- Leave it as-is
- Add a syntactic shorthand for "default scene" + `GltfAssetLabel::DefaultScene` (or similar)
- Only load the default scene and not fall back to scene 0 if not present
- Have some GUI for importing a glTF and exporting BSN, then only loading BSN in code

## Additional context

This recently hit a very experienced rendering contributor, showing that this is a footgun even for experienced devs

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.