【发布时间】:2018-03-18 12:01:07
【问题描述】:
我有一个宇宙飞船模型,我想制作起飞动画。我希望它是这样的,一旦我用光标单击宇宙飞船,动画就会激活。我正在使用动画,但我希望它在光标单击事件时激活。下面是我的 HTML 以及我被 JS 卡住的地方
<a-entity id="spaceship" cursor-animator gltf-model="models/spaceship.gltf" position="-20 -0.855 -5.259" scale="2 2 2" rotation="0 180 0">
<a-animation attribute="position" from="-20 0 -5" to="-20 0 -25" dur="10000"></a-animation>
<a-animation attribute="position" from="-20 0 -25" to="-20 1000 -200" delay="9000" dur="9000"></a-animation>
</a-entity>
// Component to activate spaceship animation on click
AFRAME.registerComponent('cursor-animator', {
init: function () {
this.el.addEventListener('click', function (evt) {
//Code
console.log('I was clicked at: ', evt.detail.intersection.point);
});
}
});
【问题讨论】:
标签: javascript html animation onclick aframe