When rotating camera is moving back when reach limit

I change default camera controls to be able rotate camera around screen center and I was able to achive that goal.

I limit camera height to prevent user to go under terrain and for better user experience but there is problem when camera reach that limit.

I don’t know why camera is moving back when user try move camera under height limit.

I tried use:

viewer.scene.screenSpaceCameraController.enableRotate= false;

but it blocks whole rotation and it makes bad user experience.

There is sandcastle example:

To see that effect rotate camera with left (drag) mouse button and reach height limit. When you reach limit you should see that camera is moving back when you try go under that limit.

I will be grateful for your help :slight_smile: