mirror of
https://github.com/photonstorm/phaser
synced 2025-02-17 06:28:30 +00:00
Seed history properly and dt clamp.
This commit is contained in:
parent
e5b82eb9b9
commit
9eb1676482
2 changed files with 10 additions and 7 deletions
|
@ -54,7 +54,7 @@ VariableTimeStep.prototype = {
|
||||||
|
|
||||||
for (var i = 0; i < this.deltaSmoothingMax; i++)
|
for (var i = 0; i < this.deltaSmoothingMax; i++)
|
||||||
{
|
{
|
||||||
history[i] = 0;
|
history[i] = 0.0166;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.delta = 0;
|
this.delta = 0;
|
||||||
|
@ -76,16 +76,19 @@ VariableTimeStep.prototype = {
|
||||||
// delta time
|
// delta time
|
||||||
var dt = (time - this.lastTime) / 1000;
|
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
|
// Probably super bad start time or browser tab inactivity / context loss
|
||||||
// so use the last 'sane' dt value
|
// 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 = history[idx];
|
||||||
dt = Math.max(Math.min(dt, 0.5), 0.0001);
|
|
||||||
|
// 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
|
// Smooth out the delta over the previous X frames
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
var CHECKSUM = {
|
var CHECKSUM = {
|
||||||
build: '1fea37a0-2f97-11e7-93dd-fd6f78427b2e'
|
build: 'f7392da0-2f9d-11e7-ba4c-5959ed8510b1'
|
||||||
};
|
};
|
||||||
module.exports = CHECKSUM;
|
module.exports = CHECKSUM;
|
Loading…
Add table
Reference in a new issue