Demo

Gyroscope (Gryoscope)

Rotation rate (alpha, beta, gamma) via devicemotion. The class name in source is Gryoscope — keep that spelling when importing.

Gyroscope (Gryoscope)

Rotation rate (alpha, beta, gamma) via devicemotion. The class name in source is Gryoscope — keep that spelling when importing.

  • Methods: start(callback), stop()
  • Import Gryoscope, not Gyroscope
TSXGryoscope — React
1import { useEffect, useState } from "react"; 2import { Gryoscope } from "@quan-erp/shared-frontend-core"; 3 4export function GyroDebug() { 5 const [rate, setRate] = useState({ alpha: 0, beta: 0, gamma: 0 }); 6 7 useEffect(() => { 8 const gyro = Gryoscope.instance; 9 gyro.start((data) => { 10 setRate({ 11 alpha: data.alpha ?? 0, 12 beta: data.beta ?? 0, 13 gamma: data.gamma ?? 0, 14 }); 15 }); 16 return () => gyro.stop(); 17 }, []); 18 19 return <pre>{JSON.stringify(rate)}</pre>; 20}