【发布时间】:2020-02-09 00:44:28
【问题描述】:
在使用 aframe-alongpath-component 的框架中,我想计算动画的每个循环。 我认为事件movingended不是循环触发的?! 当元素到达曲线点 X(可能是端点)时,我如何使用沿着路径触发激活?
【问题讨论】:
标签: aframe
在使用 aframe-alongpath-component 的框架中,我想计算动画的每个循环。 我认为事件movingended不是循环触发的?! 当元素到达曲线点 X(可能是端点)时,我如何使用沿着路径触发激活?
【问题讨论】:
标签: aframe
我的假设是错误的。随着每个循环的移动结束被触发。
let ball = document.createElement('a-sphere');
ball.setAttribute('id', `Ball_${a}`);
ball.setAttribute('class', 'clickable');
ball.setAttribute('src', `#tBall_${a}`);
ball.setAttribute(`alongpath`, `curve: .track${a}; dur: ${pathDuration}; delay: ${startdelay}; loop: true ;`);
ball.addEventListener("movingended", (e) => {
console.log("moving ended:" + bad_hits);
bad_hits++;
});
So i don't need alongpath-trigger-activated. But to answer my question:
let track = document.createElement('a-curve');
track.setAttribute('class', `track${a}`);
scene.append(track);
...
let point5 = document.createElement('a-curve-point');
point5.setAttribute('position', '0 3 -5');
point5.setAttribute('class', 'trigger');
point5.addEventListener("alongpath-trigger-activated", () => {
console.log("point 5 alongpath-trigger-activated");
});
track.append(point5);
【讨论】: