import { VirtualFileSystem } from './vfs.js'; export type Vec3 = [number, number, number]; export interface BspLumpInfo { readonly offset: number; readonly length: number; } export interface BspHeader { readonly version: number; readonly lumps: ReadonlyMap; } export interface BspEntities { readonly raw: string; readonly entities: BspEntity[]; readonly worldspawn: BspEntity | undefined; /** * Returns a sorted array of unique entity classnames present in the map. */ getUniqueClassnames(): string[]; } export interface BspEntity { readonly classname?: string; readonly properties: Record; } export interface BspPlane { readonly normal: Vec3; readonly dist: number; readonly type: number; } export interface BspNode { readonly planeIndex: number; readonly children: [number, number]; readonly mins: [number, number, number]; readonly maxs: [number, number, number]; readonly firstFace: number; readonly numFaces: number; } export interface BspLeaf { readonly contents: number; readonly cluster: number; readonly area: number; readonly mins: [number, number, number]; readonly maxs: [number, number, number]; readonly firstLeafFace: number; readonly numLeafFaces: number; readonly firstLeafBrush: number; readonly numLeafBrushes: number; } export interface BspTexInfo { readonly s: Vec3; readonly sOffset: number; readonly t: Vec3; readonly tOffset: number; readonly flags: number; readonly value: number; readonly texture: string; readonly nextTexInfo: number; } export interface BspFace { readonly planeIndex: number; readonly side: number; readonly firstEdge: number; readonly numEdges: number; readonly texInfo: number; readonly styles: [number, number, number, number]; readonly lightOffset: number; } export interface BspEdge { readonly vertices: [number, number]; } export interface BspModel { readonly mins: Vec3; readonly maxs: Vec3; readonly origin: Vec3; readonly headNode: number; readonly firstFace: number; readonly numFaces: number; } export interface BspBrush { readonly firstSide: number; readonly numSides: number; readonly contents: number; } export interface BspBrushSide { readonly planeIndex: number; readonly texInfo: number; } export interface BspArea { readonly numAreaPortals: number; readonly firstAreaPortal: number; } export interface BspAreaPortal { readonly portalNumber: number; readonly otherArea: number; } export interface BspVisibilityCluster { readonly pvs: Uint8Array; readonly phs: Uint8Array; } export interface BspVisibility { readonly numClusters: number; readonly clusters: readonly BspVisibilityCluster[]; } export interface BspLightmapInfo { readonly offset: number; readonly length: number; } export interface BspLeafLists { readonly leafFaces: readonly number[][]; readonly leafBrushes: readonly number[][]; } export interface BspData { readonly header: BspHeader; readonly entities: BspEntities; readonly planes: readonly BspPlane[]; readonly vertices: readonly Vec3[]; readonly nodes: readonly BspNode[]; readonly texInfo: readonly BspTexInfo[]; readonly faces: readonly BspFace[]; readonly lightMaps: Uint8Array; readonly lightMapInfo: readonly (BspLightmapInfo | undefined)[]; readonly leafs: readonly BspLeaf[]; readonly leafLists: BspLeafLists; readonly edges: readonly BspEdge[]; readonly surfEdges: Int32Array; readonly models: readonly BspModel[]; readonly brushes: readonly BspBrush[]; readonly brushSides: readonly BspBrushSide[]; readonly visibility: BspVisibility | undefined; readonly areas: readonly BspArea[]; readonly areaPortals: readonly BspAreaPortal[]; } export interface BspMap extends BspData { /** * Finds the closest brush-based entity that intersects with the given ray. * @param ray An object defining the origin and direction of the ray. * @returns An object containing the intersected entity, its model, and the * distance from the ray's origin, or null if no intersection occurs. */ pickEntity(ray: { origin: Vec3; direction: Vec3; }): { entity: BspEntity; model: BspModel; distance: number; } | null; /** * Finds the leaf node containing the given point. */ findLeaf(origin: Vec3): BspLeaf; /** * Returns the PVS (Potentially Visible Set) for the given point. * Returns undefined if the point is not in a valid cluster or visibility data is missing. */ calculatePVS(origin: Vec3): Uint8Array | undefined; } export declare enum BspLump { Entities = 0, Planes = 1, Vertices = 2, Visibility = 3, Nodes = 4, TexInfo = 5, Faces = 6, Lighting = 7, Leafs = 8, LeafFaces = 9, LeafBrushes = 10, Edges = 11, SurfEdges = 12, Models = 13, Brushes = 14, BrushSides = 15, Pop = 16, Areas = 17, AreaPortals = 18 } export declare class BspParseError extends Error { } export interface BspLoaderOptions { useWorker?: boolean; workerPath?: string; } export declare class BspLoader { private readonly vfs; private readonly options; constructor(vfs: VirtualFileSystem, options?: BspLoaderOptions); load(path: string): Promise; private parseInWorker; private rehydrateData; } export declare function parseBsp(buffer: ArrayBuffer): BspMap; export declare function createBspMap(data: BspData): BspMap; export declare function parseBspData(buffer: ArrayBuffer): BspData; export declare function createFaceLightmap(face: BspFace, lightMaps: Uint8Array, info?: BspLightmapInfo): Uint8Array | undefined; export declare function parseWorldspawnSettings(entities: BspEntities): Record; //# sourceMappingURL=bsp.d.ts.map