I'm building a desktop application using litegraph.js https://github.com/jagenjo/litegraph.js?files=1. What I need to do is to create new nodes to my graph dynamically. Following litegraph instructions, they can be defined by using a function like:
function my_new_node() {
this.addInput("in1");
//more constructor settings..
}
And then registering it to litegraph by:
LiteGraph.registerNodeType("basic/" + node_id + "", my_new_node);
My problem starts when I have to set different nodes dynamically added by the user, so I would like to do something like:
var node_id = node1; /* node1 is a string that user introduces with an input field, let's suppose this value to be node1. */
function node_id() { //But I want node_id to be node1 in runtime.
//constructor settings
}
LiteGraph.registerNodeType("basic/" + node_id + "", node_id);
I have already tried stuff like this[node_id] = () =>, but then it doesn't let me to register the node.
Any help will be appreciated. Thanks.