在THREE.JS中更新网格的几何与其他顶点

时间:2015-10-05 03:55:52

标签: javascript three.js mesh

我有几个网格,每个网格大约有5000个顶点。这些是原始顶点并调用“verticesA”,问题是它被延迟运行以下行:

shapeFigure[x] = new THREE.Shape (geometry [x] .vertices); // Very slow.

然后在网格中转换“shape [x]”。

shape[x] = new THREE.ShapeGeometry( shapeFigure[x][x] );
mesh[x] = new THREE.Mesh (shape[x], new THREE.MeshLambertMaterial ({color: "# FF0000"}));

这是显而易见的,因为它们与许多顶点有许多网格。我的alplicación中有一个按钮,可以生成算法。该算法仅生成新顶点(我将调用顶点B,这些顶点与“顶点A”具有相同的长度)。我想用“verticesB”更新“verticesA”。

我如何更新“verticesA”,该图形以“verticesB”的形式出现。 我不想再次使用“new THREE.Shape ...”,因为它被延迟了(因为我有许多具有许多顶点的网格)。我想直接更新顶点A到顶点B,(它更快)

我正在做这样的事情:

//mesh-> is the original (verticesA)

http://imgur.com/ympHorb (verticesA)

//geometry[x]-> is a array with the new vertices (verticesB)

//geometry[x] and mesh[x] is the same length of vertices

for (var a in mesh[x].geometry.vertices) {
 mesh[x].geometry.vertices[a].x=geometry[x][a].x;
 mesh[x].geometry.vertices[a].y=geometry[x][a].y;
}

在我的函数render()中,我有:

for (var t in mesh){

  mesh[t].geometry.verticesNeedUpdate=true;
  mesh[t].geometry.dynamic = true;
}  

这是一张地图,但是在运行上面的代码并且更新后却被扭曲了。问题是没有正确更新几何体。

http://imgur.com/qCWoMWe

地图应该是这样的:

http://imgur.com/MYXzaEd (this is verticesB)

如何正确更新几何体?

0 个答案:

没有答案
相关问题