In my Three.js scene, I have various objects, a ground plane, and directional lights, one of which casts shadows. Most objects cast shadows without issues, except for a few that are part of a complex hierarchy. These specific objects, including a guy in a yellow shirt and an orange robot, are not casting shadows properly. The hierarchy they are in is much deeper compared to the ones that behave as expected. The intricate structure mirrors that of a simulation program I am working on.
Here's a glimpse of the problem:
And here it is with only the shadow-casting light enabled:
Both characters with the faulty shadows have multiple layers of nesting, unlike the stationary objects that work fine with a simpler hierarchy. Despite being within the light's shadow frustum, these problematic objects do not cast shadows correctly. I have followed the standard troubleshooting steps for shadows, but to no avail:
- The directional light has
.castShadow
set totrue
- Only one directional light casts shadows
- The settings of the directional light's shadow frustum are correct (as seen in the screenshot)
- All
Mesh
objects have.castShadow
and.receiveShadow
set totrue
- The ground plane has
.receiveShadow
set to true - There are no gaps in the ground plane
- EDIT: Even when all lights except the shadow-casting one are disabled, the issue persists
Could the deep hierarchy be interfering with the .castShadow
settings? This seems like the most plausible explanation at this point.
EDIT: Here is the depth buffer data from the directional light, showing no signs of our guy or robot:
Just to note, I am using Three.js r70.