Skip to content
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

[gltf] Missing last frame during animation? #7387

Closed
tkazik opened this issue Dec 5, 2018 · 3 comments · Fixed by #8769
Closed

[gltf] Missing last frame during animation? #7387

tkazik opened this issue Dec 5, 2018 · 3 comments · Fixed by #8769

Comments

@tkazik
Copy link

tkazik commented Dec 5, 2018

Hi folks

I recently discovered an unexpected behavior. The following lines of code don't seem to play the animation till the last frame (stop at the second-last maybe?):

Cesium.when(model.readyPromise).then(
    function(model) {
        model.activeAnimations.add({
            name : 'All Animations',
        });
    }
)

Please verify that with the following model (one cube still, the other rotates by 90 degrees). Note, that there is no gap at the beginning between the cube. Once the animation has finished in Cesium, there is a slight angle between the cubes, which indicates that there is at least one frame missing. This is not the case in BabylonJS, where the the first and last frames look correct.

The model:
cube_rot_animOptimized_noAutoAnim2.zip

Some screenshots:

first_frame_cesium
First frame Cesium

last_frame_cesium
Last frame Cesium

last_frame_babylon
Last frame Babylon

Thx a lot!

@emackey
Copy link
Contributor

emackey commented Dec 5, 2018

This is an interesting one! If you play the Cesium timeline very, very slowly, the cubes will align perfectly.

But, if you play the timeline at 1x or faster, Cesium will "skip over" a tiny window of time where the animation comes to completion, and end up in the dead space after the animation has finished.

Basically Cesium is not "clamping" the animation to its final value. It properly assigns the "current" value during the animation, but then doesn't assign any new values after the end of the animation, so the final value is never set. If you've got a low framerate or a fast speed, your last animation frame could have happened at some point prior to the end of the model animation, and the very next frame could be off the end of it. That causes your model to get visually "stuck" near the end of the animation, on whatever frame happened to be the last one rendered before the time ran out.

@tkazik
Copy link
Author

tkazik commented Dec 5, 2018

Thanks for the quick analysis and insight!
I also tested different values of 'speedup' and noticed that the error becomes quite excessive for higher values (becomes noticeable for values greater than 0.1). This screenshot shows the error at the end of the animation with a 'speedup' of 50:

speedup_50

Sounds like a pretty nasty sampling issue. I assume that a fix is probably not straight-forward...or what do you think?

@emackey
Copy link
Contributor

emackey commented Dec 5, 2018

I didn't look at the code, but from the observed behavior only, I believe the fix would be to check if the current animation time is past the end of the model animation, and apply the final keyframe value from the model animation as if it were current.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants