import { S as SceneState } from './useSceneGate-C-4jJfT2.cjs'; import 'react'; /** * Renderer settings for one quality level. * * Only what the adapter can genuinely apply to the renderer itself. Particle * counts, geometry detail and post-processing passes are not here on purpose — * those live in your own components, keyed off `gate.quality`. An option that * looks applied and is not is worse than no option. */ interface RenderProfile { /** * Device pixel ratio. Capping this is the single biggest saving available on * a high-density display: dropping from 3 to 1.5 quarters the pixels shaded. */ dpr?: number; /** Whether shadow maps are drawn at all. */ shadows?: boolean; } interface RenderProfiles { full: RenderProfile; reduced: RenderProfile; } /** * Apply a scene gate's decision to the R3F renderer. * * ```tsx * function Rig({ state }: { state: SceneState }) { * useRenderQuality(state, { * full: { dpr: 2, shadows: true }, * reduced: { dpr: 1, shadows: false }, * }); * return null; * } * * // and outside the canvas * const scene = useSceneGate({ label: "hero" }); * *
* {scene.mounted && ( * * * * * )} *
* ``` * * Three jobs. * * **It applies the profile.** Pixel ratio and shadows follow the state, live, * without rebuilding the scene. * * **It stops the render loop when the scene is off screen.** R3F draws * continuously by default, so a hero three screens up keeps shading every * frame for nobody. On `"idle"` the loop is set to `"never"` and the context, * the textures and the geometry all stay exactly where they were — coming back * into view is instant, where a remount would pay for the whole upload again. * * **It notices when the graphics context dies.** A browser can take a WebGL * context away at any time, and R3F has no handler for it — verified against * 9.6.1, there is nothing in the bundle. What you get is a permanently black * canvas and a clean console. This calls `preventDefault()` so a replacement * context is possible at all, and reports the loss so the scene gate can hand * back a new `generation` for the ``. * * ## Why this is a separate import * * `@vectorvesper/motion` has no dependencies. Three and R3F are optional peers * reached through `@vectorvesper/motion/r3f`, so a project that never renders * 3D never pays for any of this. * * ## Why quality is not changed with `#define` * * Recompiling a shader is a stall of exactly the kind this is trying to avoid, * and it lands at the worst possible moment — when the page is already * struggling. Everything here is a renderer setting or a uniform. If you need * a cheaper shader variant, compile both up front and switch which one draws. */ declare function useRenderQuality(state: SceneState, profiles: RenderProfiles): void; export { type RenderProfile, type RenderProfiles, useRenderQuality };