Files
Iliyan Angelov 306b20e24a Frontend start
2025-09-14 00:54:48 +03:00

18 lines
627 B
JavaScript

import { time } from '../../frameloop/sync-time.mjs';
import { frame, cancelFrame, frameData } from '../../frameloop/frame.mjs';
const frameloopDriver = (update) => {
const passTimestamp = ({ timestamp }) => update(timestamp);
return {
start: (keepAlive = true) => frame.update(passTimestamp, keepAlive),
stop: () => cancelFrame(passTimestamp),
/**
* If we're processing this frame we can use the
* framelocked timestamp to keep things in sync.
*/
now: () => (frameData.isProcessing ? frameData.timestamp : time.now()),
};
};
export { frameloopDriver };