I finally found a solution, thanks all:)
[java]protected void rotateCamera(float value, Vector3f axis){
if (dragToRotate){
if (canRotate){
// value = -value;
}else{
return;
}
}
Matrix3f mat = new Matrix3f();
mat.fromAngleNormalAxis(rotationSpeed * value, axis);
Vector3f up = cam.getUp();
Vector3f left = cam.getLeft();
Vector3f dir = cam.getDirection();
Quaternion quat = new Quaternion();
quat.lookAt(dir, up);
mat.mult(up, up);
mat.mult(left, left);
mat.mult(dir, dir);
Quaternion q = new Quaternion();
q.fromAxes(left, up, dir);
q.normalize();
float angleDir = dir.angleBetween(Vector3f.UNIT_Y);
if((angleDir>0.05)&&(angleDir<3))
{
cam.setAxes(q);
}
}[/java]