Feature Library

Game cameras

0.41 GPU · 0.89 CPU ms
A still of the Game cameras demo
Still
The live demo starts when it’s in view.Click to capture the mouse (Esc lets go) · W A S D walk · V swap shoulder · F or right button aim · E drive · T top view

The third-person cameras of a game that “feels great”.

What it costs a frame

0.41 ms
0.89 ms
GPU
0.41 ms
CPU, median
0.89 ms
CPU, 95th pct
1.36 ms
Draw calls
74
Weight
Moderate

Measured 11 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. What ran: Measured walking by itself round a loop (through the low arch, under the colonnade roof, past the ball), the view turning and tilting so the arm is pulled in and eases out; the cast view on. Both casts run against about 40 boxes and a ball each frame (microseconds). Standing still, nothing is drawn at all. 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.410.891.36
apple · Apple A19 Proin a browser tab · 16 November 20261.880.380.52
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 20262.562.343.13

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. Third-person action and adventure games
  2. Over-the-shoulder aiming
  3. A driving or riding camera that hands over from on foot
  4. Walking through an architectural model or a level
  5. Keeping a follow camera out of walls without a physics engine
  6. A playable character in a product or brand world
  7. Testing a level’s tight spots for the camera
  8. A top-down or isometric game where buildings must never hide the player
  9. Walking into a building and seeing the floor you are on
  10. A camera that shows more of where you are heading

Pitfalls, in brief

  1. Leave the player’s own body out of the cast (and the car while driving it).
  2. Run the camera after the movement, on the drawn (interpolated) position, once per rendered frame with that frame’s dt.
  3. The arm pulls in at once and only eases outward.
  4. The first cast (head to shoulder pivot) matters as much as the arm: without it, standing with the shoulder against a wall puts the pivot, and so the camera, inside the wall.
  5. Keep skin and the near plane together: the camera stops skin (0.02 m) short of the ball’s contact, the ball is 0.22 m, so a near plane under 0.2 m never cuts a wall.
17 more in brief
  1. The height lag is capped at 1.5 m: a teleport or a long fall snaps the rest.
  2. One orbit for both cameras: the chase camera turns the third-person camera’s yaw and pitch (pass it as the orbit), and the third-person camera keeps updating underneath while driving, so getting out continues where the view is.
  3. The chase camera drifts behind only while the vehicle moves faster than 2.5 m/s, and only 0.6 s after the last touch: turned round a standing car the view stays put. feelSpeed is the speed at which the widening and drawing back are full; set it for your vehicles (the demo uses 24 m/s in a small yard).
  4. Its clip is a segment test from the orbit’s centre to the camera (a ray in the game), and it never pulls closer than 20% of the way: a vehicle backed into a corner shows itself rather than a wall’s inside.
  5. Add shakeOut to your own shake each frame and apply the shake after both cameras have placed the camera: they set it afresh every frame, so the offset never accumulates.
  6. The colliders here are a stand-in for small scenes: every cast tests every enabled solid (with a quick bounding-ball reject).
  7. Mouse look moves are in pixels: with pointer lock the browser may hand unaccelerated movement (unadjustedMovement), so the same sensitivity feels slower than with OS acceleration.
  8. Pointer lock needs a user gesture and can be refused (embedded frames, some hosts): keep drag to look working, and say how to get the mouse back (Esc).
  9. The top view’s lean follows the drawn focus each frame and treats a jump of more than 30 m as a teleport.
  10. The lean is in world metres on the ground, not on screen: a vehicle leans up to 16 m at full strength.
  11. The cutaway is a mask (alpha-tested discard), not transparency: no sorting, no blending, and shadows stay whole (maskShadowNode).
  12. Each building mesh reads its cut from userData.cutY as it is drawn (a per-object uniform).
  13. Back faces are drawn only as a flat cap where a wall is cut, so cut materials become double-sided.
  14. The window through buildings needs open eased (the demo at 14 a second); stepping it 0 to 1 pops.
  15. hiders() tests prisms against the chest-to-camera segment: pass the eye’s distance as reach.
  16. The cut rises with the feet on a stair (it never drops below them), so stairs must be inside the ring and their steps solid boxes; a stair modelled as one ramp mesh is cut at the player’s feet plus the stub.
  17. The props’ opening (applyViewOpening) depends on where each fragment is relative to the player’s chest: set the focus every frame (updateCutout) before drawing, including while driving (the vehicle’s centre).
22 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Where it comes from

From HaTac, and in the driving playground showcase. Fully custom code.

Jorge Jimenez, interleaved gradient noise (Next Generation Post Processing in Call of Duty: Advanced Warfare, SIGGRAPH 2014): The screen grain the cutaway dithers with, its three constants.

camerathird personover the shoulderspring armcamera collisionsphere castshape castshoulder swapaimfield of viewchase cameradriving cameraorbitpointer lockmouse looktouchvirtual stickcamera shakeframe-rate independentreduced motiontop-down cameraisometriclookaheadcamera lead

Near it in the frame