@recast-navigation/core 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/crowd.d.ts +99 -5
- package/dist/index.d.ts +7 -1
- package/dist/index.es.js +1 -1
- package/dist/index.es.js.map +1 -1
- package/dist/nav-mesh-builder.d.ts +44 -0
- package/dist/nav-mesh-exporter.d.ts +12 -0
- package/dist/nav-mesh-generator.d.ts +116 -0
- package/dist/nav-mesh-importer.d.ts +16 -0
- package/dist/nav-mesh-query.d.ts +46 -0
- package/dist/nav-mesh.d.ts +33 -84
- package/dist/tile-cache.d.ts +48 -0
- package/dist/{raw.d.ts → wasm.d.ts} +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type R from '@recast-navigation/wasm';
|
|
2
|
+
export declare type NavMeshCreateParams = {
|
|
3
|
+
verts: number[];
|
|
4
|
+
vertCount: number;
|
|
5
|
+
polys: number[];
|
|
6
|
+
polyFlags: number[];
|
|
7
|
+
polyAreas: number[];
|
|
8
|
+
polyCount: number;
|
|
9
|
+
nvp: number;
|
|
10
|
+
detailMeshes: number[];
|
|
11
|
+
detailVerts: number[];
|
|
12
|
+
detailVertsCount: number;
|
|
13
|
+
detailTris: number[];
|
|
14
|
+
detailTriCount: number;
|
|
15
|
+
offMeshConVerts: number[];
|
|
16
|
+
offMeshConRad: number[];
|
|
17
|
+
offMeshConFlags: number[];
|
|
18
|
+
offMeshConAreas: number[];
|
|
19
|
+
offMeshConDir: number[];
|
|
20
|
+
offMeshConUserID: number[];
|
|
21
|
+
offMeshConCount: number;
|
|
22
|
+
userId: number;
|
|
23
|
+
tileX: number;
|
|
24
|
+
tileY: number;
|
|
25
|
+
tileLayer: number;
|
|
26
|
+
bmin: number[];
|
|
27
|
+
bmax: number[];
|
|
28
|
+
walkableHeight: number;
|
|
29
|
+
walkableRadius: number;
|
|
30
|
+
walkableClimb: number;
|
|
31
|
+
cs: number;
|
|
32
|
+
ch: number;
|
|
33
|
+
buildBvTree: boolean;
|
|
34
|
+
};
|
|
35
|
+
export declare type CreateNavMeshDataResult = {
|
|
36
|
+
success: boolean;
|
|
37
|
+
navMeshData: readonly number[];
|
|
38
|
+
navMeshDataSize: number;
|
|
39
|
+
};
|
|
40
|
+
export declare class NavMeshBuilder {
|
|
41
|
+
raw: R.NavMeshBuilder;
|
|
42
|
+
constructor();
|
|
43
|
+
createNavMeshData(params: NavMeshCreateParams): CreateNavMeshDataResult;
|
|
44
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type R from '@recast-navigation/wasm';
|
|
2
|
+
import { NavMesh } from './nav-mesh';
|
|
3
|
+
import { TileCache } from './tile-cache';
|
|
4
|
+
export declare class NavMeshExporter {
|
|
5
|
+
raw: R.NavMeshExporter;
|
|
6
|
+
constructor();
|
|
7
|
+
/**
|
|
8
|
+
* Returns a NavMesh export that can be used later. The NavMesh must be built before retrieving the data
|
|
9
|
+
* @returns data the Uint8Array that can be saved and reused
|
|
10
|
+
*/
|
|
11
|
+
export(navMesh: NavMesh, tileCache?: TileCache): Uint8Array;
|
|
12
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type R from '@recast-navigation/wasm';
|
|
2
|
+
import { NavMesh } from './nav-mesh';
|
|
3
|
+
import { TileCache } from './tile-cache';
|
|
4
|
+
export declare type NavMeshConfig = {
|
|
5
|
+
/**
|
|
6
|
+
* The size of the non-navigable border around the heightfield.
|
|
7
|
+
* [Limit: >=0] [Units: vx]
|
|
8
|
+
* @default 0
|
|
9
|
+
*/
|
|
10
|
+
borderSize: number;
|
|
11
|
+
/**
|
|
12
|
+
* The width/height size of tile's on the xz-plane.
|
|
13
|
+
* [Limit: >= 0] [Units: vx]
|
|
14
|
+
*
|
|
15
|
+
* If tileSize is provided, a tiled navmesh will be created.
|
|
16
|
+
* If tileSize is not provided, or is set to zero, a solo navmesh will be created.
|
|
17
|
+
*
|
|
18
|
+
* To use obstacles, a tiled navmesh must be generated.
|
|
19
|
+
* @default 0
|
|
20
|
+
*/
|
|
21
|
+
tileSize: number;
|
|
22
|
+
/**
|
|
23
|
+
* The xz-plane cell size to use for fields.
|
|
24
|
+
* [Limit: > 0] [Units: wu]
|
|
25
|
+
* @default 0.2
|
|
26
|
+
*/
|
|
27
|
+
cs: number;
|
|
28
|
+
/**
|
|
29
|
+
* The y-axis cell size to use for fields.
|
|
30
|
+
* Limit: > 0] [Units: wu]
|
|
31
|
+
* @default 0.2
|
|
32
|
+
*/
|
|
33
|
+
ch: number;
|
|
34
|
+
/**
|
|
35
|
+
* The maximum slope that is considered walkable.
|
|
36
|
+
* [Limits: 0 <= value < 90] [Units: Degrees]
|
|
37
|
+
* @default 60
|
|
38
|
+
*/
|
|
39
|
+
walkableSlopeAngle: number;
|
|
40
|
+
/**
|
|
41
|
+
* Minimum floor to 'ceiling' height that will still allow the floor area to be considered walkable.
|
|
42
|
+
* [Limit: >= 3] [Units: vx]
|
|
43
|
+
* @default 2
|
|
44
|
+
*/
|
|
45
|
+
walkableHeight: number;
|
|
46
|
+
/**
|
|
47
|
+
* Maximum ledge height that is considered to still be traversable.
|
|
48
|
+
* [Limit: >=0] [Units: vx]
|
|
49
|
+
* @default 2
|
|
50
|
+
*/
|
|
51
|
+
walkableClimb: number;
|
|
52
|
+
/**
|
|
53
|
+
* The distance to erode/shrink the walkable area of the heightfield away from obstructions.
|
|
54
|
+
* [Limit: >=0] [Units: vx]
|
|
55
|
+
* @default 0.5
|
|
56
|
+
*/
|
|
57
|
+
walkableRadius: number;
|
|
58
|
+
/**
|
|
59
|
+
* The maximum allowed length for contour edges along the border of the mesh.
|
|
60
|
+
* [Limit: >=0] [Units: vx]
|
|
61
|
+
* @default 12
|
|
62
|
+
*/
|
|
63
|
+
maxEdgeLen: number;
|
|
64
|
+
/**
|
|
65
|
+
* The maximum distance a simplfied contour's border edges should deviate the original raw contour.
|
|
66
|
+
* [Limit: >=0] [Units: vx]
|
|
67
|
+
* @default 1.3
|
|
68
|
+
*/
|
|
69
|
+
maxSimplificationError: number;
|
|
70
|
+
/**
|
|
71
|
+
* The minimum number of cells allowed to form isolated island areas.
|
|
72
|
+
* [Limit: >=0] [Units: vx]
|
|
73
|
+
* @default 8
|
|
74
|
+
*/
|
|
75
|
+
minRegionArea: number;
|
|
76
|
+
/**
|
|
77
|
+
* Any regions with a span count smaller than this value will, if possible, be merged with larger regions.
|
|
78
|
+
* [Limit: >=0] [Units: vx]
|
|
79
|
+
* @default 20
|
|
80
|
+
*/
|
|
81
|
+
mergeRegionArea: number;
|
|
82
|
+
/**
|
|
83
|
+
* The maximum number of vertices allowed for polygons generated during the be merged with larger regions.
|
|
84
|
+
* [Limit: >=0] [Units: vx]
|
|
85
|
+
* @default 6
|
|
86
|
+
*/
|
|
87
|
+
maxVertsPerPoly: number;
|
|
88
|
+
/**
|
|
89
|
+
* Sets the sampling distance to use when generating the detail mesh. (For height detail only.)
|
|
90
|
+
* [Limits: 0 or >= 0.9] [Units: wu]
|
|
91
|
+
* @default 6
|
|
92
|
+
*/
|
|
93
|
+
detailSampleDist: number;
|
|
94
|
+
/**
|
|
95
|
+
* The maximum distance the detail mesh surface should deviate from heightfield data. (For height detail only.)
|
|
96
|
+
* [Limit: >=0] [Units: wu]
|
|
97
|
+
* @default 1
|
|
98
|
+
*/
|
|
99
|
+
detailSampleMaxError: number;
|
|
100
|
+
};
|
|
101
|
+
export declare type NavMeshGeneratorResult = {
|
|
102
|
+
success: boolean;
|
|
103
|
+
navMesh: NavMesh;
|
|
104
|
+
tileCache: TileCache;
|
|
105
|
+
};
|
|
106
|
+
export declare class NavMeshGenerator {
|
|
107
|
+
raw: R.NavMeshGenerator;
|
|
108
|
+
constructor();
|
|
109
|
+
/**
|
|
110
|
+
* Builds a NavMesh from the given positions and indices.
|
|
111
|
+
* @param positions a flat array of positions
|
|
112
|
+
* @param indices a flat array of indices
|
|
113
|
+
* @param navMeshConfig optional configuration for the NavMesh
|
|
114
|
+
*/
|
|
115
|
+
generate(positions: ArrayLike<number>, indices: ArrayLike<number>, navMeshConfig?: Partial<NavMeshConfig>): NavMeshGeneratorResult;
|
|
116
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type R from '@recast-navigation/wasm';
|
|
2
|
+
import { NavMesh } from './nav-mesh';
|
|
3
|
+
import { TileCache } from './tile-cache';
|
|
4
|
+
export declare type NavMeshImporterResult = {
|
|
5
|
+
navMesh: NavMesh;
|
|
6
|
+
tileCache: TileCache;
|
|
7
|
+
};
|
|
8
|
+
export declare class NavMeshImporter {
|
|
9
|
+
raw: R.NavMeshImporter;
|
|
10
|
+
constructor();
|
|
11
|
+
/**
|
|
12
|
+
* Build the navmesh from a previously saved state using getNavMeshExport
|
|
13
|
+
* @param data the Uint8Array returned by `getNavMeshExport`
|
|
14
|
+
*/
|
|
15
|
+
import(data: Uint8Array): NavMeshImporterResult;
|
|
16
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type R from '@recast-navigation/wasm';
|
|
2
|
+
import { NavMesh } from './nav-mesh';
|
|
3
|
+
import { NavPath, Vector3 } from './utils';
|
|
4
|
+
export declare type NavMeshQueryParams = {
|
|
5
|
+
navMesh: NavMesh;
|
|
6
|
+
/**
|
|
7
|
+
* @default 2048
|
|
8
|
+
*/
|
|
9
|
+
maxNodes?: number;
|
|
10
|
+
};
|
|
11
|
+
export declare class NavMeshQuery {
|
|
12
|
+
raw: R.NavMeshQuery;
|
|
13
|
+
constructor({ navMesh, maxNodes }: NavMeshQueryParams);
|
|
14
|
+
/**
|
|
15
|
+
* Returns the closest point on the NavMesh to the given position.
|
|
16
|
+
*/
|
|
17
|
+
getClosestPoint(position: Vector3): Vector3;
|
|
18
|
+
/**
|
|
19
|
+
* Returns a random point on the NavMesh within the given radius of the given position.
|
|
20
|
+
*/
|
|
21
|
+
getRandomPointAround(position: Vector3, radius: number): Vector3;
|
|
22
|
+
/**
|
|
23
|
+
* Compute the final position from a segment made of destination-position
|
|
24
|
+
*/
|
|
25
|
+
moveAlong(position: Vector3, destination: Vector3): Vector3;
|
|
26
|
+
/**
|
|
27
|
+
* Finds a path from the start position to the end position.
|
|
28
|
+
*g
|
|
29
|
+
* @returns an array of Vector3 positions that make up the path, or an empty array if no path was found.
|
|
30
|
+
*/
|
|
31
|
+
computePath(start: Vector3, end: Vector3): NavPath;
|
|
32
|
+
/**
|
|
33
|
+
* Gets the Bounding box extent specified by setDefaultQueryExtent
|
|
34
|
+
*/
|
|
35
|
+
getDefaultQueryExtent(): Vector3;
|
|
36
|
+
/**
|
|
37
|
+
* Sets the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
|
|
38
|
+
* The queries will try to find a solution within those bounds.
|
|
39
|
+
* The default is (1,1,1)
|
|
40
|
+
*/
|
|
41
|
+
setDefaultQueryExtent(extent: Vector3): void;
|
|
42
|
+
/**
|
|
43
|
+
* Destroys the NavMeshQuery instance
|
|
44
|
+
*/
|
|
45
|
+
destroy(): void;
|
|
46
|
+
}
|
package/dist/nav-mesh.d.ts
CHANGED
|
@@ -1,99 +1,48 @@
|
|
|
1
1
|
import type R from '@recast-navigation/wasm';
|
|
2
|
-
import { Crowd } from './crowd';
|
|
3
2
|
import { DebugNavMesh } from './debug-nav-mesh';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
cs: number;
|
|
19
|
-
/**
|
|
20
|
-
* @default 0.2
|
|
21
|
-
*/
|
|
22
|
-
ch: number;
|
|
23
|
-
/**
|
|
24
|
-
* @default 60
|
|
25
|
-
*/
|
|
26
|
-
walkableSlopeAngle: number;
|
|
27
|
-
/**
|
|
28
|
-
* @default 2
|
|
29
|
-
*/
|
|
30
|
-
walkableHeight: number;
|
|
31
|
-
/**
|
|
32
|
-
* @default 2
|
|
33
|
-
*/
|
|
34
|
-
walkableClimb: number;
|
|
35
|
-
/**
|
|
36
|
-
* @default 0.5
|
|
37
|
-
*/
|
|
38
|
-
walkableRadius: number;
|
|
39
|
-
/**
|
|
40
|
-
* @default 12
|
|
41
|
-
*/
|
|
42
|
-
maxEdgeLen: number;
|
|
43
|
-
/**
|
|
44
|
-
* @default 1.3
|
|
45
|
-
*/
|
|
46
|
-
maxSimplificationError: number;
|
|
47
|
-
/**
|
|
48
|
-
* @default 8
|
|
49
|
-
*/
|
|
50
|
-
minRegionArea: number;
|
|
3
|
+
export declare type NavMeshParams = {
|
|
4
|
+
orig: number[];
|
|
5
|
+
tileWidth: number;
|
|
6
|
+
tileHeight: number;
|
|
7
|
+
maxTiles: number;
|
|
8
|
+
maxPolys: number;
|
|
9
|
+
};
|
|
10
|
+
export declare type NavMeshAddTileResult = {
|
|
11
|
+
status: number;
|
|
12
|
+
tileRef: number;
|
|
13
|
+
};
|
|
14
|
+
export declare class NavMesh {
|
|
15
|
+
raw: R.NavMesh;
|
|
16
|
+
constructor(raw?: R.NavMesh);
|
|
51
17
|
/**
|
|
52
|
-
*
|
|
18
|
+
* Initializes the NavMesh for use with a single tile.
|
|
19
|
+
* @param data the nav mesh data
|
|
20
|
+
* @param dataSize the size of the nav mesh data
|
|
21
|
+
* @param flags the flags to use when building the nav mesh
|
|
22
|
+
* @returns the status of the operation
|
|
53
23
|
*/
|
|
54
|
-
|
|
24
|
+
initSolo(data: ReadonlyArray<number>, dataSize: number, flags: number): boolean;
|
|
55
25
|
/**
|
|
56
|
-
*
|
|
26
|
+
* Initializes the NavMesh for use with multiple tiles.
|
|
27
|
+
* @param params parameters for the NavMesh
|
|
28
|
+
* @returns the status of the operation
|
|
57
29
|
*/
|
|
58
|
-
|
|
30
|
+
initTiled(params: NavMeshParams): boolean;
|
|
59
31
|
/**
|
|
60
|
-
*
|
|
32
|
+
* Adds a tile to the NavMesh.
|
|
33
|
+
* @param data the nav mesh data
|
|
34
|
+
* @param dataSize the size of the nav mesh data
|
|
35
|
+
* @param flags the flags to use when building the nav mesh
|
|
36
|
+
* @param lastRef
|
|
37
|
+
* @returns the status of the operation and the reference of the added tile
|
|
61
38
|
*/
|
|
62
|
-
|
|
39
|
+
addTile(data: number[], dataSize: number, flags: number, lastRef: number): NavMeshAddTileResult;
|
|
63
40
|
/**
|
|
64
|
-
*
|
|
41
|
+
* Destroys the NavMesh.
|
|
65
42
|
*/
|
|
66
|
-
detailSampleMaxError: number;
|
|
67
|
-
};
|
|
68
|
-
export declare class NavMesh {
|
|
69
|
-
raw: R.NavMesh;
|
|
70
|
-
obstacles: Map<ObstacleRef, Obstacle>;
|
|
71
|
-
constructor();
|
|
72
|
-
update(): void;
|
|
73
43
|
destroy(): void;
|
|
74
|
-
build(positions: ArrayLike<number>, indices: ArrayLike<number>, navMeshConfig?: Partial<NavMeshConfig>): void;
|
|
75
|
-
/**
|
|
76
|
-
* Build the navmesh from a previously saved state using getNavMeshData
|
|
77
|
-
* @param data the Uint8Array returned by `getNavMeshData`
|
|
78
|
-
*/
|
|
79
|
-
buildFromNavMeshData(data: Uint8Array): void;
|
|
80
44
|
/**
|
|
81
|
-
* Returns
|
|
82
|
-
* @returns data the Uint8Array that can be saved and reused
|
|
45
|
+
* Returns a DebugNavMesh that can be used to visualize the NavMesh.
|
|
83
46
|
*/
|
|
84
|
-
getNavMeshData(): Uint8Array;
|
|
85
47
|
getDebugNavMesh(): DebugNavMesh;
|
|
86
|
-
getClosestPoint(position: Vector3): Vector3;
|
|
87
|
-
getRandomPointAround(position: Vector3, radius: number): Vector3;
|
|
88
|
-
moveAlong(position: Vector3, destination: Vector3): Vector3;
|
|
89
|
-
computePath(start: Vector3, end: Vector3): NavPath;
|
|
90
|
-
getDefaultQueryExtent(): Vector3;
|
|
91
|
-
setDefaultQueryExtent(extent: Vector3): void;
|
|
92
|
-
addCylinderObstacle(position: Vector3, radius: number, height: number): CylinderObstacle;
|
|
93
|
-
addBoxObstacle(position: Vector3, extent: Vector3, angle: number): BoxObstacle;
|
|
94
|
-
removeObstacle(obstacle: Obstacle | ObstacleRef): void;
|
|
95
|
-
createCrowd(config: {
|
|
96
|
-
maxAgents: number;
|
|
97
|
-
maxAgentRadius: number;
|
|
98
|
-
}): Crowd;
|
|
99
48
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type R from '@recast-navigation/wasm';
|
|
2
|
+
import { NavMesh } from './nav-mesh';
|
|
3
|
+
import { BoxObstacle, CylinderObstacle, Obstacle, ObstacleRef } from './obstacle';
|
|
4
|
+
import { Vector3 } from './utils';
|
|
5
|
+
export declare type TileCacheParams = {
|
|
6
|
+
orig: ReadonlyArray<number>;
|
|
7
|
+
cs: number;
|
|
8
|
+
ch: number;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
walkableHeight: number;
|
|
12
|
+
walkableRadius: number;
|
|
13
|
+
walkableClimb: number;
|
|
14
|
+
maxSimplificationError: number;
|
|
15
|
+
maxTiles: number;
|
|
16
|
+
maxObstacles: number;
|
|
17
|
+
};
|
|
18
|
+
export declare type TileCacheUpdateResult = {
|
|
19
|
+
status: number;
|
|
20
|
+
upToDate: boolean;
|
|
21
|
+
};
|
|
22
|
+
export declare class TileCache {
|
|
23
|
+
raw: R.TileCache;
|
|
24
|
+
obstacles: Map<ObstacleRef, Obstacle>;
|
|
25
|
+
constructor(raw?: R.TileCache);
|
|
26
|
+
/**
|
|
27
|
+
* Initialises the TileCache
|
|
28
|
+
* @param params
|
|
29
|
+
*/
|
|
30
|
+
init(params: TileCacheParams): void;
|
|
31
|
+
/**
|
|
32
|
+
* Updates the tile cache by rebuilding tiles touched by unfinished obstacle requests.
|
|
33
|
+
* This should be called after adding or removing obstacles.
|
|
34
|
+
*/
|
|
35
|
+
update(navMesh: NavMesh): TileCacheUpdateResult;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a cylinder obstacle and adds it to the navigation mesh.
|
|
38
|
+
*/
|
|
39
|
+
addCylinderObstacle(position: Vector3, radius: number, height: number): CylinderObstacle;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a box obstacle and adds it to the navigation mesh.
|
|
42
|
+
*/
|
|
43
|
+
addBoxObstacle(position: Vector3, extent: Vector3, angle: number): BoxObstacle;
|
|
44
|
+
/**
|
|
45
|
+
* Removes an obstacle from the navigation mesh.
|
|
46
|
+
*/
|
|
47
|
+
removeObstacle(obstacle: Obstacle | ObstacleRef): void;
|
|
48
|
+
}
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"email": "isaac@isaacmason.com",
|
|
7
7
|
"url": "https://isaacmason.com/"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.7",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"homepage": "https://github.com/isaac-mason/recast-navigation-js",
|
|
12
12
|
"bugs": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@babel/core": "^7.18.6",
|
|
29
|
-
"@recast-navigation/wasm": "0.0.
|
|
29
|
+
"@recast-navigation/wasm": "0.0.7",
|
|
30
30
|
"@rollup/plugin-commonjs": "^24.0.1",
|
|
31
31
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
32
32
|
"@rollup/plugin-terser": "^0.4.0",
|