有没有一种方法可以在页面加载时以a帧设置默认的相机方向?

时间:2020-05-14 15:27:26

标签: camera rotation aframe

默认情况下,加载场景时,相机指向前方。但我希望它稍微向上。

我尝试使用rotation属性倾斜相机。首先,它可以工作。但是,当我向下移动摄像机(到默认位置)并尝试向一侧移动时,摄像机会以奇怪的角度移动。如果我不通过相机旋转来加载场景,向上移动并再次向后移动,那是不一样的。

我正在Firefox的台式机上使用1.0.4版本的a-frame,并用鼠标控制场景。

这是我的代码:

<script src="https://aframe.io/releases/1.0.4/aframe.min.js"></script>

<a-scene>

  <a-entity id="rig" rotation="20 0 0">
    <a-entity camera look-controls="reverseMouseDrag: true" cursor="rayOrigin: mouse" position="0 1.6 0"></a-entity>
  </a-entity>

  <a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9" shadow></a-box>
  <a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E" shadow></a-sphere>
  <a-cylinder position="1 0.75 -3" radius="0.5" height="1.5" color="#FFC65D" shadow></a-cylinder>
  <a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#7BC8A4" shadow></a-plane>
  <a-sky src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/Equirectangular_projection_SW.jpg/1920px-Equirectangular_projection_SW.jpg"></a-sky>

</a-scene>

1 个答案:

答案 0 :(得分:-1)

考虑改为旋转a-sky或在所需的起始配置中设置对象场景。请注意,在VR中,您将无法强迫用户朝特定方向看。