import type * as THREE from "three"; import type { AssetCache } from "@johnmorrisdotca/kazoku-ui/renderer"; import { type Layer } from "./tiers.ts"; /** * The parts of three.js the Earth and the space view use. A page can hand over a module that re-exports just these (see `setThreeLoader`) instead of all of three. * * @example * ```ts no-run * import type { ThreeParts } from "@johnmorrisdotca/chikyu-earth/realistic"; * * const load = (): Promise => import("three"); * console.log(typeof load); * ``` */ export type ThreeParts = { [Name in "Texture" | "BufferGeometry" | "BufferAttribute" | "ShaderMaterial" | "Group" | "Mesh" | "Scene" | "OrthographicCamera" | "PerspectiveCamera" | "Vector3" | "WebGLRenderer" | "RepeatWrapping" | "ClampToEdgeWrapping" | "LinearMipmapLinearFilter" | "LinearFilter" | "BackSide" | "DoubleSide" | "LineLoop" | "LineBasicMaterial" | "Color"]: (typeof THREE)[Name]; } & { /** Only the satellites use it, so a loader that hands over a subset of three.js without it still draws everything else. */ Points?: typeof THREE.Points; /** Only the satellites above 60 times real time use it, for their streaks: without it they are dots alone there, and one warning is written to the console. */ LineSegments?: typeof THREE.LineSegments; } & { /** Only the name written on the Earth (`body-label`) uses these, so a subset of three.js without them still draws everything else. */ CanvasTexture?: typeof THREE.CanvasTexture; SphereGeometry?: typeof THREE.SphereGeometry; MeshLambertMaterial?: typeof THREE.MeshLambertMaterial; SRGBColorSpace?: typeof THREE.SRGBColorSpace; NormalBlending?: typeof THREE.NormalBlending; AdditiveBlending?: typeof THREE.AdditiveBlending; } & { /** Only the borders (`borders`) use it, so a subset of three.js without it still draws everything else. */ LineSegments?: typeof THREE.LineSegments; }; /** Milliseconds a lower texture size must be enough before the larger one is let go. */ export declare const DOWNGRADE_AFTER_MS = 4000; export interface TextureDeps { assets: AssetCache; /** Ends with a slash. */ textureBase: () => string; /** The widest texture, 4096 at most. */ cap: () => number; invalidate: () => void; onError?: (error: unknown) => void; onTier?: (layer: Layer, width: number) => void; } export interface TextureSet { /** The `{ value }` a shader uniform takes, one a layer; the value is the texture now in use. */ readonly uniforms: Record; /** Hold the width each layer needs for a disc of this many device pixels across the radius (`radiusPx[layer]`, or one number for all). */ sync(radiusPx: number | Partial>): void; dispose(): void; } /** Load the base picture of each layer, then hand back the set. Rejects (after freeing what it took) if one will not load. */ export declare function createTextureSet(three: ThreeParts, layers: readonly Layer[], deps: TextureDeps): Promise;