GLTF child not blocking shadows?

Hello guys, I am new to shadows and things so please dont eat me, but it seems like my GLTF object’s children simply do not block/cast shadows, pretty weird if you ask me.

Here’s my code:

    renderer.shadowMap.enabled = true;
    var light = new THREE.DirectionalLight(0xffffff);
    light.castShadow = true;
    light.shadowDarkness = 1;
    renderer.shadowMapSoft = true;
    light.shadowCameraNear = 2;
	light.shadowCameraFar = 5;
	light.shadowCameraLeft = -0.5;
	light.shadowCameraRight = 0.5;
	light.shadowCameraTop = 0.5;
	light.shadowCameraBottom = -0.5;
	light.position.x = 500;


var gltfloader = new GLTFLoader();
gltfloader.load("./maps/dd2fix/de_dust2.glb", function(object) {
	var obj = object.scene;
	obj.castShadow = true;
	obj.receiveShadow = true;
	obj.scale.x = obj.scale.y = obj.scale.z = 0.175;
	obj.traverse(function(child) {
		if(child.isMesh) {
			child.castShadow = true;
			child.receiveShadow = true;

Lastly, here is what I get to see, when running this code:

As you can see, both in the tunnel and the side of the stairs, they are lit like there is nothing in front of them.

You are not configuring the shadow camera correctly. It should be something like: = 0.5; = - 0.5; = - 0.5; = 0.5; = 2; = 5;

I could also imagine that the frustum of your shadow camera is too small. You can debug the frustum visually by adding a camera helper to your scene:

scene.add( new THREE.CameraHelper( ) );

BTW: It seems you are using an outdated code reference. Stuff like shadowDarkness or shadowMapSoft do not exist.

Uh, thanks for that all, but I guess, that this is not really ideal, right

I angled the camera weirdly, just so you can see the shadow still passes through a wall

Depending on your screenshot, the shadow camera frustum is too small.

1 Like