Help with playing animation backwards
ChaerilM opened this issue · comments
// Check if the animationName has a previous timescale value; default to 1 if not
const timeScale = animationTimeScales[animationName] || 1.0
const clampWhenFinished = (timeScale === 1.0)
const startAt = (timeScale === 1) ? 0 : 1000 // crossFadeDuration * 1000ms
console.log(timeScale)
model.removeAttribute('animation-mixer')
model.setAttribute('animation-mixer', {
clip: animationName,
loop: 'once',
crossFadeDuration: 1,
timeScale,
clampWhenFinished,
startAt,
})
// Store the new timescale for this animationName
animationTimeScales[animationName] = timeScale * -1.0
i had code like above, animation in blender was 60 frames. using crossFadeDuration:1
i'll get a 60fps animation. after that i set timeScale
to -1 so it will play backwards. It does play backwards, but it was played in instant. how to get the same speed as when i'm playing it forward.
The crossFadeDuration is for the duration to cross fade between animations. Does your animation is 1s? Probably not, so the startAt is probably wrong here, and this option is mainly useful when you don't have named animations if I remember.
I did a quick experiment with https://c-frame.github.io/aframe-extras/examples/animation-controls/ setting time scale at -1 and the Death animation for example with loop once, and switching between animation, but yeah it doesn't work, and startAt is no useful here because we have named animations.
The loop ping pong works correctly.
I'm not sure how to reverse an animation here, I don't have the answer right now.
Here is an example that works, and an explanation for why it works. GLBanireverse