repo: janusweb
action: commit
revision: 
path_from: 
revision_from: 5b7aceb8698a952e25b16078bb868e84d7f786ed:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit 5b7aceb8698a952e25b16078bb868e84d7f786ed
Author: James Baicoianu 
Date:   Tue Sep 3 11:24:29 2024 -0700

    player.hasAnimation() / player.getAnimation() / player.setAnimationSequence()y

diff --git a/scripts/janusplayer.js b/scripts/janusplayer.js
index 848d94f776acd6e0b2323d4ad0e868e4f540285c..
index ..c9850abb4c54fb96dc10f5ddbfcd40657285cb04 100644
--- a/scripts/janusplayer.js
+++ b/scripts/janusplayer.js
@@ -1260,5 +1260,26 @@ document.body.dispatchEvent(click);
       });
       setTimeout(() => { this.defaultanimation = currentanimation; }, t * 1000);
     }
+    this.hasAnimation = function(anim_id) {
+      return anim_id in this.ghost.body.animations;
+    }
+    this.getAnimation = function(anim_id) {
+      if (this.hasAnimation(anim_id)) {
+        return this.ghost.body.animations[anim_id];
+      }
+      return false;
+    }
+    this.setAnimationSequence = function(sequence) {
+      let cumtime = 0;
+      for (let i = 0; i < sequence.length; i++) {
+        let anim_id = sequence[i];
+        let anim = this.getAnimation(anim_id);
+        if (anim) {
+          let clip = anim.getClip();
+          setTimeout(() => this.defaultanimation = anim_id, cumtime);
+          cumtime += clip.duration;
+        }
+      }
+    }
   }, elation.engine.things.player);
 });

-----END OF PAGE-----