diff --git a/build/litegraph.js b/build/litegraph.js
index e26094570..0bf2668f4 100644
--- a/build/litegraph.js
+++ b/build/litegraph.js
@@ -286,7 +286,7 @@ LGraph.prototype.clear = function()
this.global_inputs = {};
this.global_outputs = {};
- this.graph = {};
+ //this.graph = {};
this.debug = true;
this.change();
@@ -761,10 +761,18 @@ LGraph.prototype.getNodeOnPos = function(x,y, nodes_list)
return null;
}
+// ********** GLOBALS *****************
+
//Tell this graph has a global input of this type
LGraph.prototype.addGlobalInput = function(name, type, value)
{
- this.global_inputs[name] = { type: type, value: value };
+ this.global_inputs[name] = { name: name, type: type, value: value };
+
+ if(this.onGlobalInputAdded)
+ this.onGlobalInputAdded(name, type);
+
+ if(this.onGlobalsChange)
+ this.onGlobalsChange();
}
//assign a data to the global input
@@ -776,29 +784,117 @@ LGraph.prototype.setGlobalInputData = function(name, data)
input.value = data;
}
+//assign a data to the global input
+LGraph.prototype.getGlobalInputData = function(name)
+{
+ var input = this.global_inputs[name];
+ if (!input)
+ return null;
+ return input.value;
+}
+
//rename the global input
LGraph.prototype.renameGlobalInput = function(old_name, name, data)
{
+ if(!this.global_inputs[old_name])
+ return false;
+
+ if(this.global_inputs[name])
+ {
+ console.error("there is already one input with that name");
+ return false;
+ }
+
+ this.global_inputs[name] = this.global_inputs[old_name];
+ delete this.global_inputs[old_name];
+
+ if(this.onGlobalInputRenamed)
+ this.onGlobalInputRenamed(old_name, name);
+
+ if(this.onGlobalsChange)
+ this.onGlobalsChange();
+}
+
+LGraph.prototype.removeGlobalInput = function(name)
+{
+ if(!this.global_inputs[name])
+ return false;
+
+ delete this.global_inputs[name];
+
+ if(this.onGlobalInputRemoved)
+ this.onGlobalInputRemoved(name);
+
+ if(this.onGlobalsChange)
+ this.onGlobalsChange();
+ return true;
}
LGraph.prototype.addGlobalOutput = function(name, type, value)
{
- this.global_outputs[name] = { type: type, value: value };
+ this.global_outputs[name] = { name: name, type: type, value: value };
+
+ if(this.onGlobalOutputAdded)
+ this.onGlobalOutputAdded(name, type);
+
+ if(this.onGlobalsChange)
+ this.onGlobalsChange();
}
//assign a data to the global output
-LGraph.prototype.setGlobalOutputData = function(name, data)
+LGraph.prototype.setGlobalOutputData = function(name, value)
{
var output = this.global_outputs[ name ];
if (!output)
return;
- output.value = data;
+ output.value = value;
}
+//assign a data to the global input
+LGraph.prototype.getGlobalOutputData = function(name)
+{
+ var output = this.global_outputs[name];
+ if (!output)
+ return null;
+ return output.value;
+}
+
+
//rename the global output
LGraph.prototype.renameGlobalOutput = function(old_name, name, data)
{
+ if(!this.global_outputs[old_name])
+ return false;
+
+ if(this.global_outputs[name])
+ {
+ console.error("there is already one output with that name");
+ return false;
+ }
+
+ this.global_outputs[name] = this.global_outputs[old_name];
+ delete this.global_outputs[old_name];
+
+ if(this.onGlobalOutputRenamed)
+ this.onGlobalOutputRenamed(old_name, name);
+
+ if(this.onGlobalsChange)
+ this.onGlobalsChange();
+}
+
+LGraph.prototype.removeGlobalOutput = function(name)
+{
+ if(!this.global_outputs[name])
+ return false;
+ delete this.global_outputs[name];
+
+ if(this.onGlobalOutputRemoved)
+ this.onGlobalOutputRemoved(name);
+
+ if(this.onGlobalsChange)
+ this.onGlobalsChange();
+ return true;
}
@@ -904,7 +1000,7 @@ LGraph.prototype.serialize = function()
var data = {
- graph: this.graph,
+// graph: this.graph,
iteration: this.iteration,
frame: this.frame,
@@ -1040,7 +1136,12 @@ LGraphNode.prototype.configure = function(info)
if(info[j] == null)
continue;
else if (typeof(info[j]) == 'object') //object
- this[j] = LiteGraph.cloneObject(info[j], this[j]);
+ {
+ if(this[j] && this[j].configure)
+ this[j].configure( info[j] );
+ else
+ this[j] = LiteGraph.cloneObject(info[j], this[j]);
+ }
else //value
this[j] = info[j];
}
@@ -1113,6 +1214,36 @@ LGraphNode.prototype.serialize = function()
return o;
}
+
+/* Creates a clone of this node */
+LGraphNode.prototype.clone = function()
+{
+ var node = LiteGraph.createNode(this.type);
+
+ var data = this.serialize();
+ delete data["id"];
+ node.configure(data);
+
+ /*
+ node.size = this.size.concat();
+ if(this.inputs)
+ for(var i = 0, l = this.inputs.length; i < l; ++i)
+ {
+ if(node.findInputSlot( this.inputs[i].name ) == -1)
+ node.addInput( this.inputs[i].name, this.inputs[i].type );
+ }
+
+ if(this.outputs)
+ for(var i = 0, l = this.outputs.length; i < l; ++i)
+ {
+ if(node.findOutputSlot( this.outputs[i].name ) == -1)
+ node.addOutput( this.outputs[i].name, this.outputs[i].type );
+ }
+ */
+
+ return node;
+}
+
//reduced version of objectivize: NOT FINISHED
/*
LGraphNode.prototype.reducedObjectivize = function()
@@ -1291,6 +1422,8 @@ LGraphNode.prototype.addOutput = function(name,type,extra_info)
if(!this.outputs) this.outputs = [];
this.outputs.push(o);
+ if(this.onOutputAdded)
+ this.onOutputAdded(o);
this.size = this.computeSize();
}
@@ -1312,6 +1445,8 @@ LGraphNode.prototype.addOutputs = function(array)
if(!this.outputs)
this.outputs = [];
this.outputs.push(o);
+ if(this.onOutputAdded)
+ this.onOutputAdded(o);
}
this.size = this.computeSize();
@@ -1327,6 +1462,8 @@ LGraphNode.prototype.removeOutput = function(slot)
this.disconnectOutput(slot);
this.outputs.splice(slot,1);
this.size = this.computeSize();
+ if(this.onOutputRemoved)
+ this.onOutputRemoved(slot);
}
/**
@@ -1346,6 +1483,8 @@ LGraphNode.prototype.addInput = function(name,type,extra_info)
if(!this.inputs) this.inputs = [];
this.inputs.push(o);
this.size = this.computeSize();
+ if(this.onInputAdded)
+ this.onInputAdded(o);
}
/**
@@ -1366,6 +1505,8 @@ LGraphNode.prototype.addInputs = function(array)
if(!this.inputs)
this.inputs = [];
this.inputs.push(o);
+ if(this.onInputAdded)
+ this.onInputAdded(o);
}
this.size = this.computeSize();
@@ -1381,6 +1522,8 @@ LGraphNode.prototype.removeInput = function(slot)
this.disconnectInput(slot);
this.inputs.splice(slot,1);
this.size = this.computeSize();
+ if(this.onInputRemoved)
+ this.onInputRemoved(slot);
}
/**
@@ -1723,29 +1866,6 @@ LGraphNode.prototype.alignToGrid = function()
this.pos[1] = LiteGraph.CANVAS_GRID_SIZE * Math.round(this.pos[1] / LiteGraph.CANVAS_GRID_SIZE);
}
-/* Creates a clone of this node */
-LGraphNode.prototype.clone = function()
-{
- var node = LiteGraph.createNode(this.type);
-
- node.size = this.size.concat();
- if(this.inputs)
- for(var i = 0, l = this.inputs.length; i < l; ++i)
- {
- if(node.findInputSlot( this.inputs[i].name ) == -1)
- node.addInput( this.inputs[i].name, this.inputs[i].type );
- }
-
- if(this.outputs)
- for(var i = 0, l = this.outputs.length; i < l; ++i)
- {
- if(node.findOutputSlot( this.outputs[i].name ) == -1)
- node.addOutput( this.outputs[i].name, this.outputs[i].type );
- }
-
-
- return node;
-}
/* Console output */
LGraphNode.prototype.trace = function(msg)
@@ -1968,7 +2088,7 @@ LGraphCanvas.prototype.clear = function()
* assigns a graph, you can reasign graphs to the same canvas
*
* @method setGraph
-* @param {LGraph} assigns a graph
+* @param {LGraph} graph
*/
LGraphCanvas.prototype.setGraph = function(graph)
{
@@ -1992,6 +2112,48 @@ LGraphCanvas.prototype.setGraph = function(graph)
this.setDirty(true,true);
}
+/**
+* opens a graph contained inside a node in the current graph
+*
+* @method openSubgraph
+* @param {LGraph} graph
+*/
+LGraphCanvas.prototype.openSubgraph = function(graph)
+{
+ if(!graph)
+ throw("graph cannot be null");
+
+ if(this.graph == graph)
+ throw("graph cannot be the same");
+
+ this.clear();
+
+ if(this.graph)
+ {
+ if(!this._graph_stack)
+ this._graph_stack = [];
+ this._graph_stack.push(this.graph);
+ }
+
+ graph.attachCanvas(this);
+ this.setDirty(true,true);
+}
+
+/**
+* closes a subgraph contained inside a node
+*
+* @method closeSubgraph
+* @param {LGraph} assigns a graph
+*/
+LGraphCanvas.prototype.closeSubgraph = function()
+{
+ if(!this._graph_stack || this._graph_stack.length == 0)
+ return;
+ var graph = this._graph_stack.pop();
+ graph.attachCanvas(this);
+ this.setDirty(true,true);
+}
+
/**
* assigns a canvas
*
@@ -3895,32 +4057,59 @@ LGraphCanvas.node_colors = {
LGraphCanvas.prototype.getCanvasMenuOptions = function()
{
- return [
- {content:"Add Node", is_menu: true, callback: LGraphCanvas.onMenuAdd }
- //{content:"Collapse All", callback: LGraphCanvas.onMenuCollapseAll }
- ];
+ var options = null;
+ if(this.getMenuOptions)
+ options = this.getMenuOptions();
+ else
+ {
+ options = [
+ {content:"Add Node", is_menu: true, callback: LGraphCanvas.onMenuAdd }
+ //{content:"Collapse All", callback: LGraphCanvas.onMenuCollapseAll }
+ ];
+
+ if(this._graph_stack)
+ options = [{content:"Close subgraph", callback: this.closeSubgraph.bind(this) },null].concat(options);
+ }
+
+ if(this.getExtraMenuOptions)
+ {
+ var extra = this.getExtraMenuOptions(this);
+ extra.push(null);
+ options = extra.concat( options );
+ }
+
+ return options;
}
LGraphCanvas.prototype.getNodeMenuOptions = function(node)
{
- var options = [
- {content:"Inputs", is_menu: true, disabled:true, callback: LGraphCanvas.onMenuNodeInputs },
- {content:"Outputs", is_menu: true, disabled:true, callback: LGraphCanvas.onMenuNodeOutputs },
- null,
- {content:"Collapse", callback: LGraphCanvas.onMenuNodeCollapse },
- {content:"Pin", callback: LGraphCanvas.onMenuNodePin },
- {content:"Colors", is_menu: true, callback: LGraphCanvas.onMenuNodeColors },
- {content:"Shapes", is_menu: true, callback: LGraphCanvas.onMenuNodeShapes },
- null,
- {content:"Clone", callback: LGraphCanvas.onMenuNodeClone },
- null,
- {content:"Remove", callback: LGraphCanvas.onMenuNodeRemove }
- ];
+ var options = null;
- if( node.clonable == false )
- options[7].disabled = true;
- if( node.removable == false )
- options[9].disabled = true;
+ if(node.getMenuOptions)
+ options = node.getMenuOptions(this);
+ else
+ options = [
+ {content:"Inputs", is_menu: true, disabled:true, callback: LGraphCanvas.onMenuNodeInputs },
+ {content:"Outputs", is_menu: true, disabled:true, callback: LGraphCanvas.onMenuNodeOutputs },
+ null,
+ {content:"Collapse", callback: LGraphCanvas.onMenuNodeCollapse },
+ {content:"Pin", callback: LGraphCanvas.onMenuNodePin },
+ {content:"Colors", is_menu: true, callback: LGraphCanvas.onMenuNodeColors },
+ {content:"Shapes", is_menu: true, callback: LGraphCanvas.onMenuNodeShapes },
+ null
+ ];
+
+ if(node.getExtraMenuOptions)
+ {
+ var extra = node.getExtraMenuOptions(this);
+ extra.push(null);
+ options = extra.concat( options );
+ }
+
+ if( node.clonable !== false )
+ options.push({content:"Clone", callback: LGraphCanvas.onMenuNodeClone });
+ if( node.removable !== false )
+ options.push(null,{content:"Remove", callback: LGraphCanvas.onMenuNodeRemove });
if(node.onGetInputs)
{
@@ -4273,15 +4462,32 @@ if( !window["requestAnimationFrame"] )
//Input for a subgraph
function GlobalInput()
{
+ this.title = "Input";
+
+ //random name to avoid problems with other outputs when added
+ var genname = "input_" + (Math.random()*1000).toFixed();
+ this.properties = { name: genname, type: "number" };
this.addOutput("value",0);
}
+GlobalInput.title = "Input";
+GlobalInput.desc = "Input of the graph";
+
+GlobalInput.prototype.onAdded = function()
+{
+ this.graph.addGlobalInput( this.properties.name, this.properties.type );
+}
+
GlobalInput.prototype.onExecute = function()
{
- var name = this.title;
- //read input
- var value = node.graph.global_inputs[name];
- this.setOutputData(0,value);
+ var name = this.properties.name;
+
+ //read from global input
+ var data = this.graph.global_inputs[name];
+ if(!data) return;
+
+ //put through output
+ this.setOutputData(0,data.value);
}
LiteGraph.registerNodeType("graph/input", GlobalInput);
@@ -4293,11 +4499,14 @@ function GlobalOutput()
this.title = "Output";
//random name to avoid problems with other outputs when added
- var genname = "input_" + (Math.random()*1000).toFixed();
+ var genname = "output_" + (Math.random()*1000).toFixed();
this.properties = { name: genname, type: "number" };
this.addInput("value","number");
}
+GlobalOutput.title = "Ouput";
+GlobalOutput.desc = "Output of the graph";
+
GlobalOutput.prototype.onAdded = function()
{
var name = this.graph.addGlobalOutput( this.properties.name, this.properties.type );
@@ -4305,8 +4514,7 @@ GlobalOutput.prototype.onAdded = function()
GlobalOutput.prototype.onExecute = function()
{
- var value = this.getInputData(0);
- this.graph.setGlobalOutputData( this.properties.name, value );
+ this.graph.setGlobalOutputData( this.properties.name, this.getInputData(0) );
}
LiteGraph.registerNodeType("graph/output", GlobalOutput);
@@ -4315,29 +4523,77 @@ LiteGraph.registerNodeType("graph/output", GlobalOutput);
//Subgraph: a node that contains a graph
function Subgraph()
{
+ var that = this;
this.subgraph = new LGraph();
+ this.subgraph._subgraph_node = this;
+ this.subgraph._is_subgraph = true;
+ this.subgraph.onGlobalInputAdded = this.onSubgraphNewGlobalInput.bind(this);
+ this.subgraph.onGlobalOutputAdded = this.onSubgraphNewGlobalOutput.bind(this);
+
this.bgcolor = "#FA3";
}
+Subgraph.title = "Subgraph";
+Subgraph.desc = "Graph inside a node";
+
+Subgraph.prototype.onSubgraphNewGlobalInput = function(name, type)
+{
+ this.addInput(name, type);
+}
+
+Subgraph.prototype.onSubgraphNewGlobalOutput = function(name, type)
+{
+ this.addOutput(name, type);
+}
+
+Subgraph.prototype.getExtraMenuOptions = function(graphcanvas)
+{
+ var that = this;
+ return [ {content:"Open", callback:
+ function() {
+ graphcanvas.openSubgraph( that.subgraph );
+ }
+ }];
+}
+
Subgraph.prototype.onExecute = function()
{
//send inputs to subgraph global inputs
- for(var i in this.inputs)
- {
- var input = this.inputs[i];
+ if(this.inputs)
+ for(var i = 0; i < this.inputs.length; i++)
+ {
+ var input = this.inputs[i];
+ var value = this.getInputData(i);
+ this.subgraph.setGlobalInputData( input.name, value );
+ }
- //this.subgraph.setGlobalInputData( input.name, input.value );
- }
+ //execute
+ this.subgraph.runStep();
//send subgraph global outputs to outputs
+ if(this.outputs)
+ for(var i = 0; i < this.outputs.length; i++)
+ {
+ var output = this.outputs[i];
+ var value = this.subgraph.getGlobalOutputData( output.name );
+ this.setOutputData(i, value);
+ }
}
Subgraph.prototype.configure = function(o)
{
- LGraph.prototype.configure.call(this, o);
- //after configure, ...
+ LGraphNode.prototype.configure.call(this, o);
+ //this.subgraph.configure(o.graph);
}
+Subgraph.prototype.serialize = function()
+{
+ var data = LGraphNode.prototype.serialize.call(this);
+ data.subgraph = this.subgraph.serialize();
+ return data;
+}
+
+
LiteGraph.registerNodeType("graph/subgraph", Subgraph);
@@ -4619,8 +4875,8 @@ LiteGraph.registerNodeType("network/network_callback",{
function WidgetKnob()
{
- this.size = [64,84];
this.addOutput("",'number');
+ this.size = [64,84];
this.properties = {min:0,max:1,value:0.5,wcolor:"#7AF",size:50};
}
@@ -4658,12 +4914,14 @@ LiteGraph.registerNodeType("network/network_callback",{
ctx.restore();
- ctx.font = "bold 16px Criticized,Tahoma";
- ctx.fillStyle="rgba(100,100,100,0.8)";
- ctx.textAlign = "center";
-
- ctx.fillText(this.name.toUpperCase(), this.size[0] * 0.5, 18 );
- ctx.textAlign = "left";
+ if(this.title)
+ {
+ ctx.font = "bold 16px Criticized,Tahoma";
+ ctx.fillStyle="rgba(100,100,100,0.8)";
+ ctx.textAlign = "center";
+ ctx.fillText(this.title.toUpperCase(), this.size[0] * 0.5, 18 );
+ ctx.textAlign = "left";
+ }
}
WidgetKnob.prototype.onDrawVectorKnob = function(ctx)
@@ -5377,6 +5635,7 @@ function MathClamp()
MathClamp.title = "Clamp";
MathClamp.desc = "Clamp number between min and max";
+MathClamp.filter = "shader";
MathClamp.prototype.onExecute = function()
{
@@ -5387,6 +5646,14 @@ MathClamp.prototype.onExecute = function()
this.setOutputData(0, v );
}
+MathClamp.prototype.getCode = function(lang)
+{
+ var code = "";
+ if(this.isInputConnected(0))
+ code += "clamp({{0}}," + this.properties.min + "," + this.properties.max + ")";
+ return code;
+}
+
LiteGraph.registerNodeType("math/clamp", MathClamp );
@@ -5426,7 +5693,7 @@ MathFloor.prototype.onExecute = function()
{
var v = this.getInputData(0);
if(v == null) return;
- this.setOutputData(0, v|1 );
+ this.setOutputData(0, Math.floor(v) );
}
LiteGraph.registerNodeType("math/floor", MathFloor );
@@ -5620,6 +5887,7 @@ function MathTrigonometry()
MathTrigonometry.title = "Trigonometry";
MathTrigonometry.desc = "Sin Cos Tan";
+MathTrigonometry.filter = "shader";
MathTrigonometry.prototype.onExecute = function()
{
diff --git a/build/litegraph.min.js b/build/litegraph.min.js
index a35839456..62b1df1ec 100644
--- a/build/litegraph.min.js
+++ b/build/litegraph.min.js
@@ -4,7 +4,7 @@ b.type=a;LiteGraph.debug&&console.log("Node registered: "+a);a.split("/");var c=
!this.registered_node_types[b].skip_list&&(a[this.registered_node_types[b].category]=1);var c=[];for(b in a)c.push(b);return c},reloadNodes:function(a){var b=document.getElementsByTagName("script"),c=[],d;for(d in b)c.push(b[d]);b=document.getElementsByTagName("head")[0];a=document.location.href+a;for(d in c){var e=c[d].src;if(e&&e.substr(0,a.length)==a)try{LiteGraph.debug&&console.log("Reloading: "+e);var f=document.createElement("script");f.type="text/javascript";f.src=e;b.appendChild(f);b.removeChild(c[d])}catch(g){if(LiteGraph.throw_errors)throw g;
LiteGraph.debug&&console.log("Error while reloading "+e)}}LiteGraph.debug&&console.log("Nodes reloaded")},cloneObject:function(a,b){if(null==a)return null;var c=JSON.parse(JSON.stringify(a));if(!b)return c;for(var d in c)b[d]=c[d];return b}};LiteGraph.getTime="undefined"!=typeof performance?function(){return performance.now()}:function(){return Date.now()};function LGraph(){LiteGraph.debug&&console.log("Graph created");this.list_of_graphcanvas=null;this.clear()}
LGraph.supported_types=["number","string","boolean"];LGraph.prototype.getSupportedTypes=function(){return this.supported_types||LGraph.supported_types};LGraph.STATUS_STOPPED=1;LGraph.STATUS_RUNNING=2;
-LGraph.prototype.clear=function(){this.stop();this.status=LGraph.STATUS_STOPPED;this.last_node_id=0;this._nodes=[];this._nodes_by_id={};this.last_link_id=0;this.links={};this.iteration=0;this.config={};this.fixedtime=this.runningtime=this.globaltime=0;this.elapsed_time=this.fixedtime_lapse=0.01;this.starttime=0;this.global_inputs={};this.global_outputs={};this.graph={};this.debug=!0;this.change();this.sendActionToCanvas("clear")};
+LGraph.prototype.clear=function(){this.stop();this.status=LGraph.STATUS_STOPPED;this.last_node_id=0;this._nodes=[];this._nodes_by_id={};this.last_link_id=0;this.links={};this.iteration=0;this.config={};this.fixedtime=this.runningtime=this.globaltime=0;this.elapsed_time=this.fixedtime_lapse=0.01;this.starttime=0;this.global_inputs={};this.global_outputs={};this.debug=!0;this.change();this.sendActionToCanvas("clear")};
LGraph.prototype.attachCanvas=function(a){if(a.constructor!=LGraphCanvas)throw"attachCanvas expects a LGraphCanvas instance";a.graph&&a.graph!=this&&a.graph.detachCanvas(a);a.graph=this;this.list_of_graphcanvas||(this.list_of_graphcanvas=[]);this.list_of_graphcanvas.push(a)};LGraph.prototype.detachCanvas=function(a){var b=this.list_of_graphcanvas.indexOf(a);-1!=b&&(a.graph=null,this.list_of_graphcanvas.splice(b,1))};
LGraph.prototype.start=function(a){if(this.status!=LGraph.STATUS_RUNNING){this.status=LGraph.STATUS_RUNNING;if(this.onPlayEvent)this.onPlayEvent();this.sendEventToAllNodes("onStart");this.starttime=LiteGraph.getTime();var b=this;this.execution_timer_id=setInterval(function(){b.runStep(1)},a||1)}};
LGraph.prototype.stop=function(){if(this.status!=LGraph.STATUS_STOPPED){this.status=LGraph.STATUS_STOPPED;if(this.onStopEvent)this.onStopEvent();null!=this.execution_timer_id&&clearInterval(this.execution_timer_id);this.execution_timer_id=null;this.sendEventToAllNodes("onStop")}};
@@ -16,24 +16,30 @@ LGraph.prototype.sendEventToAllNodes=function(a,b){var c=this._nodes_in_order?th
LGraph.prototype.add=function(a,b){if(a&&(-1==a.id||null==this._nodes_by_id[a.id])){if(this._nodes.length>=LiteGraph.MAX_NUMBER_OF_NODES)throw"LiteGraph: max number of nodes in a graph reached";if(null==a.id||-1==a.id)a.id=this.last_node_id++;a.graph=this;this._nodes.push(a);this._nodes_by_id[a.id]=a;if(a.onAdded)a.onAdded();this.config.align_to_grid&&a.alignToGrid();b||this.updateExecutionOrder();if(this.onNodeAdded)this.onNodeAdded(a);this.setDirtyCanvas(!0);this.change();return a}};
LGraph.prototype.remove=function(a){if(null!=this._nodes_by_id[a.id]&&!a.ignore_remove){if(a.inputs)for(var b=0;b../src/litegraph.js:922
+ ../src/litegraph.js:1018
../src/litegraph.js:856
+ ../src/litegraph.js:952
@@ -1825,7 +1825,7 @@ if the nodes are using graphical actions
- ../src/litegraph.js:889
+ ../src/litegraph.js:985
@@ -1910,7 +1910,7 @@ if the nodes are using graphical actions
- ../src/litegraph.js:804
+ ../src/litegraph.js:900
@@ -2020,7 +2020,7 @@ can be easily accesed from the outside of the graph
- ../src/litegraph.js:819
+ ../src/litegraph.js:915
diff --git a/doc/classes/LGraphCanvas.html b/doc/classes/LGraphCanvas.html
index 2d66a2b02..ebb18c716 100644
--- a/doc/classes/LGraphCanvas.html
+++ b/doc/classes/LGraphCanvas.html
@@ -96,7 +96,7 @@
../src/litegraph.js:2116
+ Defined in: ../src/litegraph.js:2278
../src/litegraph.js:2116
+ ../src/litegraph.js:2278
@@ -254,6 +254,13 @@
+
+
+ ../src/litegraph.js:1912
+ ../src/litegraph.js:2032
@@ -359,6 +373,95 @@
+
+
+
+ closeSubgraphassigns
+
+ closes a subgraph contained inside a node
+ +assigns
+ LGraph
+
+
+
+
+ a graph
+ +../src/litegraph.js:2132
+ ../src/litegraph.js:2294
@@ -432,6 +535,94 @@
+
+
+
+ openSubgraphgraph
+
+ opens a graph contained inside a node in the current graph
+ +graph
+ LGraph
+
+
+
+
+ ../src/litegraph.js:1994
+ ../src/litegraph.js:2156
@@ -533,7 +724,7 @@
assigns
+ graph
../src/litegraph.js:1966
+ ../src/litegraph.js:2086
@@ -589,15 +780,14 @@
assigns
+ graph
LGraph
a graph
- +../src/litegraph.js:2144
+ ../src/litegraph.js:2306
@@ -700,7 +890,7 @@
- ../src/litegraph.js:2175
+ ../src/litegraph.js:2337
diff --git a/doc/classes/LGraphNode.html b/doc/classes/LGraphNode.html
index 36fc193be..d6790beea 100644
--- a/doc/classes/LGraphNode.html
+++ b/doc/classes/LGraphNode.html
@@ -96,7 +96,7 @@
../src/litegraph.js:1000
+ Defined in: ../src/litegraph.js:1096
../src/litegraph.js:1385
+ ../src/litegraph.js:1528
@@ -563,7 +563,7 @@
- ../src/litegraph.js:1331
+ ../src/litegraph.js:1468
@@ -683,7 +683,7 @@
- ../src/litegraph.js:1350
+ ../src/litegraph.js:1489
@@ -784,7 +784,7 @@
- ../src/litegraph.js:1277
+ ../src/litegraph.js:1408
@@ -904,7 +904,7 @@
- ../src/litegraph.js:1296
+ ../src/litegraph.js:1429
@@ -983,7 +983,7 @@
- ../src/litegraph.js:1842
+ ../src/litegraph.js:1962
@@ -1052,7 +1052,7 @@
- ../src/litegraph.js:1398
+ ../src/litegraph.js:1541
@@ -1144,7 +1144,7 @@
- ../src/litegraph.js:1029
+ ../src/litegraph.js:1125
@@ -1225,7 +1225,7 @@
- ../src/litegraph.js:1478
+ ../src/litegraph.js:1621
@@ -1364,7 +1364,7 @@
- ../src/litegraph.js:1628
+ ../src/litegraph.js:1771
@@ -1477,7 +1477,7 @@
- ../src/litegraph.js:1561
+ ../src/litegraph.js:1704
@@ -1600,7 +1600,7 @@
- ../src/litegraph.js:1448
+ ../src/litegraph.js:1591
@@ -1707,7 +1707,7 @@
- ../src/litegraph.js:1463
+ ../src/litegraph.js:1606
@@ -1804,7 +1804,7 @@
- ../src/litegraph.js:1416
+ ../src/litegraph.js:1559
@@ -1893,7 +1893,7 @@
- ../src/litegraph.js:1685
+ ../src/litegraph.js:1828
@@ -2016,7 +2016,7 @@
- ../src/litegraph.js:1180
+ ../src/litegraph.js:1311
@@ -2122,7 +2122,7 @@
- ../src/litegraph.js:1206
+ ../src/litegraph.js:1337
@@ -2226,7 +2226,7 @@
- ../src/litegraph.js:1221
+ ../src/litegraph.js:1352
@@ -2330,7 +2330,7 @@
- ../src/litegraph.js:1248
+ ../src/litegraph.js:1379
@@ -2420,7 +2420,7 @@
- ../src/litegraph.js:1148
+ ../src/litegraph.js:1279
@@ -2489,7 +2489,7 @@
- ../src/litegraph.js:1194
+ ../src/litegraph.js:1325
@@ -2593,7 +2593,7 @@
- ../src/litegraph.js:1236
+ ../src/litegraph.js:1367
@@ -2703,7 +2703,7 @@
- ../src/litegraph.js:1426
+ ../src/litegraph.js:1569
@@ -2808,7 +2808,7 @@
- ../src/litegraph.js:1855
+ ../src/litegraph.js:1975
@@ -2873,7 +2873,7 @@
- ../src/litegraph.js:1373
+ ../src/litegraph.js:1514
@@ -2961,7 +2961,7 @@
- ../src/litegraph.js:1319
+ ../src/litegraph.js:1454
@@ -3039,7 +3039,7 @@
- ../src/litegraph.js:1075
+ ../src/litegraph.js:1176
@@ -3110,7 +3110,7 @@
- ../src/litegraph.js:1161
+ ../src/litegraph.js:1292
@@ -3203,7 +3203,7 @@
- ../src/litegraph.js:1136
+ ../src/litegraph.js:1267
diff --git a/doc/data.json b/doc/data.json
index 4e51b636d..5f149b208 100644
--- a/doc/data.json
+++ b/doc/data.json
@@ -51,7 +51,7 @@
"plugin_for": [],
"extension_for": [],
"file": "../src/litegraph.js",
- "line": 1000,
+ "line": 1096,
"description": "Base Class for all the node type classes",
"params": [
{
@@ -70,7 +70,7 @@
"plugin_for": [],
"extension_for": [],
"file": "../src/litegraph.js",
- "line": 2116,
+ "line": 2278,
"description": "marks as dirty the canvas, this way it will be rendered again",
"is_constructor": 1,
"params": [
@@ -438,7 +438,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 804,
+ "line": 900,
"description": "Assigns a value to all the nodes that matches this name. This is used to create global variables of the node that\ncan be easily accesed from the outside of the graph",
"itemtype": "method",
"name": "setInputData",
@@ -458,7 +458,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 819,
+ "line": 915,
"description": "Returns the value of the first node with this name. This is used to access global variables of the graph from the outside",
"itemtype": "method",
"name": "setInputData",
@@ -477,7 +477,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 856,
+ "line": 952,
"description": "returns if the graph is in live mode",
"itemtype": "method",
"name": "isLive",
@@ -485,7 +485,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 889,
+ "line": 985,
"description": "Creates a Object containing all the info about this graph, it can be serialized",
"itemtype": "method",
"name": "serialize",
@@ -497,7 +497,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 922,
+ "line": 1018,
"description": "Configure a graph from a JSON string",
"itemtype": "method",
"name": "configure",
@@ -512,7 +512,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1029,
+ "line": 1125,
"description": "configure a node from an object containing the serialized info",
"itemtype": "method",
"name": "configure",
@@ -520,7 +520,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1075,
+ "line": 1176,
"description": "serialize the content",
"itemtype": "method",
"name": "serialize",
@@ -528,7 +528,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1136,
+ "line": 1267,
"description": "serialize and stringify",
"itemtype": "method",
"name": "toString",
@@ -536,7 +536,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1148,
+ "line": 1279,
"description": "get the title string",
"itemtype": "method",
"name": "getTitle",
@@ -544,7 +544,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1161,
+ "line": 1292,
"description": "sets the output data",
"itemtype": "method",
"name": "setOutputData",
@@ -564,7 +564,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1180,
+ "line": 1311,
"description": "retrieves the input data from one slot",
"itemtype": "method",
"name": "getInputData",
@@ -583,7 +583,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1194,
+ "line": 1325,
"description": "tells you if there is a connection in one input slot",
"itemtype": "method",
"name": "isInputConnected",
@@ -602,7 +602,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1206,
+ "line": 1337,
"description": "tells you info about an input connection (which node, type, etc)",
"itemtype": "method",
"name": "getInputInfo",
@@ -621,7 +621,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1221,
+ "line": 1352,
"description": "tells you info about an output connection (which node, type, etc)",
"itemtype": "method",
"name": "getOutputInfo",
@@ -640,7 +640,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1236,
+ "line": 1367,
"description": "tells you if there is a connection in one output slot",
"itemtype": "method",
"name": "isOutputConnected",
@@ -659,7 +659,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1248,
+ "line": 1379,
"description": "retrieves all the nodes connected to this output slot",
"itemtype": "method",
"name": "getOutputNodes",
@@ -678,7 +678,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1277,
+ "line": 1408,
"description": "add a new output slot to use in this node",
"itemtype": "method",
"name": "addOutput",
@@ -703,7 +703,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1296,
+ "line": 1429,
"description": "add a new output slot to use in this node",
"itemtype": "method",
"name": "addOutputs",
@@ -718,7 +718,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1319,
+ "line": 1454,
"description": "remove an existing output slot",
"itemtype": "method",
"name": "removeOutput",
@@ -733,7 +733,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1331,
+ "line": 1468,
"description": "add a new input slot to use in this node",
"itemtype": "method",
"name": "addInput",
@@ -758,7 +758,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1350,
+ "line": 1489,
"description": "add several new input slots in this node",
"itemtype": "method",
"name": "addInputs",
@@ -773,7 +773,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1373,
+ "line": 1514,
"description": "remove an existing input slot",
"itemtype": "method",
"name": "removeInput",
@@ -788,7 +788,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1385,
+ "line": 1528,
"description": "add an special connection to this node (used for special kinds of graphs)",
"itemtype": "method",
"name": "addConnection",
@@ -818,7 +818,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1398,
+ "line": 1541,
"description": "computes the size of a node according to its inputs and output slots",
"itemtype": "method",
"name": "computeSize",
@@ -837,7 +837,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1416,
+ "line": 1559,
"description": "returns the bounding of the object, used for rendering purposes",
"itemtype": "method",
"name": "getBounding",
@@ -849,7 +849,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1426,
+ "line": 1569,
"description": "checks if a point is inside the shape of a node",
"itemtype": "method",
"name": "isPointInsideNode",
@@ -873,7 +873,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1448,
+ "line": 1591,
"description": "returns the input slot with a given name (used for dynamic slots), -1 if not found",
"itemtype": "method",
"name": "findInputSlot",
@@ -892,7 +892,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1463,
+ "line": 1606,
"description": "returns the output slot with a given name (used for dynamic slots), -1 if not found",
"itemtype": "method",
"name": "findOutputSlot",
@@ -911,7 +911,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1478,
+ "line": 1621,
"description": "connect this node output to the input of another node",
"itemtype": "method",
"name": "connect",
@@ -940,7 +940,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1561,
+ "line": 1704,
"description": "disconnect one output to an specific node",
"itemtype": "method",
"name": "disconnectOutput",
@@ -964,7 +964,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1628,
+ "line": 1771,
"description": "disconnect one input",
"itemtype": "method",
"name": "disconnectInput",
@@ -983,7 +983,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1685,
+ "line": 1828,
"description": "returns the center of a connection point in canvas coords",
"itemtype": "method",
"name": "getConnectionPos",
@@ -1007,7 +1007,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1842,
+ "line": 1962,
"description": "Collapse the node to make it smaller on the canvas",
"itemtype": "method",
"name": "collapse",
@@ -1015,7 +1015,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1855,
+ "line": 1975,
"description": "Forces the node to do not move or realign on Z",
"itemtype": "method",
"name": "pin",
@@ -1023,7 +1023,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1912,
+ "line": 2032,
"description": "clears all the data inside",
"itemtype": "method",
"name": "clear",
@@ -1031,10 +1031,40 @@
},
{
"file": "../src/litegraph.js",
- "line": 1966,
+ "line": 2086,
"description": "assigns a graph, you can reasign graphs to the same canvas",
"itemtype": "method",
"name": "setGraph",
+ "params": [
+ {
+ "name": "graph",
+ "description": "",
+ "type": "LGraph"
+ }
+ ],
+ "class": "LGraphCanvas"
+ },
+ {
+ "file": "../src/litegraph.js",
+ "line": 2114,
+ "description": "opens a graph contained inside a node in the current graph",
+ "itemtype": "method",
+ "name": "openSubgraph",
+ "params": [
+ {
+ "name": "graph",
+ "description": "",
+ "type": "LGraph"
+ }
+ ],
+ "class": "LGraphCanvas"
+ },
+ {
+ "file": "../src/litegraph.js",
+ "line": 2141,
+ "description": "closes a subgraph contained inside a node",
+ "itemtype": "method",
+ "name": "closeSubgraph",
"params": [
{
"name": "assigns",
@@ -1046,7 +1076,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 1994,
+ "line": 2156,
"description": "assigns a canvas",
"itemtype": "method",
"name": "setCanvas",
@@ -1061,7 +1091,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 2132,
+ "line": 2294,
"description": "Used to attach the canvas in a popup",
"itemtype": "method",
"name": "getCanvasWindow",
@@ -1073,7 +1103,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 2144,
+ "line": 2306,
"description": "starts rendering the content of the canvas when needed",
"itemtype": "method",
"name": "startRendering",
@@ -1081,7 +1111,7 @@
},
{
"file": "../src/litegraph.js",
- "line": 2175,
+ "line": 2337,
"description": "stops rendering the content of the canvas (to save resources)",
"itemtype": "method",
"name": "stopRendering",
diff --git a/doc/files/.._src_litegraph.js.html b/doc/files/.._src_litegraph.js.html
index 7c64f139b..1fecedaf9 100644
--- a/doc/files/.._src_litegraph.js.html
+++ b/doc/files/.._src_litegraph.js.html
@@ -379,7 +379,7 @@ LGraph.prototype.clear = function()
this.global_inputs = {};
this.global_outputs = {};
- this.graph = {};
+ //this.graph = {};
this.debug = true;
this.change();
@@ -854,10 +854,18 @@ LGraph.prototype.getNodeOnPos = function(x,y, nodes_list)
return null;
}
+// ********** GLOBALS *****************
+
//Tell this graph has a global input of this type
LGraph.prototype.addGlobalInput = function(name, type, value)
{
- this.global_inputs[name] = { type: type, value: value };
+ this.global_inputs[name] = { name: name, type: type, value: value };
+
+ if(this.onGlobalInputAdded)
+ this.onGlobalInputAdded(name, type);
+
+ if(this.onGlobalsChange)
+ this.onGlobalsChange();
}
//assign a data to the global input
@@ -869,29 +877,117 @@ LGraph.prototype.setGlobalInputData = function(name, data)
input.value = data;
}
+//assign a data to the global input
+LGraph.prototype.getGlobalInputData = function(name)
+{
+ var input = this.global_inputs[name];
+ if (!input)
+ return null;
+ return input.value;
+}
+
//rename the global input
LGraph.prototype.renameGlobalInput = function(old_name, name, data)
{
+ if(!this.global_inputs[old_name])
+ return false;
+
+ if(this.global_inputs[name])
+ {
+ console.error("there is already one input with that name");
+ return false;
+ }
+
+ this.global_inputs[name] = this.global_inputs[old_name];
+ delete this.global_inputs[old_name];
+
+ if(this.onGlobalInputRenamed)
+ this.onGlobalInputRenamed(old_name, name);
+
+ if(this.onGlobalsChange)
+ this.onGlobalsChange();
+}
+
+LGraph.prototype.removeGlobalInput = function(name)
+{
+ if(!this.global_inputs[name])
+ return false;
+
+ delete this.global_inputs[name];
+
+ if(this.onGlobalInputRemoved)
+ this.onGlobalInputRemoved(name);
+
+ if(this.onGlobalsChange)
+ this.onGlobalsChange();
+ return true;
}
LGraph.prototype.addGlobalOutput = function(name, type, value)
{
- this.global_outputs[name] = { type: type, value: value };
+ this.global_outputs[name] = { name: name, type: type, value: value };
+
+ if(this.onGlobalOutputAdded)
+ this.onGlobalOutputAdded(name, type);
+
+ if(this.onGlobalsChange)
+ this.onGlobalsChange();
}
//assign a data to the global output
-LGraph.prototype.setGlobalOutputData = function(name, data)
+LGraph.prototype.setGlobalOutputData = function(name, value)
{
var output = this.global_outputs[ name ];
if (!output)
return;
- output.value = data;
+ output.value = value;
}
+//assign a data to the global input
+LGraph.prototype.getGlobalOutputData = function(name)
+{
+ var output = this.global_outputs[name];
+ if (!output)
+ return null;
+ return output.value;
+}
+
+
//rename the global output
LGraph.prototype.renameGlobalOutput = function(old_name, name, data)
{
+ if(!this.global_outputs[old_name])
+ return false;
+
+ if(this.global_outputs[name])
+ {
+ console.error("there is already one output with that name");
+ return false;
+ }
+
+ this.global_outputs[name] = this.global_outputs[old_name];
+ delete this.global_outputs[old_name];
+
+ if(this.onGlobalOutputRenamed)
+ this.onGlobalOutputRenamed(old_name, name);
+
+ if(this.onGlobalsChange)
+ this.onGlobalsChange();
+}
+
+LGraph.prototype.removeGlobalOutput = function(name)
+{
+ if(!this.global_outputs[name])
+ return false;
+ delete this.global_outputs[name];
+
+ if(this.onGlobalOutputRemoved)
+ this.onGlobalOutputRemoved(name);
+
+ if(this.onGlobalsChange)
+ this.onGlobalsChange();
+ return true;
}
@@ -997,7 +1093,7 @@ LGraph.prototype.serialize = function()
var data = {
- graph: this.graph,
+// graph: this.graph,
iteration: this.iteration,
frame: this.frame,
@@ -1133,7 +1229,12 @@ LGraphNode.prototype.configure = function(info)
if(info[j] == null)
continue;
else if (typeof(info[j]) == 'object') //object
- this[j] = LiteGraph.cloneObject(info[j], this[j]);
+ {
+ if(this[j] && this[j].configure)
+ this[j].configure( info[j] );
+ else
+ this[j] = LiteGraph.cloneObject(info[j], this[j]);
+ }
else //value
this[j] = info[j];
}
@@ -1206,6 +1307,36 @@ LGraphNode.prototype.serialize = function()
return o;
}
+
+/* Creates a clone of this node */
+LGraphNode.prototype.clone = function()
+{
+ var node = LiteGraph.createNode(this.type);
+
+ var data = this.serialize();
+ delete data["id"];
+ node.configure(data);
+
+ /*
+ node.size = this.size.concat();
+ if(this.inputs)
+ for(var i = 0, l = this.inputs.length; i < l; ++i)
+ {
+ if(node.findInputSlot( this.inputs[i].name ) == -1)
+ node.addInput( this.inputs[i].name, this.inputs[i].type );
+ }
+
+ if(this.outputs)
+ for(var i = 0, l = this.outputs.length; i < l; ++i)
+ {
+ if(node.findOutputSlot( this.outputs[i].name ) == -1)
+ node.addOutput( this.outputs[i].name, this.outputs[i].type );
+ }
+ */
+
+ return node;
+}
+
//reduced version of objectivize: NOT FINISHED
/*
LGraphNode.prototype.reducedObjectivize = function()
@@ -1384,6 +1515,8 @@ LGraphNode.prototype.addOutput = function(name,type,extra_info)
if(!this.outputs) this.outputs = [];
this.outputs.push(o);
+ if(this.onOutputAdded)
+ this.onOutputAdded(o);
this.size = this.computeSize();
}
@@ -1405,6 +1538,8 @@ LGraphNode.prototype.addOutputs = function(array)
if(!this.outputs)
this.outputs = [];
this.outputs.push(o);
+ if(this.onOutputAdded)
+ this.onOutputAdded(o);
}
this.size = this.computeSize();
@@ -1420,6 +1555,8 @@ LGraphNode.prototype.removeOutput = function(slot)
this.disconnectOutput(slot);
this.outputs.splice(slot,1);
this.size = this.computeSize();
+ if(this.onOutputRemoved)
+ this.onOutputRemoved(slot);
}
/**
@@ -1439,6 +1576,8 @@ LGraphNode.prototype.addInput = function(name,type,extra_info)
if(!this.inputs) this.inputs = [];
this.inputs.push(o);
this.size = this.computeSize();
+ if(this.onInputAdded)
+ this.onInputAdded(o);
}
/**
@@ -1459,6 +1598,8 @@ LGraphNode.prototype.addInputs = function(array)
if(!this.inputs)
this.inputs = [];
this.inputs.push(o);
+ if(this.onInputAdded)
+ this.onInputAdded(o);
}
this.size = this.computeSize();
@@ -1474,6 +1615,8 @@ LGraphNode.prototype.removeInput = function(slot)
this.disconnectInput(slot);
this.inputs.splice(slot,1);
this.size = this.computeSize();
+ if(this.onInputRemoved)
+ this.onInputRemoved(slot);
}
/**
@@ -1816,29 +1959,6 @@ LGraphNode.prototype.alignToGrid = function()
this.pos[1] = LiteGraph.CANVAS_GRID_SIZE * Math.round(this.pos[1] / LiteGraph.CANVAS_GRID_SIZE);
}
-/* Creates a clone of this node */
-LGraphNode.prototype.clone = function()
-{
- var node = LiteGraph.createNode(this.type);
-
- node.size = this.size.concat();
- if(this.inputs)
- for(var i = 0, l = this.inputs.length; i < l; ++i)
- {
- if(node.findInputSlot( this.inputs[i].name ) == -1)
- node.addInput( this.inputs[i].name, this.inputs[i].type );
- }
-
- if(this.outputs)
- for(var i = 0, l = this.outputs.length; i < l; ++i)
- {
- if(node.findOutputSlot( this.outputs[i].name ) == -1)
- node.addOutput( this.outputs[i].name, this.outputs[i].type );
- }
-
-
- return node;
-}
/* Console output */
LGraphNode.prototype.trace = function(msg)
@@ -2061,7 +2181,7 @@ LGraphCanvas.prototype.clear = function()
* assigns a graph, you can reasign graphs to the same canvas
*
* @method setGraph
-* @param {LGraph} assigns a graph
+* @param {LGraph} graph
*/
LGraphCanvas.prototype.setGraph = function(graph)
{
@@ -2085,6 +2205,48 @@ LGraphCanvas.prototype.setGraph = function(graph)
this.setDirty(true,true);
}
+/**
+* opens a graph contained inside a node in the current graph
+*
+* @method openSubgraph
+* @param {LGraph} graph
+*/
+LGraphCanvas.prototype.openSubgraph = function(graph)
+{
+ if(!graph)
+ throw("graph cannot be null");
+
+ if(this.graph == graph)
+ throw("graph cannot be the same");
+
+ this.clear();
+
+ if(this.graph)
+ {
+ if(!this._graph_stack)
+ this._graph_stack = [];
+ this._graph_stack.push(this.graph);
+ }
+
+ graph.attachCanvas(this);
+ this.setDirty(true,true);
+}
+
+/**
+* closes a subgraph contained inside a node
+*
+* @method closeSubgraph
+* @param {LGraph} assigns a graph
+*/
+LGraphCanvas.prototype.closeSubgraph = function()
+{
+ if(!this._graph_stack || this._graph_stack.length == 0)
+ return;
+ var graph = this._graph_stack.pop();
+ graph.attachCanvas(this);
+ this.setDirty(true,true);
+}
+
/**
* assigns a canvas
*
@@ -3988,32 +4150,59 @@ LGraphCanvas.node_colors = {
LGraphCanvas.prototype.getCanvasMenuOptions = function()
{
- return [
- {content:"Add Node", is_menu: true, callback: LGraphCanvas.onMenuAdd }
- //{content:"Collapse All", callback: LGraphCanvas.onMenuCollapseAll }
- ];
+ var options = null;
+ if(this.getMenuOptions)
+ options = this.getMenuOptions();
+ else
+ {
+ options = [
+ {content:"Add Node", is_menu: true, callback: LGraphCanvas.onMenuAdd }
+ //{content:"Collapse All", callback: LGraphCanvas.onMenuCollapseAll }
+ ];
+
+ if(this._graph_stack)
+ options = [{content:"Close subgraph", callback: this.closeSubgraph.bind(this) },null].concat(options);
+ }
+
+ if(this.getExtraMenuOptions)
+ {
+ var extra = this.getExtraMenuOptions(this);
+ extra.push(null);
+ options = extra.concat( options );
+ }
+
+ return options;
}
LGraphCanvas.prototype.getNodeMenuOptions = function(node)
{
- var options = [
- {content:"Inputs", is_menu: true, disabled:true, callback: LGraphCanvas.onMenuNodeInputs },
- {content:"Outputs", is_menu: true, disabled:true, callback: LGraphCanvas.onMenuNodeOutputs },
- null,
- {content:"Collapse", callback: LGraphCanvas.onMenuNodeCollapse },
- {content:"Pin", callback: LGraphCanvas.onMenuNodePin },
- {content:"Colors", is_menu: true, callback: LGraphCanvas.onMenuNodeColors },
- {content:"Shapes", is_menu: true, callback: LGraphCanvas.onMenuNodeShapes },
- null,
- {content:"Clone", callback: LGraphCanvas.onMenuNodeClone },
- null,
- {content:"Remove", callback: LGraphCanvas.onMenuNodeRemove }
- ];
+ var options = null;
- if( node.clonable == false )
- options[7].disabled = true;
- if( node.removable == false )
- options[9].disabled = true;
+ if(node.getMenuOptions)
+ options = node.getMenuOptions(this);
+ else
+ options = [
+ {content:"Inputs", is_menu: true, disabled:true, callback: LGraphCanvas.onMenuNodeInputs },
+ {content:"Outputs", is_menu: true, disabled:true, callback: LGraphCanvas.onMenuNodeOutputs },
+ null,
+ {content:"Collapse", callback: LGraphCanvas.onMenuNodeCollapse },
+ {content:"Pin", callback: LGraphCanvas.onMenuNodePin },
+ {content:"Colors", is_menu: true, callback: LGraphCanvas.onMenuNodeColors },
+ {content:"Shapes", is_menu: true, callback: LGraphCanvas.onMenuNodeShapes },
+ null
+ ];
+
+ if(node.getExtraMenuOptions)
+ {
+ var extra = node.getExtraMenuOptions(this);
+ extra.push(null);
+ options = extra.concat( options );
+ }
+
+ if( node.clonable !== false )
+ options.push({content:"Clone", callback: LGraphCanvas.onMenuNodeClone });
+ if( node.removable !== false )
+ options.push(null,{content:"Remove", callback: LGraphCanvas.onMenuNodeRemove });
if(node.onGetInputs)
{
diff --git a/src/litegraph.js b/src/litegraph.js
index 02083227c..bd2da5e2f 100644
--- a/src/litegraph.js
+++ b/src/litegraph.js
@@ -285,7 +285,7 @@ LGraph.prototype.clear = function()
this.global_inputs = {};
this.global_outputs = {};
- this.graph = {};
+ //this.graph = {};
this.debug = true;
this.change();
@@ -760,10 +760,18 @@ LGraph.prototype.getNodeOnPos = function(x,y, nodes_list)
return null;
}
+// ********** GLOBALS *****************
+
//Tell this graph has a global input of this type
LGraph.prototype.addGlobalInput = function(name, type, value)
{
- this.global_inputs[name] = { type: type, value: value };
+ this.global_inputs[name] = { name: name, type: type, value: value };
+
+ if(this.onGlobalInputAdded)
+ this.onGlobalInputAdded(name, type);
+
+ if(this.onGlobalsChange)
+ this.onGlobalsChange();
}
//assign a data to the global input
@@ -775,29 +783,117 @@ LGraph.prototype.setGlobalInputData = function(name, data)
input.value = data;
}
+//assign a data to the global input
+LGraph.prototype.getGlobalInputData = function(name)
+{
+ var input = this.global_inputs[name];
+ if (!input)
+ return null;
+ return input.value;
+}
+
//rename the global input
LGraph.prototype.renameGlobalInput = function(old_name, name, data)
{
+ if(!this.global_inputs[old_name])
+ return false;
+
+ if(this.global_inputs[name])
+ {
+ console.error("there is already one input with that name");
+ return false;
+ }
+
+ this.global_inputs[name] = this.global_inputs[old_name];
+ delete this.global_inputs[old_name];
+
+ if(this.onGlobalInputRenamed)
+ this.onGlobalInputRenamed(old_name, name);
+
+ if(this.onGlobalsChange)
+ this.onGlobalsChange();
+}
+
+LGraph.prototype.removeGlobalInput = function(name)
+{
+ if(!this.global_inputs[name])
+ return false;
+
+ delete this.global_inputs[name];
+
+ if(this.onGlobalInputRemoved)
+ this.onGlobalInputRemoved(name);
+
+ if(this.onGlobalsChange)
+ this.onGlobalsChange();
+ return true;
}
LGraph.prototype.addGlobalOutput = function(name, type, value)
{
- this.global_outputs[name] = { type: type, value: value };
+ this.global_outputs[name] = { name: name, type: type, value: value };
+
+ if(this.onGlobalOutputAdded)
+ this.onGlobalOutputAdded(name, type);
+
+ if(this.onGlobalsChange)
+ this.onGlobalsChange();
}
//assign a data to the global output
-LGraph.prototype.setGlobalOutputData = function(name, data)
+LGraph.prototype.setGlobalOutputData = function(name, value)
{
var output = this.global_outputs[ name ];
if (!output)
return;
- output.value = data;
+ output.value = value;
}
+//assign a data to the global input
+LGraph.prototype.getGlobalOutputData = function(name)
+{
+ var output = this.global_outputs[name];
+ if (!output)
+ return null;
+ return output.value;
+}
+
+
//rename the global output
LGraph.prototype.renameGlobalOutput = function(old_name, name, data)
{
+ if(!this.global_outputs[old_name])
+ return false;
+
+ if(this.global_outputs[name])
+ {
+ console.error("there is already one output with that name");
+ return false;
+ }
+
+ this.global_outputs[name] = this.global_outputs[old_name];
+ delete this.global_outputs[old_name];
+
+ if(this.onGlobalOutputRenamed)
+ this.onGlobalOutputRenamed(old_name, name);
+
+ if(this.onGlobalsChange)
+ this.onGlobalsChange();
+}
+
+LGraph.prototype.removeGlobalOutput = function(name)
+{
+ if(!this.global_outputs[name])
+ return false;
+ delete this.global_outputs[name];
+
+ if(this.onGlobalOutputRemoved)
+ this.onGlobalOutputRemoved(name);
+
+ if(this.onGlobalsChange)
+ this.onGlobalsChange();
+ return true;
}
@@ -903,7 +999,7 @@ LGraph.prototype.serialize = function()
var data = {
- graph: this.graph,
+// graph: this.graph,
iteration: this.iteration,
frame: this.frame,
@@ -1039,7 +1135,12 @@ LGraphNode.prototype.configure = function(info)
if(info[j] == null)
continue;
else if (typeof(info[j]) == 'object') //object
- this[j] = LiteGraph.cloneObject(info[j], this[j]);
+ {
+ if(this[j] && this[j].configure)
+ this[j].configure( info[j] );
+ else
+ this[j] = LiteGraph.cloneObject(info[j], this[j]);
+ }
else //value
this[j] = info[j];
}
@@ -1112,6 +1213,36 @@ LGraphNode.prototype.serialize = function()
return o;
}
+
+/* Creates a clone of this node */
+LGraphNode.prototype.clone = function()
+{
+ var node = LiteGraph.createNode(this.type);
+
+ var data = this.serialize();
+ delete data["id"];
+ node.configure(data);
+
+ /*
+ node.size = this.size.concat();
+ if(this.inputs)
+ for(var i = 0, l = this.inputs.length; i < l; ++i)
+ {
+ if(node.findInputSlot( this.inputs[i].name ) == -1)
+ node.addInput( this.inputs[i].name, this.inputs[i].type );
+ }
+
+ if(this.outputs)
+ for(var i = 0, l = this.outputs.length; i < l; ++i)
+ {
+ if(node.findOutputSlot( this.outputs[i].name ) == -1)
+ node.addOutput( this.outputs[i].name, this.outputs[i].type );
+ }
+ */
+
+ return node;
+}
+
//reduced version of objectivize: NOT FINISHED
/*
LGraphNode.prototype.reducedObjectivize = function()
@@ -1290,6 +1421,8 @@ LGraphNode.prototype.addOutput = function(name,type,extra_info)
if(!this.outputs) this.outputs = [];
this.outputs.push(o);
+ if(this.onOutputAdded)
+ this.onOutputAdded(o);
this.size = this.computeSize();
}
@@ -1311,6 +1444,8 @@ LGraphNode.prototype.addOutputs = function(array)
if(!this.outputs)
this.outputs = [];
this.outputs.push(o);
+ if(this.onOutputAdded)
+ this.onOutputAdded(o);
}
this.size = this.computeSize();
@@ -1326,6 +1461,8 @@ LGraphNode.prototype.removeOutput = function(slot)
this.disconnectOutput(slot);
this.outputs.splice(slot,1);
this.size = this.computeSize();
+ if(this.onOutputRemoved)
+ this.onOutputRemoved(slot);
}
/**
@@ -1345,6 +1482,8 @@ LGraphNode.prototype.addInput = function(name,type,extra_info)
if(!this.inputs) this.inputs = [];
this.inputs.push(o);
this.size = this.computeSize();
+ if(this.onInputAdded)
+ this.onInputAdded(o);
}
/**
@@ -1365,6 +1504,8 @@ LGraphNode.prototype.addInputs = function(array)
if(!this.inputs)
this.inputs = [];
this.inputs.push(o);
+ if(this.onInputAdded)
+ this.onInputAdded(o);
}
this.size = this.computeSize();
@@ -1380,6 +1521,8 @@ LGraphNode.prototype.removeInput = function(slot)
this.disconnectInput(slot);
this.inputs.splice(slot,1);
this.size = this.computeSize();
+ if(this.onInputRemoved)
+ this.onInputRemoved(slot);
}
/**
@@ -1722,29 +1865,6 @@ LGraphNode.prototype.alignToGrid = function()
this.pos[1] = LiteGraph.CANVAS_GRID_SIZE * Math.round(this.pos[1] / LiteGraph.CANVAS_GRID_SIZE);
}
-/* Creates a clone of this node */
-LGraphNode.prototype.clone = function()
-{
- var node = LiteGraph.createNode(this.type);
-
- node.size = this.size.concat();
- if(this.inputs)
- for(var i = 0, l = this.inputs.length; i < l; ++i)
- {
- if(node.findInputSlot( this.inputs[i].name ) == -1)
- node.addInput( this.inputs[i].name, this.inputs[i].type );
- }
-
- if(this.outputs)
- for(var i = 0, l = this.outputs.length; i < l; ++i)
- {
- if(node.findOutputSlot( this.outputs[i].name ) == -1)
- node.addOutput( this.outputs[i].name, this.outputs[i].type );
- }
-
-
- return node;
-}
/* Console output */
LGraphNode.prototype.trace = function(msg)
@@ -1967,7 +2087,7 @@ LGraphCanvas.prototype.clear = function()
* assigns a graph, you can reasign graphs to the same canvas
*
* @method setGraph
-* @param {LGraph} assigns a graph
+* @param {LGraph} graph
*/
LGraphCanvas.prototype.setGraph = function(graph)
{
@@ -1991,6 +2111,48 @@ LGraphCanvas.prototype.setGraph = function(graph)
this.setDirty(true,true);
}
+/**
+* opens a graph contained inside a node in the current graph
+*
+* @method openSubgraph
+* @param {LGraph} graph
+*/
+LGraphCanvas.prototype.openSubgraph = function(graph)
+{
+ if(!graph)
+ throw("graph cannot be null");
+
+ if(this.graph == graph)
+ throw("graph cannot be the same");
+
+ this.clear();
+
+ if(this.graph)
+ {
+ if(!this._graph_stack)
+ this._graph_stack = [];
+ this._graph_stack.push(this.graph);
+ }
+
+ graph.attachCanvas(this);
+ this.setDirty(true,true);
+}
+
+/**
+* closes a subgraph contained inside a node
+*
+* @method closeSubgraph
+* @param {LGraph} assigns a graph
+*/
+LGraphCanvas.prototype.closeSubgraph = function()
+{
+ if(!this._graph_stack || this._graph_stack.length == 0)
+ return;
+ var graph = this._graph_stack.pop();
+ graph.attachCanvas(this);
+ this.setDirty(true,true);
+}
+
/**
* assigns a canvas
*
@@ -3894,32 +4056,59 @@ LGraphCanvas.node_colors = {
LGraphCanvas.prototype.getCanvasMenuOptions = function()
{
- return [
- {content:"Add Node", is_menu: true, callback: LGraphCanvas.onMenuAdd }
- //{content:"Collapse All", callback: LGraphCanvas.onMenuCollapseAll }
- ];
+ var options = null;
+ if(this.getMenuOptions)
+ options = this.getMenuOptions();
+ else
+ {
+ options = [
+ {content:"Add Node", is_menu: true, callback: LGraphCanvas.onMenuAdd }
+ //{content:"Collapse All", callback: LGraphCanvas.onMenuCollapseAll }
+ ];
+
+ if(this._graph_stack)
+ options = [{content:"Close subgraph", callback: this.closeSubgraph.bind(this) },null].concat(options);
+ }
+
+ if(this.getExtraMenuOptions)
+ {
+ var extra = this.getExtraMenuOptions(this);
+ extra.push(null);
+ options = extra.concat( options );
+ }
+
+ return options;
}
LGraphCanvas.prototype.getNodeMenuOptions = function(node)
{
- var options = [
- {content:"Inputs", is_menu: true, disabled:true, callback: LGraphCanvas.onMenuNodeInputs },
- {content:"Outputs", is_menu: true, disabled:true, callback: LGraphCanvas.onMenuNodeOutputs },
- null,
- {content:"Collapse", callback: LGraphCanvas.onMenuNodeCollapse },
- {content:"Pin", callback: LGraphCanvas.onMenuNodePin },
- {content:"Colors", is_menu: true, callback: LGraphCanvas.onMenuNodeColors },
- {content:"Shapes", is_menu: true, callback: LGraphCanvas.onMenuNodeShapes },
- null,
- {content:"Clone", callback: LGraphCanvas.onMenuNodeClone },
- null,
- {content:"Remove", callback: LGraphCanvas.onMenuNodeRemove }
- ];
+ var options = null;
- if( node.clonable == false )
- options[7].disabled = true;
- if( node.removable == false )
- options[9].disabled = true;
+ if(node.getMenuOptions)
+ options = node.getMenuOptions(this);
+ else
+ options = [
+ {content:"Inputs", is_menu: true, disabled:true, callback: LGraphCanvas.onMenuNodeInputs },
+ {content:"Outputs", is_menu: true, disabled:true, callback: LGraphCanvas.onMenuNodeOutputs },
+ null,
+ {content:"Collapse", callback: LGraphCanvas.onMenuNodeCollapse },
+ {content:"Pin", callback: LGraphCanvas.onMenuNodePin },
+ {content:"Colors", is_menu: true, callback: LGraphCanvas.onMenuNodeColors },
+ {content:"Shapes", is_menu: true, callback: LGraphCanvas.onMenuNodeShapes },
+ null
+ ];
+
+ if(node.getExtraMenuOptions)
+ {
+ var extra = node.getExtraMenuOptions(this);
+ extra.push(null);
+ options = extra.concat( options );
+ }
+
+ if( node.clonable !== false )
+ options.push({content:"Clone", callback: LGraphCanvas.onMenuNodeClone });
+ if( node.removable !== false )
+ options.push(null,{content:"Remove", callback: LGraphCanvas.onMenuNodeRemove });
if(node.onGetInputs)
{
diff --git a/src/nodes/base.js b/src/nodes/base.js
index 49181b5b4..f6104c0b2 100644
--- a/src/nodes/base.js
+++ b/src/nodes/base.js
@@ -5,15 +5,32 @@
//Input for a subgraph
function GlobalInput()
{
+ this.title = "Input";
+
+ //random name to avoid problems with other outputs when added
+ var genname = "input_" + (Math.random()*1000).toFixed();
+ this.properties = { name: genname, type: "number" };
this.addOutput("value",0);
}
+GlobalInput.title = "Input";
+GlobalInput.desc = "Input of the graph";
+
+GlobalInput.prototype.onAdded = function()
+{
+ this.graph.addGlobalInput( this.properties.name, this.properties.type );
+}
+
GlobalInput.prototype.onExecute = function()
{
- var name = this.title;
- //read input
- var value = node.graph.global_inputs[name];
- this.setOutputData(0,value);
+ var name = this.properties.name;
+
+ //read from global input
+ var data = this.graph.global_inputs[name];
+ if(!data) return;
+
+ //put through output
+ this.setOutputData(0,data.value);
}
LiteGraph.registerNodeType("graph/input", GlobalInput);
@@ -25,11 +42,14 @@ function GlobalOutput()
this.title = "Output";
//random name to avoid problems with other outputs when added
- var genname = "input_" + (Math.random()*1000).toFixed();
+ var genname = "output_" + (Math.random()*1000).toFixed();
this.properties = { name: genname, type: "number" };
this.addInput("value","number");
}
+GlobalOutput.title = "Ouput";
+GlobalOutput.desc = "Output of the graph";
+
GlobalOutput.prototype.onAdded = function()
{
var name = this.graph.addGlobalOutput( this.properties.name, this.properties.type );
@@ -37,8 +57,7 @@ GlobalOutput.prototype.onAdded = function()
GlobalOutput.prototype.onExecute = function()
{
- var value = this.getInputData(0);
- this.graph.setGlobalOutputData( this.properties.name, value );
+ this.graph.setGlobalOutputData( this.properties.name, this.getInputData(0) );
}
LiteGraph.registerNodeType("graph/output", GlobalOutput);
@@ -47,29 +66,77 @@ LiteGraph.registerNodeType("graph/output", GlobalOutput);
//Subgraph: a node that contains a graph
function Subgraph()
{
+ var that = this;
this.subgraph = new LGraph();
+ this.subgraph._subgraph_node = this;
+ this.subgraph._is_subgraph = true;
+ this.subgraph.onGlobalInputAdded = this.onSubgraphNewGlobalInput.bind(this);
+ this.subgraph.onGlobalOutputAdded = this.onSubgraphNewGlobalOutput.bind(this);
+
this.bgcolor = "#FA3";
}
+Subgraph.title = "Subgraph";
+Subgraph.desc = "Graph inside a node";
+
+Subgraph.prototype.onSubgraphNewGlobalInput = function(name, type)
+{
+ this.addInput(name, type);
+}
+
+Subgraph.prototype.onSubgraphNewGlobalOutput = function(name, type)
+{
+ this.addOutput(name, type);
+}
+
+Subgraph.prototype.getExtraMenuOptions = function(graphcanvas)
+{
+ var that = this;
+ return [ {content:"Open", callback:
+ function() {
+ graphcanvas.openSubgraph( that.subgraph );
+ }
+ }];
+}
+
Subgraph.prototype.onExecute = function()
{
//send inputs to subgraph global inputs
- for(var i in this.inputs)
- {
- var input = this.inputs[i];
+ if(this.inputs)
+ for(var i = 0; i < this.inputs.length; i++)
+ {
+ var input = this.inputs[i];
+ var value = this.getInputData(i);
+ this.subgraph.setGlobalInputData( input.name, value );
+ }
- //this.subgraph.setGlobalInputData( input.name, input.value );
- }
+ //execute
+ this.subgraph.runStep();
//send subgraph global outputs to outputs
+ if(this.outputs)
+ for(var i = 0; i < this.outputs.length; i++)
+ {
+ var output = this.outputs[i];
+ var value = this.subgraph.getGlobalOutputData( output.name );
+ this.setOutputData(i, value);
+ }
}
Subgraph.prototype.configure = function(o)
{
- LGraph.prototype.configure.call(this, o);
- //after configure, ...
+ LGraphNode.prototype.configure.call(this, o);
+ //this.subgraph.configure(o.graph);
}
+Subgraph.prototype.serialize = function()
+{
+ var data = LGraphNode.prototype.serialize.call(this);
+ data.subgraph = this.subgraph.serialize();
+ return data;
+}
+
+
LiteGraph.registerNodeType("graph/subgraph", Subgraph);
diff --git a/src/nodes/interface.js b/src/nodes/interface.js
index 623c6d09c..1fe0a6e79 100644
--- a/src/nodes/interface.js
+++ b/src/nodes/interface.js
@@ -3,8 +3,8 @@
function WidgetKnob()
{
- this.size = [64,84];
this.addOutput("",'number');
+ this.size = [64,84];
this.properties = {min:0,max:1,value:0.5,wcolor:"#7AF",size:50};
}
@@ -42,12 +42,14 @@
ctx.restore();
- ctx.font = "bold 16px Criticized,Tahoma";
- ctx.fillStyle="rgba(100,100,100,0.8)";
- ctx.textAlign = "center";
-
- ctx.fillText(this.name.toUpperCase(), this.size[0] * 0.5, 18 );
- ctx.textAlign = "left";
+ if(this.title)
+ {
+ ctx.font = "bold 16px Criticized,Tahoma";
+ ctx.fillStyle="rgba(100,100,100,0.8)";
+ ctx.textAlign = "center";
+ ctx.fillText(this.title.toUpperCase(), this.size[0] * 0.5, 18 );
+ ctx.textAlign = "left";
+ }
}
WidgetKnob.prototype.onDrawVectorKnob = function(ctx)
diff --git a/src/nodes/math.js b/src/nodes/math.js
index 6d45045e9..091a5ca4f 100644
--- a/src/nodes/math.js
+++ b/src/nodes/math.js
@@ -41,6 +41,7 @@ function MathClamp()
MathClamp.title = "Clamp";
MathClamp.desc = "Clamp number between min and max";
+MathClamp.filter = "shader";
MathClamp.prototype.onExecute = function()
{
@@ -51,6 +52,14 @@ MathClamp.prototype.onExecute = function()
this.setOutputData(0, v );
}
+MathClamp.prototype.getCode = function(lang)
+{
+ var code = "";
+ if(this.isInputConnected(0))
+ code += "clamp({{0}}," + this.properties.min + "," + this.properties.max + ")";
+ return code;
+}
+
LiteGraph.registerNodeType("math/clamp", MathClamp );
@@ -90,7 +99,7 @@ MathFloor.prototype.onExecute = function()
{
var v = this.getInputData(0);
if(v == null) return;
- this.setOutputData(0, v|1 );
+ this.setOutputData(0, Math.floor(v) );
}
LiteGraph.registerNodeType("math/floor", MathFloor );
@@ -284,6 +293,7 @@ function MathTrigonometry()
MathTrigonometry.title = "Trigonometry";
MathTrigonometry.desc = "Sin Cos Tan";
+MathTrigonometry.filter = "shader";
MathTrigonometry.prototype.onExecute = function()
{