MDN Web Docs

Instance properties

None.

Instance methods

XRTransientInputHitTestSource.cancel()

Unsubscribes from the transient input hit test.

Examples

Getting an XRTransientInputHitTestSource object for a session

Use the XRSession.requestHitTestSourceForTransientInput() method to get a transient input hit test source.

js

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 loop
function 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 the XRTransientInputHitTestSource.cancel() method. Since the object will no longer be usable, you can clean up and set the XRTransientInputHitTestSource object to null.

js

transientHitTestSource.cancel();
transientHitTestSource = null;

Specifications

Specification
WebXR Hit Test Module
# transient-input-hit-test-source-interface

Browser compatibility

See also

Help improve MDN

Yes No

Learn how to contribute

This page was last modified on by MDN contributors.

Read the original on developer.mozilla.org ↗