Instancing merged geometry

I have 3 BufferGeometries, 2 indexed and 1 is not.
I’m looking into combining them into a single geometry and instance it.
I’m having few issues with that:

  1. Each shape should have it’s own color
  2. Potentially (a flag?) I need to make the 2nd geometry invisible (I suppose that can be done using an instance attribute?)
  3. BufferGeometry doesn’t support merging indexed with non-indexed geometries.

Is there another way?
Maybe there is an example of combining multiple geometries with instancing?

Since you are going to use instanced rendering, you have to control the color via an instanced attribute. Same for the visibility control.

You could use BufferGeometry.toNonIndexed to create a non-indexed version of your two geometries. After that, the merge should work. Is this approach acceptable to you?

AFAIK, no.

I suppose that should work, but how do i control each shape with an instance attribute?
The geometry is now going to be merged and i have no notion of each shape.
Maybe I was misunderstood, think about a line with 2 connected boxes (on each side);
Say I merge those together, how can i give each box a different color and the line a different color?

I’ve never had this case when using instanced rendering. But i guess you need to find a way to create an instanced attribute “color”. Another solution is maybe the usage of a texture. These are the only options i can think of right now…

1 Like