Reputation:
I'm trying to put a light in the entire scene to cast shadows. I have a problem because they do not like changing the color of the material. And the shadows do not appear. how I can change the color of a MeshLambertMaterial material after adding it to the scene, and why not show me the light and shadows that should generate ?. When I try to change the color of the material I get all black.
This is the code that I have:
material = new THREE.MeshLambertMaterial( { color: "#FFFFFF",name:$scope.datosMunicipio[i].nombre} );
objMesh = new THREE.Mesh( extrude_geometrY, material );
objMesh.receiveShadow = true;
var lightAmbient = new THREE.AmbientLight(0x000000);
scene.add(lightAmbient);
var luzDireccional = new THREE.DirectionalLight(0x000000,1);
luzDireccional.position.set(1,1,1).normalize();
scene.add(luzDireccional);
objMesh.material.color.set("#FF0000"); //Ineed change the color
Upvotes: 0
Views: 79
Reputation: 262
I think you should change the color of the light. MeshLambertMaterial or MeshPhongMaterial are not effective to colors unless we externally add lights to it.
Upvotes: 0
Reputation: 4494
Use setHex
to apply a color in hex-notation:
objMesh.material.color.setHex( 0xFF0000 );
However you can set
a THREE.Color
like this:
var redColor = new THREE.Color( 0xFF0000 );
objMesh.material.color.copy( redColor );
Read more about colors: http://threejs.org/docs/#Reference/Math/Color
Upvotes: 0