Original:
Slightly-cleaned:
This playground demonstrates a first attempt at getting the Yuka.js NavMesh class working on a non-flat 3d terrain. In this example the terrain being used is the surface of a tree-trunk and it’s branches.
You’ll notice in the code, there’s a function called connectNodes (being used at lines 108-128), and it is used to literally patch the navMesh.graph with the missing graph edges necessary to allow navigation from any of the branches back to the main tree-trunk.
Currently the best navigation is achieved by first selecting a point on the surface of the tree trunk near the branch you want to travel to, allow the cone to travel to that position first and then click somewhere on the branch. Otherwise the path generator is prone to generating unrealistic paths.
I realize this is pretty hacky, but you’ve gotta start somewhere! I’m also really hoping that people smarter than me will chime in
I wanted to note that I borrowed a bunch of code from @labris/@roland 's examples, it was extremely helpful.