Sign in to follow this  
royibernthal

ArcRotateCamera dynamic mouse sensitivity

Recommended Posts

I'd like to have an ArcRotateCamera which rotates slower the further the mouse is from the click/touch point (while still pressed/touched).

Imagine pressing/touching anywhere, that's point A, dragging towards some direction to rotate the camera (point B updated while dragging), then releasing. (the same thing that happens now basically)

The further pointA is from pointB, the smaller the sensitivity of the camera rotation.

 

I cleared all inputs and have only mouse input now (PointersInput).

Is there some built-in functionality for such a thing or would I have to implement my own camera input?

http://doc.babylonjs.com/tutorials/customizing_camera_inputs#implementing-your-own-input

If the latter - is there a way to modify an existing camera input or would I have to build one from scratch?

Share this post


Link to post
Share on other sites

The same would apply to that no? I'd need to save the radius when the user clicks and compare it to the updated radius every scene render. Or does the radius represent that actual difference between start position (on click) and current position?

Share this post


Link to post
Share on other sites

I thought you zooming, but either way I am not thinking anything needs to be captured on click.  Just set it after every frame, to want you want it to be at certain distances.  You probably want to just plug some guesses as to values in to make sure this can changed inside a click hold.  If so, then refine "good" values once it is know to work.

Share this post


Link to post
Share on other sites

Hi Royi... sorry for the slow replies.  I hacked-together a playground that sort-of accomplishes this.

http://babylonjs-playground.azurewebsites.net/#279FW9#36

Watch console.  All the scene observer-based pointer events are working fine.  My math work in lines 91-94... is likely less-than-optimal.  :) 

I have some "accumulation" problems... somewhere.

I'm sure you can improve it.  This method is easier than coding/modding a camera input, at least. Be well.

Share this post


Link to post
Share on other sites

Hi Larry,

Thanks for the PG.

Hmm sure but it won't feel like a "clean" solution :)

Even if it complicates things, I think I'd rather create a custom camera input, keeps the order in the code - that's what camera input is meant for.

As for the math - it seems you increase the sensibility on mouse move infinitely, the longer you move the mouse around without releasing the higher the sensibility will get (it'll grow each time according to distance between down and move points).

I think the right way to tackle it would be to have a fixed calculation taking into account move and down points, and translating to a number within range of max vertical and horizontal drag distance, which at least in PG case is within around 0-900, while default sensibility is 1000, making it ideal to have some sort of min-max range according to percentage of drag distance out of default sensibility. (min-max range will be predefined to make sure the sensibility isn't too high and isn't too low)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.