Material dispose bug with instances

If an instance is made, and the material later disposed, if that instance is sorted earlier in the scene.meshes array than the sourcemesh, then an error will occur. See here.

This didn’t use to be an issue as instances could never be earlier in scene.meshes, but with optimisations in v4, disposing meshes changes the order.

A check could be done here for the existence of _sourceMesh property (though this is private to the InstancedMesh class) or just use instanceof (though performance would be worse), and continue the loop if the mesh is an instance.

Good catch!
I’ll fix that for next commit