three.js - How to change the color of a Mesh already in a scene -


i trying build first application using great three.js library.

i have cubes same color, change color of cube user click on.

can cange color of cube after instanciating it, or have delete , create new 1 ?

here trying do, can change position not color:

//...  var cube = new three.mesh(geometry, cubematerial); cube.scale.y = 1; cube.scale.x = 2; cube.position.x = 0; cube.position.y = 25; cube.position.z = 25; buildings.push(cube)  //...   buildings.foreach(function(building) {         if (1) {             building.color = 0xffffff; //doesn't change             building.position.x = 300; //works         }     });     render(); 

building.material.color.sethex( 0xffffff ); 

Comments