Portfolio / Computational Design

Boids in 3D

The same flock as Boids (Flocking), lifted off the plane. Craig Reynolds' three local rules — separation (don't crowd neighbors), alignment (match their average heading), cohesion (steer toward their average position) — run exactly as before, only now every steer is a three-dimensional vector and the swarm wheels inside a box you can walk around. No central plan; the murmuration is emergent, just three forces per agent per timestep.

Where the 2D version wraps at the screen edges, here the flock is gently turned back by the walls of a soft-walled cage, so it stays in view as a volume rather than a sheet. Each boid is a little depth-shaded dart — nearer birds darker and bolder — sorted back to front so the cloud reads as deep, and a fading comet trail follows each one so the streams and eddies of the flock's motion stay visible.

Drag to orbit, scroll to zoom, shift-drag to pan, double-click to reset; leave spin on for a slow turntable, or hover to herd the flock toward your cursor. Tune the count, attraction, repulsion, and trail length (drag it to zero for none), and toggle the cohesion links. Plain HTML5 canvas + JS with a tiny 3D vector library and the same orthographic-orbit projection as NKS Lines in 3D — no libraries, light or dark to match the page. Source on GitHub.