A browser-based single-page application inspired by Mini Metro, built with TypeScript, React, MapLibre GL, and Three.js.
- Interactive Map: Place stations by clicking on the map
- Route Creation: Connect stations to create colored transit routes
- Animated Trains: Trains move smoothly along routes using Three.js animations
- Passenger Simulation: Passengers spawn at stations and travel to destinations
- Real-time Gameplay: Dynamic passenger generation and train movement
- Frontend: TypeScript + React
- Mapping:
@mapcomponents/react-maplibrefor base map rendering - 3D Graphics: Three.js for custom animated layers
- Build Tool: Vite
- Testing: Jest + React Testing Library
- CI/CD: GitHub Actions + GitHub Pages
- Node.js 20+
- npm
# Clone the repository
git clone <repository-url>
cd metromesh
# Install dependencies
npm install
# Start development server
npm run devnpm run dev- Start development servernpm run build- Build for productionnpm run preview- Preview production buildnpm run lint- Run ESLintnpm test- Run testsnpm run test:watch- Run tests in watch mode
- Place Stations: Click anywhere on the map to place circular station nodes
- Create Routes:
- Select 2 or more stations using the checkboxes in the UI
- Click "Create Route" to connect them with a colored line
- Watch Trains: Trains automatically spawn and move along routes
- Manage Passengers: Passengers appear at stations and need transport to their destinations
Game.tsx- Main game loop and state managementMapComponent.tsx- MapLibre GL integration with click handlingThreeLayer.tsx- Three.js rendering layer for animationsStation.tsx- Animated station nodesRoute.tsx- Colored route lines connecting stationsTrain.tsx- Moving train animationsPassenger.tsx- Passenger visualization and animationsGameUI.tsx- Game controls and information overlay
The game uses React hooks for state management with the useGameState hook managing:
- Stations and their positions
- Routes connecting stations
- Train positions and movement
- Passenger spawning and destinations
- Game score and controls
The project is configured for automatic deployment to GitHub Pages via GitHub Actions:
- Push changes to the
mainbranch - GitHub Actions runs tests and builds the project
- Successful builds are automatically deployed to GitHub Pages
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
npm test - Run linter:
npm run lint - Submit a pull request
MIT