From 9eb1676482c6911006f22f770f74a054900e4f5e Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 3 May 2017 02:21:32 +0100 Subject: [PATCH] Seed history properly and dt clamp. --- v3/src/boot/VariableTimeStep.js | 15 +++++++++------ v3/src/checksum.js | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/v3/src/boot/VariableTimeStep.js b/v3/src/boot/VariableTimeStep.js index 7dabe5f73..fbe13d386 100644 --- a/v3/src/boot/VariableTimeStep.js +++ b/v3/src/boot/VariableTimeStep.js @@ -54,7 +54,7 @@ VariableTimeStep.prototype = { for (var i = 0; i < this.deltaSmoothingMax; i++) { - history[i] = 0; + history[i] = 0.0166; } this.delta = 0; @@ -76,16 +76,19 @@ VariableTimeStep.prototype = { // delta time var dt = (time - this.lastTime) / 1000; - if (dt < 0 || dt > 1) + // min / max range + if (dt < 0.0001 || dt > 0.5) { // Probably super bad start time or browser tab inactivity / context loss // so use the last 'sane' dt value - dt = history[idx]; - } + console.log('dt sync', dt, 'ms over', history[idx]); - // clamp delta to 0.0001 to 0.5 range - dt = Math.max(Math.min(dt, 0.5), 0.0001); + dt = history[idx]; + + // clamp delta to 0.0001 to 0.5 range + dt = Math.max(Math.min(dt, 0.5), 0.0001); + } // Smooth out the delta over the previous X frames diff --git a/v3/src/checksum.js b/v3/src/checksum.js index 7b75bcae8..64b1089d6 100644 --- a/v3/src/checksum.js +++ b/v3/src/checksum.js @@ -1,4 +1,4 @@ var CHECKSUM = { -build: '1fea37a0-2f97-11e7-93dd-fd6f78427b2e' +build: 'f7392da0-2f9d-11e7-ba4c-5959ed8510b1' }; module.exports = CHECKSUM; \ No newline at end of file