How should I be controlling chained tweens? #684
Unanswered
MNewbigging
asked this question in
Q&A
Replies: 1 comment
-
By using a getBobAnimation(object) {
const up = new TWEEN.Tween(object.position).to({ y: 1 }, 1000);
const down = new TWEEN.Tween(object.position).to({ y: 0 }, 1000);
up.chain(down);
down.chain(up);
// Create a TWEEN.Group to manage the animations
const group = new TWEEN.Group();
group.add(up);
group.add(down);
return group;
}
const bob = getBobAnimation(object);
bob.start();
onMouseClick = () => {
bob.pause();
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there,
I could do with some advice on a problem I'm having. I've just started with tweenjs, so I'm sure there's something I'm missing!
I'm trying to make an animation on a threejs object where it bobs up and down, and where I can pause the animation on click:
The bob animation runs fine, but I can only pause it during the
up
portion, because that's what I returned in the above function. I thought theTWEEN.Group
might help, but that seems to just be an array with some updating logic thrown in.So I wrote this:
But this just seems a bit overkill to me! So, to my question - is there some other way to achieve what I want here without writing the above class? Is it possible to hold a single reference to multiple chained tweens, and control them all via singular calls like the above class provides?
Thanks for reading :)
Beta Was this translation helpful? Give feedback.
All reactions