You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
335 B
17 lines
335 B
// We clamp high deltas so 30 fps is fairly ok
|
|
const bgFps = 30;
|
|
const desiredMsDelay = 1000 / bgFps;
|
|
|
|
let lastTick = performance.now();
|
|
|
|
function tick() {
|
|
const now = performance.now();
|
|
const delta = now - lastTick;
|
|
lastTick = now;
|
|
|
|
// @ts-ignore
|
|
self.postMessage({ delta });
|
|
}
|
|
|
|
setInterval(tick, desiredMsDelay);
|