Latest hit pose in the session's reference space, or null when no surface
was struck this frame (also null until update runs). -Z of this
matrix is the surface normal-ish forward; the translation is the contact
point.
Convenience: the contact point (translation of hitMatrix).
True when a surface was struck on the most recent update.
Whether the active session exposes the hit-test API (feature granted).
Cast from the viewer (head/center) straight ahead — the simplest "look at a surface to place" reticle. Resolves once the source is ready.
Cast from an arbitrary XRSpace — pass a controller's
targetRaySpace (from XrControllers) for a pointer-driven reticle.
An offsetRay re-aims relative to that space.
OptionaloffsetRay: XRRayTransient-input hit-test for handheld (phone) AR: each screen tap is a
short-lived input source. After this, read getTransientResults (or
the convenience hitMatrix, which tracks the first active tap).
profile defaults to the generic touchscreen profile.
OptionaloffsetRay: XRRayRefresh hitMatrix / hitPosition / tracked from this
frame's hit-test results. Call once per XRFrame.
Raw persistent-source results for this frame (empty if none / not started).
Raw transient (per-tap) results for this frame.
Cancel the active hit-test source(s) without disposing the session.
WebXR hit-test helper for placing virtual content on real-world surfaces.
A hit-test source casts a ray (from the viewer/center, a controller's pointing ray, or a screen tap) into the AR runtime's understanding of the room and returns where it strikes a real surface. The canonical use is a placement reticle: each frame, read hitMatrix (the latest strike pose in the session's reference space) and park a reticle mesh there; on a trigger/tap, drop content at that pose (optionally anchoring it — see XrAnchors).
Construct one alongside an XrSession that was created with the
'hit-test'(and, for screen AR,'hit-test'+ transient input) feature, call one of thestart*methods once (it's async — the runtime resolves the source), then call update everyXRFramebefore reading the pose.Part of the AR half of the WebXR integration — see TODO/webxr-integration.md.