Split The code is public; the app answers only to the crew.

Movement between ticks: interpolate what is drawn, so 64 Hz does not judder at 60 #128

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The work is pushed and bun run check is green (520 tests, types clean).

Notes

shipped merged

opened this

The work is pushed and bun run check is green (520 tests, types clean).

A new src/client/interpolate.ts does the arithmetic of drawing between two ticks — a position lerped, a yaw turned the short way round the circle (−170° to +170° is 20° through south, not 340°), alpha clamped to [0, 1], a teleport that snaps, and drawnAt, the clock an animation measured off world.time should advance on. It is pure and writes into the tuples it is handed, so a frame allocates nothing.

Interpolated: every other player's position and yaw, the muzzle flash on their gun (so the star stays on the barrel of the body that was drawn), every grenade's position, the bomb's, the dead toppling (a corpse never moves, so what judders is its fall clock), and the HUD's name plates, which take the same alpha the scene did. Left at the newest tick: the camera — your aim is this frame's mouse and your eye is the newest position, and that includes the teammate's eyes you borrow while dead — plus every effect's timing (tracers, sparks, your own gun's flash and bob), the radar, the crosshair and the whole HUD besides the plates.

The previous pose lives in fields that already exist: player.prev, bomb.prev, grenade.prev, written once at the top of update (and by grenades.step, the code that moves a grenade) — never a fresh object. startRound resets it, because a spawn is a teleport, and anything further than 64 units in one tick snaps anyway. The RL arena steps players through applyInput and never through update, so it pays nothing at all for this; observe.ts and the policy's 32 numbers are untouched. scripts/cost.ts reads 0.12–0.13 ms a tick either side of the change, inside the run-to-run spread.

What to look at in the preview: stand in a doorway and watch a bot strafe across it. Before, at 60 Hz against 64, it advanced two ticks or none every fifteenth frame and crossing the crosshair was a series of small jumps; now it slides. Then check what this must not have broken — flick your own view and confirm the aim is immediate, and watch a round end and restart: nobody slides to their spawn. Tests that would fail without the change are in interpolate.test.ts (including the seam and the snap), renderer.test.ts (the model matrix at alpha 0, 0.5 and 1, a teleport drawn where the body is, a grenade, a topple), world.test.ts and grenades.test.ts (where the previous pose is written, and that applyInput does not write it) and hud.test.ts (the plate over the interpolated head).

🤖 Generated with Claude Code

Closes #100

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs