Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. XRTransientInputHitTestResult

XRTransientInputHitTestResult

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.

TheXRTransientInputHitTestResult interface of theWebXR Device API contains an array of results of a hit test for transient input, grouped by input source.

You can get an array ofXRHitTestResult objects for a frame by callingXRFrame.getHitTestResultsForTransientInput().

Instance properties

XRTransientInputHitTestResult.inputSourceRead onlyExperimental

Represents theXRInputSource that was used to compute theresults array.

XRTransientInputHitTestResult.resultsRead onlyExperimental

Represents an array ofXRHitTestResult objects containing the hit test results for the input source, ordered by the distance along the ray used to perform the hit test, with the closest result at position 0.

Instance methods

None.

Examples

Accessing transient input hit test results

Two arrays are used to access transient input hit test results. First, you get an array ofXRTransientInputHitTestResult objects by callingXRFrame.getHitTestResultsForTransientInput(). Second, to get to the actualXRHitTestResult objects for an input source, you dereference theresults property on one of theXRTransientInputHitTestResult objects.

js
// frame loopfunction onXRFrame(time, xrFrame) {  let hitTestResults = xrFrame.getHitTestResultsForTransientInput(    transientHitTestSource,  );  hitTestResults.forEach((resultsPerInputSource) => {    resultsPerInputSource.results.forEach((hitTest) => {      // do something with the hit test      hitTest.getPose(referenceSpace);    });  });}

Filtering input sources

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

js
// frame loopfunction 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

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

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp