PositionSensorVRDevice: resetSensor() 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 resetSensor() của giao diện VRDisplay có thể được dùng để đặt lại cảm biến nếu muốn, trả về các giá trị vị trí và hướng về không.
Cú pháp
resetSensor()
Tham số
Không có.
Giá trị trả về
Không có (undefined).
Ví dụ
Demo sau sử dụng WebVR API để cập nhật view của một cảnh CanvasRenderingContext2D đơn giản trên mỗi frame của vòng lặp requestAnimationFrame. Demo có, ngoài các thứ khác, một nút "Reset Sensor" trong UI, khi được nhấn sẽ chạy hàm resetSensor() trên cảm biến vị trí. JavaScript trông như sau:
document.querySelector("button").onclick = () => {
gPositionSensor.resetSensor();
};
Khi nút được nhấn, vị trí, hướng hiện tại, v.v. của cảm biến/màn hình gắn đầu được đặt thành 0, điều này làm cho phương thức hữu ích khi hiệu chỉnh khi ứng dụng được tải lần đầu.