camera-controls icon indicating copy to clipboard operation
camera-controls copied to clipboard

Slow pinch-zoom when using orthographic camera

Open diredev opened this issue 2 years ago • 9 comments

Describe the bug

Using the pinch gesture to zoom the scene works great when using a perspective camera. If I use the gesture with an orthographic camera however, the camera moves very slowly, making the gesture pretty much unusable.

This is easily reproducible on mobile devices, I've tested it on both on iPad Pro 11 and an Android phone.

To Reproduce

Steps to reproduce the behavior:

  1. Launch the "orthographic" camera example on a mobile device
  2. Zoom using the pinch gesture

Code

No response

Live example

No response

Expected behavior

Should zoom at a reasonable speed even in orthographic mode.

Screenshots or Video

No response

Device

Mobile

OS

MacOS, Android

Browser

Chrome, Safari

diredev avatar Oct 04 '23 16:10 diredev

Thank you for your report. The problem has been reproduced.

I will take a look, but sorry, I don't have much time at this moment. It may take some time.

yomotsu avatar Oct 06 '23 01:10 yomotsu

Hi @yomotsu

I have been facing the same issue of zoom in ortho camera. Can you point me in a direction where I can take a look so that I can take a dig at this issue?

Regards Srinivas

SrinivasPrabhu794 avatar Nov 10 '23 13:11 SrinivasPrabhu794

Hi @yomotsu

Any help on this will be appreciated!

SrinivasPrabhu794 avatar Nov 13 '23 14:11 SrinivasPrabhu794

sorry for the loooooong delay... I checked the passed the delta value when internal zoom happens: https://github.com/yomotsu/camera-controls/blob/92ece6898f483e1f1844616a95ce0e839a48491f/src/CameraControls.ts#L3239

left is with a mouse wheel, and right is touch. image

seems the value is not much different on both sides. but mouse wheel events happened more frequently if my investigation is correct...

What we could do is that: Accelerate the delta a little bit, If the internalZoom is called from touch events. (but not sure... https://github.com/yomotsu/camera-controls/blob/92ece6898f483e1f1844616a95ce0e839a48491f/src/CameraControls.ts#L1165-L1200

yomotsu avatar Nov 20 '23 06:11 yomotsu

Thanks @yomotsu :) Sorry for my late reply, ill take a look based on your inputs :) I appreciate your help on this!

SrinivasPrabhu794 avatar Dec 04 '23 06:12 SrinivasPrabhu794

This helped me fix it for mobile devices. But the same pinch zoom slowness is observed when using the trackpad to pinch zoom on laptops in the orthographic mode. What solution would you suggest ?

SrinivasPrabhu794 avatar Jan 30 '24 07:01 SrinivasPrabhu794

This should definitely be configurable by a factor provided by the user. Is there any way of fixing this currently? It's quite unusable right now.

After further testing, this issue is only affecting tablets and not smartphones.

ricardomatias avatar Feb 29 '24 12:02 ricardomatias

After further testing, this issue is only affecting tablets and not smartphones.

Beg to differ. Pinch to zoom is sucking on my Google Pixel 8 Pro phone. 😢

Is there some way to override the pinching factor externally without forking the full project?

darkvertex avatar Jul 16 '24 19:07 darkvertex

After further testing, this issue is only affecting tablets and not smartphones.

Beg to differ. Pinch to zoom is sucking on my Google Pixel 8 Pro phone. 😢

Is there some way to override the pinching factor externally without forking the full project?

Can't you just set cameraControls.minDistance and .maxDistance based on what kind of event is happening? That's what I've been doing.

EDIT: Actually, that seems to lead to stuttering when changing direction. Setting cameraControls.dollySpeed seems to work better.

diemildefreude avatar Jul 22 '24 10:07 diemildefreude