We are facing a challenge when dealing with large Three.js scenes that consist of many individual objects. In some cases, our scenes can contain anywhere from 25,000 to 50,000 instances of Object3D
. While this may seem like a lot, we haven't found an easy way to reduce this number without compromising the scene itself. When attempting to clear such a scene by removing all objects, it typically takes around two minutes to complete the process. This holds true whether we remove each element individually using scene.remove(element);
or if we gather all elements first and then call
scene.remove(element1, element2, ...);
. We've even tried replacing the entire scene instance, but unfortunately, it was still slow.
Our observations have shown variations in performance based on different graphics cards, leading us to believe that the issue may be related to the use of numerous buffer geometries that need to be removed from the graphics card, impacting overall performance.
Due to the fact that the browser is blocked during object removal, the website becomes unresponsive for a significant period of time. Are there any suggestions for improving the performance of object removal or making it non-blocking (without resorting to setTimeout()
for removing individual elements)?
To demonstrate the issue in a simplified manner (using 50,000 cubes removed after the first frame), you can refer to the following example: http://jsfiddle.net/ua2mg5ty/