-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Closed
Description
I used the code to create an animation, but when I wanted to re-execute the last one after the execution of the last animation, the THREE.AnimationMixer's finished event produced an infinite loop and was in great need for your help.
This is my code:
function createAnimation() {
mixer = new THREE.AnimationMixer(model);
mixer.addEventListener('finished', function (e)
{
var curAction = e.action;
var clip = curAction.getClip();
var len = clip.tracks.length;
while (len--) {
var kf = clip.tracks[len];
var vc = kf.values.length;
while (vc--) {
var value = kf.values[vc];
if (value > 0) {
kf.values[vc] += 10;
}
}
}
curAction.stop();//Is there a need to restore other parameters to stop the current animation? please help me
//When an animation is executed again, the state should not be completed
curAction.play();//The finished event was fired immediately when playing again
});
var positionGo = new THREE.VectorKeyframeTrack('.position', [0, 3], [0, 0, 0, 0, 0, 50]);
var moveClipGo = new THREE.AnimationClip('Move_Car_Go', -1, [positionGo]);
var moveActionGo = mixer.clipAction(moveClipGo, car);
moveActionGo.clampWhenFinished = true;
moveActionGo.loop = THREE.LoopOnce;
moveActionGo.play();
}