在React VR中编写场景有点麻烦,因为你总是卡在第一人称视图中,这使得很难判断放置物体的深度。
默认情况下,相机放在[0, 0, 0]
坐标上,我想知道是否有办法控制它。在docs中找不到任何内容,但我知道它们不完整。如果可能的话,它可以为像aframe这样的专用编辑器铺平道路。
答案 0 :(得分:2)
在这里添加答案。
为了移动相机的位置,您可以使用自定义的ThreeJS相机并将其添加到场景中,这样您就可以保持VR元素不受影响
Ready for new connections
您的自定义相机可能就像
const vr = new VRInstance(bundle,"ReactVR",parent, {
camera:customCamera,/*your custom threeJS camera*/
...options,
});
答案 1 :(得分:1)
对于背景信息,在A-Frame中,您可以更改为您想要的任何相机或移动活动相机:
<a-scene>
<a-entity position="0 0 -5"><a-entity id="camera1" camera="active: true"></a-entity>
<a-entity position="5 0 5"><a-entity id="camera2" camera="active: false"></a-entity>
</a-scene>
<script>
document.querySelector('#camera2').setAttribute('camera', 'active', true);
</script>
答案 2 :(得分:1)
您可以使用变换来更改相机位置,这应该会产生与屏幕类似的效果:
<View style={{
transform: [
{translate: [-20, -10, -20]},
],
}}>