Node classes may fire events that we're interested in monitoring
from outside the scene graph.
For example, SceneJS.Load now exposes its internal state and we
could subscribe to transitions of that through "state-changed"
events. For example:
var myLoad = new SceneJS.Load({ uri: "http://foo.com/..." });
var handler = function(node, params) {
alert("Node " + node.getType() + " has changed state to " + node.getState());
};
myLoad.addListener("state-changed", handler,
// Listener options
{
scope: this // Optional scope for handler call, defaults to this
});
myLoad.removeListener("state-changed", handler);
Listeners may also be registered on nodes through their
constructors, for example:
var collada = new SceneJS.Load({
uri: url,
listeners: {
"state-changed" : {
fn: function(node, params) {
alert("State changed");
}
}
}
});