Git Product home page Git Product logo

nbody's Introduction

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

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.

nbody's People

Contributors

pjankiewicz avatar oliverevans96 avatar

Stargazers

 avatar T-the-G avatar Joe Smith avatar Stanislav avatar Márk Bartos avatar Evert Geldenhuys avatar Jonathan Crum avatar Moritz Riede avatar Salvador Guzman avatar BooGerMan avatar Alan avatar Zach Bateman avatar Kyle L. McGregor avatar Harold Hersey avatar necedema avatar Jeff Carpenter avatar Rasmus Henriksson avatar py avatar Joshua Byrd avatar Victor Tao avatar  avatar Luca avatar DobsonH avatar Marco Spampinato avatar Masahiro Sakuta avatar Julien Vallade avatar Ivan Vasiunyk avatar Wojciech Kargul avatar 신희제(Heejae Shin) avatar Wenping Guo avatar  avatar Tanapol Prucksakorn avatar  avatar  avatar Dominic Maas avatar Michael H. avatar  avatar  avatar Peter Dunne avatar Paz avatar  avatar  avatar

Watchers

 avatar James Cloos avatar

nbody's Issues

Installation failed

For a fresh clone, I got the following error when running cargo build --release --target wasm32-unknown-unknown

   Compiling bevy_ecs v0.7.0
error[E0433]: failed to resolve: unresolved import
  --> /home/cph/.cargo/registry/src/index.crates.io-6f17d22bba15001f/stdweb-0.4.20/src/webcore/ffi/wasm_bindgen.rs:67:32
   |
67 |             alloc: &Closure< Fn( usize ) -> *mut u8 >,
   |                                ^ unresolved import

   Compiling webbrowser v0.7.1
   Compiling egui v0.18.1
   Compiling wgpu v0.12.0
error[E0425]: cannot find function `wasm_bindgen_initialize` in this scope
  --> /home/cph/.cargo/registry/src/index.crates.io-6f17d22bba15001f/stdweb-0.4.20/src/webcore/ffi/wasm_bindgen.rs:77:22
   |
77 |         let module = wasm_bindgen_initialize( memory, table, &alloc, &free );
   |                      ^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope


Perhaps providing a Cargo.lock ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.