How to allow duplicate vertices in ExtrudeGeometry?

I’m creating an extruded geometry using an array of shapes and would like to assign bones for each shape.

Disclaimer: Figures are created in blender just because it was easier for me to create sample shapes in it.

Below are the shapes that I want to draw. I’ll be drawing them using THREE.Shape

They should be joined into one geometry just like this image below

Then have these characteristics. The red lines representing a cut and blue line representing where it should fold.


Problem is, the vertices that fall under the edges highlighted by the red lines are treated as one therefore I am not able to separate them and animate.

I need ExtrudeGeometry to treat them as separate vertices for me to be able to assign different bones to them and animate them. Is this possible? If not, do you have any proposed approach to achieve my goal?

I think I’m not able to reproduce:

In the fiddle, an instance of ExtrudeBufferGeometry is created with two shapes. The resulting 3D shapes do not share any vertices.

I was creating an ExtrudeGeometry, not ExtrudeBufferGeometry.

My algorithm is to first create an ExtrudeGeometry, assign skinIndices and skinWeights, then convert it to ExtrudeBufferGeometry.

I built it this way since it is easier to assign skinIndices and skinWeights for ExtrudeGeometry since it is indexed which makes it easier for me to track the vertex indices. As opposed to ExtrudeBufferGeometry which is non-indexed, which means the sequence of vertices in the position attribute is all over the place.

The fiddle uses now ExtrudeGeometry:

This does not change the fact that the vertices of the 3D shapes are not shared.

The shapes on the fiddle does not share any vertex at all. Try drawing two shapes where some of the vertices on both shape have the same coordinates.

1 Like

Ah, good point! The vertices are merged because of the following line in ExtrudeGeometry:

The geometry generator can not distinct between different shapes when merging vertices.

1 Like

Is it important to merge the vertices? Would it break other features if this method call is not included? If not, maybe we could add a parameter to ExtrudeGeometry to optionally disable merging of vertices

Yes, in order so save memory by achieving a real indexed geometry.

It would break the code for users who rely on this feature.

Then you have to do this for all geometry generators in order to have a consistent API. I personally vote against this since you can easily to this in your app.

const geometry = new THREE.Geoemtry().fromBufferGeometry( new THREE.ExtrudeBufferGeometry( shapes, options ) );

This is the same like above but without merging the vertices.