const NUM = 3, PLOTTER2D = false;
createCanvas(windowWidth, windowHeight, PLOTTER2D ? P2D : WEBGL);
S = min(width, height) / NUM / 1.5;
randomSeed(~~random(hour()+minute()+second()));
for (let a = 0; a < TWO_PI; a += TWO_PI/5) {
let verticies = new VertDims(pts);
verticies.add([0, 0, 0]);
const proj2D = camPrj(cam, verticies.pts);
const len = sqrt(verticies.pts[0][0]*verticies.pts[0][0]+verticies.pts[0][1]*verticies.pts[0][1]+verticies.pts[0][2]*verticies.pts[0][2])
console.log("--- " + a + " len: " + len);
console.log(verticies.pts);
console.log(verticies.project2D(200))
if (PLOTTER2D) translate(width/2, height/2);
if (!PLOTTER2D) lights();
if (!PLOTTER2D) pointLight(color(255, 192+32*sin(frameCount/23), 192+32*cos(frameCount/32)), sin(frameCount/123)*S, -2*S, 2*S);
if (!PLOTTER2D) specularMaterial(255);
if (!PLOTTER2D) shininess(100);
for (let j = 0; j < NUM; j++) {
const y = (j-(NUM-1)/2)*S;
for (let i = 0; i < NUM; i++) {
const x = (i-(NUM-1)/2)*S;
const z = noise(width+x, height+y, frameCount/64) * S*10;
const rotX = (noise((width+x)*10, (height+y)*10, frameCount/96)-0.5) * PI;
const rotY = (noise((height+y)*10, (width+x)*10, frameCount/96)-0.5) * PI;
translate(x, y, -S*4 + z);
const n = noise(width+x, height+y)
fill("pink"); if (~~(n*10) % 2 === 0) fill("steelblue");
const clr = pal[~~(noise(12 + x*S, 23 + y*S)*pal.length)];
if (!PLOTTER2D) box(S * 0.9, S * 0.9, S * n);
const a = 2.1 + frameCount/123;
pos: {x: x*11, y: y*11, z: -S*23 + z*1.4},
sze: {x: S * 0.9, y: S * 0.9, z: S * n},
rot: {x: rotX, y: rotY, z: 0},
const cube3D = new Cube(bx.pos, bx.sze, bx.rot, bx.clr);
const cam = [0, 0, -200];
if (PLOTTER2D) cube3D.show(cam);
areas.sort((a, b) => a.az - b.az);
vertex(ar.proj2D[i][0], ar.proj2D[i][1]);
function mousePressed() {
if (PLOTTER2D && mouseButton != RIGHT && mouseX > 0 && mouseX < width) {
redraw(~~random(40, 120));
if (key == "s" || key == "S") {
saveSvg("epi_boxes3D.svg.txt");
function saveSvg(name = "epi") {
translate(width/2, height/2);
for (const bx of boxes) {
const cube3D = new Cube(bx.pos, bx.sze, bx.rot, bx.clr);