// Brno map server API, version 1: the declarations of // `/releases//server/brno-map-server.mjs`, published beside the // browser declarations as `/releases//types/brno-map-server.d.ts` // (the shared helper types come from that sibling `brno-map.d.ts`). // Hand-written: this file is the contract, the implementation // (lib/api/v1/server.mjs) is checked against it (server.type-test.ts). // Removing or changing anything here is a breaking change (a new major). // // Node >= 22.13. The bundle imports bare `three`; the game provides the // three.js version in `release.three`, and the release directory must resolve it // (Node looks for `node_modules/three` above the bundle's real path). // Units are metres; the frame is three.js world space (`release.coordinates`). import type {BufferGeometry,Object3D} from 'three'; import type {BrnoMapDoorData,BrnoMapDoorList,ZoneData,TrafficPose,BrnoMapRelease,Box3DModule,CarPose,PlaceData,NewCityHallData,CityData,CutSections,DirectoryData,GroundFn,Grounding,ObjectCollision,ParkingData,PhysicsManifest,PlayAreaGuard,Point,PropCatalog,PropStart,WallCollisionData} from './brno-map.js'; export type {BrnoMapDoorAnimation,BrnoMapDoorBox,BrnoMapDoorData,BrnoMapDoorKind,BrnoMapDoorLeafData,BrnoMapDoorList,BrnoMapDoorLobby,BrnoMapDoorPose,BrnoMapDoorShape,BrnoMapDoorWorldShape,Zone,ZoneKind,ZoneData,TrafficClock,TrafficPose,TrafficAnchor,Box3DModule,CarContact,CarPose,PlaceData,NewCityHallData,CityData,CollisionNormal,CutPart,CutSections,DirectoryAddress,DirectoryData,DirectoryEntrance,DirectoryNode,DirectoryParking,DirectoryPoi,DirectoryPoint,DirectoryStart,DirectoryStop,GroundFn,Grounding,GroundingCorrection,MatrixElements,ObjectCollision,ParkingData,PhysicsBounds,PhysicsChunk,PhysicsManifest,PhysicsSourceWorld,PhysicsStart,PlayAreaGuard,Point,PropAnchor,PropBounds,PropCatalog,PropContact,PropEntity,PropProfile,PropRubblePiece,PropShape,PropStart,QuaternionTuple,Vector3Tuple,WallCollision,WallCollisionData,WorldPoint} from './brno-map.js'; export {CAR_CONTACT,createCarContact,sampleCarContact,createWallCollision,decodeCollisionChunk,inPolygon,segmentDistance,vehicleProfile,anchorBreaks,breakingSpeed,contactEnergy,freedMass,remainingSpeed,rubbleInWay,TRAM_TRAFFIC,DOOR_TIMING,leafPose,doorLeafPoses,leafShapes,doorEase,doorAnimation} from './brno-map.js'; /** * What the bundle knows about itself from its build: the browser entry's * `release` without `creditsUrl`, which only a page can resolve (the * descriptor's `credits` path is relative to the service the game uses). */ export type ServerReleaseInfo=Omit; export const release:ServerReleaseInfo; /** * Open a release directory laid out by the release cache (`@brno-map/client/node`). * Rejects a directory of another release, a release.json that does not hash to * its id, and any file whose bytes differ from what release.json binds. Each * call decodes the release anew (about 0.6 GB resident); keep one per release * and drop it to free it. */ export function openRelease(directory:string):Promise; /** A shape's baked collision triangles and bounding-volume hierarchy (local to the shape). */ export type PreparedPrototype=Readonly<{vertices:Float32Array;indices:Uint32Array;nodes:Float32Array}>; /** One placed shape: `prototype` indexes `world.prototypes`; `group` indexes `world.groups`, or -1 for static. */ export type WorldEntry=Readonly<{prototype:number;matrix:readonly number[];group:number;name:string;visible:boolean}>; /** A moving assembly: the clock's hands (`rate`, rad/s about +Y) or a tram on `routeIndex`. */ export type WorldGroup=Readonly<{name:string;matrix:readonly number[];kind:'clock'|'tram';rate:number;routeIndex?:number}>; export type WorldRoute=Readonly<{name:string;p:readonly Point[];lengthMeters:number;[key:string]:unknown}>; export type WorldStart=Readonly<{id:string;x:number;z:number;heading:number}>; /** A reviewed community edit installed in this release. */ export type InstalledIntegration=Readonly<{proposalId:string;reviewRevision:number;buildId:string;operationsSha256:string}>; /** * The decoded multiplayer world (`brno-world.bin.gz`): the solid shapes and * their placements, the moving groups, tram routes and starts. Members not * named here (the floor and terrain tables behind `ground`) are internal. */ export type ServerWorldData=Readonly<{ version:1;generatedAt:string; prototypes:readonly PreparedPrototype[];entries:readonly WorldEntry[];groups:readonly WorldGroup[]; routes:readonly WorldRoute[];starts:readonly WorldStart[]; /** sha256 of the wall collision the world was baked with. */ wallSha256:string; installedIntegrations?:readonly InstalledIntegration[]; stats:Readonly>; [internal:string]:unknown; }>; /** The release's doors (`ServerRelease.doors`): `list`, `get` (id or entrance id), `near`. */ export type ServerDoors=BrnoMapDoorList; export interface ServerRelease{ readonly release:ServerReleaseInfo; /** Floor height for a car (layered decks near its last contact), the road surface where no floor; NaN where neither. */ readonly ground:GroundFn; /** The rendered walls (`wall-collision.bin`), checked against the world's `wallSha256`. */ readonly walls:WallCollisionData; readonly world:ServerWorldData; /** * One geometry per `world.prototypes` entry, shared by every room. Geometries * of moving shapes carry their baked `position` attribute; all others are * empty, so pass `byGeometry` to `createObjectCollision`. */ readonly prototypes:Readonly<{geometries:readonly BufferGeometry[];byGeometry:WeakMap}>; readonly physics:Readonly<{ manifest:PhysicsManifest; /** The movable-prop catalogue (`props.b3c`, decompressed). */ props:PropCatalog; grounding:Grounding; /** Stump cut sections of breakable props. */ cuts:CutSections; propStarts:readonly PropStart[]; /** A chunk's decompressed BSC1 bytes, checked against release.json and the manifest's `sha256`/`byteLength` (decode with `decodeCollisionChunk`). */ chunk(id:string):Promise; /** Import this release's Box3D engine and instantiate its verified wasm (each call makes a new instance). */ loadBox3D():Promise; }>; /** Data of the same release; treat as read-only. `sha256` holds each file's digest. */ readonly data:Readonly<{ places:PlaceData;newCityHall:NewCityHallData;city:CityData;parking:ParkingData; /** The community catalogue (`community-map.json`): features a report may name. */ communityCatalog:Readonly<{schemaVersion:number;bounds:Readonly<{minX:number;minZ:number;maxX:number;maxZ:number}>;buildings:readonly unknown[];streets:readonly unknown[];requests:readonly unknown[];[key:string]:unknown}>; /** Places a game can name and route between (`places.json`; see DirectoryData). */ directory:DirectoryData;zones:ZoneData; sha256:Readonly<{places:string;newCityHall:string;city:string;parking:string;communityCatalog:string;directory:string;zones:string;doors:string}>; }>; /** * The doors a game opens, as data (after release 1.47.0): the browser's `map.doors` without the scene nodes and * methods, from the descriptors the release's cook builds its leaves from (`public/data/openable-doors.json`), keyed * by places.json's entrances the same way, the station's open doors last. A room drives a door by holding each * leaf's value and posing its body at `leafPose(door, index, value)` (`doorAnimation` for the pages' default timing); * its pages, sent the value, stand the leaf at the same pose (`BrnoMapDoor.setLeaf`). Each leaf's `shapes` are its * body's shapes in its own frame, `closedShapes` the same shut in the world; `lobby.box` is the room behind. */ readonly doors:ServerDoors; /** The community edits installed in this release, oldest first. */ readonly installedIntegrations:readonly InstalledIntegration[]; /** The last installed edit's build id (`'base'` before any); equals `release.communityBuildId`. */ readonly communityBuildId:string; } /** Collision for the solid objects of a scene. On the server pass `prepared` (`prototypes.byGeometry`): the shapes' baked BVHs. */ export function createObjectCollision(scene:Object3D,ground:GroundFn,prepared?:WeakMap):ObjectCollision; /** Whether a car pose leaves the play area or has no valid support there (true = not allowed). */ export function createPlayAreaGuard(ground:GroundFn):PlayAreaGuard; /** A car as the tram traffic meets it: its plan pose, front-wheel angle (rad) and, for layered floors, its support (`CarPose.contact`). */ export type TramTrafficCar=Readonly<{x:number;z:number;heading:number;steer?:number;contact?:CarPose['contact']}>; /** A game server's trams (`createTramTraffic`). */ export type TramTraffic=Readonly<{ /** Each tram: its traffic id (`tram-`), its route and the object it moves (the game's for its world group). */ trams:readonly Readonly<{id:string;routeIndex:number;object:Object3D}>[]; /** * Advance every tram by `dt` seconds (at most `TRAM_TRAFFIC.maxStep`; none * for a step that is not positive) among `cars` (poses that are not finite * are left out): the map's tram rule, as every page's trams run it. */ update(dt:number,cars?:Iterable):void; /** Each tram's complete world pose now, to send to pages (`BrnoMap.trams.setNetworkTraffic`); world coordinates, `speed` and `revision` always present. Pages using a clock may receive just the route anchor fields. */ snapshot():(TrafficPose&Readonly<{x:number;y:number;z:number;heading:number;pitch:number;speed:number;revision:number}>)[]; /** Counts every tram's changes between running and standing: send new poses when it changes. */ readonly revision:number; }>; /** * The trams of a release's world, run by the map's tram rule (`TRAM_TRAFFIC`; * added after release 1.9.0): one a tram group of `world.groups`, on its * `routeIndex` of `world.routes`, standing at its start distance until the * first `update`. `objects[i]` is the game's scene object for * `world.groups[i]` (the trams' are placed on their rails and their world * matrices updated, as `update` moves them); `ground` the floor the rails lie * on (`ServerRelease.ground`); `collision` (optional, e.g. the game's * `createObjectCollision` over those objects) holds a tram where its body * would meet a car. */ export function createTramTraffic(world:Pick,objects:readonly Object3D[],options:Readonly<{ground:GroundFn;collision?:Pick}>):TramTraffic; export {playArea,parkingRoads} from './brno-map.js'; export {zonesAt} from './brno-map.js';