xxxxxxxxxx
let canvaswidth = 17;
let canvasheight = 17;
let cube_size = 40;
let randomness = 0.03;
function setup() {
createCanvas(canvaswidth * cube_size, canvasheight * cube_size, WEBGL);
frameRate(60);
smooth(8);
}
function draw() {
background(30);
noStroke();
ambientLight(50);
pointLight(255, 2, 2, -width / 2, -height / 2, 400);
pointLight(color("darkorange"), width / 2, height / 2, 300);
directionalLight(255, 5, 0, 0, -1, -1);
for (let i = 0; i < canvaswidth; i++) {
for (let j = 0; j < canvasheight; j++) {
push();
translate(
(i - canvaswidth / 2 + 0.5) * cube_size,
(j - canvasheight / 2 + 0.5) * cube_size,
0
);
let iw = canvaswidth / 2 - Math.abs(i - canvaswidth / 2);
let jh = canvasheight / 2 - Math.abs(j - canvasheight / 2);
if (jh !== 0 || iw !== 0) {
const nx = noise(i, j, frameCount/123) - 0.5;
const ny = noise(j, frameCount/123, i) - 0.5;
rotateX(radians(iw * iw * jh * jh * nx*randomness));
rotateY(radians(iw * iw * jh * jh * ny*randomness));
}
specularMaterial(25);
shininess(50);
box(cube_size);
pop();
}
}
}