Record that a frame has just been rendered. If the gap since the previous
frame exceeds idleThresholdMs, prior samples are discarded so the new
burst is measured in isolation.
Current FPS averaged over the sliding window, or null when no rate
can be meaningfully reported (fewer than two samples, or currently idle).
True iff no frame has arrived within idleThresholdMs.
Number of frame samples currently retained in the window.
Discard all accumulated samples.
Sliding-window FPS tracker tuned for render-on-demand viewers.
In a continuous-render pipeline FPS is just
frames / elapsedTime, but interactive viewers only render when something changes (drag, hover, server push) so frame arrivals come in bursts separated by arbitrarily long idle gaps. A naive moving average would drag the reported rate toward zero during those gaps even though the burst itself may have been smooth.This class measures FPS only over the most recent
windowMsof frame arrivals, and treats any gap longer thanidleThresholdMsas the end of the current burst: samples accumulated before the gap are discarded so the next burst's rate isn't polluted by the pre-idle samples. While idle (no frame withinidleThresholdMs) getFps returnsnullso callers can render a neutral indicator (e.g. "—") rather than a stale or zero number.Framework-agnostic; React consumers should use InteractiveFpsProvider together with useFps / useFrameReceiver.