xxxxxxxxxx
85
let numero_punti = 60;
let x = [numero_punti];
let y = [numero_punti];
let z = [numero_punti];
let target_x = [numero_punti];
let target_y = [numero_punti];
let target_z = [numero_punti];
function setup() {
createCanvas(600, 600, WEBGL);
for(let i = 0; i < numero_punti; i++) {
x[i] = 0;
y[i] = 0;
z[i] = 0;
target_x[i] = floor(random(width));
target_y[i] = floor(random(height));
target_z[i] = floor(random(height));
}
}
function draw() {
background(100);
orbitControl();
normalMaterial();
for (let i = 0; i < numero_punti; i++) {
if (i < (numero_punti - 1)) {
stroke(0);
strokeWeight(8);
point(x[i], y[i], z[i]);
strokeWeight(1);
line(x[i], y[i], z[i], x[i + 1], y[i + 1], z[i + 1]);
//lunghezza[i] = calcola_lunghezza(x[i], x[i + 1], y[i], y[i + 1]);
}
else {
stroke(0);
strokeWeight(8);
point(x[i], y[i], z[i]);
strokeWeight(1);
stroke(255);
line(x[i], y[i], z[i], x[0], y[0], z[0]);
//lunghezza[i] = calcola_lunghezza(x[i], x[0], y[i], y[0]);
}
if (x[i] < target_x[i]) {
x[i]++;
}
if (x[i] > target_x[i]) {
x[i]--;
}
if (x[i] == target_x[i]) {
target_x[i] = floor(random(width));
}
if (y[i] < target_y[i]) {
y[i]++;
}
if (y[i] > target_y[i]) {
y[i]--;
}
if (y[i] == target_y[i]) {
target_y[i] = floor(random(height));
}
if (z[i] < target_z[i]) {
z[i]++;
}
if (z[i] > target_z[i]) {
z[i]--;
}
if (z[i] == target_z[i]) {
target_z[i] = floor(random(height));
}
}
}