Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TrackballControls doesn't work correctly for touch screens #7185

Closed
jagracar opened this issue Sep 17, 2015 · 3 comments
Closed

TrackballControls doesn't work correctly for touch screens #7185

jagracar opened this issue Sep 17, 2015 · 3 comments

Comments

@jagracar
Copy link

Hi!

I was testing on my phone one sketch that uses the trackball control class and I realized that in most of the cases when one zooms with two fingers, as soon as the zoom event finishes, the camera performs in addition a random rotation. It seems like the zoom event produced by the two contact fingers is also triggering a rotation event.

To test it, just open the Trackball controls example with a touch device and make a couple of zooms:

http://threejs.org/examples/#misc_controls_trackball

The orbit controls work fine.

@MasterJames
Copy link
Contributor

It seems to happen more around the edges then a sweet spot in the middle.

shshaw added a commit to shshaw/three.js that referenced this issue Oct 22, 2015
Fix for mrdoob#7185. After using two fingers, the camera would rapidly rotate if both fingers were not removed simultaneously. Adding in some state checks in `touchmove` and `touchend` prevents the jump from the null `_movePrev`, allowing users to quickly go from zooming and panning to rotating.
shshaw added a commit to shshaw/three.js that referenced this issue Oct 22, 2015
Fix for mrdoob#7185. After using two fingers, the camera would rapidly rotate if both fingers were not removed simultaneously. Adding in some state checks in `touchmove` and `touchend` prevents the jump from the null `_movePrev`, allowing users to quickly go from zooming and panning to rotating.
@shshaw
Copy link
Contributor

shshaw commented Oct 22, 2015

The issue seems to be related to the number of touches going from two to one. TrackballControls tries to do the typical touch rotate action on the touchend event, but the initial _movePrev value is null causing the crazy camera jump.

Try my fix in #7406. Switching from multitouch to single touch works correctly in my test cases with the changes I made.

shshaw added a commit to shshaw/three.js that referenced this issue Oct 22, 2015
* Removed unnecessary `default` case for two or more touches on `touchend` to prevent issues with 3 or more touches.
* Reset zoom distances on `case 0` and `case 1`. I couldn't combine them easily without doing a separate `if` statement.
* Simplified `case 1` action to set `_moveCurr` and `_movePrev` to the current touch position preventing camera jumping next time `touchmove` is called.

Related to issue mrdoob#7185 and pull request mrdoob#7406
@jagracar
Copy link
Author

jagracar commented Feb 4, 2018

Sorry, I forgot to close this issue!

@jagracar jagracar closed this as completed Feb 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants