android webview vr,WebVR in WebView

WebVR in WebView

06/12/2018

2 分钟可看完

本文内容

As of the Windows 10 April 2018 Update (version 1803, build 17134, EdgeHTML 17), WebVR is supported in WebView controls in Windows 10 apps. The WebView control enables you to host web content in your Windows 10 app. See Microsoft Edge WebView for Windows 10 apps for more information about WebView.

Add WebVR support to a WebView control

In order for your WebView control to host WebVR content, there are a few steps you'll have to take.

Initialize the WebView programmatically to run in a separate process. You'll have to declare, initialize, and add it to the UI programmatically (rather than declaratively in the XAML or HTML).

Add a PermissionRequested event handler for the WebView. In it, allow the permission request.

The following sample declares and initializes a WebView, handles the PermissionRequested event, adds the WebView to the UI, and navigates to a WebVR site.

WebView webView;

public MainPage()

{

this.InitializeComponent();

webView = new WebView(WebViewExecutionMode.SeparateProcess);

webView.PermissionRequested += MyWebView_PermissionRequested;

MyGrid.Children.Add(webView);

Grid.SetRow(webView, 1);

webView.Navigate("https://webvr.info/samples/03-vr-presentation.html");

}

private void MyWebView_PermissionRequested(

WebView sender, WebViewPermissionRequestedEventArgs args)

{

args.PermissionRequest.Allow();

}

let wvprocess = new MSWebViewProcess();

// WebViews created with the same MSWebViewProcess object share the same process

wvprocess.CreateWebViewAsync().then(function (webview) {

webview.navigate("https://webvr.info/samples/03-vr-presentation.html");

document.body.appendChild(webview);

webview.addEventListener("MSWebViewPermissionRequested", e => {

e.permissionRequest.allow();

});

});

See also

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值