recast-navigation 0.22.0 → 0.24.0

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.
Files changed (2) hide show
  1. package/README.md +30 -14
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -28,6 +28,7 @@ This library provides high level APIs that make it easy to get started creating
28
28
  ## Examples
29
29
 
30
30
  Go to the [examples website](https://recast-navigation-js.isaacmason.com) to see the project in action:
31
+
31
32
  - live: [https://recast-navigation-js.isaacmason.com](https://recast-navigation-js.isaacmason.com).
32
33
  - examples source code: [./packages/recast-navigation/.storybook/stories](./packages/recast-navigation/.storybook/stories).
33
34
 
@@ -161,19 +162,24 @@ import { NavMeshQuery } from 'recast-navigation';
161
162
 
162
163
  const navMeshQuery = new NavMeshQuery({ navMesh });
163
164
 
164
- /* get the closest point on the NavMesh to the given position */
165
+ /* find the closest point on the NavMesh to the given position */
165
166
  const position = { x: 0, y: 0, z: 0 };
166
- navMeshQuery.getClosestPoint(position);
167
+ const { success, status, point, polyRef, isPointOverPoly } =
168
+ navMeshQuery.findClosestPoint(position);
167
169
 
168
170
  /* get a random point around the given position */
169
171
  const radius = 0.5;
170
- navMeshQuery.getRandomPointAround(position, radius);
172
+ const {
173
+ success,
174
+ status,
175
+ randomPolyRef,
176
+ randomPoint: initialAgentPosition,
177
+ } = navMeshQuery.findRandomPointAroundCircle(position, radius);
171
178
 
172
179
  /* compute a straight path between two points */
173
- const path: Vector3[] = navMeshQuery.computePath(
174
- { x: 0, y: 0, z: 0 }, // start position
175
- { x: 2, y: 0, z: 0 } // end position
176
- );
180
+ const start = { x: 0, y: 0, z: 0 };
181
+ const end = { x: 2, y: 0, z: 0 };
182
+ const { success, error, path } = navMeshQuery.computePath(start, end);
177
183
  ```
178
184
 
179
185
  ### Crowds and Agents
@@ -192,10 +198,15 @@ const crowd = new Crowd({ maxAgents, maxAgentRadius, navMesh });
192
198
  Next, create and interface with agents in the crowd.
193
199
 
194
200
  ```ts
195
- const initialAgentPosition = navMeshQuery.getRandomPointAround(
196
- { x: 0, y: 0, z: 0 }, // position
197
- 2 // radius
198
- );
201
+ const position = { x: 0, y: 0, z: 0 };
202
+ const radius = 2;
203
+
204
+ const {
205
+ success,
206
+ status,
207
+ randomPolyRef,
208
+ randomPoint: initialAgentPosition,
209
+ } = navMeshQuery.findRandomPointAroundCircle(position, radius);
199
210
 
200
211
  const agent = crowd.addAgent(initialAgentPosition, {
201
212
  radius: 0.5,
@@ -268,7 +279,7 @@ const { success, navMesh, tileCache } = generateTileCache(positions, indices, {
268
279
  });
269
280
  ```
270
281
 
271
- You can use `addCylinderObstacle`, `addBoxObstacle`, and `removeObstacle` to add and remove obstacles from the TileCache.
282
+ You can use `addCylinderObstacle`, `addBoxObstacle`, and `removeObstacle` to add and remove obstacles from the TileCache.
272
283
 
273
284
  After adding or removing obstacles you can call `tileCache.update(navMesh)` to rebuild navmesh tiles.
274
285
 
@@ -307,7 +318,7 @@ const removeObstacleResult = tileCache.removeObstacle(boxObstacle);
307
318
  tileCache.update(navMesh);
308
319
 
309
320
  // if your obstacle requests affect many tiles, you may need to call update multiple times
310
- const maxTileCacheUpdates = 5
321
+ const maxTileCacheUpdates = 5;
311
322
  for (let i = 0; i < maxTileCacheUpdates; i++) {
312
323
  const { upToDate } = tileCache.update(navMesh);
313
324
  if (upToDate) break;
@@ -409,7 +420,12 @@ console.log(statusToReadableString(status));
409
420
  If you need to work with status codes programmatically, you can use these utilities:
410
421
 
411
422
  ```ts
412
- import { statusSucceed, statusInProgress, statusFailed, statusDetail } from 'recast-navigation';
423
+ import {
424
+ statusSucceed,
425
+ statusInProgress,
426
+ statusFailed,
427
+ statusDetail,
428
+ } from 'recast-navigation';
413
429
 
414
430
  // returns true if the status is a success
415
431
  const succeeded = statusSucceed(status);
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "email": "isaac@isaacmason.com",
19
19
  "url": "https://isaacmason.com/"
20
20
  },
21
- "version": "0.22.0",
21
+ "version": "0.24.0",
22
22
  "license": "MIT",
23
23
  "homepage": "https://github.com/isaac-mason/recast-navigation-js",
24
24
  "bugs": {
@@ -66,9 +66,9 @@
66
66
  "lint": "eslint --ext .ts src"
67
67
  },
68
68
  "dependencies": {
69
- "@recast-navigation/core": "0.22.0",
70
- "@recast-navigation/generators": "0.22.0",
71
- "@recast-navigation/three": "0.22.0"
69
+ "@recast-navigation/core": "0.24.0",
70
+ "@recast-navigation/generators": "0.24.0",
71
+ "@recast-navigation/three": "0.24.0"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@babel/core": "^7.24.4",