Objects casting/receiving shadows: is this recursive?

I have a complex object with meshes and sub-objects (children). In order for it to cast & receive shadows (on itself and other objs), do I have to recurse through the whole thing setting .castShadow and .receiveShadow on every sub-object, or can I set it on the top-level Object3D?

1 Like

Have you tried setting it just on the top-level object?

Yes, didn’t seem to work, but I’m not sure if I’m doing it right. There seem to be a lot of little things to set up (shadow cameras on the lights at least?)

That’s odd, because the docs say Object3Ds have a .receiveShadow and .castShadow attribute. But maybe it’s not recursively applied to children Meshes.

I’ve been poking around in the source and I don’t see anywhere it looks up the tree to parents, or propagates it down. So I guess I need to do that recursive traversal.

2 Likes

It’s not recursively applied.
Shadows are very expensive and you should be as conservative as possible when enabling them.

1 Like