Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
322 views
in Technique[技术] by (71.8m points)

How to make 3D object from random points using three.js?

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 ]);
       }        
   }
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
THREE.ConvexGeometry  appears to work as   WestLangley suggested

Here's a jsfiddle

http://jsfiddle.net/cwoodall22/bk3qx8ys/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...