three.js icon indicating copy to clipboard operation
three.js copied to clipboard

AnimationAction wrapping on time === duration

Open alexpineda opened this issue 1 year ago • 3 comments

Describe the bug

When using AnimationAction and setting the time = duration it loops around. Just wondering if this should be changed to test > than rather than >= than.

To Reproduce See code below.

Code

animationMixer.setTime(clip.getDuration());

Expected behavior

It should not loop over until once it is passed duration.

Additional Information

In my use case each keyframe represents an exact frame and a different scripting engine puts the frames together in different orders according to the user script and calls animationMixer.setTime.

For example, the artist has a keyframe at time 0, time X, Y and finally time Z which happens to equal clip.duration. I should be able to set the animation to any of these times without it looping.

My current work around:

if (time === this.action.getClip().duration) {
      time = time - 0.000001;
}

alexpineda avatar Sep 08 '22 11:09 alexpineda

Do you mind demonstrating the issue with a small live example? Maybe based on misc_animation_keys?

Mugen87 avatar Sep 09 '22 08:09 Mugen87

Yes I will provide an example.

alexpineda avatar Sep 09 '22 08:09 alexpineda

Ok, so I made two examples, one using misc_animation_keys and the second using one of my gltf files.

The misc_animation_keys version seems to have no issue. https://codepen.io/alexpineda/pen/eYrvrbg

My gltf viewer version seems to repeat frame 9 and 0 of my example file (first and last frame ie looping over). I still don't know why. https://codepen.io/alexpineda/pen/eYrvKge

glb test file: https://drive.google.com/file/d/14JmKNSzKW2t0m0jQNbFABD-ruiGM9QfY/view?usp=sharing

alexpineda avatar Sep 17 '22 12:09 alexpineda

If we solve second example, can we change with the none equal version?

Suprhimp avatar Oct 25 '22 01:10 Suprhimp