Three.js drawing line between two particles

I have a bunch of particles that I draw on a canvas. I am using the following code:

var geometry = new THREE.Geometry();

nodeSet.forEach(function (value, index) {

    if (value.Name.indexOf("p(") == "0") {
       particle = new THREE.Particle(protien);
    } else { particle = new THREE.Particle(material); }

    particle.ID = value.ID;
    particle.position.x = value.Xpos;// Math.random() * 2 - 1;
    particle.position.y = value.YPos; //Math.random() * 2 - 1;
    particle.position.z = Math.random() * 2 - 1;
    particle.position.normalize();
    particle.position.multiplyScalar(Math.random() * 10 + 450);
    particle.scale.x = particle.scale.y = 5;
    scene.add(particle);

    geometry.vertices.push(particle.position);
});

      

Now I would like to draw a line connecting two particles based on the .ID particle. Can someone help and point me in directions on how to do this?

+3


source to share


1 answer


This example should be a good guide:
http://mrdoob.github.com/three.js/examples/canvas_lines.html



+2


source







All Articles