My goal is to modify the color of two cubes based on a certain variable. I have created both cubes and intend to adjust their color according to how close or far they are from each other.
The cubes were generated using the following code:
geometry = new THREE.CubeGeometry( 50, 50, 50 );
material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } );
cube = new THREE.Mesh( geometry, material );
scene.add( cube );
I attempted this approach:
if(distance > 20)
{
cube.material.color = 0xffffff;
}
Unfortunately, this method did not produce the desired outcome. I searched through various examples but couldn't find a suitable solution.