mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-23 11:38:37 +00:00
fixed animation drops
This commit is contained in:
parent
721f707c94
commit
4d92922263
@ -62,7 +62,7 @@ let clock = createClock(
|
|||||||
lastEnd = end;
|
lastEnd = end;
|
||||||
const tickdeadline = phase - time; // time left until the phase is a whole number
|
const tickdeadline = phase - time; // time left until the phase is a whole number
|
||||||
lastTick = time + tickdeadline;
|
lastTick = time + tickdeadline;
|
||||||
sendMessage('tick', { begin, end, tickdeadline, cps, time: Date.now(), cycle: getCycle() });
|
sendMessage('tick', { begin, end, tickdeadline, cps, cycle: getCycle() });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(`[cyclist] error: ${e.message}`, 'error');
|
log(`[cyclist] error: ${e.message}`, 'error');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -130,6 +130,7 @@ export class Drawer {
|
|||||||
this.lastFrame = phase;
|
this.lastFrame = phase;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// query haps from last frame till now. take last 100ms max
|
// query haps from last frame till now. take last 100ms max
|
||||||
const haps = this.scheduler.pattern.queryArc(Math.max(this.lastFrame, phase - 1 / 10), phase);
|
const haps = this.scheduler.pattern.queryArc(Math.max(this.lastFrame, phase - 1 / 10), phase);
|
||||||
this.lastFrame = phase;
|
this.lastFrame = phase;
|
||||||
@ -154,6 +155,7 @@ export class Drawer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// TODO: scheduler.now() seems to move even when it's stopped, this hints at a bug...
|
// TODO: scheduler.now() seems to move even when it's stopped, this hints at a bug...
|
||||||
|
|
||||||
t = t ?? scheduler.now();
|
t = t ?? scheduler.now();
|
||||||
this.scheduler = scheduler;
|
this.scheduler = scheduler;
|
||||||
let [_, lookahead] = this.drawTime;
|
let [_, lookahead] = this.drawTime;
|
||||||
|
|||||||
@ -13,6 +13,7 @@ export class NeoCyclist {
|
|||||||
this.worker.port.start();
|
this.worker.port.start();
|
||||||
this.cycle = 0;
|
this.cycle = 0;
|
||||||
this.cps = 1;
|
this.cps = 1;
|
||||||
|
this.timeAtLastTick = 0;
|
||||||
this.worker.port.addEventListener('message', (message) => {
|
this.worker.port.addEventListener('message', (message) => {
|
||||||
if (!this.started) {
|
if (!this.started) {
|
||||||
return;
|
return;
|
||||||
@ -21,7 +22,8 @@ export class NeoCyclist {
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'tick': {
|
case 'tick': {
|
||||||
let { begin, end, cps, tickdeadline, time, cycle } = payload;
|
this.timeAtLastTickMessage = performance.now();
|
||||||
|
let { begin, end, cps, tickdeadline, cycle } = payload;
|
||||||
this.cps = cps;
|
this.cps = cps;
|
||||||
this.cycle = cycle + latency * cps;
|
this.cycle = cycle + latency * cps;
|
||||||
// const messageLatency = (Date.now() - time) / 1000;
|
// const messageLatency = (Date.now() - time) / 1000;
|
||||||
@ -54,7 +56,8 @@ export class NeoCyclist {
|
|||||||
|
|
||||||
now() {
|
now() {
|
||||||
// console.log(this.cycle, 'cycle');
|
// console.log(this.cycle, 'cycle');
|
||||||
return this.cycle;
|
const gap = ((performance.now() - this.timeAtLastTickMessage) / 1000) * this.cps;
|
||||||
|
return this.cycle + gap;
|
||||||
// this.sendMessage('requestcycles', {});
|
// this.sendMessage('requestcycles', {});
|
||||||
}
|
}
|
||||||
setCps(cps = 1) {
|
setCps(cps = 1) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user