You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was looking over the implementation of setInterval in turbulenzengine.ts.
Using requestAnimationFrame surprises me since I thought only rendering would be done in an animationFrame callback, with game state updates happening through an independent loop.
Am I even right in thinking that, e.g., physics engine updates happen through WebGLTurbulenzEngine.setInterval and therefore in a requestAnimationFrame? Is there another interval system I'm overlooking?
In any case, this system clearly works well in turbulenz. Did the team try different architectures?
The text was updated successfully, but these errors were encountered:
Yes, updates and rendering are done in that way if you are looking to update at 60fps. We use request animation frame because its more reliable callback than window.setInterval for millisecond accurate callbacks on some browsers. You can of course use window.setInterval and window.setTimeout if you wish, but if precise timing is important to you then you should probably stick with TurbulenzEngine.setInterval.
One side note. On some browsers requestAnimationFrame won't be called if the tab being displayed is hidden. In Turbulenz we use this to make sure games are not updating when they are not visible. If you need to process i.e. doing networking processing etc, then you might want to use timeouts and/or intervals for keep alives and TurbulenzEngine.setInterval for rendering.
I was looking over the implementation of setInterval in
turbulenzengine.ts
.Using requestAnimationFrame surprises me since I thought only rendering would be done in an animationFrame callback, with game state updates happening through an independent loop.
Am I even right in thinking that, e.g., physics engine updates happen through WebGLTurbulenzEngine.setInterval and therefore in a requestAnimationFrame? Is there another interval system I'm overlooking?
In any case, this system clearly works well in turbulenz. Did the team try different architectures?
The text was updated successfully, but these errors were encountered: