【问题标题】:a-frame Trigger event using aframe-alongpath-component使用 aframe-alongpath-component 触发事件
【发布时间】:2020-02-09 00:44:28
【问题描述】:

在使用 aframe-alongpath-component 的框架中,我想计算动画的每个循环。 我认为事件movingended不是循环触发的?! 当元素到达曲线点 X(可能是端点)时,我如何使用沿着路径触发激活?

【问题讨论】:

    标签: aframe


    【解决方案1】:

    我的假设是错误的。随着每个循环的移动结束被触发。

          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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-17
      • 2018-12-10
      • 1970-01-01
      • 1970-01-01
      • 2010-10-02
      • 2017-06-18
      相关资源
      最近更新 更多