Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用THREE.JS中的其他顶点更新网格的几何体_Javascript_Three.js_Mesh - Fatal编程技术网

Javascript 使用THREE.JS中的其他顶点更新网格的几何体

Javascript 使用THREE.JS中的其他顶点更新网格的几何体,javascript,three.js,mesh,Javascript,Three.js,Mesh,我有几个网格,每个网格大约有5000个顶点。这些是原始顶点,称为“verticesA”。问题是运行以下行时会延迟: shapeFigure[x] = new THREE.Shape (geometry [x] .vertices); // Very slow. 然后在网格中变换“形状[x]” shape[x] = new THREE.ShapeGeometry( shapeFigure[x][x] ); mesh[x] = new THREE.Mesh (shape[x], new THREE

我有几个网格,每个网格大约有5000个顶点。这些是原始顶点,称为“verticesA”。问题是运行以下行时会延迟:

shapeFigure[x] = new THREE.Shape (geometry [x] .vertices); // Very slow.
然后在网格中变换“形状[x]”

shape[x] = new THREE.ShapeGeometry( shapeFigure[x][x] );
mesh[x] = new THREE.Mesh (shape[x], new THREE.MeshLambertMaterial ({color: "# FF0000"}));
这是显而易见的,因为它们是具有多个顶点的多个网格。我的alplicación中有一个按钮,可以生成一个算法。该算法只生成新的顶点(我称为verticesB,这些顶点的长度与“verticesA”相同)。我想用“verticesB”更新“verticesA”

我如何更新以“verticesB”形式显示的“verticesA”。 我不想再次使用“
new THREE.Shape
…”,因为它被延迟了(因为我有许多具有许多顶点的网格)。我想直接将verticesA更新为verticesB(速度更快)

我在做这样的事情:

//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)

如何正确更新几何体?

是否使用ShapeGeometry或ExtradeGeometry创建网格?你确定你的观点顺序正确吗?@uhura我没有用你说的任何一个。“new THREE.Shape”然后是“new THREE.Mesh”。。我在文档或示例中没有发现可以使用new THREE.Shape作为几何体,当我尝试制作示例时,出现了错误。怎么样了?@uhura对不起!。是的,我用了“新三.形状测量”我更新了邮政编码。那么你明白我想要什么了吗?你确定生成的verticesB顺序正确吗?您是否尝试使用它们创建形状(而不是更新顶点)?当您尝试更新顶点时,形状是否扭曲?