xxxxxxxxxx
let i=0;
let f=0;
let H;
let g;
let myGL; // glContext
let gui;
let rotR=true;
let bgRatio = 1;
let myMouseInc = 1;
let ui = {
bgColor: "#eadc00",
outline: true,
infinite: true,
inverted: true,
autoRotate: true,
};
setup =_=> {
myGL = createCanvas(windowWidth, windowHeight, WEBGL).GL;
H=windowHeight < windowWidth ? windowHeight/1.8: windowWidth/1.8;//scale of the box
bgRatio = windowWidth / windowHeight;
g=createGraphics(w=100,w);
stroke(255);
strokeWeight(4);
gui = new dat.gui.GUI();
gui.addColor(ui, 'bgColor');
gui.add(ui, 'infinite');
gui.add(ui, 'inverted');
gui.add(ui, 'outline');
gui.add(ui, 'autoRotate');
}
draw=_=> {
let myInc = ui.autoRotate ? myMouseInc : 0;
f = rotR ? f+myInc: f-myInc;
orbitControl(3,1,0);
rotateY(f/300);
with(g){
strokeWeight(0.5);
background(0);
stroke(0,200,20);
for(y=0;y<9;y++){
for(x=0;x<9;x++){
//circle(x*16-8,y*16-8,sin((x+y+f/9)/10)*17)
rect(x*16,y*16,sin((x+y+f/9)/10)*17,tan((x+y+f/4)/20)*17);
}
}
}
if(!ui.infinite) background(255);
texture(get());
push();
myGL.enable(2884);
myGL.cullFace(myGL.BACK);
if(ui.outline) box(H*0.5);
pop();
push();
texture(g);
if(!ui.inverted) myGL.cullFace(myGL.FRONT);
box(H/3);
pop();
myGL.cullFace(myGL.BACK);
push();
texture(get());
ambientLight(ui.bgColor);
box(1000, 1000 * bgRatio, 1000,2);
pop();
}