michaelvillar / dynamics.js

Javascript library to create physics-based animations
http://dynamicsjs.com
7.57k stars 414 forks source link

Weird Issue Animating Object Propery #11

Closed JohnLouderback closed 8 years ago

JohnLouderback commented 9 years ago

I have the following code: dynamicsweirdness1 which, should, in theory, animate the zoom property on the Camera object to the specified value. However, the behavior I'm seeing is very strange where only the first few frames animate and then it spends the rest of the duration setting the value to the end value: dynamicsweirdness2 This seems like a bug, but if perhaps I'm doing this incorrectly, please let me know.

michaelvillar commented 9 years ago

Where's the Camera object from? Some library like Threejs?

JohnLouderback commented 9 years ago

It's custom code I've written, the source of which is written in TypeScript.

Here's the TypeScript code:

class Camera {
    public static x: number = 0;
    public static y: number = 0;
    private static _zoom: number = 1;
    public static get zoom(): number {
        return Camera._zoom;
    }
    public static set zoom(value) {
        Camera._zoom = value;
        StatusBar.editorZoomStatus.text = StatusBar.editorZoomText;
        console.log('zoom now = ' + value);
    }
}

which in turn is compiled to:

var Camera = (function () {
    function Camera() {
    }
    Object.defineProperty(Camera, "zoom", {
        get: function () {
            return Camera._zoom;
        },
        set: function (value) {
            Camera._zoom = value;
            StatusBar.editorZoomStatus.text = StatusBar.editorZoomText;
            console.log('zoom now = ' + value);
        },
        enumerable: true,
        configurable: true
    });
    Camera.x = 0;
    Camera.y = 0;
    Camera._zoom = 1;
    return Camera;
})();
JohnLouderback commented 9 years ago

Any news on this?

michaelvillar commented 9 years ago

Sorry, just seeing this now. I'm not sure setter/getter is supported, I'd assumed it would but maybe if it doesn't work it comes from that?

michaelvillar commented 8 years ago

After a further look at this, this seems unrelated to dynamics