Feature Library

Quadruped gait

0.74 GPU · 0.48 CPU ms
A still of the Quadruped gait demo
Still
The live demo starts when it’s in view.Tap the ground to walk there · drag to orbit · W A S D steer · 1–5 builds · P pauses, then scrub the phase

Four legs that walk, trot and run without a single animation clip.

What it costs a frame

0.74 ms
0.48 ms
GPU
0.74 ms
CPU, median
0.48 ms
CPU, 95th pct
0.68 ms
Draw calls
76
Weight
Moderate

Measured 13 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 157, 1920×1080 at 1×. 600 frames × 3 rounds, median kept (rounds ranged GPU 0.64–0.76, CPU 0.48–0.50 ms). What ran: Measured wandering by itself over the rolling ground, its speed swept from a walk through the trot to a run and back, with footprints and sole markers on: one controller at 60 Hz, four IK solves a frame and a shadowed sun. Standing still with no prints fading, nothing is drawn at all. Phones: tiers are being measured next.

On every machine it was measured on
MachineGPU msCPU msCPU p95
RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900Hreference · measuring tool0.740.480.68
apple · Apple A19 Proin a browser tab · 16 November 20261.780.280.46
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 20262.101.501.97

Bars against one 16.7 ms frame. A browser-tab run is timed in a visible tab without the tool’s scripted input, so read it as close, not exact.

What it needs

Renders with
WebGPU or WebGLWebGPU where there is one, WebGL2 where there is not.
Your browser
Runs hereNo WebGPU needed
Depends on
three.js 0.187.0No other packages

What it’s for

  1. Animals and creatures in a game, from one mesh rigged once
  2. Robots and walkers on uneven ground
  3. A pet, a mount or a companion that follows the player
  4. Tuning a gait by eye, with the schedule beside it
  5. Foot sounds and dust on touchdown, from a bit mask
  6. A creature that stops cycling when a wall blocks it

Pitfalls, in brief

  1. One fixed clock for every animal (60 Hz), and render sampling once a drawn frame: fixedStep refuses a step over 1/30 s.
  2. Read touchdownMask (and rejectedFootMask) right after each fixedStep: it holds that step only.
  3. The motor moves by what the world allowed, not by what was asked: a body blocked by a wall stops cycling.
  4. The world adapter owns collision. move() must write every field of its result, and must not apply gravity again (the request already carries it). flatWorld and heightWorld have no walls: a game needs a body sweep that turns as well as moves, so a long body doesn’t swing its rear through a fence.
  5. ground() is asked at reset, at every lift-off and at every landing, for this actor only.
8 more in brief
  1. The rig takes a model wrapper at unit scale, a body that is its direct child, and four direct chains upper → middle → end → sole.
  2. Author the pole (which way the middle joint bends) per leg: rest geometry alone does not say it reliably.
  3. The solver never stretches a bone: a target out of reach is clamped and flagged in unreachableMask.
  4. No AnimationMixer on the same bones at the same time: apply() resets and owns the body and every leg bone each call.
  5. To change build (a different morphology), make a new controller from the new profile at the old root position and yaw, and let the feet replant.
  6. Fixed here, still in the source (HaTac, 5db2c5830): at a gait change a leg could skip its lift-off and stay planted a whole extra cycle, stretching past its reach.
  7. Gait changes wait for the end of the cycle, and the phase is never reset: a sudden change of speed shows the old gait for up to one cycle.
  8. Cost grows per animal: four IK solves and the bone updates every drawn frame, plus skinning and draws.
13 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Where it comes from

From HaTac. Fully custom code.

quadrupedgaitprocedural animationlocomotionfoot placementinverse kinematicstwo-bone ikstanceswingtrotwalk cycleterrainfixed timestepinterpolationinspectorthree.jsno dependencies

Near it in the frame