Adding points/drawCount for Line2 dynamically


I’m trying to solve the problem using a line with width (Line2 currently) and I need to update the line, like driving a car passing several points and leaving the trajectory.

I think for the basic THREE.line case, the problem is easy using drawCount as in Edit fiddle - JSFiddle - Code Playground.

But I’m wondering if this is achievable using Line2.

Hi Frank,
Maybe this link can help You.


Thanks for the reply. I’ve tried this Line2 example, but I want to add new points to this line dynamically without create a new Line2 instance.


One solution is to recreate the geometry of the line, not the line itself:

// creating the Line2 instance
var line = new Line2( new LineGeometry( ), material );

// at some later point, updating the line
// by recreating only its geometry
line.geometry = new LineGeometry( );
line.geometry.setPositions( points );

Here is a live demo, see lines 57-58:


Another alternative, I guess, is to start with a large vertex buffer, but use only a part of it. Thus you will have preallocated space for all future vertices, but will use only the ones that are visible. This will eliminate the need to recreate of the geometry.

1 Like

Hi Frank,

I made a new experiment with fat lines that can be an alternative for You:

Maybe this new page can help: