mwg API
    Preparing search index...

    Class QualityScaler

    Frame-time-driven quality scaling over item 360's static fit: fitResolution answers what a device can afford once, and this watches what actually happens, stepping the backing-store ratio down when frames keep missing their budget and stepping back up only after a much longer streak inside it. Pure numbers in and out - the game (see Game's qualityScaling option) applies the returned ratio to its renderer, so this stays renderer-free and headless-testable.

    Stepping up is deliberately an order of magnitude slower than stepping down: a frame inside budget at a reduced ratio proves nothing about the next ratio up, so recovery needs a sustained streak, not a good moment.

    import { QualityScaler } from '@datamoc/mwg/two-d';

    const scaler = new QualityScaler({ ceiling: 2 });
    for (let i = 0; i < 60; i++) scaler.observe(1 / 30);
    console.log(scaler.ratio); // 1.75
    Index
    • Feeds one frame's seconds; returns the ratio the renderer should use, unchanged most frames. Non-finite or non-positive frames are ignored rather than counted either way, so a parked clock (a timeScale 0 pause) can never drive the policy.

      Parameters

      • frameSeconds: number

      Returns number

    • A new device-fitted ceiling (rotation, display change): the current ratio is clamped down to it, never up - stepping back up stays the streak's job. Returns the ratio.

      Parameters

      • ceiling: number

      Returns number