Feature Library

Ragdoll with balance and stagger

0.49 GPU · 0.41 CPU ms
A still of the Ragdoll with balance and stagger demo
Still
The live demo starts when it’s in view.Click a part of the mannequin to hit it there · drag across it to aim and size the hit · Slow, Limp (before) and Same hit again in the card · orbit to look round

A pushed body that decides, the same way every time, whether it catches itself.

What it costs a frame

0.49 ms
0.41 ms
GPU
0.49 ms
CPU, median
0.41 ms
CPU, 95th pct
0.65 ms
Draw calls
9
Weight
Light

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.32–0.52, CPU 0.41–0.44 ms). What ran: Knocked over by a 420 N·s chest hit on its first frame, so the measured frames are the controlled fall; after that it pushes itself every 2.4 s while standing, round the compass and at different parts, alternating a sway, a stagger and a fall: the balance and catch steps, or the controlled fall (shape matching, reach, limits) and the get-up through poses, on the fixed 60 Hz tick; the mannequin as three instanced meshes, one shadowed key light and a room environment. 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.490.410.65
apple · Apple A19 Proin a browser tab · 16 November 20261.670.280.54
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 20262.030.651.06

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. Characters that react to being bumped, shoved or caught by a crowd
  2. A body that stumbles and recovers before it ever falls over
  3. Falls that come from where the hit landed: a shoulder turns it, a knee sweeps its legs, a chest topples it
  4. A fall that catches itself on its hands, and a get-up that reads as a person, not a morph
  5. Falls that land against walls and ledges instead of through them
  6. A server and every client agreeing on whether someone fell
  7. Teaching balance: support, capture point and recovery steps
  8. A test dummy for doors, moving platforms and crowds that push

Pitfalls, in brief

  1. Everything runs on a fixed 1/60 s tick, and tick() refuses anything else: run as many ticks as the frame needs (cap them; the demo takes at most six) and draw with sample(alpha) between the last two.
  2. The verdict is deterministic and the seed only picks a gesture: never feed Math.random() or the frame’s dt into the balance.
  3. Pushes are impulses in N·s at a point over the ground.
  4. The motor must carry the push through collision and report back: a wall that stopped it calls balance.blocked(axisX, axisZ), or the body leans into the wall forever.
  5. A catch step is planned, not hoped for: recoveryStep() checks ground under the heel and the ball and three points along the swing, five candidates at most.
13 more in brief
  1. The ragdoll takes its bone lengths and trunk braces from the pose it starts in.
  2. Its joint radii are tuned for a 0.83 m hip height: pass the body’s hip height over 0.83 as scale, as PushableBody does, or a small body’s hands will not reach the floor and a large one floats.
  3. Most of the time on the floor is the ragdoll settling before it sleeps (about 2 s after a hard fall), not lieFor: tune settling (speed, quietFor, minimumAge) if getting up feels slow.
  4. A body pushed into a wall has joints stopped on the wall’s own line, so standing it up where the pelvis lies can put it inside the wall.
  5. The get-up blends joint positions, which shortens bones mid-blend; keepLengths() puts them back, parents first, and the joints follow the blend on springs (PoseSpring), settling exactly onto the standing pose over the last tenth.
  6. A muscle inside the ragdoll must not move the body: shape matching cancels out by itself, but anything that pulls some joints and not others (the reaching arms) has to give the difference back to the rest, or the arms tow the body across the floor.
  7. A joint limit corrected in the position alone becomes speed, and one that fights the muscles every substep pumps the body until it flies.
  8. A shape-matching cluster needs three points off one line, or its best-fit turn is undefined and it throws whatever it holds.
  9. How a hard hit ends up lying is chaotic, as in life: test the start (the head against the feet, the twist) and the guarantees (hands first, limits, standing again), not the final pose. fall.fastest (4.5 m/s) keeps a hard hit a fall rather than a forward roll over the head.
  10. Toppling (losing it) holds the root and tips the pose about the feet; a push during it ends it at once.
  11. Nothing here moves a skinned mesh: the module gives world joint positions (skeleton.ts JOINTS).
  12. A world whose height() answers null under a fallen body (off its edge) has nothing to land on: once the pelvis is 20 m under where it fell from with no ground, the body is lost (lost true, moving false, still) and never gets up until reset().
  13. Asleep, the ragdoll costs nothing, and moving is false once a standing body has settled: stop ticking and drawing then.
18 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.

Jerry Pratt, John Carff, Sergey Drakunov & Ambarish Goswami, Capture Point: A Step toward Humanoid Push Recovery (Humanoids 2006): The point a pushed body must step to: its position plus its velocity over a time constant, checked against the support between the feet.

Thomas Jakobsen, Advanced Character Physics (GDC 2001): The ragdoll’s method: Verlet particles for joints, distance constraints relaxed in a few passes, collisions as projections.

Numerical Recipes (Press et al.): The LCG constants (1664525, 1013904223) behind the seeded bracing gesture.

Matthias Müller, Bruno Heidelberger, Matthias Teschner & Markus Gross, Meshless Deformations Based on Shape Matching (SIGGRAPH 2005): The fading muscle tone: joints pulled toward their standing shape, best-fit rotated, in two clusters.

Matthias Müller, Jan Bender, Nuttapong Chentanez & Miles Macklin, A Robust Method to Extract the Rotational Part of Deformations (MIG 2016): The quaternion iteration that finds each cluster’s rotation, warm-started each step.

Wilfrid Dempster (1955), via David Winter, Biomechanics and Motor Control of Human Movement: The segment masses lumped onto the joints (mass.ts MASS_SHARE).

Fay Horak & Lewis Nashner, Central programming of postural movements (Journal of Neurophysiology 1986): The ankle and the hip strategy, before a step.

A. M. Andrew, Another efficient algorithm for convex hulls in two dimensions (1979): The monotone chain that outlines the feet.

ragdollbalancestaggerpush recoverycapture pointcatch stephit reactioncontrolled fallshape matchingjoint limitsankle and hip strategyverletposition basedconstraintsget upprocedural animationdeterministicfixed timestepmannequinthree.jsno dependenciesrests when idle

Near it in the frame