Skip to content

Early version of the recast-navigation-js navigation plugin #16612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 125 additions & 3 deletions packages/dev/core/src/Navigation/INavigationEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import type { TransformNode } from "../Meshes/transformNode";
import type { Vector3 } from "../Maths/math";
import type { Mesh } from "../Meshes/mesh";
import type { Scene } from "../scene";
import type { IVector3Like } from "../Maths/math.like";

/**
* Navigation plugin interface to add navigation constrained by a navigation mesh
*/
export interface INavigationEnginePlugin {
export interface INavigationEnginePlugin0 {
/**
* plugin name
*/
Expand All @@ -17,7 +18,7 @@ export interface INavigationEnginePlugin {
* @param meshes array of all the geometry used to compute the navigation mesh
* @param parameters bunch of parameters used to filter geometry
*/
createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters0): void;

/**
* Create a navigation mesh debug mesh
Expand Down Expand Up @@ -196,6 +197,106 @@ export interface INavigationEnginePlugin {
dispose(): void;
}

/**
*
*/
export interface INavigationEnginePlugin extends INavigationEnginePlugin0 {
/**
*
*/
navMesh?: any;

/**
*
*/
navMeshQuery: any;
/**
*
*/
setWorker: (worker: Worker) => void;
getClosestPoint(
position: IVector3Like,
options?: {
/**
*
*/
halfExtents?: IVector3Like;
}
): Vector3;
getClosestPointToRef(
position: IVector3Like,
result: Vector3,
options?: {
/**
*
*/
halfExtents?: IVector3Like;
}
): void;
getRandomPointAround(
position: IVector3Like,
maxRadius: number,
options?: {
/**
*
*/
startRef?: number;
/**
*
*/
halfExtents?: IVector3Like;
}
): Vector3;
getRandomPointAroundToRef(
position: IVector3Like,
maxRadius: number,
result: Vector3,
options?: {
/**
*
*/
startRef?: number;
/**
*
*/
halfExtents?: IVector3Like;
}
): void;

createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters0, completion?: (navmeshData: Uint8Array) => void): void;
createNavMeshWorker(meshes: Array<Mesh>, parameters: INavMeshParameters0, completion: (data?: Uint8Array) => void): void;
computePathSmooth(
start: Vector3,
end: Vector3,
options?: {
/**
*
*/
halfExtents?: IVector3Like;

/**
* @default 256
*/
maxPathPolys?: number;

/**
* @default 2048
*/
maxSmoothPathPoints?: number;

/**
* @default 0.5
*/
stepSize?: number;

/**
* @default 0.01
*/
slop?: number;
}
): Vector3[];
}

/**
* Obstacle interface
*/
Expand Down Expand Up @@ -392,7 +493,7 @@ export interface IAgentParameters {
/**
* Configures the navigation mesh creation
*/
export interface INavMeshParameters {
export interface INavMeshParameters0 {
/**
* The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
*/
Expand Down Expand Up @@ -472,6 +573,27 @@ export interface INavMeshParameters {
*/
tileSize?: number;

/**
* A hint to Recast for how many walkable surface layers might exist per tile
* allowing better memory and performance tuning during navmesh generation.
*/
expectedLayersPerTile?: number;

/**
* The hard limit on how many stacked walkable surfaces (layers) a tile can have.
* If Recast finds more layers than maxLayers, tile generation may fail or lose data.
* Use a higher value (e.g. 4–8) for complex multi-level scenes; 1–2 is fine for flat terrain.
*/
maxLayers?: number;

/**
* If set to true, intermediate objects used during the generation process will be retained.
* This is useful for debugging purposes or if you want to process the intermediate data in any other way.
* For example you can use it to trace countours, calculate heightfields, etc.
* Defaults to false.
*/
keepIntermediates?: boolean;

/**
* The size of the non-navigable border around the heightfield.
*/
Expand Down
Loading