ArcRotateCameraHammerJsInput

Hello there!
I’ve created an ArcRotateCameraHammerJsInput and I’m curious whether you would want to be as a part of BabylonJS. If so, I will prepare the class to be PR friendly. The input class handles panning, scaling and rotation.

Thanks!
R.

4 Likes

That sounds awesome!

We try not to deal with external dependencies in babylon.js, but we do have a few of them nonetheless.
If the class is independent, and letting the user know they need to integrate Hammer.js in order to get it to work, a PR is more than welcomed! The default behavior should not change, but you can add a few sentences in the documentation regarding how to change to this input and how to integrate Hammer.js.

2 Likes

Got it. I’ll do my best! I am thinking of dropping the touch pan and touch scale, because it is already implemented for the arc camera and use this input class just as an extension to it and use only the two finger rotation functionality which is missing in the base implementation. What do you think of it?

If that is the only thing missing, maybe it is worth checking if it can be added directly there without the need for an external library :slight_smile:

What would be the expected behavior when two fingers rotate? does the camera rotate, or does the object rotate?

I will prepare a demo with some use cases so you will be able to tell whether it’s worth to have it in BJS. :vulcan_salute:

4 Likes

you’re awesome :slight_smile:

1 Like

Hello @RaananW!

I’ve published my local playgrounds so you can see what I meant. I am woking with buildings and floorplans in 2,5D mode so the beta angle on the arc rotate camera is basically locked and is changed only by the system, never by the user. This allows to use a two finger rotation gesture just to rotate the alpha angle as can be seen here:
https://demos.babylonjs.xyz/hammerjs-example/#/

We have a 2D mode in our application which sets the camera to top view and you can freely pan, zoom and rotate the model:
BabylonJS HammerJS Input demo (EDIT: Not maintained and not working with the latest builds)

I ended up with ridiculously small amount of code thanks to the well writen camera base so I basically just needed to update the innertialXXXXX values for the camera! :vulcan_salute: Cool!

Regarding the integration to BJS I think this doesn’t belong to the core BJS stuff (it’s usage is specific and introduces another unwanted dependency) so it will be enough just to mention in the docs, that we have information on how to use HammerJS with BJS and just to leave a link with the repo in the docs so one can clone it, grab the ArcoRotateCameraHammerJsInput class and tailor for his/her own needs.

I will review and format the code later, there are still several things to do, however here is the repo:

Thanks!

EDIT: The settings are calibrated to my touch screen monitor :slight_smile:

R.

2 Likes

This is great!

That’s perfect. Would be great to even have a playground with hammerjs and your code integrated to show how to use it.

1 Like

Hello!
Will this be a good place to add the HammerJS stuff?
Thank you!
R.

2 Likes

Yes, this is the best place for that. Can’t wait to approve this PR :slight_smile:

2 Likes

Hey @RaananW !
The PR is already awaiting approval. I’m sorry, I don’t have time to create a PG example, but the repo contains a sample app to play with. :vulcan_salute:
R.

2 Likes

awesome, thanks a lot! I added 2 comments :slight_smile:

1 Like

Yep, another PR under construction :construction_worker_woman:

1 Like

Ok, you have it :slight_smile:

Hi!
The demo got an update so the repo did. I’ve rewritten entirely the rotate and pinch part and I’ve added two finger tilting (camera.beta). Actually HammerJS is a bit of an assh*le when reporting rotation and angle :smiley: and doesn’t have a unified method to get the rotation regardless of which finger created the first and second touch and which starts to rotate. (the topview demo is not maintained for now)

1 Like