本文介绍了Aframe Move VR相机组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我触发事件时,我会移动相机,该相机在PC上可以正常运行,但当我在手机上以vr模式运行时却无法正常运行.需要在此处修复一些代码:

I move my camera when i trigger an event and it works perfectly on pc but not when im on my phone in the vr-mode. Need to fix this here some code:

<a-entity id="camentity" rotation="0 90 0">
  <a-camera id="cam" user-height="0" wasd-controls-enabled="false" look-controls>
    <a-animation attribute="position" begin="movecam_1" duration="500" from="0 0 0" to="-40 0 -50"></a-animation>
    <a-animation attribute="position" begin="movecam_1_bc" duration="500" from="-40 0 -50" to="0 0 0"></a-animation>
 </a-camera>
</a-entity>

function kameramove_1() {
    document.querySelector( "#cam" ).emit('movecam_1');
    }

function kameramove_1_back() {
    document.querySelector( "#cam" ).emit('movecam_1_bc');
    }

推荐答案

对摄影机装备(摄影机的父级,在您的情况下为假)进行动画处理,而不是摄影机本身:

Animate the camera rig (parent of the camera, camentity in your case) not the camera itself:

    <a-entity id="camentity" rotation="0 90 0">
      <a-animation attribute="position" begin="movecam_1" duration="500" from="0 0 0" to="-40 0 -50"></a-animation>
      <a-animation attribute="position" begin="movecam_1_bc" duration="500" from="-40 0 -50" to="0 0 0"></a-animation>
      <a-camera id="cam"></a-camera>
    </a-entity>

这篇关于Aframe Move VR相机组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 12:22