1import type { Camera } from "../scene/read.ts";23/** A settled camera key precise enough that materially different bboxes differ. */4export function demandWindowKey(camera: Camera | null): string {5 if (!camera) return "fit";6 return `${camera.zoom.toFixed(2)}/${camera.x.toFixed(2)}/${camera.y.toFixed(2)}`;7}89/** Keep one demanded window per world; a pan replaces rather than accumulates. */10export function replaceDemandWindow<T>(cache: Map<string, T>, prefix: string, key: string, value: T): void {11 for (const held of cache.keys()) {12 if (held.startsWith(prefix) && held !== key) cache.delete(held);13 }14 cache.set(key, value);15}