From 23867822803d0544b1ff78072b3f9798881a589d Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Fri, 12 Jan 2024 00:24:23 -0500 Subject: [PATCH] cleaning... --- packages/core/neocyclist.mjs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/core/neocyclist.mjs b/packages/core/neocyclist.mjs index 9c6d838d..3f8d4a83 100644 --- a/packages/core/neocyclist.mjs +++ b/packages/core/neocyclist.mjs @@ -1,8 +1,5 @@ import { logger } from './logger.mjs'; -// const sharedworker = new SharedWorker(new URL('./cyclistworker.js', import.meta.url)); -// sharedworker.port.start(); - export class NeoCyclist { constructor({ onTrigger, onToggle, latency = 0.1, onError }) { this.started = false; @@ -22,12 +19,15 @@ export class NeoCyclist { switch (type) { case 'tick': { - this.timeAtLastTickMessage = performance.now(); + const now = performance.now(); + // const interval = 0.1; + // const timeSinceLastMessage = now - this.timeAtLastTickMessage; + // const messageLag = (interval * 1000 - timeSinceLastMessage) / 1000; + + this.timeAtLastTickMessage = now; let { begin, end, cps, tickdeadline, cycle } = payload; this.cps = cps; this.cycle = cycle + latency * cps; - // const messageLatency = (Date.now() - time) / 1000; - // latency = latency - messageLatency const haps = this.pattern.queryArc(begin, end); haps.forEach((hap) => { @@ -55,10 +55,8 @@ export class NeoCyclist { } now() { - // console.log(this.cycle, 'cycle'); const gap = ((performance.now() - this.timeAtLastTickMessage) / 1000) * this.cps; return this.cycle + gap; - // this.sendMessage('requestcycles', {}); } setCps(cps = 1) { this.sendMessage('cpschange', { cps });