xxxxxxxxxx
56
let space = [];
let freq = 2;
function setup() {
createCanvas(5, 5);
for(let y = 0; y < height; y++){
space[y] = [];
for(let x = 0; x < width; x++){
space[y][x] = [];
for(let z = 0; z < width; z++){
let xOff = x/width - 0.5;
let yOff = y/height - 0.5;
let zOff = z/width - 0.5;
console.log(xOff)
let zNoise = noise(freq * xOff,freq * yOff, freq * zOff);
let zMapped = map(zNoise, 0, 1, 255, 0);
space[y][x][z] = zMapped;
}
}
}
}
let zCount = 0;
let zGate = true;
function draw() {
background(220);
for(let x = 0; x < width; x++){
for(let y = 0; y < height; y++){
strokeWeight(2);
stroke(space[x][y][zCount]);
point(x,y);
}
}
if(zCount == width - 1){
zGate = false;
}
if(zCount == 0){
zGate = true;
}
if(zGate){
zCount++;
}else{
zCount--;
}
}