import type { Box3, Vec2, Vec3 } from 'mathcat'; import { type NavMesh, type NavMeshNode, type NavMeshPoly, type NavMeshTile, type NavMeshTileParams, type OffMeshConnection, type OffMeshConnectionParams } from './nav-mesh.js'; import { type NodeRef } from './node.js'; /** * Creates a new empty navigation mesh. * @returns The created navigation mesh */ export declare const createNavMesh: () => NavMesh; /** * Gets a navigation mesh node by its reference. * Note that navmesh nodes are pooled and may be reused on removing then adding tiles, so do not store node objects. * @param navMesh the navigation mesh * @param nodeRef the node reference * @returns the navigation mesh node */ export declare const getNodeByRef: (navMesh: NavMesh, nodeRef: NodeRef) => NavMeshNode; /** * Gets a navigation mesh node by its tile and polygon index. * @param navMesh the navigation mesh * @param tile the navigation mesh tile * @param polyIndex the polygon index * @returns the navigation mesh node */ export declare const getNodeByTileAndPoly: (navMesh: NavMesh, tile: NavMeshTile, polyIndex: number) => NavMeshNode; /** * Checks if a navigation mesh node reference is valid. * @param navMesh the navigation mesh * @param nodeRef the node reference * @returns true if the node reference is valid, false otherwise */ export declare const isValidNodeRef: (navMesh: NavMesh, nodeRef: NodeRef) => boolean; /** * Gets the tile at the given x, y, and layer position. * @param navMesh the navigation mesh * @param x the x position * @param y the y position * @param layer the layer * @returns the navigation mesh tile */ export declare const getTileAt: (navMesh: NavMesh, x: number, y: number, layer: number) => NavMeshTile | undefined; /** * Gets all tiles at the given x and y position. * @param navMesh the navigation mesh * @param x the x position * @param y the y position * @returns the navigation mesh tiles */ export declare const getTilesAt: (navMesh: NavMesh, x: number, y: number) => NavMeshTile[]; /** * Returns the tile x and y position in the nav mesh from a world space position. * @param outTilePosition the output tile position * @param navMesh the navigation mesh * @param worldPosition the world space position */ export declare const worldToTilePosition: (outTilePosition: Vec2, navMesh: NavMesh, worldPosition: Vec3) => Vec2; export type GetTileAndPolyByRefResult = { success: false; tile: NavMeshTile | null; poly: NavMeshPoly | null; polyIndex: number; } | { success: true; tile: NavMeshTile; poly: NavMeshPoly; polyIndex: number; }; /** * Gets the tile and polygon from a polygon reference * @param ref The polygon reference * @param navMesh The navigation mesh * @returns Object containing tile and poly, or null if not found */ export declare const getTileAndPolyByRef: (ref: NodeRef, navMesh: NavMesh) => GetTileAndPolyByRefResult; export type GetPolyHeightResult = { success: boolean; height: number; }; export declare const createGetPolyHeightResult: () => GetPolyHeightResult; /** * Gets the height of a polygon at a given point using detail mesh if available. * @param result The result object to populate * @param tile The tile containing the polygon * @param poly The polygon * @param polyIndex The index of the polygon in the tile * @param pos The position to get height for * @returns The result object with success flag and height */ export declare const getPolyHeight: (result: GetPolyHeightResult, tile: NavMeshTile, poly: NavMeshPoly, polyIndex: number, pos: Vec3) => GetPolyHeightResult; /** * Gets the closest point on detail mesh edges to a given point * @param tile The tile containing the detail mesh * @param poly The polygon * @param pos The position to find closest point for * @param outClosestPoint Output parameter for the closest point * @param onlyBoundary If true, only consider boundary edges * @returns The squared distance to the closest point * closest point */ export declare const getClosestPointOnDetailEdges: (outClosestPoint: Vec3, tile: NavMeshTile, poly: NavMeshPoly, polyIndex: number, pos: Vec3, onlyBoundary: boolean) => number; export type GetClosestPointOnPolyResult = { success: boolean; isOverPoly: boolean; position: Vec3; }; export declare const createGetClosestPointOnPolyResult: () => GetClosestPointOnPolyResult; /** * Gets the closest point on a polygon to a given point * @param result the result object to populate * @param navMesh the navigation mesh * @param nodeRef the polygon node reference * @param position the point to find the closest point to * @returns the result object */ export declare const getClosestPointOnPoly: (result: GetClosestPointOnPolyResult, navMesh: NavMesh, nodeRef: NodeRef, position: Vec3) => GetClosestPointOnPolyResult; /** * Gets the closest point on the boundary of a polygon to a given point. * If the point is inside the polygon (in XZ), the Y coordinate is adjusted to the polygon surface. * @param out the output closest point * @param navMesh the navigation mesh * @param nodeRef the polygon node reference * @param point the point to find the closest point to * @returns whether the operation was successful */ export declare const getClosestPointOnPolyBoundary: (out: Vec3, navMesh: NavMesh, nodeRef: NodeRef, point: Vec3) => boolean; export type FindNearestPolyResult = { success: boolean; nodeRef: NodeRef; position: Vec3; }; export declare const createFindNearestPolyResult: () => FindNearestPolyResult; export declare const findNearestPoly: (result: FindNearestPolyResult, navMesh: NavMesh, center: Vec3, halfExtents: Vec3, queryFilter: QueryFilter) => FindNearestPolyResult; export declare const queryPolygonsInTile: (out: NodeRef[], navMesh: NavMesh, tile: NavMeshTile, bounds: Box3, filter: QueryFilter) => void; export declare const queryPolygons: (navMesh: NavMesh, bounds: Box3, filter: QueryFilter) => NodeRef[]; /** * Reconnects an off mesh connection. This must be called if any properties of an off mesh connection are changed, for example the start or end positions. * @param navMesh the navmesh * @param offMeshConnection the off mesh connectionion to reconnect * @returns whether the off mesh connection was successfully reconnected */ export declare const reconnectOffMeshConnection: (navMesh: NavMesh, offMeshConnection: OffMeshConnection) => boolean; /** * Builds a navmesh tile from the given parameters * This builds a BV-tree for the tile, and initializes runtime tile properties * @param params the parameters to build the tile from * @returns the built navmesh tile */ export declare const buildTile: (params: NavMeshTileParams) => NavMeshTile; /** * Adds a tile to the navmesh. * If a tile already exists at the same position, it will be removed first. * @param navMesh the navmesh to add the tile to * @param tile the tile to add */ export declare const addTile: (navMesh: NavMesh, tile: NavMeshTile) => void; /** * Removes the tile at the given location * @param navMesh the navmesh to remove the tile from * @param x the x coordinate of the tile * @param y the y coordinate of the tile * @param layer the layer of the tile * @returns true if the tile was removed, otherwise false */ export declare const removeTile: (navMesh: NavMesh, x: number, y: number, layer: number) => boolean; /** * Adds a new off mesh connection to the NavMesh, and returns it's ID * @param navMesh the navmesh to add the off mesh connection to * @param offMeshConnectionParams the parameters of the off mesh connection to add * @returns the ID of the added off mesh connection */ export declare const addOffMeshConnection: (navMesh: NavMesh, offMeshConnectionParams: OffMeshConnectionParams) => number; /** * Removes an off mesh connection from the NavMesh * @param navMesh the navmesh to remove the off mesh connection from * @param offMeshConnectionId the ID of the off mesh connection to remove */ export declare const removeOffMeshConnection: (navMesh: NavMesh, offMeshConnectionId: number) => void; /** * Returns whether the off mesh connection with the given ID is currently connected to the navmesh. * An off mesh connection may be disconnected if the start or end positions have no valid polygons nearby to connect to. * @param navMesh the navmesh * @param offMeshConnectionId the ID of the off mesh connection * @returns whether the off mesh connection is connected */ export declare const isOffMeshConnectionConnected: (navMesh: NavMesh, offMeshConnectionId: number) => boolean; /** * A query filter used in navigation queries. * * This allows for customization of what nodes are considered traversable, and * the cost of traversing between nodes. * * If you are getting started, you can use the built-in @see DEFAULT_QUERY_FILTER or @see ANY_QUERY_FILTER */ export type QueryFilter = { /** * Checks if a NavMesh node passes the filter. * @param nodeRef The node reference. * @param navMesh The navmesh * @returns Whether the node reference passes the filter. */ passFilter(nodeRef: NodeRef, navMesh: NavMesh): boolean; /** * Calculates the cost of moving from one point to another. * @param pa The start position on the edge of the previous and current node. [(x, y, z)] * @param pb The end position on the edge of the current and next node. [(x, y, z)] * @param navMesh The navigation mesh * @param prevRef The reference id of the previous node. [opt] * @param curRef The reference id of the current node. * @param nextRef The reference id of the next node. [opt] * @returns The cost of moving from the start to the end position. */ getCost(pa: Vec3, pb: Vec3, navMesh: NavMesh, prevRef: NodeRef | undefined, curRef: NodeRef, nextRef: NodeRef | undefined): number; }; export declare const ANY_QUERY_FILTER: { getCost(pa: Vec3, pb: Vec3, _navMesh: NavMesh, _prevRef: number | undefined, _curRef: number, _nextRef: number | undefined): number; passFilter(_nodeRef: NodeRef, _navMesh: NavMesh): boolean; }; export type DefaultQueryFilter = QueryFilter & { includeFlags: number; excludeFlags: number; }; export declare const createDefaultQueryFilter: () => DefaultQueryFilter; export declare const DEFAULT_QUERY_FILTER: DefaultQueryFilter;