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

// Cloned by jahangir alam on 17 Sep 2024 from World "One Cube World (P5)" by Starter user 
// Please leave this clone trail here.

 const MUSICFILE = '/uploads/starter/SuspenseStrings.mp3';
 AB.backgroundMusic ( MUSICFILE );


// make an array of random (x,y,z) positions 
const numBoxes = 1000;
let B = new Array(numBoxes);
for(let i = 0; i < numBoxes; i++){
    B[i] = [AB.randomIntAtoB(-500,500), AB.randomIntAtoB(-500,500), AB.randomIntAtoB(-500,500) ];
}


let img;

function preload() 
{
   img = loadImage ( '/uploads/alamj2/1727021173.png' );
}
 
 
const objectsize    = 200;      // size of object 

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

let angle = 0;                 // rotate angle starts at 0  
function setup()        // "setup" is called once at start of run 
{
  createCanvas ( ABWorld.fullwidth(), ABWorld.fullheight(),  WEBGL );
}

let i = 0;
function draw()         // "draw" is called every timestep during run 
{
    texture(img);        	

    background("royalblue");    // background color
    //fill('red')
           
    rotateX(0);             // set each dimension rotation angle to "angle"
    rotateY(angle);
    rotateZ(0);
    i += 100;
    //box(objectlength + i);            // size of the object
    for ( let i = 0; i < numBoxes; i++ )
    {
      translate ( B[i][0], B[i][1], B[i][2] );		// get box position i 
      box(objectsize + i);             
    }

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