Hi there, i have a strange problem. I create a custom BufferGeometry (made by myself, it’s called CustomWireframeGeometry) to create a sort of wireframe of quads for meshes. In this geometry i set only position and color attributes and then i construct a LineSegments mesh. After that i want to change colors of the edges of this geometry on hover with raycasting.
I’m able to get the index of the edge to change vertices color, but it doesn’t work.
These piece of codes may help:
//create the custom wireframe
const geometry = new THREE.BoxGeometry( 20, 20, 20 );
const wireframe = new CustomWireframeGeometry( geometry ); //custom geometry that extends BufferGeometry
var lineMaterial = new THREE.LineBasicMaterial({color: 0xffffff,vertexColors: true});
const line = new THREE.LineSegments( wireframe,lineMaterial );
...
//and then on intersection from the raycaster i call this function
setLineColor : function(intersected,color){ //intersected is the intersected object of the raycaster
var index = intersected.index;
const colorAttribute = intersected.object.geometry.getAttribute("color");
colorAttribute.setXYZ(index,color.r,color.g,color.b);
colorAttribute.setXYZ(index + 1,color.r,color.g,color.b);
colorAttribute.needsUpdate = true;
}
As you can see i set needsUpdate to true for the color attribute, but nothing changes…
Can anyone help me please?
Thank you very much in advance