The live demo starts when it’s in view.Tap the ground: the lead calls the squad there · drag to orbit
Agents that see, hear and hide as a group.
What it costs a frame
GPU
0.73 ms
CPU
0.60 ms
02468101216.7 ms
GPU
0.73 ms
CPU, median
0.60 ms
CPU, 95th pct
0.84 ms
Draw calls
99
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.47–0.73, CPU 0.60–0.81 ms). What ran: Measured as it runs by itself: eight agents hiding from the sweeping light on its moving mast, two lookouts taking turns, call-outs and regroups as they happen; sight cones (34 rays each against 30 solids at 30 Hz), cover spots, call rings and a 1024² spot-light shadow on. Phones: tiers are being measured next.
apple · Apple A19 Proin a browser tab · 16 November 2026
3.98
0.74
3.74
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 2026
2.49
1.49
2.25
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
Sentries and watchers that see and hear in a stealth game
A group of agents that hide from a light, a camera or a patrol
NPCs that take cover behind walls and crates without hand-placed cover nodes
Turn-taking so only a few agents act at once (look out, go first, speak)
Wildlife that hears footsteps and flees together
Crowd or evacuation simulations where people call to each other and regroup
Minimap sight cones that respect walls
Pitfalls, in brief
A cover spot hides only from the side it faces: protects(spot, threat) must be well above 0 (scoreCover wants 0.45), and the spot still needs a line check from the threat’s eye to a body tucked behind it.
Give the threat’s y as the height it sees from (a lamp’s head, a sentry’s eyes) and test the watched body’s chest, not its feet: feet are behind every kerb.
The cover field caches per collider set by identity: pass a new colliders object when walls move or break, or it keeps the old spots.
Cover searches are rationed (searchesPerStep, shared by every body): a squad of twelve finds its spots over a few steps, not in one.
A mind never searches itself: it sets wants, and only the director hands it a spot.
6 more in brief
band defaults to the source’s fighting distances (a quarter to seven tenths of the body’s range).
A call’s front travels at speed: a listener is told when it passes, not when it is called.
A relay is a new call with relayOf set to the first one: nobody hears the same news twice, so relays spread outward without echoing back.
Hush and turns pull against each other: a hushed lookout keeps its turn but does not peek, and loses the turn after 1.4 s out of touch.
sightFan is level at the eye: a viewer behind a wall taller than its eyes sees nothing past it, and over a lower one sees everything.
Facings are atan2(dx, dz) (0 along +z), as three.js yaw is.
11 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.
Chris Wellons, “lowbias32” integer hash (hash-prospector): The finalising constants of sweepPhase’s hash (public domain).
Hart, Nilsson and Raphael, A* search (1968): The walk grid’s search. The algorithm, not code.
Slab test for a ray against a box (Kay and Kajiya, 1986): segmentHit clips the line against each box’s three slabs. The method, not code.
aiagentsnpcperceptionsight coneline of sighthearingcovercover pointssquadgroup behaviourturn takingstealthsearchlightcall-outsregrouppathfindingwalk gridstate machinethree.jsno dependencies