4

I was like a line and other defined. My problem is I do not know how to dynamically so that a line is created from an object "a" to an object "b".

1 Answers1

7

Adapted from the Line example at http://threejs.org/docs/#Reference/Objects/Line -- assuming your objects a and b are there too, and in world coordinates (not parented):

var material = new THREE.LineBasicMaterial({
    color: 0x0000ff
});

var geometry = new THREE.Geometry();
geometry.vertices.push(
    a.position,
    b.position
);

var line = new THREE.Line( geometry, material );
scene.add( line );

That creates a line from a to b.

If your objects move, you can have just move those vertices in your update and say: geometry.verticesNeedUpdate = true.

antont
  • 2,676
  • 1
  • 19
  • 21