Best way to render a collection of isloated lines


I am trying to render some isolated lines in vtk js. I have a collection of point pairs, each of which I would like to connect with lines.

The only example I have seen is something like the following;

  const pointPolydata = vtkPolyData.newInstance();
  pointPolydata.getPoints().setData(Float32Array.from(points), 3);
  const lines = new Uint32Array(points.length + 1);
  for (let i = 0; i < points.length; i++) {
    lines[i] = i;


However what I end up with is one line connecting all of the points, which is not what I want.

I could repeat the above for each of the point pairs, but I believe that would require adding multiple actors to the scene, which feels like overkill?

Any help would be much appreciated


You can get your isolated lines by specifying several line cells. For instance, the below code draws lines between point indices (0,1), (2,3), and (4,5). A single line is of the form 2, <startPtIdx>, <endPtIdx>.

  2, 0, 1,
  2, 2, 3
  2, 4, 5