It appears that Three.js lacks a proper method for disposing of a THREE.Scene
and all its contents.
My current approach is as follows:
$.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();
}
});
Despite these efforts, the Chrome Heap profiler shows that there are still numerous objects that are not being properly cleaned up (such as Textures, Shader Materials, Vectors, etc...).