BufferGeometry is not rendering correctly

I am programatically generating a mesh using buffergeometry but I’m having issues when viewing the rendered output. The mesh generated with wireframe material seem to be different when wireframe is set to false.

wireframe: true

wireframe: false

What do you think is causing this issue?
I am using Three JS version 98. Also tried it with other versions but problem still happens

Here’s a sample pen for the problem

You indices are correct actually. So is the rest of logic, to a certain extent.

The problem is that you are setting the geometry indices wrong. If you replace

geometry.setIndex(new THREE.BufferAttribute(new Uint8Array(indices), 3) );


geometry.setIndex( indices );

You can see that it renders the full quad properly.


You’re right. Thanks.

Although, the docs said it’s accepting BufferAttribute as a parameter.

You are absolutely correct, because it does. Changing the itemSize to 1, solves the issue as well.

That’s what setIndex() does internally. It checks if it’s a regular Array typed parameter, if it is… It converts to a BufferAttribute with itemSize 1.

1 Like

Thanks for the info!