ChristopherChudzicki / mathbox-react

BSD 3-Clause "New" or "Revised" License
14 stars 3 forks source link

animation loop pause / slowdown? #19

Open sritchie opened 2 years ago

sritchie commented 2 years ago

math3d.org has a nice system for slowing down the render loop on static scenes when the user's not interacting with them.

While porting over @znah's notebook example in the Mathbox repo, I noticed this snippet for pausing a Mathbox instance's render loop when it's offscreen: https://github.com/unconed/mathbox/pull/17/files#diff-4f72fd87fb2ab3fd3821222aabc2f8c7cfd1529301aa4d741efd67e5412846e6R160-R171

@ChristopherChudzicki , do you think that these strategies should be implemented in mathbox-react? Maybe implemented in mathbox but exposed through the mathbox-react component API somehow, I mean.

It feels like a nice idea, to be able to provide a render strategy like this to the top level component.

Or, if not, is there a clean way to hook these strategies in, maybe by storing a mathbox ref separately and using the same callback approach from the notebook?

It feels gross to do that, but maybe it's fine.

ChristopherChudzicki commented 2 years ago

@sritchie Ah, that's a neat snippet.

I think the best place to implement this is in Threestrap as an option on the Loop plugin. Possibly on by default.

Regarding rate controls: I think Threestrap is also the right place for that (but... mathbox-react probably needs to make interacting with threestrap a bit more convenient in general).

Actually, Threestrap previously had this functionality! I remember seeing it during my holiday investigations. It seems to have been accidentally removed:

I think we may have inadvertently lost some of Steven's later updates to threestrap =/. More TODOs!