refactor: timestamp precision
This commit is contained in:
parent
e15e94777f
commit
77dcb7c5a1
|
@ -29,7 +29,7 @@ export default class Engine {
|
||||||
frame = 0;
|
frame = 0;
|
||||||
handle;
|
handle;
|
||||||
incomingActions = new Map();
|
incomingActions = new Map();
|
||||||
last = Date.now();
|
last;
|
||||||
server;
|
server;
|
||||||
|
|
||||||
constructor(Server) {
|
constructor(Server) {
|
||||||
|
@ -398,10 +398,12 @@ export default class Engine {
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
|
this.last = performance.now() / 1000;
|
||||||
const loop = async () => {
|
const loop = async () => {
|
||||||
|
const now = performance.now() / 1000;
|
||||||
|
const elapsed = now - this.last;
|
||||||
|
this.last = now;
|
||||||
this.acceptActions();
|
this.acceptActions();
|
||||||
const elapsed = (Date.now() - this.last) / 1000;
|
|
||||||
this.last = Date.now();
|
|
||||||
this.tick(elapsed);
|
this.tick(elapsed);
|
||||||
this.update(elapsed);
|
this.update(elapsed);
|
||||||
this.setClean();
|
this.setClean();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user