This shouldn’t be a problem for any correct code, but can cause all kinds of weird behavior if people aren’t careful!
When re-running playground code, the global variable “scene” isn’t cleared (not sure about other globals) – it is still set to the scene that was created by the last execution of the playground. This playground demonstrates this happening, run it a few times and watch the counter increase:
Scene creation code shouldn’t refer to the global “scene” (it should either pass null as scene to creation functions, or explicitly pass the scene it’s creating) BUT it’s a very easy error to make to refer to “scene” somewhere without actually having it defined. This can create some very confusing results since there won’t be any errors, and code kind-of-sort-of works except that materials and textures and meshes are added to the OLD scene rather than the new one… and then they don’t show up in the inspector, and some poor newbie tears their hair out for a while.
Suggested: Clear all Babylon-related window globals in the context heading into a playground re-run. That way any dangling references to “scene” will fail immediately as the variable will be undefined.