MeshInstance.castShadow not working properly

Hey all,

This might be a bug, or I’m just missing something obvious. When I call the following code at runtime, the shadows on my mesh disappear as expected.

var meshInstances = this.entity.model.meshInstances;
for (var mi = 0; mi < meshInstances.length; mi++) {
     meshInstances[mi].castShadow = false;
}

However, when I later try to reenable the shadows with this snipped, nothing happens:

var meshInstances = this.entity.model.meshInstances;
for (var mi = 0; mi < meshInstances.length; mi++) {
     meshInstances[mi].castShadow = true;
}

The shadows remain gone for good. Is there some update function that I need to call for the scene to notice the change, or what? Please help.

Can you put together a sample project that demonstrates this issue?

Thanks,

While trying to set up the demo I wasn’t able to get the shadows to disappear with the code above anymore, either, it just does nothing. What does work however is adding this after both instructions:

this.entity.model.enabled = false;
this.entity.model.enabled = true;

Which seems to update the renderer to the change. This makes the shadows reappear correctly as well so it solves my issue. Not sure if this is the correct way to handle the update, but it does the trick for now.