It seems like Three.js does not have a good way to dispose a THREE.Scene
and all of the objects within that scene.
Currently I am doing the following:
$.each(scene.__objects, function(idx, obj) {
scene.remove(obj);
if (obj.geometry) {
obj.geometry.dispose();
}
if (obj.material) {
if (obj.material instanceof THREE.MeshFaceMaterial) {
$.each(obj.material.materials, function(idx, obj) {
obj.dispose();
});
} else {
obj.material.dispose();
}
}
if (obj.dispose) {
obj.dispose();
}
});
Looking at the Chrome Heap profiler, there are still many objects that do not get cleaned up (Textures, Shader Materials, Vectors, etc...).