Camera myCam; boolean smoothMove = true; void setup() { size(400, 400, P3D); // create a camera with distance 700 and smooth movement myCam = new Camera( 800, smoothMove ); // the center of the orbit is assigned myCam.setTarget( 200, 200, 100 ); } void draw() { // must be called in the beginning of the draw loop // translate and rotate actions are called inside! myCam.useCam(); // place your draw job here background(255); lights(); directionalLight(255, 255, 200, 0, 0.2, -1); directionalLight(200, 200, 255, 1, 0.2, 0); drawSomeCubes(); // draw a ground fill(255, 200); stroke(0); translate(200, 200, -11); ellipse(0,0, 80000, 80000); } // the camera movement is combined here with mouse action void mouseDragged() { if (mouseButton == LEFT) { myCam.mouseOrbit(); } else if (mouseButton == RIGHT) { myCam.mouseZoom(); } else if (mouseButton == CENTER) { myCam.mousePan(); } } // the camera movement is combined here with key action void keyPressed() { if (key == CODED) { if (keyCode == UP) myCam.pan( 0, 30); else if (keyCode == DOWN) myCam.pan( 0, -30); else if (keyCode == LEFT) myCam.pan( 30, 0); else if (keyCode == RIGHT) myCam.pan(-30, 0); } else { if (key == ' ') { smoothMove = !smoothMove; if (smoothMove) myCam.smooth(); else myCam.noSmooth(); } else if (key == 'a') myCam.orbit( 30, 0 ); else if (key == 'd') myCam.orbit(-30, 0 ); else if (key == 'w') myCam.orbit( 0, 30 ); else if (key == 's') myCam.orbit( 0,-30 ); else if (key == 'q'){ myCam.setTarget( 200, 200, 0 ); myCam.setDistance( 700 ); } } } // simple paintjob void drawSomeCubes() { float offset = 100; noStroke(); stroke(255, 40); for (int i=0; i<5; i++) { for (int k=0; k<5; k++) { for (int m=0; m<5; m++) { color c = color( i * (255/5), k * (255/5), m * (255/5) ); fill( c ); cube(offset *i, offset*k, offset* m, 20); } } } } void cube(float x, float y, float z, float bSize) { pushMatrix(); translate(x, y, z); box(bSize); popMatrix(); }