dev21w45-b

This commit is contained in:
Victor Westerlund 2021-11-11 17:12:37 +01:00
parent 9de4811adf
commit fc25c3ccba

View file

@ -22,18 +22,19 @@ class Monkey {
let task = null; let task = null;
// Run task after delay // Run task after delay
function frame(time) { function frame() {
if(self.flags[0] === 0 || self.flags[2] === 0) return self.abort(); if(self.flags[0] === 0 || self.flags[2] === 0) return self.abort();
postMessage(["TASK",task]); postMessage(["TASK",task]);
self.i++; self.i++;
scheduleFrame(time); scheduleFrame();
} }
// Queue the next task // Queue the next task
function scheduleFrame(time) { function scheduleFrame() {
task = self.tasks[self.i]; task = self.tasks[self.i];
//const elapsed = Math.round(performance.now() - start); //const elapsed = Math.round(performance.now() - start);
const wait = task[0] + start; const wait = task[0] + start;
console.log(wait);
setTimeout(() => requestAnimationFrame(frame),wait); setTimeout(() => requestAnimationFrame(frame),wait);
} }