Code viewer for World: My First World

// Cloned by Chris Dobey on 19 Sep 2023 from World "One Cube World (P5)" by Starter user 
// Please leave this clone trail here.
 
 const MUSICFILE = '/uploads/dobeyc3/space-music.mp3';
 AB.backgroundMusic ( MUSICFILE );

 
const objectsize    = 25;      // size of object   

const anglechange   = 0.001;     // how much the rotate angle changes each step 

var angle = 0;                  // rotate angle starts at 0  

var sun_img;
var earth_img

var earth_rotate = 0;

function preload() 
{
   sun_img = loadImage ( '/uploads/dobeyc3/sun.png' );
   earth_img = loadImage ( '/uploads/dobeyc3/earth.png' );
}

function setup()        // "setup" is called once at start of run 
{
  createCanvas ( ABWorld.fullwidth(), ABWorld.fullheight(),  WEBGL );
  textureWrap(CLAMP);
}

const time = 1;

function draw()         // "draw" is called every timestep during run 
{
    background("midnightblue");    // background color 
    texture(sun_img);               // paint sphere with this color 
           
             // set each dimension rotation angle to "angle"
  
    rotateY(angle);             // set each dimension rotation angle to "angle"
    sphere ( 200 );            // draw a sphere of this size
    
    translate(1000, 0, 0);
    rotateY(millis() / 1000);
    texture(earth_img);
    sphere ( 200 );


    angle = angle + anglechange ;       // change angle each step to get rotate movement
}