Lightweight representation of a Polygon as a series of points.
This parses a world that is a uniform grid into convex polygons (specifically rectangles) that can be used for building a navmesh. This is designed mainly for parsing tilemaps into polygons. The functions takes a 2D array that indicates which tiles are walkable and which aren't. The function returns PolyPoint[] that can be used to construct a NavMesh.
Notes:
2D array of any type.
The width of each tile in the grid.
The height of each tile in the grid.
Function that is used to test if a specific location in the map is walkable. Defaults to assuming "truthy" means walkable.
Amount to "shrink" the mesh away from the tiles. This adds more polygons to the generated mesh, but can be helpful for preventing agents from getting caught on edges. This supports values between 0 and tileWidth/tileHeight (whichever dimension is smaller).
Generated using TypeDoc
navmesh
is the core logic package. It is game-engine agnostic, usable outside of Phaser.