Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamically create and destroy a Three.js scene without leaking memory

Lets say we had a page with two buttons, create and destroy. When you click create the Three.js scene in this memory test below is dynamically added to the page and starts running. Clicking destroy should remove the scene, dealocate all buffers and free up all memory etc. http://mrdoob.github.com/three.js/examples/webgl_test_memory.html

Does anyone know how to do this without framing the scene and changing the url?

thanks

like image 631
Alan Avatar asked Oct 06 '22 06:10

Alan


1 Answers

I think you need to using the dispose() method in side geometry, material and texture.

geometry.dispose();
material.dispose();
texture.dispose();

https://github.com/mrdoob/three.js/blob/master/examples/webgl_test_memory.html

like image 96
user3006521 Avatar answered Oct 13 '22 10:10

user3006521