I have taken your idea and used the rotation code bits to rotate the cube along the Y axis as well as the X axis originally.

```
boolean rotateU=false;
boolean rotateD=false;
boolean rotateL=false;
boolean rotateR=false;
float angleX=0;
float angleY=0;
float anglechgU=HALF_PI/60;
float anglechgD=HALF_PI/60;
float anglechgL=HALF_PI/60;
float anglechgR=HALF_PI/60;
float max1Add=HALF_PI;
float max2Add=HALF_PI;
float max1=max1Add;
float max2=max2Add;
void setup(){
size(1000,1000,P3D);
noFill();
stroke(255);
println("press w to rotate ");
}
void draw(){
background(0);
fill(255);
text("Use w to rotate Up",19,19);
text("Use s to rotate Down",19,38);
text("Use a to rotate Left",19,57);
text("Use d to rotate Right",19,76);
lights();
translate(width/2,height/2);
rotateX(angleX);
if(rotateU){
angleX+=anglechgU;
if(angleX>=max1){
anglechgU=0;
rotateU=false;
max1+=max1Add;
}
}
if(rotateD){
angleX-=anglechgD;
if(angleX<=max1){
anglechgD=0;
rotateD=false;
max1-=max1Add;
}
}
rotateY(angleY);
if(rotateL){
angleY-=anglechgL;
if(angleY<=max2){
anglechgL=0;
rotateL=false;
max2-=max2Add;
}
}
if(rotateR){
angleY+=anglechgR;
if(angleY>=max2){
anglechgR=0;
rotateR=false;
max2+=max2Add;
}
}
fill(255,0,0);
box(500);
println("X angle=",angleX);
println("Y angle=",angleY);
}
void keyPressed(){
if(key=='w'){
rotateU=true;
anglechgU=HALF_PI/60;
}
if(key=='s'){
rotateD=true;
anglechgD=HALF_PI/60;
}
if(key=='a'){
rotateL=true;
anglechgL=HALF_PI/60;
}
if(key=='d'){
rotateR=true;
anglechgR=HALF_PI/60;
}
}
```

I think that I will need to create some vectors for the rotation code, because when I rotate the cube in the desired direction, for example, rotate it upward 90 deg/.5 pi, it seems that the entire dimensional plane moves around with it, because after the X rotation is finished, and if I rotate it to the right by pressing d, it seems like the cube rotates along its Z axis. In fact, it is actually rotating along the angleY variable with the rotateY bit I put in there. The two println functions in there were used to prove this.