Gyroscope: x property
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Thuộc tính chỉ đọc x của giao diện Gyroscope trả về một số xác định vận tốc góc của thiết bị dọc theo trục x của nó.
Giá trị
Một Number.
Ví dụ
Gyroscope thường được đọc trong bộ gọi lại sự kiện reading.
Trong ví dụ dưới đây, điều này xảy ra sáu mươi lần mỗi giây.
js
let gyroscope = new Gyroscope({ frequency: 60 });
gyroscope.addEventListener("reading", (e) => {
console.log(`Angular velocity along the X-axis ${gyroscope.x}`);
console.log(`Angular velocity along the Y-axis ${gyroscope.y}`);
console.log(`Angular velocity along the Z-axis ${gyroscope.z}`);
});
gyroscope.start();
Thông số kỹ thuật
| Specification |
|---|
| Gyroscope> # gyroscope-x> |