particles · gravity · collision · rigid bodies · configurable bounciness
Features
Rigid Bodies
Spawn boxes and circles held together by PBD distance constraints with mass-weighted correction.
Elastic Collisions
Mass-weighted impulse response for point-point and point-vs-edge collisions. Configurable restitution (0–1).
Gravity + Forces
Gravity, friction damping, and custom directional forces. Newton's second law: a = F/m.
Canvas Playback
Simulation pre-baked server-side; PNG frames streamed to an in-browser canvas player with play/pause/scrub.
Interactive Controls
Sliders for gravity, friction, bounciness, particle count, and step count. Spawn rigid bodies on demand.
Test Suite + CI
48 Pest tests covering physics, constraints, and collision. GitHub Actions matrix across PHP 8.1/8.2/8.3.
Quickstart
# Clone and install git clone https://github.com/d4rkd0s/phpfisx cd phpfisx composer install # Start dev server php -S localhost:8000 # Open in browser open http://localhost:8000
Requires PHP 8.1+ with ext-gd enabled and Composer.
Got Yarn? yarn start does the same thing.
Roadmap
- 2D Fields with bounds
- 2D Points (particles)
- 2D Gravity
- 2D Custom forces
- 2D Velocity system
- 2D Friction / damping
- 2D Mass + inertia
- Point-point elastic collision
- Rigid bodies (boxes + circles)
- Point-vs-edge collision
- Restitution (bounciness)
- Animated canvas playback
- Static surfaces (walls/ramps)
- Visual scene editor
- Per-shape materials
- Live unstepped simulation
- 3D Spaces + shapes
- 3D .stl / .obj import
Why PHP?
There are plenty of physics engines in compiled languages (C++, Rust, Go). PHP is different: no compilation, no install friction, runs anywhere a web server exists, and it's genuinely fun to push a language into unexpected territory. phpfisx is a proof of concept that the physics are the interesting part — not the runtime.