diff --git a/public/sketch.js b/public/sketch.js index 53263cb..7b72777 100644 --- a/public/sketch.js +++ b/public/sketch.js @@ -1,31 +1,33 @@ let angle = 0; let w = 24; +let ma; function setup() { createCanvas(400, 400, WEBGL); + ma = atan(1 / sqrt(2)) } function draw() { - background(175); - ortho(); - directionalLight(255, 255, 255, 0, -1, 0); + background(100); + ortho(-300, 300, 300, -300, 0, 600); - translate(0, 50, -50); - rotateX(PI / 8); - rectMode(CENTER); + rotateX(-QUARTER_PI); + rotateY(ma); let offset = 0; - for (let x = 0; x < width; x += w) { - push(); - let a = angle + offset; - let h = map(sin(a), -1, 1, 0, 100); - translate(x - width / 2, 0, 0); - ambientMaterial(255); - box(w, h, w); - //rect(x - width / 2 + w / 2, 0, w - 2, h); + for (let z = 0; z < height; z += w) { + for (let x = 0; x < width; x += w) { + push(); + let a = angle + offset; + let h = map(sin(a), -1, 1, 0, 100); + translate(x - width / 2, 0, z - height / 2); + normalMaterial(); + box(w - 2, h, w - 2); + //rect(x - width / 2 + w / 2, 0, w - 2, h); + pop(); + } offset += 0.1; - pop(); } angle += 0.1;