Giel Berkers
Giel Berkers

Reputation: 2960

how can I set the size of a directional light in Three.JS?

I've added a directional light to my scene, but it doesn't show all the shadow. The shadow gets cut off, just like when the FOV of a spotlight is too small.

When I enable the shadowCameraVisible, i see that my light is like a big box which shows the shadow (which makes sense). The question is: how can I make this 'box' bigger?

Upvotes: 8

Views: 5230

Answers (1)

Giel Berkers
Giel Berkers

Reputation: 2960

Found it! Turns out the shadowcamera has left, right, top and bottom properties:

light.shadowCameraLeft = -3000;
light.shadowCameraRight = 3000;
light.shadowCameraTop = 3500;
light.shadowCameraBottom = -3000;

If you get pixelized shadows, it means your shadow map (read: memory) is not big enough. Experiment which is the lowest map you need, because this seems to be expensive. Example:

 light.shadow.mapSize.x = 2048
 light.shadow.mapSize.y = 2048

Upvotes: 11

Related Questions