import type * as THREE from "three"; import type { BodyLabelLook } from "@johnmorrisdotca/kazoku-ui/body-label"; import type { ThreeParts } from "./textures.ts"; /** * The attributes of the family's body label, in the order a settings panel lists them. * * @example * ```ts * import { BODY_LABEL_ATTRIBUTES } from "@johnmorrisdotca/chikyu-earth/realistic"; * * console.log(BODY_LABEL_ATTRIBUTES.join(", ")); * ``` */ export declare const BODY_LABEL_ATTRIBUTES: readonly ["body-label", "body-label-strength", "body-label-repeat", "body-label-latitude", "body-label-facing", "body-label-font", "body-label-fallback-font"]; /** * The settings of the name on the Earth: the same options the family's label takes, with the text left out (it is the Earth's own name, in the page's language). * * @example * ```ts * import type { BodyLabelSettings } from "@johnmorrisdotca/chikyu-earth/realistic"; * * const settings: BodyLabelSettings = { look: "painted", strength: 0.5, repeat: "once", latitude: 0, facing: false }; * console.log(settings.look); * ``` */ export interface BodyLabelSettings { look: BodyLabelLook; /** 0 to 1. */ strength: number; repeat: "once" | "both" | "around"; /** Degrees, kept within 70 of the equator by the label. */ latitude: number; /** The name keeps facing the reader while the Earth turns under it. */ facing: boolean; /** A CSS font family the page has loaded; Michroma, fetched once, when left out. */ font?: string; /** The family for letters the font has none of (Japanese); the page's sans when left out. */ fallbackFont?: string; } /** What an Earth tells its scene about its name: the settings now, or `null` for none, and the text. */ export interface BodyLabelState { settings: BodyLabelSettings | null; text: string; /** What the layer has done: the label is made and in the globe, and it is showing (not hidden for being small), as of the last draw. */ drawn: { made: boolean; showing: boolean; }; } export declare const newBodyLabelState: () => BodyLabelState; /** * What the family's attributes mean: `body-label` (`painted`, `etched`, `outline` or `burned`; present with another value, or none, it is `painted`; absent, no label), `body-label-strength` (0 to 1, 0.5), `body-label-repeat` (`once`, `both` or * `around`; `once`), `body-label-latitude` (degrees; 0), `body-label-facing` (present: always facing the reader), `body-label-font` and `body-label-fallback-font`. * * @param get - Reads an attribute by name, `null` for one that is not there. * @returns The settings, or `null` for no label. * * @example * ```ts * import { readBodyLabel } from "@johnmorrisdotca/chikyu-earth/realistic"; * * const attributes: Record = { "body-label": "etched", "body-label-strength": "0.8", "body-label-repeat": "both" }; * console.log(readBodyLabel((name) => attributes[name] ?? null)); * ``` */ export declare function readBodyLabel(get: (name: string) => string | null): BodyLabelSettings | null; /** * The name written on the Earth: `EARTH`, or `地球` for a Japanese page. * * @param language - `en` or `ja`. * @returns The text. * * @example * ```ts * import { bodyLabelText } from "@johnmorrisdotca/chikyu-earth/realistic"; * * console.log(bodyLabelText("en"), bodyLabelText("ja")); * ``` */ export declare const bodyLabelText: (language: "en" | "ja") => string; export interface BodyLabelLayer { /** Puts the label right for this draw (made, changed or taken away as the settings say) and returns nothing: it asks for a draw of its own when something changed. */ sync(camera: THREE.Camera, radiusPx: number): void; dispose(): void; } /** * Loads Michroma, the family's font for a name written on a body or a sky, from where `setBodyLabelFontUrl` says (beside kazoku-ui's label by default). Once: asking again does nothing. * * @returns A promise that settles when the font is in. * * @example * ```ts no-run * import { loadMichroma } from "@johnmorrisdotca/chikyu-earth/realistic"; * * await loadMichroma(); * ``` */ export declare function loadMichroma(): Promise; /** * Where Michroma, the family's font for the name, is fetched from. Left alone it is the file beside the label's own module (`fonts/Michroma-Regular.ttf` in kazoku-ui's `body-label`), which is right where the package is used as it is shipped, or through a * bundler that keeps assets beside the code (Vite does); a bundler or a site that moves the module copies the file and says where with this. A page that names its own font (`body-label-font`) never fetches it. * * @param url - The font file's address, or `undefined` for the default. * * @example * ```ts no-run * import { setBodyLabelFontUrl } from "@johnmorrisdotca/chikyu-earth/realistic"; * * setBodyLabelFontUrl("/fonts/Michroma-Regular.ttf"); * ``` */ export declare function setBodyLabelFontUrl(url: string | undefined): void; /** * Makes the layer that keeps the Earth's name on its globe, inside `parent` (the group or mesh that turns with the Earth, a radius of 1). The family's body label is loaded only when the settings first ask for it, and its font (Michroma, 64 kB) only * when the page has named no font of its own. All three.js parts the label needs must be in `three` (the full three.js has them); without them `onError` is told once and nothing is drawn. * * @param three - The page's three.js. * @param parent - What turns with the Earth. * @param state - The settings and the text, which the element changes. * @param deps - `invalidate` asks for a draw; `onError` hears of a label that could not be made. * @returns The layer. */ export declare function createBodyLabelLayer(three: ThreeParts, parent: THREE.Object3D, state: BodyLabelState, deps: { invalidate: () => void; onError?: (error: unknown) => void; }): BodyLabelLayer;