let t;
let r;
let nSpheres = 10;
let stars;
function preload() {
stars = loadImage("/assets/2k_stars_milky_way.jpg");
}
function setup() {
createCanvas(windowWidth, windowHeight, WEBGL);
noStroke();
r = 50;
angleMode(DEGREES);
rFactor = random(10, 20);
texture(stars);
sphere(1000, 24, 24);
}
function draw() {
t = 360 * sin(frameCount / 20);
orbitControl();
pointLight(100, 255, 255, 500 * sin(t / 20), 500 * cos(t / 20), 0);
specularMaterial(200, 100, 200);
rotateX(90);
for (let j = 0; j < nSpheres; j++) {
rotate((360 / nSpheres) * j);
for (let i = 0; i < nSpheres; i++) {
push();
let a = (360 / nSpheres) * i;
translate(r * cos(t + a), r * sin(t + a), 0);
sphere(10 + rFactor * sin(t / 5), 50, 50);
pop();
push();
translate(r * 2 * cos(-t + a), 0, r * 2 * sin(-t + a));
sphere(10 + (rFactor / 4) * sin(t / 10), 50, 50);
pop();
translate(r * 2 * cos(t + a), 0, r * 2 * sin(t + a));
sphere(10 + rFactor * cos(t / 6), 50, 50);
}
}
}