Help with DirectionalLight

Hi all
i’m a newbie with three js

i’m tring to illuminate this object with two directionallight but i get light only on the back… what do i miss?? can be an object “bug” ?

light2 is the one with problems

function createDirectionalLightWithHelper(x, y, z,tx,ty,tz,color,intensity) {
	var light = new THREE.DirectionalLight(color, intensity);
	light.position.set(x, y, z);
	light.castShadow = true;
	light.target.position.set(tx, ty, tz);
	light.target.updateMatrixWorld();
	light.shadow.mapSize.width = 1024;
	light.shadow.mapSize.height = 1024;
	light.shadow.camera.near = 0.5;
	light.shadow.camera.far = 50;

	var helper = new THREE.DirectionalLightHelper(light, 5);
	scene.add(helper);
	helper.parent.updateMatrixWorld();
	helper.update();

	var shadowHelper = new THREE.CameraHelper(light.shadow.camera);
	scene.add(shadowHelper);

	return light;
}

	var light1 = createDirectionalLightWithHelper(0, 20, -50,0,50,0,0xffffff,3);
	var light2 = createDirectionalLightWithHelper(0, 20, 50,0,50,0,0xffffff,3);

	scene.add(light1);
	scene.add(light2);

@daniele_zerosi maybe try using 1 directional light only and add it to the camera instead of adding it to the scene.

Depending on the format of your model, you might be able to find a 3D viewer on my webpage and test it there.

The code is ok, just see the Note under the .target property:

scene.add(light.target);

(On a side-note, you don’t need to manually call .updateMatrixWorld, it just clutters the code in this case.)

Thanks to all. Problem was in the object. Interesting to add light to camera. As i said i’m a newbie and i didn’t know it is possible to do that

From the look of the helpers, the shadow camera far distance isn’t far enough. the box needs to overlap the objects that are going to cast shadow, and the surfaces that will receive shadows.
You can move the lights closer, or increase their shadowCamera far distance and update the projection matrix.

let shadowCam = directionalLight.shadow.camera;
shadowCam.far = 1000;
shadowCame.updateProjectionMatrix();

edit: wups. I see in your setup you’re setting .far … im leaving this up tho since it may help someone.