fractalkitty looking for math? fractalkitty.com

100 days of code

starProjecting

#trig#image#3d#animation#sky#space

Using NASA's star images, I played with projection in a Friday afternoon.


function preload(){
 stars=loadImage('/assets/starmap_4k.jpeg')
}
function setup(){
 cnv=createCanvas(windowWidth,windowHeight,WEBGL);
  noStroke();
  angleMode(DEGREES)
}
function draw(){
  background(0);
  ambientLight(205,255,255);
  texture(stars);
  rotateX(90);
  push()
    rotateZ(frameCount/4);
    sphere(height/4,25,25);
    sphere(height/1.2,24,24);
    sphere(height*4,24,24);
    sphere(height/10,24,24);
    sphere(height/45,24,24);
    torus(height*2,height*2-1,24,24);
  pop()
 t=frameCount/40;
  x=height*4.4*sin(t)*sin(t);
  if(x>height*2){
    x=height*7*sin(t*3)*sin(t*3)
  }
  camera(x, 0, 0, 0, 0, 0, 0, 1, 0);
}