首页 > 解决方案 > A-frame 持续为 gltf 设置动画以转到相机 A-frame 的位置

问题描述

我正在使用 A-frame ( https://aframe.io ) 创建一个 vr 场景,我想知道如何为 gltf 模型设置动画以始终跟随相机。例如,我想使用 A-frame 的动画属性并定位我的模型,使其始终跟随玩家。如果玩家向前移动 10 米,则 gltf 将动画向前 10 个空间。如果玩家向左移动 10 格,无论玩家移动到哪里,摄像机都会跟随玩家。我想让 gltf 模型始终跟随相机。如何才能做到这一点?我的 gltf 模型的代码:

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

<a-scene>
                   <a-gltf-model class="cube" mixin="cube" animation='   property: position; dur: 2500; from: 0 2.3 -1; to: 0 2.5 -1; dir: alternate; autoplay: true; easing: linear; loop: true;' src="https://cdn.glitch.com/bb5471f0-16f5-4309-8c7c-52310dc4ff58%2FRobotfr.glb?v=1625527911166"  position="0 2.3 -1"scale="1.2 1.2 1.2"  speech-command__show="command: assistant; type: attribute; attribute: visible; value: true;"speech-command__hide="command: hide; type: attribute; attribute: visible; value: false;"></a-gltf-model>

</a-scene>

标签: javascriptjquerythree.jsaframewebvr

解决方案


推荐阅读