SimulationQuadruped gait
Four legs that walk, trot and run without a single animation clip.
What it costs a frame
- 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.
| Machine | GPU ms | CPU ms | CPU p95 |
|---|---|---|---|
| RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900Hreference · measuring tool | 0.74 | 0.48 | 0.68 |
| apple · Apple A19 Proin a browser tab · 16 November 2026 | 1.78 | 0.28 | 0.46 |
| Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 2026 | 2.10 | 1.50 | 1.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
- Animals and creatures in a game, from one mesh rigged once
- Robots and walkers on uneven ground
- A pet, a mount or a companion that follows the player
- Tuning a gait by eye, with the schedule beside it
- Foot sounds and dust on touchdown, from a bit mask
- A creature that stops cycling when a wall blocks it
Pitfalls, in brief
- One fixed clock for every animal (60 Hz), and render sampling once a drawn frame: fixedStep refuses a step over 1/30 s.
- Read touchdownMask (and rejectedFootMask) right after each fixedStep: it holds that step only.
- The motor moves by what the world allowed, not by what was asked: a body blocked by a wall stops cycling.
- 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.
- ground() is asked at reset, at every lift-off and at every landing, for this actor only.
8 more in brief
- The rig takes a model wrapper at unit scale, a body that is its direct child, and four direct chains upper → middle → end → sole.
- Author the pole (which way the middle joint bends) per leg: rest geometry alone does not say it reliably.
- The solver never stretches a bone: a target out of reach is clamped and flagged in unreachableMask.
- No AnimationMixer on the same bones at the same time: apply() resets and owns the body and every leg bone each call.
- 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.
- 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.
- 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.
- Cost grows per animal: four IK solves and the bone updates every drawn frame, plus skinning and draws.
Where it comes from
From HaTac. Fully custom code.


