【问题标题】:Making an entity rotate with the camera - Aframe使实体随相机旋转 - Aframe
【发布时间】:2019-08-04 23:54:44
【问题描述】:

我正在尝试像这样在 Aframe 中制作一个 rolodex 菜单。

这是目前的故障https://glitch.com/edit/#!/fourth-kitten

我正在尝试让实体通过相机旋转到视图中

   AFRAME.registerComponent('rotate-with-camera', {
    tick: function (){
      console.log(this)
      if(this.el.sceneEl.camera){
        const {rotation} = this.el.sceneEl.camera.parent
        const containerRotation = this.el.getAttribute('rotation')
        this.el.setAttribute('rotation', {...containerRotation, z: containerRotation.y -= rotation._y * 360})
      }
    }
    })

但是,我无法像此示例那样获得良好的平滑滚动,并且我对正确的数学运算感到困惑,以使其在上卷或下卷时保持在相机前以使下一行动画进入视野。

有什么想法吗?

【问题讨论】:

    标签: view three.js menu camera aframe


    【解决方案1】:

    如果你想把它放在相机前面,那么只需使用 parent - child DOM 层次结构:

    <a-camera>
        <a-entity position="0 0 -3></a-entity>
    </a-camera>
    

    这样您的菜单就会出现在摄像头前面,并且会随着摄像头旋转。

    要访问外部元素,您可以在相机向右 - 向左看时稍微移动容器

    故障here

    【讨论】:

      猜你喜欢
      • 2012-10-11
      • 2016-09-28
      • 1970-01-01
      • 2022-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-15
      • 1970-01-01
      相关资源
      最近更新 更多