I have a problem with the memory usage of a scene while animating some meshes.
I have a mesh imported from blender that represents a moving crane. I receive several updates per seconds about the state of the crane : its position and the position of its attached tong.
So every time I receive a new position information, I clear the mesh’s animations, push a new one with its new destination and launch it with the following code:
this.mesh.animations = ; this.mesh.animations.push(animation); this.scene.beginAnimation(this.mesh, 0, 1000, false, 1,
My problem is that the engine seems to keep a lot of references to animation elements like RuntimeAnimation, Animatables, etc. as well as position vectors that are never cleaned. Over time, this crashes the browser.
Although if I stop the position updates (so I don’t create any new animations), the memory falls back to normal(-ish) after a while.
About the scene, I have a few hundred meshes. Most of them are cubes but I couldn’t make instances of them because they all have different properties. The crane and tong have about 5000 vertices each.
Also, almost all meshes have an attached label that is composed of a plane with a texture showing the name of the element.
Can anybody give me pointers about what’s going on and how I could fix this situation?
I tried to lower the duration of the animations so they would be quicker than the refresh rate of the crane and I noticed that the memory consumption seemed more stable (I’ll let it run for a few hours to be sure).
Could my problem be due to the fact that I am creating new animations before the previous ones are finished?