Tidy up node constructors
Reported by lindsay.kay (at xeolabs) | August 18th, 2010 @ 07:31 PM
The default constructor technique is getting dirty, forcing us into inefficiencies, such as with ID registration:
SceneJS.Node = function() {
this._nodeType = "node";
this._NODEINFO = null; // Big and bold, to stand out in debugger object graph inspectors
this._sid = null;
this._children = [];
this._fixedParams = true;
this._parent = null;
this._listeners = {};
this._numListeners = 0; // Useful for quick check whether node observes any events
this._addedEvents = []; // Events added with #addEvent
this._eventsOut = []; // FIFO queue for events fired from this node with #fireEvent, flushed after each render
/* Used by many node types to track the level at which they can
* memoise internal state. When rendered, a node increments
* this each time it discovers that it can cache more state, so that
* it knows not to recompute that state when next rendered.
* Since internal state is usually dependent on the states of higher
* nodes, this is reset whenever the node is attached to a new
* parent.
*
* private
*/
this._memoLevel = 0;
/* Deregister default ID
*/
if (this._id) {
SceneJS._nodeIDMap[this._id] = null;
}
SceneJS.Node._ArgParser.parseArgs(arguments, this);
/* Register again by whatever ID we now have
*/
if (!this._id) {
this._id = SceneJS._createKeyForMap(SceneJS._nodeIDMap, "n");
}
SceneJS._nodeIDMap[this._id] = this;
};
Comments and changes to this ticket
-
lindsay.kay (at xeolabs) August 31st, 2010 @ 09:50 AM
- 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.
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.