Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var waveT = function(callback) {
- return new Transitionable(0)
- .to(Math.PI, 'easeInOut', 1000)
- .to(0, 'easeInOut', 1000, callback);
- };
- var WAVELENGTH = 5;
- var WAVEHEIGHT = 5;
- var wave = buoy.addComponent({
- id: null,
- node: null,
- x: null,
- onMount: function(node) {
- this.id = node.addComponent(this);
- node.requestUpdate(this.id);
- this.node = node;
- self = this;
- var cb = null;
- cb = function() { self.x = waveT(cb); };
- this.x = waveT(cb);
- },
- onUpdate: function() {
- var t = this.x.get();
- this.node.setPosition(t * WAVELENGTH, Math.sin(t) * -(WAVEHEIGHT));
- this.node.setRotation(0, 0, Math.sin(t) / 10);
- this.node.requestUpdateOnNextTick(this.id);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement