Jump to content

ArcRotateCamera dynamic mouse sensitivity


royibernthal
 Share

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?

Link to comment
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.

Link to comment
Share on other sites

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

http://playground.babylonjs.com/#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.

Link to comment
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)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...