Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

three.js r72 no longer supports THREE.LinePieces, how to merge multiple disconnected lines with THREE.LineSegments?

I just updated to three.js r72 and I am getting the following warning in console concerning THREE.LinePieces ...

THREE.Line: parameter THREE.LinePieces no longer supported. Created THREE.LineSegments instead.

The lines will appear disconnected dispite the warnings, however, for the following example, if I update THREE.LinePieces to THREE.LineSegments all disconnected lines become connected.

var lineMaterial = new THREE.LineBasicMaterial({color: 0x000000, linewidth: 1});
var lineGeom = new THREE.Geometry();
var xstrt = 0;
for (nn=0; nn<numLines; nn++)
{
    lineGeom.vertices.push(new THREE.Vector3(xstrt, -5, 0));
    lineGeom.vertices.push(new THREE.Vector3(xstrt, 5, 0));
    xstrt += 5;
}
var Line  = new THREE.Line(lineGeom, lineMaterial, THREE.LinePieces); // seperate lines, but with warnings
//var Line  = new THREE.Line(lineGeom, lineMaterial, THREE.LineSegments); // connected as one line only :(

Am I expected to create separate geometries (containing two vertices) for each line segment or is it possible to merge multiple line segments into one geometry as I had with LinePieces?

like image 614
o1sound Avatar asked Oct 02 '15 20:10

o1sound


1 Answers

Here is the pattern to follow to create a collection of line segments with a single draw call.

var line = new THREE.LineSegments( geometry, material );

three.js r.72

like image 190
WestLangley Avatar answered Oct 22 '22 09:10

WestLangley