import type { Vec3 } from "../world/geometry.js"; /** Explicit traversable connection between two navigation polygons. */ export interface NavMeshLink { from: number; to: number; cost?: number; /** Where the link leaves `from`; defaults to that polygon's center. */ start?: Vec3; /** Where the link lands in `to`; defaults to that polygon's center. */ end?: Vec3; } /** Serializable polygon navigation mesh data. Treat it as immutable once queried; queries cache derived geometry per object. */ export interface NavMeshData { /** Flat xyz vertex coordinates. Polygon indices refer to triples in this array. */ verts: number[]; /** Convex polygons as vertex index lists. */ polys: number[][]; links: NavMeshLink[]; /** Area id per polygon, priced by {@link NavMeshQueryOptions.areaCosts}. */ areas?: number[]; } /** Neighbor relationship for one navigation polygon. */ export interface NavMeshAdjacency { neighbors: number[]; cost: number; } /** Route points and polygons selected through a navigation mesh. */ export interface NavMeshPath { points: Vec3[]; polys: number[]; /** True when the search budget ran out and the route ends at the polygon nearest the goal. */ partial?: boolean; } /** Tunable pricing and bounds for a {@link NavMeshQuery}. */ export interface NavMeshQueryOptions { /** Cost multiplier per area id; unlisted areas cost 1, and a negative or non-finite cost blocks the area. */ areaCosts?: Readonly>; /** Most polygons one path search may expand before returning a partial path. Default 2048. */ maxNodes?: number; } /** Serializable tuning of a {@link NavMeshQuery}. */ export interface NavMeshQuerySnapshot { areaCosts: Record; maxNodes: number; } /** Cached, allocation-light queries over one {@link NavMeshData}. */ export interface NavMeshQuery { readonly mesh: NavMeshData; /** Polygon nearest the point in 3D, so stacked floors resolve by height; null for an empty mesh. */ findPolygon(point: Vec3): number | null; /** Closest point on the mesh surface, or null for an empty mesh. */ closestPoint(point: Vec3): Vec3 | null; /** Cheapest polygon corridor by A*, straightened with a portal funnel. */ findPath(from: Vec3, to: Vec3): NavMeshPath | null; /** True when the straight segment stays on walkable, unblocked polygons. */ raycast(from: Vec3, to: Vec3): boolean; retune(patch: NavMeshQueryOptions): void; snapshot(): NavMeshQuerySnapshot; restore(next: NavMeshQuerySnapshot): void; } /** Build polygon adjacency from shared edges and explicit off-mesh links. */ export declare function buildNavAdjacency(mesh: NavMeshData): NavMeshAdjacency[]; /** * Create a cached query over a nav mesh: height-aware polygon lookup through a uniform grid, binary-heap A* * priced by area costs and bounded by `maxNodes`, portal-funnel path straightening, and edge-walking raycasts. * @capability navmesh-query route, snap, and raycast on a polygon navmesh with retunable area costs and a bounded search */ export declare function createNavMeshQuery(mesh: NavMeshData, options?: NavMeshQueryOptions): NavMeshQuery; /** Return the closest point on the mesh surface, or null for an empty mesh. */ export declare function closestPoint(mesh: NavMeshData, point: Vec3): Vec3 | null; /** A* over polygon portals with default area costs, straightened by a portal funnel. Use {@link createNavMeshQuery} to price areas. */ export declare function findPath(mesh: NavMeshData, from: Vec3, to: Vec3): NavMeshPath | null; /** True when the segment remains over walkable polygons. */ export declare function raycastNav(mesh: NavMeshData, from: Vec3, to: Vec3): boolean;