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

Clicking on the Ammo sample in the r120 does not launch the iron ball #20191

Closed
4 tasks done
cx20 opened this issue Aug 26, 2020 · 12 comments
Closed
4 tasks done

Clicking on the Ammo sample in the r120 does not launch the iron ball #20191

cx20 opened this issue Aug 26, 2020 · 12 comments

Comments

@cx20
Copy link
Contributor

cx20 commented Aug 26, 2020

Description of the problem

In the previous Ammo sample, clicking with the mouse launch an iron ball.
However, in the r120 sample, the iron ball does not appear when the mouse is clicked.
I tried the combination of the r120 sample and the previous version of OrbitControls.js and the iron ball does appear, so I think this control is probably related.

r120 Ammo Convex object breaking example result:
image

r119 Ammo Convex object breaking example result:
image

Three.js version
  • r120
Browser
  • Chrome
  • Firefox
OS
  • Windows
Hardware Requirements (graphics card, VR Device, ...)

MacBook Air (BootCamp) Intel(R) UHD Graphics 617 Direct3D11 vs_5_0 ps_5_0

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 26, 2020

I see similar problems in the spline editor example where I can't interact with TransformControls anymore.

https://threejs.org/examples/webgl_geometry_spline_editor

Maybe related to the introduction of Pointer Events in OrbitControls.

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 26, 2020

When using OrbitControls (r120) and you make a mouse click, a pointerdown event listener processes the event and calls event.preventDefault(). However, this call prevents the respective mouse event from being sent (see https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent). Hence, any event listeners listening to mousedown or mousemove events are now broken with OrbitControls (and TrackballControls).

BTW: Since EditorControls does not call event.preventDefault(), the controls still works with TransformControls.

I guess this side effect was missed when Pointer Events were introduced (#20161). It seems we can only fix this in two ways:

  • Revert the Pointer Events change.
  • Remove the calls from event.preventDefault() in OrbitControls and TrackballControls from pointer event listeners (although I'm not sure about the consequences of doing this).

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 26, 2020

Even when removing event.preventDefault() from pointerdown and pointermove event listeners in OrbitControls, webgl_geometry_spline_editor is still broken 🤔 .

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 26, 2020

More simple repro case:

r119: https://jsfiddle.net/jog5nqyh/
r120: https://jsfiddle.net/jog5nqyh/1/

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 26, 2020

@mrdoob I suggest we revert the Pointer Events change and make r120.1. It seems this change has the potential to break a lot of user code.

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 26, 2020

PR: #20194

@marcofugaro
Copy link
Contributor

marcofugaro commented Aug 27, 2020

Remove the calls from event.preventDefault() in OrbitControls and TrackballControls from pointer event listeners (although I'm not sure about the consequences of doing this).

The preventDefault() on mousedown event was introduced in #15620, I don't fully understand why it was added, but probably you guys do.

I've update the broken jsfiddle of the issue with the mousedown's preventDefault() commented out. I can't reproduce the original issue, can you?

https://jsfiddle.net/marcofugaro/2ftxhosr/1/

Testing also the webgl_multiple_elements_text example on mobile/desktop, and everything works fine without that preventDefault():

https://raw.githack.com/marcofugaro/three.js/orbit-test/examples/webgl_multiple_elements_text.html

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 27, 2020

Even when commenting out the calls of preventDefault(), webgl_geometry_spline_editor is still broken.

If we were aware that calling preventDefault() on a pointer event breaks the respective mouse event, I doubt the controls PRs were merged.

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 27, 2020

The preventDefault() on mousedown event was introduced in #15620, I don't fully understand why it was added, but probably you guys do.

BTW: The call of preventDefault() in mousemove was implemented earlier. And is problematic, too.

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 27, 2020

As a roadmap, I suggest to revert, figure out if it's possible to remove the usage of preventDefault() and only then introduce Pointer Events.

@mrdoob
Copy link
Owner

mrdoob commented Aug 29, 2020

Fixed: 9f2226e

In fact, the iron balls never worked on mobile. Now they do.

@mrdoob mrdoob closed this as completed Aug 29, 2020
@cx20
Copy link
Contributor Author

cx20 commented Aug 30, 2020

Thanks! I have confirmed that the sample works with the updated r120.

r120 Ammo Convex object breaking example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants