matthias-research / pages

My web page containing all the demos from my youtube channel "Ten Minute Physics" www.youtube.com/c/TenMinutePhysics
655 stars 136 forks source link

[FIX] Account for elapsed simulation time when delaying for targetFps #13

Closed zalo closed 2 years ago

zalo commented 2 years ago

@matthias-research

This PR accounts for a minor bug in the timerCallback function which resulted in it never reaching the target framerate.

When delaying for the next frame, it did not take into account the time it takes to simulate the cloth.

These should be the minimal set of changes to account for this issue; you can see the difference more starkly by reducing clothNumX and clothNumY (it should reach 60fps now where it did not before).

matthias-research commented 2 years ago

Hi, great catch. Will merge it.