royibernthal Posted March 19, 2017 Share Posted March 19, 2017 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? Quote Link to comment Share on other sites More sharing options...
royibernthal Posted March 20, 2017 Author Share Posted March 20, 2017 Any idea? Quote Link to comment Share on other sites More sharing options...
adam Posted March 20, 2017 Share Posted March 20, 2017 I'd try setting angularSensibility according to distance. https://github.com/BabylonJS/Babylon.js/blob/master/src/Cameras/babylon.arcRotateCamera.ts#L58 Quote Link to comment Share on other sites More sharing options...
royibernthal Posted March 20, 2017 Author Share Posted March 20, 2017 Is the distance exposed anywhere or am I supposed to calculate it myself by listening to mouse events? I think it's calculated here but it's not really exposed: https://github.com/BabylonJS/Babylon.js/blob/master/src/Cameras/Inputs/babylon.arcrotatecamera.input.pointers.ts Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted March 20, 2017 Share Posted March 20, 2017 It is exposed as radius in the camera itself. Might be implementable as a scene after renderer where you assign angular sensibility based on camera radius. Quote Link to comment Share on other sites More sharing options...
royibernthal Posted March 20, 2017 Author Share Posted March 20, 2017 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? Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted March 20, 2017 Share Posted March 20, 2017 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. Quote Link to comment Share on other sites More sharing options...
royibernthal Posted March 20, 2017 Author Share Posted March 20, 2017 I don't really understand what you mean. Can you please clarify? An example would be great. Quote Link to comment Share on other sites More sharing options...
royibernthal Posted March 23, 2017 Author Share Posted March 23, 2017 Anyone? Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 28, 2017 Share Posted March 28, 2017 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. Quote Link to comment Share on other sites More sharing options...
royibernthal Posted March 29, 2017 Author Share Posted March 29, 2017 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) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.