Get to know MDN better
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
The XRRay() constructor creates a new XRRay object which is a geometric ray described by an origin point and a direction vector.
A point object defining the 3-dimensional point in space that the ray originates from, in meters. All dimensions are optional, however, if provided, the origin's w property must be 1.0. The object is initialized to { x: 0.0, y: 0.0, z: 0.0, w: 1.0 } by default.
direction OptionalA vector object defining the ray's 3-dimensional directional vector. All dimensions are optional, however, if provided, the direction's w property must be 0.0. The object is initialized to: { x: 0.0, y: 0.0, z: -1.0, w: 0.0 } by default.
transform OptionalAn XRRigidTransform object representing the position and orientation of the ray.
A newly-created XRRay object.
Thrown if one of the following conditions is met:
The XRRay() constructor allows to creating new rays by either providing an origin point and a direction vector, or by passing in an XRRigidTransform object.
| WebXR Hit Test Module # dom-xrray-xrray |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Feb 5, 2024 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.