refactor: more accurate tick
This commit is contained in:
parent
a89d167839
commit
e195064210
|
@ -72,12 +72,16 @@ const messageHandle = setInterval(() => {
|
||||||
}
|
}
|
||||||
}, 1000 / 60);
|
}, 1000 / 60);
|
||||||
// Prediction.
|
// Prediction.
|
||||||
|
let lastTime = performance.now();
|
||||||
const predictionHandle = setInterval(() => {
|
const predictionHandle = setInterval(() => {
|
||||||
|
const now = performance.now();
|
||||||
|
const elapsed = (now - lastTime) / 1000;
|
||||||
|
lastTime = now;
|
||||||
if (hasSelfEntity()) {
|
if (hasSelfEntity()) {
|
||||||
selfEntity.inputState = actionState.toJS();
|
selfEntity.inputState = actionState.toJS();
|
||||||
}
|
}
|
||||||
entityList.tick(1 / 60);
|
entityList.tick(elapsed);
|
||||||
}, 1000 / 60);
|
}, 1000 / 80);
|
||||||
// State updates.
|
// State updates.
|
||||||
let dirty = false;
|
let dirty = false;
|
||||||
function onMessage({type, payload}) {
|
function onMessage({type, payload}) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user