I am currently working on a project involving a cube with multiple textures, one for each face. Initially, I was able to change the color of the cube when hovering over it using a single texture. However, I now want to implement this functionality with a texture array.
if ( intersects.length > 0 )
{
// if the closest object intersected is not the currently stored intersection object
if ( intersects[ 0 ].object != INTERSECTED )
{
// restore previous intersection object (if it exists) to its original color
if ( INTERSECTED )
INTERSECTED.material.color.setHex( INTERSECTED.currentHex );
// store reference to closest object as current intersection object
INTERSECTED = intersects[ 0 ].object;
// store color of closest object (for later restoration)
INTERSECTED.currentHex = INTERSECTED.material.color.getHex();
// set a new color for closest object
INTERSECTED.material.color.setHex( 0x118D08 );
}
However, after making these changes, the color change on hover no longer works and I am encountering the following errors:
Uncaught TypeError: Cannot read property 'setHex' of undefined [repeated 13 times]
Uncaught TypeError: Cannot read property 'getHex' of undefined
Although the cube is correctly textured, it seems like there might be an issue with the MeshFaceMaterial not having a color parameter. I am unsure if what I am attempting is feasible or if I am overlooking something. Any insights or suggestions would be greatly appreciated.