build/litegraph.js
function(type, title, options) {
            var base_class = this.registered_node_types[type];
            if (!base_class) {
                if (LiteGraph.debug) {
                    console.log(
                        'GraphNode type "' + type + '" not registered.'
                    );
                }
                return null;
            }

            var prototype = base_class.prototype || base_class;

            title = title || base_class.title || type;

            var node = null;

            if (LiteGraph.catch_exceptions) {
                try {
                    node = new base_class(title);
                } catch (err) {
                    console.error(err);
                    return null;
                }
            } else {
                node = new base_class(title);
            }

            node.type = type;

            if (!node.title && title) {
                node.title = title;
            }
            if (!node.properties) {
                node.properties = {};
            }
            if (!node.properties_info) {
                node.properties_info = [];
            }
            if (!node.flags) {
                node.flags = {};
            }
            if (!node.size) {
                node.size = node.computeSize();
            }
            if (!node.pos) {
                node.pos = LiteGraph.DEFAULT_POSITION.concat();
            }
            if (!node.mode) {
                node.mode = LiteGraph.ALWAYS;
            }

            //extra options
            if (options) {
                for (var i in options) {
                    node[i] = options[i];
                }
            }

            return node;
        }
function(type, title, options) {
            var base_class = this.registered_node_types[type];
            if (!base_class) {
                if (LiteGraph.debug) {
                    console.log(
                        'GraphNode type "' + type + '" not registered.'
                    );
                }
                return null;
            }

            var prototype = base_class.prototype || base_class;

            title = title || base_class.title || type;

            var node = null;

            if (LiteGraph.catch_exceptions) {
                try {
                    node = new base_class(title);
                } catch (err) {
                    console.error(err);
                    return null;
                }
            } else {
                node = new base_class(title);
            }

            node.type = type;

            if (!node.title && title) {
                node.title = title;
            }
            if (!node.properties) {
                node.properties = {};
            }
            if (!node.properties_info) {
                node.properties_info = [];
            }
            if (!node.flags) {
                node.flags = {};
            }
            if (!node.size) {
                node.size = node.computeSize();
            }
            if (!node.pos) {
                node.pos = LiteGraph.DEFAULT_POSITION.concat();
            }
            if (!node.mode) {
                node.mode = LiteGraph.ALWAYS;
            }

            //extra options
            if (options) {
                for (var i in options) {
                    node[i] = options[i];
                }
            }

            return node;
        }
function ( type , title , options ) { var base_class = this . registered_node_types [ type ] ; if ( ! base_class ) { if ( LiteGraph . debug ) { console . log ( 'GraphNode type "' + type + '" not registered.' ) ; } return null ; } var prototype = base_class . prototype || base_class ; title = title || base_class . title || type ; var node = null ; if ( LiteGraph . catch_exceptions ) { try { node = new base_class ( title ) ; } catch ( err ) { console . error ( err ) ; return null ; } } else { node = new base_class ( title ) ; } node . type = type ; if ( ! node . title && title ) { node . title = title ; } if ( ! node . properties ) { node . properties = { } ; } if ( ! node . properties_info ) { node . properties_info = [ ] ; } if ( ! node . flags ) { node . flags = { } ; } if ( ! node . size ) { node . size = node . computeSize ( ) ; } if ( ! node . pos ) { node . pos = LiteGraph . DEFAULT_POSITION . concat ( ) ; } if ( ! node . mode ) { node . mode = LiteGraph . ALWAYS ; } //extra options if ( options ) { for ( var i in options ) { node [ i ] = options [ i ] ; } } return node ; }
Create a node of a given type with a name. The node is not attached to any graph yet.
@method createNode
@param {String} type full name of the node class. p.e. "math/sin"
@param {String} name a name to distinguish from other nodes
@param {Object} options to set options
Create a node of a given type with a name . The node is not attached to any graph yet .