Explain the property of light.shadow.camera.near/far/right/left/top/bottom?

I just start to create a game use three.js by copy and modify the example code,
One thing really confuse me is the shadow of lights.
First , the shadow edge is not sharp, it has some jags / sawtooth . see code snaps here : http://jsfiddle.net/f17Lz5ux/5131/

Second, when I change code to this:

light.shadow.camera.top = 180;
light.shadow.camera.bottom = -100;
light.shadow.camera.left = -120;
light.shadow.camera.right = 120;

the shadow enlarged, and becomes less recognizable.

when I change code to this:

light.shadow.camera.near = 1;
light.shadow.camera.far = 10;
light.shadow.camera.right = 15;
light.shadow.camera.left = - 15;
light.shadow.camera.top	= 15;
light.shadow.camera.bottom = - 15;
light.shadow.mapSize.width = 1024;
light.shadow.mapSize.height = 1024;

the shadow disappear !

so, could someone help me explain the light.shadow.camera.near/far/right/left/top/bottom property ?

I can see it in this example: Edit fiddle - JSFiddle - Code Playground

The mentioned values just define the frustum of the shadow camera which is used for calculating the shadow map of a light source. To achieve good shadow quality, the frustums should be as small/tight as possible.

You should be aware that right, left, top and bottom are only values of an orthographic shadow camera. SpotLight has a perspective shadow camera so these values are ignored.

3 Likes

Thanks for your reply.
I have a problem with directional light shadow, when at scene initialize, the player is stand on (0,0,0) which is in the light shadow camera’s frustums, but when the player move some way , it goes out of the frustums, so I need to change light shadow camera when I change the player’s position ? or set the frustums as large as possible ?

You should try to change the position of the directional light according to the player’s position.

1 Like