-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
animation repository #360
Comments
Skype discussion: [9/14/15, 10:53:56 AM] Sam Reid: BRAINSTORM:
// Integrated support for animation in scenery. Specify target values and durati
var animationHandle = node.animateTo({x:100,y:100,opacity:0.5},{animationTime:100,type=‘quadratic’});
// Use the handle to communicate with the animation.
animationHandle.stop();
|
Input from @samreid @jonathanolson @jbphet @aaronsamuel137 @jessegreenberg requested. |
Related to #358 (managing Tween animations). If we had a common library for animations, this would be easier to assess and fix. |
One issue for using Tween.js is that when an animation starts, it copies all properties of the animated object. This means calling getters for things like get x() get y() get matrix(), etc. This is why we have settled on the patten of passing an object literal instead of a scenery node to be tweened, then passing the values through to the scenery node. One step we could in making a superior API would be to automatically create this proxy--that would help us get rid of a great deal of duplicated code. Or we could fork or rewrite the important tween.js behavior as desired. At one point I forked tween.js to use the keys in the target instance to determine which original values to copy from the animated object. |
@samreid wrote:
You're referring to what is typically called the 'patterns' literal, correct? Eg: var someNode = ...
var parameters = { opacity: 0 };
var tween = new TWEEN.Tween( parameters )
.to( { opacity: 1 }, 500 )
.onUpdate( function() {
someNode.opacity = parameters.opacity;
} )
... |
I presume you meant the |
Yep, |
So it appears there are actually 2 issues at play here:
We should discuss both independently--TWEEN.js uses a different convention for its API than we use throughout our libraries. |
My recommendations:
|
From Sept 24 meeting: we would like the API to automatically handles cancelling previous animations (if any) |
9/24/14 dev meeting: |
Unassigning for now. I'll revisit when I start adding animation to function-builder. |
@pixelzoom just a ping since you are moving nicely on function builder |
No plans to work on this in the immediate future. The animation functions in function-builder currently consist of only FadeIn and FadeOut. There will undoubtedly be others, but I'm not there yet. And designing a general library is definitely not on my radar at this point - and might not be until function-builder is well along. |
3/10/16 dev meeting: It would be nice to be able to wrap Tween (versus using it directly in sim code) so that we can test the animation library when we update to a new version of Tween. |
It looks like the new Tween.js has Universal Module Definition: https://github.com/tweenjs/tween.js/blob/master/src/Tween.js // UMD (Universal Module Definition)
(function (root) {
if (typeof define === 'function' && define.amd) {
// AMD
define([], function () {
return TWEEN;
});
} else if (typeof module !== 'undefined' && typeof exports === 'object') {
// Node.js
module.exports = TWEEN;
} else if (root !== undefined) {
// Global variable
root.TWEEN = TWEEN;
}
})(this); So perhaps it does not need to be a global. |
@pixelzoom can this issue be closed now that we have twixt? |
Yes. |
I've used Tween in 2 sims - Hooke's Law, and now Function Builder. It's used in 13 other sims, where there is duplicate code and varying patterns to accomplish similar animation tasks. Proposal: Rather than embedding Tween this heavily in sims, how about writing wrappers for common animation tasks? This would reduce duplicated/different code, promote reuse, and make it easier to switch to some other animation library in the future. Wrapper examples in function-builder, FadeIn and FadeOut. Thoughts?
The text was updated successfully, but these errors were encountered: