import type { CitySource } from '../source'; import type { Cs2Backdrop } from '../../cs2/backdrop'; import { type OuterLandField } from './outerLand'; export declare const MARGIN_DEM_SCHEMA: "helix.city-margin-dem/1"; export declare const DEFAULT_MARGIN_M = 4096; export interface MarginDemMeta { schema: typeof MARGIN_DEM_SCHEMA; file: string; /** Scene Y metres (orthometric height minus the frame's origin altitude), 16 bit over `heightRangeM`. */ heightRangeM: [number, number]; metresPerSample: number; originXZ: [number, number]; samples: [number, number]; originAltitudeM: number; sha256: string; note: string; } export interface MarginDem { meta: MarginDemMeta; /** Row 0 is the smallest z (north), x east; scene Y metres. */ heights: Float32Array; /** Bilinear lookup; clamps to the window. */ sampleAt(x: number, z: number): number; } /** A margin DEM from its meta and scene-Y heights (tests, and anything that already holds the raster). */ export declare function makeMarginDem(meta: MarginDemMeta, heights: Float32Array): MarginDem; export declare function readMarginDem(dir: string): Promise; /** Fetch the DEM around the city (bounds plus the margin) and keep it in `dir`. */ export declare function fetchMarginDem(source: CitySource, dir: string, marginM: number, log?: (line: string) => void, cacheDir?: string): Promise; export interface MarginMeshOptions { marginM: number; /** Scene Y at a plan point on the city's own terrain (the conformed ground), used to meet it at the bounds. */ coreHeightAt: (x: number, z: number) => number; /** Height of sea level in scene Y (minus the frame origin altitude). */ seaLevelY: number; /** * `urban` (default): the paved basin and dry hill a real city's DEM ring wears. `natural`: the grass, shore sand and underwater floor of a * fictional map whose own ground is grass (`ground: 'natural'`), so the ring continues the land instead of ringing it in grey. */ palette?: 'urban' | 'natural'; } export interface MarginMesh { glb: Uint8Array; sha256: string; bounds: { min: [number, number, number]; max: [number, number, number]; }; triangles: number; vertices: number; cellM: number; decodedBytes: number; } export declare const srgbToLinear: (c: number) => number; export declare const hex: (value: string) => [number, number, number]; export declare const smooth: (a: number, b: number, v: number) => number; /** Value noise on a lattice of `scale` metres, 0..1. */ export declare function noise(x: number, z: number, scale: number, salt: number): number; /** The `natural` palette: the colours of a CS2 map's own grass and shore (the terrain splat's `natural` ground), so the ring reads as more land. */ export declare const NATURAL: { basin: [number, number, number]; basinWarm: [number, number, number]; hill: [number, number, number]; dry: [number, number, number]; sand: [number, number, number]; floor: [number, number, number]; }; export declare function buildMarginMesh(source: CitySource, dem: MarginDem, options: MarginMeshOptions): Promise; export declare function mixColour(a: [number, number, number], b: [number, number, number], t: number): [number, number, number]; export interface SeaEdgeOptions { /** How far the ground continues beyond the bounds (m). */ marginM: number; /** The longest slope from the edge's height down to the sea floor (m, at most `marginM`; default 0.75 of it); along the border it varies down to 0.12 of this. */ falloffM?: number; /** Scene Y at a plan point on the city's own terrain, used to meet it at the bounds. */ coreHeightAt: (x: number, z: number) => number; /** Sea level in scene Y. */ seaLevelY: number; /** How far under the sea the ring's outer rim lies (m, default 40): below what the ocean's own shore band shows. */ floorDepthM?: number; } /** * The ground beyond a fictional map's edge: a Cities: Skylines II map is a square that simply stops, and the land at its border stood * above the water as a hard-edged slab (Jack, 2026-10-22). With no real DEM to continue it, the ground carries on from the border's own * height and slopes (smoothstep) down under the sea over `falloffM`, so the square's edge becomes a coast with water beyond it and the * ocean runs on to the horizon. A border already under water stays at its depth. Pure: the same source heights give the same raster. */ export declare function syntheticSeaEdgeDem(source: CitySource, options: SeaEdgeOptions): MarginDem; export interface TerrainMarginInput { sourceDir: string; /** Where the margin DEM is kept (default `/terrain/margin`). */ cacheDir?: string; marginM: number; offline?: boolean; coreHeightAt: (x: number, z: number) => number; log?: (line: string) => void; /** A fictional map: no DEM is fetched; the ring is the border sloping under the sea (`syntheticSeaEdgeDem`) in the `natural` palette. */ seaEdge?: { falloffM?: number; splatLayers?: readonly [number, number, number, number]; backdrop?: Cs2Backdrop | null; }; } /** The ring for a city, or null (with the reason in `note`) when there is no margin DEM and the run may not fetch one. */ export declare function buildTerrainMargin(source: CitySource, input: TerrainMarginInput): Promise<{ mesh: MarginMesh | null; note?: string; demSha256?: string; outer?: OuterLandField; backdrop?: boolean; }>;