mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 18:22:25 +00:00
Remove the fixed 60 FPS cap. The render governor caps a parked scene at 60 ticks a second, since Cesium still runs the clock, data sources and update listeners on every animation frame when it skips the draw, and holds continuous render while the camera moves (moveStart to moveEnd, with pose sampling for cameras that drift by rounding errors and never raise moveEnd). Waits that counted frames (a tracked contact's first position, a shared follow view, a trail's temporary copy) now count drawn time through src/time/frameWait.js, so they last the same at any refresh rate.
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
/**
|
|
* A wait measured in time spent drawing frames, the same at any display
|
|
* refresh rate.
|
|
*
|
|
* Each call to `tick()` adds the time since the previous call, but at most
|
|
* MAX_STEP_MS, so a background tab, a parked scene or a hidden owner (which
|
|
* draw no frames for this wait) does not use the wait up while nothing is on
|
|
* screen.
|
|
*/
|
|
|
|
/** The most one frame may add to a wait, in milliseconds. */
|
|
export const MAX_STEP_MS = 100;
|
|
|
|
/**
|
|
* Start a wait of `limitMs` drawn time.
|
|
* @param {number} limitMs How long to wait, in milliseconds.
|
|
* @param {() => number} [now] Clock in milliseconds.
|
|
* @returns {{tick: () => boolean, pause: () => void}} `tick()` counts one
|
|
* drawn frame and answers whether the wait is over; `pause()` makes the
|
|
* next tick count nothing for the gap since the last one.
|
|
*/
|
|
export function createFrameWait(limitMs, now = () => performance.now()) {
|
|
let waitedMs = 0;
|
|
let lastMs = NaN;
|
|
return {
|
|
tick() {
|
|
const at = now();
|
|
if (Number.isFinite(lastMs))
|
|
waitedMs += Math.min(Math.max(at - lastMs, 0), MAX_STEP_MS);
|
|
lastMs = at;
|
|
return waitedMs >= limitMs;
|
|
},
|
|
pause() {
|
|
lastMs = NaN;
|
|
},
|
|
};
|
|
}
|