From 074785cea106179cb3305637055ab0a009ca74f2 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:52 -0500 Subject: initial commit --- files/ru/web/api/gyroscope/index.html | 71 +++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 files/ru/web/api/gyroscope/index.html (limited to 'files/ru/web/api/gyroscope/index.html') diff --git a/files/ru/web/api/gyroscope/index.html b/files/ru/web/api/gyroscope/index.html new file mode 100644 index 0000000000..acb3658d59 --- /dev/null +++ b/files/ru/web/api/gyroscope/index.html @@ -0,0 +1,71 @@ +--- +title: Gyroscope +slug: Web/API/Gyroscope +translation_of: Web/API/Gyroscope +--- +
{{APIRef("Gyroscope")}}
+ +

Gyroscope интерфейс Sensor API дает возможность считать позицию устройства по всем трем осям.

+ +

Для использования того сенсора пользователю нужно предоставить доступ устройства к 'gyroscope' через {{domxref('Permissions')}} API.

+ +

If a feature policy blocks use of a feature it is because your code is inconsistent with the policies set on your server. This is not something that would ever be shown to a user. See {{httpheader('Feature-Policy')}} for implementation instructions.

+ +

Конструктор

+ +
+
{{domxref("Gyroscope.Gyroscope()")}}
+
Создание нового Gyroscope объекта.
+
+ +

Свойства

+ +
+
{{domxref('Gyroscope.x')}} {{readonlyinline}}
+
Возвращает угловое отклонение устройства по оси X.
+
{{domxref('Gyroscope.y')}} {{readonlyinline}}
+
Возвращает угловое отклонение устройства по оси Y.
+
{{domxref('Gyroscope.z')}} {{readonlyinline}}
+
Возвращает угловое отклонение устройства по оси Z.
+
+ +

Примеры

+ +

Гироскоп обычно использует {{domxref('Sensor.onreading')}} событие для вызова callback-функции. В примере ниже функция вызывается 6 раз в секуунду.

+ +
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();
+ +

Спецификации

+ + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Generic Sensor')}}{{Spec2('Generic Sensor')}}Defines sensors in general.
{{SpecName('Gyroscope','#gyroscope-interface','Gyroscope')}}{{Spec2('Gyroscope')}}Initial definition.
+ +

Поддержка браузерами

+ + + +

{{Compat("api.Gyroscope")}}

-- cgit v1.2.3-54-g00ecf