How does BufferGeometry.addGroup() internally work?

I have a Draco3D Model that has to be rendered with different materials for each part.

What I used to do was to first load the whole geometry using DRACOLoader then create a new Mesh for each part by copying the section of buffer. But in this way calculating new index buffers used took up lots of CPU usage. So I sought a way in which I can share the buffer and render with range of index.

I tried usng BufferGeometry.addGroup(). It looked like exactly what I was looking for. By using the function I only had to make one mesh with array of materials. I expected much better performance. But the result was that it got little slower instead.

How is BufferGeometry.addGroups() implemented? Does it internally do exactly the same what I used to do and that’s why there was no performance differences?

All 3D objects of a scene which are going to be rendered are internally transformed into render items. Normally there is a 1:1 relationship. However, if a geometry has groups and multiple materials are applied to a 3D object, multiple render items are generated from a single 3D object. Eventually, you end up with the same number of render items.

1 Like

Do render items from the same group share the same VBO and IBO? Or do you mean each render item eventually allocate their own VBO and IBO and calculate a whole new index buffers, copy the section of original vertex buffer, doing exactly what I used to do?

Yes, they do. Only the draw range is different (the part of the buffer that is going to be rendered).