import { type CellGlbResult } from './cellGlb'; import { type RibbonStats } from './ribbons'; import { type MarkingCell, type SurfaceCell } from './walk'; export declare const RESTYLE_COLLIDER_MAX_TRIANGLES = 60000; /** Scene perf rule P05 refuses a streamed cell over 300,000 triangles; a cell (surface and paint) is split before 250,000. */ export declare const RESTYLE_CELL_MAX_TRIANGLES = 250000; /** A cell is never split below this side, metres. */ export declare const RESTYLE_CELL_MIN_SIZE_M = 128; /** The collider tier's weld-and-simplify tolerance; a cell that cannot reach the budget at it grows it by root-two steps up to the cap. */ export declare const RESTYLE_COLLIDER_ERROR_M = 0.05; export declare const RESTYLE_COLLIDER_ERROR_CAP_M = 0.8; /** * A cell whose walls, girders and barrier faces still miss their share of the budget at the cap above (Pacifica's rail-bridge band, cell 10,3: * 46,910 against 45,000 with 31,000 triangles of drawn asphalt and sidewalk kept exact) keeps growing that error, still in root-two steps, up to * this: only what no wheel or foot rests on moves, and only in the cells that would otherwise be over budget. Past it the cell is over budget * and the convert refuses it, as before. */ export declare const RESTYLE_COLLIDER_RESCUE_CAP_M = 3.2; /** * The collider's own tops (the up-facing faces no drawn top covered: kerb tops, medians, concrete decks, ballast, parapets) are simplified apart * from the walls and never past this. Coarsened with the walls they went up to the rescue cap with them, and an edge collapse that folds a * parapet's top vertex onto a deck lifts the deck to the parapet: Pacifica rd12's worst cell moved them 1.12 m, a collider top a metre over the * drawn track and path (Double Train Track at 2400.87,3076.81; Pavement Path at -6409.89,-3575.41) that a foot or a wheel stands on unseen. */ export declare const RESTYLE_COLLIDER_TOP_ERROR_CAP_M = 0.1; /** The `line` tile of the engine's 1,024 px marking atlas (`MARKING_ATLAS.line`: u0, v0, du, dv). */ export declare const MARKING_LINE_TILE: readonly [0.5, 0.5, 0.0625, 0.5]; /** The engine's `MARKING_PAINT`. */ export declare const MARKING_PAINT: { readonly white: readonly [0.92, 0.92, 0.9]; readonly yellow: readonly [0.85, 0.62, 0.12]; }; /** `_ROAD.w` of paint: how worn it reads (the shader scales chipping and wear by 0.35 + 1.3 x this). Fresh paint: worn lines vanish at 60 m. */ export declare const MARKING_AGE = 0.04; /** Metres a paint ribbon may move when its segments are welded and merged along a rail (a stripe is 10 to 15 cm wide). */ export declare const MARKING_ERROR_M = 0.015; /** * The solid core of the `line` tile across its width, as a fraction: texels 12 to 55 of 64 are paint (about 80 % alpha), the * rest is a transparent margin, so a ribbon mapped edge to edge paints only 69 % of its width. Rails map to the core instead, * a texel and a half inside it, so the painted width is the ribbon's width. */ export declare const MARKING_LINE_CORE: readonly [0.22, 0.84]; export interface RestyleOptions { colliderMaxTriangles?: number; /** Triangles above which a render cell is split into quarters (default RESTYLE_CELL_MAX_TRIANGLES). */ cellMaxTriangles?: number; /** * Tolerance in metres for simplifying the concrete structure (bridge girders, walls, decks: 58% of Leonida's 10.9M road triangles, mostly * flat sides) in each render cell; omitted keeps it as the game drew it. The drivable top follows within this distance. */ structureErrorM?: number; /** Tolerance in metres for the surfaces a player drives and walks on (asphalt, sidewalk, kerb, gravel); omitted keeps them as the game drew them. */ surfaceErrorM?: number; /** Folder for the far road layer (`render/`, `mesh-cells.json`); omitted writes no far layer. */ farOut?: string; /** The far layer's simplifier tolerance in metres (default FAR_ERROR_M). */ farErrorM?: number; log?: (message: string) => void; } export interface RestyleColliderReport { cx: number; cz: number; triangles: number; trianglesBeforeSimplify: number; /** Of `triangles`, the render's up-facing ones taken exactly as drawn (colliderTops.ts). */ topTriangles: number; /** The walls' simplify error (they alone go past the cap, up to the rescue cap). */ errorMetres: number; /** The collider's own tops' simplify error: at most `RESTYLE_COLLIDER_TOP_ERROR_CAP_M` unless the cell could not fit otherwise. */ topErrorMetres: number; overBudget: boolean; } interface TierTotals { cells: number; triangles: number; bytes: number; maxSideM: number; } export interface RestyleReport { source: string; cellSizeM: number; before: { render: TierTotals & { materials: number; }; markings: TierTotals; collider: TierTotals & { overBudget: number; maxTriangles: number; }; }; after: { render: TierTotals & { maxCellTriangles: number; refinedCells: number; }; markings: TierTotals & { droppedTriangles: number; }; collider: TierTotals & { overBudget: number; maxTriangles: number; maxErrorM: number; maxTopErrorM: number; }; }; trianglesBySurface: Record; clippedTriangles: number; outsideGridTriangles: number; textures: number; colliders: RestyleColliderReport[]; /** Paint ribbons by class (`ribbons.ts`). */ ribbons: RibbonStats; /** The far layer, when asked for. */ far?: { cells: number; cellSizeM: number; triangles: number; trianglesBefore: number; bytes: number; errorM: number; maxErrorM: number; }; } declare function surfaceMesh(cell: SurfaceCell): { positions: Float32Array; normals: Float32Array; indices: Uint32Array; road: Uint8Array; colour: Uint8Array; }; /** The lattice a cell is written on (`LATTICE_PER_M`): two vertices on one lattice point are one vertex. */ type RenderMesh = ReturnType; /** * Tolerance in metres per surface kind for `reduceRenderMesh`. The baked pieces are the game's deformed meshes: a lane fragment is cut every * metre or two along its spline and across its width, a bridge side is the same, so a flat run carries many times the triangles its shape needs. */ export interface SurfaceErrors { /** Asphalt, sidewalk, gravel, kerb, sett and median: what a player drives and walks on. */ surfaceM: number; /** Concrete: bridge girders, walls, decks and undersides. */ structureM: number; /** Square metres under which a triangle (after the lattice snap) is a sliver nothing shows and is dropped. Default `MIN_TRIANGLE_AREA_M2`. */ minAreaM2?: number; } /** A triangle under 5 cm squared (a 2 x 25 cm sliver) draws nothing at street level and is where the game's pieces meet; it is dropped. */ export declare const MIN_TRIANGLE_AREA_M2 = 0.0005; /** * Welds a render mesh and collapses its flat runs, one surface kind at a time (a kind is its own material in the shader, so a collapse never * crosses one). The cell meshes come out of `walk` with one vertex per source vertex and cell, so a position is held by two to three vertices; * `MeshoptSimplifier` over that buffer has no edge to collapse. Vertices are welded by lattice position, normal and kind (a hard edge * keeps its two normals), indices are compacted per kind, simplified within `errors`, and the vertices nothing draws any more are dropped. */ export declare function reduceRenderMesh(mesh: RenderMesh, errors: SurfaceErrors): Promise; declare function markingMesh(cell: MarkingCell): { positions: Float32Array; normals: Float32Array; indices: Uint32Array; road: Uint8Array; colour: Uint8Array; uvs: Float32Array; }; /** * Welds a paint mesh: the ribbons come out of `walk` with a vertex per ribbon corner and cell, so a corner shared by two segments is held * twice. A vertex is one lattice position on one rail (`uvs.x`) in one paint colour; segments collapse only along a rail, within `errorM` * (a collapse across the ribbon would move a vertex by its width, far outside any tolerance a stripe allows). */ export declare function reduceMarkingMesh(mesh: ReturnType, errorM: number): Promise>; /** * The cell's collider: the render's up-facing triangles exactly as drawn (`tops`, welded, never simplified), plus the bake's * collider without its undersides and without the tops a render top covers, welded by exact position (clipped border vertices are * bit-identical across cells) and simplified into the rest of the budget. That rest simplifies as one mesh (its walls hold its tops' * outlines in place: a top strip simplified alone collapses across the inside of every bend, 5,000 m2 of collider over nothing) with the * error rising in root-two steps only to `RESTYLE_COLLIDER_TOP_ERROR_CAP_M`. Past that, every corner of an up-facing triangle is locked * and only the walls go on coarsening, to the cap and then the rescue cap: a wall collapsing no longer drags a top with it (pacifica-s19: * collider tops a metre over the drawn track and path). */ export declare function simplifyCollider(soup: Float32Array, budget: number, tops?: Float32Array): Promise<{ positions: Float32Array; indices: Uint32Array; before: number; topTriangles: number; errorMetres: number; topErrorMetres: number; overBudget: boolean; }>; /** Every vertex that is a corner of an up-facing triangle (normal y at least `COLLIDER_TOP_MIN_NORMAL_Y`), for `simplifyLocked`. */ export declare function upFacingCorners(positions: Float32Array, indices: Uint32Array, minNy?: number): Uint8Array; /** A soup split into its up-facing triangles (unit normal Y at least `COLLIDER_TOP_MIN_NORMAL_Y`: a surface to stand on) and the rest. */ export declare function splitUpFacing(soup: Float32Array, minNy?: number): { up: Float32Array; rest: Float32Array; }; /** A triangle facing further down than this is a slab's underside: nothing drives or walks on it, and a deck's top still stops a body from below. */ export declare const COLLIDER_UNDERSIDE_MAX_NORMAL_Y = -0.5; /** * The collider soup without its undersides. A CS2 road is a closed slab, so about a third of its collider was the bottom of a road * buried in the ground or the soffit of a deck; every one of those triangles cost the cell budget, and the simplifier made room by * doubling its error (Pacifica: 0.2 m on the worst cells), which is a 0.2 m bump or dip under a wheel and a car sitting into the drawn road. */ export declare function withoutUndersides(soup: Float32Array): Float32Array; /** * Restyles `source` (a folder holding `mesh-cells.json`) into `out`, which receives `render/`, `collider/`, * `markings-a/` and a new `mesh-cells.json`. Nothing in `source` is written. */ export declare function restyleCs2Roads(source: string, out: string, options?: RestyleOptions): Promise; export type { CellGlbResult };