如何在React VR中将相机更改为第3人?

时间:2017-07-21 21:33:44

标签: aframe webvr react-360

在React VR中编写场景有点麻烦,因为你总是卡在第一人称视图中,这使得很难判断放置物体的深度。

默认情况下,相机放在[0, 0, 0]坐标上,我想知道是否有办法控制它。在docs中找不到任何内容,但我知道它们不完整。如果可能的话,它可以为像这样的专用编辑器铺平道路。

editor view in a-frame

3 个答案:

答案 0 :(得分:2)

在这里添加答案。

  1. 您可以使用Nuclide和Atom获得'编辑'感觉,这些链接可以在React VR文档中找到here
  2. 为了移动相机的位置,您可以使用自定义的ThreeJS相机并将其添加到场景中,这样您就可以保持VR元素不受影响

    Ready for new connections

  3. 您的自定义相机可能就像

    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]},
    ],
  }}>