CreateJS / TweenJS

A simple but powerful tweening / animation library for Javascript. Part of the CreateJS suite of libraries.
http://createjs.com/
MIT License
3.56k stars 967 forks source link

Do not tween inherited properties #79

Closed ghost closed 7 years ago

ghost commented 8 years ago

I'm using TweenJS with Three.js and this is very annoying. For example, I can't easily operate with THREE.Vector instances because of large amount of their inherited properties. Simple "Tween.get(vector1).to(vector2)"-pattern is inefficient for now.

a._cloneProps = function(a) {
    var b = {};
    for (var c in a) // if (a.hasOwnProperty(c)) would be nice here
        b[c] = a[c];
    return b
}
gskinner commented 7 years ago

Interesting. Totally see the use case here of passing a typed DTO. I am a little concerned that in some cases people will want the inherited property to come through, and it will be confusing why it doesn't.

As an aside, the actual implementation would require a check in the for...in loop(s) in _appendProps. It's also complicated by the fact that we now delete properties of the props object if a plugin tells us to ignore it.

I'm going to take a look at this to see if I can identify a good solution. In the interim, you could just run the DTO through a simple clone method to output a generic object with the values you want.

gskinner commented 7 years ago

I addressed this issue in 3d23dedaf915964a2dd390fb7b53234fbfa23ab4, feedback welcome.