Skip to content

2D Position Based Fluid simulation in Rust with both WASM and native targets

License

Notifications You must be signed in to change notification settings

lucas-schuermann/pbd-fluid-rs

Repository files navigation

Build

pbd-fluid-rs is a 2D Position Based Fluid implementation in Rust with WASM + WebGL. It was inspired by Matthais Müller's position based fluid demo.

For a quick demo, please see https://lucas-schuermann.github.io/pbd-fluid-rs/. The WASM version of this project is deployed to Github Pages after building with Github Actions.

Running

Package Dependencies

# debian/ubuntu
apt install build-essential pkg-config cmake libfreetype6-dev libfontconfig1-dev

Native (cargo)

RUST_LOG=info cargo run --package native --release

Press 1-4 to select a dam break scene and reset the simulation, s to toggle drawing with a single color, or space to add a block of particles.

Web (npm)

# install dependencies
npm install

# compile to WASM, run webpack, and spawn a local server
npm run serve

Then visit http://localhost:8080

License

This project is distributed under the MIT license.