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 prevents click events #171

Closed
HongchengZhao opened this issue Oct 26, 2020 · 4 comments
Closed

TrackballControls prevents click events #171

HongchengZhao opened this issue Oct 26, 2020 · 4 comments

Comments

@HongchengZhao
Copy link

HongchengZhao commented Oct 26, 2020

I found that adding TrackballControls to the scene prevents click events from happening.

Here is a reproduction: https://codesandbox.io/s/pedantic-kilby-l4ggk

@HongchengZhao
Copy link
Author

HongchengZhao commented Nov 4, 2020

I was able to solve this problem by importing TrackballControls from "three/examples/jsm/controls/experimental/CameraControls" instead of "three/examples/jsm/controls/TrackballControls". Moreover, it is compatible with the invalidateFrameLoop flag as it manages updates internally like OrbitControls. See this PR #18483 of three.js.
Still don't know why the previous version blocks click events though. 😢

@Marviel
Copy link

Marviel commented Feb 22, 2021

Still having this issue.

@joshuaellis
Copy link
Member

Hi @Marviel,

If you can provide a minimal working example of the issue, I'd be happy to open this again and we can look into it.

@drcmda
Copy link
Member

drcmda commented Feb 23, 2021

orbit does that, too. they swallow "onClick" on mobile for instance. the reason for this is probably not related to drei or r3f, it's something three does most likely and in that case we couldn't fix it anyway, but would be nice to know what it is.

maybe related to this bit:

	function onMouseDown( event ) {

		event.preventDefault();
		event.stopPropagation();

https://github.com/mrdoob/three.js/blob/dev/examples/jsm/controls/TrackballControls.js

edit:*

so it probably shuts down the event and it travels no longer. i don't quite understand why they have to call stopPropagation tbh.

the current workaround is to use onPointerUp instead, not even sure why it works, but it seems to be ok. it has some disadvantages, though. it is not 100% the same as a click.

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

4 participants