Build & Run

Congratulations! All the code is in place. Now let's see it in action.

1. Running Native (Desktop)

To run the simulation as a native desktop application, use Cargo:

# Run in release mode for performance (simulation is heavy!)
cargo run --release
💡 Performance

Always use --release. In debug mode, Rust is significantly slower, and simulating a million particles might run at 1 FPS instead of 60+.

Command Line Arguments

The native version accepts command line arguments to customize the simulation:

# Usage: ./target/release/particle-system [NUM_PARTICLES] [TIME_TO_DIE] [PARTICLES_PER_SEC]
# Example: 1 million particles, 1.0s lifetime, 1000 generated/sec
cargo run --release -- 1000000 1.0 1000

2. Running Web (WASM)

Running on the web requires two steps: compilation and serving.

Step A: Compile to WASM

Use wasm-pack to build the project targeting the web:

wasm-pack build --target web --out-name Unreal_Majid

This will create a pkg/ directory containing:

  • Unreal_Majid_bg.wasm (The compiled binary)
  • Unreal_Majid.js (JavaScript glue code)

Step B: Serve Locally

Modern browsers block WASM loading from file:// URLs for security. You must serve the directory over HTTP. An easy way is using Python:

# Run this in the project root
python3 -m http.server

Then open your browser and navigate to:

http://localhost:8000

⚠️ Browser Support

This project uses WebGPU. Ensure your browser supports it. Chrome 113+ enables it by default on Windows/macOS. On Linux, you may need to enable flags in chrome://flags.