// Cloned by Tristan Everitt on 19 Sep 2022 from World "One Cube World (P5)" by Starter user
// Please leave this clone trail here.
const objectsize = 50; // size of object
let anglechange = 0.01; // how much the rotate angle changes each step
let speed = 1;
var angle = 0; // rotate angle starts at 0
let r = 0;
let g = 0;
let b = 0;
function setup() // "setup" is called once at start of run
{
createCanvas ( ABWorld.fullwidth(), ABWorld.fullheight(), WEBGL );
}
function draw() // "draw" is called every timestep during run
{
background("#A52A2A"); // background color
fill("rgb("+r+","+g+","+b+")"); // 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
if(Math.ceil(Math.random() * 100) === 50) {
speed = speed > 1 ? 1 : 5;
r = Math.floor(Math.random() * 255);
g = Math.floor(Math.random() * 255);
b = Math.floor(Math.random() * 255);
}
angle = angle - (anglechange * speed) ; // change angle each step to get rotate movement
}