#28 ✓resolved
lindsay.kay (at xeolabs)

Mutable nodes - node objects with setters & getters

Reported by lindsay.kay (at xeolabs) | April 20th, 2010 @ 12:55 AM | in V0.7.3

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.

Comments and changes to this ticket

  • lindsay.kay (at xeolabs)

    lindsay.kay (at xeolabs) April 21st, 2010 @ 11:15 AM

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

    lindsay.kay (at xeolabs) April 24th, 2010 @ 12:15 AM

    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

  • lindsay.kay (at xeolabs)

    lindsay.kay (at xeolabs) May 1st, 2010 @ 09:12 AM

    • Tag set to oo api, scenejs.node
    • State changed from “open” to “resolved”

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