Hey there, I'm just starting out with Three.js and I've been having trouble changing the color of a line when a button is clicked. I've created the line using Line Basic Material, but for some reason, the color isn't updating as expected.
Here's 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'm using WebGLRenderer with Trackball controls and my version is r66. If anyone has any suggestions on how to make this work, I'd really appreciate it. I've been searching for a solution with no luck so far.
Thanks so much in advance!