Reputation: 2673
I have few scenes with cameras in one page.
One of them is a map view.
I can simply load this scene by function, but is in THREE js simple way to remove whole scene?
When I do not showing map, I don't want to keep objects loaded and rendered for better performance.
I found only how to remove child by child in loop. But I hope there is a better solution.
Upvotes: 1
Views: 1374
Reputation: 168
Just removing THREE objects from your scene is not enough to delete them from memory. You have to call the dispose() methods on the objects' geometries, materials and textures.
https://github.com/mrdoob/three.js/issues/5175
After you call your dispose and remove methods, do a diagnostic like this (where this.renderer is your THREE.Renderer):
if (this.renderer && (this.renderer.info.memory.geometries || this.renderer.info.memory.programs || this.renderer.info.memory.textures)) {
loge("VIEW.clear: geometries=" + this.renderer.info.memory.geometries + " programs=" + this.renderer.info.memory.programs + " textures=" + this.renderer.info.memory.textures);
}
If the number of programs, geometries and textures isn't stable, you are inviting performance issues and a memory leak.
Upvotes: 1