let angle = 0; let w = 22; let ma; let maxD; function setup() { createCanvas(600, 600, WEBGL); colorMode(HSB, 360, 100, 100); ma = atan(1 / sqrt(2)); maxD = dist(0, 0, 200, 200); } function draw() { background(300); ortho(-500, 500, 500, -500, 0, 1000); rotateX(-QUARTER_PI); rotateY(ma); rectMode(CENTER); let offset = 0; for (let z = 0; z < height; z += w) { for (let x = 0; x < width; x += w) { push(); let d = dist(x, z, width / 4, height / 4); let offset = map(d, 2, maxD, -4, 8); let a = angle + offset; let h = floor(map(sin(a), -2, 2, 100, 300)); translate(x - width / 2, 0, z - height / 2); //normalMaterial(); box(w - 2, h, w - 2); pop(); } } angle += 0.1; }
p5js,ちょっとむずかしい。。。