import { type SurfaceFlag } from '@quake2ts/shared'; import { IndexBuffer, Texture2D, VertexArray, VertexBuffer, type VertexAttributeLayout } from './resources.js'; import { BspMap } from '../assets/bsp.js'; export interface BspLightmapData { readonly width: number; readonly height: number; readonly samples: Uint8Array; } export interface BspSurfaceInput { readonly vertices: ReadonlyArray | Float32Array; readonly textureCoords: ReadonlyArray | Float32Array; readonly lightmapCoords?: ReadonlyArray | Float32Array; readonly indices?: ReadonlyArray | Uint16Array | Uint32Array; readonly texture: string; readonly surfaceFlags?: SurfaceFlag; readonly lightmap?: BspLightmapData; readonly faceIndex: number; readonly mins?: { readonly x: number; readonly y: number; readonly z: number; }; readonly maxs?: { readonly x: number; readonly y: number; readonly z: number; }; } export interface LightmapPlacement { readonly atlasIndex: number; readonly offset: [number, number]; readonly scale: [number, number]; } export interface BspSurfaceGeometry { readonly vao: VertexArray; readonly vertexBuffer: VertexBuffer; readonly indexBuffer: IndexBuffer; readonly indexCount: number; readonly vertexCount: number; readonly texture: string; readonly surfaceFlags: SurfaceFlag; readonly lightmap?: LightmapPlacement; readonly vertexData: Float32Array; readonly indexData: Uint16Array; readonly mins?: { readonly x: number; readonly y: number; readonly z: number; }; readonly maxs?: { readonly x: number; readonly y: number; readonly z: number; }; } export interface LightmapAtlas { readonly texture: Texture2D; readonly width: number; readonly height: number; readonly pixels: Uint8Array; } export interface BspBuildOptions { readonly atlasSize?: number; readonly lightmapPadding?: number; readonly hiddenClassnames?: Set; } export interface BspGeometryBuildResult { readonly surfaces: readonly BspSurfaceGeometry[]; readonly lightmaps: readonly LightmapAtlas[]; } export declare const BSP_VERTEX_LAYOUT: readonly VertexAttributeLayout[]; /** * Converts a parsed BSP map into a set of flat surface inputs ready for rendering. * * This function handles: * 1. Traversing faces and their edges to build vertex lists. * 2. Calculating texture coordinates (UVs) from surface normals and texture info. * 3. Generating triangle indices (fan triangulation) for convex polygon faces. * 4. Extracting and calculating lightmap data and coordinates. * * @param map The parsed BSP map structure. * @returns An array of surface inputs suitable for consumption by `buildBspGeometry`. */ export declare function createBspSurfaces(map: BspMap): BspSurfaceInput[]; export declare function buildBspGeometry(gl: WebGL2RenderingContext, surfaces: readonly BspSurfaceInput[], map?: BspMap, options?: BspBuildOptions): BspGeometryBuildResult; //# sourceMappingURL=bsp.d.ts.map