files/en-us/web/api/hmdvrdevice/index.md
{{APIRef("WebVR API")}}{{Deprecated_Header}}{{Non-standard_Header}}
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, {{domxref("VRDisplay")}}.
VRDisplay.hardwareUnitId {{ReadOnlyInline}}
VRDevice is a part of. All devices that are part of the same physical piece of hardware will have the same hardwareUnitId.VRDevice. The ID shouldn't change across browser restarts, allowing configuration data to be saved based on it.VRDevice.The following example, taken from the WebVR spec, finds the first available HMDVRDevice and its associated {{domxref("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;
}
}
}
});
{{Compat}}