nbody
nbody copied to clipboard
Yet another n-body simulation in Rust
This is a weekend project utilizing several technologies:
- Bevy - game engine
- egui - UI elements
- webassembly - wasm-bindgen is used to compile Rust to webassembly which can be run in the browser
The code to calculate velocities of objects is naive all pairs algorithm which can handle up to 1000 objects in 60.0 FPS on a laptop. Web version is 4x slower which means it can handle around 500 objects.
Screenshot
![planet simulation](https://github.com/pjankiewicz/nbody/raw/master/images/screenshot.png)
Demo
https://pjankiewicz.github.io/nbody/index.html
Running desktop application
cargo run --release
Building webassembly version
cargo build --release --target wasm32-unknown-unknown
wasm-bindgen --out-dir ./out/ --target web ./target/wasm32-unknown-unknown/release/nbody.wasm
Running
python -m http.server
And navigate to http://localhost:8000 in your browser.