Code viewer for World: Step 11. Make lots of boxes
 const MUSICFILE = '/uploads/starter/SuspenseStrings.mp3';
 AB.backgroundMusic ( MUSICFILE );

// Cloned by test2 on 7 Feb 2021 from World "Cubes?" by Elva 
// Please leave this clone trail here.
 
// make an array of random (x,y,z) positions 

const noboxes = 30;                 	// how many boxes to have 
var a = new Array(noboxes);         	// array of the box positions

for ( var i=0; i < noboxes; i++ )   	// set up the array
{
    a[i] = [ AB.randomIntAtoB(-500,500), AB.randomIntAtoB(-500,500), AB.randomIntAtoB(-500,500) ];
}	


// Cloned by Elva on 31 Jan 2021 from World "POV: youre getting hit over and over with a baseball bat" by test2 
// Please leave this clone trail here.
 


// I want to explain for loop
// by printing things out to screen each time round loop
// problem where to print things out 

// use console
// secret place on web pages 
// see errors, messages 
// ctrl-shift-J 


// show how random no works 
var x = AB.randomIntAtoB ( 10, 500 );

// write x to header so I can see what it is 
AB.msg ( x );  


var img;

function preload() 
{
  img = loadImage ( '/uploads/test2/1608477756.png' );
} 



 
 
const objectsize    = x;      // size of object   

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

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


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


function draw()         // "draw" is called every timestep during run 
{
    
// console.log ( "draw is called!");
    
    texture(img);      
    background("black");    // background color 
   // fill("black");               // paint box with this color 
           
    rotateX(angle);             // set each dimension rotation angle to "angle"
    rotateY(angle);
    rotateZ(angle);

 
 for ( var i=0; i < noboxes; i++ )
{
  translate ( a[i][0], a[i][1], a[i][2] );		// get box position i 
  box(objectsize);             
}

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