I am looking to implement picking functionality using IdMapping in Three.js
Due to concerns about performance, I have a single large geometry that is calculated as follows:
for (var i = 0; i < numberOfVertices; i += 9) {
p1 = new THREE.Vector3(graphData.triangles.vertices[i+0], graphData.triangles.vertices[i+1], graphData.triangles.vertices[i+2]);
p2 = new THREE.Vector3(graphData.triangles.vertices[i+3], graphData.triangles.vertices[i+4], graphData.triangles.vertices[i+5]);
p3 = new THREE.Vector3(graphData.triangles.vertices[i+6], graphData.triangles.vertices[i+7], graphData.triangles.vertices[i+8]);
geometry.vertices.push(new THREE.Vertex( p1.clone() ));
geometry.vertices.push(new THREE.Vertex( p2.clone() ));
geometry.vertices.push(new THREE.Vertex( p3.clone() ));
geometry.faces.push( new THREE.Face3( i/3, i/3+1, i/3+2 ) );
geometry.colors.push(new THREE.Color(0xFF0000));
geometry.colors.push(new THREE.Color(0xFF0000));
geometry.colors.push(new THREE.Color(0xFF0000));
}
geometry.computeFaceNormals();
var material = new THREE.MeshBasicMaterial({});
var triangles = new THREE.Mesh( geometry, material );
scene.add(triangles);
Is there a way for me to assign unique colors to each vertex within my geometry?