Journal
Nov 14, 2026·2 min read· WebGL

Spot lights need a target

I spent an evening wondering why a desk lamp lit the floor in the middle of the room instead of the desk. Then why the wall of frames was dark. Every spot light in the scene was aimed at the same place: the origin.

Why

A three.js SpotLight does not point where you rotate it. It points at its target, a separate object whose default position is (0, 0, 0). And the target's world matrix is only updated if the target is part of the scene graph. If you set light.target.position and never add the target to the scene, nothing moves.

The fix

Either add the target to the scene, or update its matrix yourself:

light.target.position.set(x, y, z);
light.target.updateMatrixWorld();

In React Three Fiber I wrapped this in a small Spot component that takes a target prop and does both lines in a layout effect. After that, every lamp in the room is declared with where it stands and what it looks at.

A related trap

Hiding an object that contains a light changes the number of lights in the scene, and three.js recompiles every lit material when that number changes. I had a small robot with a light inside that appeared with a visible hitch. Scaling it to nearly zero instead of toggling visible keeps the light count stable, and the hitch is gone.

Neither of these is a bug. Both are the kind of thing you only learn by losing an evening.