2016-11-16 2 views
0

カメラを現在の位置からクリックした要素から渡された位置に移動するためのアニメーションを取得しようとしています。この問題は、 'to'の位置をアニメーションに渡すための適切な構文にあるようです。ここに私が持っているものがあります。2番目の引数としてデータを渡すAフレーム位置のアニメーション

<a-entity id="cam-position" position="0 0 1.2" rotation="-0 0 0"> 
     <a-camera look-controls wasd-controls> 
      <a-entity visible="true" cursor="fuse: true; fuse-timeout: 500" 
       position="0 0 -1" 
       scale="0.01 0.01 0.01" 
       geometry="primitive: sphere" 
       material="color: #6AD7FF; shader: standard"> 
       <a-animation begin="click" 
        easing="ease-in" 
        attribute="scale" 
        dur="2000" 
        fill="backwards" 
        from="0.01 0.01 0.01" to="0.04 0.04 0.04"> 
       </a-animation> 
       <a-animation begin="fusing" 
        easing="ease-in" 
        attribute="scale" 
        fill="forwards" 
        from="1 1 1" to="0.1 0.1 0.1" > 
       </a-animation> 
      </a-entity> 
     </a-camera> 
     <a-animation begin="move" 
        attribute="position" 
        dur="2000" 
        from="0 0 1.2" 
        > 
       </a-animation> 
     </a-entity> 

document.querySelector('#cam-position').emit('move',{'to': { x: 0, y: 0, z: -88 } }); 

第2引数とa-アニメーションに 'to'が指定されていなければ正常に動作します。何か案は?ありがとう

答えて

0

moveを放射しているとき、第2引数はイベントの詳細です。アニメーションにはイベントトリガでアニメーションを開始する機能がありますが、イベントの詳細は表示されません。

これは機能ではないため、すべてのイベントを処理するのではなく、animation.setAttribute('to', {...})を実行する必要があります。

document.querySelector('a-animation[begin="move"]').setAttribute('to', '0 0 -88'); 
document.querySelector('#cam-position').emit('move') 
+0

アニメーションはまだ行われていません。位置attrは '0 0 -88'に変更されますが、アニメーションはデフォルトで古い属性に設定されています。コンソールロギングは、変更されたことを示します。新しい「to」ポジションを反映するためにカメラエンティティを更新する必要がありますか、それとも何か不足していますか? –

+0

このAPIを試すこともできます:https://ngokevin.github.io/kframe/components/animation/ – ngokevin

+0

kframe/animationと同じです。 –

関連する問題