Skip to content

Instantly share code, notes, and snippets.

@xeolabs
Created October 11, 2009 00:30
Show Gist options
  • Save xeolabs/207287 to your computer and use it in GitHub Desktop.
Save xeolabs/207287 to your computer and use it in GitHub Desktop.
SceneJs.MyNewNode = function(cfg) {
cfg = cfg || {};
/** Called when pre-visited during scene traversal
*/
this.preVisit = function() {
var backend = SceneJs.Backend.getNodeBackend(this.getType());
if (backend) {
var someData = {};
backend.doSomethingToCanvas(someData);
}
};
/** Called when post-visited during scene traversal
*/
this.postVisit = function() {
var backend = SceneJs.Backend.getNodeBackend(this.getType());
if (backend) {
var someMoreData = {};
backend.doSomethingElseToCanvas(someMoreData);
}
};
/** Chain a call from this constructor to constructor of Node superclass
*/
SceneJs.Node.superclass.constructor.call(this, SceneJs.apply(cfg, {
getType: function() {
return 'my-node-type';
}
}));
};
/* Extend the Node class with our new MyNewNode class
*/
SceneJs.extend(SceneJs.MyNewNode, SceneJs.Node, {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment