UNPKG

three-pathfinding-3d

Version:

A 3D pathfinding library for Three.js, supporting navigation meshes (navmeshes) and various pathfinding algorithms.

66 lines (65 loc) 2.17 kB
import { Vector3, type BufferGeometry } from 'three'; import type { Zone, GroupItem } from './type'; /** * Defines an instance of the pathfinding module, with one or more zones. */ declare class Pathfinding { zones: { [key: string]: Zone; }; constructor(); /** * (Static) Builds a zone/node set from navigation mesh geometry. * @param geometry * @param tolerance Vertex welding tolerance. * @return */ static createZone(geometry: BufferGeometry, tolerance?: number): Zone; /** * Sets data for the given zone. * @param zoneID * @param zone */ setZoneData(zoneID: string, zone: Zone): void; /** * Returns the closest node to the target position. * @param position * @param zoneID * @param groupID * @param checkPolygon * @return */ getClosestNode(position: Vector3, zoneID: string, groupID: number, checkPolygon?: boolean): GroupItem; /** * Returns a path between given start and end points. If a complete path * cannot be found, will return the nearest endpoint available. * * @param startPosition Start position. * @param targetPosition Destination. * @param zoneID ID of current zone. * @param groupID Current group ID. * @return Array of points defining the path. */ findPath(startPosition: Vector3, targetPosition: Vector3, zoneID: string, groupID: number): { path: Vector3[]; nodePath: GroupItem[]; channelPath: { left: Vector3; right: Vector3; }[]; }; getGroup(zoneID: string, position: Vector3, checkPolygon?: boolean): number; /** * Clamps a step along the navmesh, given start and desired endpoint. May be * used to constrain first-person / WASD controls. * * @param start start point * @param end Desired end point. * @param zoneID * @param groupID * @param endTarget Updated endpoint. * @return Updated node. */ clampStep(startRef: Vector3, endRef: Vector3, zoneID: string, groupID: number, endTarget: Vector3): GroupItem; } export { Pathfinding };