Code viewer for World: 9Dots - One Cube World (P5)

// Cloned by Terry D on 18 Feb 2019 from World "One Cube World (P5)" by Starter user 
// Please leave this clone trail here.
 
 
var angle = 0;                  // rotate angle starts at 0  

const objectsize    = 300;      // size of object   

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

const noboxes = 30;             // number of boxes

var a = new Array(noboxes);     // array of boxes
for (var i = 0; i < noboxes; i++) {
    a[i] = [AB.randomIntAtoB(-500,500), AB.randomIntAtoB(-500,500), AB.randomIntAtoB(-500,500) ];
}


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

var img;

// click the sound icon on the rendered web page to turn sound on/off
const MUSICFILE = '/uploads/starter/SuspenseStrings.mp3';
AB.backgroundMusic ( MUSICFILE );

function preload() 
{
   // loading within preload() improves response time
   // you can't load remote (e.g., Google) images because they may be blocked
   // img = loadImage (  "/uploads/starter/earth.1.jpg" );
   img = loadImage("/uploads/9dots/pleiades.jpg")
}


function draw()         // "draw" is called every timestep during run 
{
    texture(img); 
    
    background("darkblue");    // background color 
    // fill("yellowgreen");               // paint box with this color 
           
    rotateX(angle);             // set each dimension rotation angle to "angle"
    rotateY(angle);
    rotateZ(angle);
  
    /* 
    box(objectsize);            // draw a cube of this size 
    translate(250, 250, 250);
    box(objectsize); 
    */
    
    // add boxes from array
    for (var i = 0; i < noboxes; i++) {
        translate(a[i][0], a[i][1], a[i][2]);
        box(objectsize);
    }
  
    angle = angle + anglechange ;       // change angle each step to get rotate movement        
}