In a scene I have a lot of equal static objects, only having a different position. So to have a better performance I want to merge the buffergeometries of these objects togetter into one large object (mergedObj).
So I’ve created a functon called mergeObjects() that merges a copy of a baseObjects geometry and its children geometries into the new mergedObjects geometry and its children geometries.
That is working as expected when having some objects, but if the count of objects expand, or the amount of vertices inside the different geometries rises, problems occur. Some of the geometries will get merged and others aren’t resulting in misformed objects. Sometimes geometries only get merged half.
I’m not sure if this is a problem in my code or that I’m hitting on some limitation of either the merge geometries functions of BufferGeometrieUtils, or some other limitiation of WebGL or memory I’m not aware of. Or maybe I’m missing something else here. But I could use some help at this point after a lot of debugging.
I’ve created a codePen to illustrate the problem:
The base-object in the example exists of an Object3D object with two children: a sphere and a cube. These are on the same x-location, stacked on top of each other.
In canvas you see only the cube gets copied and merged all the way, but the spere is not. If you lower the resolution of the sphere more instances of the spere get copied, so it has something to do with a limitiation somewhere about maximum buffer size of maximum amount of vertices or something like that.
After lot of debugging I’m kind of stuck on this. Anybody who can give me some clue or direction where to look to solve this strange issue? Thanks!