/** How the scene is looked at: turned about the vertical (degrees, clockwise as the eye sees the floor), tipped back from straight overhead (degrees), and magnified. */ export interface TurnView { yaw: number; pitch: number; zoom: number; } /** The named viewpoints. */ export type TurnPreset = "overhead" | "broadcast" | "end" | "corner"; /** The viewpoints, in the order the controls and the number keys list them. */ export declare const TURN_PRESET_NAMES: readonly TurnPreset[]; /** * The four viewpoints. `overhead` looks straight down; `broadcast` is the main camera, high on one side line and turned a little towards the near end so that the boards, the nets and the goals show their faces; `end` stands behind an end line, along the * surface, which is where a net, a goal or a basket is best seen; `corner` is low, from a corner, with the nearest net or goal in front. */ export declare const TURN_PRESETS: Readonly>; /** The same four for a long, narrow surface (a football field, a hockey rink): turned less, because a diagonal view would shrink it in the box. */ export declare const LONG_PRESETS: Readonly>; /** * The same four for the net sports, whose net runs across the court: seen from the side line it is a stick, so the broadcast view stands high behind an end line, as a * television camera does, and the end-on view is lower behind it. The corner view is the same. */ export declare const NET_PRESETS: Readonly>; /** * The same four for a curling sheet, which is ten times as long as it is wide: from the side it is a strip across the box, so the broadcast and the corner views * stay nearly square on to it, and the end view looks along it. */ export declare const CURLING_PRESETS: Readonly>; /** The four viewpoints of a sport. */ export declare const presetsFor: (sport?: string) => Readonly>; /** The view a mount opens on. */ export declare const TURN_DEFAULT: TurnPreset; export declare const PITCH_MAX = 84; export declare const ZOOM_MIN = 0.5; export declare const ZOOM_MAX = 4; /** An angle in degrees brought to the range -180 to 180. */ export declare const wrap: (angle: number) => number; /** A view held to what the controls allow: the pitch from overhead to 84 degrees, the zoom from half to four times. A number that is not one is left as it was. */ export declare function clampView(view: TurnView, fallback?: TurnView): TurnView; /** The angle equal to `to` that is nearest to `from`, so that a change of view turns the short way round. */ export declare const nearest: (from: number, to: number) => number; /** The view a viewpoint name stands for in a sport, or `undefined` for a name that is not one. */ export declare const presetView: (name: string | undefined, sport?: string) => TurnView | undefined; /** The name of the viewpoint a view is in a sport, or `undefined` when it is none of them (it has been turned by hand). */ export declare function presetOf(view: TurnView, sport?: string): TurnPreset | undefined; /** The steps of the keys and the buttons, in degrees, and the factor of a zoom step. A held Shift takes the larger. */ export declare const STEP: { readonly yaw: 6; readonly yawBig: 24; readonly pitch: 4; readonly pitchBig: 12; readonly zoom: 1.2; }; /** The view after a step of a key or a button. */ export declare function step(view: TurnView, change: { yaw?: number; pitch?: number; zoom?: number; }): TurnView; /** A side a key, a button or a drag takes the surface toward. */ export type TurnToward = "left" | "right" | "up" | "down"; /** * The view after a step of `amount` degrees toward a side, the way a drag toward that side takes the view: left and right carry the near side to the left and to the right (the yaw rises and * falls), up tips the surface as a drag up does and down as a drag down does (the pitch rises and falls). The arrow keys and the four turn buttons are this, so that a drag, a key and a button * toward one side all move the surface the same way. */ export declare function nudge(view: TurnView, toward: TurnToward, amount: number): TurnView; /** * The view after a drag of the pointer by (dx, dy) pixels, `degreesPerPixel` apart: the surface is taken hold of, so a drag to the right carries the side nearest the eye to the right (the * yaw falls) and a drag down tips the top toward the eye (the pitch falls). */ export declare function drag(view: TurnView, dx: number, dy: number, tilt?: boolean, degreesPerPixel?: number): TurnView; /** A box in the scene, in pixels from the scene's middle, the floor at `z0` and the highest thing at `z1`. */ export interface Box3 { x0: number; y0: number; x1: number; y1: number; z0: number; z1: number; } /** How a view is placed in a container: the scale (at a zoom of 1) that fits the scene, and where the middle of what is seen falls. */ export interface Placement { k: number; tx: number; ty: number; } /** Where a point of the scene falls on the screen, in pixels from the middle of the container, when the scene is placed as given and the eye is `distance` pixels away. */ export declare function project(point: readonly [number, number, number], view: TurnView, at: Placement, distance: number): [number, number, number]; /** The rectangle on the screen that a box covers. */ export declare function covered(b: Box3, view: TurnView, at: Placement, distance: number): { x0: number; y0: number; x1: number; y1: number; }; /** * The placement that fits the scene in a container of width `w` and height `h` pixels, centred, with `pad` of its width and height left round it. It fits the scene at every turn about the * vertical at the view's pitch, not at the view's own turn (its `yaw` is not used): the scale and the place are one for the whole circle, so that turning never zooms in and out or sways, and * nothing is cut off at any angle. (A turn used to fit each angle alone, so a long floor was drawn up to 1.8 times as large side-on as end-on.) Tipping the view still rescales it, since the * extent of the scene on the screen changes with the pitch. The perspective bends the sum, so it is found by a few rounds of scaling and re-centring; six is plenty. */ export declare function fit(b: Box3, view: TurnView, w: number, h: number, distance: number, pad?: number): Placement; /** A 4 by 4 matrix, as CSS writes it in `matrix3d`: sixteen numbers, a column after a column. */ export type Mat4 = readonly number[]; /** Two matrices as one: `b` first, then `a`. */ export declare function multiply(a: Mat4, b: Mat4): number[]; /** * The matrix that puts a point of the scene on the screen for a view in a placement: the scene (whose middle is the origin) is scaled, turned about the vertical, * tipped back, shifted to where the fit puts it, and seen with a perspective `distance` pixels deep. This is `project`'s arithmetic as one matrix, so that an * element can be given its whole place in one `matrix3d` and need no 3D context of the browser's: a browser that draws nested 3D layers flat still draws it right. */ export declare function cameraMatrix(view: TurnView, at: Placement, distance: number): number[]; /** A matrix as the CSS `transform` that applies it. */ export declare const matrix3d: (m: Mat4) => string; /** How far a point is from the eye's plane after the scene is turned and tipped, in pixels towards the eye: bigger is nearer. Planes are drawn far first. */ export declare function depthOf(point: readonly [number, number, number], view: TurnView, at: Placement): number; /** How far the eye is from the screen, in pixels, for a container: a long lens, so that the floor keeps its shape and the heights lean a little. */ export declare const eyeDistance: (w: number, h: number, lens?: number) => number;