Skip to content

Instantly share code, notes, and snippets.

@simonghales
simonghales / revised.ts
Last active March 23, 2024 23:26
Running a game loop on a web worker
export const createNewPhysicsLoopWebWorker = (stepRate: number) => {
return new Worker('data:application/javascript,' +
encodeURIComponent(`
var start = performance.now();
var updateRate = ${stepRate};
function getNow() {
return start + performance.now();
}