unconed / MathBox.js

MathBox is a (work in progress) library for making presentation-quality math diagrams in WebGL.
MIT License
1.94k stars 127 forks source link

Added linear easing to animations. #2

Closed Soares closed 11 years ago

Soares commented 11 years ago

Very useful when you want to create e.g. a continuous rotating graph. Now you can do:

var n = 0; var duration = 1000; var spin = function() { mathbox.animate('surface', { worldRotation: [0, 0, n++ * τ] }, { duration: duration, ease: 'linear' }); setTimeout(spin, duration); }; spin();

For a continuous spin. I'd still like to see better support for this, but full support would require allowing properties (such as worldRotation above) to be functions that return the new result instead of being values.

unconed commented 11 years ago

I do plan to rearchitect mathbox so that expressions can be used everywhere, it is indeed the only logical outcome. This is a bit tricky to do though, because expressions should be able to return individual values rather than being expected to return an entire data array.

In your case though, you could easily just queue up an unreasonably long animation (e.g. 10 minutes) rather than repeating a short one over and over again.

For continuous animations, I do find it handier to use director.clock() on live expressions.

In the meantime, there's no harm in having linear easing though, so I'm happy to include it.