PurpleKingdomGames / tyrian

Elm-inspired Scala UI library.
https://tyrian.indigoengine.io/
MIT License
346 stars 26 forks source link

Make render loop wait for model updates #255

Closed armanbilge closed 5 months ago

armanbilge commented 7 months ago

Previously, the render loop was running on every animation frame in the browser. Now, then render loop waits until there has been at least one update to the model before re-starting the render cycle.

davesmith00000 commented 7 months ago

Thanks @armanbilge, that is what we talked about.

I'm thinking about this in terms of https://github.com/PurpleKingdomGames/tyrian/issues/201 and wondering if this is the right strategy though. I'll try and mull it over on an up-coming dog walk or something. :smile:

davesmith00000 commented 7 months ago

@armanbilge, as it stands this PR doesn't quite work (the page never re-renders), but if you remove resetModelUpdateCount i.e. lines 41 and 90, then it appears to work perfectly.

davesmith00000 commented 7 months ago

image

Quite. :confused: emoji is my general feeling in that bit of code. Which is odd because it's barely 60 lines of not terribly complicated looking code. :smile:

I'm in the middle of something at the moment, but I think when I get the chance, I'd like to see if there's some way to reformulate it that makes it easier to follow.

davesmith00000 commented 5 months ago

Closing as this issue has been resolved by another PR.