Beginner question: I create some random points in java script. How can I later "call" each single one of them? I believe it was called an Object (the list of all points), where I can manipulate their position in the list or "pull" the ones I need. How do I do that in js?
what is the line:
var dots = []; for? The comment after that was added from another person and I don't get it.
How can I make a line between two points (let's say the first and second from the list - the 0 and the 1) in Three.js?
More complicated question: I create here X (in this case 20) random points in java script. I am trying to figure out a way to randomly create faces using groups of 3 points and form a mesh.
Well, not so randomly, because I need a result, where all faces bind together in a continuous mesh. The result should look like a terrain poly-surface made out of the many vertex points.
var numpoints = 20;
var dots = []; //If you want to use for other task
for (var i = 0 ; i < numpoints ; i++){
var x = Math.random() * (80 - 1) + 1 //Math.random() * (max - min) + min
var y = Math.random() * (80 - 1) + 1
var z = Math.random() * (10 - 1) + 1
var dotGeometry = new THREE.Geometry();
dots.push(dotGeom etry);
dotGeometry.vertices.push(new THREE.Vector3( x, y, z));
var dotMaterial = new THREE.PointCloudMaterial( { size: 3, sizeAttenuation: false, color: 0xFF0000 } );
var dot = new THREE.PointCloud( dotGeometry, dotMaterial );
scene.add(dot);
}
Aucun commentaire:
Enregistrer un commentaire