Skip to content

Releases: play-co/accelerometer

rotationRate fixes

06 Mar 12:29
@mgh mgh
Compare
Choose a tag to compare

Mobile browsers incorrectly map alpha, beta, and gamma. This release remaps those to the proper names and fixes inconsistencies in radians and degrees.

v3.0.0: switch to devicemotion events

06 Mar 09:27
@mgh mgh
Compare
Choose a tag to compare

Summary

  • accelerometer plugin emits devicemotion events with same motion event api as an HTML5 browser on all platforms
  • fixes incompatibilities between native and mobile browsers, namely:
    • mobile Safari (iOS): acceleration values are inverted (relative to other platforms)
    • iOS native: acceleration values are scaled by -9.8 (relative to other platforms)
  • also exposes native APIs over window.addEventListener for compatibility (existing html5 browser code can run unmodified on native), but this is not recommended for new code since direct use of the accelerometer plugin API avoids browser differences

Usage

  • place the import at the top of your Application.js:

     import accelerometer;
    
  • use the devicemotion event:

     accelerometer.on('devicemotion', function (evt) {
        // these values should be identical on all devices
        evt.acceleration.x...
     });
    
  • (not recommended, but supported for compatibility) native DOM API window.addEventListener:

     window.addEventListener('devicemotion', function (evt) {
        // WARNING: these values will not be the same in all browsers.  Use the devkit
        // accelerometer api directly for consistent values.
        evt.acceleration.x...
     });
    
  • event objects have the following properties:

     evt.acceleration.x
     evt.acceleration.y
     evt.acceleration.z
     evt.accelerationIncludingGravity.x
     evt.accelerationIncludingGravity.y
     evt.accelerationIncludingGravity.z
     evt.rotationRate.alpha
     evt.rotationRate.beta
     evt.rotationRate.gamma
    

Devkit2 Support

25 Nov 19:46
Compare
Choose a tag to compare

Initial commit with DevKit2 Support

Devkit1 Support

25 Nov 19:42
Compare
Choose a tag to compare

Last commit from master before switching to DevKit2