Advertisement
Guest User

Untitled

a guest
May 27th, 2015
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var waveT = function(callback) {
  2.     return new Transitionable(0)
  3.         .to(Math.PI, 'easeInOut', 1000)
  4.         .to(0, 'easeInOut', 1000, callback);
  5. };
  6.  
  7. var WAVELENGTH = 5;
  8. var WAVEHEIGHT = 5;
  9.  
  10. var wave = buoy.addComponent({
  11.     id: null,
  12.     node: null,
  13.     x: null,
  14.     onMount: function(node) {
  15.         this.id = node.addComponent(this);
  16.         node.requestUpdate(this.id);
  17.         this.node = node;
  18.         self = this;
  19.         var cb = null;
  20.         cb = function() { self.x = waveT(cb); };
  21.         this.x = waveT(cb);
  22.     },
  23.     onUpdate: function() {
  24.         var t = this.x.get();
  25.  
  26.         this.node.setPosition(t * WAVELENGTH, Math.sin(t) * -(WAVEHEIGHT));
  27.         this.node.setRotation(0, 0, Math.sin(t) / 10);
  28.  
  29.         this.node.requestUpdateOnNextTick(this.id);
  30.     }
  31. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement