A real-time video chat application with a Minecraft-style 3D interface built with WebRTC and React Three Fiber.
- 🎮 Minecraft-style 3D World: Navigate a voxel-based room in first-person view
- 📹 WebRTC Video Chat: Peer-to-peer video communication
- 💬 Real-time Chat: Text messaging with Socket.IO
- 👥 Multiplayer: See other users as 3D avatars
- 🎨 Customizable Avatars: Each user gets unique colors based on their ID
- NestJS - Node.js framework
- Socket.IO - Real-time communication
- JWT - Authentication
- React - UI framework
- Vite - Build tool
- React Three Fiber - 3D rendering
- Drei - Three.js helpers
- Zustand - State management
- TailwindCSS - Styling
first-person-room/
├── server/ # NestJS backend
│ ├── src/
│ │ ├── modules/
│ │ │ ├── auth/ # Authentication module
│ │ │ └── chat/ # Chat & WebRTC signaling
│ │ ├── app.module.ts
│ │ └── main.ts
│ └── package.json
│
├── client/ # React frontend
│ ├── src/
│ │ ├── components/
│ │ │ ├── 3d/ # Three.js components
│ │ │ └── ui/ # UI components
│ │ ├── hooks/ # Custom hooks
│ │ ├── stores/ # Zustand stores
│ │ ├── pages/ # Page components
│ │ └── layouts/ # Layout components
│ └── package.json
│
└── package.json # Root package.json
- Node.js 18+
- npm or yarn
- Install dependencies:
npm install- Start the development servers:
npm run devThis will start:
- Backend server on
http://localhost:3001 - Frontend on
http://localhost:5173
# Backend only
npm run dev:server
# Frontend only
npm run dev:client| Key | Action |
|---|---|
| W/A/S/D | Move |
| Mouse | Look around |
| Space | Jump |
| Enter/T | Open chat |
| Escape | Pause menu |
PORT- Server port (default: 3001)JWT_SECRET- JWT secret keyCLIENT_URL- Frontend URL for CORS
- Configure in
vite.config.tsfor proxy settings
- User registers/logs in via REST API
- Server returns JWT token
- Token used for Socket.IO authentication
- User joins room via Socket.IO
- Server notifies existing users
- New user initiates WebRTC offers to all users
- ICE candidates exchanged through server
- Direct peer-to-peer video streams established
- Position/rotation synced via Socket.IO
- Throttled to reduce bandwidth
- Smooth interpolation on receiving end
MIT