0

我正在改进 WebXR 应用程序的错误处理,并且在用户启动浏览器应用程序而没有运行 SteamVR(至少对于 VIVE)的常见实例中,我想在提示用户后重新检查 XR 支持运行他们的 XR 平台的软件。

问题是缺少页面刷新,我不知道如何让 navigator.xr 刷新自己。

目前我有以下内容:

let launchingPlatform = false;

async function EvalCompatibility(passedCallback, failedCallback){
    console.log("Evaluating compatibility.");

    let hasImmersive = false;
    if (navigator.xr) {
        //FIXME: Seems to only update with a total page refresh!
        hasImmersive = await navigator.xr.isSessionSupported("immersive-vr");
    }else{
        failedCallback("navigator.xr");
        return;
    }

    if(hasImmersive){
        passedCallback();
        
    }else{
        if(!launchingPlatform){
            launchingPlatform = true;
            //Ask to launch VR app. (SteamVR, Etc..)
            PromptLaunchVRPlatformSoftware();
        }

        if(failureCount <=10){
            failureCount++;
            await new Promise(resolve => setTimeout(resolve, 5000));
            EvalCompatibility(XRSupported, XRSupportFailure);

        }else{
            failedCallback("xr.platform");
        }
    }
}

4

0 回答 0