简体   繁体   English

在桌面上模拟加速度计(JavaScript)

[英]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. 问题是我似乎无法正确覆盖这些值,因为在桌面上'accelerationInIncludeGravity'或'devicemotion'返回为'undefined'。 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. 我需要在javascript中执行此操作。

You need hardware or emulation for the values to be present. 您需要硬件或仿真才能显示这些值。 Google Chrome's dev tools has accelerometer emulation. Google Chrome浏览器的开发工具具有加速度计仿真功能。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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