I have a code for a button that checks if the color of the triangle is white it deletes them, the issue is that I got the triangles but don’t know how to check if the triangle has a specific color, but right now the function is deleting all the triangles there are in the scene. Here’s the code:
function deletetriangle() {
if (mesh) {
let colorAttr = mesh.geometry.getAttribute("color");
let indexAttr = mesh.geometry.index;
for (let i = 0; i < indexAttr.count; i++) {
let r = colorAttr.array[i * 3];
let g = colorAttr.array[i * 3 + 1];
let b = colorAttr.array[i * 3 + 2];
if (r === 255 && g === 255 && b === 255) {
indexAttr.array = 0
}
}
indexAttr.needsUpdate = true;
}
}