Code viewer for World: One Cube World (P5) (clone...


const objectsize    = 75;      // size of object   

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

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



function setup()        // "setup" is called once at start of run 
{
  createCanvas (ABWorld.fullwidth(), ABWorld.fullheight(),  WEBGL );
    stroke('#222222');
    strokeWeight(4);

}

function draw()         // "draw" is called every timestep during run 
{

    background("black");    // background color 
    fill("yellow");               // paint box with this color 
           
    rotateX(angle);             // set each dimension rotation angle to "angle"
    rotateY(angle);
    rotateZ(angle);
    
    if (keyIsPressed === true) {  // If the key is pressed, then show a different shape
    sphere(objectsize);

  }
    else
    
    box(mouseX, mouseY, 100, 100, 100);            // draw a box with mouse functionality 
    stroke('#222222');
    strokeWeight(4);
    
  
    angle = angle + anglechange ;       // change angle each step to get rotate movement  
    
    pop()
}