Add option to set "_startValues" from current values
vis-prime opened this issue · comments
I don't have a concrete solution but here's the problem I faced
So i have a tween for a vector3 created like this to goes to a random value
const randomMovement = new Tween(spotLight.target.position)
.to(
{
x: MathUtils.randFloatSpread(5),
z: MathUtils.randFloatSpread(5),
},
1000
)
.easing(Easing.Elastic.Out)
.repeat(4000)
.repeatDelay(100)
.onRepeat(() => {
randomMovement.to({
x: MathUtils.randFloatSpread(5),
z: MathUtils.randFloatSpread(5),
})
})
I update the end goal on each repeat using tween.to()
but the _startValues was 0,0 initially and on each repeat it starts from 0,0 instead of whatever the current values are
hacky solution: add this in the onRepeat and onStart it works correctly
.onStart(() => {
randomMovement._valuesStart.x = spotLight.target.position.x
randomMovement._valuesStart.z = spotLight.target.position.z
})
.onRepeat(() => {
randomMovement._valuesStart.x = spotLight.target.position.x
randomMovement._valuesStart.z = spotLight.target.position.z
randomMovement.to({
x: MathUtils.randFloatSpread(5),
z: MathUtils.randFloatSpread(5),
})
})
is this usecase worth adding a new public method / alternate method ?
this is sort of like the relativeValues in docs
I think I have the same problem as you with chain() :
#643
I think I have the same problem as you with chain() : #643
so the initial mesh.position is 0,0,0 & the second tween is starting from 0,0,0 instead of where the first tween ended at , correct ?
then yea, its a similar issue
I think I have the same problem as you with chain() : #643
so the initial mesh.position is 0,0,0 & the second tween is starting from 0,0,0 instead of where the first tween ended at , correct ?
then yea, its a similar issue
Yes, I added a glitch demo with the bug.
Hey guys! This is the new expected behavior (was changed a while back). It makes the tween able to repeat exactly the same animation each time.
The previous behavior was sort of accidental and would not repeat the desired animation every time.
We have an issue for implementing that here: #522
You can see in the first example there (the "51 lines" example) one way to work around this is to make separate new
Tweens for each part of the animation, that way they always start with latest values of the object passed into new Tween
.
Also here's another way to solve it when the use case is similar to #643: #643 (comment)
Closing as duplicate of #522 (please bring any ideas you may have there 😃)