XRTransientInputHitTestSource
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.
Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.
TheXRTransientInputHitTestSource interface of theWebXR Device API handles transient input hit test subscriptions. You can get anXRTransientInputHitTestSource object by calling theXRSession.requestHitTestSourceForTransientInput().
This object doesn't itself contain transient input hit test results, but it is used to compute hit tests for eachXRFrame by callingXRFrame.getHitTestResultsForTransientInput(), which returnsXRTransientInputHitTestResult objects.
In this article
Instance properties
None.
Instance methods
XRTransientInputHitTestSource.cancel()ExperimentalUnsubscribes from the transient input hit test.
Examples
>Getting anXRTransientInputHitTestSource object for a session
Use theXRSession.requestHitTestSourceForTransientInput() method to get a transient input hit test source.
const xrSession = navigator.xr.requestSession("immersive-ar", { requiredFeatures: ["local", "hit-test"],});let transientHitTestSource = null;xrSession .requestHitTestSourceForTransientInput({ profile: "generic-touchscreen", offsetRay: new XRRay(), }) .then((touchScreenHitTestSource) => { transientHitTestSource = touchScreenHitTestSource; });// frame loopfunction onXRFrame(time, xrFrame) { let hitTestResults = xrFrame.getHitTestResultsForTransientInput( transientHitTestSource, ); // do things with the transient hit test results}Unsubscribe from a transient input hit test
To unsubscribe from a transient input hit test source, use theXRTransientInputHitTestSource.cancel() method. Since the object will no longer be usable, you can clean up and set theXRTransientInputHitTestSource object tonull.
transientHitTestSource.cancel();transientHitTestSource = null;Specifications
| Specification |
|---|
| WebXR Hit Test Module> # transient-input-hit-test-source-interface> |