I am working with a Mesh instance that utilizes a TubeGeometry for its path. Whenever I make changes to the underlying curve that the TubeGeometry instance is based on, I remove the mesh from the scene and create a new one.
Although the scene updates properly, the memory usage is skyrocketing, indicating that I am not deallocating the removed mesh correctly after it is removed from the scene.
Below is the code snippet I am using for deallocation:
$.each(parent.children, function (idx, obj) {
parent.remove(obj);
renderer.deallocateObject(obj);
obj.deallocate();
});
Here, parent
represents an Object3D where I place the Mesh, and renderer
is an instance of WebGLRenderer.
Could someone point out where I am going wrong and suggest the correct approach to handle this?
I have included a Plunk with my current example. The relevant code can be found in the scene.js file, specifically lines 76-86. Note that the example is using r53.