b3d-quality

The system quality proxy — the single place that vends device-appropriate defaults. The probe measures the device and feeds a PerfProfile in here; components then resolve any attribute left at its auto sentinel against the current budgets. A global override (setQuality) lets a settings menu force a tier.

This module is deliberately DOM-free (plain state + an observer list, no tosijs import) so all of its logic is unit-testable headless — the pure-module ethos the rest of the framework follows.

The auto default convention

Components declare performance-sensitive attributes with an auto sentinel (0 for numbers) instead of a hard-wired number, and resolve them here:

// in a component's setup:
const subs = resolveBudget(this.hiResSubdivisions, 'hiResSubdivisions', { xr })
//           explicit author value wins; 0 (auto) → the tier's budget

So an author who sets a value gets exactly that; everything left unset adapts to the measured device. This is the pattern to reach for wherever you find a hard-wired default that affects performance (terrain detail, shadow map size, reflection resolution, render scaling…): make the default auto and resolve it, rather than baking one number that's wrong for both a phone and a workstation.

Global override

import { setQuality, getQuality } from 'tosijs-3d'

setQuality('low')            // force low everywhere
setQuality('auto')           // back to the measured profile (default)
// a settings <select> calls setQuality(e.target.value) and reads getQuality()