手动启用设备运动 Aframe 1.0.4

问题描述 投票:0回答:1

我添加了 device-orientation-permission-ui="enabled: false" 的场景,因为我想自己处理所有的弹出窗口和加载屏幕。

当我请求访问运动传感器后,通过。

$("#btn_enable").one("click", checkGyro);

function checkGyro() {

    DeviceMotionEvent.requestPermission().then(permissionState => {
        if (permissionState === 'granted') {
            window.addEventListener('devicemotion', () => {});
        }
    });
    .catch(console.error);

}

设备(iPad iOS 13.4的移动查看模式)显示出弹出式窗口请求访问运动和方向传感器,我允许这样做,但是环视场景的能力被禁用。

我缺少什么来让这个工作?

我在控制台中得到了这个。

webvr-polyfill.js:2584 TypeError: null is not an object (evaluating 
'i.alpha')
(anonymous) @ webvr-polyfill.js:2584
(anonymous) @ webvr-polyfill.js:2560
(anonymous) @ [native code]:1
aframe
1个回答
0
投票

请求权限必须由用户操作触发,比如点击或点击。根据API安全和隐私政策,未经用户同意,不能由页面启动。

© www.soinside.com 2019 - 2024. All rights reserved.