#73 ✓resolved
lindsay.kay (at xeolabs)

Node event listeners

Reported by lindsay.kay (at xeolabs) | May 13th, 2010 @ 02:56 AM | in V0.7.5

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");
                    }
                }
            }
        });

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

SceneJS provides easy access to WebGL through a simple and declarative JavaScript API. The SceneJS API is functional, which enables its scene definitions to be really compact and expressive, while hooking into other JavaScript code just that little bit more smoothly.

Shared Ticket Bins

People watching this ticket

Pages