如何从three.js中的一系列3D点创建3D多边形? [英] How do I create a 3D polygon from a series of 3D points in three.js?

查看:28
本文介绍了如何从three.js中的一系列3D点创建3D多边形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道在 Three.js 中给定一组 3D 点,生成自定义 3D 多边形的最佳方法是什么.它是一个没有孔的简单多边形.这些点是有序的,以便它们代表相邻的顶点.我可以在 2D 中进行,但我不不希望顶点共面.感谢您的帮助!

I wonder what would be the best way to generate a custom 3D polygon given an array of 3D points in three.js. It is a simple polygon without holes. The points are ordered so that they represent neighboring vertices.I can do it in 2D, but I don't want the vertices to be coplanar. Thank you for your help!

推荐答案

这里的主要问题是如何从一堆点创建 3D 网格.换句话说:你需要弄清楚哪些顶点应该连接起来形成一个三角形.

The main problem here is how to create a 3D mesh from a bunch of points. In other words: you need to figure out which of the vertices should be connect to form a triangle.

这是一件令人惊讶的复杂的事情(好吧,至少我很惊讶)并且有大量的科学论文、图书馆等等.

This is an surprisingly complicated thing to do (well, at least I was surprised) and there are tons of scientific papers, libraries and so on about that.

但是,在您的情况下,它更简单一些,因为您已经大致知道顶点应该如何连接.我建议您查看 earcut-librarylibtess.js,两者都应该能够创建您需要的三角剖分.

However, in your case it is a bit simpler as you already know roughly how the vertices should get connected. I would recommend you have a look at the earcut-library or libtess.js, both of which should be able to create the triangulations you need.

一旦你有了它,你就可以大致遵循@lior-trau's关于如何从结果.

Once you have that, you can roughly go with @lior-trau's recommendation for how to create the geometry from the result.

这篇关于如何从three.js中的一系列3D点创建3D多边形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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