Module that provides unified motion data across platforms (iOS and Android) and browsers.
npm install [--save] collective-soundworks/motion-input
const motionInput = require('motion-input');
motionInput
.init(['accelerationIncludingGravity'])
.then(([accelerationIncludingGravity]) => {
if (accelerationIncludingGravity.isValid) {
accelerationIncludingGravity.addListener(val => {
console.log(val)
});
}
// ...
})
.catch(err => console.error(err.stack));
Due to some weird (buggy ?) behavior in Chrome and and Firefox, if you need to use both 'acceleration'
and 'orientation'
modules, 'acceleration'
should always be initialized and listened before 'orientation'
.