basketball.casa

A basketball world simulated from the body up. Watch only.

The replay's close camera now finds a clear line to the ball

When the ball is stolen, stripped or charged into, the replay cuts in close so the hands can be seen. Until now the close camera always sat on the same side of the play, and every so often another player stood between it and the ball, so the frame showed a back instead of the steal. The camera now checks for that and turns round the play to a side where nothing is in the way.

Close in on an interception: a blue player's back and head fill the middle of the frame, in front of the red player reaching up for the ball
Before: an interception, with a bystander standing in the line to the ball.
The same interception from a camera turned round the play: the red player reaching up for the ball stands clear, the blue player now at the edge of the frame
After: the same moment, from a side with nothing between the camera and the ball.

Turning as little as it can

For each close-up the camera first tries the place it would have stood anyway. If no other body is near the line from the camera to the ball, it stays there, so every close-up that was already clear looks exactly as before. If someone is in the way, it tries turning round the ball by 30 degrees one way, then the other, then 60, and takes the first turn that leaves the line clear. It never turns further than that, so it stays on its own side of the court.

export function clearTurn(at, dir, bodies) {
  let best = 0, room = -1;
  for (const turn of TURNS) {
    const r = clearance(at, dir, turn, bodies);
    if (r >= CLEAR_M) return turn;
    if (r > room) { best = turn; room = r; }
  }
  return best;
}

The players in the play itself, those within an arm's reach of the ball, never count as being in the way: they are what the shot is for. Anyone else within 0.4 metres of the line, about half a body's width, does. If every turn is blocked, the camera takes the one with the most room.

The bodies the game put there

The camera does not guess where people are. It reads where the simulation placed every player at the moment of the steal, once for each close-up, so the camera holds still while it is in close, and a paused replay, a scrub and normal play all choose the same side.

Close in on a strip: a blue player seen from behind fills the centre of the frame, the ball and the red defender mostly hidden behind them
A strip, before: the ball is behind a bystander.
The same strip from a camera turned round the play: the red defender and the ball at their feet in clear view, the bystander off to the left
After: the camera turned, the ball and the defender in view.

Checked on every close-up, not one

The fix was checked on every steal, strip and charge of two whole games: 18 moments, each cut to by both of the replay's cameras, so 36 close-ups. In 5 of them someone stood within about a third of a metre of the line to the ball. Those five now turn, and in each the nearest bystander is 0.7 to 1.5 metres from the line. The other 31 were already clear and did not move at all.