Seems like an easy way to achieve making the sphere dispose correctly is setting the action manager to be on the killBox rather than the sphere. The actionManager also has a dispose method, but calling that before calling sphere.dispose didn’t seem to work.
The method you want to use does depend on if you enumerate through “map”-object of your meshes, then using delete is prefered, because it will be undefined (inexistent) and your loops don’t consider the mesh anymore. Else if it has to be equal null, because you need this mesh as null-property in any of your evaluations afterwards. Else if scope is going to be left anyway, I would just use dispose(), but I’m new to TypeScript, aswell. So maybe someone can correct me if I’m wrong.
FWIW, if anyone else comes here - if you’re disposing of individual nodes in a scene, DO NOT iterate via scene.transformNodes.forEach() ! If you call transformNode.dispose() inside your iterator, it will modify the array out from under your iterator causing nodes to be skipped seemingly at random.
I ended up copying the array first with splice( 0 ), then iteration became stable despite nodes being disposed.
Yes I tried scene.removeTransformNode() instead - no help there.