
Creator: @LinusEkenstam ↗
Custom WebGL2 3D physics engine in Rust
Creator notes
I wrote a custom 3D physics engine and WebGL2 renderer from scratch in Rust that runs in the browser via WebAssembly. 0 external math crates. 0 physics libraries. <100KB .wasm binary at 120 FPS. Here’s how the entire architecture fits together in ~1,200 lines of Rust. I've had the opportunity to play around with Gemini 4 Argon for the past couple of weeks. I could not help myself, but I wanted to see what it could do. I know there are lot of really cool projects around, that are super polished and amazing. However, I wanted to make something a bit more raw. So I tasked Argon with building a 3D engine that includes a physics engine out of the box. While try to keeping it light weight. The result, IMPULSE. Instead of pulling in Rapier or Bullet, everything is solved from first principles at 120Hz (2 substeps/frame): → Analytical world-space inverse inertia tensors (R * I_local^-1 * R^T) → 15-axis Separating Axis Theorem (SAT) for OBB-OBB manifolds → Iterative sequential impulses + Baumgarte stabilization → 3 X 3 effective mass matrix K^-1 for ball-and-socket & catenary bridge joints We skipped wgpu for raw web-sys WebGL2 to keep compile times instant and the binary tiny: → Two-pass 2048x2048 depth shadow map with 3x3 PCF → Procedural unit meshes + local-space rotational stripes → Screen-to-world ray unprojection for 3D mouse spring dragging → Toggleable AABB & contact normal wireframe pass In my stress tests, I'll throw 500+ rigid bodies, including light and shadows, all WebGL. I should turn this into a benchmark for all models going forward, because it's truly amazing. My goal was to create an engine that is super light weight and that I can use in other projects. The entire engine so far weighs only 82.7 KB Should I drop the GitHub repo + live playable link?
Original post · @LinusEkenstam ↗More to explore
View all ↗

Interactive 3D island with controllable sailboat
@ai_for_success

Real-time 3D fluffy pumpkin plushie
@thebuggeddev

3D seaplane on water generated by Gemini 4
@LuminaBench