问题
我想从HTML按钮的回调中启动一个基于a帧的WebXR环境。稍后我将从JavaScript中添加一个实体。
环境
在Windows 10的Chrome版本84.0.4147.89 (正式构建) beta (64位)上运行一个框架1.0.4。
我试过什么
我在html中使用a-平面在a场景前面填充了HTML按钮,但是html按钮是不可点击的:
<body>
<button id="startButton" onclick="onButtonClicked()">START</button>
<a-scene>
<a-plane id="plane1" position="0 0 0" rotation="-90 0 0" width="4" height="4" color="#7BC8A4" wireframe="false"></a-plane>
</a-scene>
</body>我只使用一个HTML按钮填充了主体,然后从按钮回调中插入了WebXR innerHTML。这似乎有点奏效。按下html按钮后,VR按钮出现,但当我按VR按钮时,画布就变黑了。在使用JavaScript动态添加WebXR元素而不是innerHTML时,我会得到相同的行为。
到目前为止,最好的解决方案是实现呈现管道(requestSession()、requestReferenceSpace()、drawScene()等),但我很难使drawScene()得到正确的实现。
问题
是否有一种方法可以简单地启动现有的WebXR管道,这样我就不必自己实现呈现管道了?
也许是这样的:
navigator.xr.initXR()或
navigator.xr.requestSession('immersive-vr').then(navigator.xr.onSessionStarted);发布于 2020-07-17 19:22:27
A-框架带有内置的enter VR按钮,您可以通过vr-模式-ui组件来定制该按钮。
<a-scene
vr-mode-ui="enterVRButton: #myEnterVRButton; enterARButton: #myEnterARButton">
<!-- Style the button with images or whatever. -->
<a id="myEnterVRButton" href="#"></a>
<a id="myEnterARButton" href="#"></a>
</a-scene>示例:https://glitch.com/edit/#!/fluoridated-ruby-whip?path=index.html%3A16%3A105
https://stackoverflow.com/questions/62957192
复制相似问题