xxxxxxxxxx
63
let angle = 0;
let p_width = 60;
let p_dist = 4;
let xrot;
let yrot;
let limit_width = 400;
let limit_height = 400;
function setup(){
createCanvas(windowWidth,windowHeight, WEBGL);
ortho(-300,300,300,-300,-900,1200);
hovertext = createGraphics(200,200);
hovertext.textSize(65);
hovertext.textAlign(CENTER);
hovertext.fill(255);
hovertext.text('Hello',100,100);
xrot = 0.7;
yrot = 0;
}
function windowResized(){
resizeCanvas(windowWidth,windowHeight);
ortho(-300,300,300,-300,-900,1200);
}
function draw(){
background(0);
//3d wave
push();
ambientMaterial(60,150,60);
let my = mouseY+height/2;
let mx = mouseX+width/2;
pointLight(255,255,255,mx,height,100);
rotateX(xrot);
rotateY(yrot+(mx/width));
for(let z=-limit_width;z<limit_width;z+=p_width+p_dist)
for(let x=-limit_width;x<limit_width;x+=p_width+p_dist){
let h = map(sin(angle+(-z/100+x/100)),-1,1,1,100);
push();
translate(x,0,z);
box(p_width,h,p_width);
pop();
}
pop();
//text on a plane, uncommenting slows the program 10x
/*
push();
noStroke();
texture(hovertext);
rotateX(3);
translate(0,-100,0);
plane(200,200);
pop();
*/
//step
angle+=.05;
}