recast-navigation 0.3.0 → 0.4.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 +34 -14
- package/package.json +27 -25
package/README.md
CHANGED
|
@@ -40,9 +40,7 @@ await init();
|
|
|
40
40
|
### Creating a NavMesh
|
|
41
41
|
|
|
42
42
|
```ts
|
|
43
|
-
import {
|
|
44
|
-
|
|
45
|
-
const navMeshGenerator = new NavMeshGenerator();
|
|
43
|
+
import { generateSoloNavMesh } from 'recast-navigation';
|
|
46
44
|
|
|
47
45
|
const positions = [
|
|
48
46
|
/* flat array of positions */
|
|
@@ -57,7 +55,7 @@ const navMeshConfig = {
|
|
|
57
55
|
/* ... */
|
|
58
56
|
};
|
|
59
57
|
|
|
60
|
-
const { navMesh } =
|
|
58
|
+
const { success, navMesh } = generateSoloNavMesh(
|
|
61
59
|
positions,
|
|
62
60
|
indices,
|
|
63
61
|
navMeshConfig
|
|
@@ -87,11 +85,17 @@ Recast Navigation supports creating Box and Cylinder obstacles.
|
|
|
87
85
|
Note that in order to use obstacles, you must create a tiled NavMesh.
|
|
88
86
|
|
|
89
87
|
```ts
|
|
88
|
+
import { generateTiledNavMesh } from 'recast-navigation';
|
|
89
|
+
|
|
90
90
|
/* create a tiled NavMesh */
|
|
91
|
-
const { navMesh, tileCache } =
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
const { success, navMesh, tileCache } = generateTiledNavMesh(
|
|
92
|
+
positions,
|
|
93
|
+
indices,
|
|
94
|
+
{
|
|
95
|
+
/* ... */
|
|
96
|
+
tileSize: 16,
|
|
97
|
+
}
|
|
98
|
+
);
|
|
95
99
|
|
|
96
100
|
/* add a Box obstacle to the NavMesh */
|
|
97
101
|
const position = { x: 0, y: 0, z: 0 };
|
|
@@ -207,17 +211,33 @@ If you are using `@recast-navigation/three`, you can use `NavMeshHelper` and `Cr
|
|
|
207
211
|
A NavMesh and TileCache can be exported and imported as a Uint8Array.
|
|
208
212
|
|
|
209
213
|
```ts
|
|
210
|
-
|
|
211
|
-
const navMeshExporter = new NavMeshExporter();
|
|
214
|
+
import { exportNavMesh, importNavMesh } from 'recast-navigation';
|
|
212
215
|
|
|
213
|
-
|
|
216
|
+
/* exporting */
|
|
217
|
+
const navMeshExport: Uint8Array = exportNavMesh(
|
|
214
218
|
navMesh,
|
|
215
219
|
tileCache // optional
|
|
216
220
|
);
|
|
217
221
|
|
|
218
222
|
/* importing */
|
|
219
|
-
const
|
|
223
|
+
const { navMesh, tileCache } = importNavMesh(navMeshExport);
|
|
224
|
+
```
|
|
220
225
|
|
|
221
|
-
|
|
222
|
-
|
|
226
|
+
### Escape Hatches
|
|
227
|
+
|
|
228
|
+
This library provides a higher level api over Recast, but also exposes a `Raw` api that aims to match the recast and detour libraries as much as possible.
|
|
229
|
+
|
|
230
|
+
This functionality is experimental, and not all of recast is exposed yet. You will need to have familiarity with the recast and detour c++ libraries, and you may need to submit an issue or a PR if something you need is not exposed yet.
|
|
231
|
+
|
|
232
|
+
Auto-generated documentation can be found here: https://docs.recast-navigation-js.isaacmason.com/variables/index.Raw.html
|
|
233
|
+
|
|
234
|
+
```ts
|
|
235
|
+
import { Raw } from 'recast-navigation';
|
|
236
|
+
|
|
237
|
+
const navMeshData = Raw.DetourNavMeshBuilder.createNavMeshData(/* ... */);
|
|
223
238
|
```
|
|
239
|
+
|
|
240
|
+
The solo and tiled nav mesh generators in this library are adaptations of the `RecastDemo` examples: https://github.com/isaac-mason/recastnavigation/blob/main/RecastDemo/Source/Sample_SoloMesh.cpp
|
|
241
|
+
|
|
242
|
+
You can use the solo and tiled nav mesh generators in this library as the basis of a nav mesh generator suiting your requirements. See: https://github.com/isaac-mason/recast-navigation-js/tree/main/packages/recast-navigation-core/src/generators
|
|
243
|
+
|
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.4.0",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"homepage": "https://github.com/isaac-mason/recast-navigation-js",
|
|
24
24
|
"bugs": {
|
|
@@ -44,48 +44,50 @@
|
|
|
44
44
|
"README.md"
|
|
45
45
|
],
|
|
46
46
|
"scripts": {
|
|
47
|
-
"
|
|
47
|
+
"clean": "(rm index.js index.d.ts three.js three.d.ts || true)",
|
|
48
|
+
"build": "yarn clean && rollup --config rollup.config.js --bundleConfigAsCjs",
|
|
48
49
|
"storybook": "storybook dev -p 6006",
|
|
49
50
|
"build-storybook": "storybook build"
|
|
50
51
|
},
|
|
51
52
|
"dependencies": {
|
|
52
|
-
"@recast-navigation/core": "0.
|
|
53
|
-
"@recast-navigation/three": "0.
|
|
53
|
+
"@recast-navigation/core": "0.4.0",
|
|
54
|
+
"@recast-navigation/three": "0.4.0"
|
|
54
55
|
},
|
|
55
56
|
"peerDependencies": {
|
|
56
|
-
"three": "^0.
|
|
57
|
+
"three": "^0.155.0"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
|
-
"@babel/core": "^7.
|
|
60
|
-
"@mdx-js/react": "^
|
|
61
|
-
"@
|
|
62
|
-
"@react-three/
|
|
60
|
+
"@babel/core": "^7.22.5",
|
|
61
|
+
"@mdx-js/react": "^2.3.0",
|
|
62
|
+
"@pmndrs/assets": "^1.6.0",
|
|
63
|
+
"@react-three/csg": "^3.0.0",
|
|
64
|
+
"@react-three/drei": "^9.78.2",
|
|
63
65
|
"@react-three/fiber": "^8.12.0",
|
|
64
66
|
"@rollup/plugin-commonjs": "^24.0.1",
|
|
65
67
|
"@rollup/plugin-multi-entry": "^6.0.0",
|
|
66
68
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
67
|
-
"@rollup/plugin-terser": "^0.4.
|
|
68
|
-
"@rollup/plugin-typescript": "^11.
|
|
69
|
-
"@storybook/addon-actions": "^7.
|
|
70
|
-
"@storybook/addon-essentials": "^7.
|
|
71
|
-
"@storybook/addon-interactions": "^7.
|
|
72
|
-
"@storybook/addon-links": "^7.
|
|
73
|
-
"@storybook/addon-mdx-gfm": "^7.
|
|
74
|
-
"@storybook/react": "^7.
|
|
75
|
-
"@storybook/react-vite": "^7.
|
|
69
|
+
"@rollup/plugin-terser": "^0.4.3",
|
|
70
|
+
"@rollup/plugin-typescript": "^11.1.2",
|
|
71
|
+
"@storybook/addon-actions": "^7.3.2",
|
|
72
|
+
"@storybook/addon-essentials": "^7.3.2",
|
|
73
|
+
"@storybook/addon-interactions": "^7.3.2",
|
|
74
|
+
"@storybook/addon-links": "^7.3.2",
|
|
75
|
+
"@storybook/addon-mdx-gfm": "^7.3.2",
|
|
76
|
+
"@storybook/react": "^7.3.2",
|
|
77
|
+
"@storybook/react-vite": "^7.3.2",
|
|
76
78
|
"@types/react": "^18.2.11",
|
|
77
|
-
"@types/react-dom": "^18.
|
|
78
|
-
"@types/three": "^0.
|
|
79
|
+
"@types/react-dom": "^18.2.7",
|
|
80
|
+
"@types/three": "^0.155.0",
|
|
79
81
|
"babel-loader": "^8.3.0",
|
|
80
|
-
"leva": "^0.9.
|
|
82
|
+
"leva": "^0.9.35",
|
|
81
83
|
"react": "^18.2.0",
|
|
82
84
|
"react-dom": "^18.2.0",
|
|
83
|
-
"rollup": "^3.
|
|
85
|
+
"rollup": "^3.26.3",
|
|
84
86
|
"rollup-plugin-copy": "^3.4.0",
|
|
85
87
|
"rollup-plugin-filesize": "^10.0.0",
|
|
86
|
-
"storybook": "^7.
|
|
87
|
-
"suspend-react": "^0.
|
|
88
|
-
"three": "^0.
|
|
88
|
+
"storybook": "^7.3.2",
|
|
89
|
+
"suspend-react": "^0.1.3",
|
|
90
|
+
"three": "^0.155.0",
|
|
89
91
|
"three-pathfinding": "^1.2.0"
|
|
90
92
|
},
|
|
91
93
|
"packageManager": "yarn@3.2.2"
|