Open lionleaf opened 6 years ago
INTERBEAN is also a bit long name for a variable you might repeat a ton of times while writing animations, anyone have a better suggestion? FBEAN? (float bean) BEAF?
Not sure I follow. This PR would make INTERBEAN piecewise linear with the slope depending on bpm and fps already, right?
There is no guarantee that there is a fixed number of frames in each BEAN. In this example, bpm is 125, subdivision is 4 and fps is 60.
Not a completely straight line:
So, if you were to use INTERBEAN e.g. like this:
this.ball.position.x = Math.sin(INTERBEAN);
then the animation will speed up and slow down ever so slightly all the time.
Yes, we agree about the current behaviour then. It is piecewise linear and certainly not just a straight line.
I went back to find the original use case that motivated this:
Basically it's used for animations between states that complete on a beat. (In this case the rotation of the cube).
And since there could be different amounts of frames between beats you do want the rotation speed to vary.
You're right though, this could easily be used in scenarios where you want/expect a constant speed.
An alternative that would also solve the motivating scenario would be a number that goes 0.0 -> 1.0 between each beat?
Also happy to make the decision that this is more confusing than useful and close this PR.
Maybe we can just give it a name that implies the piece-wise-ness strongly enough and merge that.
Adds new global variable INTERBEAN, which is a float that is interpolated between BEAN numbers, in a linear way between frames. This can be used to key animations without getting the lower frame rate of BEAN.
Discussion to be had here: Can we instead change BEAN to have fractional values? The way I see it that would be the preferred option here, but I'm afraid of changing behaviour if people have already relied on it being an integer somewhere.