Disabling panning on multiTouch event leads to wrong behaviour

Hello there,
It’s been a very long time !

TL;DR
I feel like disabling panning for multiTouch event results in the wrong behaviour.
I can provide a PR if you agree with me. :slight_smile:

Playground (use a mobile)
https://playground.babylonjs.com/#4U6TVQ#2

Description
I needed to disable panning on my ArcRotateCamera.
I found that there were three events to look at:

  • Ctrl + click
  • Right click
  • Multi touch

Setting panningSensibility to 0 disables panning for all events but I would like some granularity.
As stated in the docs, camera.attachControl(false, false, -1); disables panning on ctrl + click and right click.

And this gives the same result as setting panningSensibility to 0, great!

Then, for multi touch event, I found two booleans associated with panning on ArcRotateCameraPointersInput: multiTouchPanning and multiTouchPanAndZoom.

However, disabling them doesn’t give the expected result. UX is impacted, zooming becomes very hard on touch screen.

So I looked at the code and:

camera.inputs.attached.pointers.multiTouchPanAndZoom = false;

This instruction disables panning and zooming at the same time. Panning and zooming are still possible but only one at a time. There is a threshold to decide between panning and zooming.

camera.inputs.attached.pointers.multiTouchPanning = false;

Alone, disabling multiTouchPanning has no effect because it’s a fallback when multiTouchPanAndZoom is disabled.

camera.inputs.attached.pointers.multiTouchPanAndZoom = false;
camera.inputs.attached.pointers.multiTouchPanning = false;

These two instructions combined disable panning. Only zooming is enabled. But the threshold is still used to decide between zooming and doing nothing. And that’s why UX is impacted, it’s hard to zoom.

I think the right behaviour here should be same as setting panningSensibility to 0, it should not be hard to zoom. Do you agree?

I found a hack so threshold always says to zoom:

camera.pinchToPanMaxDistance = 0;

But I think it would be better to update the code to not use the threshold when panning is disabled. It shouldn’t be hard, I can provide a PR if you’re OK.

A PR would be awesome !!!

1 Like

Hello,

Here is the PR.

Fixing this, I realized there is no equivalent to multiTouchPanning for zoom. There isn’t any option to disable zoom on multiTouch event (pinch).

Can anybody confirm or deny that this option doesn’t exist for an ArcRotateCamera ?

With the current state, there is a possible hack to disable pinch: setting the threshold so high that zoom should never happen (so result is not 100% guaranteed).
But after my fix, this hack will disappear when panning is disabled.

Permission to do this as this is only an unreliable hack and not a feature?

I could add a multiTouchZoom property which would enable/disable zoom for multiTouch event in another PR if needed.

I like your PR!

@PolygonalSun is our resident input expert and he will quickly review your PR :slight_smile:

Can anybody confirm or deny that this option doesn’t exist for an ArcRotateCamera ?

I confirm it does not exist yet so please add it to your PR!

1 Like

Also thanks a lot for the help! much appreciated!

Sorry to dredge up an old topic, but for some reason I’m having trouble getting this to work on all devices. I’m running latest preview release 5.0.0-alpha.35 and here’s what I’m doing (in TS) to disable panning and zooming etc:

const input = myArcRotateCamera.inputs.attached.pointers as ArcRotateCameraPointersInput;
input.multiTouchPanAndZoom = false;
input.multiTouchPanning = false;
input.pinchZoom = false;

This seems to work on my Android device but I’m still able to pan using MacBook Pro touchpad gestures for instance.

2 Likes

pinging @PolygonalSun (might take a bit of time)

1 Like

Hey @inteja, sorry about the delay in response. I don’t know if you’re still having this issue but I am currently unable to repro this on my Mac. If you use the latest as of today (alpha.45), are you still seeing the same thing?

1 Like