// move the mouse to rotate, press mouse to zoom float zoom = 1; void setup() { size(500, 500, P3D); } void draw() { background(0); if (keyPressed == true) zoom = mouseX-300; // press key to change zoom translate(width/2, height/2, zoom); // to make sure all rotations are centered around the center of our window, and move away from the object by "zoom" rotateX(mouseY/100.0); // rotate around the X and Y axis (divide by 100 to make a small number as it expects radians) rotateY( mouseX/100.0); beginShape(); // start a new shape, fill(255, 0, 0); vertex(-100, -100, 0); // define the three corners of our face fill(255, 255, 0); vertex( -100, 100, 0); fill(255, 0, 255); vertex( 100, 100, 0); endShape(); // done with the shape }