bevyengine / bevyengine/bevy

Keep original Scene -> Node Mapping in GLTF Asset Loader

Open
#3,511 1 comment 0 reactions 0 assignees View on GitHub
A-Assets A-Scenes C-Feature C-Usability
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## What problem does this solve or what need does it fill?

I want to build a GLTF viewer that shows both the scene as well as the tree structure of a given GLTF scene.

For that to work I need to know which nodes are the basis of a scene.
However currently all nodes just get added to the bevy Scene and it is impossible to tell which nodes created that scene.
https://github.com/bevyengine/bevy/blob/1d0d8a3397bd6fc2c14d42ffd0668d2443748912/crates/bevy_gltf/src/loader.rs#L283-L294

## What solution would you like?

I would like to keep a field `scenes_to_node: HashMap, Vec>>` in the Gltf file
that preserves this information.

## What alternative(s) have you considered?

I could load the file with the [gltf::GLTF](https://docs.rs/gltf/latest/gltf/struct.Gltf.html) struct myself, get the indices of the nodes and then look them up in the `nodes` field of [`bevy::gltf::Gltf`](https://docs.rs/bevy/latest/bevy/gltf/struct.Gltf.html).

However this would require the program to load the file twice (and likely one time blockingly).

## Additional context

I believe the implementation to be fairly trivial. If there is support/acceptance for this feature I'm willing to implement it myself, however I first wanted to reach out here.

Contributor guide

Open the contributing guide

Research direction

Start in crates/bevy_gltf/src/loader.rs at the linked scene-loading code, then inspect the Gltf asset's existing scene and node handle fields. Preserve the original scene-to-node relationships in the proposed mapping, and verify that each loaded scene identifies the nodes that created it.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.