title: Is there a way to get the exact point inside navmesh so the pathfinder can work properly?
body: <p>I am making a first person shooter in Three.js and I wanted to use <a href="https://github.com/donmccurdy/three-pathfinding" rel="nofollow noreferrer">Don McCurdy's pathfinding algorithm</a> for my enemy AI. For the navmesh I followed <a href="https://www.youtube.com/watch?v=3CYljFpF4ds&amp;list=PLFky-gauhF47XkxyjKuVaetZyt02PMujv&amp;ab_channel=NikLever" rel="nofollow noreferrer">Nik Lever's Three.JS Pathfinding Tutorial</a>. In order to use the pathfinder, both the player and the enemies need to be on the surface of the navmesh. The problem is that since the navmesh is slightly off the ground (IDK how to get it on the same elevation as the level) and I want the player to be able to jump, I can't have them simply stick to the navmesh and offset the models. I tried to fix it by raycasting from the player/enemy to the navmesh and using the intersection point, but because of floating point arithmetic the intersection point is always slightly off.</p>
  <p>There is a lot of code in my project, so I'm only sharing the troubling bits. If more code is needed, I will add it.</p>
  <hr>
  <p><strong>Entity.js</strong></p>
  <p>rayCaster is a globally scoped <a href="https://threejs.org/docs/index.html?q=rayc#api/en/core/Raycaster" rel="nofollow noreferrer">Three.js Raycaster</a></p>
  <pre><code>update(map, navmesh) {
    // ...some code...
    rayCaster.set(new THREE.Vector3(this.pos.x, this.pos.y + 10, this.pos.z), new THREE.Vector3(0, -1, 0));
    var hits = rayCaster.intersectObject(navMesh);
    if(hits &amp;&amp; hits[0]) this.point = hits[0].point;
  }
  </code></pre>
  <hr>
  <p><strong>Game.js</strong></p>
  <pre><code>this.pathfinder = new Pathfinding();
  this.pathfinder.setZoneData(&quot;lvl1&quot;, Pathfinding.createZone(this.navmesh.geometry, 3));
  
  update() {
    // ...more code...
    for(var i = this.enemies.length - 1; i &gt;= 0; i--) {
      var group = this.pathfinder.getGroup(&quot;lvl1&quot;, this.enemies[i].point), path = 0;
      if(group != null &amp;&amp; group != undefined) path = this.pathfinder.findPath(this.enemies[i].point, player.point, &quot;lvl1&quot;, group);
      // Path is always null
      this.zombies[i].update(this.map, this.navmesh);
    }
  }
  </code></pre>