Add bevy_gltf settings for animation player and target creation
#22046
+148
−55
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.
Objective
Enable features like keeping meshes and animations in separate glTFs, and binding meshes to another mesh's animation player.
Background
When
bevy_animationis enabled,bevy_gltfwill:AnimationPlayercomponent.AnimationTargetIdcomponent, and anAnimatedBycomponent that points to the root node.This works well for glTFs that are self-contained meshes with animations. But it fails for two cases:
AnimationTargetIdcomponents so it can bind to animations.AnimatedByandAnimationPlayercomponents created automatically - theAnimatedBycomponents will be created separately when binding to the other mesh's player.Solution
Add these settings:
So for the two example cases:
CreateAnimationTargetIds::Always.CreateAnimationTargetIds::Alwaysif necessary, andCreateAnimationPlayers::Never.The PR also moves the component creation code from
load_nodeto where the scenes are created. This made the logic a bit simpler, and I think it's nicer if everything is done in one self-contained step rather then being mixed in with other per-node work.Testing
Tested every combination of settings on a few glTFs with and without animation. Also: