public void focus(double x, double y, double z) {
Lock();
cam.SetFocalPoint(x, y, z);
- if (doNotRotate)
- cam.SetViewUp(upDirection);
+ if (doNotRotate) {
+ double[] proj = cam.GetDirectionOfProjection();
+ if (Math.abs(proj[1] * upDirection[2] - proj[2] * upDirection[1]) < 1e-6 &&
+ Math.abs(proj[2] * upDirection[0] - proj[0] * upDirection[2]) < 1e-6 &&
+ Math.abs(proj[0] * upDirection[1] - proj[1] * upDirection[0]) < 1e-6)
+ cam.SetViewUp(upDirection[1], upDirection[2], upDirection[0]);
+ else
+ cam.SetViewUp(upDirection);
+ }
cam.OrthogonalizeViewUp();
resetCameraClippingRange();
// panel.UpdateLight();