Skip to content

five-on-it / apps/client/src/renderer/camera

apps/client/src/renderer/camera ​

The GTA2-style camera as pure math: a steep perspective view from above the player's car that looks slightly ahead along the velocity and, in a car, zooms out at speed (the settings' Zoom out at speed: on or off, how far, how quickly). The scene is right-handed, so a camera placed on the -z side of its target shows +z as "up" on screen, which is the car's spawn heading.

The zoom out at speed follows a filtered speed, never the raw one, which prediction's corrections, bumps, knocks and handbrake turns make noisy: SpeedZoom smooths it one way quickly (the view pulls out as the car gathers speed) and the other slowly (a brief brake or a bump does not pump the view), frame-rate independent, and eases it into the height with a smoothstep from a crawl to full speed. On foot the view rises a little with the pace as it always has (footZoom). The look-ahead follows a filtered velocity too (LookAhead): the raw one swings with every flick of the steering keys, a kerb or a correction of the prediction, and the look-ahead magnifies each into a jolt of the whole picture. CameraFollower then follows the pose so made, carried along by that velocity so it trails the car by nothing. A blow (LookAhead.impact) is the one thing neither filters: the picture stops with the car.

Classes ​

Interfaces ​

Variables ​

Functions ​