-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Allow users to fix glTF coordinate system imports #19633
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
Allow users to fix glTF coordinate system imports #19633
Conversation
You added a new feature but didn't update the readme. Please run |
Will fix the CI and expand the PR description in a few minutes :) |
I would prefer them to be fixed in this PR. Introducing temporary changes in examples makes it harder to sort actual regressions |
Sure, can do :) |
We should remove the term "simply" entirely and make sure that phrasing is not used in the migration guide. |
@ChristopherBiscardi done. Also, I fixed the CI and expanded the PR description. Right now I'm porting all examples, but that will take quite a while. This PR can be merged in the meantime without any issues, as the flag is not enabled by default yet |
It looks like your PR has been selected for a highlight in the next release blog post, but you didn't provide a release note. Please review the instructions for writing release notes, then expand or revise the content in the release notes directory to showcase your changes. |
Now that this is opt-in and not breaking, I want a brief release note to gather feedback please. |
@alice-i-cecile done 👍 |
# Objective - Followup to #19633 - As discussed, it's a bit cumbersome to specify that you want the correct orientation every single time - Also, glTFs loaded from third parties will still be loaded incorrectly ## Solution - Allow opting into the new behavior globally or per-asset - Also improved some docs while on it :) ## Testing - Ran the animation examples - Ran the test scene from the last PR with all configuration combinations
…e#19685) # Objective - Followup to bevyengine#19633 - As discussed, it's a bit cumbersome to specify that you want the correct orientation every single time - Also, glTFs loaded from third parties will still be loaded incorrectly ## Solution - Allow opting into the new behavior globally or per-asset - Also improved some docs while on it :) ## Testing - Ran the animation examples - Ran the test scene from the last PR with all configuration combinations
# Objective Fix glTF coordinate conversion not converting tangents. <img width="995" height="565" alt="image" src="https://github.com/user-attachments/assets/20aada7a-39fe-4527-b257-c5efb4555aaf" /> Report: https://discord.com/channels/691052431525675048/692572690833473578/1405362252617355335 Thread: https://discord.com/channels/691052431525675048/1405451520836898848 ## Solution Fixed by removing a redundant copy of the tangent attributes. In #5370 attribute copying was moved to a more generic function (see `convert_attribute`). But one code path was left behind, so the tangents are actually copied twice. This is technically a bug, but a harmless one since both copies are the same. Later on, #19633 added the option to convert attribute coordinates. But only the first tangent copy (in `convert_attribute`) applies the conversion - the second copy will overwrite them with unconverted values. This PR removes the second copy. There's also some minor code quality tweaks - prefer `contains_attribute()` to `attribute().is_some()`, and fixed some bad indentation in log macros. I can revert these if we want to play it safe. ## Testing Tested a modified version of example `load_gltf` with and without feature `gltf_convert_coordinates_default`. Also tested after hacking the loader to use the code path where tangents are recalculated.
Objective
Fixes #5670 as an opt-in for now
glTF uses the following coordinate system:
and Bevy uses:
For the longest time, Bevy has simply ignored this distinction. That caused issues when working across programs, as most software respects the
glTF coordinate system when importing and exporting glTFs. Your scene might have looked correct in Blender, Maya, TrenchBroom, etc. but everything would be flipped when importing it into Bevy!
Solution
Add an option to the glTF loader to perform coordinate conversion. Note that this makes a distinction in the camera nodes, as glTF uses a different coordinate system for them.
Follow Ups
Testing
I ran all glTF animation examples with the new setting enabled to validate that they look the same, just flipped.
Also got a nice test scene from Chris that includes a camera inside the glTF. Thanks @ChristopherBiscardi!
Blender (-Y forward):

Bevy (-Z forward, but the model looks the wrong way):

Bevy with

convert_coordinates
enabled (-Z forward):Validation that the axes are correct with F3D's glTF viewer (+Z forward):
