What Is The Right Way To Remove A Mesh Completely From The Scene In Three.js?
How can I remove meshes from three.js scene completely without causing memory leaks. I could find that loading the same models again and again causes the browser to crash, so it se
Solution 1:
Use the dispose
method on the geometry and material. Also, ensure that nothing is holding references to these objects, as that will prevent garbage collection.
var myMesh = new THREE.Mesh(geo, mat);
scene.add(myMesh);
//...
scene.remove(myMesh);
myMesh.geometry.dispose();
myMesh.material.dispose();
myMesh = undefined;
Post a Comment for "What Is The Right Way To Remove A Mesh Completely From The Scene In Three.js?"