recast-navigation 0.31.1 → 0.33.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.
- package/README.md +29 -15
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -375,9 +375,13 @@ If many obstacle requests have been made and you need to avoid reaching the 64 o
|
|
|
375
375
|
```ts
|
|
376
376
|
/* add a Box obstacle to the NavMesh */
|
|
377
377
|
const position = { x: 0, y: 0, z: 0 };
|
|
378
|
-
const
|
|
378
|
+
const halfExtents = { x: 1, y: 1, z: 1 };
|
|
379
379
|
const angle = 0;
|
|
380
|
-
const addBoxObstacleResult = tileCache.addBoxObstacle(
|
|
380
|
+
const addBoxObstacleResult = tileCache.addBoxObstacle(
|
|
381
|
+
position,
|
|
382
|
+
halfExtents,
|
|
383
|
+
angle
|
|
384
|
+
);
|
|
381
385
|
const boxObstacle = addBoxObstacleResult.obstacle;
|
|
382
386
|
|
|
383
387
|
/* add a Cylinder obstacle to the NavMesh */
|
|
@@ -500,7 +504,7 @@ If you need to work with status codes programmatically, you can use these utilit
|
|
|
500
504
|
|
|
501
505
|
```ts
|
|
502
506
|
import {
|
|
503
|
-
|
|
507
|
+
Detour,
|
|
504
508
|
statusSucceed,
|
|
505
509
|
statusInProgress,
|
|
506
510
|
statusFailed,
|
|
@@ -517,15 +521,15 @@ const inProgress = statusInProgress(status);
|
|
|
517
521
|
const failed = statusFailed(status);
|
|
518
522
|
|
|
519
523
|
// get the detail of the status
|
|
520
|
-
const detail =
|
|
521
|
-
//
|
|
522
|
-
//
|
|
523
|
-
//
|
|
524
|
-
//
|
|
525
|
-
//
|
|
526
|
-
//
|
|
527
|
-
//
|
|
528
|
-
//
|
|
524
|
+
const detail = Detour.DT_BUFFER_TOO_SMALL;
|
|
525
|
+
// Detour.DT_WRONG_MAGIC;
|
|
526
|
+
// Detour.DT_WRONG_VERSION;
|
|
527
|
+
// Detour.DT_OUT_OF_MEMORY;
|
|
528
|
+
// Detour.DT_INVALID_PARAM;
|
|
529
|
+
// Detour.DT_BUFFER_TOO_SMALL;
|
|
530
|
+
// Detour.DT_OUT_OF_NODES;
|
|
531
|
+
// Detour.DT_PARTIAL_RESULT;
|
|
532
|
+
// Detour.DT_ALREADY_OCCUPIED;
|
|
529
533
|
|
|
530
534
|
const detail = statusDetail(status, detail);
|
|
531
535
|
```
|
|
@@ -549,18 +553,28 @@ const { navMesh } = importNavMesh(navMeshExport);
|
|
|
549
553
|
To export a TileCache and NavMesh, the usage varies slightly:
|
|
550
554
|
|
|
551
555
|
```ts
|
|
552
|
-
import {
|
|
556
|
+
import { exportTileCache, importTileCache } from 'recast-navigation';
|
|
553
557
|
|
|
554
558
|
/* exporting */
|
|
555
559
|
// pass both the navMesh and the tileCache
|
|
556
|
-
const navMeshExport: Uint8Array =
|
|
560
|
+
const navMeshExport: Uint8Array = exportTileCache(navMesh, tileCache);
|
|
557
561
|
|
|
558
562
|
/* importing */
|
|
559
563
|
// also pass the TileCacheMeshProcess implementation for the tile cache
|
|
560
564
|
// if you used `generateTileCache` and didn't provide one, `createDefaultTileCacheMeshProcess` returns the default TileCacheMeshProcess `generateTileCache` uses
|
|
561
565
|
const tileCacheMeshProcess = createDefaultTileCacheMeshProcess();
|
|
562
566
|
|
|
563
|
-
|
|
567
|
+
// otherwise, you can use your own TileCacheMeshProcess
|
|
568
|
+
const customTileCacheMeshProcess = new TileCacheMeshProcess(
|
|
569
|
+
(navMeshCreateParams, polyAreas, polyFlags) => {
|
|
570
|
+
for (let i = 0; i < navMeshCreateParams.polyCount(); ++i) {
|
|
571
|
+
polyAreas.set(i, 0);
|
|
572
|
+
polyFlags.set(i, 1);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
);
|
|
576
|
+
|
|
577
|
+
const { navMesh, tileCache, allocator, compressor } = importTileCache(
|
|
564
578
|
navMeshExport,
|
|
565
579
|
tileCacheMeshProcess
|
|
566
580
|
);
|
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.
|
|
21
|
+
"version": "0.33.0",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"homepage": "https://github.com/isaac-mason/recast-navigation-js",
|
|
24
24
|
"bugs": {
|
|
@@ -64,18 +64,18 @@
|
|
|
64
64
|
"storybook": "storybook dev -p 6006",
|
|
65
65
|
"build-storybook": "storybook build",
|
|
66
66
|
"test": "tsc && vitest run",
|
|
67
|
-
"lint": "eslint
|
|
67
|
+
"lint": "eslint src"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@recast-navigation/core": "0.
|
|
71
|
-
"@recast-navigation/generators": "0.
|
|
72
|
-
"@recast-navigation/three": "0.
|
|
70
|
+
"@recast-navigation/core": "0.33.0",
|
|
71
|
+
"@recast-navigation/generators": "0.33.0",
|
|
72
|
+
"@recast-navigation/three": "0.33.0"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@babel/core": "^7.24.5",
|
|
76
76
|
"@babel/preset-env": "^7.24.5",
|
|
77
77
|
"@babel/preset-typescript": "^7.24.1",
|
|
78
|
-
"@isaac-mason/eslint-config-typescript": "^0.0.
|
|
78
|
+
"@isaac-mason/eslint-config-typescript": "^0.0.9",
|
|
79
79
|
"@mdx-js/react": "^2.3.0",
|
|
80
80
|
"@pmndrs/assets": "^1.6.0",
|
|
81
81
|
"@react-three/drei": "^9.105.4",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"@types/react-dom": "^18.2.8",
|
|
97
97
|
"@types/three": "^0.163.0",
|
|
98
98
|
"@vitejs/plugin-react": "^4.2.1",
|
|
99
|
-
"eslint": "^
|
|
99
|
+
"eslint": "^9.6.0",
|
|
100
100
|
"leva": "^0.9.35",
|
|
101
101
|
"react": "^18.3.1",
|
|
102
102
|
"react-dom": "^18.2.0",
|