From my debugging, this happens when I dispose the last mesh in my scene, and only if the scene uses the CascadedShadowGenerator, with non-default numCascades (4 is fine, 2 and 3 crash). No issue if I don’t have this specific setup.
I have tried to create a repro case in the PG but did not manage.
Tagging @Evgeni_Popov as I’ve seen that you’ve done significant work on shadows in 4.2, so this might ring a bell to you ;).
I’m happy to help debug this more, but so far that’s all I could come up with. Also pointing out that this is not a major issue for me since I can simply put 4 cascades to fix it.
Are you disposing of the shadow generator before disposing of the meshes? If yes, you should do the reverse.
It seems the dispose function of the shadow generator RTT has been called before you get the error, as this.getScene() will return null only if RTT.dispose has been called.
I am not disposing of the shadow generator at all, I clear all meshes of the scene to replace them by new ones that will use the same shadow generator. Also, this used to work before up to v4.1.
That’s strange, looking at the code it seems the only way to have _scene = null is by calling dispose() on the RTT, dispose is the only location I have found that sets this._scene = null.
I guess a repro would be the only way to move further.