有没有办法在页面加载时设置默认的摄像头方向? [英] Is there a way to set the default camera direction when a page loads, in a-frame?

查看:7
本文介绍了有没有办法在页面加载时设置默认的摄像头方向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我尝试使用ROTATION属性倾斜相机。乍一看,它是有效的。但当我将相机向下移动(到其默认位置),然后尝试移动到一侧时,相机以一个奇怪的角度移动。如果我在不旋转摄像机的情况下加载场景,向上移动,然后再次移动,情况就不一样了。

我使用的是1.0.4版本的a-Frame,在桌面上,在Firefox中,用鼠标控制场景。

以下是我的代码:

数据-lang="js"数据-隐藏="假"数据-控制台="真"数据-巴贝尔="假">
<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>

推荐答案

考虑改为旋转a-sky或在您需要的启动配置中设置对象场景。请注意,在VR中,您无法强制用户查看特定方向。

这篇关于有没有办法在页面加载时设置默认的摄像头方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆