简体   繁体   中英

Simulate the Accelerometer on desktop (Javascript)

I am looking to simulate the Accelerometer on the 'desktop'. The problem is I can't seem to correctly override the values since 'accelerationIncludingGravity' or 'devicemotion' come back as 'undefined' on desktop. What I would like to do is manually set this value like so:

document.getElementById('myButton').addEventListener('click', function(){
    accelerationIncludingGravity.z = 100;
});

Is there anyway to do this? I need to do this in javascript.

You need hardware or emulation for the values to be present. Google Chrome's dev tools has accelerometer emulation.

https://developer.chrome.com/devtools/docs/device-mode#device-sensors

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM