Back to Content

XRTransientInputHitTestResult: inputSource property

files/en-us/web/api/xrtransientinputhittestresult/inputsource/index.md

latest993 B
Original Source

{{APIRef("WebXR Device API")}}{{SeeCompatTable}}{{SecureContext_Header}}

The read-only inputSource property of the {{DOMxRef("XRTransientInputHitTestResult")}} interface represents an {{domxref("XRInputSource")}} object that was used to compute the {{domxref("XRTransientInputHitTestResult.results", "results")}} array.

Value

An {{domxref("XRInputSource")}} object.

Examples

Filtering input sources

The inputSource property allows you to filter hit test results by input source.

js
// frame loop
function onXRFrame(time, xrFrame) {
  let hitTestResults = xrFrame.getHitTestResultsForTransientInput(
    transientHitTestSource,
  );

  hitTestResults.forEach((resultsPerInputSource) => {
    if (resultsPerInputSource.inputSource === myPreferredInputSource) {
      // act on hit test results from the preferred input source
    }
  });
}

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • {{domxref("XRInputSource")}}