diff --git a/v3/src/boot/VariableTimeStep.js b/v3/src/boot/VariableTimeStep.js index e5321ad41..7dabe5f73 100644 --- a/v3/src/boot/VariableTimeStep.js +++ b/v3/src/boot/VariableTimeStep.js @@ -20,12 +20,11 @@ var VariableTimeStep = function (game, framerate) this.time = 0; this.startTime = 0; this.lastTime = 0; - this.runOff = 0; this.delta = 0; this.deltaIndex = 0; this.deltaHistory = []; - this.deltaSmoothingMax = 30; + this.deltaSmoothingMax = 10; }; VariableTimeStep.prototype.constructor = VariableTimeStep; @@ -70,15 +69,19 @@ VariableTimeStep.prototype = { step: function (time) { + var idx = this.deltaIndex; + var history = this.deltaHistory; + var max = this.deltaSmoothingMax; + // delta time var dt = (time - this.lastTime) / 1000; if (dt < 0 || dt > 1) { - // Loop skip, probably super bad start time - this.runOff = time - this.lastTime; - this.lastTime = time; - return; + // Probably super bad start time or browser tab inactivity / context loss + // so use the last 'sane' dt value + + dt = history[idx]; } // clamp delta to 0.0001 to 0.5 range @@ -86,10 +89,6 @@ VariableTimeStep.prototype = { // Smooth out the delta over the previous X frames - var idx = this.deltaIndex; - var history = this.deltaHistory; - var max = this.deltaSmoothingMax; - // add the delta to the smoothing array history[idx] = dt; diff --git a/v3/src/checksum.js b/v3/src/checksum.js index e2e6f5a9a..7b75bcae8 100644 --- a/v3/src/checksum.js +++ b/v3/src/checksum.js @@ -1,4 +1,4 @@ var CHECKSUM = { -build: '77d3f640-2f92-11e7-94cb-df78655b45e3' +build: '1fea37a0-2f97-11e7-93dd-fd6f78427b2e' }; module.exports = CHECKSUM; \ No newline at end of file