Mesh Material Color rendering as undefined

I’m new to three.js and am trying to generate a simple cube with randomly colored faces. In my cubeMaterials array I assign each face like such new THREE.MeshBasicMaterial({color: colorArray[0], transparent:true, opacity:0.8}),… However when the cube renders it renders as all dark / grey. I’ve tried changing the colors via their RBG properties to no luck either. Is this a simple fix or am I missing something altogether??

Here’s a link to the JS Fiddle Link here

works for me
var cubeMaterial = new THREE.MeshNormalMaterial(cubeMaterials);

Out of curiosity, what revision of three.js are you using?


UPDATE:

It is a very old version, the THREE.MeshFaceMaterial is long outdated.

Your program code looks quite complicated for a three.js beginner. Are you working from a template?

Take a look at the example ColorIndividualFaces from the Collection of examples from discourse.threejs.org.

1 Like

cheers! thank you. working now after a few modifications. also super resourceful collection!