The XRTransientInputHitTestSource
interface of the WebXR Device API handles transient input hit test subscriptions. You can get an XRTransientInputHitTestSource
object by calling the XRSession.requestHitTestSourceForTransientInput()
.
This object doesn't itself contain transient input hit test results, but it is used to compute hit tests for each XRFrame
by calling XRFrame.getHitTestResultsForTransientInput()
, which returns XRTransientInputHitTestResult
objects.
Instance properties
Instance methods
XRTransientInputHitTestSource.cancel()
Experimental
-
Unsubscribes from the transient input hit test.
Examples
Use the XRSession.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;
});
function onXRFrame(time, xrFrame) {
let hitTestResults = xrFrame.getHitTestResultsForTransientInput(
transientHitTestSource,
);
}
To unsubscribe from a transient input hit test source, use the XRTransientInputHitTestSource.cancel()
method. Since the object will no longer be usable, you can clean up and set the XRTransientInputHitTestSource
object to null
.
transientHitTestSource.cancel();
transientHitTestSource = null;
Specifications
Browser compatibility
|
Desktop |
Mobile |
|
Chrome |
Edge |
Firefox |
Internet Explorer |
Opera |
Safari |
WebView Android |
Chrome Android |
Firefox for Android |
Opera Android |
Safari on IOS |
Samsung Internet |
XRTransientInputHitTestSource |
81 |
81 |
No |
No |
68 |
No |
No |
81 |
No |
58 |
No |
13.0 |
cancel |
81 |
81 |
No |
No |
68 |
No |
No |
81 |
No |
58 |
No |
13.0 |
See also