import { KYOGIJO_STRINGS } from "./strings.core.ts"; import { type PresetTable, type TurnDirection, type TurnPreset, type TurnView } from "./turn.camera.ts"; import type { Plane } from "./turn.kit.ts"; import { type UprightOptions, type Uprights } from "./uprights.ts"; import { type ResolvedBoard } from "./overlay.ts"; import type { VenueSettings } from "./venue.ts"; import type { Box3 } from "./turn.camera.ts"; import type { OutsideSpec } from "./outside.dom.ts"; import type { GovernorTuning, Quality, QualityTier } from "./quality.ts"; import type { Language, LightingOptions, LightingPreset, ScoreOptions, SurfaceOptions } from "./types.ts"; /** What can be asked of a 3D view. */ export interface TurnSettings { /** The viewpoint it opens on: `overhead`, `broadcast`, `end` or `corner` (the default). */ preset?: TurnPreset; /** An exact opening view, laid over the preset's. */ view?: Partial; /** Whether the buttons under the view are drawn (a row of viewpoints, turn, raise, zoom and reset). True when left out; the keys and the pointer work either way. */ controls?: boolean; /** What stands on the surface: `false` for the floor alone, or which kinds, whether the boards and the glass are drawn, the height of a volleyball net. True when left out. */ uprights?: boolean | UprightOptions; /** * The venue round the surface, raised in 3D from the data the package already has: the stands of a drawing's `crowd` (every tier a strip of raked planes with the crowd on it, the walks between the tiers, a * ballpark's grandstands and the seats on top of its wall) and a dojo's room (its walls with their doors and windows, the dais, the banner, the balconies and the edge of the mats). `true` or `false`, or * `{ roof, detail }`. On when the drawing has a crowd or is a dojo, and off with `uprights: false`. The stands and the walls give way to the eye as the boards do, so that the surface is never hidden. */ venue?: boolean | VenueSettings; /** Where the score of a score drawing goes: `board` (the default) hangs it up as a scoreboard that faces the eye (over the middle of a court or a rink, behind an end of a field, behind centre field in a ballpark) and takes the panel off the floor; `floor` leaves the panel on the floor. */ score?: "board" | "floor"; /** What a finger does on the view: `scroll` (the default) lets a vertical swipe scroll the page and a sideways one turn the view; `turn` keeps every touch for the view, which then also tips it. */ touch?: "scroll" | "turn"; /** `smooth` glides between viewpoints, `none` jumps; `auto` (the default) glides unless the reader prefers reduced motion. */ motion?: "auto" | "smooth" | "none"; /** The drawing the floor is, in place of `drawKyogijo`: a chart's `draw`, for instance. It is given the options with the view's own changes (the whole surface, lying wide). */ floor?: (options: SurfaceOptions | ScoreOptions) => string; /** How long a lens the eye has, as a multiple of the view's longer side: 8 by default (`LENS`), and the larger it is the flatter the picture; a short lens makes the near end of a turning floor swell. */ lens?: number; /** The size the first view is worked out for, in pixels, when the markup is made away from a page. 960 by 600 by default. */ size?: { width: number; height: number; }; /** The prefix of the ids in the view, for a page with more than one. A hash of the options when missing. */ id?: string; /** * The auto-turn, a trophy case's slow turn of the whole view: `true` starts it when the view is mounted (paused, if the reader prefers reduced motion), `"force"` starts it even then; left out, nothing moves until * the reader presses Play (or Space). It stops while the pointer holds the view and while the page is hidden, and the keys, the viewpoints and the reset stop it. */ autoPlay?: boolean | "force"; /** Degrees of yaw a second the auto-turn goes by: 12 by default, positive turning the near side to the right as a drag to the right does, negative the other way. */ speed?: number; /** Which way the auto-turn goes: `"counterclockwise"` (the way it has always turned, the near side swinging to the viewer's right) by default, or `"clockwise"`. The Reverse button, `setDirection` and `update` change it; a negative `speed` reverses it too. */ direction?: TurnDirection; /** Called with the direction when the Reverse button or `setDirection` changes it. */ onDirectionChange?: (direction: TurnDirection) => void; /** Called with `true` when the auto-turn starts and `false` when it stops, whatever stopped it. */ onPlayChange?: (playing: boolean) => void; /** * How much the view draws, so that it turns well on every device: `"auto"` (the default) starts on `high` and watches the frames the view makes while it turns, stepping a tier down when they run over budget for a while and back up * when they have been steady for longer; `"high"` is everything as it always was; `"medium"` and `"low"` draw less (the buildings round a district stand up fewer, the trees and the crowd are thinner, a small venue is a block, and the layers * are rastered at a lower pixel ratio). A tier asked for by name is kept; `setQuality` changes it at once, and the camera and the auto-turn go on. See `docs/quality.md`. */ quality?: Quality; /** How the frames are judged in `auto` (see `GovernorTuning`): for a test or a screen that is unusual; the defaults suit a 60 Hz display. */ qualityTuning?: Partial; /** Called with the tier the view is drawn at when it is first mounted and each time `auto` or `setQuality` changes it. */ onQualityChange?: (tier: QualityTier, quality: Quality) => void; /** Called after the view has changed by a key, a button or the pointer, with the view and the viewpoint it is (`undefined` when it has been turned by hand). */ onChange?: (view: TurnView, preset: TurnPreset | undefined) => void; } /** The pixels in one foot of the scene at a zoom of 1: the floor is drawn this big, and scaled down to fit. A larger floor is sharper. */ export declare const WORLD_PX = 1400; /** Everything a 3D view is made of. */ export interface TurnModel { id: string; language: Language; /** The options the floor is drawn from: the whole surface, lying wide. */ options: SurfaceOptions | ScoreOptions; title: string; /** What the drawing says, and then what stands on it. */ description: string; /** The sentence about what stands on the surface, or an empty string. */ standing: string; /** The floor: the markup of the flat drawing. */ floor: string; /** The floor's viewBox in feet. */ viewBox: { x: number; y: number; w: number; h: number; }; /** Pixels in a foot. */ scale: number; uprights: Uprights; /** The patterns the venue's planes are drawn with, and the crowd's colours (custom properties) they read: both empty when the view has no venue. */ defs: string; crowdStyle: string; /** Whether the venue is raised. */ venue: boolean; /** The lighting of the venue (`data-lighting` on the view's root, which the stylesheet reads), or `undefined`. */ lighting?: LightingPreset; /** The sport and look the floor is painted in, when it has one (a budō surface's mats): the planes of its room are painted in the same look. */ look: { sport: string; look: string; } | undefined; planes: Plane[]; /** The whole scene in pixels, from its middle: the floor's rectangle, and the height of the highest thing. */ box: Box3; /** The middle of the floor, in feet. */ centre: [number, number]; view: TurnView; /** False when there is nothing to turn: a badge is a strip, not a surface. */ turnable: boolean; /** The four viewpoints, when the model has its own (a tournament layout's); the sport's when missing. */ presets?: PresetTable; /** A lens of the model's own, as a multiple of the view's longer side, used when the settings give none: a scene that turns about a point far from some of what it shows wants a longer one, so that what swings toward the eye does not swell. */ lens?: number; /** The flat drawing to show where the 3D view cannot be drawn, when it is not `drawKyogijo`'s of `options` (a tournament layout's). */ flat?: string; /** The buildings of a scene that has several standing apart (a district's), each as the convex hull of its outline in the drawing's frame, in feet: the planes that name one (`Plane.group`) are stacked building by building. */ groups?: { hull: readonly (readonly [number, number])[]; }[]; /** The board the options ask for (`board`), laid over the view: a layer of its own, never a plane of the scene. */ board?: ResolvedBoard; /** Whether the model has tiers: a district's does (`quality`), a single surface's does not, and the view does not time its frames or make its layers smaller for one that has none. */ tiered?: boolean; /** The crowd outside the venues of a district, asked for (`DistrictOptions.outside`): a canvas on the floor that the mount paints (`outside.dom.ts`), never a plane of the scene. */ outside?: OutsideSpec; } /** The lighting a venue is built with, as a model's field: the venue's own setting, else the crowd's, and none where there is no venue. */ export declare const lightingOf: (venue: { lighting?: LightingOptions; } | undefined, crowd: SurfaceOptions["crowd"]) => { lighting?: LightingPreset; }; /** The options with what makes the floor of a 3D view: the whole surface, lying wide, at its full size. */ export declare function floorOptions(options: SurfaceOptions | ScoreOptions): SurfaceOptions | ScoreOptions; /** The view a set of settings opens on. */ export declare const openingView: (settings: Pick, sport?: string | PresetTable) => TurnView; /** * The scene's extent in pixels from its middle: the area it is fitted to (in feet, in the drawing's frame) widened to take in every plane that is not the ground, and as high as the highest of them (or of `lift`, the height * of the floor itself). */ export declare function sceneBox(planes: readonly Plane[], area: { x0: number; y0: number; x1: number; y1: number; }, lift: number, centre: readonly [number, number], scale: number): Box3; /** Work out a 3D view from the options of a drawing. */ export declare function buildTurn(options: SurfaceOptions | ScoreOptions, settings?: TurnSettings): TurnModel; /** The words of the 3D view in the model's language. */ export declare const turnWords: (model: Pick) => (typeof KYOGIJO_STRINGS)["en"]["turn"];