Dok11 / easy-prop-animation

EasyPropAnimation is a helpful class for Babylon.js that allows you easy to runs a property animations
MIT License
3 stars 0 forks source link

Multiple animation snapping to end #1

Closed Link2Twenty closed 1 year ago

Link2Twenty commented 1 year ago

Hi, when I have multiple animations with different durations all animations seem to snap to their final frame when the first duration is reached.

EasyPropAnimation.run(scene.activeCamera, {
  position: [camera.x, camera.y, camera.z],
  target: [camTarget.x, camTarget.y, camTarget.z],
  transition: 'target 0.5s cubic-bezier(0.4, 0, 0.2, 1), position 1.5s cubic-bezier(0.4, 0, 0.2, 1)',
});

I've fixed this in a local version of your code by converting all animations to an animation group and then playing, and returning, that animation group at the end of the run functions. I'm happy to do a pull request if that's the route you want to take.

An added bonus of using animationGroup is you gain observables on the entire group like so

console.log('animation start');

const anim = EasyPropAnimation.run(scene.activeCamera, {
  position: [camera.x, camera.y, camera.z],
  target: [camTarget.x, camTarget.y, camTarget.z],
  transition: 'target 0.5s cubic-bezier(0.4, 0, 0.2, 1), position 1.5s cubic-bezier(0.4, 0, 0.2, 1)',
});

anim.onAnimationGroupEndObservable.add(() => console.log('animation end'));

Thanks 😊

Dok11 commented 1 year ago

Thanks for feedback. I have fixed this bug locally via beginDirectAnimation, and will push updates in a day.

Dok11 commented 1 year ago

An added bonus of using animationGroup is you gain observables on the entire group like so

Intresting idea, I'll check this later, thank you!

Dok11 commented 1 year ago

An added bonus of using animationGroup is you gain observables on the entire group like so

Yes, I think it is a great idea, so, since 1.0.3 this library returns an AnimationGroup! 😃