xxxxxxxxxx
44
class Box {
constructor(x, y, angle) {
this.x = x;
this.y = y;
this.depth = 0;
this.angle = 0;
this.isLetter = false;
}
display() {
noFill();
stroke(255, 100);
if (this.isLetter) {
this.depth = this.depth+2*cos(this.angle);
stroke(255)
this.angle+=1;
} else {
this.angle-=1;
}
push();
// translate(this.x, this.y, this.depth);
translate(this.x, this.y, this.depth);
rotateX(this.angle);
rotateY(this.angle);
// this.mouseHover();
box(size - (1/3*size), size - (1/3*size));
// box(size - (1/3*size), size - (1/3*size), this.depth);
pop();
}
mouseHover() {
let distance = dist(this.x, this.y, mouseX - (size*num/2), mouseY - (size*num/2));
if (distance < size*5) {
stroke(255);
rotateX(this.angle);
rotateY(this.angle);
}
this.angle += 1;
}
}