0

I am trying to put some color on vertices but the colors do not appear. I am using Three.js library. This is the function example I am using:

function parserExpose(arr) {
    var geometry = new THREE.PlaneGeometry(60, 60, arr.x - 1, arr.y - 1);

    for (var i = 0, l = geometry.vertices.length; i < l; i++) {
        geometry.vertices[i].z = (arr.topo[i].topoValues / 65535 * 2470);
        geometry.vertices[i].color = new THREE.Color(Math.random() * 0x00ffff);
    }
    geometry.colorsNeedUpdate = true;
    geometry.needsUpdate = true;
    geometry.__dirtyVertices = true;
    geometry.__dirtyNormals = true;
    geometry.computeBoundingSphere();
    //vertexColors: THREE.VertexColors
    //THREE.FaceColors 
    var plane = new THREE.Mesh(geometry, new THREE.MeshBasicMaterial({vertexColors: THREE.VertexColors, wireframe: true, wireframeLinewidth: 3}));

    scene.add(plane);

}

If I use geometry.faces[] I can change the color but I only want to change on vertices not the faces.

Thx in advance. :)

bloodyKnuckles
  • 11,551
  • 3
  • 29
  • 37
  • Vertices don't have anything to color, they don't have any meshes associated with them. – Brennan Mar 09 '15 at 17:46
  • 1
    @Brennam How can i get the faces that are associated with vertice? exist one way to do that? :/ – Mário Balfas Mar 09 '15 at 17:49
  • You can't. Vertices are infinitely small representations of a point. If you want to color them, add a geometry/mesh at the same location and associate to the vertex. – Brennan Mar 09 '15 at 17:53
  • What are you trying to achieve exactly? It sounds like you want a particle system or point cloud – 2pha Mar 10 '15 at 04:45
  • @2pha For now i only want to color the vertices. i was able to do that with this [example](http://stackoverflow.com/questions/10330342/threejs-assign-different-colors-to-each-vertex-in-a-geometry). But the next achive will be to do some point cloud. You have some examples of that? :) – Mário Balfas Mar 10 '15 at 09:29
  • http://threejs.org/examples/#webgl_interactive_raycasting_pointcloud – 2pha Mar 11 '15 at 04:26

0 Answers0