亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

AFRAME動畫——如何重用動畫

AFRAME動畫——如何重用動畫

繁花如伊 2023-02-17 16:30:02
我想要一個像這樣的不規則動畫(這是在水滴的情況下):滴沒有什么滴滴滴沒有什么沒有什么有沒有辦法做到這一點或循環一個很長的滴水動畫?
查看完整描述

1 回答

?
叮當貓咪

TA貢獻1776條經驗 獲得超12個贊

如何創建一個自定義組件來管理動畫?


如果您正在使用動畫組件- 您可以提供一個事件名稱,這將觸發動畫:


<a-sphere id="driplet" animation="...; startEvents: drip">

現在你想“排隊”動畫:播放,等待,播放,播放,等待。因此,讓我們通過使用固定間隔來發出drip事件或等待來做到這一點:


AFRAME.registerComponent("foo", {

  init: function() {

    // the mentioned "queue"

    const animationQueue = ["drip", "", "drip", "drip", ""]


    // grab the animations interval

    var interval = this.el.getAttribute("animation").dur


    // we'll use this to know where we are in the queue

    var animationIdx = 0;


    // set the event cycle

    var intervalIdx = setInterval(e => {

       // emit the event from the queue

       this.el.emit(animationQueue[animationIdx])


       // set the animationIdx to the 'next' item in queue

       if (animationIdx < animationQueue.length - 1)

         animationIdx++;

       else

         animationIdx = 0;

    }, interval);      

  }

})

在這個小提琴中查看



查看完整回答
反對 回復 2023-02-17
  • 1 回答
  • 0 關注
  • 90 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號