Updating an old project from ThreeJS 106 to the actual version is quite some work: Adding export and import, not using with in methods etc.
Now one obstacle is left: Geometry.merge is gone. BufferGeometryUtils.mergeGeometries is not the same. The same Attributes was needed, ok. But:
I need to merge BufferGeometry(s) which contain groups for different materials already.
.mergeGeometries either creates no groups or new ones, one for each source geometry.
But eliminates my original groups.
I tested it and even steppt through the merge function: All data is available, this merge could read and merge the original groups. Do I need to clone BufferGeometryUtils.mergeGeometries and add that feature myself or is there another way?
I don’t think there’s any built-in function to concatenate the geometry and preserve the original groups. The groups are represented as a range of vertices (start and end index in vertex list, or in index list if present) so applying them to the new geometry should just be a matter of creating new groups with an offset added. So you could call BufferGeometryUtils.mergeGeometries first, without creating groups, and then modify the resulting geometry to add the groups.
Just to check – you are aware that there’s almost no performance benefit to merging geometries, if you’re going to keep it divided into groups, right? Normally merging reduces draw calls, but not when groups are used. If you’re merging for non-performance reasons then carry on.
Yes, merging with a false and do it my selves is the way. I would prefer to add this code to the Utils as a third/extra mode.
And yes, just merging gives no extra performance. The next step would be to have a sort of the material indices, including sorting the attributes! And now at last merging the side by side groups with equal material index.
The old version of the ThreeJS Geometry did have all this abilities. Makes me kind of sad.
To mention what I do: I take 3D data form OSM.org and render buildings ways and all details. So I often have the same materials. Merging a whole tile of 200 m square, sorted by materials like walls and roof did give a much better performance.