three.js r72不再支持THREE.LinePieces,如何将多个断开的行与THREE.LineSegments合并?

时间:2015-10-02 20:36:31

标签: javascript three.js

我刚更新为three.js r72,我在控制台收到有关THREE.LinePieces的以下警告......

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

如果我将THREE.LinePieces更新为THREE.LineSegments,则所有断开的线路都会连接。

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 :(

我是否希望为每个线段创建单独的几何图形(包含两个顶点),或者可以像使用LinePieces一样将多个线段合并为一个几何图形?

1 个答案:

答案 0 :(得分:12)

以下是使用单个绘制调用创建线段集合的模式。

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

three.js r.72