Closed mpryor closed 1 year ago
@jollyjerr Yeah for sure!! I've been wondering about how we want to handle our core-update loop in general. The only reason this even animates after the simulation is done is because I added that random setInterval()
in, which may not be ideal.
Some things to think about:
In https://github.com/jollyjerr/mindgraph/pull/19/commits/f1ff1b77d5cb1809f9cd51e78f4a9fcdc5baf391 I fixed the easing functions so they actually work now, added a couple more easing functions, and added an example page at http://localhost:5173/tests/animexample.html
IMHO pinning the whole thing to 60fps or https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame would be fine for now!
I updated the core rendering loop to use the window.requestAnimationFrame()
per your suggestion. I also worked my way through Mozilla's Canvas tutorial, and this seems to be the preferred method for animations.
Now that the rendering loop is controlled on an interval (outside the Artist class), any re-renders that were triggered internally have been removed (during zoom, during mouseover events, etc).
With these changes, the animation stuff is pretty snappy
Starting a draft PR to play around with some animation concepts