如何解决设备运动脚本的问题?

15

我不确定这是否是正确的地方来询问,但我有一个与devicemotion脚本有关的问题。

我有一些代码在页面加载时运行,以检查是否有可用的陀螺仪。我是这样做的:

function check_user_hardware(){

    if (mobile_size <= 600) {
        hidden = true;
    }
    console.log("checking hardware");
    giro_timer = setTimeout(update_gyro_value, 30);
    window.addEventListener("devicemotion", function(event){
        console.log("device motion?");
        if(event.rotationRate.alpha || event.rotationRate.beta || event.rotationRate.gamma){
            calculate_rotation_mesh_pos(event.rotationRate.beta, event.rotationRate.gamma);
            if (!gyroscope) {
                gyroscope = true;
                console.log("gyroscope here");
                current_interaction_mode = 'gyroscope_option';
                set_user_ui_elements();
            }
        }else{
            followMouse = true;
            console.log("no gyroscope here");
            current_interaction_mode = 'followMouse_option';
            set_user_ui_elements();
            window.addEventListener('mousemove', get_user_mouse_pos);
        }
    });
}
这在几周前还可以正常工作,但现在不再起作用。 我在控制台看到以下内容:
checking hardware

就是这样。为什么我的devicemotion事件不会触发? 即使在我使用基本SSL加密的网站上也无法工作,为什么? 我需要某种特殊的SSL加密吗?
这是怎么回事? 欢迎所有建议!
如果需要更多信息,我将乐意提供。
您可以在此处查看有关该网站的详细信息:gravient.thomashoek.com

1个回答

0

我在我的Web应用程序上遇到了同样的问题。我看到Chromium 62存在加速度计问题,但似乎在v.63中已经修复了。

然而,在我的Chrome Android上,“devicemotion”事件也不再起作用(但在iOS上完美运行)。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接