javascript - Threejs IcosahedronGeometry vertex color -


i trying change color of selected vertex dynamically. referring https://jsfiddle.net/pmankar/m70cpxes/, created icosahedrongeometry point cloud geometry , on click event change color of vertex 100.

document.addeventlistener('click', function() {   mesh.geometry.colorsneedupdate = true;   mesh.geometry.colors[100] = new three.color("rgb(255,0,0)");   console.log(mesh.geometry); }) 

now, have 2 questions:

  1. how make vertex 100 change colors
  2. why showing random color point cloud

you declared var material, created materail = new three.pointsmaterial(); , applied material again mesh. there's typo: material != materail.

also, have different colors of vertices have set colors of them

  geometry = new three.icosahedrongeometry(102, detailslevel);    var colors = [];   geometry.vertices.foreach(function(){     colors.push(new three.color(0xffffff));   });   geometry.colors = colors; 

and in material have set vertexcolors three.vertexcolors

material = new three.pointsmaterial( { size:4, vertexcolors: three.vertexcolors} ); 

after all, in "click" event listener can do

mesh.geometry.colors[100].set(0xff0000); mesh.geometry.colorsneedupdate = true; 

jsfiddle example


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -