合并多条断开的线

合并多条断开的线

本文介绍了Three.js r72 不再支持 THREE.LinePieces,如何用 THREE.LineSegments 合并多条断开的线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

尽管有警告,线路仍将显示为断开连接,但是,对于以下示例,如果我将 THREE.LinePieces 更新为 THREE.LineSegments,所有断开连接的线路都会连接起来.

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

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

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?

推荐答案

这是使用单个绘制调用创建线段集合的模式.

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

three.js r.72

这篇关于Three.js r72 不再支持 THREE.LinePieces,如何用 THREE.LineSegments 合并多条断开的线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 04:31