google / model-viewer

Easily display interactive 3D models on the web and in AR!
https://modelviewer.dev
Apache License 2.0
6.88k stars 816 forks source link

Animations that end on intervals of 24-frames incorrectly return to their starting frame early #4050

Open cpiggott opened 1 year ago

cpiggott commented 1 year ago

Description

Something interesting that I have noted with animation today is that any animations that use 24fps and finish on an interval of 24 have an issue in Model Viewer. I have an animation that is 120 frames @ 24fps and an animation that is slightly longer 124 frames @ 24fps. The one that is 120 frames snaps back to the initial starting point of the animation before the animation completes when looping is turned off, but the animation that is 124 frames will stop at the end of the animation and then stay in place.

First, add the cubeanum.glb to the Model Editor and uncheck "Play" on the animation tab, dragging the slider all the way to the end(5.0 seconds), and the cube will snap back to its original location in the animation, but the animation frame is still at the end.

If you then upload the cubeanim_fixed.glb to Model Editor and do the same, you will see when the animation slider is dragged out to the end of the animation(5.04 seconds), the cube stays in the last frame of the animation and does not snap back. I have tested this with 3-second and 4-second animations as well, with the same breaking result where the animation snaps back to the original keyframe.

Broken: cubeanim.glb Working: cubeanim_fixed.glb

If you don't want to download these files, create an animation in Blender where the keyframes end at an interval of 24fps.

Live Demo

Repro via Model Editor. I have provided two different GLBs above.

Version

Browser Affected

OS

AR

elalish commented 1 year ago

Yeah, that's not too surprising; I had to fight the three.js animation mixer pretty hard to get it to work this well. Would you mind checking if any of the prior releases worked properly? If so, something may have changed upstream that we have to account for.