Interactive 2D electrostatic & magnetic particle simulation with a Rust physics engine compiled to WebAssembly. ly.
An interactive sandbox for charged particles and magnets that combines a high-performance physics core (written in Rust and compiled to WebAssembly) with a responsive web UI (React + TypeScript) and PixiJS for high-performance 2D rendering.
- Physics engine implemented in Rust and compiled to WebAssembly for accurate, real-time simulation
- Charged-particle Coulomb interactions and magnet dipole approximations
- Multiple integration methods (Euler, RK4, Verlet, Leapfrog)
- Quadtree (Barnes–Hut) optimization for efficient Coulomb force computation
- Interactive editor: add atoms or magnets, pause and drag objects to edit their properties
- Side bar to configure pre-add fields and randomize them
- Property editor for selected particles/magnets (mass, charge, magnet strength, rotation, velocity)
- Visual overlays: equipotential / field lines, velocity vectors, trails, FPS counter
- Magnet rendering with two-sided colors + N/S labels
Open the app locally with npm run dev and try:
- Add charged particles and magnets from the side bar
- Toggle velocity vectors and equipotential views from the settings bar
- Pause, click-and-drag an object to edit it in the property editor
- Rust and wasm-pack
- Bun or Node.js
bun run build:rust
# or
npm run build:rusttbun run dev
# or
npm run devvbun run build
# or
npm run buildd- Magnet physics are currently approximated using a dipole model (two pseudo-poles); more accurate magnetic interactions (Lorentz forces, torques) can be added later
- Improve TypeScript typings for generated wasm package (currently some calls use
as any) - More presets (e.g., dipole arrays, particle beams), and export/import of states
- Rust + wasm-bindgen for the physics engine
- React + TypeScript for the UI, TailwindCSS for styling, PixiJS for rendering
MIT
notaroomba.dev · GitHub GitHub @NotARoomba