Ratatoskr/src/app/hooks/useSkyState.ts
Meta Vens c1628468a3 Serve the ridge scene only: delete the terrain style and its picker
Removes scene/terrain/, the temporary sceneStyle.ts localStorage override, the Terrain/Ridges
picker in SkyStateControl, terrainSkyFor/terrainDrawn and the terrain reach, 'terrain' from
SceneStyle, and skyBand.ts (the band shaping only the terrain sky used; FixedSkyState now lives
in skyState.ts). A config or stored value that says anything but 'raymarch' is the ridges.
skyBackdrop keeps its constants: the bounds are at least as wide as the ridge budgets, now
asserted directly instead of against the terrain union. The raymarch scene is untouched.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-17 16:05:19 +01:00

21 lines
973 B
TypeScript

import { useSyncExternalStore } from 'react';
import {
getResolvedSkyState,
getSkyState,
subscribe,
type FixedSkyState,
type SkyState,
} from '../features/scene/skyState';
import { readCapabilities, resolveTier } from '../features/scene/tier';
import { useClientConfig } from './useClientConfig';
/** The choice, as the control shows it ('auto' stays 'auto'). The sky being drawn is `useResolvedSkyState`. */
export const useSkyState = (): SkyState => useSyncExternalStore(subscribe, getSkyState);
/** The sky being drawn: day, dusk or night. Unlike the choice it changes as the clock crosses, so it re-renders. */
export const useResolvedSkyState = (): FixedSkyState =>
useSyncExternalStore(subscribe, getResolvedSkyState);
/** Whether a background scene runs on this device and config (the tier the scene host will mount). */
export const useSceneOn = (): boolean =>
resolveTier(useClientConfig().backgroundScene, readCapabilities(navigator)) !== 'off';