import { type Cs2MeshGroupRecord, type Cs2PrefabMeshEntry, type Cs2PrefabMeshManifest } from './types'; export declare const CSM2_MAGIC = 843928387; export declare const CSM2_HEADER_BYTES = 32; export declare const CSM2_GROUPED_HEADER_BYTES = 36; export declare const CSM2_GROUP_BYTES = 16; /** @deprecated Triangle ratios are not LOD metadata. Retained only for API compatibility. */ export declare const CSM2_LOD_REDUCED_SHARE = 0.25; export interface Csm2Mesh { version: number; flags: number; /** Positions are metres in the world frame; the Z mirror is already applied and the winding is already correct. */ positions: Float32Array; /** Stored i16, divided by 32767 here. */ normals: Float32Array; /** Stored IEEE half, widened here. */ uvs: Float32Array; indices: Uint16Array | Uint32Array; groups: Cs2MeshGroupRecord[]; } export interface Csm2Bounds { min: [number, number, number]; max: [number, number, number]; centre: [number, number, number]; /** Radius of the sphere around `centre` that contains every vertex. */ radius: number; } export interface Csm2LodSplit { /** Largest source mesh, for diagnostics only. Every source group is retained. */ largestMeshIndex: number; reducedMeshIndices: number[]; nearMeshIndices: number[]; farMeshIndices: number[]; near: Cs2MeshGroupRecord[]; far: Cs2MeshGroupRecord[]; nearTriangles: number; farTriangles: number; /** Without explicit LOD metadata, `far` repeats the complete `near` assembly. */ farIsNear: boolean; } /** Decodes one CSM2 container. Every header invariant the writer enforces is enforced here too. */ export declare function decodeCsm2(bytes: Uint8Array): Csm2Mesh; /** * CS2 packs a vertex normal octahedrally (`_TANGENTSPACE_OCTO`), and the exporter's unpack is wrong for the lower hemisphere: it keeps the * raw octahedral pair as x and y and clamps z to 0. The tell is `z == 0` with `|x| + |y| > 1` (a vector the upper hemisphere never produces: * (1, 1, 0), (-0.9, 0.7, 0) ...). On the Leonida buildings that is 15 to 20 % of all vertices, every one on a face pointing along the mesh's * +Z (the game's -Z), so a facade came out with triangles lit as if they faced sideways: the black wedge blotches on towers. The fold the * exporter skipped is `x' = (1 - |y|) sign(x)`, `y' = (1 - |x|) sign(y)`, `z = |x| + |y| - 1` (here in the mirrored frame, so z is negated back). * A real horizontal normal also has `z == 0`, so each candidate is decoded both ways and keeps whichever agrees with the faces that use the * vertex. Repairs in place; returns how many vertices changed. */ export declare function repairOctahedralNormals(positions: Float32Array, normals: Float32Array, indices: ArrayLike): number; /** No bounds are stored anywhere in the container, so every consumer computes them. */ export declare function computeBounds(positions: Float32Array): Csm2Bounds; /** * @deprecated CSM2 groups identify component/material ranges, not interchangeable LODs. * Without authored LOD metadata, retain the complete assembly at both distances. Use generateCsm2Lods to reduce it. */ export declare function splitLodBuckets(groups: readonly Cs2MeshGroupRecord[], indices?: ArrayLike): Csm2LodSplit; export interface Cs2MeshDirectory { manifest: Cs2PrefabMeshManifest; dir: string; byPrefab: Map; } /** Reads `prefab-meshes-v2.json` from a `meshes-v2/` or `tree-meshes-v2/` folder. No container bytes are touched. */ export declare function readCs2MeshDirectory(dir: string, manifestName?: string): Promise; /** Loads one prefab's container. The file name is opaque and comes only from `entries[].file`. */ export declare function readCs2Mesh(directory: Cs2MeshDirectory, prefab: string): Promise; export declare function halfToFloat(value: number): number;