-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Rebrand glTF coordinate conversion to an alternative strategy that is biased towards glTF models #20131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
janhohenheim
wants to merge
9
commits into
bevyengine:main
Choose a base branch
from
janhohenheim:gltf-coords-opt-in
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Rebrand glTF coordinate conversion to an alternative strategy that is biased towards glTF models #20131
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
777e28e
Revert "Nudge users into migrating to new default glTF coordinate con…
janhohenheim 105a0d1
Rename option
janhohenheim 6f9e196
Adjust guide
janhohenheim df8f6d6
Add PR
janhohenheim b8d0852
Update crates/bevy_gltf/src/loader/mod.rs
janhohenheim ff9b18c
Update crates/bevy_gltf/src/lib.rs
janhohenheim 5591166
Merge branch 'main' into gltf-coords-opt-in
janhohenheim b04db5b
Rename
janhohenheim 4165726
Add PR
janhohenheim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
title: Allow importing glTFs with corrected model forward semantics | ||
authors: ["@janhohenheim"] | ||
pull_requests: [19633, 19685, 19816, 20131] | ||
--- | ||
|
||
Bevy uses the following coordinate system for all worldspace entities that have a `Transform`: | ||
|
||
- forward: -Z | ||
- up: Y | ||
- right: X | ||
|
||
But glTF is a bit more complicated. Models in glTF scenes use the following coordinate system: | ||
|
||
- forward: Z | ||
- up: Y | ||
- right: -X | ||
|
||
but cameras and lights in glTF scenes use the following coordinate system: | ||
|
||
- forward: -Z | ||
- up: Y | ||
- right: X | ||
|
||
As you can see, this clashes with Bevy assumption that everything in the world uses the same coordinate system. | ||
In the past, we only imported glTFs using the camera / light coordinate system for everything, as that is already aligned with Bevy. | ||
In other words, the glTF importer simply assumed that glTF models used -Z as their forward direction, even though they use +Z. | ||
|
||
But that meant that on the Bevy side, a glTF model's `Transform::forward()` would actually point backwards from the point of view of the model, | ||
which is counterintuitive and very annoying when working across different art pipelines. | ||
|
||
To remedy this, users can now change the import behavior to instead favor correct `Transform::forward()` semantics for models. | ||
The downside is that glTF cameras and lights that have a global identity transform in glTF will now look to +Z instead of -Z in Bevy. | ||
This should not be a problem in many cases, as the whole scene is rotated so that the end result on your screen will be rendered the exact same way. | ||
|
||
To globally opt into the behavior that favors glTF models over glTF cameras, you can set `GltfPlugin::favor_model_coordinates`: | ||
|
||
```rust | ||
App::new() | ||
.add_plugins(DefaultPlugins.set(GltfPlugin { | ||
favor_model_coordinates: true, | ||
..default() | ||
})) | ||
.run(); | ||
``` | ||
|
||
You can also control this on a per-asset-level: | ||
|
||
```rust | ||
let handle = asset_server.load_with_settings( | ||
"fox.gltf#Scene0", | ||
|settings: &mut GltfLoaderSettings| { | ||
settings.favor_model_coordinates = Some(true); | ||
}, | ||
); | ||
``` | ||
|
||
Setting the above to `None` will fall back to the global setting taken from `GltfPlugin::favor_model_coordinates`. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.