Skip to content

Instantly share code, notes, and snippets.

@drart
Created November 10, 2014 16:36
Show Gist options
  • Save drart/c3f06bcfdca8b13d37f5 to your computer and use it in GitHub Desktop.
Save drart/c3f06bcfdca8b13d37f5 to your computer and use it in GitHub Desktop.
Simple Verold + jQuery example component
var $ = require('jquery');
function Component() {
this.shouldrotate = false;
}
Component.prototype = new VAPI.VeroldComponent();
/**
* Called as soon as the VeroldEntity begins to load.
*/
Component.prototype.init = function() {
var that = this;
$("#home").hover(
function(){ that.shouldrotate = true; }, // hover over
function(){ that.shouldrotate = false; } // hover off
);
};
Component.prototype.objectCreated = function() {
// this.getThreeData() is available
};
Component.prototype.update = function(delta) {
var threeData;
if (this.hasThreeData()) {
// It is safe to manipulate threeData now.
threeData = this.getThreeData();
if(this.shouldrotate)
{
threeData.rotation.y += 0.1;
}
}
};
Component.prototype.shutdown = function() {
};
return Component;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment