summaryrefslogtreecommitdiff
path: root/frontend/_rigidbody/program_common.js
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/_rigidbody/program_common.js')
-rw-r--r--frontend/_rigidbody/program_common.js15
1 files changed, 9 insertions, 6 deletions
diff --git a/frontend/_rigidbody/program_common.js b/frontend/_rigidbody/program_common.js
index 9d097e2..988056f 100644
--- a/frontend/_rigidbody/program_common.js
+++ b/frontend/_rigidbody/program_common.js
@@ -36,7 +36,7 @@ function getContext(pId, pOnRun) {
function requestUpdateLoop(pFunction, pOnExit) {
let lDeltaTimeSeconds = undefined,
- lStartTimeSeconds = undefined,
+ lLastTimeSeconds = undefined,
lIsRunning = true;
function update(pTimeStamp) {
@@ -50,15 +50,18 @@ function requestUpdateLoop(pFunction, pOnExit) {
pTimeStamp = pTimeStamp / 1000.0; // Convert to seconds
// Time calculation
- if (lStartTimeSeconds === undefined) {
- lStartTimeSeconds = pTimeStamp;
+ if (lLastTimeSeconds === undefined) {
+ lLastTimeSeconds = pTimeStamp;
lDeltaTimeSeconds = 0;
} else {
- lDeltaTimeSeconds = lStartTimeSeconds - pTimeStamp;
- lStartTimeSeconds = pTimeStamp;
+ lDeltaTimeSeconds = pTimeStamp - lLastTimeSeconds;
+ lLastTimeSeconds = pTimeStamp;
}
- pFunction(lDeltaTimeSeconds);
+ while (lDeltaTimeSeconds > 0) {
+ pFunction(lDeltaTimeSeconds);
+ lDeltaTimeSeconds -= 0.16;
+ }
requestAnimationFrame(update);
}