import type * as THREE from "three"; import type { ThreeParts } from "../realistic/textures.ts"; import { type BorderShapes } from "./lines.ts"; /** * Where the borders' shapes come from. `countries` gives the countries (chizu's `world-geo`, Natural Earth 1:110m, when left out); `regions` gives one country's regions by its code, or `null` * for a country with none, and draws no regions when left out. Each is a set of shapes in longitude and latitude. * * @example * ```ts no-run * import type { BorderData } from "@johnmorrisdotca/chikyu-earth/realistic"; * * const data: BorderData = { regions: async (code) => (code === "JP" ? (await fetch("/regions/jp.json")).json() : null) }; * console.log(typeof data.regions); * ``` */ export interface BorderData { countries?: () => Promise; regions?: (code: string) => Promise; } /** * What the borders have done: how many segments each set has, whether each was drawn at the last draw, the countries whose regions have arrived, how many times a set's lines were made, and whether * a set could not be loaded. * * @example * ```ts no-run * import type { BorderStats } from "@johnmorrisdotca/chikyu-earth/realistic"; * * const empty: BorderStats = { countries: 0, regions: 0, shown: { countries: false, regions: false }, loaded: [], builds: 0, failed: false }; * console.log(empty); * ``` */ export interface BorderStats { countries: number; regions: number; shown: { countries: boolean; regions: boolean; }; loaded: string[]; builds: number; failed: boolean; } /** What the element and the scene share: the sets switched on, where the shapes come from, and what the layer did. */ export interface BorderState { countries: boolean; regions: boolean; data: BorderData; onError?: (error: unknown) => void; stats: BorderStats; } export declare const newBorderState: () => BorderState; /** Places the view shows, how far round the sphere the view reaches from each (degrees), and the Earth's radius on the screen (CSS pixels). */ export interface BorderView { points: readonly { lon: number; lat: number; }[]; angle: number; radius: number; } export interface BorderLayer { sync(view: BorderView): void; dispose(): void; } /** * Makes the layer under `parent` (the group that turns with the Earth). It loads what the sets switched on need, the first time `sync` asks. * * @param three - The page's three.js; it must have `LineSegments`. * @param parent - The Earth's own group. * @param state - The model's borders. * @param invalidate - Asks for a draw (when shapes arrive). * @param order - The render order: after the clouds, before the air. * @returns The layer. */ export declare function createBorderLayer(three: ThreeParts, parent: THREE.Object3D, state: BorderState, invalidate: () => void, order: number): BorderLayer;