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

Add sample for requestHitTestSourceForTransientInput #126

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lehoangphu
Copy link
Contributor

The work for OpenXR backend support for Hit-Test is now in Chromium 93, soon the Edge build on Hololens will have hittest enabled by default and it works with transient hand input. This sample demonstrate the API usage for hit-test with transient input source.

Copy link
Member

@toji toji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good overall, but if we're going to have an example that explicitly makes use of transient hit tests I want to make sure it's demonstrating it in a scenario where it makes the most sense.

<body>
<header>
<details open>
<summary>Hit Test using input source</summary>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<summary>Hit Test using input source</summary>
<summary>Hit Test using transient input sources</summary>

<details open>
<summary>Hit Test using input source</summary>
<p>
This sample demonstrates use of hit testing using transient input source to place virtual objects on real-world surfaces.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This sample demonstrates use of hit testing using transient input source to place virtual objects on real-world surfaces.
This sample demonstrates use of hit testing using transient input source to place virtual objects on real-world surfaces. Transient input sources are created to listen to inputs that may exist only for a brief period, such as screen taps, making them impractical to request a typical hit test source for.

It would be good to have some additional text, like what I've suggested, to explain why a transient input source is treated differently.

}

if (!xrTransientInputHitTestSourceRequested) {
session.requestHitTestSourceForTransientInput({ profile: inputSource.profiles[0]})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't really in the spirit of how transient input hit tests are intended to be used. If you have an input source that you can get a profile from, you probably just want a regular hit test source, as it'll be easier to use and is likely to be cheaper on the implementation end.

A transient input source is typically thought of as one that may only be observable during a select event. generic-touchscreen is s good example here: We don't have a continuous input source that represents the touchscreen, but we may generate events that come from one. Since the select event may only persist for a single frame, and since requestHitTestSource() is asynchronous, the input source may disappear before the hit test source is fully created, and as a result you may never see hit test results from it.

Because requestHitTestSourceForTransientInput() takes a profile, you can do something like session.requestHitTestSourceForTransientInput('generic-touchscreen') to indicate to the system that you want to track hit tests for ANY source that includes the generic-touchscreen profile, even if it only persists for a frame. That way you can get the hit test results in the select events consistently.

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

Successfully merging this pull request may close these issues.

None yet

2 participants