Maybe a newbie question but i'd like to use a random variable several times in my code, but of course it reminds the same for all parameters using it. How could I fix it ?
Example :
var randomColor = [yellow, blue, green][Math.floor(Math.random() * 3)]
const cube1 = new THREE.Mesh(geometry, randomColor);
scene.add(cube1);
const cube2 = new THREE.Mesh(geometry, randomColor);
scene.add(cube2);
Those two cubes will have to same material (named randomColor) even if it is random. Thank you in advance !
Aucun commentaire:
Enregistrer un commentaire