I’m attempting to create a mesh with indexed bufferGeometry. It needs to have vertex colors with an alpha channel. I’m doing something like this (summarized):
thisColor = thisMaterial.color;
var vertexColors = [];
for (jj=0; jj<vertexCount; jj++) {
vertexColors[4*jj+0] = thisMaterial.color.r;
vertexColors[4*jj+1] = thisMaterial.color.g;
vertexColors[4*jj+2] = thisMaterial.color.b;
vertexColors[4*jj+3] = 1.0;
}
var myColorAttribute = new THREE.Float32BufferAttribute(vertexColors, 4);
var newGeometry = new THREE.BufferGeometry();
newGeometry.setAttribute( 'color', myColorAttribute );
thisMaterial.vertexColors = true
thisMaterial.needsUpdate = true;
newGeometry.attributes.color.needsUpdate = true;
Excuse the archaic coding style (My name says it all)
Does it look OK?
Thanks