mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-20 06:44:32 +00:00
fix on Trigger
This commit is contained in:
@@ -2977,12 +2977,14 @@
|
||||
//used to mark events in graph
|
||||
var target_connection = node.inputs[link_info.target_slot];
|
||||
|
||||
if (node.onAction) {
|
||||
node.onAction(target_connection.name, param);
|
||||
} else if (node.mode === LiteGraph.ON_TRIGGER) {
|
||||
if (node.mode === LiteGraph.ON_TRIGGER)
|
||||
{
|
||||
if (node.onExecute) {
|
||||
node.onExecute(param);
|
||||
}
|
||||
}
|
||||
else if (node.onAction) {
|
||||
node.onAction(target_connection.name, param);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -21251,10 +21253,10 @@ LGraphTextureBlur.pixel_shader = "precision highp float;\n\
|
||||
//based on https://catlikecoding.com/unity/tutorials/advanced-rendering/bloom/
|
||||
function FXGlow()
|
||||
{
|
||||
this.intensity = 1;
|
||||
this.persistence = 0.99;
|
||||
this.iterations = 16;
|
||||
this.threshold = 0;
|
||||
this.intensity = 0.5;
|
||||
this.persistence = 0.6;
|
||||
this.iterations = 8;
|
||||
this.threshold = 0.8;
|
||||
this.scale = 1;
|
||||
|
||||
this.dirt_texture = null;
|
||||
|
||||
74
build/litegraph.min.js
vendored
74
build/litegraph.min.js
vendored
@@ -65,42 +65,42 @@ if(!a)return null;var b=this.graph.getNodeById(a.origin_id);return b?(a=b.output
|
||||
a<this.inputs.length?this.graph.links[this.inputs[a].link]:null:null};s.prototype.getInputNode=function(a){if(!this.inputs||a>=this.inputs.length)return null;a=this.inputs[a];return a&&null!==a.link?(a=this.graph.links[a.link])?this.graph.getNodeById(a.origin_id):null:null};s.prototype.getInputOrProperty=function(a){if(!this.inputs||!this.inputs.length)return this.properties?this.properties[a]:null;for(var b=0,d=this.inputs.length;b<d;++b){var f=this.inputs[b];if(a==f.name&&null!=f.link&&(f=this.graph.links[f.link]))return f.data}return this.properties[a]};
|
||||
s.prototype.getOutputData=function(a){return!this.outputs||a>=this.outputs.length?null:this.outputs[a]._data};s.prototype.getOutputInfo=function(a){return this.outputs?a<this.outputs.length?this.outputs[a]:null:null};s.prototype.isOutputConnected=function(a){return this.outputs?a<this.outputs.length&&this.outputs[a].links&&this.outputs[a].links.length:!1};s.prototype.isAnyOutputConnected=function(){if(!this.outputs)return!1;for(var a=0;a<this.outputs.length;++a)if(this.outputs[a].links&&this.outputs[a].links.length)return!0;
|
||||
return!1};s.prototype.getOutputNodes=function(a){if(!this.outputs||0==this.outputs.length||a>=this.outputs.length)return null;a=this.outputs[a];if(!a.links||0==a.links.length)return null;for(var b=[],d=0;d<a.links.length;d++){var f=this.graph.links[a.links[d]];f&&(f=this.graph.getNodeById(f.target_id))&&b.push(f)}return b};s.prototype.trigger=function(a,b){if(this.outputs&&this.outputs.length){this.graph&&(this.graph._last_trigger_time=e.getTime());for(var d=0;d<this.outputs.length;++d){var f=this.outputs[d];
|
||||
!f||f.type!==e.EVENT||a&&f.name!=a||this.triggerSlot(d,b)}}};s.prototype.triggerSlot=function(a,b,d){if(this.outputs&&(a=this.outputs[a])&&(a=a.links)&&a.length){this.graph&&(this.graph._last_trigger_time=e.getTime());for(var f=0;f<a.length;++f){var g=a[f];if(null==d||d==g){var t=this.graph.links[a[f]];if(t&&(t._last_time=e.getTime(),g=this.graph.getNodeById(t.target_id)))if(t=g.inputs[t.target_slot],g.onAction)g.onAction(t.name,b);else if(g.mode===e.ON_TRIGGER&&g.onExecute)g.onExecute(b)}}}};s.prototype.clearTriggeredSlot=
|
||||
function(a,b){if(this.outputs){var d=this.outputs[a];if(d&&(d=d.links)&&d.length)for(var f=0;f<d.length;++f){var g=d[f];if(null==b||b==g)if(g=this.graph.links[d[f]])g._last_time=0}}};s.prototype.setSize=function(a){this.size=a;if(this.onResize)this.onResize(this.size)};s.prototype.addProperty=function(a,b,d,f){d={name:a,type:d,default_value:b};if(f)for(var g in f)d[g]=f[g];this.properties_info||(this.properties_info=[]);this.properties_info.push(d);this.properties||(this.properties={});this.properties[a]=
|
||||
b;return d};s.prototype.addOutput=function(a,b,d){a={name:a,type:b,links:null};if(d)for(var f in d)a[f]=d[f];this.outputs||(this.outputs=[]);this.outputs.push(a);if(this.onOutputAdded)this.onOutputAdded(a);this.setSize(this.computeSize());this.setDirtyCanvas(!0,!0);return a};s.prototype.addOutputs=function(a){for(var b=0;b<a.length;++b){var d=a[b],f={name:d[0],type:d[1],link:null};if(a[2])for(var g in d[2])f[g]=d[2][g];this.outputs||(this.outputs=[]);this.outputs.push(f);if(this.onOutputAdded)this.onOutputAdded(f)}this.setSize(this.computeSize());
|
||||
this.setDirtyCanvas(!0,!0)};s.prototype.removeOutput=function(a){this.disconnectOutput(a);this.outputs.splice(a,1);for(var b=a;b<this.outputs.length;++b)if(this.outputs[b]&&this.outputs[b].links)for(var d=this.outputs[b].links,f=0;f<d.length;++f){var g=this.graph.links[d[f]];g&&(g.origin_slot-=1)}this.setSize(this.computeSize());if(this.onOutputRemoved)this.onOutputRemoved(a);this.setDirtyCanvas(!0,!0)};s.prototype.addInput=function(a,b,d){a={name:a,type:b||0,link:null};if(d)for(var f in d)a[f]=d[f];
|
||||
this.inputs||(this.inputs=[]);this.inputs.push(a);this.setSize(this.computeSize());if(this.onInputAdded)this.onInputAdded(a);this.setDirtyCanvas(!0,!0);return a};s.prototype.addInputs=function(a){for(var b=0;b<a.length;++b){var d=a[b],f={name:d[0],type:d[1],link:null};if(a[2])for(var g in d[2])f[g]=d[2][g];this.inputs||(this.inputs=[]);this.inputs.push(f);if(this.onInputAdded)this.onInputAdded(f)}this.setSize(this.computeSize());this.setDirtyCanvas(!0,!0)};s.prototype.removeInput=function(a){this.disconnectInput(a);
|
||||
for(var b=this.inputs.splice(a,1),d=a;d<this.inputs.length;++d)if(this.inputs[d]){var f=this.graph.links[this.inputs[d].link];f&&(f.target_slot-=1)}this.setSize(this.computeSize());if(this.onInputRemoved)this.onInputRemoved(a,b[0]);this.setDirtyCanvas(!0,!0)};s.prototype.addConnection=function(a,b,d,f){a={name:a,type:b,pos:d,direction:f,links:null};this.connections.push(a);return a};s.prototype.computeSize=function(a){function b(a){return a?f*a.length*0.6:0}if(this.constructor.size)return this.constructor.size.concat();
|
||||
var d=Math.max(this.inputs?this.inputs.length:1,this.outputs?this.outputs.length:1);a=a||new Float32Array([0,0]);var d=Math.max(d,1),f=e.NODE_TEXT_SIZE,g=b(this.title),t=0,x=0;if(this.inputs)for(var c=0,k=this.inputs.length;c<k;++c){var h=this.inputs[c],h=h.label||h.name||"",h=b(h);t<h&&(t=h)}if(this.outputs)for(c=0,k=this.outputs.length;c<k;++c)h=this.outputs[c],h=h.label||h.name||"",h=b(h),x<h&&(x=h);a[0]=Math.max(t+x+10,g);a[0]=Math.max(a[0],e.NODE_WIDTH);this.widgets&&this.widgets.length&&(a[0]=
|
||||
Math.max(a[0],1.5*e.NODE_WIDTH));a[1]=(this.constructor.slot_start_y||0)+d*e.NODE_SLOT_HEIGHT;d=0;if(this.widgets&&this.widgets.length){c=0;for(k=this.widgets.length;c<k;++c)d=this.widgets[c].computeSize?d+(this.widgets[c].computeSize(a[0])[1]+4):d+(e.NODE_WIDGET_HEIGHT+4);d+=8}a[1]=this.widgets_up?Math.max(a[1],d):null!=this.widgets_start_y?Math.max(a[1],d+this.widgets_start_y):a[1]+d;this.constructor.min_height&&a[1]<this.constructor.min_height&&(a[1]=this.constructor.min_height);a[1]+=6;return a};
|
||||
s.prototype.getPropertyInfo=function(a){var b=null;if(this.properties_info)for(var d=0;d<this.properties_info.length;++d)if(this.properties_info[d].name==a){b=this.properties_info[d];break}this.constructor["@"+a]&&(b=this.constructor["@"+a]);this.constructor.widgets_info&&this.constructor.widgets_info[a]&&(b=this.constructor.widgets_info[a]);!b&&this.onGetPropertyInfo&&(b=this.onGetPropertyInfo(a));b||(b={});b.type||(b.type=typeof this.properties[a]);"combo"==b.widget&&(b.type="enum");return b};s.prototype.addWidget=
|
||||
function(a,b,d,f,g){this.widgets||(this.widgets=[]);!g&&f&&f.constructor===Object&&(g=f,f=null);g&&g.constructor===String&&(g={property:g});f&&f.constructor===String&&(g||(g={}),g.property=f,f=null);f&&f.constructor!==Function&&(console.warn("addWidget: callback must be a function"),f=null);b={type:a.toLowerCase(),name:b,value:d,callback:f,options:g||{}};void 0!==b.options.y&&(b.y=b.options.y);f||b.options.callback||b.options.property||console.warn("LiteGraph addWidget(...) without a callback or property assigned");
|
||||
if("combo"==a&&!b.options.values)throw"LiteGraph addWidget('combo',...) requires to pass values in options: { values:['red','blue'] }";this.widgets.push(b);this.setSize(this.computeSize());return b};s.prototype.addCustomWidget=function(a){this.widgets||(this.widgets=[]);this.widgets.push(a);return a};s.prototype.getBounding=function(a){a=a||new Float32Array(4);a[0]=this.pos[0]-4;a[1]=this.pos[1]-e.NODE_TITLE_HEIGHT;a[2]=this.size[0]+4;a[3]=this.size[1]+e.NODE_TITLE_HEIGHT;if(this.onBounding)this.onBounding(a);
|
||||
return a};s.prototype.isPointInside=function(a,b,d,f){d=d||0;var g=this.graph&&this.graph.isLive()?0:e.NODE_TITLE_HEIGHT;f&&(g=0);if(this.flags&&this.flags.collapsed){if(v(a,b,this.pos[0]-d,this.pos[1]-e.NODE_TITLE_HEIGHT-d,(this._collapsed_width||e.NODE_COLLAPSED_WIDTH)+2*d,e.NODE_TITLE_HEIGHT+2*d))return!0}else if(this.pos[0]-4-d<a&&this.pos[0]+this.size[0]+4+d>a&&this.pos[1]-g-d<b&&this.pos[1]+this.size[1]+d>b)return!0;return!1};s.prototype.getSlotInPosition=function(a,b){var d=new Float32Array(2);
|
||||
if(this.inputs)for(var f=0,g=this.inputs.length;f<g;++f){var t=this.inputs[f];this.getConnectionPos(!0,f,d);if(v(a,b,d[0]-10,d[1]-5,20,10))return{input:t,slot:f,link_pos:d}}if(this.outputs)for(f=0,g=this.outputs.length;f<g;++f)if(t=this.outputs[f],this.getConnectionPos(!1,f,d),v(a,b,d[0]-10,d[1]-5,20,10))return{output:t,slot:f,link_pos:d};return null};s.prototype.findInputSlot=function(a){if(!this.inputs)return-1;for(var b=0,d=this.inputs.length;b<d;++b)if(a==this.inputs[b].name)return b;return-1};
|
||||
s.prototype.findOutputSlot=function(a){if(!this.outputs)return-1;for(var b=0,d=this.outputs.length;b<d;++b)if(a==this.outputs[b].name)return b;return-1};s.prototype.connect=function(a,b,d){d=d||0;if(!this.graph)return console.log("Connect: Error, node doesn't belong to any graph. Nodes must be added first to a graph before connecting them."),null;if(a.constructor===String){if(a=this.findOutputSlot(a),-1==a)return e.debug&&console.log("Connect: Error, no slot of name "+a),null}else if(!this.outputs||
|
||||
a>=this.outputs.length)return e.debug&&console.log("Connect: Error, slot number not found"),null;b&&b.constructor===Number&&(b=this.graph.getNodeById(b));if(!b)throw"target node is null";if(b==this)return null;if(d.constructor===String){if(d=b.findInputSlot(d),-1==d)return e.debug&&console.log("Connect: Error, no slot of name "+d),null}else{if(d===e.EVENT)return null;if(!b.inputs||d>=b.inputs.length)return e.debug&&console.log("Connect: Error, slot number not found"),null}var f=!1;null!=b.inputs[d].link&&
|
||||
(this.graph.beforeChange(),b.disconnectInput(d),f=!0);var g=this.outputs[a];if(b.onConnectInput&&!1===b.onConnectInput(d,g.type,g,this,a))return null;var t=b.inputs[d],x=null;if(!e.isValidConnection(g.type,t.type))return this.setDirtyCanvas(!1,!0),f&&this.graph.connectionChange(this,x),null;f||this.graph.beforeChange();x=new m(++this.graph.last_link_id,t.type,this.id,a,b.id,d);this.graph.links[x.id]=x;null==g.links&&(g.links=[]);g.links.push(x.id);b.inputs[d].link=x.id;this.graph&&this.graph._version++;
|
||||
if(this.onConnectionsChange)this.onConnectionsChange(e.OUTPUT,a,!0,x,g);if(b.onConnectionsChange)b.onConnectionsChange(e.INPUT,d,!0,x,t);this.graph&&this.graph.onNodeConnectionChange&&(this.graph.onNodeConnectionChange(e.INPUT,b,d,this,a),this.graph.onNodeConnectionChange(e.OUTPUT,this,a,b,d));this.setDirtyCanvas(!1,!0);this.graph.afterChange();this.graph.connectionChange(this,x);return x};s.prototype.disconnectOutput=function(a,b){if(a.constructor===String){if(a=this.findOutputSlot(a),-1==a)return e.debug&&
|
||||
console.log("Connect: Error, no slot of name "+a),!1}else if(!this.outputs||a>=this.outputs.length)return e.debug&&console.log("Connect: Error, slot number not found"),!1;var d=this.outputs[a];if(!d||!d.links||0==d.links.length)return!1;if(b){b.constructor===Number&&(b=this.graph.getNodeById(b));if(!b)throw"Target Node not found";for(var f=0,g=d.links.length;f<g;f++){var t=d.links[f],x=this.graph.links[t];if(x.target_id==b.id){d.links.splice(f,1);var c=b.inputs[x.target_slot];c.link=null;delete this.graph.links[t];
|
||||
this.graph&&this.graph._version++;if(b.onConnectionsChange)b.onConnectionsChange(e.INPUT,x.target_slot,!1,x,c);if(this.onConnectionsChange)this.onConnectionsChange(e.OUTPUT,a,!1,x,d);if(this.graph&&this.graph.onNodeConnectionChange)this.graph.onNodeConnectionChange(e.OUTPUT,this,a);this.graph&&this.graph.onNodeConnectionChange&&(this.graph.onNodeConnectionChange(e.OUTPUT,this,a),this.graph.onNodeConnectionChange(e.INPUT,b,x.target_slot));break}}}else{f=0;for(g=d.links.length;f<g;f++)if(t=d.links[f],
|
||||
x=this.graph.links[t]){b=this.graph.getNodeById(x.target_id);this.graph&&this.graph._version++;if(b){c=b.inputs[x.target_slot];c.link=null;if(b.onConnectionsChange)b.onConnectionsChange(e.INPUT,x.target_slot,!1,x,c);if(this.graph&&this.graph.onNodeConnectionChange)this.graph.onNodeConnectionChange(e.INPUT,b,x.target_slot)}delete this.graph.links[t];if(this.onConnectionsChange)this.onConnectionsChange(e.OUTPUT,a,!1,x,d);this.graph&&this.graph.onNodeConnectionChange&&(this.graph.onNodeConnectionChange(e.OUTPUT,
|
||||
this,a),this.graph.onNodeConnectionChange(e.INPUT,b,x.target_slot))}d.links=null}this.setDirtyCanvas(!1,!0);this.graph.connectionChange(this);return!0};s.prototype.disconnectInput=function(a){if(a.constructor===String){if(a=this.findInputSlot(a),-1==a)return e.debug&&console.log("Connect: Error, no slot of name "+a),!1}else if(!this.inputs||a>=this.inputs.length)return e.debug&&console.log("Connect: Error, slot number not found"),!1;var b=this.inputs[a];if(!b)return!1;var d=this.inputs[a].link;if(null!=
|
||||
d){this.inputs[a].link=null;var f=this.graph.links[d];if(f){var g=this.graph.getNodeById(f.origin_id);if(!g)return!1;var t=g.outputs[f.origin_slot];if(!t||!t.links||0==t.links.length)return!1;for(var x=0,c=t.links.length;x<c;x++)if(t.links[x]==d){t.links.splice(x,1);break}delete this.graph.links[d];this.graph&&this.graph._version++;if(this.onConnectionsChange)this.onConnectionsChange(e.INPUT,a,!1,f,b);if(g.onConnectionsChange)g.onConnectionsChange(e.OUTPUT,x,!1,f,t);this.graph&&this.graph.onNodeConnectionChange&&
|
||||
(this.graph.onNodeConnectionChange(e.OUTPUT,g,x),this.graph.onNodeConnectionChange(e.INPUT,this,a))}}this.setDirtyCanvas(!1,!0);this.graph&&this.graph.connectionChange(this);return!0};s.prototype.getConnectionPos=function(a,b,d){d=d||new Float32Array(2);var f=0;a&&this.inputs&&(f=this.inputs.length);!a&&this.outputs&&(f=this.outputs.length);var g=0.5*e.NODE_SLOT_HEIGHT;if(this.flags.collapsed)return b=this._collapsed_width||e.NODE_COLLAPSED_WIDTH,this.horizontal?(d[0]=this.pos[0]+0.5*b,d[1]=a?this.pos[1]-
|
||||
e.NODE_TITLE_HEIGHT:this.pos[1]):(d[0]=a?this.pos[0]:this.pos[0]+b,d[1]=this.pos[1]-0.5*e.NODE_TITLE_HEIGHT),d;if(a&&-1==b)return d[0]=this.pos[0]+0.5*e.NODE_TITLE_HEIGHT,d[1]=this.pos[1]+0.5*e.NODE_TITLE_HEIGHT,d;if(a&&f>b&&this.inputs[b].pos)return d[0]=this.pos[0]+this.inputs[b].pos[0],d[1]=this.pos[1]+this.inputs[b].pos[1],d;if(!a&&f>b&&this.outputs[b].pos)return d[0]=this.pos[0]+this.outputs[b].pos[0],d[1]=this.pos[1]+this.outputs[b].pos[1],d;if(this.horizontal)return d[0]=this.pos[0]+this.size[0]/
|
||||
f*(b+0.5),d[1]=a?this.pos[1]-e.NODE_TITLE_HEIGHT:this.pos[1]+this.size[1],d;d[0]=a?this.pos[0]+g:this.pos[0]+this.size[0]+1-g;d[1]=this.pos[1]+(b+0.7)*e.NODE_SLOT_HEIGHT+(this.constructor.slot_start_y||0);return d};s.prototype.alignToGrid=function(){this.pos[0]=e.CANVAS_GRID_SIZE*Math.round(this.pos[0]/e.CANVAS_GRID_SIZE);this.pos[1]=e.CANVAS_GRID_SIZE*Math.round(this.pos[1]/e.CANVAS_GRID_SIZE)};s.prototype.trace=function(a){this.console||(this.console=[]);this.console.push(a);this.console.length>
|
||||
s.MAX_CONSOLE&&this.console.shift();if(this.graph.onNodeTrace)this.graph.onNodeTrace(this,a)};s.prototype.setDirtyCanvas=function(a,b){this.graph&&this.graph.sendActionToCanvas("setDirty",[a,b])};s.prototype.loadImage=function(a){var b=new Image;b.src=e.node_images_path+a;b.ready=!1;var d=this;b.onload=function(){this.ready=!0;d.setDirtyCanvas(!0)};return b};s.prototype.captureInput=function(a){if(this.graph&&this.graph.list_of_graphcanvas)for(var b=this.graph.list_of_graphcanvas,d=0;d<b.length;++d){var f=
|
||||
b[d];if(a||f.node_capturing_input==this)f.node_capturing_input=a?this:null}};s.prototype.collapse=function(a){this.graph._version++;if(!1!==this.constructor.collapsable||a)this.flags.collapsed=this.flags.collapsed?!1:!0,this.setDirtyCanvas(!0,!0)};s.prototype.pin=function(a){this.graph._version++;this.flags.pinned=void 0===a?!this.flags.pinned:a};s.prototype.localToScreen=function(a,b,d){return[(a+this.pos[0])*d.scale+d.offset[0],(b+this.pos[1])*d.scale+d.offset[1]]};A.LGraphGroup=e.LGraphGroup=l;
|
||||
l.prototype._ctor=function(a){this.title=a||"Group";this.font_size=24;this.color=h.node_colors.pale_blue?h.node_colors.pale_blue.groupcolor:"#AAA";this._bounding=new Float32Array([10,10,140,80]);this._pos=this._bounding.subarray(0,2);this._size=this._bounding.subarray(2,4);this._nodes=[];this.graph=null;Object.defineProperty(this,"pos",{set:function(a){!a||2>a.length||(this._pos[0]=a[0],this._pos[1]=a[1])},get:function(){return this._pos},enumerable:!0});Object.defineProperty(this,"size",{set:function(a){!a||
|
||||
2>a.length||(this._size[0]=Math.max(140,a[0]),this._size[1]=Math.max(80,a[1]))},get:function(){return this._size},enumerable:!0})};l.prototype.configure=function(a){this.title=a.title;this._bounding.set(a.bounding);this.color=a.color;this.font=a.font};l.prototype.serialize=function(){var a=this._bounding;return{title:this.title,bounding:[Math.round(a[0]),Math.round(a[1]),Math.round(a[2]),Math.round(a[3])],color:this.color,font:this.font}};l.prototype.move=function(a,b,d){this._pos[0]+=a;this._pos[1]+=
|
||||
b;if(!d)for(d=0;d<this._nodes.length;++d){var f=this._nodes[d];f.pos[0]+=a;f.pos[1]+=b}};l.prototype.recomputeInsideNodes=function(){this._nodes.length=0;for(var a=this.graph._nodes,b=new Float32Array(4),d=0;d<a.length;++d){var f=a[d];f.getBounding(b);E(this._bounding,b)&&this._nodes.push(f)}};l.prototype.isPointInside=s.prototype.isPointInside;l.prototype.setDirtyCanvas=s.prototype.setDirtyCanvas;e.DragAndScale=w;w.prototype.bindEvents=function(a){this.last_mouse=new Float32Array(2);this._binded_mouse_callback=
|
||||
this.onMouse.bind(this);a.addEventListener("mousedown",this._binded_mouse_callback);a.addEventListener("mousemove",this._binded_mouse_callback);a.addEventListener("mousewheel",this._binded_mouse_callback,!1);a.addEventListener("wheel",this._binded_mouse_callback,!1)};w.prototype.computeVisibleArea=function(){if(this.element){var a=-this.offset[0],b=-this.offset[1],d=a+this.element.width/this.scale,f=b+this.element.height/this.scale;this.visible_area[0]=a;this.visible_area[1]=b;this.visible_area[2]=
|
||||
d-a;this.visible_area[3]=f-b}else this.visible_area[0]=this.visible_area[1]=this.visible_area[2]=this.visible_area[3]=0};w.prototype.onMouse=function(a){if(this.enabled){var b=this.element,d=b.getBoundingClientRect(),f=a.clientX-d.left,d=a.clientY-d.top;a.canvasx=f;a.canvasy=d;a.dragging=this.dragging;var g=!1;this.onmouse&&(g=this.onmouse(a));if("mousedown"==a.type)this.dragging=!0,b.removeEventListener("mousemove",this._binded_mouse_callback),document.body.addEventListener("mousemove",this._binded_mouse_callback),
|
||||
document.body.addEventListener("mouseup",this._binded_mouse_callback);else if("mousemove"==a.type)g||(b=f-this.last_mouse[0],g=d-this.last_mouse[1],this.dragging&&this.mouseDrag(b,g));else if("mouseup"==a.type)this.dragging=!1,document.body.removeEventListener("mousemove",this._binded_mouse_callback),document.body.removeEventListener("mouseup",this._binded_mouse_callback),b.addEventListener("mousemove",this._binded_mouse_callback);else if("mousewheel"==a.type||"wheel"==a.type||"DOMMouseScroll"==a.type)a.eventType=
|
||||
"mousewheel",a.wheel="wheel"==a.type?-a.deltaY:null!=a.wheelDeltaY?a.wheelDeltaY:-60*a.detail,a.delta=a.wheelDelta?a.wheelDelta/40:a.deltaY?-a.deltaY/3:0,this.changeDeltaScale(1+0.05*a.delta);this.last_mouse[0]=f;this.last_mouse[1]=d;a.preventDefault();a.stopPropagation();return!1}};w.prototype.toCanvasContext=function(a){a.scale(this.scale,this.scale);a.translate(this.offset[0],this.offset[1])};w.prototype.convertOffsetToCanvas=function(a){return[(a[0]+this.offset[0])*this.scale,(a[1]+this.offset[1])*
|
||||
this.scale]};w.prototype.convertCanvasToOffset=function(a,b){b=b||[0,0];b[0]=a[0]/this.scale-this.offset[0];b[1]=a[1]/this.scale-this.offset[1];return b};w.prototype.mouseDrag=function(a,b){this.offset[0]+=a/this.scale;this.offset[1]+=b/this.scale;if(this.onredraw)this.onredraw(this)};w.prototype.changeScale=function(a,b){a<this.min_scale?a=this.min_scale:a>this.max_scale&&(a=this.max_scale);if(a!=this.scale&&this.element){var d=this.element.getBoundingClientRect();if(d){b=b||[0.5*d.width,0.5*d.height];
|
||||
d=this.convertCanvasToOffset(b);this.scale=a;0.01>Math.abs(this.scale-1)&&(this.scale=1);var f=this.convertCanvasToOffset(b),d=[f[0]-d[0],f[1]-d[1]];this.offset[0]+=d[0];this.offset[1]+=d[1];if(this.onredraw)this.onredraw(this)}}};w.prototype.changeDeltaScale=function(a,b){this.changeScale(this.scale*a,b)};w.prototype.reset=function(){this.scale=1;this.offset[0]=0;this.offset[1]=0};A.LGraphCanvas=e.LGraphCanvas=h;h.DEFAULT_BACKGROUND_IMAGE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQBJREFUeNrs1rEKwjAUhlETUkj3vP9rdmr1Ysammk2w5wdxuLgcMHyptfawuZX4pJSWZTnfnu/lnIe/jNNxHHGNn//HNbbv+4dr6V+11uF527arU7+u63qfa/bnmh8sWLBgwYJlqRf8MEptXPBXJXa37BSl3ixYsGDBMliwFLyCV/DeLIMFCxYsWLBMwSt4Be/NggXLYMGCBUvBK3iNruC9WbBgwYJlsGApeAWv4L1ZBgsWLFiwYJmCV/AK3psFC5bBggULloJX8BpdwXuzYMGCBctgwVLwCl7Be7MMFixYsGDBsu8FH1FaSmExVfAxBa/gvVmwYMGCZbBg/W4vAQYA5tRF9QYlv/QAAAAASUVORK5CYII=";
|
||||
!f||f.type!==e.EVENT||a&&f.name!=a||this.triggerSlot(d,b)}}};s.prototype.triggerSlot=function(a,b,d){if(this.outputs&&(a=this.outputs[a])&&(a=a.links)&&a.length){this.graph&&(this.graph._last_trigger_time=e.getTime());for(var f=0;f<a.length;++f){var g=a[f];if(null==d||d==g){var t=this.graph.links[a[f]];if(t&&(t._last_time=e.getTime(),g=this.graph.getNodeById(t.target_id)))if(t=g.inputs[t.target_slot],g.mode===e.ON_TRIGGER){if(g.onExecute)g.onExecute(b)}else if(g.onAction)g.onAction(t.name,b)}}}};
|
||||
s.prototype.clearTriggeredSlot=function(a,b){if(this.outputs){var d=this.outputs[a];if(d&&(d=d.links)&&d.length)for(var f=0;f<d.length;++f){var g=d[f];if(null==b||b==g)if(g=this.graph.links[d[f]])g._last_time=0}}};s.prototype.setSize=function(a){this.size=a;if(this.onResize)this.onResize(this.size)};s.prototype.addProperty=function(a,b,d,f){d={name:a,type:d,default_value:b};if(f)for(var g in f)d[g]=f[g];this.properties_info||(this.properties_info=[]);this.properties_info.push(d);this.properties||
|
||||
(this.properties={});this.properties[a]=b;return d};s.prototype.addOutput=function(a,b,d){a={name:a,type:b,links:null};if(d)for(var f in d)a[f]=d[f];this.outputs||(this.outputs=[]);this.outputs.push(a);if(this.onOutputAdded)this.onOutputAdded(a);this.setSize(this.computeSize());this.setDirtyCanvas(!0,!0);return a};s.prototype.addOutputs=function(a){for(var b=0;b<a.length;++b){var d=a[b],f={name:d[0],type:d[1],link:null};if(a[2])for(var g in d[2])f[g]=d[2][g];this.outputs||(this.outputs=[]);this.outputs.push(f);
|
||||
if(this.onOutputAdded)this.onOutputAdded(f)}this.setSize(this.computeSize());this.setDirtyCanvas(!0,!0)};s.prototype.removeOutput=function(a){this.disconnectOutput(a);this.outputs.splice(a,1);for(var b=a;b<this.outputs.length;++b)if(this.outputs[b]&&this.outputs[b].links)for(var d=this.outputs[b].links,f=0;f<d.length;++f){var g=this.graph.links[d[f]];g&&(g.origin_slot-=1)}this.setSize(this.computeSize());if(this.onOutputRemoved)this.onOutputRemoved(a);this.setDirtyCanvas(!0,!0)};s.prototype.addInput=
|
||||
function(a,b,d){a={name:a,type:b||0,link:null};if(d)for(var f in d)a[f]=d[f];this.inputs||(this.inputs=[]);this.inputs.push(a);this.setSize(this.computeSize());if(this.onInputAdded)this.onInputAdded(a);this.setDirtyCanvas(!0,!0);return a};s.prototype.addInputs=function(a){for(var b=0;b<a.length;++b){var d=a[b],f={name:d[0],type:d[1],link:null};if(a[2])for(var g in d[2])f[g]=d[2][g];this.inputs||(this.inputs=[]);this.inputs.push(f);if(this.onInputAdded)this.onInputAdded(f)}this.setSize(this.computeSize());
|
||||
this.setDirtyCanvas(!0,!0)};s.prototype.removeInput=function(a){this.disconnectInput(a);for(var b=this.inputs.splice(a,1),d=a;d<this.inputs.length;++d)if(this.inputs[d]){var f=this.graph.links[this.inputs[d].link];f&&(f.target_slot-=1)}this.setSize(this.computeSize());if(this.onInputRemoved)this.onInputRemoved(a,b[0]);this.setDirtyCanvas(!0,!0)};s.prototype.addConnection=function(a,b,d,f){a={name:a,type:b,pos:d,direction:f,links:null};this.connections.push(a);return a};s.prototype.computeSize=function(a){function b(a){return a?
|
||||
f*a.length*0.6:0}if(this.constructor.size)return this.constructor.size.concat();var d=Math.max(this.inputs?this.inputs.length:1,this.outputs?this.outputs.length:1);a=a||new Float32Array([0,0]);var d=Math.max(d,1),f=e.NODE_TEXT_SIZE,g=b(this.title),t=0,x=0;if(this.inputs)for(var c=0,k=this.inputs.length;c<k;++c){var h=this.inputs[c],h=h.label||h.name||"",h=b(h);t<h&&(t=h)}if(this.outputs)for(c=0,k=this.outputs.length;c<k;++c)h=this.outputs[c],h=h.label||h.name||"",h=b(h),x<h&&(x=h);a[0]=Math.max(t+
|
||||
x+10,g);a[0]=Math.max(a[0],e.NODE_WIDTH);this.widgets&&this.widgets.length&&(a[0]=Math.max(a[0],1.5*e.NODE_WIDTH));a[1]=(this.constructor.slot_start_y||0)+d*e.NODE_SLOT_HEIGHT;d=0;if(this.widgets&&this.widgets.length){c=0;for(k=this.widgets.length;c<k;++c)d=this.widgets[c].computeSize?d+(this.widgets[c].computeSize(a[0])[1]+4):d+(e.NODE_WIDGET_HEIGHT+4);d+=8}a[1]=this.widgets_up?Math.max(a[1],d):null!=this.widgets_start_y?Math.max(a[1],d+this.widgets_start_y):a[1]+d;this.constructor.min_height&&a[1]<
|
||||
this.constructor.min_height&&(a[1]=this.constructor.min_height);a[1]+=6;return a};s.prototype.getPropertyInfo=function(a){var b=null;if(this.properties_info)for(var d=0;d<this.properties_info.length;++d)if(this.properties_info[d].name==a){b=this.properties_info[d];break}this.constructor["@"+a]&&(b=this.constructor["@"+a]);this.constructor.widgets_info&&this.constructor.widgets_info[a]&&(b=this.constructor.widgets_info[a]);!b&&this.onGetPropertyInfo&&(b=this.onGetPropertyInfo(a));b||(b={});b.type||
|
||||
(b.type=typeof this.properties[a]);"combo"==b.widget&&(b.type="enum");return b};s.prototype.addWidget=function(a,b,d,f,g){this.widgets||(this.widgets=[]);!g&&f&&f.constructor===Object&&(g=f,f=null);g&&g.constructor===String&&(g={property:g});f&&f.constructor===String&&(g||(g={}),g.property=f,f=null);f&&f.constructor!==Function&&(console.warn("addWidget: callback must be a function"),f=null);b={type:a.toLowerCase(),name:b,value:d,callback:f,options:g||{}};void 0!==b.options.y&&(b.y=b.options.y);f||
|
||||
b.options.callback||b.options.property||console.warn("LiteGraph addWidget(...) without a callback or property assigned");if("combo"==a&&!b.options.values)throw"LiteGraph addWidget('combo',...) requires to pass values in options: { values:['red','blue'] }";this.widgets.push(b);this.setSize(this.computeSize());return b};s.prototype.addCustomWidget=function(a){this.widgets||(this.widgets=[]);this.widgets.push(a);return a};s.prototype.getBounding=function(a){a=a||new Float32Array(4);a[0]=this.pos[0]-
|
||||
4;a[1]=this.pos[1]-e.NODE_TITLE_HEIGHT;a[2]=this.size[0]+4;a[3]=this.size[1]+e.NODE_TITLE_HEIGHT;if(this.onBounding)this.onBounding(a);return a};s.prototype.isPointInside=function(a,b,d,f){d=d||0;var g=this.graph&&this.graph.isLive()?0:e.NODE_TITLE_HEIGHT;f&&(g=0);if(this.flags&&this.flags.collapsed){if(v(a,b,this.pos[0]-d,this.pos[1]-e.NODE_TITLE_HEIGHT-d,(this._collapsed_width||e.NODE_COLLAPSED_WIDTH)+2*d,e.NODE_TITLE_HEIGHT+2*d))return!0}else if(this.pos[0]-4-d<a&&this.pos[0]+this.size[0]+4+d>
|
||||
a&&this.pos[1]-g-d<b&&this.pos[1]+this.size[1]+d>b)return!0;return!1};s.prototype.getSlotInPosition=function(a,b){var d=new Float32Array(2);if(this.inputs)for(var f=0,g=this.inputs.length;f<g;++f){var t=this.inputs[f];this.getConnectionPos(!0,f,d);if(v(a,b,d[0]-10,d[1]-5,20,10))return{input:t,slot:f,link_pos:d}}if(this.outputs)for(f=0,g=this.outputs.length;f<g;++f)if(t=this.outputs[f],this.getConnectionPos(!1,f,d),v(a,b,d[0]-10,d[1]-5,20,10))return{output:t,slot:f,link_pos:d};return null};s.prototype.findInputSlot=
|
||||
function(a){if(!this.inputs)return-1;for(var b=0,d=this.inputs.length;b<d;++b)if(a==this.inputs[b].name)return b;return-1};s.prototype.findOutputSlot=function(a){if(!this.outputs)return-1;for(var b=0,d=this.outputs.length;b<d;++b)if(a==this.outputs[b].name)return b;return-1};s.prototype.connect=function(a,b,d){d=d||0;if(!this.graph)return console.log("Connect: Error, node doesn't belong to any graph. Nodes must be added first to a graph before connecting them."),null;if(a.constructor===String){if(a=
|
||||
this.findOutputSlot(a),-1==a)return e.debug&&console.log("Connect: Error, no slot of name "+a),null}else if(!this.outputs||a>=this.outputs.length)return e.debug&&console.log("Connect: Error, slot number not found"),null;b&&b.constructor===Number&&(b=this.graph.getNodeById(b));if(!b)throw"target node is null";if(b==this)return null;if(d.constructor===String){if(d=b.findInputSlot(d),-1==d)return e.debug&&console.log("Connect: Error, no slot of name "+d),null}else{if(d===e.EVENT)return null;if(!b.inputs||
|
||||
d>=b.inputs.length)return e.debug&&console.log("Connect: Error, slot number not found"),null}var f=!1;null!=b.inputs[d].link&&(this.graph.beforeChange(),b.disconnectInput(d),f=!0);var g=this.outputs[a];if(b.onConnectInput&&!1===b.onConnectInput(d,g.type,g,this,a))return null;var t=b.inputs[d],x=null;if(!e.isValidConnection(g.type,t.type))return this.setDirtyCanvas(!1,!0),f&&this.graph.connectionChange(this,x),null;f||this.graph.beforeChange();x=new m(++this.graph.last_link_id,t.type,this.id,a,b.id,
|
||||
d);this.graph.links[x.id]=x;null==g.links&&(g.links=[]);g.links.push(x.id);b.inputs[d].link=x.id;this.graph&&this.graph._version++;if(this.onConnectionsChange)this.onConnectionsChange(e.OUTPUT,a,!0,x,g);if(b.onConnectionsChange)b.onConnectionsChange(e.INPUT,d,!0,x,t);this.graph&&this.graph.onNodeConnectionChange&&(this.graph.onNodeConnectionChange(e.INPUT,b,d,this,a),this.graph.onNodeConnectionChange(e.OUTPUT,this,a,b,d));this.setDirtyCanvas(!1,!0);this.graph.afterChange();this.graph.connectionChange(this,
|
||||
x);return x};s.prototype.disconnectOutput=function(a,b){if(a.constructor===String){if(a=this.findOutputSlot(a),-1==a)return e.debug&&console.log("Connect: Error, no slot of name "+a),!1}else if(!this.outputs||a>=this.outputs.length)return e.debug&&console.log("Connect: Error, slot number not found"),!1;var d=this.outputs[a];if(!d||!d.links||0==d.links.length)return!1;if(b){b.constructor===Number&&(b=this.graph.getNodeById(b));if(!b)throw"Target Node not found";for(var f=0,g=d.links.length;f<g;f++){var t=
|
||||
d.links[f],x=this.graph.links[t];if(x.target_id==b.id){d.links.splice(f,1);var c=b.inputs[x.target_slot];c.link=null;delete this.graph.links[t];this.graph&&this.graph._version++;if(b.onConnectionsChange)b.onConnectionsChange(e.INPUT,x.target_slot,!1,x,c);if(this.onConnectionsChange)this.onConnectionsChange(e.OUTPUT,a,!1,x,d);if(this.graph&&this.graph.onNodeConnectionChange)this.graph.onNodeConnectionChange(e.OUTPUT,this,a);this.graph&&this.graph.onNodeConnectionChange&&(this.graph.onNodeConnectionChange(e.OUTPUT,
|
||||
this,a),this.graph.onNodeConnectionChange(e.INPUT,b,x.target_slot));break}}}else{f=0;for(g=d.links.length;f<g;f++)if(t=d.links[f],x=this.graph.links[t]){b=this.graph.getNodeById(x.target_id);this.graph&&this.graph._version++;if(b){c=b.inputs[x.target_slot];c.link=null;if(b.onConnectionsChange)b.onConnectionsChange(e.INPUT,x.target_slot,!1,x,c);if(this.graph&&this.graph.onNodeConnectionChange)this.graph.onNodeConnectionChange(e.INPUT,b,x.target_slot)}delete this.graph.links[t];if(this.onConnectionsChange)this.onConnectionsChange(e.OUTPUT,
|
||||
a,!1,x,d);this.graph&&this.graph.onNodeConnectionChange&&(this.graph.onNodeConnectionChange(e.OUTPUT,this,a),this.graph.onNodeConnectionChange(e.INPUT,b,x.target_slot))}d.links=null}this.setDirtyCanvas(!1,!0);this.graph.connectionChange(this);return!0};s.prototype.disconnectInput=function(a){if(a.constructor===String){if(a=this.findInputSlot(a),-1==a)return e.debug&&console.log("Connect: Error, no slot of name "+a),!1}else if(!this.inputs||a>=this.inputs.length)return e.debug&&console.log("Connect: Error, slot number not found"),
|
||||
!1;var b=this.inputs[a];if(!b)return!1;var d=this.inputs[a].link;if(null!=d){this.inputs[a].link=null;var f=this.graph.links[d];if(f){var g=this.graph.getNodeById(f.origin_id);if(!g)return!1;var t=g.outputs[f.origin_slot];if(!t||!t.links||0==t.links.length)return!1;for(var x=0,c=t.links.length;x<c;x++)if(t.links[x]==d){t.links.splice(x,1);break}delete this.graph.links[d];this.graph&&this.graph._version++;if(this.onConnectionsChange)this.onConnectionsChange(e.INPUT,a,!1,f,b);if(g.onConnectionsChange)g.onConnectionsChange(e.OUTPUT,
|
||||
x,!1,f,t);this.graph&&this.graph.onNodeConnectionChange&&(this.graph.onNodeConnectionChange(e.OUTPUT,g,x),this.graph.onNodeConnectionChange(e.INPUT,this,a))}}this.setDirtyCanvas(!1,!0);this.graph&&this.graph.connectionChange(this);return!0};s.prototype.getConnectionPos=function(a,b,d){d=d||new Float32Array(2);var f=0;a&&this.inputs&&(f=this.inputs.length);!a&&this.outputs&&(f=this.outputs.length);var g=0.5*e.NODE_SLOT_HEIGHT;if(this.flags.collapsed)return b=this._collapsed_width||e.NODE_COLLAPSED_WIDTH,
|
||||
this.horizontal?(d[0]=this.pos[0]+0.5*b,d[1]=a?this.pos[1]-e.NODE_TITLE_HEIGHT:this.pos[1]):(d[0]=a?this.pos[0]:this.pos[0]+b,d[1]=this.pos[1]-0.5*e.NODE_TITLE_HEIGHT),d;if(a&&-1==b)return d[0]=this.pos[0]+0.5*e.NODE_TITLE_HEIGHT,d[1]=this.pos[1]+0.5*e.NODE_TITLE_HEIGHT,d;if(a&&f>b&&this.inputs[b].pos)return d[0]=this.pos[0]+this.inputs[b].pos[0],d[1]=this.pos[1]+this.inputs[b].pos[1],d;if(!a&&f>b&&this.outputs[b].pos)return d[0]=this.pos[0]+this.outputs[b].pos[0],d[1]=this.pos[1]+this.outputs[b].pos[1],
|
||||
d;if(this.horizontal)return d[0]=this.pos[0]+this.size[0]/f*(b+0.5),d[1]=a?this.pos[1]-e.NODE_TITLE_HEIGHT:this.pos[1]+this.size[1],d;d[0]=a?this.pos[0]+g:this.pos[0]+this.size[0]+1-g;d[1]=this.pos[1]+(b+0.7)*e.NODE_SLOT_HEIGHT+(this.constructor.slot_start_y||0);return d};s.prototype.alignToGrid=function(){this.pos[0]=e.CANVAS_GRID_SIZE*Math.round(this.pos[0]/e.CANVAS_GRID_SIZE);this.pos[1]=e.CANVAS_GRID_SIZE*Math.round(this.pos[1]/e.CANVAS_GRID_SIZE)};s.prototype.trace=function(a){this.console||
|
||||
(this.console=[]);this.console.push(a);this.console.length>s.MAX_CONSOLE&&this.console.shift();if(this.graph.onNodeTrace)this.graph.onNodeTrace(this,a)};s.prototype.setDirtyCanvas=function(a,b){this.graph&&this.graph.sendActionToCanvas("setDirty",[a,b])};s.prototype.loadImage=function(a){var b=new Image;b.src=e.node_images_path+a;b.ready=!1;var d=this;b.onload=function(){this.ready=!0;d.setDirtyCanvas(!0)};return b};s.prototype.captureInput=function(a){if(this.graph&&this.graph.list_of_graphcanvas)for(var b=
|
||||
this.graph.list_of_graphcanvas,d=0;d<b.length;++d){var f=b[d];if(a||f.node_capturing_input==this)f.node_capturing_input=a?this:null}};s.prototype.collapse=function(a){this.graph._version++;if(!1!==this.constructor.collapsable||a)this.flags.collapsed=this.flags.collapsed?!1:!0,this.setDirtyCanvas(!0,!0)};s.prototype.pin=function(a){this.graph._version++;this.flags.pinned=void 0===a?!this.flags.pinned:a};s.prototype.localToScreen=function(a,b,d){return[(a+this.pos[0])*d.scale+d.offset[0],(b+this.pos[1])*
|
||||
d.scale+d.offset[1]]};A.LGraphGroup=e.LGraphGroup=l;l.prototype._ctor=function(a){this.title=a||"Group";this.font_size=24;this.color=h.node_colors.pale_blue?h.node_colors.pale_blue.groupcolor:"#AAA";this._bounding=new Float32Array([10,10,140,80]);this._pos=this._bounding.subarray(0,2);this._size=this._bounding.subarray(2,4);this._nodes=[];this.graph=null;Object.defineProperty(this,"pos",{set:function(a){!a||2>a.length||(this._pos[0]=a[0],this._pos[1]=a[1])},get:function(){return this._pos},enumerable:!0});
|
||||
Object.defineProperty(this,"size",{set:function(a){!a||2>a.length||(this._size[0]=Math.max(140,a[0]),this._size[1]=Math.max(80,a[1]))},get:function(){return this._size},enumerable:!0})};l.prototype.configure=function(a){this.title=a.title;this._bounding.set(a.bounding);this.color=a.color;this.font=a.font};l.prototype.serialize=function(){var a=this._bounding;return{title:this.title,bounding:[Math.round(a[0]),Math.round(a[1]),Math.round(a[2]),Math.round(a[3])],color:this.color,font:this.font}};l.prototype.move=
|
||||
function(a,b,d){this._pos[0]+=a;this._pos[1]+=b;if(!d)for(d=0;d<this._nodes.length;++d){var f=this._nodes[d];f.pos[0]+=a;f.pos[1]+=b}};l.prototype.recomputeInsideNodes=function(){this._nodes.length=0;for(var a=this.graph._nodes,b=new Float32Array(4),d=0;d<a.length;++d){var f=a[d];f.getBounding(b);E(this._bounding,b)&&this._nodes.push(f)}};l.prototype.isPointInside=s.prototype.isPointInside;l.prototype.setDirtyCanvas=s.prototype.setDirtyCanvas;e.DragAndScale=w;w.prototype.bindEvents=function(a){this.last_mouse=
|
||||
new Float32Array(2);this._binded_mouse_callback=this.onMouse.bind(this);a.addEventListener("mousedown",this._binded_mouse_callback);a.addEventListener("mousemove",this._binded_mouse_callback);a.addEventListener("mousewheel",this._binded_mouse_callback,!1);a.addEventListener("wheel",this._binded_mouse_callback,!1)};w.prototype.computeVisibleArea=function(){if(this.element){var a=-this.offset[0],b=-this.offset[1],d=a+this.element.width/this.scale,f=b+this.element.height/this.scale;this.visible_area[0]=
|
||||
a;this.visible_area[1]=b;this.visible_area[2]=d-a;this.visible_area[3]=f-b}else this.visible_area[0]=this.visible_area[1]=this.visible_area[2]=this.visible_area[3]=0};w.prototype.onMouse=function(a){if(this.enabled){var b=this.element,d=b.getBoundingClientRect(),f=a.clientX-d.left,d=a.clientY-d.top;a.canvasx=f;a.canvasy=d;a.dragging=this.dragging;var g=!1;this.onmouse&&(g=this.onmouse(a));if("mousedown"==a.type)this.dragging=!0,b.removeEventListener("mousemove",this._binded_mouse_callback),document.body.addEventListener("mousemove",
|
||||
this._binded_mouse_callback),document.body.addEventListener("mouseup",this._binded_mouse_callback);else if("mousemove"==a.type)g||(b=f-this.last_mouse[0],g=d-this.last_mouse[1],this.dragging&&this.mouseDrag(b,g));else if("mouseup"==a.type)this.dragging=!1,document.body.removeEventListener("mousemove",this._binded_mouse_callback),document.body.removeEventListener("mouseup",this._binded_mouse_callback),b.addEventListener("mousemove",this._binded_mouse_callback);else if("mousewheel"==a.type||"wheel"==
|
||||
a.type||"DOMMouseScroll"==a.type)a.eventType="mousewheel",a.wheel="wheel"==a.type?-a.deltaY:null!=a.wheelDeltaY?a.wheelDeltaY:-60*a.detail,a.delta=a.wheelDelta?a.wheelDelta/40:a.deltaY?-a.deltaY/3:0,this.changeDeltaScale(1+0.05*a.delta);this.last_mouse[0]=f;this.last_mouse[1]=d;a.preventDefault();a.stopPropagation();return!1}};w.prototype.toCanvasContext=function(a){a.scale(this.scale,this.scale);a.translate(this.offset[0],this.offset[1])};w.prototype.convertOffsetToCanvas=function(a){return[(a[0]+
|
||||
this.offset[0])*this.scale,(a[1]+this.offset[1])*this.scale]};w.prototype.convertCanvasToOffset=function(a,b){b=b||[0,0];b[0]=a[0]/this.scale-this.offset[0];b[1]=a[1]/this.scale-this.offset[1];return b};w.prototype.mouseDrag=function(a,b){this.offset[0]+=a/this.scale;this.offset[1]+=b/this.scale;if(this.onredraw)this.onredraw(this)};w.prototype.changeScale=function(a,b){a<this.min_scale?a=this.min_scale:a>this.max_scale&&(a=this.max_scale);if(a!=this.scale&&this.element){var d=this.element.getBoundingClientRect();
|
||||
if(d){b=b||[0.5*d.width,0.5*d.height];d=this.convertCanvasToOffset(b);this.scale=a;0.01>Math.abs(this.scale-1)&&(this.scale=1);var f=this.convertCanvasToOffset(b),d=[f[0]-d[0],f[1]-d[1]];this.offset[0]+=d[0];this.offset[1]+=d[1];if(this.onredraw)this.onredraw(this)}}};w.prototype.changeDeltaScale=function(a,b){this.changeScale(this.scale*a,b)};w.prototype.reset=function(){this.scale=1;this.offset[0]=0;this.offset[1]=0};A.LGraphCanvas=e.LGraphCanvas=h;h.DEFAULT_BACKGROUND_IMAGE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQBJREFUeNrs1rEKwjAUhlETUkj3vP9rdmr1Ysammk2w5wdxuLgcMHyptfawuZX4pJSWZTnfnu/lnIe/jNNxHHGNn//HNbbv+4dr6V+11uF527arU7+u63qfa/bnmh8sWLBgwYJlqRf8MEptXPBXJXa37BSl3ixYsGDBMliwFLyCV/DeLIMFCxYsWLBMwSt4Be/NggXLYMGCBUvBK3iNruC9WbBgwYJlsGApeAWv4L1ZBgsWLFiwYJmCV/AK3psFC5bBggULloJX8BpdwXuzYMGCBctgwVLwCl7Be7MMFixYsGDBsu8FH1FaSmExVfAxBa/gvVmwYMGCZbBg/W4vAQYA5tRF9QYlv/QAAAAASUVORK5CYII=";
|
||||
h.link_type_colors={"-1":e.EVENT_LINK_COLOR,number:"#AAA",node:"#DCA"};h.gradients={};h.prototype.clear=function(){this.fps=this.render_time=this.last_draw_time=this.frame=0;this.dragging_rectangle=null;this.selected_nodes={};this.selected_group=null;this.visible_nodes=[];this.connecting_node=this.node_capturing_input=this.node_over=this.node_dragged=null;this.highlighted_links={};this.dragging_canvas=!1;this.dirty_bgcanvas=this.dirty_canvas=!0;this.node_widget=this.node_in_panel=this.dirty_area=
|
||||
null;this.last_mouse=[0,0];this.last_mouseclick=0;this.visible_area.set([0,0,0,0]);if(this.onClear)this.onClear()};h.prototype.setGraph=function(a,b){this.graph!=a&&(b||this.clear(),!a&&this.graph?this.graph.detachCanvas(this):(a.attachCanvas(this),this._graph_stack&&(this._graph_stack=null),this.setDirty(!0,!0)))};h.prototype.getTopGraph=function(){return this._graph_stack.length?this._graph_stack[0]:this.graph};h.prototype.openSubgraph=function(a){if(!a)throw"graph cannot be null";if(this.graph==
|
||||
a)throw"graph cannot be the same";this.clear();this.graph&&(this._graph_stack||(this._graph_stack=[]),this._graph_stack.push(this.graph));a.attachCanvas(this);this.checkPanels();this.setDirty(!0,!0)};h.prototype.closeSubgraph=function(){if(this._graph_stack&&0!=this._graph_stack.length){var a=this.graph._subgraph_node,b=this._graph_stack.pop();this.selected_nodes={};this.highlighted_links={};b.attachCanvas(this);this.setDirty(!0,!0);a&&(this.centerOnNode(a),this.selectNodes([a]))}};h.prototype.getCurrentGraph=
|
||||
@@ -461,7 +461,7 @@ k.pixel_shader))}function a(){this.addInput("R","Texture");this.addInput("G","Te
|
||||
"color");this.addInput("B","color");this.addOutput("Texture","Texture");this.properties={angle:0,scale:1,A:[0,0,0],B:[1,1,1],texture_size:32};d._shader||(d._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,d.pixel_shader));this._uniforms={u_angle:0,u_colorA:vec3.create(),u_colorB:vec3.create()}}function f(){this.addInput("A","Texture");this.addInput("B","Texture");this.addInput("Mixer","Texture");this.addOutput("Texture","Texture");this.properties={factor:0.5,size_from_biggest:!0,invert:!1,precision:c.DEFAULT};
|
||||
this._uniforms={u_textureA:0,u_textureB:1,u_textureMix:2,u_mix:vec4.create()}}function g(){this.addInput("Tex.","Texture");this.addOutput("Edges","Texture");this.properties={invert:!0,threshold:!1,factor:1,precision:c.DEFAULT};g._shader||(g._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,g.pixel_shader))}function t(){this.addInput("Texture","Texture");this.addInput("Distance","number");this.addInput("Range","number");this.addOutput("Texture","Texture");this.properties={distance:100,range:50,only_depth:!1,
|
||||
high_precision:!1};this._uniforms={u_texture:0,u_distance:100,u_range:50,u_camera_planes:null}}function x(){this.addInput("Texture","Texture");this.addOutput("Texture","Texture");this.properties={precision:c.DEFAULT,invert:!1};this._uniforms={u_texture:0,u_camera_planes:null,u_ires:vec2.create()}}function M(){this.addInput("Texture","Texture");this.addInput("Iterations","number");this.addInput("Intensity","number");this.addOutput("Blurred","Texture");this.properties={intensity:1,iterations:1,preserve_aspect:!1,
|
||||
scale:[1,1],precision:c.DEFAULT}}function K(){this.intensity=1;this.persistence=0.99;this.iterations=16;this.threshold=0;this.scale=1;this.dirt_texture=null;this.dirt_factor=0.5;this._textures=[];this._uniforms={u_intensity:1,u_texture:0,u_glow_texture:1,u_threshold:0,u_texel_size:vec2.create()}}function N(){this.addInput("in","Texture");this.addInput("dirt","Texture");this.addOutput("out","Texture");this.addOutput("glow","Texture");this.properties={enabled:!0,intensity:1,persistence:0.99,iterations:16,
|
||||
scale:[1,1],precision:c.DEFAULT}}function K(){this.intensity=0.5;this.persistence=0.6;this.iterations=8;this.threshold=0.8;this.scale=1;this.dirt_texture=null;this.dirt_factor=0.5;this._textures=[];this._uniforms={u_intensity:1,u_texture:0,u_glow_texture:1,u_threshold:0,u_texel_size:vec2.create()}}function N(){this.addInput("in","Texture");this.addInput("dirt","Texture");this.addOutput("out","Texture");this.addOutput("glow","Texture");this.properties={enabled:!0,intensity:1,persistence:0.99,iterations:16,
|
||||
threshold:0,scale:1,dirt_factor:0.5,precision:c.DEFAULT};this.fx=new K}function L(){this.addInput("Texture","Texture");this.addOutput("Filtered","Texture");this.properties={intensity:1,radius:5}}function y(){this.addInput("Texture","Texture");this.addOutput("Filtered","Texture");this.properties={sigma:1.4,k:1.6,p:21.7,epsilon:79,phi:0.017}}function G(){this.addOutput("Webcam","Texture");this.properties={texture_name:"",facingMode:"user"};this.boxcolor="black";this.version=0}function O(){this.addInput("in",
|
||||
"Texture");this.addInput("f","number");this.addOutput("out","Texture");this.properties={enabled:!0,factor:1,precision:c.LOW};this._uniforms={u_texture:0,u_factor:1}}function H(){this.addInput("in","");this.properties={precision:c.LOW,width:0,height:0,channels:1};this.addOutput("out","Texture")}function F(){this.addInput("in","Texture");this.addOutput("out","Texture");this.properties={precision:c.LOW,split_channels:!1};this._values=new Uint8Array(1024);this._values.fill(255);this._curve_texture=null;
|
||||
this._uniforms={u_texture:0,u_curve:1,u_range:1};this._must_update=!0;this._points={RGB:[[0,0],[1,1]],R:[[0,0],[1,1]],G:[[0,0],[1,1]],B:[[0,0],[1,1]]};this.curve_editor=null;this.addWidget("toggle","Split Channels",!1,"split_channels");this.addWidget("combo","Channel","RGB",{values:["RGB","R","G","B"]});this.curve_offset=68;this.size=[240,160]}function S(){this.addInput("in","Texture");this.addInput("exp","number");this.addOutput("out","Texture");this.properties={exposition:1,precision:c.LOW};this._uniforms=
|
||||
|
||||
@@ -2975,12 +2975,14 @@
|
||||
//used to mark events in graph
|
||||
var target_connection = node.inputs[link_info.target_slot];
|
||||
|
||||
if (node.onAction) {
|
||||
node.onAction(target_connection.name, param);
|
||||
} else if (node.mode === LiteGraph.ON_TRIGGER) {
|
||||
if (node.mode === LiteGraph.ON_TRIGGER)
|
||||
{
|
||||
if (node.onExecute) {
|
||||
node.onExecute(param);
|
||||
}
|
||||
}
|
||||
else if (node.onAction) {
|
||||
node.onAction(target_connection.name, param);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3483,10 +3483,10 @@ LGraphTextureBlur.pixel_shader = "precision highp float;\n\
|
||||
//based on https://catlikecoding.com/unity/tutorials/advanced-rendering/bloom/
|
||||
function FXGlow()
|
||||
{
|
||||
this.intensity = 1;
|
||||
this.persistence = 0.99;
|
||||
this.iterations = 16;
|
||||
this.threshold = 0;
|
||||
this.intensity = 0.5;
|
||||
this.persistence = 0.6;
|
||||
this.iterations = 8;
|
||||
this.threshold = 0.8;
|
||||
this.scale = 1;
|
||||
|
||||
this.dirt_texture = null;
|
||||
|
||||
Reference in New Issue
Block a user