@recast-navigation/core 0.0.4 → 0.0.6

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.
@@ -5,62 +5,97 @@ import type { BoxObstacle, CylinderObstacle, Obstacle, ObstacleRef } from './obs
5
5
  import type { NavPath, Vector3 } from './utils';
6
6
  export declare type NavMeshConfig = {
7
7
  /**
8
+ * The size of the non-navigable border around the heightfield.
9
+ * [Limit: >=0] [Units: vx]
8
10
  * @default 0
9
11
  */
10
12
  borderSize: number;
11
13
  /**
14
+ * The width/height size of tile's on the xz-plane.
15
+ * [Limit: >= 0] [Units: vx]
16
+ *
17
+ * If tileSize is provided, a tiled navmesh will be created.
18
+ * If tileSize is not provided, or is set to zero, a solo navmesh will be created.
19
+ *
20
+ * To use obstacles, a tiled navmesh must be generated.
12
21
  * @default 0
13
22
  */
14
23
  tileSize: number;
15
24
  /**
25
+ * The xz-plane cell size to use for fields.
26
+ * [Limit: > 0] [Units: wu]
16
27
  * @default 0.2
17
28
  */
18
29
  cs: number;
19
30
  /**
31
+ * The y-axis cell size to use for fields.
32
+ * Limit: > 0] [Units: wu]
20
33
  * @default 0.2
21
34
  */
22
35
  ch: number;
23
36
  /**
37
+ * The maximum slope that is considered walkable.
38
+ * [Limits: 0 <= value < 90] [Units: Degrees]
24
39
  * @default 60
25
40
  */
26
41
  walkableSlopeAngle: number;
27
42
  /**
43
+ * Minimum floor to 'ceiling' height that will still allow the floor area to be considered walkable.
44
+ * [Limit: >= 3] [Units: vx]
28
45
  * @default 2
29
46
  */
30
47
  walkableHeight: number;
31
48
  /**
49
+ * Maximum ledge height that is considered to still be traversable.
50
+ * [Limit: >=0] [Units: vx]
32
51
  * @default 2
33
52
  */
34
53
  walkableClimb: number;
35
54
  /**
55
+ * The distance to erode/shrink the walkable area of the heightfield away from obstructions.
56
+ * [Limit: >=0] [Units: vx]
36
57
  * @default 0.5
37
58
  */
38
59
  walkableRadius: number;
39
60
  /**
61
+ * The maximum allowed length for contour edges along the border of the mesh.
62
+ * [Limit: >=0] [Units: vx]
40
63
  * @default 12
41
64
  */
42
65
  maxEdgeLen: number;
43
66
  /**
67
+ * The maximum distance a simplfied contour's border edges should deviate the original raw contour.
68
+ * [Limit: >=0] [Units: vx]
44
69
  * @default 1.3
45
70
  */
46
71
  maxSimplificationError: number;
47
72
  /**
73
+ * The minimum number of cells allowed to form isolated island areas.
74
+ * [Limit: >=0] [Units: vx]
48
75
  * @default 8
49
76
  */
50
77
  minRegionArea: number;
51
78
  /**
79
+ * Any regions with a span count smaller than this value will, if possible, be merged with larger regions.
80
+ * [Limit: >=0] [Units: vx]
52
81
  * @default 20
53
82
  */
54
83
  mergeRegionArea: number;
55
84
  /**
85
+ * The maximum number of vertices allowed for polygons generated during the be merged with larger regions.
86
+ * [Limit: >=0] [Units: vx]
56
87
  * @default 6
57
88
  */
58
89
  maxVertsPerPoly: number;
59
90
  /**
91
+ * Sets the sampling distance to use when generating the detail mesh. (For height detail only.)
92
+ * [Limits: 0 or >= 0.9] [Units: wu]
60
93
  * @default 6
61
94
  */
62
95
  detailSampleDist: number;
63
96
  /**
97
+ * The maximum distance the detail mesh surface should deviate from heightfield data. (For height detail only.)
98
+ * [Limit: >=0] [Units: wu]
64
99
  * @default 1
65
100
  */
66
101
  detailSampleMaxError: number;
@@ -69,8 +104,21 @@ export declare class NavMesh {
69
104
  raw: R.NavMesh;
70
105
  obstacles: Map<ObstacleRef, Obstacle>;
71
106
  constructor();
107
+ /**
108
+ * Updates the NavMesh tile cache by rebuilding tiles touched by unfinished obstacle requests.
109
+ * This should be called after adding or removing obstacles.
110
+ */
72
111
  update(): void;
112
+ /**
113
+ * Destroys the NavMesh.
114
+ */
73
115
  destroy(): void;
116
+ /**
117
+ * Builds a NavMesh from the given positions and indices.
118
+ * @param positions a flat array of positions
119
+ * @param indices a flat array of indices
120
+ * @param navMeshConfig optional configuration for the NavMesh
121
+ */
74
122
  build(positions: ArrayLike<number>, indices: ArrayLike<number>, navMeshConfig?: Partial<NavMeshConfig>): void;
75
123
  /**
76
124
  * Build the navmesh from a previously saved state using getNavMeshData
@@ -82,15 +130,49 @@ export declare class NavMesh {
82
130
  * @returns data the Uint8Array that can be saved and reused
83
131
  */
84
132
  getNavMeshData(): Uint8Array;
133
+ /**
134
+ * Returns a DebugNavMesh that can be used to visualize the NavMesh.
135
+ */
85
136
  getDebugNavMesh(): DebugNavMesh;
137
+ /**
138
+ * Returns the closest point on the NavMesh to the given position.
139
+ */
86
140
  getClosestPoint(position: Vector3): Vector3;
141
+ /**
142
+ * Returns a random point on the NavMesh within the given radius of the given position.
143
+ */
87
144
  getRandomPointAround(position: Vector3, radius: number): Vector3;
145
+ /**
146
+ * Compute the final position from a segment made of destination-position
147
+ */
88
148
  moveAlong(position: Vector3, destination: Vector3): Vector3;
149
+ /**
150
+ * Finds a path from the start position to the end position.
151
+ *
152
+ * @returns an array of Vector3 positions that make up the path, or an empty array if no path was found.
153
+ */
89
154
  computePath(start: Vector3, end: Vector3): NavPath;
155
+ /**
156
+ * Gets the Bounding box extent specified by setDefaultQueryExtent
157
+ */
90
158
  getDefaultQueryExtent(): Vector3;
159
+ /**
160
+ * Sets the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
161
+ * The queries will try to find a solution within those bounds.
162
+ * The default is (1,1,1)
163
+ */
91
164
  setDefaultQueryExtent(extent: Vector3): void;
165
+ /**
166
+ * Creates a cylinder obstacle and adds it to the navigation mesh.
167
+ */
92
168
  addCylinderObstacle(position: Vector3, radius: number, height: number): CylinderObstacle;
169
+ /**
170
+ * Creates a box obstacle and adds it to the navigation mesh.
171
+ */
93
172
  addBoxObstacle(position: Vector3, extent: Vector3, angle: number): BoxObstacle;
173
+ /**
174
+ * Removes an obstacle from the navigation mesh.
175
+ */
94
176
  removeObstacle(obstacle: Obstacle | ObstacleRef): void;
95
177
  createCrowd(config: {
96
178
  maxAgents: number;
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.4",
9
+ "version": "0.0.6",
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.4",
29
+ "@recast-navigation/wasm": "0.0.6",
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",