13

我不确定这是否是正确的提问地点,但我的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

4

1 回答 1

0

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

然而,“devicemotion”事件在我这边也不再适用于 chrome Android(但在 iOS 上运行良好)。

于 2018-03-23T09:19:29.313 回答