import { type RaceMoment } from "./circuits.race.moment.ts"; import { type CircuitRace, type RaceOptions } from "./circuits.race.ts"; import type { CircuitOptions } from "./circuits.types.ts"; import type { Pt } from "./crowd.ts"; import { type KyogijoTurn } from "./turn.dom.ts"; import type { TurnModel, TurnSettings } from "./turn.model.ts"; import type { Language } from "./types.ts"; /** The speeds the controls offer: real time, ten times and sixty times (a minute of the race a second). */ export declare const RACE_SPEEDS: readonly number[]; /** What a race's view is drawn from: the circuit's options and the race's. */ export type RaceViewOptions = CircuitOptions & Omit; /** How a race is shown and played. */ export interface RaceViewSettings { /** `flat` (the default) or `3d`: the circuit's 3D view, with the cars standing on it as discs that face the eye. */ view?: "flat" | "3d"; /** The 3D view's own settings (its viewpoint, its controls). */ turn?: TurnSettings; /** 1 (the default), 10 or 60; any speed from 1 to 600 is allowed. */ speed?: number; /** Seconds from the start to begin at: 0 (the grid) by default. */ start?: number; /** Play at once. Ignored for a reader who prefers reduced motion, and while the page is hidden. */ autoplay?: boolean; /** `auto` (the default) follows `prefers-reduced-motion`; `smooth` and `step` force one. */ motion?: "auto" | "smooth" | "step"; /** The timing board under the controls: on by default. */ board?: boolean; /** A race already worked out to play instead of a simulation: one from a feed (`raceFromFeed`). */ race?: CircuitRace; /** Told when the reader plays, pauses, seeks or changes speed, and when the race ends: not at every frame. */ onChange?: (state: RaceState) => void; } /** What a race's view is doing. */ export interface RaceState { t: number; duration: number; playing: boolean; ended: boolean; speed: number; motion: "smooth" | "step"; } /** * Where a race is drawn: the circuit's own drawing and 3D view (`mountCircuitRace`), or another scene the circuit lies in, a district's ground among its venues (`mountDistrictRace`). The cars are placed in the circuit's own plan * (`raceAt`); `point` says where such a point is in the scene. */ export interface RaceScene { /** The scene's flat drawing at a moment, its cars as the `.ky-ci-car` groups of `carMarkup`: the race given when it came from a feed, else the simulation the options make. */ flat(options: O, t: number, given: CircuitRace | undefined): string; /** The options the 3D view is mounted and updated with. */ view(options: O): V; /** The 3D view's model. */ build(options: V, settings: TurnSettings): TurnModel; /** Where a point of the circuit's plan lies in the scene: the same point for the circuit's own drawing. */ point(options: O): (p: Pt) => Pt; } /** What `mountCircuitRace` gives back (and `mountDistrictRace`, with a district's options and 3D view). */ export interface KyogijoRace { /** The race it plays. */ readonly race: CircuitRace; /** The 3D view, when the race is on one. */ readonly turn: KyogijoTurn | undefined; state(): RaceState; /** The race at the clock's time: the standings, the lap, the fastest lap. */ moment(): RaceMoment; play(): void; pause(): void; toggle(): void; /** Go to a time, in seconds from the start. */ seek(t: number): void; /** Go to the moment the leader next crosses the line. */ nextLap(): void; setSpeed(speed: number): void; /** Draw again with new options (the language, the theme): the clock and the race stay where they are. A new circuit, seed, laps or cars is a new race: mount it again. */ update(options: O): void; /** Play another race in the same view (a feed that came in again while a race is followed): the clock stays where it is, held to the new race's end, and stays playing or paused. */ replace(race: CircuitRace): void; destroy(): void; } /** * Mount a simulated race on a circuit: the circuit flat (or in 3D) with a dot for each made-up car, the race clock, play and pause, the speeds 1×, 10× and 60×, a slider over the whole race and the timing board, moving * together. It does nothing until it is played, and nothing while it is paused, hidden or out of sight. * @example * ```ts no-run * import { mountCircuitRace } from "@johnmorrisdotca/kyogijo-stadiums/circuits"; * const race = mountCircuitRace(document.querySelector("#race")!, { circuit: "las-vegas" }, { speed: 10 }); * race.play(); * ``` */ export declare function mountCircuitRace(host: HTMLElement, initial: RaceViewOptions, settings?: RaceViewSettings): KyogijoRace; /** A race in a page, drawn in a scene: what `mountCircuitRace` does on the circuit's own drawing, and `mountDistrictRace` on a district's ground. */ export declare function mountRaceIn(host: HTMLElement, initial: O, scene: RaceScene, settings?: RaceViewSettings): KyogijoRace;