Skip to content
Viacheslav K.
← Lab

Centipede Locomotion

A many-legged creature that walks, turns and climbs walls with no animation data at all.

Downloads 627 kB on demand

W / ↑
Forward
A D / ← →
Turn
Drag
Steer
Scroll
Zoom
Space
Autopilot
Built
Stack
TypeScript, three.js, WebGL, Vite

How it works

Every leg here is solved, not played back. There are no animation clips, no keyframes and no skeleton: each foot raycasts the surface beneath it, decides on its own when it has been left behind, and steps to catch up. The gait emerges from the timing between those decisions, and wall climbing falls out of the same code as walking on the floor - the legs simply find a different surface, and the body follows the average of the normals they land on.

Rebuilt from scratch after seeing the many-legged procedural walkers going around Unreal circles. None of that code is used here.

Notes

  • Two-bone legs solved in closed form with the law of cosines - no IK solver, no dependency, roughly fifteen lines
  • Feet raycast for their own contact point and trigger a step once the resolved target drifts past a threshold, so gait is a consequence of movement rather than a clip that plays over it
  • Metachronal wave: a fixed phase offset per body segment produces the ripple that reads as a centipede instead of a row of legs moving together
  • The body is a trail of recorded head poses, sampled by arc length, which keeps segments on the surface through corners that a per-segment constraint solver mangles
  • Wall and ceiling climbing needs no separate mode - body up is the blend of the surface normals underfoot, and gravity is replaced by adhesion along its negative
  • The cost is one raycast per leg, and the demo prints its own measured update time in the corner rather than asking anyone to take that on faith
  • Physically-based materials on CC0 scans from Poly Haven, with ambient occlusion, roughness and metalness packed into one image per surface, and UVs rewritten into world units so a 46-unit floor and a 1-unit edge share the same grain
  • Texture resolution chosen from texels per world unit rather than habit, and surfaces picked partly for how well they hide their own repetition - which is how the whole scene fits in 627 kB instead of the 1.7 MB the same set costs at 1k throughout