本文介绍了如何使用three.js从随机点制作3D对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我生成了10个随机点。我想将每个点连接到每个平面区域并获得面部。所以,它将会是一个漂亮的三维对象,里面有不可见的平面。如何从10个随机点的几何图形制作人脸?
var objects3 = [];
var geometrySpline = new THREE.Geometry(); (var i = 0; i x = Math.floor(Math.random()*(max-min + 1))+ min;
。
y = Math.floor(Math.random()*(max - min + 1))+ min;
z = Math.floor(Math.random()*(max - min + 1))+ min;
n = new THREE.Vector3(x,y,z);
objects3.push(n); (var x2 = 0; x2 }
为(var x = 0; x 。 x2 ++){
geometrySpline.vertices.push(objects3 [x]);
geometrySpline.vertices.push(objects3 [x2]);
$ / code $ / pre
解决方案 THREE.ConvexGeometry看起来像WestLangley建议的
这里有一个jsfiddle
I generate 10 random points. I want connect each point to every another and get faces for every flat area. So, it will nice 3D object with invisible flat faces inside.
How is it possible to make faces from geometry of 10 random points?
var objects3 = [];
var geometrySpline = new THREE.Geometry();
for ( var i = 0; i < 10; i ++ ) {
x = Math.floor(Math.random() * (max - min + 1)) + min;
y = Math.floor(Math.random() * (max - min + 1)) + min;
z = Math.floor(Math.random() * (max - min + 1)) + min;
n = new THREE.Vector3( x, y, z );
objects3.push( n );
}
for ( var x = 0; x < (objects3.length); x ++ ) {
for ( var x2 = 0; x2 < (objects3.length); x2 ++ ) {
geometrySpline.vertices.push(objects3[ x ]);
geometrySpline.vertices.push(objects3[ x2 ]);
}
}
解决方案 THREE.ConvexGeometry appears to work as WestLangley suggested
Here's a jsfiddle
http://jsfiddle.net/cwoodall22/bk3qx8ys/
这篇关于如何使用three.js从随机点制作3D对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!