Hi.
I am using Geometry.mergeVertices method and I have realized that colors are not properly mapped after merging.
In my case I have a IndexedBufferGeometry which I convert into a geometry with:
geometry = new THREE.Geometry().fromBufferGeometry( geometry );
After doing this colors i Geometry are ok.
But after applying mergeVertice they don’t.
geometry.mergeVertices();
It seems that this method doesn’t take in mind colors.
Is there any fix for this?
Best regards
Any chances to demonstrate this issue with a live example ? Right now, it’s hard to understand the expected and actual visual result.
Hi.
Today I will try to push a live example.
It’s quite easy to demonstrate with a merged BufferGeometry composed of multiple bufferGeometries with different colors.
Best regards
mergeVertices
in the BufferGeometryUtils
example should (if I remember right) account for multiple vertex attributes in a geometry and correctly retain vertex colors:
mem += indices ? indices.count * indices.itemSize * indices.array.BYTES_PER_ELEMENT : 0;
return mem;
},
/**
* @param {BufferGeometry} geometry
* @param {number} tolerance
* @return {BufferGeometry>}
*/
mergeVertices: function ( geometry, tolerance = 1e-4 ) {
tolerance = Math.max( tolerance, Number.EPSILON );
// Generate an index buffer if the geometry doesn't have one, or optimize it
// if it's already available.
var hashToIndex = {};
var indices = geometry.getIndex();
var positions = geometry.getAttribute( 'position' );
var vertexCount = indices ? indices.count : positions.count;
I think in general it’s considered best to not use Geometry
if you can avoid it.
1 Like
Hi
Very sorry for the delay.
I have been on vacations in a place with no internet connection. Really nice.
: )
I will try this option and will keep you informed,
Best regards