根据事件使相机动画

  • 本文关键字:相机 动画 事件 aframe
  • 更新时间 :
  • 英文 :


使用一个简单的代码,可以在单击对象时移动相机的位置。但是,是否可以使相机动画到这些位置?

这是我的代码:

    <a-scene>
        <a-entity >
            <a-box id="box01" color="#6173F4" position="1 0 0"></a-box>
            <a-box id="box02" color="#6173F4" position="-1 0 0"></a-box>
            <a-camera id="cam">
                <a-cursor></a-cursor>
            </a-camera>
            <script> 
            var cam = document.querySelector('#cam');
            var caja1 = document.querySelector('#box01');
            var caja2 = document.querySelector('#box02');
            caja1.addEventListener('click', function () {
                cam.setAttribute('position' , {x: 1, y: 0, z: 4});
                cam.setAttribute('rotation' , {x: 0, y: 0, z: 0});
            }); 
            caja2.addEventListener('click', function () {
                cam.setAttribute('position' , {x: -3, y: 3, z: 4});
                cam.setAttribute('rotation' , {x: -30, y: -30, z: 0});
            }); 
            </script>
        </a-entity>
    <a-text value="Hello, A-Frame!" color="#FFF"
    position="0 0 1" scale="1.5 1.5 1.5"></a-text>
    <a-sky color="#4069b4"></a-sky>
</a-scene>

don McCurdy让您覆盖了您。检查他的演示,这可能正是您想要的:https://sandbox.donmccurdy.com/checkpoints/(固定损坏的链接)

最新更新