r3f-native-orbitcontrols icon indicating copy to clipboard operation
r3f-native-orbitcontrols copied to clipboard

Only horizontal pan with one finger

Open DavidVRG opened this issue 11 months ago • 5 comments

Can I only move horizontally with one finger?

DavidVRG avatar Mar 13 '24 13:03 DavidVRG

This isn't usually possible in web orbit controls that support touch, because the main action in this type of control is to rotate (the camera around the orbited object). This could be added though, it'd require some modifications in handleTouchMovePan, which actually should be abstracted to "forward" the event to the correct "dispatcher" (pan or rotate, or also zoom). If you are interested in implementing this, I could help explaining some parts of the code (if that'd help).

TiagoCavalcante avatar Mar 14 '24 00:03 TiagoCavalcante

My idea is to be able to move horizontally in this (pan with one finger):

<Plane args={[200, 200]} position={[0, 0, 0]} rotation={[-Math.PI / 2, 0, 0]}> <meshStandardMaterial attach="material" color="#fcbf49" /> </Plane>

I try a lot of things but not working. I tried to limit how far the pan moves. My biggest problem is that I can go under the Plane and I can also go excessively towards it.

DavidVRG avatar Mar 14 '24 12:03 DavidVRG

Now that I think about it, vertical movement should not be prohibited, but limited. If it's possible.

DavidVRG avatar Mar 14 '24 12:03 DavidVRG

@DavidVRG I believe the behavior you want to achieve isn't possible with orbit controls. What you want is map controls.

Look at the following web examples: Map controls Orbit controls

Unfortunately, I don't know any library that implements map controls for native (and any controls which isn't orbit controls).

However, I can, in the future, adapt more types of controls to mobile. But an ideal solution is to make some changes in Drei directly. See this.

TiagoCavalcante avatar Mar 14 '24 17:03 TiagoCavalcante

Hey @DavidVRG

I have made a pull request to support map controls. #47 should solve the problem. It uses google map like gestures for map controls. Please look into the pull request and see if it fits your use case.

ashkalor avatar Aug 16 '24 10:08 ashkalor