I am facing a challenge with managing memory in my project. I have a dynamic sphere with moving points on it, and I am creating curves to connect these points. Here is an illustration of the process:
https://i.sstatic.net/PGWuU.jpg
As the points are constantly changing position, I need to draw new curves for each frame, which leads to a significant increase in memory usage.
Each curve creation process involves the following code snippet:
// points = array of Three.Vector3 size 40
path = new THREE.CatmullRomCurve3(points)
mesh = new THREE.Mesh(
new THREE.TubeGeometry(path,64,0.5,false), // geometry
new THREE.MeshBasicMaterial({color: 0x0000ff}) // material
)
scene.add(mesh)
And for removing these elements from the scene:
scene.remove(mesh)
mesh.material.dispose()
mesh.geometry.dispose()
However, I am unable to dispose of the array of 40 Three.js vectors called points
, as well as the CatmullRomCurve3 object named path
.
I am seeking guidance on how to properly handle disposal of instances created using new THREE.Vector3()
and new THREE.CatmullRomCurve3()
.