This line can make the camera shake, especially if time_step has a large value:
my.pan += sign(ang(temp_ang.pan - my.pan)) * time_step * 5;Replace it with something like this to make the rotation stop accurately:
var pan_diff = ang(temp_ang.pan - my.pan);
my.pan += sign(pan_diff) * minv(abs(pan_diff), time_step * 5);To make the rotation smoother you need a few more lines of code:
var pan_diff = ang(temp_ang.pan - my.pan);
// Replace 10 (in both lines) with a higher value to make the rotation stop more smoothly.
if (abs(pan_diff) < 10)
my.pan += abs(pan_diff)/10 * sign(pan_diff) * time_step * 5;
else
my.pan += sign(pan_diff) * minv(abs(pan_diff), time_step * 5);
This should work better. At least I think so.
