Novice inquiry: I have generated some random points in JavaScript. How can I individually access each point later on? I remember something about an 'Object' that holds all the points, allowing me to manipulate their positions or selectively retrieve them. How can I achieve this in JavaScript?
Can someone explain what the line:
var dots = [];
is used for? Another person added a comment after that, but I'm having trouble understanding it.
How do I draw a line between two points (let's say the first and second from the list - index 0 and 1) in Three.js?
Advanced query: I have generated X (let's say 20) random points in JavaScript. I am exploring ways to create faces by grouping 3 points together and forming a mesh.
But rather than entirely randomly, I would like the faces to form a continuous mesh resembling a terrains poly-surface. What guidelines should I follow?
Refer to this image for clarification: https://i.sstatic.net/fVbKN.png
var numpoints = 20;
var dots = []; //Reserved for future use
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(dotGeometry);
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);
}