I'm currently working on developing a basic 3D game using three.js. My goal is to create colored cubes, but I'm encountering an issue where all the cubes are displaying the same color.
My cube creation code looks like this:
var geometry = new THREE.BoxGeometry(width, height, length);
var material = new THREE.MeshNormalMaterial({color: hexColor});
var cube = new THREE.Mesh(geometry, material);
(this code snippet is within a function)
I call this function twice, with hexColor values set to 0x0000ff (blue) and 0xff0000 (red). The cubes do render on the screen, however, each face of the cube appears to be a different color instead of uniform.
I also attempted:
cube.material.color.setHex();
But it throws an error message "Uncaught TypeError: Cannot read property 'setHex' of undefined"
Your assistance in resolving this issue would be greatly appreciated! Thank you.