hely
hely

Reputation: 11

I want to change the cube color, which is created by three.js

I've created a cube like this

cube = new THREE.Mesh(
                     new THREE.CubeGeometry(50,20,50),              
                     new THREE.MeshLambertMaterial({color: 0x6699ff}) 
                );
                scene.add(cube);
                cube.position.set(80,32,40);

But I want to change the color of the cube, how could I do?

Any help would be appreciated. Thanks

Upvotes: 1

Views: 1813

Answers (1)

ThisIsSparta
ThisIsSparta

Reputation: 1307

You can use this function:

    var color = 0x421575; // Your color
    cube.material.color.setHex( color );

The result is shown in those fiddles:

Hope this helps.

Upvotes: 1

Related Questions