xxxxxxxxxx
68
function setup() {
createCanvas(600, 600, WEBGL);
// noStroke();
fill(128);
// stroke(255);
noStroke();
frameRate(60);
ambientLight(100);
specularMaterial(250);
}
var radius = 50.0,
myScale = 0.025,
nSteps = 360;
function noisy(x, y, theta) {
// noise(x,y) == noise(-x,y) --- so add offset of radius*5
var px = radius + (x+radius) * cos(theta);
var py = radius + (x+radius) * sin(theta);
return noise(myScale * px, myScale * py, myScale * y);
}
function boxes(n) {
if (n > 1) {
let theta = map(frameCount % nSteps, 0, nSteps, 0, TWO_PI);
// console.log(theta);
push()
// rotateX(noisy(n, 0, theta))
// rotateY(noisy(n, 1, theta))
// rotateX(frameCount * 0.01);
// rotateY(frameCount * 0.01);
box(10*n*noisy(n, theta));
pop();
translate(50, 0);
boxes(n - 1);
}
}
function draw() {
let theta = map(frameCount%nSteps, 0, nSteps, 0, TWO_PI);
background(0);
pointLight(250*noisy(100, 0, theta),
250*noisy(200, 0, theta),
250*noisy(300, 0, theta),
1000*noisy(400, 0, theta),
1000*noisy(500, 0, theta), 0);
translate(-250, -250);
for (var x=0; x<18; x++) {
push()
translate(x*30, 0);
for (var y=0; y<18; y++) {
push();
translate(0,0,100*noisy(x,y,theta));
sphere(15);
pop();
translate(0, 30);
}
pop();
}
// translate(-200, 0);
// boxes(10);
}