I am new to Three.js, I have been trying to change the color of the line when a button is clicked which I have created using line basic material, but the color of the line is not getting changed.
my code
if (color === "color") {
material = new THREE.LineBasicMaterial({
color: 0xff0000,
opacity: 1,
linewidth: 5
});
} else {
material = new THREE.LineBasicMaterial({
color: 0x000000,
opacity: 1,
linewidth: 1
});
}
var tmp_geo = new THREE.Geometry();
tmp_geo.vertices.push(new THREE.Vector3( -10, 0, 0 ));
tmp_geo.vertices.push(new THREE.Vector3( 10, 0, 10 ));
line = new THREE.Line(tmp_geo, material);
line.material.needsUpdate = true;
line.geometry.colorsNeedUpdate = true;
line.scale.x = line.scale.y = line.scale.z = 1;
line.originalScale = 1;
geometries.push(tmp_geo);
scene.add(line);
I am using webGlRenderer with Trackball controls and my version is r66. Is there anyway to do this. I have been trying to find a solution to fix this. Please any help will be helpful.
Thanks in advance