repo: janusweb
action: commit
revision: 
path_from: 
revision_from: c4f6336d8c1272282c2ab8645ec869b8294a911c:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit c4f6336d8c1272282c2ab8645ec869b8294a911c
Author: James Baicoianu 
Date:   Fri Jun 23 01:23:57 2017 -0700

    Moved basic animation support to janusbase

diff --git a/scripts/janusbase.js b/scripts/janusbase.js
index 01094c35a8f545059fc0d460bc4e5fbf0ea86a65..
index ..1a39b01e9ba6252fec43ca387ed7c84a34aee45f 100644
--- a/scripts/janusbase.js
+++ b/scripts/janusbase.js
@@ -24,6 +24,8 @@ elation.require(['engine.things.generic', 'utils.template'], function() {
         rotate_axis: { type: 'string', default: '0 1 0' },
         rotate_deg_per_sec: { type: 'string' },
         onclick: { type: 'object' },
+        anim_id: { type: 'string' },
+        anim_transition_time: { type: 'float', default: .2 },
       });
       //if (this.col) this.color = this.col;
       elation.events.add(this.room, 'janusweb_script_frame_end', elation.bind(this, this.handleFrameUpdates));
@@ -308,5 +310,22 @@ console.error('dunno what this is', other);
         this.engine.client.player.cursor_style = 'default';
       }
     }
+    this.setAnimation = function(anim_id) {
+      if (!this.activeanimation || anim_id != this.anim_id) {
+        if (!this.animationmixer) return;
+        if (this.activeanimation) {
+          //console.log('pause active animation', this.activeanimation);
+          // TODO - interpolating between actions would make transitions smoother
+          this.activeanimation.stop();
+        }
+        if (this.animationactions && this.animationactions[anim_id]) {
+          var action = this.animationactions[anim_id];
+          //console.log('found action!', anim_id, action);
+          action.play();
+          this.activeanimation = action;
+        }
+        this.anim_id = anim_id;
+      }
+    }
   }, elation.engine.things.generic);
 });

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