donmccurdy / three-pathfinding

Navigation mesh utilities for three.js, based on PatrolJS.
https://three-pathfinding.donmccurdy.com/
MIT License
1.23k stars 135 forks source link

How to export navmesh to make sure zone's groups length = 1 #142

Open yaoyutian opened 2 years ago

yaoyutian commented 2 years ago

After Pathfinding.createZone ,zone's groups length greater then 1; while start position and end position in different group, findPath Failed! after reading src code ,i still can't figure out why a simple mesh atfer createzone ,get multiple groups. can anyone help! how do I need to do the exportation of nav mesh , can make zone group's length =1?

截屏2022-03-30 下午8 49 58 截屏2022-03-30 下午8 52 30

mesh file (change Filename Extension from txt to glb) 3-3.txt

donmccurdy commented 2 years ago

The mesh topology needs to be very clean to be used as a navmesh. Projects like 'recast' (previously available in Blender) did this automatically, but it's necessary if you're building the navmesh yourself too. Doing a 'merge by distance' in Blender might help, try the file below?

navmesh.glb.zip

It's also generally a good thing if the navmesh has roughly similar sizes of triangles, long/thin triangles may cause weird pathfinding choices.