A React Three Fiber application that demonstrates NavMesh-based pathfinding for NPCs in a 3D environment using three-pathfinding.
- 3D environment with React Three Fiber
- Navigation mesh (NavMesh) for pathfinding
- NPC movement simulation using three-pathfinding
- Orbit controls for camera manipulation
- Debug mode to visualize the navigation mesh and paths
- React
- Vite
- Three.js
- React Three Fiber (@react-three/fiber)
- React Three Drei (@react-three/drei)
- three-pathfinding
- Node.js (v14 or later)
- npm or yarn
# Clone the repository
git clone https://github.com/yourusername/walkable.git
cd walkable
# Install dependencies
npm install# Start the development server
npm run devOpen your browser and navigate to http://localhost:5173 to see the application.
# Build the application
npm run build/src
/components
/navigation
NavMesh.jsx # Navigation mesh implementation
NPC.jsx # NPC character with pathfinding
/scene
Model.jsx # 3D model component
Scene.jsx # Main 3D scene setup
UI.jsx # User interface overlay
App.jsx # Main application component
main.jsx # Entry point
- Use the orbit controls to navigate the 3D environment (mouse drag to rotate, scroll to zoom)
- Toggle the debug mode to visualize the navigation mesh and pathfinding
- NPCs will automatically navigate around obstacles using the navigation mesh
- Replace the placeholder model in
Model.jsxwith your own 3D models - Modify the navigation mesh in
NavMesh.jsxto match your environment - Adjust NPC behavior in
NPC.jsxto create different movement patterns
MIT
If you are developing a production application, we recommend using TypeScript and enable type-aware lint rules. Check out the TS template to integrate TypeScript and typescript-eslint in your project.