-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Move loop-animation component to each object instead of scene #6153
Conversation
Thinking whether we can convert from object-level https://github.com/mozilla/hubs/blob/051996a9e158a0bcff8c5ebb38590af92870fa3f/src/inflators/model.tsx#L141-L143 As I wrote somewhere, I think scene-level is easier implement, more intuitive, and better maintainability and want to update Honestly I'm very biased tho, I prefer scene-level |
Will a scene-level loop-animation handle objects dropped in-room correctly? |
Every dropped glTF is a scene and it will has it's own mixer to manage all the scene animations so it should work correctly.
This will effectively be the same as you were doing just done at an earlier stage. I agree on that having a scene level loop-animation makes more sense but that would require some component redesigning to add some extra info. Now you can set different animation parameters like offset and timeScale so the scene component would need support to individually set those per animation. Independently from where we place the component (scene or object) we should move the Blender component from using the animation name to using the index as now we have a problem with animations that use the same name as when we look for the animation among all the scene animations, we always pick same one as there is no way to tell which animation is the one targeted to a specific object so we end up re-targetting the first one to all the objects using that name. That would allow us to eventually simplify this: |
If you feel this PR approach is correct for now we can focus on landing this and look into updating the architecture later to now delay the newLoader release anymore. |
I first want to understand the problem correctly that this PR want to resolve.
Like this?
And the problem is that it is unclear what If so, honestly I still don't get how keeping |
@takahirox It depends. That's one way, another way has it combined together into one animation with multiple channels/samplers. Exporting multiple objects with the same action seems to result in what you have above, while exporting multiple tracks with the same name (for multiple objects) seems to result in the multiple channels/samplers. Here's a text based glTF file exported from Blender 3.6 to showcase this: |
@takahirox When different objects have different animations with the same name in Blender they are all exported as different animations with same name in the Then we look for the animation that matches the clip name here: And we create the animation clips here: As they all have the same name we always get the first
With this PR we move the As I mentioned before this behavior is NOT what we want, we don't want to re-target animations we want to run the right clip on the scene level mixer. Giving this another thought another maybe simpler solution would be to add a pre-process stage to the GLTF loader and replace the "clip" field in the Let me know what you think and maybe we can take that approach better. |
Some comments, I'm confused...
Even if we move Do we assume that the same named animations have the same animation data? Is it a safe assumption?
Honestly I still don't get why node level Update: I found the hack. Here in Three.js the (optional) root node is used as animation target object if target object is unfound. If I'm right this is a hidden behavior so it may be dangerous to rely on it. Actually this fallback is removed in the latest Three.js mrdoob/three.js#25329 I agree with removing the fallback as more straightforward Three.js API. And probably animations may not be retargeted correctly in some cases. What I came up with so far are Case 1: An animaton that targets multiple nodes will end up with retargetting only the optional root node.
Case 2: If original target node is under the optional root node, the optional root node is not chosen as target node.
I'm feeling more and more that the current |
I guess perhaps we had assumption that animations that have the same name have the same animation data and animation target in a clip is only root node having from
to
The same animation data content are referred from original and cloned |
Made a PR #6183 |
Closing in favor of #6183 |
When two animation clips with the same name are targeted to different objects we are playing always the first one and the second one is never played.
This used to work fine in AFrame because we used to re-targe animations based on the object where
loop-component
was attached but with the bitECS migration we ignore the objects components and we attach oneloop-animation
component to the scene root so we can't re-target anymore as we have lost the reference of which objects play animations.Note: This works fine in most cases but it fails when several objects are using the same animation name which seems to be pretty common (as I've seen this in different assets lately)
This PR addresses this issue keeping the
loop-animation
component attached to the original object so the animations can be correctly re-targeted.As it's widely commented in the code, it makes sense to have only one
loop-animation
at the scene level that handles all the animations in the scene but that would require quite some refactoring to move the component to the scene level. What we could easily do is updating the Blender component to use the glTF animation index instead of the clip name as that one it's unique so we can at least do the component transform that we are doing and each clip would be correctly played in its related object. I'll open an issue to update the Blender component and start using that instead of the clip name.Use this model for testing.
Frustum.glb.zip
Frustum.blend.zip