2017-07-21 29 views
2

在React VR中编写场景有点麻烦,因为你总是被困在第一人称视图中,这使得很难判断物体放置的深度。如何将相机更改为React VR中的第三人?

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

editor view in a-frame

回答

1

添加到这里的答案。

  1. 你可以得到一个“editor'y觉得使用核素和Atom,这些链接的阵营VR文档here
  2. 发现为了移动相机的位置,你可以使用自定义ThreeJS摄像头并将其添加到您的场景,这样您可以留下您的VR元素不变

    const vr = new VRInstance(bundle,"ReactVR",parent, { camera:customCamera,/*your custom threeJS camera*/ ...options, });

您的自定义相机也能像

import { PerspectiveCamera } from "three"; 

const VIEW_ANGLE = 60; 
const ASPECT = document.body.clientWidth/document.body.clientHeight; 
const NEAR = 0.1; 
const FAR = 10000; 


const camera = new PerspectiveCamera(VIEW_ANGLE, ASPECT, NEAR, FAR); 

camera.name = "Custom3JSCamera"; 

camera.position.set(0,0,5); 
export default camera; 
+0

谢谢@luciferous,我喜欢这种方法,因为它不需要改变你的场景,它实际上是一个单独的相机,这正是我所期待的。 – Valentin

1

的背景信息,在A型框架,你可以改变你想要的任何相机或移动活动的摄像头的地方:

<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> 
1

您可以使用变换来改变摄像头的地方,这应该给你一个类似于你的屏幕上的效果:

<View style={{ 
    transform: [ 
     {translate: [-20, -10, -20]}, 
    ], 
    }}> 
相关问题