WebXR项目本地测试及HTTPS配置

WebXR开发过成中,项目编译后需要在本地进行测试和debug,这时候有两个比较方便的选择——使用模拟器或创建本地服务器用VR头显连接测试。

模拟器

Immersive Web Emulator是一款WebXR Emulator for Meta Quest devices。你可以使用它验证一些简单的操作或在没有设备的时候测试XR应用的相关功能。

Item media 3 screenshot
Item media 4 screenshot

实机测试环境配置

我个人倾向于使用vscode以及liveserver插件来测试。由于WebXR的特性,“This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.”(WebXR_Device_API)。因此你需要为liveserver配置ssl证书,否则可能会遇到应用无法打开的状况。

未配置https时,通过VR打开的按钮是灰色的

SSL证书配置

前往下载OpenSSL对应你系统的版本并安装(windows的话,选择x64 light版即可)。打开命令行工具,输入以下指令创建ssl证书及密钥:

openssl req -newkey rsa:2048 -nodes -keyout selfsigned.key -x509 -days 365 -out selfsigned.crt

You will be prompted to fill out information about the certificate (e.g., country, state, etc.), but for local use, you can skip or fill with placeholder info. 密钥会生成在你当前命令行所在路径。

随后进去liveserver的设置,对https进行配置:

"liveServer.settings.https": {
  "enable": true,
  "cert": "path/to/selfsigned.crt",
  "key": "path/to/selfsigned.key",
  "passphrase": ""
}

最后在你的浏览器中用https访问WebXR应用的页面即可正常使用VR模式打开并测试了。

参考

unity-webxr-export

How to use WebXR with Unity – January 2024 Edition

WebXR on a server that isn’t secure

VR / AR Button grey on Oculus Browser

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇