import type * as THREE from "three"; import type { AssetCache } from "@johnmorrisdotca/kazoku-ui/renderer"; import { type EarthMapSource } from "../door/map.ts"; import type { ThreeParts } from "./textures.ts"; import { type TileCamera } from "./tiles.ts"; /** * The most tiles held at once, day and night together, about a megabyte and a third of graphics memory each (a 512 pixel square with its mipmaps). * * @example * ```ts * import { TILE_LIMIT } from "@johnmorrisdotca/chikyu-earth/realistic"; * * console.log(TILE_LIMIT); * ``` */ export declare const TILE_LIMIT = 48; /** * Milliseconds a tile that is no longer wanted is kept (the view may come straight back) before it is freed. * * @example * ```ts * import { TILE_KEEP_MS } from "@johnmorrisdotca/chikyu-earth/realistic"; * * console.log(TILE_KEEP_MS); * ``` */ export declare const TILE_KEEP_MS = 4000; /** * The bytes of decoded tiles the view holds, all sources together: 72 MB, which is the 48 tiles it has always held (`TILE_LIMIT`, a 512 pixel square with its mipmaps is 1.4 MB). A tile that arrives when the view needs every tile it holds, * and does not fit, is refused and counted (`stats.refused`): the view draws what it holds. * * @example * ```ts * import { TILE_BUDGET } from "@johnmorrisdotca/chikyu-earth/realistic"; * * console.log(TILE_BUDGET / 1024 / 1024); * ``` */ export declare const TILE_BUDGET: number; type Three = ThreeParts; type Uniform = { value: T; }; /** What the tiles share with the surface they are laid over. */ export interface TileShared { sunDir: Uniform; lights: Uniform; boost: Uniform; ortho: Uniform; /** The whole-Earth water and night pictures' uniforms: their value is the picture now held. */ water: Uniform; night: Uniform; /** More uniforms the surface program reads (the cloud picture and where the Sun is in the Earth's axes), shared with the sphere's own. */ extra?: Record>; } /** * The map source each layer is drawn from now, or none: read at every draw. A layer's tiles come from its source alone, and the night tiles go with day tiles (no day source, no night tiles). * `finer` is laid over the day tiles, and only when the view is closer than the day tiles serve. A source with its own `grid` is placed on that grid. */ export type TileSources = { day?: EarthMapSource; night?: EarthMapSource; finer?: EarthMapSource; }; export interface TileSetDeps { assets: AssetCache; /** The sources of the layers now (the data door's: a source a page added, else the `tiles` folder). Read at every draw; the objects are the same while nothing changed. */ sources: () => TileSources; /** The bytes of decoded tiles held, all sources together: `TILE_BUDGET` where left out. */ budgetBytes?: number; /** The widest picture this device holds: tiles are only used where the day picture reaches 4096. */ cap: () => number; /** Ask for one draw. */ invalidate: () => void; /** A reader who asked for less motion: a finer tile is shown at once, with no fade. */ reducedMotion?: () => boolean; /** Told once when a tile set's manifest has been read: the finest width of each layer. */ onManifest?: (layers: Record) => void; limit?: number; now?: () => number; } /** What the tile set is doing, for a page or a test. */ export interface TileStats { /** A readable manifest is in hand. */ ready: boolean; /** The level now wanted for the day picture, `null` when the pictures of the package are sharp enough. */ level: number | null; /** Tiles held (loading, loaded, on the sphere or not), and those on the sphere in view. */ held: number; shown: number; loading: number; /** Tiles that could not be fetched and are not asked for again for a while. */ failed: number; /** Tile fetches made. */ requested: number; /** The bytes of decoded tiles held, which never pass the budget except by tiles the view needs now, and tiles that arrived and did not fit, which are not held. */ heldBytes: number; refused: number; /** The tiles in view that came from each source, by the source's id: what a credit line counts. */ used: Record; /** The level of the finer grid now wanted, or `null` when the view is no closer than the tiles underneath. */ finer: number | null; /** True while a finer tile is still fading in. At rest, after the fade, this is false and nothing is drawn for it. */ fading: boolean; } export interface TileSet { sync(camera: TileCamera, sun: readonly [number, number, number], night: boolean, ratio: number): void; readonly stats: TileStats; dispose(): void; } /** Make the set that puts tiles on `parent`, a group that turns with the Earth. */ export declare function createTileSet(three: Three, parent: THREE.Group, shared: TileShared, deps: TileSetDeps): TileSet; export {};