每个面具有K个顶点的三维点的三角剖分 [英] Triangulation of 3D points with K vertices per face

查看:144
本文介绍了每个面具有K个顶点的三维点的三角剖分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Three.js。我有一个 3D点(x,y,z)和一组面孔的集合。一张脸由 K点组成。它可以像凹面一样凸出。
我发现在Three.js文档中没有任何可以帮助我的东西。一种解决方案可能是对这些形状进行三角测量,但到目前为止我还没有找到任何简单的3D三角测量算法。

I'm working with Three.js. I have a collection of 3D points (x, y, z) and a collection of faces. One face is composed of K points. It can be as well convex as concave. I found nothing that could help me in the Three.js documentation. One solution could be to triangulate those shapes, but so far I haven't found any simple 3D triangulation algorithm.

另一种解决方案是做类似的事情:

The other solution would be doing something like that :

var pointsGeometry = new THREE.Geometry();

pointsGeometry.vertices.push(new THREE.Vector3(10, 0, 0));
pointsGeometry.vertices.push(new THREE.Vector3(10, 10, 0));
pointsGeometry.vertices.push(new THREE.Vector3(0, 10, 0));
pointsGeometry.vertices.push(new THREE.Vector3(1, 3, 0));
pointsGeometry.vertices.push(new THREE.Vector3(-1, 3, 0));
pointsGeometry.vertices.push(new THREE.Vector3(10, 0, 0));

var material = new THREE.MeshBasicMaterial({color: 0x00ff00});

var mesh = new THREE.Shape/ShapeGeometry/Something(pointsGeometry, material);
group.add(mesh);

scene.add(group);

我有很多这些形状一起构建一个封闭的表面。

I have a lot of these shapes that build together a closed surface.

有任何建议吗?

感谢您的关注。
祝你有愉快的一天。

Thank you for your attention. Have a nice day.

推荐答案

正如你所指出的,有两种方法可以实现这一目标:

As you pointed out, there are 2 ways to achieve that :


  • 使用3D三角测量算法(不是由Three.js提供);

  • 通常使用2D三角剖分算法用于Three.js Shape 在几何体的每个面上应用了一些变换的对象。

  • use a 3D triangulation algorithm (not provided by Three.js) ;
  • use the 2D triangulation algorithm normally used for Three.js Shape objects with some transformation applied upon each face of the geometry.

最后一个似乎很酷,但不幸的是,当我尝试时,我意识到这不是那么微不足道。我提出了类似于Paul-Jan所说的内容:

The last one seems cool but unfortunately, as I tried out I realized it's not that trivial. I came up with something similar to what Paul-Jan said :

对于几何体的每个面:


  1. 计算面部的质心;

  2. 计算面部法线;

  3. 计算面部矩阵;

  4. 将3D点投影到脸部的2D平面上;

  5. 创建几何体(使用 Shape 三角剖分算法);

  6. 将面矩阵应用于新创建的几何体

  7. 创建网格并将其添加到 Object3D (我尝试将所有几何图形合并为1,但它失败并带有 ShapeBufferGeometry

  1. Compute the centroid the face ;
  2. Compute the face normal ;
  3. Compute the matrix of the face ;
  4. Project the 3D points onto the 2D plane of the face ;
  5. Create the geometry (triangulated with the Shape triangulation algorithm) ;
  6. Apply the face matrix to the newly created geometry
  7. Create a Mesh and add it to an Object3D (I tried to merged all the geometries into 1, but it fails with the ShapeBufferGeometry)

检查这个小提琴

小心顶点的绕线顺序或将 THREE.Material.side 添加到 THREE.DoubleSide 以防止面孔被剔除。

Be careful to the winding order of your vertices or put the THREE.Material.side to THREE.DoubleSide to prevent faces from being culled.

这篇关于每个面具有K个顶点的三维点的三角剖分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆