查找顶点的相邻顶点

Find neigbouring vertices of a vertex

我正在做一个项目来寻找一个顶点的相邻顶点,例如在一个特定顶点(Xi、Yj、Zk)的矩形网格中,相邻顶点将是

Xi+1 , Yj , Zk (right vertex)
Xi-1 , Yj , Zk (left vertex)
Xi , Yj+1 , Zk (top vertex)
Xi , Yj-1 , Zk (bottom vertex)
Xi , Yj , Zk+1 (front vertex)
Xi , Yj , Zk-1 (back vertex)

但是三角网格怎么可能找到。 有没有代码可以找到它们附近或一定范围内的顶点。

我目前正在使用 js 脚本,特别是 three.js 脚本 我加载了一个 3d obj 模型,它将是一个缓冲区几何。然后我使用它的几何属性得到了网格的顶点。现在对于每个顶点我想找到它连接的顶点......就像找到给定顶点共享其边的顶点...... 任何小的引用都会有很大的帮助。 提前致谢

Is there any code availabe to find the vertices near them or within a certain range.

不,至少不在存储库中。但是,您可以自己实现一个基本的解决方案。这个想法是创建一个 THREE.Sphere for representing the concept of neighborhood. The center property would be your vertex and radius property would be your range. You can then iterate over all other vertices and call THREE.Sphere.containsPoint() 的实例来验证顶点是否位于定义的邻域内。

three.js R115

Three.js 没有开箱即用的东西,但有一个脚本您可以修改以获得所需的结果。

SubdivisionModifier needs to compare adjacent vertex positions to calculate position averages. In order to achieve this, it converts a BufferGeometry to a Geometry

geometry = new THREE.Geometry().fromBufferGeometry( geometry );

然后它使用每条边来查找连接到该边的两个三角形(面)。您可以在其 source code, line 216 中看到这一点。如果您将此脚本复制粘贴到您的源代码中,您可以进行修改以执行您想要的操作:

  1. 仅搜索连接到顶点的边。
  2. Return 那些边的另一边的顶点。

我知道这不是一个完整的答案,但这是我能想到的最接近解决您问题的建议。