immersive-web / webxr-samples

Samples to demonstrate use of the WebXR Device API
https://immersive-web.github.io/webxr-samples/
MIT License
995 stars 479 forks source link

Adding handling selectstart and selectend to Input Selection sample. #55

Closed Artyom17 closed 4 years ago

Artyom17 commented 4 years ago

Recently, found a bug in Oculus Browser with handling selectbegin/select/selectend which I was unable to detect with the existing tests/samples. Now, it should become obvious, if there are issues with these events. The proper behavior is:

At the end, the cubes must appear in the same size as they were, if all selectstart/select/selectend events are dispatched correctly. Otherwise, the cube will be either smaller or larger than the original size.

Artyom17 commented 4 years ago

Demo: https://youtu.be/wVBPdR0iuJk

klausw commented 4 years ago

Thank you, this looks helpful.

FYI, you're referring to "selectbegin" in this description, but the name of the event is "selectstart". Your code does use "selectstart" though, for a minute I was worried we somehow had a serious compatibility issue if the names don't match across browsers...

Be aware that the select sequence is cancelable, so it's not guaranteed that you'll get a "select" event in between "selectstart" and "selectend", and in that case the cube would continue enlarging. I don't think that would be expected to happen in this sample though.

In case it helps, I recently added a simple debug tool to Chrome's fork of the sample to show events as they happen, but since this uses HTML output it's only really useful for desktop VR, or AR mode with DOM Overlay enabled. See https://github.com/immersive-web/dom-overlays/issues/8#issuecomment-575834993 for more details on that, and search for "debugSources" in the hit test sample.

Artyom17 commented 4 years ago

Yeah, I know. Which is ok, the cubes will end up a bit smaller if 'select' wasn't fired.

toji commented 4 years ago

LGTM, thank you!