I have a playground here
Look at the console. When you just run this code you see at the start:
dt = 16, dt = 1, dt = 2, dt = 17, ....
But after 5 seconds it stops by setTimeout()
with stopRenderLoop()
and starts again with runRenderLoop()
, there are no any dt = 1 or 2ms
, now dt-values are only:
dt = 16, 17, 17, 16, ...
.
It looks after restarting the loop physics runs slower than in works before. Maybe some physics sub-steps are missing.
Why does it happen? Should I restart physics somehow?