# donmccurdy/three-pathfinding architecture

> Architecture diagram of the GitHub repository donmccurdy/three-pathfinding, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/donmccurdy/three-pathfinding
- Repository: https://github.com/donmccurdy/three-pathfinding

## Overview

three-pathfinding is a Three.js navigation-mesh runtime: application code supplies BufferGeometry, builds and registers a zone, then queries groups and paths or clamps movement. Zone construction turns mesh triangles into connected polygon groups; A* finds a polygon corridor and the funnel channel converts it to waypoints. A separate helper renders debugging markers. The README also describes drag-and-drop and teleport demos. Demo wiring is not established by the sampled source, so those links to the library are omitted.

Main entry points: [`src/Pathfinding.js`](https://github.com/donmccurdy/three-pathfinding/blob/main/src/Pathfinding.js) (Pathfinding API), [`src/Builder.js`](https://github.com/donmccurdy/three-pathfinding/blob/main/src/Builder.js) (Zone builder), [`src/Utils.js`](https://github.com/donmccurdy/three-pathfinding/blob/main/src/Utils.js) (Geometry utilities), [`src/AStar.js`](https://github.com/donmccurdy/three-pathfinding/blob/main/src/AStar.js) (A* search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mesh["Mesh preparation"]
  node_zonebuilder["Zone builder<br/>[Builder.js]"]
  node_utils["Geometry utilities<br/>[Utils.js]"]
end

subgraph group_runtime["Navigation runtime"]
  node_pathfinding["Pathfinding API<br/>[Pathfinding.js]"]
  node_astar["A* search<br/>[AStar.js]"]
  node_heap["Binary heap<br/>[BinaryHeap.js]"]
  node_channel["Funnel channel<br/>[Channel.js]"]
  node_zone["Zone data"]
end

subgraph group_debug["Debug visualization"]
  node_helper["Debug helper"]
end

subgraph group_demos["Examples"]
  node_dragdrop["Drag-and-drop demo<br/>[index.html]"]
  node_teleport["Teleport demo<br/>[teleport.html]"]
end

node_app(("Application"))
node_geometry["Navmesh geometry"]
node_result["Path or step"]
node_three["Three.js"]

node_app -->|"loads"| node_geometry
node_app -->|"calls"| node_pathfinding
node_pathfinding -->|"builds zone"| node_zonebuilder
node_zonebuilder -->|"reads"| node_geometry
node_zonebuilder -->|"welds vertices"| node_utils
node_zonebuilder -->|"creates"| node_zone
node_app -->|"registers zone"| node_pathfinding
node_pathfinding -->|"stores and reads"| node_zone
node_pathfinding -->|"queries geometry"| node_utils
node_pathfinding -->|"searches corridor"| node_astar
node_astar -->|"orders nodes"| node_heap
node_astar -->|"scores distance"| node_utils
node_pathfinding -->|"pulls funnel"| node_channel
node_channel -->|"tests geometry"| node_utils
node_pathfinding -->|"returns path or step"| node_result
node_app -->|"updates markers"| node_helper
node_helper -->|"creates scene objects"| node_three
node_zonebuilder -->|"uses vectors"| node_three
node_pathfinding -->|"uses geometry types"| node_three
node_app -->|"views"| node_dragdrop
node_app -->|"views"| node_teleport

click node_pathfinding "https://github.com/donmccurdy/three-pathfinding/blob/main/src/Pathfinding.js"
click node_zonebuilder "https://github.com/donmccurdy/three-pathfinding/blob/main/src/Builder.js"
click node_utils "https://github.com/donmccurdy/three-pathfinding/blob/main/src/Utils.js"
click node_astar "https://github.com/donmccurdy/three-pathfinding/blob/main/src/AStar.js"
click node_heap "https://github.com/donmccurdy/three-pathfinding/blob/main/src/BinaryHeap.js"
click node_channel "https://github.com/donmccurdy/three-pathfinding/blob/main/src/Channel.js"
click node_helper "https://github.com/donmccurdy/three-pathfinding/blob/main/src/PathfindingHelper.js"
click node_dragdrop "https://github.com/donmccurdy/three-pathfinding/blob/main/demo/index.html"
click node_teleport "https://github.com/donmccurdy/three-pathfinding/blob/main/demo/teleport.html"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_zonebuilder,node_utils toneBlue
class node_pathfinding,node_astar,node_heap,node_channel,node_zone toneAmber
class node_helper toneMint
class node_dragdrop,node_teleport toneRose
class node_app,node_geometry,node_result,node_three toneIndigo
```

## Components

### Mesh preparation

- [Zone builder](https://github.com/donmccurdy/three-pathfinding/blob/main/src/Builder.js): `src/Builder.js`
- [Geometry utilities](https://github.com/donmccurdy/three-pathfinding/blob/main/src/Utils.js): `src/Utils.js`

### Navigation runtime

- [Pathfinding API](https://github.com/donmccurdy/three-pathfinding/blob/main/src/Pathfinding.js): `src/Pathfinding.js`
- [A* search](https://github.com/donmccurdy/three-pathfinding/blob/main/src/AStar.js): `src/AStar.js`
- [Binary heap](https://github.com/donmccurdy/three-pathfinding/blob/main/src/BinaryHeap.js): `src/BinaryHeap.js`
- [Funnel channel](https://github.com/donmccurdy/three-pathfinding/blob/main/src/Channel.js): `src/Channel.js`
- **Zone data**

### Debug visualization

- [Debug helper](https://github.com/donmccurdy/three-pathfinding/blob/main/src/PathfindingHelper.js): `src/PathfindingHelper.js`

### Examples

- [Drag-and-drop demo](https://github.com/donmccurdy/three-pathfinding/blob/main/demo/index.html): `demo/index.html`
- [Teleport demo](https://github.com/donmccurdy/three-pathfinding/blob/main/demo/teleport.html): `demo/teleport.html`

### Other components

- **Application**
- **Navmesh geometry**
- **Path or step**
- **Three.js**

## Connections

- Application → Navmesh geometry: loads
- Application → Pathfinding API: calls
- Pathfinding API → Zone builder: builds zone
- Zone builder → Navmesh geometry: reads
- Zone builder → Geometry utilities: welds vertices
- Zone builder → Zone data: creates
- Application → Pathfinding API: registers zone
- Pathfinding API → Zone data: stores and reads
- Pathfinding API → Geometry utilities: queries geometry
- Pathfinding API → A* search: searches corridor
- A* search → Binary heap: orders nodes
- A* search → Geometry utilities: scores distance
- Pathfinding API → Funnel channel: pulls funnel
- Funnel channel → Geometry utilities: tests geometry
- Pathfinding API → Path or step: returns path or step
- Application → Debug helper: updates markers
- Debug helper → Three.js: creates scene objects
- Zone builder → Three.js: uses vectors
- Pathfinding API → Three.js: uses geometry types
- Application → Drag-and-drop demo: views
- Application → Teleport demo: views
