Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
Non-standard: This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
The HMDVRDevice
interface of the WebVR API represents a head mounted display, providing access to information about each eye, and allowing us to modify the current field of view.
This interface doesn't define any properties of its own, but it does inherit the properties of its parent interface, VRDisplay
.
-
VRDisplay.hardwareUnitId
Read only
-
Returns the distinct hardware ID for the overall hardware unit that this VRDevice
is a part of. All devices that are part of the same physical piece of hardware will have the same hardwareUnitId
.
-
VRDisplay.displayId
Read only
-
Returns the ID for this specific VRDevice
. The ID shouldn't change across browser restarts, allowing configuration data to be saved based on it.
-
VRDisplay.displayName
Read only
-
A human-readable name to identify the VRDevice
.
The following example, taken from the WebVR spec, finds the first available HMDVRDevice
and its associated PositionSensorVRDevice
, if it has one.
navigator.getVRDevices().then((devices) => {
for (const device of devices) {
if (device instanceof HMDVRDevice) {
gHMD = device;
break;
}
}
if (gHMD) {
for (const device of devices) {
if (
device instanceof PositionSensorVRDevice &&
device.hardwareUnitId === gHMD.hardwareUnitId
) {
gPositionSensor = devices[i];
break;
}
}
}
});