title: How do I detect if a device has a gyroscope in a web browser?
body: <p>I am using THREE.js and creating a web-app where the user can rotate the device and the scene will move accordingly. Something similar to <a href="https://va3c.github.io/three.js/examples/misc_controls_deviceorientation.html" rel="noreferrer">this</a>.</p>
  <p>I am having a problem differentiating between devices that have a gyroscope and those that don't.</p>
  <p>Detecting devices that don't have orientation sensors at all is easy. All the alpha, beta, gamma values of DeviceOrientationEvent are null. But, if a mobile device doesn't have a gyro, it still gives <strong>alpha</strong>, <strong>beta</strong>, <strong>gamma</strong> values in <strong>DeviceOrientationEvent</strong>. The problem is these values are very noisy, and cause a lot of <strong>shaking</strong> in the scene. So, I want to disable the device orientation for these devices. But, so far I haven't been able to find how to make out if the data is coming from a gyro or accelerometer (that's my guess on where the data is coming from).</p>
  <p>I don't know if it helps, but a good example of how this is handled can be seen <a href="http://krpano.com/tours/paris" rel="noreferrer">here</a>. (Press the axis like icon at the bottom; you'll have to see it on a device that doesn't have a gyroscope and a gyroscope to see the difference). What they are doing for devices without a gyroscope is only updating the <em><strong>pitch</strong></em> and the <em><strong>roll</strong></em>. The <em><strong>yaw</strong></em> isn't updated when you rotate with the phone.</p>
  <p>So, it is definitely possible, but I haven't yet found out how even after searching a lot. It would be great if anyone could help.</p>
  <p>Thanks a lot.</p>
  <h1>EDIT:</h1>
  <p>On devices that just have an accelerometer, like <em>MOTO E</em>, all values are null - <strong>DeviceOrientationEvent</strong> and <strong>rotationRate</strong> - with the only exception of <strong>accelerationIncludingGravity</strong>. But, the device I was testing earlier, that didn't have a gyro but still gave alpha, beta, gamma values for <strong>DeviceOrientationEvent</strong>, seems to have <strong>2</strong> accelerometers according to <a href="http://www.gsmarena.com/motorola_moto_g_(3rd_gen)-7247.php" rel="noreferrer">the &quot;sensors&quot; details on GSM Arena</a>. That is how I suspect it was able to give DeviceOrientationEvent data, albeit <em>noisy</em>. Looks like 2 accelerometers aren't enough to give rotation rate ;)</p>