Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information. Update changelog for v4.2.0 Sep 23, 2018
index.js [universal-controls] Support constraint to nav mesh. Nov 25, 2017
nav-agent.js Update changelog for v4.2.0 Sep 23, 2018
nav-mesh.js [nav] nav-mesh should listen for 'object3dset'. Sep 23, 2018
system.js Update three-pathfinding to 0.7.0 Aug 31, 2018


Set of components for pathfinding along a nav mesh, using PatrolJS.

  • nav-mesh: Assigns model from the current entity as a navigation mesh for the pathfinding system. A navigation mesh is not the same as visible terrain geometry. See below.
  • nav-agent: Adds behaviors to an entity allowing it to navigate to any reachable destination along the nav mesh.

Creating a nav mesh

Blog post.

Setting a destination

Controllers can be activated to begin moving their entity toward a destination. Example:

<!-- NPC -->
<a-entity id="npc"
          nav-agent="speed: 1.5"></a-entity>

<!-- Nav Mesh -->
<a-entity gltf-model="navmesh.gltf"

<!-- Scene -->
<a-entity gltf-model="scene.gltf"></a-entity>
var npcEl = document.querySelector('#npc');
npcEl.setAttribute('nav-agent', {
  active: true,
  destination: e.detail.intersection.point


The nav-agent component will emit two events:

  • navigation-start: Entity beginning travel to a destination.
  • navigation-end: Entity has reached destination.

Important notes

This implementation is meant as a proof-of-concept, and doesn't have all the features and polish of game engine navigation. Currently missing:

  • Smooth rotation when navigating around corners.
  • Dynamic obstacles, like mobile props and NPCs.
  • Multiple nav meshes and/or levels.
You can’t perform that action at this time.