A simple 3D demo using Three.js that features a first-person view (FPV) drone-like camera movement system in a large open space with a central landmark.
- FPV drone-like controls for intuitive navigation
- Large open map with a central landmark
- Rotating green cube on a tall pedestal as a reference point
- 1000x1000 unit ground plane with edge fade-out effect
- Tall towers dispersed near the edges for better depth perception
- Checkerboard textures and improved shading for better visual feedback
- Enhanced lighting system
- Multiple directional lights
- Adjusted light intensities for better depth perception
- Ambient lighting for improved visibility
- Responsive design that adapts to window resizing
- Modern development setup using Vite
- SQLite-based telemetry logging system
- Captures frame timing data
- Records performance metrics
- Stores system information
- Real-time performance monitoring
- Automatic error handling and logging
- Gamepad support with traditional FPV drone controls
- Flight routine demo with programmable drone movements
- SVG favicon representing a racing drone
- Improved physics with momentum and altitude hold functionality
The demo supports both keyboard and gamepad controls:
W/S
: Move forward/backwardA/D
: Strafe left/rightSpace
: Move upShift
: Move downArrow Keys
: Rotate the view (left/right/up/down)H
: Toggle altitude hold modeR
: Reset drone position
- Left Stick:
- Up: Throttle up (move drone vertically up)
- Down: Throttle down to 0
- Left: Rotate drone left
- Right: Rotate drone right
- Right Stick:
- Up: Tilt forward
- Down: Tilt backward
- Left: Tilt left
- Right: Tilt right
The control scheme follows traditional FPV drone controls for intuitive flying.
Note: The gamepad controls will automatically activate when a controller is connected. Keyboard controls remain available as a fallback.
- Node.js LTS (v20.x recommended, currently using v20.19.0)
- npm (comes with Node.js)
If you're using a different Node.js version and encounter issues, especially with better-sqlite3
, we recommend switching to Node.js 20 LTS. You can install it via:
# Using homebrew on macOS
brew install node@20
brew link --overwrite --force node@20
# Using nvm (Node Version Manager)
nvm install 20
nvm use 20
- Clone the repository:
git clone https://github.com/ZachBeta/threejs_fpv.git
cd threejs_fpv
- Install dependencies:
npm install
To start the development server:
npm run dev
This will start the Vite development server. Open your browser and navigate to http://localhost:5173 to see the demo.
To create a production build:
npm run build
To preview the production build:
npm run preview
home.html
- Main HTML file (previously index.html)demos/
- Demo HTML files and assetssrc/demos/drone_flight_demo.js
- Drone flight simulation with Three.js scene setup and animationsrc/demos/flight_routine_demo.js
- Programmatic flight routines demo implementationsrc/demos/game_state_demo.js
- Game state and telemetry display demosrc/demos/physics_demo.js
- Physics engine demonstrationsrc/logger.js
- Telemetry logging system implementationsrc/flight_routines/
- Contains various flight routine definitionssrc/models/
- Contains 3D model definitions including drone and mappackage.json
- Project configuration and dependencieslogs.db
- SQLite database for storing telemetry datapublic/favicon.svg
- SVG favicon representing a racing drone
- Three.js - 3D graphics library
- Vite - Next generation frontend tooling
- better-sqlite3 - Fast and simple SQLite3 library
The project includes a comprehensive telemetry logging system that captures performance metrics and system information:
- Frame timing and FPS metrics
- System information
- Error events and stack traces
- Performance bottlenecks
- Game state data with player identification
The telemetry data is stored in a SQLite database (logs.db
) with tables for:
- Frame metrics
- System information
- Error logs
- Game state snapshots with player name
You can query the logs using any SQLite client. For example:
# Using sqlite3 command line tool
sqlite3 logs.db "SELECT * FROM frame_metrics LIMIT 5;"
Please read our RULES.md for guidelines on contributing to this project.
- Home page (home.html) points to demos
- Pulled demo JS closer to demo pages
- Renamed logging demo to game state demo
- Resolved issue with multiple logging_demo.js files by renaming to game_state_demo.js
- Basic FPV drone controls implementation
- Map Enhancement:
- Added more objects to the map
- Added tall towers dispersed near the edges
- Implemented edge fade-out effect with fog
- Fixed floating demo cube clipping
- Added checkerboard texture and improved shading
- Enhanced lighting system with multiple directional lights
- Reset drone with L button
- Basic gamepad support
- Improved visual feedback for controls
- Handle npm warnings - npm audit fix
- Confirm logging database tests only interface with our code
- Set up Vite development environment
- Implement basic telemetry logging system
- Basic flight routine demo implementation
- Implemented SVG favicon representing a racing drone
- Making spawn pedestal semi transparent like the platform
- Creating a tracking flight routine for tower focusing
- Creating collapsible flight routine demo menu
- Adding scrollbar for longer flight routines
- Implementing "out and back" flight routine
- Handling momentum in physics tests
- Creating "safety off" mode for full pitch and roll
- Merging physics demo and flight routines demo
- Adding player name functionality to game state logging system
- Physics and Movement:
- Implement separate rotor thrust physics
- Improve altitude hold behavior realism
- Enhance hover state physics
- Implement player name functionality in UI
- Game State Display:
- Display controller state information
- Show position and orientation data
- Add performance metrics overlay
- Display the drone camera at the front of the drone in flight routine demo
- Add more complex flight routines to the flight routine demo
- Physics/controls: implement toggle hover feature
- Migrate to TypeScript
- Upgrade logo and the drone model used in the demo
- Add client/server rigor to prevent game hacking
- Fix flight routines duplicates
- Handle yaw modulo
- Fix hover functionality on gamepad
- Fix reset button on gamepad
- Add more complex yaw flight routines (180s, 360s)
- Development Tasks:
- Write unit tests for new features
- Add integration tests for physics system
- Implement automated performance testing
- Add browser compatibility tests
- Performance Optimization:
- Profile and optimize render loop
- Implement level of detail system
- Add object pooling for frequently created/destroyed objects
- Optimize physics calculations
- UI/UX Improvements:
- Add game state display (controller state, position, etc.)
- Implement HUD for important information
- Add visual feedback for physics interactions
- Create settings menu for controls and graphics
- Add visual feedback for stick boundaries
- Add labels for stick axes
- Improve routine step transitions
- Add smooth interpolation between steps
- Create visualization tool for logged data
- Map Enhancement:
- Separate map and map data when it becomes an issue
- Extract map logic to a dedicated class
- Add procedural generation options
- Implement dynamic loading for large maps
- Additional Features:
- Add multiplayer support
- Implement race mode
- Create obstacle course mode
- Add drone customization options
- Should we adjust the base throttle for routine steps?
- Do we need to handle window focus/blur for the routine?
- Should we add error recovery for failed steps?
- Logger might be causing initialization issues
- Consider adding more error handling
- Maybe we need to delay logging until after DOM is ready
MIT