I followed the basic example from the three js docs, “Creating a scene” and for my application, I need to make sure that the WebGL context is freed when changing the scene.
I noticed that calling WebGLRenderer.dispose() has no effect. To demonstrate this, adding renderer.dispose() in the animation loop has no effect.
Calling WebGLRenderer.dispose() has an effect and it is not recommended to continue calls of render() after you have used this method. Yes, rendering will still work since the renderer recovers parts of the internal state but important event listeners will be removed from the context which can’t be undone.
I suggest you switch to setAnimationLoop() like in the following fiddle. This will make the usage of WebGLRenderer.dispose() more as expected. Notice that with the upcoming release r165 all example code uses setAnimationLoop() so it is the new recommended way to configure the animation loop.