I'm attempting to create a multitude of objects simultaneously while aiming for the color to gradually fade. Nonetheless, despite using .toString(16)
to form a string, there seems to be an issue with this line of code:
new THREE.MeshBasicMaterial({ color: '0x' + color, wireframe: false, opacity: 0.5 });
Presently, here's the code:
for (var i = 0; i < 10; i++) {
for (var j = 0; j < 10; j++) {
for (var k = 0; k < 10; k++) {
geometry = new THREE.CubeGeometry(50, 50, 50);
colorr = 254 / 10 * k;
colorr = Math.round(colorr);
colorr = colorr.toString(16);
colorg = 254 / 10 * k;
colorg = Math.round(colorg);
colorg = colorg.toString(16);
colorb = 254 / 10 * k;
colorb = Math.round(colorb);
colorb = colorb.toString(16);
color = '0x' + colorr + colorg + colorb;
material[i] = new THREE.MeshBasicMaterial({ color: color, wireframe: false, opacity: 0.5 });
mesh[i] = new THREE.Mesh(geometry, material[i]);
mesh[i].position.x = -500 + (k * 100);
mesh[i].position.y = -500 + (j * 100);
mesh[i].position.z = -500 + (i * 100);
scene.add(mesh[i]);
objects.push(mesh[i]);
}
}
}
Unfortunately, the end result is simply a dull greyish black color.