///camera varibles
int oldx = mouseX;
int oldy = mouseY;
float rotx = 0;
float roty = 0;
float zcam = 0;
void setup() {
size(1000, 500, P3D);
}
void draw(){
background(0);
cam();
fill(255);
rectMode(CENTER);
rect(0,0,200,200);
}
void cam() {
int newx = mouseX;
int newy = mouseY;
translate(width/2, height/2,zcam);
rotateY(rotx);
rotateX(roty);
//rotateZ(PI);
if ((mousePressed == true)) {
rotx = rotx + (oldx-newx)/50.0;
roty = roty + (oldy-newy)/50.0;
}
oldx = newx;
oldy = newy;
}
void mouseWheel(MouseEvent event) {
float e = event.getCount();
zcam = zcam - e*5;
}