xxxxxxxxxx
34
let num = 10; let size = 15;
let cam;
function setup() {
createCanvas(400, 400, WEBGL);
frameRate(24);
cam = createCamera();
cam.lookAt(0,0,0);
}
function draw() {
background(220);
orbitControl();
stroke(0,0,0,10);
fill(255, 0, 0, 1);
let randomChoice = Math.floor(random(num ** 3));
for (let i = 0; i < num; i++) {
for (let j = 0; j < num; j++) {
for (let k = 0; k < num; k++) {
if (i * j * k == randomChoice) {
fill('red');
} else {
noFill();
}
push();
translate(i*size, j*size, k*size);
box(size);
pop();
}
}
}
}