recast-navigation-js is a WebAssembly port of the Recast and Detour libraries. Recast is a state of the art navigation mesh construction toolset for games, and Detour is a path-finding and spatial reasoning toolkit.
This library provides high level APIs that make it easy to get started creating navigation meshes, querying them, and simulating crowds. It also provides lower-level APIs that give you fine-grained control over the navmesh generation process.
Installation
recast-navigation-js ships as ECMAScript modules, and is compatible with Node.js and browser environments.
NPM
npm install recast-navigation
If you are using Vite, you may need to opt recast-navigation out of pre-bundling:
export default defineConfig(() => ({
optimizeDeps: { exclude: ['recast-navigation'] }
)}
If you are planning to use the library with three.js, install the @recast-navigation/three package for three.js helpers:
npm install @recast-navigation/three
If you are planning to use the library with playcanvas, install the @recast-navigation/playcanvas package for playcanvas helpers:
npm install @recast-navigation/playcanvas
Usage without bundlers
You can use import maps to use the library without a bundler:
<script type="importmap">
{
"imports": {
// required
"@recast-navigation/core": "https://unpkg.com/@recast-navigation/core@0.35.0/dist/index.mjs",
"@recast-navigation/wasm": "https://unpkg.com/@recast-navigation/wasm@0.35.0/dist/recast-navigation.wasm-compat.js",
// easy to use generators
"@recast-navigation/generators": "https://unpkg.com/@recast-navigation/generators@0.35.0/dist/index.mjs",
// optional integrations
"@recast-navigation/three": "https://unpkg.com/@recast-navigation/three@0.35.0/dist/index.mjs",
"@recast-navigation/playcanvas": "https://unpkg.com/@recast-navigation/three@0.35.0/dist/index.mjs",
}
}
</script>
<script type="module">
import { init } from '@recast-navigation/core';
await init();
</script>