A swarm is two separate problems, and keeping them apart is the whole trick. Appearance is what one bee looks like; at swarm scale a bee is a handful of triangles and its identity doesn't matter, so we bake one bee mesh and hand it to a THREE.InstancedMesh that stamps it N times in a single draw call. Motion is where each bee is — and that is never a baked loop (a loop either synchronises every bee, which looks uncanny, or rides fixed rails that ignore the flower and the cursor). It's a live agent sim, recomputed every frame, in swarm3d.js: pure struct-of-arrays with a fixed-timestep step(), the exact shape a WebGPU compute pass or a Rust loop wants.
The mechanics port almost mechanically — the dimension count is just a constant. Three things actually change:
curl(Ψ). That's automatically source/sink-free, so bees swirl through the field instead of all draining into one point. (The bench's selftest checks ∇·F ≈ 0.)axis × radial: pick an axis, and the tangential force lays the orbit in the plane perpendicular to it — that's what makes the torus you see.1Field / attractor. A global pull toward a target plus the swirl above. Cheap, global, no bee-to-bee anything. This alone gives a credible orbiting cloud.
2Boids — direct perception. Reynolds' three local rules: separation (short-range push, the strongest), cohesion (toward the neighbour centroid), alignment (match neighbour heading). Each bee senses only neighbours within a radius. This is emergence from direct sensing — every bee reads its neighbours each tick.
3Stigmergy — indirect, environment-mediated. This is the one people mean by "how do ants/termites/bees really coordinate," and it's qualitatively different from boids. No agent talks to another. Instead each bee deposits a marker (here: "scent") into a shared medium — a 3D voxel grid — and reads the medium back. The grid has its own physics: scent evaporates (a forgetting rate) and diffuses (spreads to neighbours). Bees steer up the local gradient. The result: where a few bees pass, scent pools; the pooling pulls more bees; their deposits reinforce it — a positive feedback that condenses diffuse traffic into lanes and recruitment trails that no bee planned and no central controller drew. Turn the field on in the panel and watch ropes of flight form and dissolve.
Boids is coordination through perception — it needs every agent to sense every neighbour, which is the part that gets expensive and brittle at scale. Stigmergy is coordination through the world: the environment becomes a shared, decaying memory, so an agent that arrives later "reads" the work of agents long gone. That decouples agents in time and space, which is exactly why real colonies use it — ant pheromone trails, termite mound construction (a deposited pellet makes the next pellet more likely there), bee nest-site recruitment. The two evaporation/diffusion knobs are doing real work: evaporation sets the memory's half-life (too slow and stale trails never clear; too fast and nothing accumulates), and diffusion sets how sharp vs. smeared the trails read. Tune them and you're tuning a distributed memory, not an animation.
Everything — spawn, PRNG (xmur3→mulberry32), noise, the scent field — is seeded and runs on a fixed 1/60 s substep, so the sim is reproducible from (seed, #steps) on any machine regardless of render FPS. That's the same portable-asset property the sister 2D Bee Lab and the Sprite Lab rely on. The CPU kernel here is a faithful preview of a GPU port — the SoA + pure-step shape transfers straight to a compute shader. Kernel + selftest: tjs/swarm/swarm3d.js, swarm3d.selftest.mjs.