Rotate ArcRotateCamera with mouse distance

As a follow up to my question answered here:

In the example the rotation is based on the mouse position on the screen and a turnFactor, I want it to work more like the old rotary phones where the change in alpha is directly related to angle the mouse moves between start and end vector to give the appearance you are dragging the ground.

I thought something like camera.alpha += Vector3.GetAngleBetweenVectors(start, end, normal) would accomplish this but it has unexpected results.

I am not sure to understand what you are trying to accomplish here ? would be great if you could detail a bit more and provide your start playground ?

My start playground is based off of msDestiny14’s example.

I added a cylinder at the center for a rotation reference and a sphere to stand in for a position I might start to click and drag but the entire ground is where you could “grab”.

Basically what I want is if I were to click and drag in a counter-clockwise manner on the ground the camera would rotate clockwise and vice versa.

In the original example, once you pass the horizontal halfway the rotation direction changes. I want to it to continue until I start dragging in the other direction.

Hopefully that makes more sense.

This is just 2d maths at this point to modify @msDestiny14 sample: https://playground.babylonjs.com/#SRZRWV#693

3 Likes