Currently, I am working on creating a pattern using Three.js
. The goal is to change the color of a face to gray when the user hovers over it with the mouse, and then revert it back to its original light blue color when the mouse moves away. Unfortunately, this functionality is not working as expected. Below is the snippet of code that I suspect is causing the issue:
if (intersects.length > 0) {
if (intersects[0].object != INTERSECTED) {
if (INTERSECTED) {
INTERSECTED.face.color.setRGB(INTERSECTED.currentRGB);
}
INTERSECTED = intersects[0];
INTERSECTED.object.currentHex = INTERSECTED.object.material.color.getHex();
INTERSECTED.face.color.setHex(0x777777);
INTERSECTED.object.geometry.colorsNeedUpdate = true;
}
} else {
if (INTERSECTED) {
INTERSECTED.material.color.setRGB( INTERSECTED.currentRGB );
}
INTERSECTED = null;
}
My suspicion is that the issue lies within the targetList = []
part of the code, as I noticed that nothing seems to be stored inside it when I log it using console.log()
. You can view the full code in this Fiddle. Can you spot where I may be going wrong?
Thank you in advance for any insights you may have!