我有一个太空船模型,我想为它的起飞制作动画。我希望这样,一旦我用光标点击宇宙飞船,动画就会激活。我有动画工作使用,但我想它激活后,光标点击事件。下面是我的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>
AFRAME.registerComponent('cursor-animator', {
init: function () {
this.el.addEventListener('click', function (evt) {
console.log('I was clicked at: ', evt.detail.intersection.point);
});
}
});