fractalkitty looking for math? fractalkitty.com

all

scratchpad

#random#trig#3d#interactive#animation#space

vibeplanets

let vibe;
let planets;

function setup() {
  createCanvas(windowWidth, windowHeight, WEBGL);
  planets = [];
  background("#520032");
  for (let i = 0; i < 10; i++) {
    planets[i] = {
      x: random(-width, width),
      y: 0,
      z: random(-1200, 1200),
      s: random(-1, 1),
      r: random(2, 40)
    };
  }

  noStroke();
  m = 4 * max(windowWidth, windowHeight);
}

function draw() {
  background(201, 0, 188);

  t = frameCount / 100;
  camera(500 * sin(t / 2), 500 * cos(t / 2), 1200 + 500 * sin(t / 5));
  orbitControl();
  push();
  pointLight(201, 0, 188, 0, -500, -2200);
  pointLight(201, 0, 188, 1000, -500, 2200);
  ambientMaterial(255, 255, 255, 255);

  sphere(1800, 24, 24);
  pop();
  pointLight(66, 0, 235, 0, -500, -2200);
  pointLight(66, 0, 235, 1000, -500, 2200);
  sphere(m / 100, 24, 24);
  for (let i = 0; i < planets.length; i++) {
    push();
    rotateZ((planets[i].s * t) / 2);
    push();
    rotateY(t * planets[i].s);
    translate(planets[i].x, planets[i].y, planets[i].z);
    sphere(planets[i].r, 24, 24);

    pop();
    push();
    rotateX(PI / 2);
    stroke(66, 0, 235);
    noFill();
    strokeWeight(5);
    circle(0, 0, 2 * dist(planets[i].x, planets[i].y, planets[i].z, 0, 0, 0));
    pop();
    pop();
  }
  push();

  fill(82, 0, 51, 50);

  for (let i = 0; i < planets.length; i++) {}
  pop();
}
function windowResized() {
  setup();
  draw();
}