Code viewer for World: Jittering Cube
 


//---- normal P5 code -------------------------------------------------------
var objectSize = 200;

var angleChange = 0.01;

var angleX = 0;
var angleY = 0;
var angleZ = 0;

function generateRandomFloat(min, max, places) {
    let value = (Math.random() * (max - min + 1)) + min;
    return parseFloat(Number.parseFloat(value).toFixed(places));
}

function setup()
{
    createCanvas(ABWorld.fullwidth(), ABWorld.fullheight(), WEBGL);
}


function draw()
{
    background(93, 194, 222);
    
    rotateX(angleX);
    rotateY(angleY);
    rotateZ(angleZ);
    
    box(objectSize);
    
    angleX = angleX + generateRandomFloat(-1, 1, 6) * 0.01
    angleY = angleY + generateRandomFloat(-1, 1, 6) * 0.01
    angleZ = angleZ + generateRandomFloat(-1, 1, 6) * 0.01
}