HMDVRDevice
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 not standardized. We do not recommend using non-standard features in production, as they have limited browser support, and may change or be removed. However, they can be a suitable alternative in specific cases where no standard option exists.
Giao diện HMDVRDevice của WebVR API đại diện cho một màn hình đội đầu, cung cấp quyền truy cập thông tin về mỗi mắt và cho phép chúng ta sửa đổi trường nhìn hiện tại.
Phương thức phiên bản
HMDVRDevice.getEyeParameters()Deprecated Non-standard-
Trả về các tham số hiện tại cho mắt được chỉ định trong tham số của nó ("left" hoặc "right"), chẳng hạn như thông tin trường nhìn, được lưu trong một đối tượng
VREyeParameters. HMDVRDevice.setFieldOfView()Deprecated Non-standard-
Đặt trường nhìn cho cả hai mắt.
Thuộc tính phiên bản
Giao diện này không định nghĩa bất kỳ thuộc tính riêng nào, nhưng nó kế thừa các thuộc tính của giao diện cha, VRDisplay.
VRDisplay.hardwareUnitIdRead only-
Trả về ID phần cứng riêng biệt cho đơn vị phần cứng tổng thể mà
VRDevicenày là một phần. Tất cả các thiết bị là một phần của cùng một phần cứng vật lý sẽ có cùnghardwareUnitId. VRDisplay.displayIdRead only-
Trả về ID cho
VRDevicecụ thể này. ID không nên thay đổi qua các lần khởi động lại trình duyệt, cho phép lưu dữ liệu cấu hình dựa trên nó. VRDisplay.displayNameRead only-
Tên có thể đọc được của con người để nhận dạng
VRDevice.
Ví dụ
Ví dụ sau, lấy từ thông số kỹ thuật WebVR, tìm HMDVRDevice đầu tiên có sẵn và PositionSensorVRDevice liên quan của nó, nếu có.
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;
}
}
}
});