i am trying to make the camera orbit spherically and have modified an example about orbiting on one plane (the x-z plane to exact) this is what i have so far:

- float xrotation=0;
- float yrotation=0;
- void setup() {
- size(500, 500, P3D);
- background(255);
- }
- void draw() {
- background(255);
- lights();
- xrotation += mouseX-pmouseX;
- yrotation += mouseY-pmouseY;
- float orbitRadius= 200;
- float ypos= sin(radians(yrotation))*orbitRadius;
- float xpos= cos(radians(xrotation))*orbitRadius;
- float zpos= sqrt((orbitRadius*orbitRadius-xpos*xpos-ypos*ypos));
- camera(xpos, ypos, zpos, 0, 0, 0, 0, -1, 0);
- box(25);
- }

now sometimes the box disappears and im not sure why i may not have the right equation for ypos but the other two should be solid... i think lol. does anyone know why this might be happening>?

1