Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Mutable nodes - node objects with setters & getters

#28

In addition to the functional definition style, support references to nodes as objects that can be modified.

The purely declarative functional style might be a bit of a pain to some people.

This is easily done - scene nodes are higher order functions that work conceptually like this:

SceneJS.myNode = function() {

    var foo = arguments[0];
    var bar = arguments[1];

    return function() {

         // Visit function, called on traversal - does something with foo and bar.
    }
}

They can be extended like so:

SceneJS.myNode = function() {

    var foo = arguments[0];
    var bar = arguments[1];

    return {
          visit: function() {

                  // Visit function, called on traversal - does something with foo and bar.
          },

          setFoo(val) {
               foo = val;
          },

          getFoo() {
               return foo;
          }
    }
}

So we can then do this:

var node1 = SceneJS.myNode({foo:"xx"});

var node2 = SceneJS.myOtherNode( node1 );

node1.setFoo(99);

Furthermore, we could also have a base class that provides mutation of child node lists:

node1.addChild( SceneJS.myNode({ ... });

var node3 = node1.getLastChild();

..and so on.

Reported by lindsay.kay (at xeolabs) · April 20th, 2010 @ 12:55 AM

State: resolved
Milestone: V0.7.3

Activity

  1. lindsay.kay (at xeolabs)
    lindsay.kay (at xeolabs)
    • Milestone set to V0.7.3
    • State changed from new to open

    April 21st, 2010 @ 11:15 AM

  2. lindsay.kay (at xeolabs)
    lindsay.kay (at xeolabs)

    Sub Tasks

    • Reset memoisation levels of nodes in a subgraph when root node removed/added; many nodes, like transforms, have a "memo" level that determines how much they cache internally, eg. matrices. This level starts at zero, then escalates as the nodes find that they can afford to not recompute various things. Reset that level to zero in those cases since dependencies will have changed. DONE

    • Support access to nodes in SceneJS.load's loaded subgraphs

    • SceneJS._utils.newScope() should create prototype class, not a closure class

    April 24th, 2010 @ 12:15 AM

  3. lindsay.kay (at xeolabs)
    lindsay.kay (at xeolabs)
    • Tag set to oo api, scenejs.node
    • State changed from open to resolved

    May 1st, 2010 @ 09:12 AM

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.