Rotate on Command

like that?

boolean rotate=false;
float angle=0;

void setup() {
  size(1000, 1000, P3D);
  noFill();
  stroke(255);
  println("use key [space] for animation");
}

void draw() {
  background(0);
  angle += 0.001;
  translate(width/2, height/2);
  if (rotate) rotateY(angle);
  box(500);
}

void keyPressed() {
  if (key == ' ' )  rotate = !rotate;
}

1 Like