// Brno map browser API, version 1: the declarations of // `/releases//browser/brno-map.mjs`, published beside it as // `/releases//types/brno-map.d.ts`. Hand-written: this file is // the contract, the implementation (lib/api/v1/browser.ts) is checked against // it. Removing or changing anything here is a breaking change (a new major). // // Units are metres and seconds; the frame is three.js world space, +Y up, // heading 0 faces +Z and positive headings turn toward +X (`release.coordinates`). // The page must map the bare specifiers `three` and `three/addons/` to the // three.js version in `release.three` (one shared instance with the game). import type * as THREE from 'three'; /** Plan point `[x, z]`. */ export type Point=readonly [x:number,z:number]; // --- Release and configuration --------------------------------------------- /** * What the bundle knows about itself from its build. Publish-time facts are * not here because the bundle is built before it is published: the publish * `sequence`, `published`, the `attribution` line, `changes` and * `deprecations` are in the release descriptor (`/releases//index.json`, * the same document `/v1/latest.json` points to) that the game resolved before * importing this module. */ export type BrnoMapRelease=Readonly<{ mapId:'brno'; /** The map's semantic version; its major is `api`. */ version:string; api:1; /** sha256 of the release manifest: one release, its code, data and physics. Rooms pin it. */ mapReleaseId:string; /** The three.js version this bundle was built against (exact; the page must provide its minor). */ three:string; /** The last integrated community build (`'base'` before any), a consistency check beside the release id. */ communityBuildId:string; /** Absolute URL of this release's credits page, resolved from where this module was loaded. */ creditsUrl:string; coordinates:Readonly<{originWGS84:readonly [latitude:number,longitude:number];units:'metres';frame:string}>; }>; export const release:BrnoMapRelease; export type BrnoMapDetail='auto'|'desktop'|'compact'; export type BrnoMapConfiguration={ /** `auto` (default) picks `compact` on coarse pointers and small screens. */ detail?:BrnoMapDetail; /** Service root that `objects/` resolve against. Default: the root this module was loaded from. */ assetBase?:string|URL; /** Overrides of logical paths (`/models/x.glb`) to URLs, ahead of the release's own map. */ manifest?:Readonly>; }; export type BrnoMapRuntime=Readonly<{ detail:'desktop'|'compact';compact:boolean; /** Highest device pixel ratio the map's detail policy is tuned for. */ pixelRatioCap:number; /** The resolved asset directory, ending in `/`. */ assetBase:string; /** True once a URL was resolved or a map started loading; then only the same configuration is accepted. */ locked:boolean; }>; /** * One release and detail policy per page. Before the lock a new configuration * replaces the last one; after it a different one throws (reload the page to * change). Omitted options keep the current configuration's values. */ export function configure(options?:BrnoMapConfiguration):BrnoMapRuntime; /** The current configuration, or null before `configure` (nothing is loaded). */ export function runtime():BrnoMapRuntime|null; /** * URL of a logical map file (`/models/…`, `/textures/…`, `/data/…`, * `/experiments/box3d/full/…`, `/vendor/box3d/…`) in this release. Configures * the defaults first if `configure` was not called, and locks the configuration. */ export function assetUrl(logicalPath:string):string; // --- Loading ------------------------------------------------------------------ export type GraphicsQuality='full'|'compact'; export type BrnoMapProgress={phase:'assets'|'assembly';fraction:number}; export type BrnoMapLoadOptions={ /** Caller-owned; the map renders its reflection captures with it and never disposes it. */ renderer:THREE.WebGLRenderer; /** Aborting rejects a pending load and disposes a loaded map. */ signal?:AbortSignal; onProgress?:(progress:BrnoMapProgress)=>void; /** Default: `compact` when the configured detail is compact, else `full`. */ graphicsQuality?:GraphicsQuality; /** Load photographs and the local reflection only when `startVisualDetails` is called. Default false. `true` implies `assemble`. */ deferVisualDetails?:boolean; /** * Capture a local reflection cube for car paint (the city around the * astronomical clock on náměstí Svobody). Default true. The cooked map (the * default load) captures it after the first frame, one cube face an animation * frame; until then `targets.reflection` holds the environment. */ localReflection?:boolean; /** * Load the city as it was before the community build with this id was * integrated (`release.communityBuildId` names the last one), e.g. to compare * a proposal before and after. Rejects an id this release has not integrated. * Implies `assemble`. */ beforeCommunityBuildId?:string; /** * Assemble the city in the browser from the release's sources and media * instead of loading the release's cooked map (the city assembled ahead, the * profile of the configured detail), which is the default and loads faster. * Default false, or true when `deferVisualDetails` or `beforeCommunityBuildId` * asks for an assembly; `false` with either of them is rejected. */ assemble?:boolean; /** * Where on the plan (x, z: metres) the first view looks. The cooked map * streams its near cells around the camera; those around this place are in * the first frame. An assembled map holds everything from the start and * ignores it. */ startView?:{x:number;z:number}; }; /** Load the map of this release into a new scene. Configures the defaults first if `configure` was not called. */ export function loadBrnoMap(options:BrnoMapLoadOptions):Promise; export type TextureDetailsStatus=Readonly<{status:'idle'|'loading'|'complete'|'cancelled';total:number;loaded:number;failed:number;cancelled:number}>; export type ReflectionStatus=Readonly<{status:'idle'|'waiting-details'|'capturing'|'complete'|'skipped'|'failed'|'cancelled';reason?:string}>; export type VisualDetailsStatus=Readonly<{textures:TextureDetailsStatus;reflection:ReflectionStatus}>; /** One rendered frame, passed to `BrnoMap.update` before the frame is drawn. */ export type BrnoMapFrame={ /** Seconds; drives the map's own animation (fountains, clock, water). */ time:number; /** The camera position: photographs, roof detail and impostors stream around it. */ viewer:THREE.Vector3; /** What the game follows (its car); trams react to it. Default: `viewer`. */ focus?:THREE.Vector3; /** * Seconds pacing the map's own tram simulation: each frame the trams run * the difference since the last frame's value (at most 0.1 s). Default: * `time`. It is not a shared clock: two pages given the same value still * show their trams where each page started them. For trams every page of a * multiplayer room agrees on, run the server's `createTramTraffic` and hand * its poses to `trams.setNetworkTraffic` (after release 1.9.0). */ trafficTime?:number; /** True when a tram must stop because the given tram object would hit something of the game's. */ tramBlocked?:(tram:THREE.Object3D)=>boolean; /** Camera-to-focus distance (m): street-tree fragments nearer the camera than this, less a margin, dither out. Omitted: the last value set (initially 0, no fade); see `setFoliageFadeDistance`. */ foliageFadeDistance?:number; }; /** A car pose as the ground and collision queries read it (a game's car state satisfies it). */ export type CarPose={ readonly x:number;readonly z:number;readonly heading:number; /** The car's last accepted support plane; layered floors (parking decks) are chosen near it. */ readonly contact:Readonly<{initialized:boolean;height:number;grade:number;crossfall:number}>; }; /** Ground height at a plan point (m), optionally for a car on layered floors. NaN where there is no support. */ export type GroundFn=(x:number,z:number,car?:CarPose)=>number; export type StreetCollider=Readonly<{x:number;z:number;radius:number;heading?:number;halfWidth?:number;halfLength?:number;dynamic?:boolean}>; /** The rendered walls as one triangle soup with its bounding-volume hierarchy (input to `createWallCollision`). */ export type WallCollisionData=Readonly<{vertices:Float32Array;indices:Uint32Array;nodes:Float32Array}>; export type CityBuilding=Readonly<{id:number;p:readonly Point[];h:number;name:string;belowGround:boolean;tags:Readonly>}>; export type CityRoadKind="cycleway"|"footway"|"path"|"pedestrian"|"residential"|"secondary"|"secondary_link"|"service"|"steps"|"tertiary"|"tertiary_link"|(string&{}); export type RoadSurface="asphalt"|"compacted"|"concrete"|"concrete:plates"|"dirt"|"fine_gravel"|"grass"|"grass_paver"|"gravel"|"ground"|"metal"|"paved"|"paving"|"paving_stones"|"rubber"|"sett"|"stepping_stones"|"stone"|"terrazzo"|"unhewn_cobblestone"|"unpaved"|(string&{}); export type CityRoad=Readonly<{ id:number;p:readonly Point[];w:number;name:string;kind:CityRoadKind;surface:RoadSurface; /** Where `w` comes from: the way's OSM `width` tag, or an estimate from its road class. */ widthSource:'OSM width'|'estimated from road class'; /** The OSM node id of each point of `p` (same length and order; a closed way repeats its first); ways share the ids where they meet. */ nodeIds:readonly number[]; }>; /** OpenStreetMap buildings and roads of the play area (ODbL 1.0; credit `attribution`). */ export type CityData=Readonly<{ origin:readonly [latitude:number,longitude:number];source:string;attribution:string;license:string; buildings:readonly CityBuilding[];roads:readonly CityRoad[]; /** The map's default start. */ spawn:Readonly<{x:number;z:number;heading:number}>; }>; export type PlaceArea=Readonly<{id:string;name:string;kind:string;p:readonly Point[];holes:readonly (readonly Point[])[];area:number;source:string}>; /** Named squares and parks (OpenStreetMap, ODbL 1.0). */ export type PlaceData=Readonly<{source:string;license:string;inputSha256?:string;areas:readonly PlaceArea[]}>; /** A place's position: map metres (x east, z south), y the floor under it (m; null where the map has none). */ export type DirectoryPoint=Readonly<{x:number;y:number|null;z:number}>; /** A named point of interest; `category` is its OpenStreetMap key=value (`amenity=fast_food`, `shop=clothes`…), `id` `osm:node/`. */ /** `building`: the main station's building, for a point of interest inside it (reached through the station's doors). */ export type DirectoryPoi=DirectoryPoint&Readonly<{id:string;name:string;category:string;brand?:string;address?:string;level?:string;building?:string}>; /** A door the map draws itself in an entrance (frame, leaves, glass and handles in the wall's thickness): its style, * its leaves and how far they stand open (degrees, 0 shut). A game draws no door of its own there. `revolving`: a * revolving door's drum (Clarion), `leaves` its four wings. */ export type DirectoryDoor=Readonly<{style:DoorStyle|'curtain-wall'|'revolving';leaves:1|2|4;openDeg:number}>; /** An address point; `id` is `ruian:` where OpenStreetMap names its RÚIAN record, else `osm:node/`. */ export type DirectoryAddress=DirectoryPoint&Readonly<{id:string;street:string;houseNumber:string;conscriptionNumber?:string;streetNumber?:string;postcode?:string}>; /** A door (OpenStreetMap `entrance`). */ export type DirectoryEntrance=DirectoryPoint&Readonly<{id:string;kind:'main'|'service'|'shop'|'garage'|'home'|'exit'|'emergency'|'other';name?:string; /** The main station's open doors and the doors the map draws: the building, the rooms the door joins (inside, * outside) and its clear width (m). */ building?:string;joins?:readonly [string,string];widthM?:number;door?:DirectoryDoor}>; /** A transit stop position or platform with the lines that call (`tram 4`, `bus 67`, `trolleybus 37`…); `platform` is its local ref. */ export type DirectoryStop=DirectoryPoint&Readonly<{id:string;name:string;kind:string;modes:readonly ('tram'|'bus'|'trolleybus'|'train')[];lines:readonly string[];platform?:string}>; /** A parking area (OpenStreetMap `amenity=parking`): its outline in map metres, its tags where given. */ export type DirectoryParking=Readonly<{id:string;name?:string;access?:string;parking?:string;fee?:string;capacity?:number;outline:readonly Point[]}>; /** A crossing or a traffic signal node, with its OpenStreetMap crossing and signal tags. */ export type DirectoryNode=DirectoryPoint&Readonly<{id:string;[tag:string]:string|number|null}>; /** A named pose a game may start a player at (`station-hall`: the main station's departure hall). */ export type DirectoryStart=Readonly<{id:string;name:string;x:number;y:number;z:number;heading:number;source:string}>; /** * Places a game can name and route between, inside the play outline (public/data/places.json; OpenStreetMap, * ODbL 1.0: credit `attribution`). `roadTags` holds the access, direction, lane, sidewalk and cycleway tags of * the map's roads by `CityRoad.id`. */ export type DirectoryData=Readonly<{schemaVersion:1;id:string;source:string;license:string;attribution:string;frame:string; pois:readonly DirectoryPoi[];addresses:readonly DirectoryAddress[];entrances:readonly DirectoryEntrance[];stops:readonly DirectoryStop[]; parking:readonly DirectoryParking[];roadTags:Readonly>>>; crossings:readonly DirectoryNode[];signals:readonly DirectoryNode[];starts:readonly DirectoryStart[]}>; /** A drivable route of the Vaňkovka parking: plan points (`pathXZ`) or points with their deck height (`pathXYZ`). */ export type ParkingRoute=Readonly<{id:string;pathXZ?:readonly Point[];pathXYZ?:readonly (readonly [x:number,y:number,z:number])[];widthM?:number;source?:string;sourceLevels?:readonly string[]}>; export type ParkingData=Readonly<{ routes:readonly ParkingRoute[]; schemaVersion?:number;status?:string;frame?:string; plateaus?:Readonly<{P1:number;P2:number}>; annex?:Readonly<{minX:number;maxX:number;minZ:number;maxZ:number}>; models?:readonly Readonly<{name:string;triangles:number;layer:string|null}>[]; sourceWallCuts?:readonly Readonly<{file:string;sourceFace:number}>[]; sourceFloorTriangles?:Readonly<{P1:number;P2:number;Dornych:number;southRamp:number}>; hiddenFloorAreaM2?:number; materialColoursSRGB?:Readonly<{asphalt:string;walls:string;roof:string;ceiling:string;concrete:string;brick:string;paint:string;yellow:string}>; uncertainties?:readonly string[];modelSHA256?:string; }>; /** The unbuilt new City Hall: the plan ring of its base, the map's keep-out and minimap footprint. */ export type NewCityHallData=Readonly<{footprint:readonly Point[]}>; /** The Box3D engine module of this release (Emscripten; SIMD, no threads). Its API is Box3D's own and is not described by v1. */ export type Box3DModule={readonly [name:string]:any}; /** The release's physics files and engine. Usable before a map loads (e.g. to prepare physics while the city loads). */ export type BrnoMapPhysics=Readonly<{ /** URL of a file named by the physics manifest (`manifest.json`, a chunk's `file`, `props.b3c`, …). Configures the defaults first if `configure` was not called. */ url(file:string):string; /** Import this release's Box3D engine and instantiate it (each call makes a new instance). */ loadBox3D():Promise; }>; /** The same object as every loaded map's `physics`. */ export const physics:BrnoMapPhysics; // --- Physics documents ---------------------------------------------------------- // The decoded physics files a game reads (fetched through `physics.url` in the // browser, parsed in `ServerRelease.physics` on a game server). Every field // named here is part of v1: renaming or removing one, or changing its meaning, // is a breaking change. Fields not named here are internal. export type Vector3Tuple=readonly [x:number,y:number,z:number]; export type QuaternionTuple=readonly [x:number,y:number,z:number,w:number]; /** A 4×4 matrix in three.js `Matrix4.toArray()` (column-major) order. */ export type MatrixElements=readonly number[]; export type PhysicsBounds=Readonly<{minX:number;maxX:number;minY:number;maxY:number;minZ:number;maxZ:number}>; /** A collision chunk of the physics manifest; its vertices are local to `origin`. */ export type PhysicsChunk=Readonly<{ id:string;file:string;origin:Readonly<{x:number;y:number;z:number}>;bounds:PhysicsBounds; /** sha256 and length of the decompressed BSC1 bytes. */ sha256:string;byteLength:number;compression?:'gzip'; /** Named triangle ranges; `ground` is the drivable floor. */ sections:readonly Readonly<{name:string;firstTriangle:number;triangleCount:number}>[]; /** * Contact parts of the chunk's bodies (triangle numbers in the chunk). `kind` * says from which side a car meets their faces: `ground-patch` from above, * `surface-patch` from both sides, `front-patch` from the front only; * without a kind the part is a closed component. */ contactMeshes?:readonly Readonly<{sourceObject:string;kind?:'ground-patch'|'surface-patch'|'front-patch';triangleIndices:readonly number[];[key:string]:unknown}>[]; [key:string]:unknown; }>; /** A start pose on the physics floor (`y` is its height). */ export type PhysicsStart=Readonly<{id:string;label:string;x:number;y:number;z:number;heading:number;driveable?:boolean;blocked?:boolean;grade?:number;crossfall?:number;groundCenterY?:number;[key:string]:unknown}>; /** `manifest.json`. */ export type PhysicsManifest=Readonly<{ chunks:readonly PhysicsChunk[]; exclusions:Readonly<{sourceWorldSha256:string;[key:string]:unknown}>; spawns:readonly PhysicsStart[]; /** The play outline in plan, counter-clockwise. */ playOutline:readonly Point[]; [key:string]:unknown; }>; /** The world a physics document was baked from; the props catalogue, grounding and `exclusions.sourceWorldSha256` must name the same. */ export type PhysicsSourceWorld=Readonly<{sha256:string;generatedAt:string}>; export type PropBounds=Readonly<{min:Vector3Tuple;max:Vector3Tuple}>; /** One collision shape of a movable prop, in its model space: a box or a convex hull. */ export type PropShape= | Readonly<{type:'box';center:Vector3Tuple;halfExtents:Vector3Tuple;sourcePart:string;[key:string]:unknown}> | Readonly<{type:'hull';points:readonly Vector3Tuple[];sourcePart:string;[key:string]:unknown}>; /** * How an anchored prop holds until it breaks free. The prop is a static body * at its entity's pose as authored (no seating on the ground at run time: it * is drawn exactly there, flush with its neighbours), until one contact both delivers at least * `breakEnergyJ` (½·m·v² of the other body, `m` its effective mass at the contact (`PropContact`) and `v` the contact's * approach speed) and approaches at no less than `breakSpeed` (m/s). What * the break leaves is `onBreak`'s: * - `'fall'` (also when `onBreak` is absent): the prop becomes a dynamic body * of the asset's mass, whole when the asset's `cutHeight` is null (no * stump is left), above the cut otherwise; * - `'shatter'` (the Vaňkovka roof glass's panes, added after release 1.2.1; * the station pavilion's ground-tier shop panes, after 1.41.0): * the prop breaks up: its body leaves the world (it collides no more) and * its instance is hidden; nothing of it is left to fall. A game that does * not know `'shatter'` treats it as `'fall'` (a whole pane falls), which * stays playable. How a glass prop breaks is its asset's `glazing` * (`PropProfile.glazing`). * The set is closed: a later value is a new API version. * * `breakLoadN` (optional; the Vaňkovka roof glass's panes, after 1.2.1): the * prop also breaks, as `onBreak` says, when a static load above this (N) * rests on it, e.g. a wheel: a car standing on it breaks it where its weight * share on a wheel (m·g over the wheels touching) exceeds `breakLoadN`, even * when it rolled on too slowly for the impact rule. A game that ignores it * breaks the prop by impact only. * * `supportedBy` (optional; the Vaňkovka car park's height-bar beams, after * 1.2.1): the catalogue ids (`PropEntity.id`) of the breakable members that * carry this prop. When any of them breaks, the game releases this prop in * the same step, as broken (as its `onBreak` says), with no energy needed; * a prop released so releases what it carries in turn. A game that ignores * it leaves the prop standing where it was drawn, held by nothing. * * `rubble` (optional; the Vaňkovka edges' `parapet` segments, after 1.7.0): * a prop that falls (`onBreak` `'fall'` or absent) falls as these pieces * instead of whole (`PropRubblePiece`). On the break the game takes the * prop's body out of the world and makes one dynamic body a piece, at the * prop's pose (its entity's position and rotation, as it stands), at rest, * awake, each of its piece's shapes (model space, scaled by the entity's * scale) and `massKg`; the piece is drawn as the prop's instance mapped by * its `drawMatrix`. What a break leaves in the way of the body that broke * it is the pieces in its way (`rubbleInWay`, `freedMass`). The pieces split * the prop across its model x–y face; a body comes through it along model z. * A game that ignores `rubble` breaks the prop whole, as releases up to * 1.7.0 did: that stays playable. */ export type PropAnchor=Readonly<{breakEnergyJ:number;breakSpeed:number;onBreak?:'fall'|'shatter';breakLoadN?:number;supportedBy?:readonly string[];rubble?:readonly PropRubblePiece[];[key:string]:unknown}>; /** * One piece of what an anchored prop falls as (`PropAnchor.rubble`), in the * prop's model space: its collision `shapes` (no two pieces' shapes touch, * so a game releases them apart), its mass (kg; the pieces' masses sum to * the asset's `approximateMassKg`) and `drawMatrix` (column-major), which * maps the prop's own drawing (its instance's geometry) onto the piece's. * Drawn where its body is: instance world matrix = the body's pose (with the * entity's scale) × `drawMatrix` × the instance's matrix relative to its * entity's (`PropEntity.matrix`⁻¹ × the instance's world matrix, the * identity for the Vaňkovka edges' segments). */ export type PropRubblePiece=Readonly<{shapes:readonly PropShape[];massKg:number;drawMatrix:MatrixElements;[key:string]:unknown}>; /** A movable prop asset of the catalogue. */ export type PropProfile=Readonly<{ kind:string;sourceBounds:PropBounds;solidBounds:PropBounds; /** Points that must rest on the ground (feet, the base ring). */ supportPoints:readonly Vector3Tuple[]; shapes:readonly PropShape[];approximateMassKg:number; /** Height (m, model space) where a breakable prop (a tree, a lamp) snaps off its stump; null for a prop that moves whole. */ cutHeight:number|null; /** * A prop a game raises or lowers (the old town's rising bollards): lowered, it stands `travelM` under its up pose, * flush with the paving, and should not collide; `initial` is the state the release stages and draws its props in * (a prop's entity pose and the map's instance are that state's). A game that ignores it gets that state. */ retractable?:Readonly<{travelM:number;initial:'up'|'down'}>; /** * Present on a prop that is static until broken and says when it breaks * (the Vaňkovka roof edge's `parapet` segments, added after release 1.0.0; * the Vaňkovka roof glass's `glass` panes, which shatter, after 1.2.1). * Absent: the prop is loose, or its entities carry their own anchors * (`PropEntity.anchor`: every `tree` and every `lamp`, after 1.9.0). * Releases up to 1.9.0 left trees and lamps without one, breakable by the * game's own rule. */ anchor?:PropAnchor; /** * The glass of a glass prop (added after release 1.41.0): how it breaks * when its anchor gives way (`onBreak` `'shatter'`). * - `'toughened'` (also when absent): toughened safety glass bursts into * small blunt pieces at once and leaves its frame empty, as `'shatter'` * says (the station pavilion's shop panes); * - `'laminated'`: laminated glass cracks but its interlayer holds it * together in its frame: a game may draw it cracked in place and keep its * collision until a second break (the Vaňkovka roof glass's panes, which * releases up to 1.41.0 shipped without the field). * A game that ignores it shatters every glass prop as `'shatter'` says. */ glazing?:'toughened'|'laminated'; [key:string]:unknown; }>; /** * One placed prop; `asset` keys `PropCatalog.assets`, `id` is the scene tags' * feature or catalogue id. `anchor` (added after release 1.9.0): this * placement's own break rule, which takes the place of its asset's * (`entity.anchor ?? asset.anchor`): every `tree` has one, from its own stem * (props of one tree model differ by their stems), and every `lamp`, from * its model's steel pole. The prop is static until the rule breaks it, as * `PropAnchor` says, but an entity's own anchor does not change where it * stands: a game stands it where it stood it before the anchor was added * (at its `GroundingCorrection` where `grounding.json` has one, as some * lamps have; seated on its floor otherwise), not necessarily at its * authored pose, which only an asset's anchor fixes. A game that ignores it * keeps its earlier behaviour for the prop. */ export type PropKind="advertising-column"|"barrier"|"barrier-arm"|"barrier-cabinet"|"bench"|"bench-block"|"bench-island"|"bike-hoop"|"bin"|"board-post"|"bollard"|"chair"|"charging-station"|"clock-post"|"cross"|"drinking-fountain"|"drinking-tap"|"fire-hydrant"|"flagpole"|"glass"|"grit-bin"|"hanging-board"|"height-bar"|"height-bar-post"|"lamp"|"lamp-post"|"mirror-post"|"parapet"|"parking-meter"|"planter"|"post-box"|"poster-box"|"railing"|"sign"|"sign-post"|"street-cabinet"|"table"|"transit-stop-sign"|"transit-validator"|"tree"|(string&{}); export type PropEntity=Readonly<{id:string;kind:PropKind;asset:string;matrix:MatrixElements;position:Vector3Tuple;rotation:QuaternionTuple;scale:Vector3Tuple;render?:Readonly<{metadata:string;idField:string|null;id:string;asset?:string;meshNamePrefix?:string;includeAllLods:boolean}>;bakeSource?:Readonly<{entryIndex:number;prototype:number;meshName:string}>;anchor?:PropAnchor;[key:string]:unknown}>; /** `props.b3c`, gunzipped and parsed. */ export type PropCatalog=Readonly<{sourceWorld:PhysicsSourceWorld;assets:Readonly>;entities:readonly PropEntity[];[key:string]:unknown}>; /** A placed prop's checked rest pose on the ground (`id` is a `PropEntity.id`). */ export type GroundingCorrection=Readonly<{id:string;position:Vector3Tuple;rotation:QuaternionTuple;[key:string]:unknown}>; /** `grounding.json`. */ export type Grounding=Readonly<{sourceWorld:PhysicsSourceWorld;corrections:readonly GroundingCorrection[];[key:string]:unknown}>; /** A stump section: closed loops (model space) where a part of the asset is cut. */ export type CutPart=Readonly<{meshName:string;loops:readonly (readonly Vector3Tuple[])[];[key:string]:unknown}>; /** `cut-sections.json`: the cut sections of breakable prop assets. */ export type CutSections=Readonly<{assets:Readonly>>;[key:string]:unknown}>; /** An entry of `prop-starts.json`: a start pose facing the prop `targetId`. */ export type PropStart=PhysicsStart&Readonly<{targetId:string}>; /** A city cell of a cooked map: its key (stable in a release) and its drawables. */ export type BrnoMapCell=Readonly<{ key:string; /** * The cell's drawables (meshes, instanced meshes, lines) in the scene: each * is one cell's. Their ancestors (groups, LODs) may hold several cells' * drawables and are not listed; reach them by `parent`. */ objects:readonly THREE.Object3D[]; }>; /** * The cells of a cooked map as they are shown and let go (see Cells on * `BrnoMap`), e.g. to bind a game's physics to the props of a cell as it * appears instead of searching the scene every frame. An assembled map has * no cells: `shown()` is empty and no listener is called. A listener's error * is reported (`reportError`) and stops neither the map nor other listeners; * after `dispose` no listener is called. Each listener hears of a cell's * release after its show, also when another listener lets the cell go as it * hears of its show (by `dispose`, or the map reloading its cells after the * GPU was lost): its objects may then have left `scene` by the time a later * listener hears of the show, and its release follows. */ export type BrnoMapCells=Readonly<{ /** * Call `listener` with each cell shown now, then with each cell shown from * now on: once its objects are in `scene` with their world matrices, before * a frame draws them. Returns a function that stops the calls. */ onShow(listener:(cell:BrnoMapCell)=>void):()=>void; /** * Call `listener` with each cell let go from now on: once its objects have * left `scene` and their resources are freed (the same `objects` its show * gave). Drop what refers to them. Returns a function that stops the calls. */ onRelease(listener:(cell:BrnoMapCell)=>void):()=>void; /** The cells shown now. */ shown():BrnoMapCell[]; }>; /** * A loaded map. * * Ownership: everything in `scene` when `loadBrnoMap` resolves belongs to the * map; anything the game adds afterwards belongs to the game. `dispose()` * frees exactly the map's resources (geometry, materials, textures, render * targets, the sun's shadow map) and removes the map's objects from `scene`; * the game's objects, its renderer and its own resources stay untouched. * * Cells: a cooked map (the default) streams its city cells around the camera, * so map objects are added to `scene` and removed from it as the camera * moves; `cells` tells which, when. An assembled map holds every object from * the start. * * Still objects: the objects of a cooked map's cells do not move. Their * `matrix` is set once (`matrixAutoUpdate` is false) and their `matrixWorld` * as a cell is shown; three.js's per-frame matrix update leaves them out * until the scene moves (or one is put under another parent), and then makes * them again. `updateWorldMatrix(true, …)` and `getWorldPosition` read them * right, also right after the scene moved, as three.js reads any object (an * ancestor whose own matrix three.js does not update must be updated by the * game, as always). Setting `position`, `rotation` or * `scale` on one has no effect. What a game adds under one of them is * updated by three.js as usual, following it. One a game puts under its own * object follows that object as any three.js object with `matrixAutoUpdate` * false does (in each frame's update). Trams and the clock move * (`driveDynamic`). * * Decoder workers: a cooked map has three.js's shared `MeshoptDecoder` * decode in a few workers (fewer on the compact profile; one fewer than the * device's cores at most, one at least). Being shared with the game's own loaders, * they stay after `dispose`; `MeshoptDecoder.useWorkers(0)` ends them. * * Scene tags that are part of v1 (read them from `object.userData`): * - `driveSolid`: `true` makes the object and its subtree solid for cars * (`createObjectCollision`); `false` excludes the subtree; absent inherits. * A game may set `false` on map objects it simulates itself. * - `driveDynamic`: `true` on a solid subtree that moves (trams, the clock, * the leaves of the doors a game opens, `BrnoMap.doors`); collision re-reads * its transforms, a physics game drives it kinematically. * - `driveActor`: on each `driveDynamic` root, `{kind: 'clock' | 'tram' | * 'door', key: string}`: what moves and its stable identity in the release (a * clock tier's name, `tram-`, `door::`), * the same on every page of a release. Door leaves (after release 1.45.0) * stand still until a game opens them; each leaf root's meshes are its * convex parts (a leaf, a revolving door's wing or post). * - `communityProp`: on an `InstancedMesh` of street features, * `{kinds: string[], featureIds: string[], partId: string, lod: string}`: * per instance index the feature's kind (`bench`, `bin`, `tree`, `lamp`, * …) and stable id (a `PropEntity.id` for movable ones); for the whole mesh * the stable id of the rendered part and its level of detail (`high`, * `low`, `impostor`, `impostor-wood`). The physics catalogue binds to the * `high` parts. * - `photoPlacementIds`: on an `InstancedMesh` of photographed garden * benches, the placement id of each instance. * - `physicalPropIds`: on an `InstancedMesh` of movable furniture or of * anchored props (the Vaňkovka roof edge's segments, `PropAnchor`), the * physics catalogue id (`props.b3c` entity) of each instance. * Other `userData` keys and object names are internal and may change. */ /** * A wall face, in map metres: its plan line `a`→`b` and the plan `normal` towards the side the point was * asked from (the street, asked from the street). Seen from that side `a` is on the left; `u` (metres along * the wall) runs from `a` to `b`. `baseY`, `topY`: the lowest and highest point of the face. */ export type FacadeWall=Readonly<{a:readonly [x:number,z:number];b:readonly [x:number,z:number];normal:readonly [x:number,z:number];baseY:number;topY:number}>; /** * What the wall shader paints across a piece of a ground storey: `pier` (the masonry at a shop run's ends), * `window`, `doorway` (a residential door), `shop-glass`, `shop-door` (a shop run's door bay: glass down to * the pavement) or `blank` (plain wall between residential openings). Openings say their painted bottom * and top (`sillY`, `headY`; a shop door's `headY` is the underside of its transom). A doorway of a * facade family's street front (after client 1.20.0, facade index version 2) says its `style`. */ export type FacadeBayKind='pier'|'window'|'doorway'|'shop-glass'|'shop-door'|'blank'; /** * What a family facade's doorway is (added in client 1.20.0): `house-door`, a tenement's house door (about * 1.2 m wide); `gateway`, a carriage gateway into the courtyard (about 2.2 m wide, higher). Still `kind` * `doorway`: code that switches on the kind keeps working. A doorway of the generic facade has no style. */ export type FacadeDoorwayStyle='house-door'|'gateway'; export type FacadeBay=Readonly<{u0:number;u1:number;kind:FacadeBayKind;sillY?:number;headY?:number;style?:FacadeDoorwayStyle}>; /** The architectural families of the map's facades (plan SZP-331): stage 1b paints tenements, the others keep the generic facade. */ export type FacadeFamilyName='tenement'|'interwar'|'baroque'|'postwar'|'contemporary'|'utility'; /** * The facade family of a generic wall (added in client 1.20.0; only where the facade index carries one, * version 2): `name`, its `variant` (tenements `T1`…`T5`; `courtyard` for the family's courtyard faces) and * `street`, whether the wall is one of the building's street fronts (bays sized to the front, shops where * the data puts shops, a house door or gateway) rather than a courtyard face (no shops). */ export type FacadeFamily=Readonly<{name:FacadeFamilyName;variant:string;street:boolean}>; /** A door the map draws itself on the wall (a directory entrance with `door`), at `u`, `width` its clear width (m) where known. */ export type FacadeDoor=Readonly<{entrance:DirectoryEntrance;u:number;width:number|null}>; /** * The facade at a point: the wall face nearest to it and what is painted on it. `source`: `generic` (the * map's procedural facade: its ground storey's bays, in order along `u`, within `span` of the point), * `photo` (a registered photograph covers the wall) or `module` (a building the map models itself: * the station, the new buildings, Dornych…); the last two have no bays (`bays` empty, `groundStorey`, * `storeyHeight`, `bayWidth` null). `u`: the point's position along the wall. `groundStorey`: at the * point, its base (the storey grid's line v = 0) and height; on a sloping street the base rises along the * wall by `slope` metres per metre of u, and a bay's `sillY`/`headY` hold at its middle. `shop` when the * point is on a shopfront run, whose `fascia` (painted sign band, at the point) it gives. The bays are * what is painted along the storey's middle line: where a seam between two faces of the wall crosses the * storey, a face's grid may differ above or below it (a door slot never straddles one). `floorY`: the * rendered floor 0.3 m in front of the wall at the point (null where none): on a rising street it may * stand above the storey's base and bury the foot of what is painted there. `storeyHeight` * and `bayWidth`: the grid's storey and bay in metres, for upper windows too. `doors`: the doors the map * draws on this wall within `span`. */ export type FacadeOpenings=Readonly<{ wall:FacadeWall;source:'generic'|'photo'|'module';u:number;floorY:number|null; groundStorey:Readonly<{baseY:number;height:number;slope:number;shop:boolean;fascia?:Readonly<{bottomY:number;topY:number}>}>|null; bays:readonly FacadeBay[];storeyHeight:number|null;bayWidth:number|null;doors:readonly FacadeDoor[]; family?:FacadeFamily; }>; /** * A place for a door: `u0`…`u1` along `wall`, `centre` its middle on the wall's plan line, from `baseY` to * `headY`. `kind`: `entrance`, a door the map draws itself (its `entrance`; draw none there); `shop-door`, a * painted shop door bay between its mullions, up to its transom; `doorway`, a painted residential doorway. * A painted slot never reaches across a pier, a fascia or a seam between wall faces. `baseY` is the * painted door's foot, or the floor in front where the street buries it; `floorY` the rendered floor 0.3 m * in front (null where none): where it is lower than `baseY`, the door needs a step up to it. A doorway of * a family facade says its `style` (after client 1.20.0). */ export type FacadeDoorSlot=Readonly<{u0:number;u1:number;centre:readonly [x:number,z:number];baseY:number;headY:number;floorY:number|null; kind:'entrance'|'shop-door'|'doorway';source:FacadeOpenings['source'];wall:FacadeWall;entrance?:DirectoryEntrance;style?:FacadeDoorwayStyle}>; /** `radius`: how far from the point a wall is looked for (m, default 2); `y`: the floor there (default the rendered ground), which picks the walls standing round it; `span`: how far along the wall bays and doors are listed each side of the point (m, default 6). */ export type FacadeQueryOptions=Readonly<{radius?:number;y?:number;span?:number}>; /** `width`, `height`: the smallest opening wanted (m, default any; a painted slot keeps at least 1.8 m above the floor); `reach`: how far along the wall from the point to look (m, default 6); `maxStep`: how far a painted door's foot may stand above the floor in front (m, default 0.6: a few steps); `radius`, `y` as for facadeAt. */ export type FacadeDoorOptions=Readonly<{width?:number;height?:number;reach?:number;maxStep?:number;radius?:number;y?:number}>; /** * The map's facades, as drawn (added in client 1.17.0; facade families from client 1.20.0, which reads * the facade index's versions 1 and 2). The index loads at the first `ready` (a cooked * map fetches it, ~0.8 MB; an assembled one builds it, a few seconds); the queries throw before it has. * `facadeAt`: the wall at a plan point and what it paints, or null where no wall stands within `radius`. * `doorAt`: the door slot nearest the point on that wall: a door the map draws there first, else the * nearest painted door bay (`generic` walls only) that fits `width` × `height`; null where none does. */ export type BrnoMapFacades=Readonly<{ readonly ready:Promise;readonly loaded:boolean; facadeAt(x:number,z:number,options?:FacadeQueryOptions):FacadeOpenings|null; doorAt(x:number,z:number,options?:FacadeDoorOptions):FacadeDoorSlot|null; }>; export interface BrnoMap{ readonly scene:THREE.Scene; /** The map's lights. A game may move the sun and its shadow camera (e.g. to follow its car). */ readonly lighting:Readonly<{hemisphere:THREE.HemisphereLight;sun:THREE.DirectionalLight}>; readonly ground:Readonly<{ /** Highest rendered floor at a plan point; NaN where there is none. */ height(x:number,z:number):number; /** Floor for a car: on multilevel structures (parking decks, ramps) the layer near its last support; elsewhere `height`, or `fallback` where there is no floor; NaN where there is no support. */ forCar(x:number,z:number,car?:CarPose,fallback?:(x:number,z:number)=>number):number; /** The terrain and road surface under the rendered floors, defined everywhere. */ terrain(x:number,z:number):number; }>; readonly collision:Readonly<{ walls:WallCollisionData;streetColliders:readonly StreetCollider[]; /** * The map's solid objects (see the scene tags) for the whole play area, the * game's own objects not among them; cars stand on `ground.forCar` over * `ground.terrain`. Trams and the clock move live, objects follow their * visibility, and `driveSolid: false` the game sets on a map object leaves * it out from then on. A map loaded assembled builds it at first use (about * a second); a cooked map gives it ready, and `createObjectCollision` on its * scene gives this collision (warning once) with the game's solid objects added. */ objects:ObjectCollision; }>; readonly trams:Readonly<{ /** Show only the trams near a plan point (`update` does this around `focus` every frame). */ updateVisibility(x:number,z:number):void; /** Give each tram a contact shadow drawn with the game's shadow texture. */ installContactShadows(texture:THREE.Texture):void; /** Run a query with the tram visibility a plan point would have, then restore it. */ withVisibility(x:number,z:number,query:()=>T):T; /** * Draw the trams where a game server's tram traffic has them (added after * release 1.9.0): `poses` the server's `TramTraffic.snapshot()` as last * received (each pose moves the tram whose `driveActor.key` is its `id`), * `clock` when it was received (`TrafficClock`). Call it every frame * before `update`, with the last poses received: the map then predicts each * tram along its rails from the pose's distance and speed at the server's * time, eases out the network's jitter and freezes a tram whose poses stop * coming (it predicts at most 1.5 s past the server time of its last * pose, then stands there until the next arrives), and `update` no longer * runs its own simulation. `blocked` (optional): true when the given tram object would * hit something of the game's (its own car): the tram is held there until * the server's stop arrives. Without `clock` a pose is drawn as it is * (`x`…`pitch`). `null` returns the trams to the map's own simulation, * from where they stand. */ setNetworkTraffic(poses:readonly (TrafficPose|TrafficAnchor)[]|null,clock?:TrafficClock,blocked?:(tram:THREE.Object3D)=>boolean):void; }>; /** * Environment textures for the game's own materials (car paint). `reflection` * is the local reflection, undefined without one (`localReflection: false`, * disposed). The cooked map (the default load) gives it from the start holding * the environment (the HDR sky the map is lit by) and fills the same target * with the city a few frames after the first frame (`visualDetailsStatus.reflection` * then says 'complete' and `startVisualDetails()` resolves): a * MeshStandardMaterial or MeshPhysicalMaterial given it at load reflects the * city from then on, with nothing to rebind. An assembled map with * `deferVisualDetails` gives it only once captured. */ readonly targets:{readonly environment:THREE.WebGLRenderTarget;readonly reflection:THREE.WebGLCubeRenderTarget|undefined}; /** Data of the same release, loaded with the map. Treat it as read-only: the map shares it. */ readonly data:Readonly<{city:CityData;places:PlaceData;parking:ParkingData;newCityHall:NewCityHallData;directory:DirectoryData;zones:ZoneData}>; readonly physics:BrnoMapPhysics; readonly cells:BrnoMapCells; /** Where a game may put its own doors: the walls and the openings the map paints on them. */ readonly facades:BrnoMapFacades; /** The doors a game opens, and the doors the station builds standing open (after release 1.46.0). */ readonly doors:BrnoMapDoors; /** Advance the map for one frame; call once per frame before rendering. No-op after `dispose`. */ update(frame:BrnoMapFrame):void; /** Set the foliage fade (`BrnoMapFrame.foliageFadeDistance`) after `update`, once the frame's final camera is known. No-op after `dispose`. */ setFoliageFadeDistance(metres:number):void; /** Load deferred photographs and the local reflection; one cached promise per map. A cooked map's resolves once its local reflection is captured, a few frames after the first frame drawn or this call, whichever is first. */ startVisualDetails():Promise; readonly visualDetailsStatus:VisualDetailsStatus; readonly graphicsQuality:GraphicsQuality; /** Switch texture and level-of-detail quality; false when unchanged or disposed. */ setGraphicsQuality(quality:GraphicsQuality):boolean; /** Free the map's resources (see Ownership). Idempotent. */ dispose():void; readonly disposed:boolean; } // --- Doors -------------------------------------------------------------------- /** * How a door opens: `swing` (leaves hung on hinges, opening inwards by * `openDeg`), `slide` (an automatic door's leaves sliding back by `slideM` * along `slideAxis`), `revolving` (four wings on a post turning about the * drum's axis; a quarter turn brings it back to rest). */ export type BrnoMapDoorKind='swing'|'slide'|'revolving'; /** A collision shape of a leaf in its node's frame (m): a box, turned `rotationY` (rad) about y where given, or an upright cylinder. */ export type BrnoMapDoorShape= | Readonly<{type:'box';center:Vector3Tuple;halfExtents:Vector3Tuple;rotationY?:number}> | Readonly<{type:'cylinder';center:Vector3Tuple;radius:number;halfHeight:number}>; /** A box in the world (m): its middle, half-extents along its own axes, turned by `quaternion`. */ export type BrnoMapDoorBox=Readonly<{type:'box';center:Vector3Tuple;halfExtents:Vector3Tuple;quaternion:QuaternionTuple}>; /** A collision shape of a leaf in the world (m): a box, or a cylinder about its own y (`quaternion` turns it). */ export type BrnoMapDoorWorldShape=BrnoMapDoorBox|Readonly<{type:'cylinder';center:Vector3Tuple;radius:number;halfHeight:number;quaternion:QuaternionTuple}>; /** A leaf's world transform: its node's position and quaternion (`[x, y, z, w]`), scale 1 (after release 1.47.0). */ export type BrnoMapDoorPose=Readonly<{position:Vector3Tuple;quaternion:QuaternionTuple}>; /** * One moving part of a door as data (both entries; the browser's `BrnoMapDoorLeaf` adds its scene node): a leaf, or * a revolving door's rotor. Its origin lies on the hinge axis at the leaf's foot (swing), at the leaf's back edge's * foot where it stands shut (slide) or on the drum's axis at the floor (revolving); its local x runs along the leaf * from the hinge (or back edge; a rotor's towards the door's `along`), y up. `leafPose` gives its pose at any value. */ export type BrnoMapDoorLeafData=Readonly<{ /** The leaf's stable id (`door::`), its `driveActor.key`. */ key:string; kind:BrnoMapDoorKind; /** Its origin, shut (world). */ hinge:Readonly<{x:number;y:number;z:number}>; /** The turning axis (world): up. */ axis:readonly [0,1,0]; /** Its pose shut (world; `leafPose` at 0; after release 1.47.0). */ closed:BrnoMapDoorPose; /** Swing: how far it opens (degrees) and which way about `axis` (+1 counter-clockwise seen from above, -1 clockwise): always inwards. */ openDeg?:number;openSign?:1|-1; /** Slide: the unit direction (world) it slides open along, and how far (m). */ slideAxis?:Vector3Tuple;slideM?:number; /** Revolving: the turn (degrees) between two rest poses (`value` 1). */ turnDeg?:90; /** The leaf's width (m; a revolving door's wing reach), height and thickness. */ widthM:number;heightM:number;thicknessM:number; /** Its collision as boxes and cylinders in its own frame, for a game that builds its own body (the browser's meshes under `node` are the same parts). */ shapes:readonly BrnoMapDoorShape[]; /** The same shapes in the world, shut (map metres; after release 1.47.0). `leafShapes` places them at any value. */ closedShapes:readonly BrnoMapDoorWorldShape[]; }>; /** * One moving part of a door (`BrnoMapDoorLeafData`, written out member by member so the release's API comparison * reads every name): its data and `node`, its scene node, a `driveDynamic` root (`driveActor` * `{kind: 'door', key}`) standing at `leafPose(door, index, value)`. The map moves it (`BrnoMapDoor.set`); a game that * moves `node` itself keeps `value` stale. */ export type BrnoMapDoorLeaf=Readonly<{ /** The leaf's stable id (`door::`), its `driveActor.key`. */ key:string; kind:BrnoMapDoorKind; /** Its origin, shut (world). */ hinge:Readonly<{x:number;y:number;z:number}>; /** The turning axis (world): up. */ axis:readonly [0,1,0]; /** Its pose shut (world; `leafPose` at 0; after release 1.47.0). */ closed:BrnoMapDoorPose; /** Swing: how far it opens (degrees) and which way about `axis` (+1 counter-clockwise seen from above, -1 clockwise): always inwards. */ openDeg?:number;openSign?:1|-1; /** Slide: the unit direction (world) it slides open along, and how far (m). */ slideAxis?:Vector3Tuple;slideM?:number; /** Revolving: the turn (degrees) between two rest poses (`value` 1). */ turnDeg?:90; /** The leaf's width (m; a revolving door's wing reach), height and thickness. */ widthM:number;heightM:number;thicknessM:number; /** Its collision as boxes and cylinders in its own frame, for a game that builds its own body (the browser's meshes under `node` are the same parts). */ shapes:readonly BrnoMapDoorShape[]; /** The same shapes in the world, shut (map metres; after release 1.47.0). `leafShapes` places them at any value. */ closedShapes:readonly BrnoMapDoorWorldShape[]; node:THREE.Object3D; /** How far it stands open: 0 shut to 1 fully open (revolving: quarter turns, any number). */ readonly value:number; }>; /** * The shallow room the map draws behind an openable door, solid (floor, walls, * ceiling, back wall): `depthM` from the facade to its back wall, as wide and * high as given, its floor at `floorY`; `light` the colour of its dim interior * light (a game may light it, e.g. a PointLight of that colour inside). `box`: * that room as a box (world; after release 1.47.0): from the door's facade * line `depthM` along `inward`, `widthM` wide about the door's middle, from * `floorY` up `heightM`. */ export type BrnoMapDoorLobby=Readonly<{depthM:number;widthM:number;heightM:number;floorY:number;light:string;room?:string;box:BrnoMapDoorBox}>; /** * A door of the map as data (both entries: the server's `ServerRelease.doors` * lists these; the browser's `BrnoMapDoor` adds the methods that move it). An * openable door (`standsOpen` false) has its `leaves` and its `lobby`. The * doors the main station builds standing open into its halls (`standsOpen` * true) have no leaves to move; `rooms` are the rooms they join (inside, * outside), as `DirectoryEntrance.joins`. */ export type BrnoMapDoorData=Readonly<{ /** Its places.json entrance id where it has one, else the doors review's id (`new-buildings::`, `vankovka:`, `mcdonalds-svobody:main`, `new-city-hall:`, `dornych:::`). */ id:string; /** The places.json entrance at the door (`DirectoryEntrance.id`), null where the directory has none. */ entranceId:string|null; /** The place that draws it: `new-buildings`, `vankovka`, `mcdonalds-svobody`, `new-city-hall`, `dornych`, `station`. */ place:string;name:string|null;kind:BrnoMapDoorKind; /** The look of its leaves (`DoorStyle`, a place's own style name, `revolving`). */ style:string; /** The opening's foot on the facade line (world; y the sill). */ centre:Readonly<{x:number;y:number;z:number}>; /** Unit plan directions: along the opening, and into the building. Absent on a station door. */ along?:Point;inward?:Point; /** The opening's width and height (m). */ widthM:number|null;heightM?:number; standsOpen:boolean; /** A station door: how far its leaves stand open (degrees). */ openDeg?:number; leaves:readonly BrnoMapDoorLeafData[]; lobby:BrnoMapDoorLobby|null; rooms?:readonly [inside:string,outside:string]; /** Its leaves' `driveActor` keys. */ collision:readonly string[]; }>; /** * A door of the map. The game opens an openable door (`set`, `setLeaf`, * `animateTo`) and its leaves move, drawn and solid where they stand * (`collision`: their `driveActor` keys). Shut (the map starts every door * shut), they stop rays and cars as the facade does. A leaf at `value` stands * at `leafPose(door, index, value)`, the pose a game server computes from the * same release (`ServerRelease.doors`). */ export type BrnoMapDoor=Readonly<{ /** Its places.json entrance id where it has one, else the doors review's id (`new-buildings::`, `vankovka:`, `mcdonalds-svobody:main`, `new-city-hall:`, `dornych:::`). */ id:string; /** The places.json entrance at the door (`DirectoryEntrance.id`), null where the directory has none. */ entranceId:string|null; /** The place that draws it: `new-buildings`, `vankovka`, `mcdonalds-svobody`, `new-city-hall`, `dornych`, `station`. */ place:string;name:string|null;kind:BrnoMapDoorKind; /** The look of its leaves (`DoorStyle`, a place's own style name, `revolving`). */ style:string; /** The opening's foot on the facade line (world; y the sill). */ centre:Readonly<{x:number;y:number;z:number}>; /** Unit plan directions: along the opening, and into the building. Absent on a station door. */ along?:Point;inward?:Point; /** The opening's width and height (m). */ widthM:number|null;heightM?:number; standsOpen:boolean; /** A station door: how far its leaves stand open (degrees). */ openDeg?:number; leaves:readonly BrnoMapDoorLeaf[]; lobby:BrnoMapDoorLobby|null; rooms?:readonly [inside:string,outside:string]; /** Its leaves' `driveActor` keys. */ collision:readonly string[]; /** The leaves' mean `value`. */ readonly value:number; /** True while `animateTo` moves it. */ readonly animating:boolean; /** Stand every leaf at `value` (0 shut, 1 fully open; revolving: quarter turns), at once. Stops an animation. */ set(value:number):void; /** Stand one leaf at `value`. Stops an animation. */ setLeaf(index:number,value:number):void; /** * The map's default animation (`doorAnimation(door.kind, door.value, value, * seconds)`): move every leaf to `value` over `seconds` (default: 1.4 s a full * swing, 0.9 s a full slide, 3.5 s a quarter turn, in proportion), advanced by * `BrnoMap.update` from its frame's `time`. Resolves true when there, false * when another call or `set` interrupts it. */ animateTo(value:number,seconds?:number):Promise; }>; /** A list of doors: the browser's `BrnoMapDoors` (`BrnoMapDoor`), the server's `ServerDoors` (`BrnoMapDoorData`). */ export type BrnoMapDoorList=Readonly<{ /** Every door, the openable ones first. */ list():Door[]; /** A door by its id or its entrance id. */ get(id:string):Door|undefined; /** The doors whose middle lies within `radius` (m, plan) of (x, z), the nearest first. */ near(x:number,z:number,radius:number):Door[]; }>; /** * The map's doors (after release 1.45.0). A door's leaves are drawn and solid * within about 90 m of the frame's `viewer` (55 m on the compact profile) and * hidden beyond (hidden, they do not collide in `collision.objects`, nor in a * physics game that follows visibility). */ export type BrnoMapDoors=Readonly<{ /** Every door, the openable ones first. */ list():BrnoMapDoor[]; /** A door by its id or its entrance id. */ get(id:string):BrnoMapDoor|undefined; /** The doors whose middle lies within `radius` (m, plan) of (x, z), the nearest first. */ near(x:number,z:number,radius:number):BrnoMapDoor[]; }>; /** Seconds the default animation takes: a full swing, a full slide, a quarter turn of a revolving door (after release 1.47.0; both entries). */ export const DOOR_TIMING:Readonly<{swing:number;slide:number;revolving:number}>; /** * Where leaf `leafIndex` of `door` (either entry's) stands at `value` (0 shut … 1 open, clamped; a revolving door's * value counts quarter turns, any number): its node's world position and quaternion, plain arrays. The browser stands * its leaves with this function, so a game server's poses are the pages' (after release 1.47.0; both entries). */ export function leafPose(door:Readonly<{leaves:readonly BrnoMapDoorLeafData[]}>,leafIndex:number,value:number):BrnoMapDoorPose; /** Every leaf's pose at `value` (`door.set(value)`), in leaf order. */ export function doorLeafPoses(door:Readonly<{leaves:readonly BrnoMapDoorLeafData[]}>,value:number):BrnoMapDoorPose[]; /** Leaf `leafIndex`'s `shapes` in the world where it stands at `value` (`closedShapes` at 0). */ export function leafShapes(door:Readonly<{leaves:readonly BrnoMapDoorLeafData[]}>,leafIndex:number,value:number):BrnoMapDoorWorldShape[]; /** The default animation's easing of its time fraction (0 … 1, clamped): smoothstep for a swing or slide; even (linear) for a revolving door. */ export function doorEase(t:number,kind?:BrnoMapDoorKind):number; /** A default animation: `valueAt(elapsed)` is the value every leaf stands at `elapsed` seconds in; it is done at `seconds`. */ export type BrnoMapDoorAnimation=Readonly<{from:number;to:number;seconds:number;valueAt(elapsed:number):number}>; /** * The map's default animation of a door of `kind` from `from` (`door.value`) to `to` (clamped to 0 … 1 for a swing or * slide) over `seconds` (default `DOOR_TIMING[kind]` × the distance): what `BrnoMapDoor.animateTo` runs, for a game * server that drives the same timing. */ export function doorAnimation(kind:BrnoMapDoorKind,from:number,to:number,seconds?:number):BrnoMapDoorAnimation; // --- Scene-free helpers (also exported by the server entry) ------------------- /** The car contact geometry (m) and the limits of a drivable support. */ export const CAR_CONTACT:Readonly<{wheelbase:number;track:number;frontAxle:number;rearAxle:number;maxGrade:number;maxCrossfall:number;maxWarp:number;maxStep:number}>; /** The support plane under a car's four tyres. */ export type CarContact={initialized:boolean;height:number;grade:number;crossfall:number;warp:number;localGrade:number;valid:boolean;driveable:boolean}; export function createCarContact():CarContact; /** Fit the support plane under a car at a pose; writes into and returns `out` (allocation-free per frame). */ export function sampleCarContact(ground:GroundFn,x:number,z:number,heading:number,out?:CarContact,car?:CarPose):CarContact; /** * A contact with an anchored prop (`PropAnchor`): the mass (kg) the other body * meets it with and the contact's approach speed (m/s). `mass` is the other * body's effective mass at the contact point along the contact's normal, * 1/(1/m + (r×n)·I⁻¹·(r×n)) (r the point less its centre of mass, I its * inertia tensor): a broken prop that tumbles into its neighbour corner first * meets it with a fraction of its mass (a Vaňkovka edge's segment, about a * fifth of it), though the point's approach speed is high. A car driven * into a prop meets it square, near its centre line, and may give its mass. * `freedMass` (optional, for `remainingSpeed`): the mass (kg) of what the * break leaves standing in the body's way (`freedMass`): the prop's own when * it falls whole, the pieces in the body's way when it falls as rubble, 0 or * absent when it shatters. */ export type PropContact=Readonly<{mass:number;approachSpeed:number;freedMass?:number}>; /** The kinetic energy (J) a contact delivers: ½·m·v². */ export function contactEnergy(contact:PropContact):number; /** Whether a contact breaks an anchored prop free: at least `breakEnergyJ` at no less than `breakSpeed`. */ export function anchorBreaks(anchor:PropAnchor,contact:PropContact):boolean; /** The lowest approach speed (m/s) at which a body of `mass` kg breaks an anchored prop free. */ export function breakingSpeed(anchor:PropAnchor,mass:number):number; /** * The approach speed (m/s) a body keeps through an anchored prop it breaks * free; 0 when the contact does not break it. A game that breaks the prop on * a hit event, after the step that stopped the body against it, gives the * body this speed along its approach again. The break energy is the whole * impact's (the car's crumple and the barrier's give together), so it is not * charged twice: with `freedMass` M (what broke free and still stands in the * way, which the engine meets next as a near-plastic contact), the body keeps * v' with ½·m²·v'²/(m + M) = ½·m·v² − breakEnergyJ, no more than v; without it * (a prop that shatters) ½·m·v'² = ½·m·v² − breakEnergyJ. */ export function remainingSpeed(anchor:PropAnchor,contact:PropContact):number; /** A point of the world (m). */ export type WorldPoint=Readonly<{x:number;y:number;z:number}>; /** * The rubble pieces (`PropAnchor.rubble`) in the way of a body that breaks * the prop: those whose model-space x and y ranges (their shapes') overlap * the ranges of the body's collision `points` (world, e.g. its boxes' * corners) taken into the prop's model space by its entity's `matrix` * (`PropEntity.matrix`). Their indices in `anchor.rubble`; none without rubble. */ export function rubbleInWay(anchor:PropAnchor,matrix:MatrixElements,points:readonly WorldPoint[]):number[]; /** * What a break leaves in the way of the body that broke the prop (kg), * `PropContact.freedMass` for `remainingSpeed`: 0 where the prop shatters, * the `massKg` of the rubble pieces in the body's way (`rubbleInWay`) where * it falls as rubble, its asset's `approximateMassKg` where it falls whole. */ export function freedMass(profile:Pick,matrix:MatrixElements,points:readonly WorldPoint[]):number; /** * The map's tram rule (added after release 1.9.0; lib/game/tram-traffic.mjs, * run by the page's own trams and by the server entry's `createTramTraffic`): * one tram a route of the release's tram routes, starting `starts[i]` metres * along route i (`starts.at(-1)` for any later route), running at `speed` * (m/s) or standing. It stands while a car is within `stopRadius` (m) of its * route point `lookAhead` (m) ahead; otherwise it moves in steps of at most * `sweepStep` (m) and stops at the last step where its body meets no car. * Its pose: its centre `lift` (m) over the floor, its heading and pitch along * the chord between its bogies `bogieOffset` (m) behind and ahead, as long as * the floor read at the bogies, half way to them and the middle lies within * `railTolerance` (m) of that chord and it climbs no steeper than `maxGrade`; * otherwise (a floor reading that is not the rail's: a ledge, a deck over the * street) along the line no steeper than `maxGrade` that most of those * readings lie on (both added after release 1.53.0, SZP-346). A server * steps it by at most `maxStep` (s) a tick; a page draws it within * `visibleRadius` (m) of the focus. */ export const TRAM_TRAFFIC:Readonly<{speed:number;bogieOffset:number;lookAhead:number;stopRadius:number;sweepStep:number;maxStep:number;lift:number;visibleRadius:number;starts:readonly number[];/** The steepest rail a pose follows (rise over run; SZP-346). */maxGrade:number;/** How far (m) a floor reading under a tram may lie off the line its other readings make and still be the rail's (SZP-346). */railTolerance:number}>; /** * A tram as a game server's tram traffic has it (`TramTraffic.snapshot()` of * the server entry; after release 1.9.0): `id` is `tram-`, the * `driveActor.key` of the tram it moves; `distance` (m) along its route; * `speed` `TRAM_TRAFFIC.speed` while it runs, 0 while it stands; `revision` * counts its changes between running and standing. `x`…`pitch` are its pose * then (world metres, radians, YXZ Euler); a server sending only route * anchors sends TrafficAnchor instead. */ export type TrafficPose=Readonly<{id:string;x:number;y:number;z:number;heading:number;pitch:number;distance:number;speed?:number;revision?:number}>; /** * A tram's place on its route only (`distance`, with `speed` and `revision` * as in TrafficPose), its world pose optional: what setNetworkTraffic also * takes from a server that sends route anchors. Without a clock the page * places the tram at `distance` on its route. */ export type TrafficAnchor=Readonly<{id:string;distance:number;speed?:number;revision?:number;x?:number;y?:number;z?:number;heading?:number;pitch?:number}>; /** * When the page received a set of traffic poses: `serverTime` (ms) the * server's clock when it sent them, `receivedAt` the page's * `performance.now()` (ms) on arrival, `oneWayMs` the estimated one-way delay * (ms, held to 0…250) and `latencyMeasured` whether that estimate was measured. */ export type TrafficClock=Readonly<{serverTime:number;receivedAt:number;oneWayMs:number;latencyMeasured?:boolean}>; /** The box a car collides as (m): half width, half length, and its span above the floor. */ export const VEHICLE_BOX:Readonly<{halfWidth:number;halfLength:number;low:number;high:number}>; export type CollisionNormal=Readonly<{x:number;y:number;z:number}>; export type WallCollision={ /** Whether the car body at a pose meets a wall. `steer` is the front-wheel angle (rad). */ blocked(x:number,z:number,heading:number,steer?:number,car?:CarPose):boolean; /** Fraction (0…1) of a segment that is clear of walls, shortened by `clearance` (m, default .25). */ traceSegment(from:THREE.Vector3Like,to:THREE.Vector3Like,clearance?:number):number; /** Contact normal of the last blocking `blocked` query, or null. */ readonly lastNormal:CollisionNormal|null; }; export function createWallCollision(data:WallCollisionData,ground:GroundFn):WallCollision; export type ObjectCollision={ /** Whether the car body at a pose meets a solid scene object (see the scene tags). */ blocked(x:number,z:number,heading:number,steer?:number,car?:CarPose):boolean; /** The same query against one object's subtree (e.g. a tram against a car). */ blockedBy(object:THREE.Object3D,x:number,z:number,heading:number,steer?:number,car?:CarPose):boolean; /** Clear fraction of a camera sightline; skips objects marked camera-transparent (street trees). */ traceSightline(from:THREE.Vector3Like,to:THREE.Vector3Like,clearance?:number):number; readonly lastNormal:CollisionNormal|null; }; /** Build collision for the solid objects of a scene (its state when called; dynamic objects stay live). */ export function createObjectCollision(scene:THREE.Object3D,ground:GroundFn):ObjectCollision; /** The same construction in cooperative steps: advance the generator between frames. */ export function createObjectCollisionSteps(scene:THREE.Object3D,ground:GroundFn):Generator; /** Whether a car pose leaves the play area or has no valid support there (true = not allowed). */ export type PlayAreaGuard=(x:number,z:number,heading:number,car?:CarPose)=>boolean; /** An axis-aligned side of the play outline: `value` on `axis` (0: x, 1: z), spanning `lo`…`hi` on the other; `outward` is the outside's sign. */ export type PlayEdge=Readonly<{axis:0|1;value:number;lo:number;hi:number;outward:-1|1}>; export type MapView={zoom:number;sx:number;sy:number;sw:number;sh:number;playerX:number;playerY:number}; export type RoadExit={edgeIndex:number;t:number;name:string;width:number}; export const playArea:Readonly<{ createGuard(ground:GroundFn):PlayAreaGuard; /** Counter-clockwise outline in plan (outside on the right of each side). */ outline:readonly Point[]; edges:readonly PlayEdge[]; /** Minimap projection: canvas pixel = origin + world coordinate × scale, on a size × size canvas. */ projection:Readonly<{scale:number;origin:number;size:number}>; /** Source rectangle of the minimap canvas for a view around a point, or of the whole area (`overview`). */ mapView(width:number,height:number,x:number,z:number,overview?:boolean):MapView; /** The point at `t` along an edge, `offset` metres outward. */ edgePoint(edge:PlayEdge,t:number,offset?:number):[x:number,z:number]; /** Where roads cross the play outline (named streets first, one per crossing). */ roadExits(roads:readonly Readonly<{p:readonly Point[];w:number;name?:string}>[]):RoadExit[]; }>; /** Even-odd point-in-polygon test in plan. */ export function inPolygon(x:number,z:number,points:readonly Point[]):boolean; /** Plan distance from a point to a segment. */ export function segmentDistance(x:number,z:number,a:Point,b:Point):number; /** * Decode one decompressed BSC1 collision chunk (the manifest's chunks are * gzip; check `byteLength` and `sha256` before decoding). Positions are local * to the chunk's manifest `origin`. The arrays are views of the given bytes. */ export function decodeCollisionChunk(buffer:ArrayBuffer|ArrayBufferView):{positions:Float32Array;indices:Uint32Array}; /** * The vehicle the map's collision is measured for (SPZ Drive's Octavia). * `bands`: body boxes `[halfWidth, halfHeight, halfLength, centreY, centreZ]`; * `wheels`: tyre boxes `[x, y, z, halfX, halfY, halfZ, front]` (front 1, rear 0); * `maximumSteer`: front-wheel angle limit (rad). Model-origin metres. */ export const vehicleProfile:Readonly<{ name:'spz-octavia'; bands:readonly (readonly [halfWidth:number,halfHeight:number,halfLength:number,centreY:number,centreZ:number])[]; wheels:readonly (readonly [x:number,y:number,z:number,halfX:number,halfY:number,halfZ:number,front:0|1])[]; maximumSteer:number; }>; /** Convert routes with an authored positive width to plan roads. Routes without width are omitted; deck means pathXYZ is available. */ export function parkingRoads(parking:ParkingData):readonly Readonly<{id:string;p:readonly Point[];w:number;kind:'parking';deck:boolean}>[]; /** Closed rings in map metres; overlapping pieces retain their OSM access rules. * Split polygons have # appended to the OSM id. No access tag means * unknown; this layer does not grant driving permission. */ export type ZoneKind='pedestrian-zone'|'pedestrian-area'|'park'|'garden'|'lawn'|'playground'|'outdoor-seating'|'construction'|'parking'|'railway'; export type Zone=Readonly<{id:string;kind:ZoneKind;name?:string;p:readonly Point[];holes:readonly (readonly Point[])[];parking?:'surface'|'street-side'|'underground'|'multi-storey'|'rooftop'|'layby';motorVehicle?:'no'|'delivery'|'permit'|'destination';motorVehicleConditional?:string}>; export type ZoneData=Readonly<{schemaVersion:1;id:string;source:string;license:string;attribution:string;zones:readonly Zone[]}>; /** The map's door styles: the station's platform doors (`timber-glazed`), its front's portals (`timber-portal`), an * aluminium shop front (`metal-glazed`). */ export type DoorStyle='timber-glazed'|'timber-portal'|'metal-glazed'; /** One leaf of a map door style for a game to instance and swing itself: x from the hinge (0) to the meeting edge * (`width`), y up from its foot, z across its `thickness` (0 its middle); the solid parts in vertex colours and the * glass. The materials are new, the caller's to dispose; one pair serves every leaf of the style. */ export type DoorLeafKit=Readonly<{geometries:Readonly<{solid:THREE.BufferGeometry;glass:THREE.BufferGeometry}>;materials:Readonly<{solid:THREE.MeshStandardMaterial;glass:THREE.MeshStandardMaterial}>;thickness:number}>; /** A leaf `width` 0.4–2 m (default 0.9) by `height` 1.8–3.2 m (default 2.1) of a door style, built with the game's three. */ export function doorLeafKit(three:typeof THREE,style:DoorStyle,size?:Readonly<{width?:number;height?:number}>):DoorLeafKit; /** Includes outer boundaries; excludes holes and their boundaries. Does not interpret conditional hours. */ export function zonesAt(zones:readonly Zone[],x:number,z:number):Zone[];