-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
SkeletonUtils: Fix retargetClip()
duration and last frame handling.
#27653
Conversation
I've locally tested the change with the fiddle from #25288 (comment). These are the console outputs:
The duration is now correct but it seems the new keyframes are missing one entry (591 vs. 592). I would expect matching keyframe length. |
How did you calculate the FPS option? |
Also, like mentioned in this comment #25288 (comment) it could make sense to default to the original animation FPS to avoid this small alteration. |
Ah, the keyframe length is now correct!
The new suggested default makes sense to me. |
Sorry my previous commit would work in most cases but it's not guaranteed that the first track is using the most frames. In the last commit we're certain to use the correct fps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's give this a try!
retargetClip()
duration and last frame handling.
Fixed #25288
Description
Description
This PR addresses two main issues in the animation retargeting process:
Issue 1: Incorrect Delta Calculation
Problem: The calculation of the relation between
numFrames
anddelta
was incorrect.Expected Behavior: For an animation lasting 2 seconds with 3 frames spaced evenly, the expected delta should be 1s.
For a given 1.5 FPS ( 3 frames / 2 seconds ) = 1.5
amount of frames = Duration ( 2s ) * 1.5 FPS = 3 frames
New Formula: The revised formula correctly calculates the delta:
duration (2s) / (amount of frames (3) - 1) => 1s
Old Formula: Previously, the formula incorrectly calculated the delta:
1 second / FPS (1.5) => 0.666666s
Impact: This incorrect delta calculation resulted in the animation retrieving the wrong part, leading to a shortened and trimmed appearance.
Issue 2: Incorrect Last Frame in Loop
Problem: In the final loop iteration, the last frame was identical to the first frame, instead of representing the state of the last frame of the original animation.
To illustrate, here is how a 3 frame animation loop back to its start position without that fix.
Before adding if ( i === numFrames - 2 )
https://github.com/mrdoob/three.js/assets/7174039/c2bb49ef-3810-4b53-b6d4-a0e413a8140f
After
https://github.com/mrdoob/three.js/assets/7174039/226ed358-bc8d-4d38-bdde-5354b25c5953