|
@@ -10,25 +10,50 @@ import { Scene } from "../scene";
|
|
export interface INavigationEnginePlugin {
|
|
export interface INavigationEnginePlugin {
|
|
name: string;
|
|
name: string;
|
|
|
|
|
|
- /// Create a navigation mesh that will constrain a Crowd of agents
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Creates a navigation mesh
|
|
|
|
+ * @param mesh of all the geometry used to compute the navigatio mesh
|
|
|
|
+ * @param parameters bunch of parameters used to filter geometry
|
|
|
|
+ */
|
|
createMavMesh(mesh: AbstractMesh, parameters: NavMeshParameters): void;
|
|
createMavMesh(mesh: AbstractMesh, parameters: NavMeshParameters): void;
|
|
|
|
|
|
- /// Create and a to the scene a debug navmesh. Set the material to make it visible
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Create a navigation mesh debug mesh
|
|
|
|
+ * @param scene is where the mesh will be added
|
|
|
|
+ * @returns debug display mesh
|
|
|
|
+ */
|
|
createDebugNavMesh(scene: Scene): Mesh;
|
|
createDebugNavMesh(scene: Scene): Mesh;
|
|
|
|
|
|
- /// Get a navigation mesh constrained position, closest to the parameter position
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Get a navigation mesh constrained position, closest to the parameter position
|
|
|
|
+ * @param position world position
|
|
|
|
+ * @returns the closest point to position constrained by the navigation mesh
|
|
|
|
+ */
|
|
getClosestPoint(position: Vector3): Vector3;
|
|
getClosestPoint(position: Vector3): Vector3;
|
|
|
|
|
|
- /// return a random position within a position centered disk
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Get a navigation mesh constrained position, within a particular radius
|
|
|
|
+ * @param position world position
|
|
|
|
+ * @param maxRadius the maximum distance to the constrained world position
|
|
|
|
+ * @returns the closest point to position constrained by the navigation mesh
|
|
|
|
+ */
|
|
getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
|
|
getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
|
|
|
|
|
|
///
|
|
///
|
|
isSupported(): boolean;
|
|
isSupported(): boolean;
|
|
|
|
|
|
- /// Create a new Crowd so you can add agents
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Create a new Crowd so you can add agents
|
|
|
|
+ * @param maxAgents the maximum agent count in the crowd
|
|
|
|
+ * @param maxAgentRadius the maximum radius an agent can have
|
|
|
|
+ * @param scene to attach the crowd to
|
|
|
|
+ * @returns the crowd you can add agents to
|
|
|
|
+ */
|
|
createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
|
|
createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
|
|
|
|
|
|
- ///
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Release all resources
|
|
|
|
+ */
|
|
dispose(): void;
|
|
dispose(): void;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -36,100 +61,175 @@ export interface INavigationEnginePlugin {
|
|
* Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
|
|
* Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
|
|
*/
|
|
*/
|
|
export interface ICrowd {
|
|
export interface ICrowd {
|
|
- /// add a new agent to the crowd with the specified parameter a corresponding transformNode.
|
|
|
|
- /// You can attach anything to that node. The node position is updated in the scene update tick.
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
|
|
|
|
+ * You can attach anything to that node. The node position is updated in the scene update tick.
|
|
|
|
+ * @param pos world position that will be constrained by the navigation mesh
|
|
|
|
+ * @param parameters agent parameters
|
|
|
|
+ * @param transform hooked to the agent that will be update by the scene
|
|
|
|
+ * @returns agent index
|
|
|
|
+ */
|
|
addAgent(pos: Vector3, parameters: AgentParameters, transform: TransformNode): number;
|
|
addAgent(pos: Vector3, parameters: AgentParameters, transform: TransformNode): number;
|
|
|
|
|
|
- ///
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Returns the agent position in world space
|
|
|
|
+ * @param index agent index returned by addAgent
|
|
|
|
+ * @returns world space position
|
|
|
|
+ */
|
|
getAgentPosition(index: number): Vector3;
|
|
getAgentPosition(index: number): Vector3;
|
|
|
|
|
|
- ///
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Gets the agent velocity in world space
|
|
|
|
+ * @param index agent index returned by addAgent
|
|
|
|
+ * @returns world space velocity
|
|
|
|
+ */
|
|
getAgentVelocity(index: number): Vector3;
|
|
getAgentVelocity(index: number): Vector3;
|
|
|
|
|
|
- /// remove a particular agent previously created
|
|
|
|
|
|
+ /**
|
|
|
|
+ * remove a particular agent previously created
|
|
|
|
+ * @param index agent index returned by addAgent
|
|
|
|
+ */
|
|
removeAgent(index: number): void;
|
|
removeAgent(index: number): void;
|
|
|
|
|
|
- /// get the list of all agents attached to this crowd
|
|
|
|
|
|
+ /**
|
|
|
|
+ * get the list of all agents attached to this crowd
|
|
|
|
+ * @returns list of agent indices
|
|
|
|
+ */
|
|
getAgents() : number[];
|
|
getAgents() : number[];
|
|
|
|
|
|
- /// Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
|
|
|
|
+ * @param deltaTime in seconds
|
|
|
|
+ */
|
|
update(deltaTime: number): void;
|
|
update(deltaTime: number): void;
|
|
|
|
|
|
- /// Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
|
|
|
|
+ * @param index agent index returned by addAgent
|
|
|
|
+ * @param destination targeted world position
|
|
|
|
+ * @returns the closest point to position constrained by the navigation mesh
|
|
|
|
+ */
|
|
agentGoto(index: number, destination: Vector3): void;
|
|
agentGoto(index: number, destination: Vector3): void;
|
|
|
|
|
|
- /// dispose
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Release all resources
|
|
|
|
+ */
|
|
dispose() : void;
|
|
dispose() : void;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * Configures an agent
|
|
|
|
+ */
|
|
export class AgentParameters {
|
|
export class AgentParameters {
|
|
- /// Agent radius. [Limit: >= 0]
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Agent radius. [Limit: >= 0]
|
|
|
|
+ */
|
|
radius: number;
|
|
radius: number;
|
|
|
|
|
|
- /// Agent height. [Limit: > 0]
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Agent height. [Limit: > 0]
|
|
|
|
+ */
|
|
height: number;
|
|
height: number;
|
|
|
|
|
|
- /// Maximum allowed acceleration. [Limit: >= 0]
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Maximum allowed acceleration. [Limit: >= 0]
|
|
|
|
+ */
|
|
maxAcceleration: number;
|
|
maxAcceleration: number;
|
|
|
|
|
|
- /// Maximum allowed speed. [Limit: >= 0]
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Maximum allowed speed. [Limit: >= 0]
|
|
|
|
+ */
|
|
maxSpeed: number;
|
|
maxSpeed: number;
|
|
|
|
|
|
- /// Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
|
|
|
|
+ */
|
|
collisionQueryRange: number;
|
|
collisionQueryRange: number;
|
|
|
|
|
|
- /// The path visibility optimization range. [Limit: > 0]
|
|
|
|
|
|
+ /**
|
|
|
|
+ * The path visibility optimization range. [Limit: > 0]
|
|
|
|
+ */
|
|
pathOptimizationRange: number;
|
|
pathOptimizationRange: number;
|
|
|
|
|
|
- /// How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
|
|
|
|
|
|
+ /**
|
|
|
|
+ * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
|
|
|
|
+ */
|
|
separationWeight: number;
|
|
separationWeight: number;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * Configures the navigation mesh creation
|
|
|
|
+ */
|
|
export class NavMeshParameters {
|
|
export class NavMeshParameters {
|
|
- /// The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
|
|
|
|
- cs: number;
|
|
|
|
-
|
|
|
|
- /// The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
|
|
|
|
|
|
+ /**
|
|
|
|
+ * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
|
|
|
|
+ */
|
|
|
|
+ cs: number;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
|
|
|
|
+ */
|
|
ch: number;
|
|
ch: number;
|
|
-
|
|
|
|
- //constructor(): NavMeshParameters;
|
|
|
|
- /// The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
|
|
|
|
+ */
|
|
walkableSlopeAngle: number;
|
|
walkableSlopeAngle: number;
|
|
|
|
|
|
- /// Minimum floor to 'ceiling' height that will still allow the floor area to
|
|
|
|
- /// be considered walkable. [Limit: >= 3] [Units: vx]
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Minimum floor to 'ceiling' height that will still allow the floor area to
|
|
|
|
+ * be considered walkable. [Limit: >= 3] [Units: vx]
|
|
|
|
+ */
|
|
walkableHeight: number;
|
|
walkableHeight: number;
|
|
|
|
|
|
- /// Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
|
|
|
|
+ */
|
|
walkableClimb: number;
|
|
walkableClimb: number;
|
|
|
|
|
|
- /// The distance to erode/shrink the walkable area of the heightfield away from
|
|
|
|
- /// obstructions. [Limit: >=0] [Units: vx]
|
|
|
|
|
|
+ /**
|
|
|
|
+ * The distance to erode/shrink the walkable area of the heightfield away from
|
|
|
|
+ * obstructions. [Limit: >=0] [Units: vx]
|
|
|
|
+ */
|
|
walkableRadius: number;
|
|
walkableRadius: number;
|
|
|
|
|
|
- /// The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
|
|
|
|
|
|
+ /**
|
|
|
|
+ * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
|
|
|
|
+ */
|
|
maxEdgeLen: number;
|
|
maxEdgeLen: number;
|
|
|
|
|
|
- /// The maximum distance a simplfied contour's border edges should deviate
|
|
|
|
- /// the original raw contour. [Limit: >=0] [Units: vx]
|
|
|
|
|
|
+ /**
|
|
|
|
+ * The maximum distance a simplfied contour's border edges should deviate
|
|
|
|
+ * the original raw contour. [Limit: >=0] [Units: vx]
|
|
|
|
+ */
|
|
maxSimplificationError: number;
|
|
maxSimplificationError: number;
|
|
|
|
|
|
- /// The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
|
|
|
|
|
|
+ /**
|
|
|
|
+ * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
|
|
|
|
+ */
|
|
minRegionArea: number;
|
|
minRegionArea: number;
|
|
|
|
|
|
- /// Any regions with a span count smaller than this value will, if possible,
|
|
|
|
- /// be merged with larger regions. [Limit: >=0] [Units: vx]
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Any regions with a span count smaller than this value will, if possible,
|
|
|
|
+ * be merged with larger regions. [Limit: >=0] [Units: vx]
|
|
|
|
+ */
|
|
mergeRegionArea: number;
|
|
mergeRegionArea: number;
|
|
|
|
|
|
- /// The maximum number of vertices allowed for polygons generated during the
|
|
|
|
- /// contour to polygon conversion process. [Limit: >= 3]
|
|
|
|
|
|
+ /**
|
|
|
|
+ * The maximum number of vertices allowed for polygons generated during the
|
|
|
|
+ * contour to polygon conversion process. [Limit: >= 3]
|
|
|
|
+ */
|
|
maxVertsPerPoly: number;
|
|
maxVertsPerPoly: number;
|
|
|
|
|
|
- /// Sets the sampling distance to use when generating the detail mesh.
|
|
|
|
- /// (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Sets the sampling distance to use when generating the detail mesh.
|
|
|
|
+ * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
|
|
|
|
+ */
|
|
detailSampleDist: number;
|
|
detailSampleDist: number;
|
|
|
|
|
|
- /// The maximum distance the detail mesh surface should deviate from heightfield
|
|
|
|
- /// data. (For height detail only.) [Limit: >=0] [Units: wu]
|
|
|
|
|
|
+ /**
|
|
|
|
+ * The maximum distance the detail mesh surface should deviate from heightfield
|
|
|
|
+ * data. (For height detail only.) [Limit: >=0] [Units: wu]
|
|
|
|
+ */
|
|
detailSampleMaxError: number;
|
|
detailSampleMaxError: number;
|
|
}
|
|
}
|