HMDVRDevice: getEyeParameters() method
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.
Phương thức getEyeParameters() của giao diện HMDVRDevice 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"), được lưu trong một đối tượng VREyeParameters.
Bao gồm thông tin trường nhìn và nhiều hơn nữa.
Cú pháp
getEyeParameters(whichEye)
Tham số
whichEye-
Một chuỗi đại diện cho mắt mà bạn muốn trả về thông tin. Giá trị có thể là
lefthoặcright.
Giá trị trả về
Một đối tượng VREyeParameters.
Ví dụ
Ví dụ sau được lấy từ code threejs-vr-boilerplate của Mozilla VR Team, cụ thể là tệp VREffect.js. Đầu code, phương thức getEyeParameters() được dùng để truy cập thông tin về từng mắt, sau đó được dùng cho các tính toán kết xuất.
if (vrHMD.getEyeParameters !== undefined) {
const eyeParamsL = vrHMD.getEyeParameters("left");
const eyeParamsR = vrHMD.getEyeParameters("right");
eyeTranslationL = eyeParamsL.eyeTranslation;
eyeTranslationR = eyeParamsR.eyeTranslation;
eyeFOVL = eyeParamsL.recommendedFieldOfView;
eyeFOVR = eyeParamsR.recommendedFieldOfView;
} else {
// …
}