Add cleanup/destroy to the API

Not all applications run forever with three loaded.
Sometime we need to get rid of all objects.

In my tests at least renderer.domElement held a reference to the canvas, preventing the garbage collection.

http://stackoverflow.com/questions/22565737/cleanup-threejs-scene-leak
suggests some code to cleanup which should be IMO in the library itself to be proper maintained.

The easiest way would be to have

THREE.destroy()

which removes all references to fetched or created stuff

Author: Fantashit

1 thought on “Add cleanup/destroy to the API

  1. THREE itself doesn’t have a reference to all the things created, so there is no way for that to work.

    I agree though that information on the best way to clean up a scene is lacking – this could be a candidate for a page in the manual.

Comments are closed.