Hit testLimited availability
The getHitTestResults() method of an XRFrame object helps place objects in an augmented reality session by finding where cast rays intersect with real-world geometry.
Not yet supported in all major browsers — check the table and provide a fallback.
Browser support
DesktopChrome
1–80Not supported
81+Supportedsince Apr 7, 2020
Current: 155Edge
12–80Not supported
81+Supportedsince Apr 13, 2020
Current: 154Firefox
✕Not supportedup to 157
Current: 157Safari
✕Not supportedup to 27
Current: 27MobileChrome Android
18–80Not supported
81+Supportedsince Apr 7, 2020
Current: 155Firefox Android
✕Not supportedup to 157
Current: 157Safari iOS
✕Not supportedup to 27
Current: 27How to use
Not supported in Firefox, Safari, Firefox Android, Safari iOS. Use feature detection below and provide a fallback (or a polyfill) for those browsers.
Example
Full syntax and examples are on MDN: getHitTestResults.
Feature detection
JS · check before using
if ("XRHitTestResult" in globalThis) {
// XRHitTestResult is available
} else {
// load a polyfill or use a fallback
}Sub-features
Support for each part of the feature (18). The overall table above shows when the whole feature works.
| Sub-feature | Chrome | Edge | Firefox | Safari | Chrome Android | Firefox Android | Safari iOS |
|---|---|---|---|---|---|---|---|
| XRFrame.getHitTestResults | 81 | 81 | ✕ | ✕ | 81 | ✕ | ✕ |
| XRFrame.getHitTestResultsForTransientInput | 81 | 81 | ✕ | ✕ | 81 | ✕ | ✕ |
| XRHitTestResult | 81 | 81 | ✕ | ✕ | 81 | ✕ | ✕ |
| XRHitTestResult.getPose | 81 | 81 | ✕ | ✕ | 81 | ✕ | ✕ |
| XRHitTestSource | 81 | 81 | ✕ | ✕ | 81 | ✕ | ✕ |
| XRHitTestSource.cancel | 81 | 81 | ✕ | ✕ | 81 | ✕ | ✕ |
| XRRay | 81 | 81 | ✕ | ✕ | 81 | ✕ | ✕ |
| XRRay.XRRay | 81 | 81 | ✕ | ✕ | 81 | ✕ | ✕ |
| XRRay.direction | 81 | 81 | ✕ | ✕ | 81 | ✕ | ✕ |
| XRRay.matrix | 81 | 81 | ✕ | ✕ | 81 | ✕ | ✕ |
| XRRay.origin | 81 | 81 | ✕ | ✕ | 81 | ✕ | ✕ |
| XRSession.requestHitTestSource | 81 | 81 | ✕ | ✕ | 81 | ✕ | ✕ |
| XRSession.requestHitTestSourceForTransientInput | 81 | 81 | ✕ | ✕ | 81 | ✕ | ✕ |
| XRTransientInputHitTestResult | 81 | 81 | ✕ | ✕ | 81 | ✕ | ✕ |
| XRTransientInputHitTestResult.inputSource | 81 | 81 | ✕ | ✕ | 81 | ✕ | ✕ |
| XRTransientInputHitTestResult.results | 81 | 81 | ✕ | ✕ | 81 | ✕ | ✕ |
| XRTransientInputHitTestSource | 81 | 81 | ✕ | ✕ | 81 | ✕ | ✕ |
| XRTransientInputHitTestSource.cancel | 81 | 81 | ✕ | ✕ | 81 | ✕ | ✕ |