An interactive N-body gravity simulation that combines a high-performance physics engine (written in Rust and compiled to WASM) with a responsive web UI (React + TypeScript), and PixiJS for high-performance 2D canvas rendering.
Live demo · gravity.notaroomba.dev
- High-performance physics core implemented in Rust and compiled to WebAssembly for accurate, real-time N-body gravitational simulation
- Smooth, interactive 2D visualization built with React, PixiJS, and TypeScript
- Barnes-Hut quadtree optimization for efficient simulation of 500+ bodies
- Multiple numerical integration methods (Euler, RK4, Verlet, Leapfrog)
- Adjustable parameters (gravity, mass, speed, quadtree theta) and simulation controls
- Real-time editing: pause to drag planets, modify properties, and adjust velocities
- Interactive viewport with pan and zoom controls
- Visual features: velocity vectors, trails, FPS counter, and quadtree visualization
- Add/remove planets dynamically with hold-to-add/remove functionality
Open https://gravity.notaroomba.dev in a browser.
npm run build:rust
# or
bun run build:rusttnpm run dev
# or
bun run devvnpm run build
# or
bun run buildd- Additional integration methods for improved energy conservation
- Presets for interesting orbital configurations (binary stars, solar systems, etc.)
- Export/import simulation states
- Performance optimizations for 1000+ body simulations
- Rust and wasm-bindgen for the physics engine
- React for the UI, TailwindCSS for the styling, and PixiJS for rendering
- Barnes-Hut algorithm for quadtree optimization
- Inspiration from classic N-body simulations and orbital mechanics visualizations
MIT
notaroomba.dev · GitHub GitHub @NotARoomba · ·