Add ability to get state of SceneJS.Load and SceneJS.LoadCollada
nodes.
A SceneJS.Load node has four states it can be in:
- STATE_INITIAL - node has been defined, but not
rendered yet and hence has not yet made its load request
- STATE_LOADING - has made its load request and
is waiting for the response, which it will receive on a future
render of its scene graph
- STATE_LOADED - has successfully received its
response and loaded the content into its subgraph
- STATE_ERROR - attempted to load but failed
(eg. HTTP 404) and now permanently inactivated by SceneJS
When a SceneJS.Load has not been rendered in a while (maybe it's
within a SceneJS.Boundary that's been outside of the view frustum
for a long time) it may transition back to STATE_INITIAL when
SceneJS evicts it's subgraph from the scene to reclaim memory.
Provide a new method, SceneJS.Load.getState()
to query the node's state, plus a "state-changed"
event to listen to through the new SceneJS.Node event API.
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);