diff --git a/build/litegraph.js b/build/litegraph.js index ff28c093a..36caf5406 100644 --- a/build/litegraph.js +++ b/build/litegraph.js @@ -9171,7 +9171,21 @@ LGraphNode.prototype.executeAction = function(action) var graphcanvas = LGraphCanvas.active_canvas; var canvas = graphcanvas.canvas; + var root_document = canvas.ownerDocument || document; + if( root_document.fullscreenElement ) + root_document.fullscreenElement.appendChild(dialog); + else + root_document.body.appendChild(dialog); + + //compute best position var rect = canvas.getBoundingClientRect(); + + var left = ( event ? event.clientX : (rect.left + rect.width * 0.5) ) - 80; + var top = ( event ? event.clientY : (rect.top + rect.height * 0.5) ) - 20; + dialog.style.left = left + "px"; + dialog.style.top = top + "px"; + + /* var offsetx = -20; var offsety = -20; if (rect) { @@ -9186,8 +9200,9 @@ LGraphNode.prototype.executeAction = function(action) dialog.style.left = canvas.width * 0.5 + offsetx + "px"; dialog.style.top = canvas.height * 0.5 + offsety + "px"; } - canvas.parentNode.appendChild(dialog); + */ + input.focus(); function select(name) { @@ -10177,7 +10192,8 @@ LGraphNode.prototype.executeAction = function(action) if ( options.event && options.event.constructor !== MouseEvent && - options.event.constructor !== CustomEvent + options.event.constructor !== CustomEvent && + options.event.constructor !== PointerEvent ) { console.error( "Event passed to ContextMenu is not of type MouseEvent or CustomEvent. Ignoring it." @@ -10659,7 +10675,7 @@ if (typeof exports != "undefined") { this.enabled = true; //create inner graph - this.subgraph = new LGraph(); + this.subgraph = new LiteGraph.LGraph(); this.subgraph._subgraph_node = this; this.subgraph._is_subgraph = true; diff --git a/build/litegraph.min.js b/build/litegraph.min.js index 2d99c2cb0..4a49b6bc1 100755 --- a/build/litegraph.min.js +++ b/build/litegraph.min.js @@ -1,13 +1,13 @@ -(function(w){function c(a){e.debug&&console.log("Graph created");this.list_of_graphcanvas=null;this.clear();a&&this.configure(a)}function r(a,b,d,t,n,e){this.id=a;this.type=b;this.origin_id=d;this.origin_slot=t;this.target_id=n;this.target_slot=e;this._data=null;this._pos=new Float32Array(2)}function l(a){this._ctor(a)}function f(a){this._ctor(a)}function s(a,b){this.offset=new Float32Array([0,0]);this.scale=1;this.max_scale=10;this.min_scale=0.1;this.onredraw=null;this.enabled=!0;this.last_mouse= +(function(w){function c(a){e.debug&&console.log("Graph created");this.list_of_graphcanvas=null;this.clear();a&&this.configure(a)}function s(a,b,d,t,n,e){this.id=a;this.type=b;this.origin_id=d;this.origin_slot=t;this.target_id=n;this.target_slot=e;this._data=null;this._pos=new Float32Array(2)}function l(a){this._ctor(a)}function f(a){this._ctor(a)}function r(a,b){this.offset=new Float32Array([0,0]);this.scale=1;this.max_scale=10;this.min_scale=0.1;this.onredraw=null;this.enabled=!0;this.last_mouse= [0,0];this.element=null;this.visible_area=new Float32Array(4);a&&(this.element=a,b||this.bindEvents(a))}function k(a,b,d){d=d||{};this.background_image="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQBJREFUeNrs1rEKwjAUhlETUkj3vP9rdmr1Ysammk2w5wdxuLgcMHyptfawuZX4pJSWZTnfnu/lnIe/jNNxHHGNn//HNbbv+4dr6V+11uF527arU7+u63qfa/bnmh8sWLBgwYJlqRf8MEptXPBXJXa37BSl3ixYsGDBMliwFLyCV/DeLIMFCxYsWLBMwSt4Be/NggXLYMGCBUvBK3iNruC9WbBgwYJlsGApeAWv4L1ZBgsWLFiwYJmCV/AK3psFC5bBggULloJX8BpdwXuzYMGCBctgwVLwCl7Be7MMFixYsGDBsu8FH1FaSmExVfAxBa/gvVmwYMGCZbBg/W4vAQYA5tRF9QYlv/QAAAAASUVORK5CYII="; -a&&a.constructor===String&&(a=document.querySelector(a));this.ds=new s;this.zoom_modify_alpha=!0;this.title_text_font=""+e.NODE_TEXT_SIZE+"px Arial";this.inner_text_font="normal "+e.NODE_SUBTEXT_SIZE+"px Arial";this.node_title_color=e.NODE_TITLE_COLOR;this.default_link_color=e.LINK_COLOR;this.default_connection_color={input_off:"#778",input_on:"#7F7",output_off:"#778",output_on:"#7F7"};this.highquality_render=!0;this.use_gradients=!1;this.editor_alpha=1;this.pause_rendering=!1;this.clear_background= +a&&a.constructor===String&&(a=document.querySelector(a));this.ds=new r;this.zoom_modify_alpha=!0;this.title_text_font=""+e.NODE_TEXT_SIZE+"px Arial";this.inner_text_font="normal "+e.NODE_SUBTEXT_SIZE+"px Arial";this.node_title_color=e.NODE_TITLE_COLOR;this.default_link_color=e.LINK_COLOR;this.default_connection_color={input_off:"#778",input_on:"#7F7",output_off:"#778",output_on:"#7F7"};this.highquality_render=!0;this.use_gradients=!1;this.editor_alpha=1;this.pause_rendering=!1;this.clear_background= !0;this.read_only=!1;this.render_only_selected=!0;this.live_mode=!1;this.allow_searchbox=this.allow_interaction=this.allow_dragnodes=this.allow_dragcanvas=this.show_info=!0;this.drag_mode=this.allow_reconnect_links=!1;this.filter=this.dragging_rectangle=null;this.always_render_background=!1;this.render_canvas_border=this.render_shadows=!0;this.render_connections_shadows=!1;this.render_connections_border=!0;this.render_connection_arrows=this.render_curved_connections=!1;this.render_collapsed_slots= !0;this.render_execution_order=!1;this.render_link_tooltip=this.render_title_colored=!0;this.links_render_mode=e.SPLINE_LINK;this.canvas_mouse=[0,0];this.onSelectionChange=this.onNodeMoved=this.onDrawLinkTooltip=this.onDrawOverlay=this.onDrawForeground=this.onDrawBackground=this.onMouse=this.onSearchBoxSelection=this.onSearchBox=null;this.connections_width=3;this.round_radius=8;this.over_link_center=this.node_widget=this.current_node=null;this.last_mouse_position=[0,0];this.visible_area=this.ds.visible_area; this.visible_links=[];b&&b.attachCanvas(this);this.setCanvas(a);this.clear();d.skip_render||this.startRendering();this.autoresize=d.autoresize}function y(a,b){return Math.sqrt((b[0]-a[0])*(b[0]-a[0])+(b[1]-a[1])*(b[1]-a[1]))}function u(a,b,d,t,n,e){return da&&tb?!0:!1}function v(a,b){var d=a[0]+a[2],t=a[1]+a[3],n=b[1]+b[3];return a[0]>b[0]+b[2]||a[1]>n||dh.width-g.width-10&&(e=h.width-g.width-10);c>h.height-g.height-10&&(c=h.height-g.height-10)}n.style.left=e+"px";n.style.top=c+"px";b.scale&&(n.style.transform="scale("+b.scale+")")}var e=w.LiteGraph={VERSION:0.4,CANVAS_GRID_SIZE:10,NODE_TITLE_HEIGHT:30,NODE_TITLE_TEXT_Y:20,NODE_SLOT_HEIGHT:20,NODE_WIDGET_HEIGHT:20,NODE_WIDTH:140,NODE_MIN_WIDTH:50,NODE_COLLAPSED_RADIUS:10,NODE_COLLAPSED_WIDTH:80,NODE_TITLE_COLOR:"#999",NODE_TEXT_SIZE:14,NODE_TEXT_COLOR:"#AAA",NODE_SUBTEXT_SIZE:12, NODE_DEFAULT_COLOR:"#333",NODE_DEFAULT_BGCOLOR:"#353535",NODE_DEFAULT_BOXCOLOR:"#666",NODE_DEFAULT_SHAPE:"box",DEFAULT_SHADOW_COLOR:"rgba(0,0,0,0.5)",DEFAULT_GROUP_FONT:24,WIDGET_BGCOLOR:"#222",WIDGET_OUTLINE_COLOR:"#666",WIDGET_TEXT_COLOR:"#DDD",WIDGET_SECONDARY_TEXT_COLOR:"#999",LINK_COLOR:"#9A9",EVENT_LINK_COLOR:"#A86",CONNECTING_LINK_COLOR:"#AFA",MAX_NUMBER_OF_NODES:1E3,DEFAULT_POSITION:[100,100],VALID_SHAPES:["default","box","round","card"],BOX_SHAPE:1,ROUND_SHAPE:2,CIRCLE_SHAPE:3,CARD_SHAPE:4, ARROW_SHAPE:5,INPUT:1,OUTPUT:2,EVENT:-1,ACTION:-1,ALWAYS:0,ON_EVENT:1,NEVER:2,ON_TRIGGER:3,UP:1,DOWN:2,LEFT:3,RIGHT:4,CENTER:5,STRAIGHT_LINK:0,LINEAR_LINK:1,SPLINE_LINK:2,NORMAL_TITLE:0,NO_TITLE:1,TRANSPARENT_TITLE:2,AUTOHIDE_TITLE:3,proxy:null,node_images_path:"",debug:!1,catch_exceptions:!0,throw_errors:!0,allow_scripts:!1,registered_node_types:{},node_types_by_file_extension:{},Nodes:{},searchbox_extras:{},registerNodeType:function(a,b){if(!b.prototype)throw"Cannot register a simple object, it must be a class with a prototype"; @@ -44,10 +44,10 @@ null};c.prototype.renameOutput=function(a,b){if(!this.outputs[a])return!1;if(thi b,this._version++,this.onOutputTypeChanged)this.onOutputTypeChanged(a,b)};c.prototype.removeOutput=function(a){if(!this.outputs[a])return!1;delete this.outputs[a];this._version++;if(this.onOutputRemoved)this.onOutputRemoved(a);if(this.onInputsOutputsChange)this.onInputsOutputsChange();return!0};c.prototype.triggerInput=function(a,b){for(var d=this.findNodesByTitle(a),e=0;ea.length||(this._pos[0]=a[0],this._pos[1]=a[1])},get:function(){return this._pos},enumerable:!0});this.id=-1;this.type=null;this.inputs=[];this.outputs=[];this.connections=[];this.properties={};this.properties_info=[];this.flags={}};l.prototype.configure=function(a){this.graph&&this.graph._version++;for(var b in a)if("properties"== b)for(var d in a.properties){if(this.properties[d]=a.properties[d],this.onPropertyChanged)this.onPropertyChanged(d,a.properties[d])}else null!=a[b]&&("object"==typeof a[b]?this[b]&&this[b].configure?this[b].configure(a[b]):this[b]=e.cloneObject(a[b],this[b]):this[b]=a[b]);a.title||(this.title=this.constructor.title);if(this.onConnectionsChange){if(this.inputs)for(d=0;d=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}null!=b.inputs[d].link&&b.disconnectInput(d);var c=this.outputs[a]; -if(b.onConnectInput&&!1===b.onConnectInput(d,c.type,c))return null;var n=b.inputs[d],h=null;if(e.isValidConnection(c.type,n.type)){h=new r(++this.graph.last_link_id,n.type,this.id,a,b.id,d);this.graph.links[h.id]=h;null==c.links&&(c.links=[]);c.links.push(h.id);b.inputs[d].link=h.id;this.graph&&this.graph._version++;if(this.onConnectionsChange)this.onConnectionsChange(e.OUTPUT,a,!0,h,c);if(b.onConnectionsChange)b.onConnectionsChange(e.INPUT,d,!0,h,n);this.graph&&this.graph.onNodeConnectionChange&& +if(b.onConnectInput&&!1===b.onConnectInput(d,c.type,c))return null;var n=b.inputs[d],h=null;if(e.isValidConnection(c.type,n.type)){h=new s(++this.graph.last_link_id,n.type,this.id,a,b.id,d);this.graph.links[h.id]=h;null==c.links&&(c.links=[]);c.links.push(h.id);b.inputs[d].link=h.id;this.graph&&this.graph._version++;if(this.onConnectionsChange)this.onConnectionsChange(e.OUTPUT,a,!0,h,c);if(b.onConnectionsChange)b.onConnectionsChange(e.INPUT,d,!0,h,n);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.connectionChange(this,h);return h};l.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 c=0,n=d.links.length;ca.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})};f.prototype.configure=function(a){this.title=a.title;this._bounding.set(a.bounding);this.color=a.color; this.font=a.font};f.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}};f.prototype.move=function(a,b,d){this._pos[0]+=a;this._pos[1]+=b;if(!d)for(d=0;dthis.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 e=this.convertCanvasToOffset(b),d=[e[0]-d[0],e[1]-d[1]];this.offset[0]+=d[0];this.offset[1]+=d[1];if(this.onredraw)this.onredraw(this)}}}; -s.prototype.changeDeltaScale=function(a,b){this.changeScale(this.scale*a,b)};s.prototype.reset=function(){this.scale=1;this.offset[0]=0;this.offset[1]=0};w.LGraphCanvas=e.LGraphCanvas=k;k.link_type_colors={"-1":e.EVENT_LINK_COLOR,number:"#AAA",node:"#DCA"};k.gradients={};k.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= +e;this.last_mouse[1]=d;a.preventDefault();a.stopPropagation();return!1}};r.prototype.toCanvasContext=function(a){a.scale(this.scale,this.scale);a.translate(this.offset[0],this.offset[1])};r.prototype.convertOffsetToCanvas=function(a){return[(a[0]+this.offset[0])*this.scale,(a[1]+this.offset[1])*this.scale]};r.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};r.prototype.mouseDrag=function(a,b){this.offset[0]+= +a/this.scale;this.offset[1]+=b/this.scale;if(this.onredraw)this.onredraw(this)};r.prototype.changeScale=function(a,b){athis.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 e=this.convertCanvasToOffset(b),d=[e[0]-d[0],e[1]-d[1]];this.offset[0]+=d[0];this.offset[1]+=d[1];if(this.onredraw)this.onredraw(this)}}}; +r.prototype.changeDeltaScale=function(a,b){this.changeScale(this.scale*a,b)};r.prototype.reset=function(){this.scale=1;this.offset[0]=0;this.offset[1]=0};w.LGraphCanvas=e.LGraphCanvas=k;k.link_type_colors={"-1":e.EVENT_LINK_COLOR,number:"#AAA",node:"#DCA"};k.gradients={};k.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.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()};k.prototype.setGraph=function(a,b){this.graph!=a&&(b||this.clear(),!a&&this.graph?this.graph.detachCanvas(this):(a.attachCanvas(this),this.setDirty(!0,!0)))};k.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.setDirty(!0,!0)};k.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]))}};k.prototype.getCurrentGraph= function(){return this.graph};k.prototype.setCanvas=function(a,b){if(a&&a.constructor===String&&(a=document.getElementById(a),!a))throw"Error creating LiteGraph canvas: Canvas not found";if(a!==this.canvas&&(!a&&this.canvas&&(b||this.unbindEvents()),this.canvas=a,this.ds.element=a)){a.className+=" lgraphcanvas";a.data=this;a.tabindex="1";this.bgcanvas=null;this.bgcanvas||(this.bgcanvas=document.createElement("canvas"),this.bgcanvas.width=this.canvas.width,this.bgcanvas.height=this.canvas.height); @@ -170,8 +170,8 @@ m[0],-6+m[1],12+m[2],12+m[3]):q==e.ROUND_SHAPE||q==e.CARD_SHAPE&&a.flags.collaps e.getTime(),d=this.visible_area;C[0]=d[0]-20;C[1]=d[1]-20;C[2]=d[2]+40;C[3]=d[3]+40;a.lineWidth=this.connections_width;a.fillStyle="#AAA";a.strokeStyle="#AAA";a.globalAlpha=this.editor_alpha;for(var d=this.graph._nodes,c=0,n=d.length;ch[2]&&(h[0]+=h[2],h[2]=Math.abs(h[2]));0>h[3]&&(h[1]+=h[3],h[3]=Math.abs(h[3]));if(v(h,C)){var A=f.outputs[l],l=g.inputs[m];if(A&&l&&(f=A.dir||(f.horizontal?e.DOWN:e.RIGHT),l=l.dir||(g.horizontal?e.UP:e.LEFT),this.renderLink(a,u,x,k,!1,0,null,f,l),k&&k._last_time&&1E3>b-k._last_time)){var A=2-0.002*(b-k._last_time),J=a.globalAlpha;a.globalAlpha=J*A;this.renderLink(a,u,x,k,!0,A,"white",f,l); a.globalAlpha=J}}}}}}a.globalAlpha=1};k.prototype.renderLink=function(a,b,d,c,n,h,g,m,p,q){c&&this.visible_links.push(c);!g&&c&&(g=c.color||k.link_type_colors[c.type]);g||(g=this.default_link_color);null!=c&&this.highlighted_links[c.id]&&(g="#FFF");m=m||e.RIGHT;p=p||e.LEFT;var f=y(b,d);this.render_connections_border&&0.6b[1]?0:Math.PI,a.save(),a.translate(l[0],l[1]),a.rotate(A),a.beginPath(),a.moveTo(-5,-3),a.lineTo(0,7),a.lineTo(5,-3),a.fill(),a.restore(),a.save(),a.translate(q[0],q[1]),a.rotate(u),a.beginPath(),a.moveTo(-5,-3),a.lineTo(0,7),a.lineTo(5,-3),a.fill(),a.restore()),a.beginPath(),a.arc(n[0],n[1],5,0,2*Math.PI),a.fill());if(h)for(a.fillStyle=g,l=0;5>l;++l)h=(0.001*e.getTime()+0.2*l)%1,n=this.computeConnectionPoint(b,d,h,m,p),a.beginPath(),a.arc(n[0], n[1],5,0,2*Math.PI),a.fill()};k.prototype.computeConnectionPoint=function(a,b,d,c,n){c=c||e.RIGHT;n=n||e.LEFT;var h=y(a,b),g=[a[0],a[1]],m=[b[0],b[1]];switch(c){case e.LEFT:g[0]+=-0.25*h;break;case e.RIGHT:g[0]+=0.25*h;break;case e.UP:g[1]+=-0.25*h;break;case e.DOWN:g[1]+=0.25*h}switch(n){case e.LEFT:m[0]+=-0.25*h;break;case e.RIGHT:m[0]+=0.25*h;break;case e.UP:m[1]+=-0.25*h;break;case e.DOWN:m[1]+=0.25*h}c=(1-d)*(1-d)*(1-d);n=3*(1-d)*(1-d)*d;h=3*(1-d)*d*d;d*=d*d;return[c*a[0]+n*g[0]+h*m[0]+d*b[0], @@ -205,13 +205,13 @@ l.scrollIntoView())}function c(){function a(d,e){var c=document.createElement("d e.searchbox_extras[m];if(-1!==t.desc.toLowerCase().indexOf(d)){var x=e.registered_node_types[t.type];if(!x||!x.filter||x.filter==l)if(a(t.desc,"searchbox_extra"),-1!==k.search_limit&&h++>k.search_limit)break}}t=null;if(Array.prototype.filter)t=Object.keys(e.registered_node_types).filter(v);else for(m in t=[],e.registered_node_types)v(m)&&t.push(m);for(m=0;mk.search_limit);m++);var v=function(a){var b=e.registered_node_types[a];return l&&b.filter!=l?!1: -1!==a.toLowerCase().indexOf(d)}}}var g=this,h=document.createElement("div");h.className="litegraph litesearchbox graphdialog rounded";h.innerHTML="Search
";h.close=function(){g.search_box=null;document.body.focus();setTimeout(function(){g.canvas.focus()},20);h.parentNode&&h.parentNode.removeChild(h)};var m=null;1";else if("enum"==g&&h.values){f=""}else if("boolean"==g)f="";else{console.warn("unknown type: "+g);return}var k= -this.createDialog(""+b+""+f+"",d);if("enum"==g&&h.values){var p=k.querySelector("select");p.addEventListener("change",function(a){c(a.target.value)})}else if("boolean"==g)(p=k.querySelector("input"))&&p.addEventListener("click",function(a){c(!!p.checked)});else if(p=k.querySelector("input"))p.addEventListener("blur",function(a){this.focus()}),q=void 0!==a.properties[b]?a.properties[b]:"",q=JSON.stringify(q),p.value=q,p.addEventListener("keydown",function(a){13== -a.keyCode&&(e(),a.preventDefault(),a.stopPropagation())});k.querySelector("button").addEventListener("click",e)}};k.prototype.createDialog=function(a,b){b=b||{};var d=document.createElement("div");d.className="graphdialog";d.innerHTML=a;var e=this.canvas.getBoundingClientRect(),c=-20,g=-20;e&&(c-=e.left,g-=e.top);b.position?(c+=b.position[0],g+=b.position[1]):b.event?(c+=b.event.clientX,g+=b.event.clientY):(c+=0.5*this.canvas.width,g+=0.5*this.canvas.height);d.style.left=c+"px";d.style.top=g+"px"; -this.canvas.parentNode.appendChild(d);d.close=function(){this.parentNode&&this.parentNode.removeChild(this)};return d};k.onMenuNodeCollapse=function(a,b,d,e,c){c.collapse()};k.onMenuNodePin=function(a,b,d,e,c){c.pin()};k.onMenuNodeMode=function(a,b,d,c,g){new e.ContextMenu(["Always","On Event","On Trigger","Never"],{event:d,callback:function(a){if(g)switch(a){case "On Event":g.mode=e.ON_EVENT;break;case "On Trigger":g.mode=e.ON_TRIGGER;break;case "Never":g.mode=e.NEVER;break;default:g.mode=e.ALWAYS}}, -parentMenu:c,node:g});return!1};k.onMenuNodeColors=function(a,b,d,c,g){if(!g)throw"no node for color";b=[];b.push({value:null,content:"No color"});for(var h in k.node_colors)a=k.node_colors[h],a={value:h,content:""+h+""},b.push(a);new e.ContextMenu(b,{event:d,callback:function(a){g&&((a=a.value?k.node_colors[a.value]: +clearInterval(p);p=setTimeout(c,10);return}a.preventDefault();a.stopPropagation()}));var A=k.active_canvas,x=A.canvas,v=x.ownerDocument||document;v.fullscreenElement?v.fullscreenElement.appendChild(h):v.body.appendChild(h);x=x.getBoundingClientRect();v=(a?a.clientY:x.top+0.5*x.height)-20;h.style.left=(a?a.clientX:x.left+0.5*x.width)-80+"px";h.style.top=v+"px";u.focus();return h};k.prototype.showEditPropertyValue=function(a,b,d){function e(){c(p.value)}function c(d){"number"==typeof a.properties[b]&& +(d=Number(d));if("array"==g||"object"==g)d=JSON.parse(d);a.properties[b]=d;a._graph&&a._graph._version++;if(a.onPropertyChanged)a.onPropertyChanged(b,d);k.close();a.setDirtyCanvas(!0,!0)}if(a&&void 0!==a.properties[b]){d=d||{};var g="string";null!==a.properties[b]&&(g=typeof a.properties[b]);var h=null;a.getPropertyInfo&&(h=a.getPropertyInfo(b));if(a.properties_info)for(var m=0;m";else if("enum"==g&&h.values){f=""}else if("boolean"==g)f="";else{console.warn("unknown type: "+ +g);return}var k=this.createDialog(""+b+""+f+"",d);if("enum"==g&&h.values){var p=k.querySelector("select");p.addEventListener("change",function(a){c(a.target.value)})}else if("boolean"==g)(p=k.querySelector("input"))&&p.addEventListener("click",function(a){c(!!p.checked)});else if(p=k.querySelector("input"))p.addEventListener("blur",function(a){this.focus()}),q=void 0!==a.properties[b]?a.properties[b]:"",q=JSON.stringify(q),p.value=q,p.addEventListener("keydown", +function(a){13==a.keyCode&&(e(),a.preventDefault(),a.stopPropagation())});k.querySelector("button").addEventListener("click",e)}};k.prototype.createDialog=function(a,b){b=b||{};var d=document.createElement("div");d.className="graphdialog";d.innerHTML=a;var e=this.canvas.getBoundingClientRect(),c=-20,g=-20;e&&(c-=e.left,g-=e.top);b.position?(c+=b.position[0],g+=b.position[1]):b.event?(c+=b.event.clientX,g+=b.event.clientY):(c+=0.5*this.canvas.width,g+=0.5*this.canvas.height);d.style.left=c+"px";d.style.top= +g+"px";this.canvas.parentNode.appendChild(d);d.close=function(){this.parentNode&&this.parentNode.removeChild(this)};return d};k.onMenuNodeCollapse=function(a,b,d,e,c){c.collapse()};k.onMenuNodePin=function(a,b,d,e,c){c.pin()};k.onMenuNodeMode=function(a,b,d,c,g){new e.ContextMenu(["Always","On Event","On Trigger","Never"],{event:d,callback:function(a){if(g)switch(a){case "On Event":g.mode=e.ON_EVENT;break;case "On Trigger":g.mode=e.ON_TRIGGER;break;case "Never":g.mode=e.NEVER;break;default:g.mode= +e.ALWAYS}},parentMenu:c,node:g});return!1};k.onMenuNodeColors=function(a,b,d,c,g){if(!g)throw"no node for color";b=[];b.push({value:null,content:"No color"});for(var h in k.node_colors)a=k.node_colors[h],a={value:h,content:""+h+""},b.push(a);new e.ContextMenu(b,{event:d,callback:function(a){g&&((a=a.value?k.node_colors[a.value]: null)?g.constructor===e.LGraphGroup?g.color=a.groupcolor:(g.color=a.color,g.bgcolor=a.bgcolor):(delete g.color,delete g.bgcolor),g.setDirtyCanvas(!0,!0))},parentMenu:c,node:g});return!1};k.onMenuNodeShapes=function(a,b,d,c,g){if(!g)throw"no node passed";new e.ContextMenu(e.VALID_SHAPES,{event:d,callback:function(a){g&&(g.shape=a,g.setDirtyCanvas(!0))},parentMenu:c,node:g});return!1};k.onMenuNodeRemove=function(a,b,d,e,c){if(!c)throw"no node passed";!1!==c.removable&&(c.graph.remove(c),c.setDirtyCanvas(!0, !0))};k.onMenuNodeClone=function(a,b,d,c,e){!1!=e.clonable&&(a=e.clone())&&(a.pos=[e.pos[0]+5,e.pos[1]+5],e.graph.add(a),e.setDirtyCanvas(!0,!0))};k.node_colors={red:{color:"#322",bgcolor:"#533",groupcolor:"#A88"},brown:{color:"#332922",bgcolor:"#593930",groupcolor:"#b06634"},green:{color:"#232",bgcolor:"#353",groupcolor:"#8A8"},blue:{color:"#223",bgcolor:"#335",groupcolor:"#88A"},pale_blue:{color:"#2a363b",bgcolor:"#3f5159",groupcolor:"#3f789e"},cyan:{color:"#233",bgcolor:"#355",groupcolor:"#8AA"}, purple:{color:"#323",bgcolor:"#535",groupcolor:"#a1309b"},yellow:{color:"#432",bgcolor:"#653",groupcolor:"#b58b2a"},black:{color:"#222",bgcolor:"#000",groupcolor:"#444"}};k.prototype.getCanvasMenuOptions=function(){var a=null;this.getMenuOptions?a=this.getMenuOptions():(a=[{content:"Add Node",has_submenu:!0,callback:k.onMenuAdd},{content:"Add Group",callback:k.onGroupAdd}],this._graph_stack&&0a?b:dthis.size[0]-p.NODE_TITLE_HEIGHT&&0>b[1]){var c=this;setTimeout(function(){d.openSubgraph(c.subgraph)}, -10)}};r.prototype.onAction=function(a,b){this.subgraph.onAction(a,b)};r.prototype.onExecute=function(){if(this.enabled=this.getInputOrProperty("enabled")){if(this.inputs)for(var a=0;athis.size[0]-p.NODE_TITLE_HEIGHT&&0>b[1]){var c=this;setTimeout(function(){d.openSubgraph(c.subgraph)}, +10)}};s.prototype.onAction=function(a,b){this.subgraph.onAction(a,b)};s.prototype.onExecute=function(){if(this.enabled=this.getInputOrProperty("enabled")){if(this.inputs)for(var a=0;a=f?this.trigger(null,e):this._pending.push([f,e])};k.prototype.onExecute=function(){var c=1E3*this.graph.elapsed_time;this.isInputConnected(1)&&(this.properties.time_in_ms=this.getInputData(1));for(var e=0;e=f?this.trigger(null,e):this._pending.push([f,e])};k.prototype.onExecute=function(){var c=1E3*this.graph.elapsed_time;this.isInputConnected(1)&&(this.properties.time_in_ms=this.getInputData(1));for(var e=0;ef[1]))return this.old_y=c.canvasY,this.captureInput(!0),this.mouse_captured=!0};l.prototype.onMouseMove=function(c){if(this.mouse_captured){var f=this.old_y-c.canvasY;c.shiftKey&&(f*=10);if(c.metaKey||c.altKey)f*=0.1;this.old_y=c.canvasY; c=this._remainder+f/l.pixels_threshold;this._remainder=c%1;c=Math.clamp(this.properties.value+(c|0)*this.properties.step,this.properties.min,this.properties.max);this.properties.value=c;this.graph._version++;this.setDirtyCanvas(!0)}};l.prototype.onMouseUp=function(c,f){200>c.click_time&&(this.properties.value=Math.clamp(this.properties.value+(f[1]>0.5*this.size[1]?-1:1)*this.properties.step,this.properties.min,this.properties.max),this.graph._version++,this.setDirtyCanvas(!0));this.mouse_captured&& @@ -286,7 +286,7 @@ c=this._remainder+f/l.pixels_threshold;this._remainder=c%1;c=Math.clamp(this.pro c.beginPath();c.moveTo(0,0);c.arc(0,0,m,0,1.5*Math.PI);c.fill();c.strokeStyle="black";c.fillStyle=this.properties.color;c.lineWidth=2;c.beginPath();c.moveTo(0,0);c.arc(0,0,m-4,0,1.5*Math.PI*Math.max(0.01,this.value));c.closePath();c.fill();c.lineWidth=1;c.globalAlpha=1;c.restore();c.fillStyle="black";c.beginPath();c.arc(f,g,0.75*m,0,2*Math.PI,!0);c.fill();c.fillStyle=this.mouseOver?"white":this.properties.color;c.beginPath();var k=this.value*Math.PI*1.5+0.75*Math.PI;c.arc(f+Math.cos(k)*m*0.65,g+Math.sin(k)* m*0.65,0.05*m,0,2*Math.PI,!0);c.fill();c.fillStyle=this.mouseOver?"white":"#AAA";c.font=Math.floor(0.5*m)+"px Arial";c.textAlign="center";c.fillText(this.properties.value.toFixed(this.properties.precision),f,g+0.15*m)}};f.prototype.onExecute=function(){this.setOutputData(0,this.properties.value);this.boxcolor=z.colorToString([this.value,this.value,this.value])};f.prototype.onMouseDown=function(c){this.center=[0.5*this.size[0],0.5*this.size[1]+20];this.radius=0.5*this.size[0];if(20>c.canvasY-this.pos[1]|| z.distance([c.canvasX,c.canvasY],[this.pos[0]+this.center[0],this.pos[1]+this.center[1]])>this.radius)return!1;this.oldmouse=[c.canvasX-this.pos[0],c.canvasY-this.pos[1]];this.captureInput(!0);return!0};f.prototype.onMouseMove=function(c){if(this.oldmouse){c=[c.canvasX-this.pos[0],c.canvasY-this.pos[1]];var f=this.value,f=f-0.01*(c[1]-this.oldmouse[1]);1f&&(f=0);this.value=f;this.properties.value=this.properties.min+(this.properties.max-this.properties.min)*this.value;this.oldmouse=c;this.setDirtyCanvas(!0)}}; -f.prototype.onMouseUp=function(c){this.oldmouse&&(this.oldmouse=null,this.captureInput(!1))};f.prototype.onPropertyChanged=function(c,f){if("min"==c||"max"==c||"value"==c)return this.properties[c]=parseFloat(f),!0};z.registerNodeType("widget/knob",f);s.title="Inner Slider";s.prototype.onPropertyChanged=function(c,f){"value"==c&&(this.slider.value=f)};s.prototype.onExecute=function(){this.setOutputData(0,this.properties.value)};z.registerNodeType("widget/internal_slider",s);k.title="H.Slider";k.desc= +f.prototype.onMouseUp=function(c){this.oldmouse&&(this.oldmouse=null,this.captureInput(!1))};f.prototype.onPropertyChanged=function(c,f){if("min"==c||"max"==c||"value"==c)return this.properties[c]=parseFloat(f),!0};z.registerNodeType("widget/knob",f);r.title="Inner Slider";r.prototype.onPropertyChanged=function(c,f){"value"==c&&(this.slider.value=f)};r.prototype.onExecute=function(){this.setOutputData(0,this.properties.value)};z.registerNodeType("widget/internal_slider",r);k.title="H.Slider";k.desc= "Linear slider controller";k.prototype.onDrawForeground=function(c){-1==this.value&&(this.value=(this.properties.value-this.properties.min)/(this.properties.max-this.properties.min));c.globalAlpha=1;c.lineWidth=1;c.fillStyle="#000";c.fillRect(2,2,this.size[0]-4,this.size[1]-4);c.fillStyle=this.properties.color;c.beginPath();c.rect(4,4,(this.size[0]-8)*this.value,this.size[1]-8);c.fill()};k.prototype.onExecute=function(){this.properties.value=this.properties.min+(this.properties.max-this.properties.min)* this.value;this.setOutputData(0,this.properties.value);this.boxcolor=z.colorToString([this.value,this.value,this.value])};k.prototype.onMouseDown=function(c){if(0>c.canvasY-this.pos[1])return!1;this.oldmouse=[c.canvasX-this.pos[0],c.canvasY-this.pos[1]];this.captureInput(!0);return!0};k.prototype.onMouseMove=function(c){if(this.oldmouse){c=[c.canvasX-this.pos[0],c.canvasY-this.pos[1]];var f=this.value,f=f+(c[0]-this.oldmouse[0])/this.size[0];1f&&(f=0);this.value=f;this.oldmouse=c;this.setDirtyCanvas(!0)}}; k.prototype.onMouseUp=function(c){this.oldmouse=null;this.captureInput(!1)};k.prototype.onMouseLeave=function(c){};z.registerNodeType("widget/hslider",k);y.title="Progress";y.desc="Shows data in linear progress";y.prototype.onExecute=function(){var c=this.getInputData(0);void 0!=c&&(this.properties.value=c)};y.prototype.onDrawForeground=function(c){c.lineWidth=1;c.fillStyle=this.properties.color;var f=(this.properties.value-this.properties.min)/(this.properties.max-this.properties.min),f=Math.min(1, @@ -295,18 +295,18 @@ f),f=Math.max(0,f);c.fillRect(2,2,(this.size[0]-4)*f,this.size[1]-4)};z.register this.getInputData(0);null!=c&&(this.properties.value=c)};u.prototype.resize=function(){if(this.last_ctx){var c=this.str.split("\\n");this.last_ctx.font=this.properties.fontsize+"px "+this.properties.font;var f=0,g;for(g in c){var m=this.last_ctx.measureText(c[g]).width;ff?l.xbox.axes.lx:0,this._left_axis[1]=Math.abs(l.xbox.axes.ly)>f?l.xbox.axes.ly:0,this._right_axis[0]=Math.abs(l.xbox.axes.rx)>f?l.xbox.axes.rx:0,this._right_axis[1]=Math.abs(l.xbox.axes.ry)>f?l.xbox.axes.ry:0,this._triggers[0]=Math.abs(l.xbox.axes.ltrigger)>f?l.xbox.axes.ltrigger: -0,this._triggers[1]=Math.abs(l.xbox.axes.rtrigger)>f?l.xbox.axes.rtrigger:0);if(this.outputs)for(f=0;ff?l.xbox.axes.rtrigger:0);if(this.outputs)for(f=0;fl;l++)if(f[l]){l=f[l];f=this.xbox_mapping;f||(f=this.xbox_mapping={axes:[], -buttons:{},hat:"",hatmap:c.CENTER});f.axes.lx=l.axes[0];f.axes.ly=l.axes[1];f.axes.rx=l.axes[2];f.axes.ry=l.axes[3];f.axes.ltrigger=l.buttons[6].value;f.axes.rtrigger=l.buttons[7].value;f.hat="";f.hatmap=c.CENTER;for(var s=0;ss)f.buttons[c.mapping_array[s]]=l.buttons[s].pressed,l.buttons[s].was_pressed&&this.trigger(c.mapping_array[s]+"_button_event");else switch(s){case 12:l.buttons[s].pressed&&(f.hat+="up",f.hatmap|=c.UP); -break;case 13:l.buttons[s].pressed&&(f.hat+="down",f.hatmap|=c.DOWN);break;case 14:l.buttons[s].pressed&&(f.hat+="left",f.hatmap|=c.LEFT);break;case 15:l.buttons[s].pressed&&(f.hat+="right",f.hatmap|=c.RIGHT);break;case 16:f.buttons.home=l.buttons[s].pressed}l.xbox=f;return l}};c.prototype.onDrawBackground=function(c){if(!this.flags.collapsed){var f=this._left_axis,s=this._right_axis;c.strokeStyle="#88A";c.strokeRect(0.5*(f[0]+1)*this.size[0]-4,0.5*(f[1]+1)*this.size[1]-4,8,8);c.strokeStyle="#8A8"; -c.strokeRect(0.5*(s[0]+1)*this.size[0]-4,0.5*(s[1]+1)*this.size[1]-4,8,8);f=this.size[1]/this._current_buttons.length;c.fillStyle="#AEB";for(s=0;sr)f.buttons[c.mapping_array[r]]=l.buttons[r].pressed,l.buttons[r].was_pressed&&this.trigger(c.mapping_array[r]+"_button_event");else switch(r){case 12:l.buttons[r].pressed&&(f.hat+="up",f.hatmap|=c.UP); +break;case 13:l.buttons[r].pressed&&(f.hat+="down",f.hatmap|=c.DOWN);break;case 14:l.buttons[r].pressed&&(f.hat+="left",f.hatmap|=c.LEFT);break;case 15:l.buttons[r].pressed&&(f.hat+="right",f.hatmap|=c.RIGHT);break;case 16:f.buttons.home=l.buttons[r].pressed}l.xbox=f;return l}};c.prototype.onDrawBackground=function(c){if(!this.flags.collapsed){var f=this._left_axis,r=this._right_axis;c.strokeStyle="#88A";c.strokeRect(0.5*(f[0]+1)*this.size[0]-4,0.5*(f[1]+1)*this.size[1]-4,8,8);c.strokeStyle="#8A8"; +c.strokeRect(0.5*(r[0]+1)*this.size[0]-4,0.5*(r[1]+1)*this.size[1]-4,8,8);f=this.size[1]/this._current_buttons.length;c.fillStyle="#AEB";for(r=0;ra&&(a+=1024);var c=Math.floor(a);a-=c;d=k.data[c];c=k.data[1023==c?0:c+1];b&&(a=a*a*a*(a*(6*a-15)+10));return d*(1-a)+c*a};k.prototype.onExecute=function(){var a=this.getInputData(0)||0,a=k.getValue(a,this.properties.smooth), +["out_min","number"],["out_max","number"]]};B.registerNodeType("math/range",f);r.title="Rand";r.desc="Random number";r.prototype.onExecute=function(){if(this.inputs)for(var a=0;aa&&(a+=1024);var c=Math.floor(a);a-=c;d=k.data[c];c=k.data[1023==c?0:c+1];b&&(a=a*a*a*(a*(6*a-15)+10));return d*(1-a)+c*a};k.prototype.onExecute=function(){var a=this.getInputData(0)||0,a=k.getValue(a,this.properties.smooth), b=this.properties.min;this._last_v=a*(this.properties.max-b)+b;this.setOutputData(0,this._last_v)};k.prototype.onDrawBackground=function(a){this.outputs[0].label=(this._last_v||0).toFixed(3)};B.registerNodeType("math/noise",k);y.title="Spikes";y.desc="spike every random time";y.prototype.onExecute=function(){var a=this.graph.elapsed_time;this._remaining_time-=a;this._blink_time-=a;a=0;0this._remaining_time?(this._remaining_time= Math.random()*(this.properties.max_time-this.properties.min_time)+this.properties.min_time,this._blink_time=this.properties.duration,this.boxcolor="#FFF"):this.boxcolor="#000";this.setOutputData(0,a)};B.registerNodeType("math/spikes",y);u.title="Clamp";u.desc="Clamp number between min and max";u.prototype.onExecute=function(){var a=this.getInputData(0);null!=a&&(a=Math.max(this.properties.min,a),a=Math.min(this.properties.max,a),this.setOutputData(0,a))};u.prototype.getCode=function(a){a="";this.isInputConnected(0)&& (a+="clamp({{0}},"+this.properties.min+","+this.properties.max+")");return a};B.registerNodeType("math/clamp",u);v.title="Lerp";v.desc="Linear Interpolation";v.prototype.onExecute=function(){var a=this.getInputData(0);null==a&&(a=0);var b=this.getInputData(1);null==b&&(b=0);var d=this.properties.f,c=this.getInputData(2);void 0!==c&&(d=c);this.setOutputData(0,a*(1-d)+b*d)};v.prototype.onGetInputs=function(){return[["f","number"]]};B.registerNodeType("math/lerp",v);z.title="Abs";z.desc="Absolute";z.prototype.onExecute= @@ -347,13 +347,13 @@ a[3]))};B.registerNodeType("math3d/vec4-to-xyzw",F);I.title="XYZW->Vec4";I.desc= "rotate a point",w.prototype.onExecute=function(){var a=this.getInputData(0);null==a&&(a=this.properties.vec);var b=this.getInputData(1);null==b?this.setOutputData(a):this.setOutputData(0,vec3.transformQuat(vec3.create(),a,b))},B.registerNodeType("math3d/rotate_vec3",w),w=function(){this.addInputs([["A","quat"],["B","quat"]]);this.addOutput("A*B","quat");this._value=quat.create()},w.title="Mult. Quat",w.desc="rotate quaternion",w.prototype.onExecute=function(){var a=this.getInputData(0);if(null!= a){var b=this.getInputData(1);null!=b&&(a=quat.multiply(this._value,a,b),this.setOutputData(0,a))}},B.registerNodeType("math3d/mult-quat",w),w=function(){this.addInputs([["A","quat"],["B","quat"],["factor","number"]]);this.addOutput("slerp","quat");this.addProperty("factor",0.5);this._value=quat.create()},w.title="Quat Slerp",w.desc="quaternion spherical interpolation",w.prototype.onExecute=function(){var a=this.getInputData(0);if(null!=a){var b=this.getInputData(1);if(null!=b){var d=this.properties.factor; null!=this.getInputData(2)&&(d=this.getInputData(2));a=quat.slerp(this._value,a,b,d);this.setOutputData(0,a)}}},B.registerNodeType("math3d/quat-slerp",w))})(this); -(function(w){function c(){this.addInput("A","number,vec3");this.addInput("B","number,vec3");this.addOutput("=","vec3");this.addProperty("OP","+","enum",{values:c.values});this._result=vec3.create()}function r(){this.addInput("in","vec3");this.addInput("f","number");this.addOutput("out","vec3");this.properties={f:1};this._data=new Float32Array(3)}function l(){this.addInput("in","vec3");this.addOutput("out","number")}function f(){this.addInput("in","vec3");this.addOutput("out","vec3");this._data=new Float32Array(3)} -function s(){this.addInput("A","vec3");this.addInput("B","vec3");this.addInput("f","vec3");this.addOutput("out","vec3");this.properties={f:0.5};this._data=new Float32Array(3)}function k(){this.addInput("A","vec3");this.addInput("B","vec3");this.addOutput("out","number")}var y=w.LiteGraph;c.values="+ - * / % ^ max min".split(" ");c.title="Operation";c.desc="Easy math 3D operators";c["@OP"]={type:"enum",title:"operation",values:c.values};c.size=[100,60];c.prototype.getTitle=function(){return"max"== +(function(w){function c(){this.addInput("A","number,vec3");this.addInput("B","number,vec3");this.addOutput("=","vec3");this.addProperty("OP","+","enum",{values:c.values});this._result=vec3.create()}function s(){this.addInput("in","vec3");this.addInput("f","number");this.addOutput("out","vec3");this.properties={f:1};this._data=new Float32Array(3)}function l(){this.addInput("in","vec3");this.addOutput("out","number")}function f(){this.addInput("in","vec3");this.addOutput("out","vec3");this._data=new Float32Array(3)} +function r(){this.addInput("A","vec3");this.addInput("B","vec3");this.addInput("f","vec3");this.addOutput("out","vec3");this.properties={f:0.5};this._data=new Float32Array(3)}function k(){this.addInput("A","vec3");this.addInput("B","vec3");this.addOutput("out","number")}var y=w.LiteGraph;c.values="+ - * / % ^ max min".split(" ");c.title="Operation";c.desc="Easy math 3D operators";c["@OP"]={type:"enum",title:"operation",values:c.values};c.size=[100,60];c.prototype.getTitle=function(){return"max"== this.properties.OP||"min"==this.properties.OP?this.properties.OP+"(A,B)":"A "+this.properties.OP+" B"};c.prototype.onExecute=function(){var c=this.getInputData(0),f=this.getInputData(1);if(null!=c&&null!=f){c.constructor===Number&&(c=[c,c,c]);f.constructor===Number&&(f=[f,f,f]);var k=this._result;switch(this.properties.OP){case "+":k=vec3.add(k,c,f);break;case "-":k=vec3.sub(k,c,f);break;case "x":case "X":case "*":k=vec3.mul(k,c,f);break;case "/":k=vec3.div(k,c,f);break;case "%":k[0]=c[0]%f[0];k[1]= c[1]%f[1];k[2]=c[2]%f[2];break;case "^":k[0]=Math.pow(c[0],f[0]);k[1]=Math.pow(c[1],f[1]);k[2]=Math.pow(c[2],f[2]);break;case "max":k[0]=Math.max(c[0],f[0]);k[1]=Math.max(c[1],f[1]);k[2]=Math.max(c[2],f[2]);break;case "min":k[0]=Math.min(c[0],f[0]);k[1]=Math.min(c[1],f[1]);k[2]=Math.min(c[2],f[2]);break;default:console.warn("Unknown operation: "+this.properties.OP)}this.setOutputData(0,k)}};c.prototype.onDrawBackground=function(c){this.flags.collapsed||(c.font="40px Arial",c.fillStyle="#666",c.textAlign= -"center",c.fillText(this.properties.OP,0.5*this.size[0],0.5*(this.size[1]+y.NODE_TITLE_HEIGHT)),c.textAlign="left")};y.registerNodeType("math3d/operation",c);r.title="vec3_scale";r.desc="scales the components of a vec3";r.prototype.onExecute=function(){var c=this.getInputData(0);if(null!=c){var f=this.getInputData(1);null==f&&(f=this.properties.f);var k=this._data;k[0]=c[0]*f;k[1]=c[1]*f;k[2]=c[2]*f;this.setOutputData(0,k)}};y.registerNodeType("math3d/vec3-scale",r);l.title="vec3_length";l.desc="returns the module of a vector"; -l.prototype.onExecute=function(){var c=this.getInputData(0);null!=c&&(c=Math.sqrt(c[0]*c[0]+c[1]*c[1]+c[2]*c[2]),this.setOutputData(0,c))};y.registerNodeType("math3d/vec3-length",l);f.title="vec3_normalize";f.desc="returns the vector normalized";f.prototype.onExecute=function(){var c=this.getInputData(0);if(null!=c){var f=Math.sqrt(c[0]*c[0]+c[1]*c[1]+c[2]*c[2]),k=this._data;k[0]=c[0]/f;k[1]=c[1]/f;k[2]=c[2]/f;this.setOutputData(0,k)}};y.registerNodeType("math3d/vec3-normalize",f);s.title="vec3_lerp"; -s.desc="returns the interpolated vector";s.prototype.onExecute=function(){var c=this.getInputData(0);if(null!=c){var f=this.getInputData(1);if(null!=f){var k=this.getInputOrProperty("f"),e=this._data;e[0]=c[0]*(1-k)+f[0]*k;e[1]=c[1]*(1-k)+f[1]*k;e[2]=c[2]*(1-k)+f[2]*k;this.setOutputData(0,e)}}};y.registerNodeType("math3d/vec3-lerp",s);k.title="vec3_dot";k.desc="returns the dot product";k.prototype.onExecute=function(){var c=this.getInputData(0);if(null!=c){var f=this.getInputData(1);null!=f&&this.setOutputData(0, +"center",c.fillText(this.properties.OP,0.5*this.size[0],0.5*(this.size[1]+y.NODE_TITLE_HEIGHT)),c.textAlign="left")};y.registerNodeType("math3d/operation",c);s.title="vec3_scale";s.desc="scales the components of a vec3";s.prototype.onExecute=function(){var c=this.getInputData(0);if(null!=c){var f=this.getInputData(1);null==f&&(f=this.properties.f);var k=this._data;k[0]=c[0]*f;k[1]=c[1]*f;k[2]=c[2]*f;this.setOutputData(0,k)}};y.registerNodeType("math3d/vec3-scale",s);l.title="vec3_length";l.desc="returns the module of a vector"; +l.prototype.onExecute=function(){var c=this.getInputData(0);null!=c&&(c=Math.sqrt(c[0]*c[0]+c[1]*c[1]+c[2]*c[2]),this.setOutputData(0,c))};y.registerNodeType("math3d/vec3-length",l);f.title="vec3_normalize";f.desc="returns the vector normalized";f.prototype.onExecute=function(){var c=this.getInputData(0);if(null!=c){var f=Math.sqrt(c[0]*c[0]+c[1]*c[1]+c[2]*c[2]),k=this._data;k[0]=c[0]/f;k[1]=c[1]/f;k[2]=c[2]/f;this.setOutputData(0,k)}};y.registerNodeType("math3d/vec3-normalize",f);r.title="vec3_lerp"; +r.desc="returns the interpolated vector";r.prototype.onExecute=function(){var c=this.getInputData(0);if(null!=c){var f=this.getInputData(1);if(null!=f){var k=this.getInputOrProperty("f"),e=this._data;e[0]=c[0]*(1-k)+f[0]*k;e[1]=c[1]*(1-k)+f[1]*k;e[2]=c[2]*(1-k)+f[2]*k;this.setOutputData(0,e)}}};y.registerNodeType("math3d/vec3-lerp",r);k.title="vec3_dot";k.desc="returns the dot product";k.prototype.onExecute=function(){var c=this.getInputData(0);if(null!=c){var f=this.getInputData(1);null!=f&&this.setOutputData(0, c[0]*f[0]+c[1]*f[1]+c[2]*f[2])}};y.registerNodeType("math3d/vec3-dot",k);w.glMatrix?(w=function(){this.addOutput("quat","quat");this.properties={x:0,y:0,z:0,w:1,normalize:!1};this._value=quat.create()},w.title="Quaternion",w.desc="quaternion",w.prototype.onExecute=function(){this._value[0]=this.getInputOrProperty("x");this._value[1]=this.getInputOrProperty("y");this._value[2]=this.getInputOrProperty("z");this._value[3]=this.getInputOrProperty("w");this.properties.normalize&&quat.normalize(this._value, this._value);this.setOutputData(0,this._value)},w.prototype.onGetInputs=function(){return[["x","number"],["y","number"],["z","number"],["w","number"]]},y.registerNodeType("math3d/quaternion",w),w=function(){this.addInputs([["degrees","number"],["axis","vec3"]]);this.addOutput("quat","quat");this.properties={angle:90,axis:vec3.fromValues(0,1,0)};this._value=quat.create()},w.title="Rotation",w.desc="quaternion rotation",w.prototype.onExecute=function(){var c=this.getInputData(0);null==c&&(c=this.properties.angle); var f=this.getInputData(1);null==f&&(f=this.properties.axis);c=quat.setAxisAngle(this._value,f,0.0174532925*c);this.setOutputData(0,c)},y.registerNodeType("math3d/rotation",w),w=function(){this.addInputs([["vec3","vec3"],["quat","quat"]]);this.addOutput("result","vec3");this.properties={vec:[0,0,1]}},w.title="Rot. Vec3",w.desc="rotate a point",w.prototype.onExecute=function(){var c=this.getInputData(0);null==c&&(c=this.properties.vec);var f=this.getInputData(1);null==f?this.setOutputData(c):this.setOutputData(0, @@ -361,24 +361,24 @@ vec3.transformQuat(vec3.create(),c,f))},y.registerNodeType("math3d/rotate_vec3", "quat"],["factor","number"]]);this.addOutput("slerp","quat");this.addProperty("factor",0.5);this._value=quat.create()},w.title="Quat Slerp",w.desc="quaternion spherical interpolation",w.prototype.onExecute=function(){var c=this.getInputData(0);if(null!=c){var f=this.getInputData(1);if(null!=f){var k=this.properties.factor;null!=this.getInputData(2)&&(k=this.getInputData(2));c=quat.slerp(this._value,c,f,k);this.setOutputData(0,c)}}},y.registerNodeType("math3d/quat-slerp",w),w=function(){this.addInput("vec3", "vec3");this.addOutput("remap","vec3");this.addOutput("clamped","vec3");this.properties={clamp:!0,range_min:[-1,-1,0],range_max:[1,1,0],target_min:[-1,-1,0],target_max:[1,1,0]};this._value=vec3.create();this._clamped=vec3.create()},w.title="Remap Range",w.desc="remap a 3D range",w.prototype.onExecute=function(){var c=this.getInputData(0);c&&this._value.set(c);for(var c=this.properties.range_min,f=this.properties.range_max,k=this.properties.target_min,e=this.properties.target_max,l=0;3>l;++l){var g= f[l]-c[l];this._clamped[l]=Math.clamp(this._value[l],c[l],f[l]);0==g?this._value[l]=0.5*(k[l]+e[l]):(g=(this._value[l]-c[l])/g,this.properties.clamp&&(g=Math.clamp(g,0,1)),this._value[l]=k[l]+g*(e[l]-k[l]))}this.setOutputData(0,this._value);this.setOutputData(1,this._clamped)},y.registerNodeType("math3d/remap_range",w)):console.warn("No glmatrix found, some Math3D nodes may not work")})(this); -(function(w){function c(c,f){return c==f}function r(c){return null!=c&&c.constructor===String?c.toUpperCase():c}w=w.LiteGraph;w.wrapFunctionAsNode("string/toString",c,["*"],"String");w.wrapFunctionAsNode("string/compare",c,["String","String"],"Boolean");w.wrapFunctionAsNode("string/concatenate",function(c,f){return void 0===c?f:void 0===f?c:c+f},["String","String"],"String");w.wrapFunctionAsNode("string/contains",function(c,f){return void 0===c||void 0===f?!1:-1!=c.indexOf(f)},["String","String"], -"Boolean");w.wrapFunctionAsNode("string/toUpperCase",r,["String"],"String");w.wrapFunctionAsNode("string/split",r,["String","String"],"Array");w.wrapFunctionAsNode("string/toFixed",function(c){return null!=c&&c.constructor===Number?c.toFixed(this.properties.precision):c},["Number"],"String",{precision:0})})(this); -(function(w){function c(){this.addInput("sel","number");this.addInput("A");this.addInput("B");this.addInput("C");this.addInput("D");this.addOutput("out");this.selected=0}function r(){this.properties={sequence:"A,B,C"};this.addInput("index","number");this.addInput("seq");this.addOutput("out");this.index=0;this.values=this.properties.sequence.split(",")}var l=w.LiteGraph;c.title="Selector";c.desc="selects an output";c.prototype.onDrawBackground=function(c){if(!this.flags.collapsed){c.fillStyle="#AFB"; -var s=(this.selected+1)*l.NODE_SLOT_HEIGHT+6;c.beginPath();c.moveTo(50,s);c.lineTo(50,s+l.NODE_SLOT_HEIGHT);c.lineTo(34,s+0.5*l.NODE_SLOT_HEIGHT);c.fill()}};c.prototype.onExecute=function(){var c=this.getInputData(0);if(null==c||c.constructor!==Number)c=0;this.selected=c=Math.round(c)%(this.inputs.length-1);c=this.getInputData(c+1);void 0!==c&&this.setOutputData(0,c)};c.prototype.onGetInputs=function(){return[["E",0],["F",0],["G",0],["H",0]]};l.registerNodeType("logic/selector",c);r.title="Sequence"; -r.desc="select one element from a sequence from a string";r.prototype.onPropertyChanged=function(c,l){"sequence"==c&&(this.values=l.split(","))};r.prototype.onExecute=function(){var c=this.getInputData(1);c&&c!=this.current_sequence&&(this.values=c.split(","),this.current_sequence=c);c=this.getInputData(0);null==c&&(c=0);this.index=c=Math.round(c)%this.values.length;this.setOutputData(0,this.values[c])};l.registerNodeType("logic/sequence",r)})(this); -(function(w){function c(){this.addInput("A","Number");this.addInput("B","Number");this.addInput("C","Number");this.addInput("D","Number");this.values=[[],[],[],[]];this.properties={scale:2}}function r(){this.addOutput("frame","image");this.properties={url:""}}function l(){this.addInput("f","number");this.addOutput("Color","color");this.properties={colorA:"#444444",colorB:"#44AAFF",colorC:"#44FFAA",colorD:"#FFFFFF"}}function f(){this.addInput("","image,canvas");this.size=[200,200]}function s(){this.addInputs([["img1", +(function(w){function c(c,f){return c==f}function s(c){return null!=c&&c.constructor===String?c.toUpperCase():c}w=w.LiteGraph;w.wrapFunctionAsNode("string/toString",c,["*"],"String");w.wrapFunctionAsNode("string/compare",c,["String","String"],"Boolean");w.wrapFunctionAsNode("string/concatenate",function(c,f){return void 0===c?f:void 0===f?c:c+f},["String","String"],"String");w.wrapFunctionAsNode("string/contains",function(c,f){return void 0===c||void 0===f?!1:-1!=c.indexOf(f)},["String","String"], +"Boolean");w.wrapFunctionAsNode("string/toUpperCase",s,["String"],"String");w.wrapFunctionAsNode("string/split",s,["String","String"],"Array");w.wrapFunctionAsNode("string/toFixed",function(c){return null!=c&&c.constructor===Number?c.toFixed(this.properties.precision):c},["Number"],"String",{precision:0})})(this); +(function(w){function c(){this.addInput("sel","number");this.addInput("A");this.addInput("B");this.addInput("C");this.addInput("D");this.addOutput("out");this.selected=0}function s(){this.properties={sequence:"A,B,C"};this.addInput("index","number");this.addInput("seq");this.addOutput("out");this.index=0;this.values=this.properties.sequence.split(",")}var l=w.LiteGraph;c.title="Selector";c.desc="selects an output";c.prototype.onDrawBackground=function(c){if(!this.flags.collapsed){c.fillStyle="#AFB"; +var r=(this.selected+1)*l.NODE_SLOT_HEIGHT+6;c.beginPath();c.moveTo(50,r);c.lineTo(50,r+l.NODE_SLOT_HEIGHT);c.lineTo(34,r+0.5*l.NODE_SLOT_HEIGHT);c.fill()}};c.prototype.onExecute=function(){var c=this.getInputData(0);if(null==c||c.constructor!==Number)c=0;this.selected=c=Math.round(c)%(this.inputs.length-1);c=this.getInputData(c+1);void 0!==c&&this.setOutputData(0,c)};c.prototype.onGetInputs=function(){return[["E",0],["F",0],["G",0],["H",0]]};l.registerNodeType("logic/selector",c);s.title="Sequence"; +s.desc="select one element from a sequence from a string";s.prototype.onPropertyChanged=function(c,l){"sequence"==c&&(this.values=l.split(","))};s.prototype.onExecute=function(){var c=this.getInputData(1);c&&c!=this.current_sequence&&(this.values=c.split(","),this.current_sequence=c);c=this.getInputData(0);null==c&&(c=0);this.index=c=Math.round(c)%this.values.length;this.setOutputData(0,this.values[c])};l.registerNodeType("logic/sequence",s)})(this); +(function(w){function c(){this.addInput("A","Number");this.addInput("B","Number");this.addInput("C","Number");this.addInput("D","Number");this.values=[[],[],[],[]];this.properties={scale:2}}function s(){this.addOutput("frame","image");this.properties={url:""}}function l(){this.addInput("f","number");this.addOutput("Color","color");this.properties={colorA:"#444444",colorB:"#44AAFF",colorC:"#44FFAA",colorD:"#FFFFFF"}}function f(){this.addInput("","image,canvas");this.size=[200,200]}function r(){this.addInputs([["img1", "image"],["img2","image"],["fade","number"]]);this.addOutput("","image");this.properties={fade:0.5,width:512,height:512}}function k(){this.addInput("","image");this.addOutput("","image");this.properties={width:256,height:256,x:0,y:0,scale:1};this.size=[50,20]}function y(){this.addInput("clear",x.ACTION);this.addOutput("","canvas");this.properties={width:512,height:512,autoclear:!0};this.canvas=document.createElement("canvas");this.ctx=this.canvas.getContext("2d")}function u(){this.addInput("canvas", "canvas");this.addInput("img","image,canvas");this.addInput("x","number");this.addInput("y","number");this.properties={x:0,y:0,opacity:1}}function v(){this.addInput("canvas","canvas");this.addInput("x","number");this.addInput("y","number");this.addInput("w","number");this.addInput("h","number");this.properties={x:0,y:0,w:10,h:10,color:"white",opacity:1}}function z(){this.addInput("t","number");this.addOutputs([["frame","image"],["t","number"],["d","number"]]);this.properties={url:"",use_proxy:!0}} function e(){this.addOutput("Webcam","image");this.properties={facingMode:"user"};this.boxcolor="black";this.frame=0}var x=w.LiteGraph;c.title="Plot";c.desc="Plots data over time";c.colors=["#FFF","#F99","#9F9","#99F"];c.prototype.onExecute=function(c){if(!this.flags.collapsed){c=this.size;for(var e=0;4>e;++e){var f=this.getInputData(e);if(null!=f){var h=this.values[e];h.push(f);h.length>c[0]&&h.shift()}}}};c.prototype.onDrawBackground=function(e){if(!this.flags.collapsed){var f=this.size,k=0.5*f[1]/ -this.properties.scale,h=c.colors,q=0.5*f[1];e.fillStyle="#000";e.fillRect(0,0,f[0],f[1]);e.strokeStyle="#555";e.beginPath();e.moveTo(0,q);e.lineTo(f[0],q);e.stroke();if(this.inputs)for(var p=0;4>p;++p){var a=this.values[p];if(this.inputs[p]&&this.inputs[p].link){e.strokeStyle=h[p];e.beginPath();var b=a[0]*k*-1+q;e.moveTo(0,Math.clamp(b,0,f[1]));for(var d=1;dp;++p){var a=this.values[p];if(this.inputs[p]&&this.inputs[p].link){e.strokeStyle=h[p];e.beginPath();var b=a[0]*k*-1+q;e.moveTo(0,Math.clamp(b,0,f[1]));for(var d=1;de&&(e=0);if(0!=c.length){var f=[0,0,0];if(0==e)f=c[0];else if(1==e)f=c[c.length-1];else{var h=(c.length-1)* e,e=c[Math.floor(h)],c=c[Math.floor(h)+1],h=h-Math.floor(h);f[0]=e[0]*(1-h)+c[0]*h;f[1]=e[1]*(1-h)+c[1]*h;f[2]=e[2]*(1-h)+c[2]*h}for(var k in f)f[k]/=255;this.boxcolor=colorToString(f);this.setOutputData(0,f)}};x.registerNodeType("color/palette",l);f.title="Frame";f.desc="Frame viewerew";f.widgets=[{name:"resize",text:"Resize box",type:"button"},{name:"view",text:"View Image",type:"button"}];f.prototype.onDrawBackground=function(c){this.frame&&!this.flags.collapsed&&c.drawImage(this.frame,0,0,this.size[0], -this.size[1])};f.prototype.onExecute=function(){this.frame=this.getInputData(0);this.setDirtyCanvas(!0)};f.prototype.onWidget=function(c,e){if("resize"==e.name&&this.frame){var f=this.frame.width,h=this.frame.height;f||null==this.frame.videoWidth||(f=this.frame.videoWidth,h=this.frame.videoHeight);f&&h&&(this.size=[f,h]);this.setDirtyCanvas(!0,!0)}else"view"==e.name&&this.show()};f.prototype.show=function(){showElement&&this.frame&&showElement(this.frame)};x.registerNodeType("graphics/frame",f);s.title= -"Image fade";s.desc="Fades between images";s.widgets=[{name:"resizeA",text:"Resize to A",type:"button"},{name:"resizeB",text:"Resize to B",type:"button"}];s.prototype.onAdded=function(){this.createCanvas();var c=this.canvas.getContext("2d");c.fillStyle="#000";c.fillRect(0,0,this.properties.width,this.properties.height)};s.prototype.createCanvas=function(){this.canvas=document.createElement("canvas");this.canvas.width=this.properties.width;this.canvas.height=this.properties.height};s.prototype.onExecute= -function(){var c=this.canvas.getContext("2d");this.canvas.width=this.canvas.width;var e=this.getInputData(0);null!=e&&c.drawImage(e,0,0,this.canvas.width,this.canvas.height);e=this.getInputData(2);null==e?e=this.properties.fade:this.properties.fade=e;c.globalAlpha=e;e=this.getInputData(1);null!=e&&c.drawImage(e,0,0,this.canvas.width,this.canvas.height);c.globalAlpha=1;this.setOutputData(0,this.canvas);this.setDirtyCanvas(!0)};x.registerNodeType("graphics/imagefade",s);k.title="Crop";k.desc="Crop Image"; +this.size[1])};f.prototype.onExecute=function(){this.frame=this.getInputData(0);this.setDirtyCanvas(!0)};f.prototype.onWidget=function(c,e){if("resize"==e.name&&this.frame){var f=this.frame.width,h=this.frame.height;f||null==this.frame.videoWidth||(f=this.frame.videoWidth,h=this.frame.videoHeight);f&&h&&(this.size=[f,h]);this.setDirtyCanvas(!0,!0)}else"view"==e.name&&this.show()};f.prototype.show=function(){showElement&&this.frame&&showElement(this.frame)};x.registerNodeType("graphics/frame",f);r.title= +"Image fade";r.desc="Fades between images";r.widgets=[{name:"resizeA",text:"Resize to A",type:"button"},{name:"resizeB",text:"Resize to B",type:"button"}];r.prototype.onAdded=function(){this.createCanvas();var c=this.canvas.getContext("2d");c.fillStyle="#000";c.fillRect(0,0,this.properties.width,this.properties.height)};r.prototype.createCanvas=function(){this.canvas=document.createElement("canvas");this.canvas.width=this.properties.width;this.canvas.height=this.properties.height};r.prototype.onExecute= +function(){var c=this.canvas.getContext("2d");this.canvas.width=this.canvas.width;var e=this.getInputData(0);null!=e&&c.drawImage(e,0,0,this.canvas.width,this.canvas.height);e=this.getInputData(2);null==e?e=this.properties.fade:this.properties.fade=e;c.globalAlpha=e;e=this.getInputData(1);null!=e&&c.drawImage(e,0,0,this.canvas.width,this.canvas.height);c.globalAlpha=1;this.setOutputData(0,this.canvas);this.setDirtyCanvas(!0)};x.registerNodeType("graphics/imagefade",r);k.title="Crop";k.desc="Crop Image"; k.prototype.onAdded=function(){this.createCanvas()};k.prototype.createCanvas=function(){this.canvas=document.createElement("canvas");this.canvas.width=this.properties.width;this.canvas.height=this.properties.height};k.prototype.onExecute=function(){var c=this.getInputData(0);c&&(c.width?(this.canvas.getContext("2d").drawImage(c,-this.properties.x,-this.properties.y,c.width*this.properties.scale,c.height*this.properties.scale),this.setOutputData(0,this.canvas)):this.setOutputData(0,null))};k.prototype.onDrawBackground= function(c){this.flags.collapsed||this.canvas&&c.drawImage(this.canvas,0,0,this.canvas.width,this.canvas.height,0,0,this.size[0],this.size[1])};k.prototype.onPropertyChanged=function(c,e){this.properties[c]=e;"scale"==c?(this.properties[c]=parseFloat(e),0==this.properties[c]&&(this.trace("Error in scale"),this.properties[c]=1)):this.properties[c]=parseInt(e);this.createCanvas();return!0};x.registerNodeType("graphics/cropImage",k);y.title="Canvas";y.desc="Canvas to render stuff";y.prototype.onExecute= function(){var c=this.canvas,e=this.properties.width|0,f=this.properties.height|0;c.width!=e&&(c.width=e);c.height!=f&&(c.height=f);this.properties.autoclear&&this.ctx.clearRect(0,0,c.width,c.height);this.setOutputData(0,c)};y.prototype.onAction=function(c,e){"clear"==c&&this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height)};x.registerNodeType("graphics/canvas",y);u.title="DrawImage";u.desc="Draws image into a canvas";u.prototype.onExecute=function(){var c=this.getInputData(0);if(c){var e= @@ -393,9 +393,9 @@ this.trigger("stream_closed")}};e.prototype.onPropertyChanged=function(c,e){"fac function(){null!=this._webcam_stream||this._waiting_confirmation||this.openStream();if(this._video&&this._video.videoWidth){this._video.frame=++this.frame;this._video.width=this._video.videoWidth;this._video.height=this._video.videoHeight;this.setOutputData(0,this._video);for(var c=1;c=this.size[1]||!this.properties.show||!this._video||(c.save(),c.drawImage(this._video,0,0,this.size[0],this.size[1]),c.restore())};e.prototype.onGetOutputs=function(){return[["width","number"],["height","number"],["stream_ready",x.EVENT],["stream_closed",x.EVENT],["stream_error",x.EVENT]]}; x.registerNodeType("graphics/webcam",e)})(this); -(function(w){function c(){this.addOutput("Texture","Texture");this.properties={name:"",filter:!0};this.size=[c.image_preview_size,c.image_preview_size]}function r(){this.addInput("Texture","Texture");this.properties={flipY:!1};this.size=[c.image_preview_size,c.image_preview_size]}function l(){this.addInput("Texture","Texture");this.addOutput("tex","Texture");this.addOutput("name","string");this.properties={name:"",generate_mipmaps:!1}}function f(){this.addInput("Texture","Texture");this.addInput("TextureB", +(function(w){function c(){this.addOutput("Texture","Texture");this.properties={name:"",filter:!0};this.size=[c.image_preview_size,c.image_preview_size]}function s(){this.addInput("Texture","Texture");this.properties={flipY:!1};this.size=[c.image_preview_size,c.image_preview_size]}function l(){this.addInput("Texture","Texture");this.addOutput("tex","Texture");this.addOutput("name","string");this.properties={name:"",generate_mipmaps:!1}}function f(){this.addInput("Texture","Texture");this.addInput("TextureB", "Texture");this.addInput("value","number");this.addOutput("Texture","Texture");this.help="

pixelcode must be vec3, uvcode must be vec2, is optional

\t\t

uv: tex. coords

color: texture colorB: textureB

time: scene time value: input value

For multiline you must type: result = ...

";this.properties={value:1,pixelcode:"color + colorB * value",uvcode:"",precision:c.DEFAULT};this.has_error=!1} -function s(){this.addOutput("out","Texture");this.properties={code:"",u_value:1,u_color:[1,1,1,1],width:512,height:512,precision:c.DEFAULT};this.properties.code="//time: time in seconds\n//texSize: vec2 with res\nuniform float u_value;\nuniform vec4 u_color;\n\nvoid main() {\n vec2 uv = v_coord;\n vec3 color = vec3(0.0);\n\t//your code here\n\tcolor.xy=uv;\n\ngl_FragColor = vec4(color, 1.0);\n}\n";this._uniforms={u_value:1,u_color:vec4.create(),in_texture:0,texSize:vec2.create(),time:0}}function k(){this.addInput("in", +function r(){this.addOutput("out","Texture");this.properties={code:"",u_value:1,u_color:[1,1,1,1],width:512,height:512,precision:c.DEFAULT};this.properties.code="//time: time in seconds\n//texSize: vec2 with res\nuniform float u_value;\nuniform vec4 u_color;\n\nvoid main() {\n vec2 uv = v_coord;\n vec3 color = vec3(0.0);\n\t//your code here\n\tcolor.xy=uv;\n\ngl_FragColor = vec4(color, 1.0);\n}\n";this._uniforms={u_value:1,u_color:vec4.create(),in_texture:0,texSize:vec2.create(),time:0}}function k(){this.addInput("in", "Texture");this.addInput("scale","vec2");this.addInput("offset","vec2");this.addOutput("out","Texture");this.properties={offset:vec2.fromValues(0,0),scale:vec2.fromValues(1,1),precision:c.DEFAULT}}function y(){this.addInput("in","Texture");this.addInput("warp","Texture");this.addInput("factor","number");this.addOutput("out","Texture");this.properties={factor:0.01,scale:[1,1],offset:[0,0],precision:c.DEFAULT};this._uniforms={u_texture:0,u_textureB:1,u_factor:1,u_scale:vec2.create(),u_offset:vec2.create()}} function u(){this.addInput("Texture","Texture");this.properties={additive:!1,antialiasing:!1,filter:!0,disable_alpha:!1,gamma:1};this.size[0]=130}function v(){this.addInput("Texture","Texture");this.addOutput("","Texture");this.properties={size:0,generate_mipmaps:!1,precision:c.DEFAULT}}function z(){this.addInput("Texture","Texture");this.addOutput("","Texture");this.properties={iterations:1,generate_mipmaps:!1,precision:c.DEFAULT}}function e(){this.addInput("Texture","Texture");this.addOutput("tex", "Texture");this.addOutput("avg","vec4");this.addOutput("lum","number");this.properties={use_previous_frame:!0,high_quality:!1};this._uniforms={u_texture:0,u_mipmap_offset:0};this._luminance=new Float32Array(4)}function x(){this.addInput("Texture","Texture");this.addOutput("min_t","Texture");this.addOutput("max_t","Texture");this.addOutput("min","vec4");this.addOutput("max","vec4");this.properties={mode:"max",use_previous_frame:!0};this._uniforms={u_texture:0};this._max=new Float32Array(4);this._min= @@ -418,7 +418,7 @@ function(){var a=null;this.isOutputConnected(1)&&(a=this.getInputData(0));!a&&th (e=a.width/a.height);this.setOutputData(b,e)}}}},c.prototype.onResourceRenamed=function(a,b){this.properties.name==a&&(this.properties.name=b)},c.prototype.onDrawBackground=function(a){if(!(this.flags.collapsed||20>=this.size[1]))if(this._drop_texture&&a.webgl)a.drawImage(this._drop_texture,0,0,this.size[0],this.size[1]);else{if(this._last_preview_tex!=this._last_tex)if(a.webgl)this._canvas=this._last_tex;else{var b=c.generateLowResTexturePreview(this._last_tex);if(!b)return;this._last_preview_tex= this._last_tex;this._canvas=cloneCanvas(b)}this._canvas&&(a.save(),a.webgl||(a.translate(0,this.size[1]),a.scale(1,-1)),a.drawImage(this._canvas,0,0,this.size[0],this.size[1]),a.restore())}},c.generateLowResTexturePreview=function(a){if(!a)return null;var b=c.image_preview_size,d=a;if(a.format==gl.DEPTH_COMPONENT)return null;if(a.width>b||a.height>b)d=this._preview_temp_tex,this._preview_temp_tex||(this._preview_temp_tex=d=new GL.Texture(b,b,{minFilter:gl.NEAREST})),a.copyTo(d);a=this._preview_canvas; a||(this._preview_canvas=a=createCanvas(b,b));d&&d.toCanvas(a);return a},c.prototype.getResources=function(a){this.properties.name&&(a[this.properties.name]=GL.Texture);return a},c.prototype.onGetInputs=function(){return[["in","Texture"]]},c.prototype.onGetOutputs=function(){return[["width","number"],["height","number"],["aspect","number"]]},c.replaceCode=function(a,b){return a.replace(/\{\{[a-zA-Z0-9_]*\}\}/g,function(a){a=a.replace(/[\{\}]/g,"");return b[a]||""})},D.registerNodeType("texture/texture", -c),r.title="Preview",r.desc="Show a texture in the graph canvas",r.allow_preview=!1,r.prototype.onDrawBackground=function(a){if(!this.flags.collapsed&&(a.webgl||r.allow_preview)){var b=this.getInputData(0);if(b){var d=null,d=!b.handle&&a.webgl?b:c.generateLowResTexturePreview(b);a.save();this.properties.flipY&&(a.translate(0,this.size[1]),a.scale(1,-1));a.drawImage(d,0,0,this.size[0],this.size[1]);a.restore()}}},D.registerNodeType("texture/preview",r),l.title="Save",l.desc="Save a texture in the repository", +c),s.title="Preview",s.desc="Show a texture in the graph canvas",s.allow_preview=!1,s.prototype.onDrawBackground=function(a){if(!this.flags.collapsed&&(a.webgl||s.allow_preview)){var b=this.getInputData(0);if(b){var d=null,d=!b.handle&&a.webgl?b:c.generateLowResTexturePreview(b);a.save();this.properties.flipY&&(a.translate(0,this.size[1]),a.scale(1,-1));a.drawImage(d,0,0,this.size[0],this.size[1]);a.restore()}}},D.registerNodeType("texture/preview",s),l.title="Save",l.desc="Save a texture in the repository", l.prototype.getPreviewTexture=function(){return this._texture},l.prototype.onExecute=function(){var a=this.getInputData(0);a&&(this.properties.generate_mipmaps&&(a.bind(0),a.setParameter(gl.TEXTURE_MIN_FILTER,gl.LINEAR_MIPMAP_LINEAR),gl.generateMipmap(a.texture_type),a.unbind(0)),this.properties.name&&(c.storeTexture?c.storeTexture(this.properties.name,a):c.getTexturesContainer()[this.properties.name]=a),this._texture=a,this.setOutputData(0,a),this.setOutputData(1,this.properties.name))},D.registerNodeType("texture/save", l),f.widgets_info={uvcode:{widget:"code"},pixelcode:{widget:"code"},precision:{widget:"combo",values:c.MODE_VALUES}},f.title="Operation",f.desc="Texture shader operation",f.presets={},f.prototype.getExtraMenuOptions=function(a){var b=this;return[{content:b.properties.show?"Hide Texture":"Show Texture",callback:function(){b.properties.show=!b.properties.show}}]},f.prototype.onPropertyChanged=function(){this.has_error=!1},f.prototype.onDrawBackground=function(a){this.flags.collapsed||20>=this.size[1]|| !this.properties.show||!this._tex||this._tex.gl!=a||(a.save(),a.drawImage(this._tex,0,0,this.size[0],this.size[1]),a.restore())},f.prototype.onExecute=function(){var a=this.getInputData(0);if(this.isOutputConnected(0))if(this.properties.precision===c.PASS_THROUGH)this.setOutputData(0,a);else{var b=this.getInputData(1);if(this.properties.uvcode||this.properties.pixelcode){var d=512,e=512;a?(d=a.width,e=a.height):b&&(d=b.width,e=b.height);b||(b=GL.Texture.getWhiteTexture());var h=c.getTextureType(this.properties.precision, @@ -427,11 +427,11 @@ h+"|"+g)){var m=c.replaceCode(f.pixel_shader,{UV_CODE:h,PIXEL_CODE:g});try{k=new gl.disable(gl.BLEND);a&&a.bind(0);b&&b.bind(1);var c=Mesh.getScreenQuad();k.uniforms({u_texture:0,u_textureB:1,value:p,texSize:[d,e],time:n}).draw(c)});this.setOutputData(0,this._tex)}}}},f.pixel_shader="precision highp float;\n\t\t\n\t\tuniform sampler2D u_texture;\n\t\tuniform sampler2D u_textureB;\n\t\tvarying vec2 v_coord;\n\t\tuniform vec2 texSize;\n\t\tuniform float time;\n\t\tuniform float value;\n\t\t\n\t\tvoid main() {\n\t\t\tvec2 uv = v_coord;\n\t\t\t{{UV_CODE}};\n\t\t\tvec4 color4 = texture2D(u_texture, uv);\n\t\t\tvec3 color = color4.rgb;\n\t\t\tvec4 color4B = texture2D(u_textureB, uv);\n\t\t\tvec3 colorB = color4B.rgb;\n\t\t\tvec3 result = color;\n\t\t\tfloat alpha = 1.0;\n\t\t\t{{PIXEL_CODE}};\n\t\t\tgl_FragColor = vec4(result, alpha);\n\t\t}\n\t\t", f.registerPreset=function(a,b){f.presets[a]=b},f.registerPreset("",""),f.registerPreset("bypass","color"),f.registerPreset("add","color + colorB * value"),f.registerPreset("substract","(color - colorB) * value"),f.registerPreset("mate","mix( color, colorB, color4B.a * value)"),f.registerPreset("invert","vec3(1.0) - color"),f.registerPreset("multiply","color * colorB * value"),f.registerPreset("divide","(color / colorB) / value"),f.registerPreset("difference","abs(color - colorB) * value"),f.registerPreset("max", "max(color, colorB) * value"),f.registerPreset("min","min(color, colorB) * value"),f.registerPreset("displace","texture2D(u_texture, uv + (colorB.xy - vec2(0.5)) * value).xyz"),f.registerPreset("grayscale","vec3(color.x + color.y + color.z) * value / 3.0"),f.registerPreset("saturation","mix( vec3(color.x + color.y + color.z) / 3.0, color, value )"),f.registerPreset("threshold","vec3(color.x > colorB.x * value ? 1.0 : 0.0,color.y > colorB.y * value ? 1.0 : 0.0,color.z > colorB.z * value ? 1.0 : 0.0)"), -f.prototype.onInspect=function(a){var b=this;a.addCombo("Presets","",{values:Object.keys(f.presets),callback:function(c){var d=f.presets[c];d&&(b.setProperty("pixelcode",d),b.title=c,a.refresh())}})},D.registerNodeType("texture/operation",f),s.title="Shader",s.desc="Texture shader",s.widgets_info={code:{type:"code"},precision:{widget:"combo",values:c.MODE_VALUES}},s.prototype.onPropertyChanged=function(a,b){if("code"==a){var c=this.getShader();if(c){var d=c.uniformInfo;if(this.inputs)for(var e={}, +f.prototype.onInspect=function(a){var b=this;a.addCombo("Presets","",{values:Object.keys(f.presets),callback:function(c){var d=f.presets[c];d&&(b.setProperty("pixelcode",d),b.title=c,a.refresh())}})},D.registerNodeType("texture/operation",f),r.title="Shader",r.desc="Texture shader",r.widgets_info={code:{type:"code"},precision:{widget:"combo",values:c.MODE_VALUES}},r.prototype.onPropertyChanged=function(a,b){if("code"==a){var c=this.getShader();if(c){var d=c.uniformInfo;if(this.inputs)for(var e={}, h=0;h>=1;1<(d|0)&&(d>>=1);if(2>b)break;m=g[t]=GL.Texture.getTemporary(b,d,e);n[0]=1/q.width;n[1]=1/q.height;q.blit(m,k.uniforms(f));q=m}this.isOutputConnected(2)&&(b=this._average_texture,b&&b.type==a.type&&b.format==a.format||(b=this._average_texture=new GL.Texture(1,1,{type:a.type,format:a.format,filter:gl.LINEAR})),n[0]=1/q.width,n[1]=1/q.height,f.u_intensity=l,f.u_delta=1,q.blit(b,k.uniforms(f)),this.setOutputData(2,b));gl.enable(gl.BLEND);gl.blendFunc(gl.ONE,gl.ONE);f.u_intensity= this.getInputOrProperty("persistence");f.u_delta=0.5;for(t-=2;0<=t;t--)m=g[t],g[t]=null,n[0]=1/q.width,n[1]=1/q.height,q.blit(m,k.uniforms(f)),GL.Texture.releaseTemporary(q),q=m;gl.disable(gl.BLEND);this.isOutputConnected(1)&&(g=this._glow_texture,g&&g.width==a.width&&g.height==a.height&&g.type==h&&g.format==a.format||(g=this._glow_texture=new GL.Texture(a.width,a.height,{type:h,format:a.format,filter:gl.LINEAR})),q.blit(g),this.setOutputData(1,g));if(this.isOutputConnected(0)){g=this._final_texture; -g&&g.width==a.width&&g.height==a.height&&g.type==h&&g.format==a.format||(g=this._final_texture=new GL.Texture(a.width,a.height,{type:h,format:a.format,filter:gl.LINEAR}));var s=this.getInputData(1),u=this.getInputOrProperty("dirt_factor");f.u_intensity=l;k=s?E._dirt_final_shader:E._final_shader;k||(k=s?E._dirt_final_shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,E.final_pixel_shader,{USE_DIRT:""}):E._final_shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,E.final_pixel_shader));g.drawTo(function(){a.bind(0); -q.bind(1);s&&(k.setUniform("u_dirt_factor",u),k.setUniform("u_dirt_texture",s.bind(2)));k.toViewport(f)});this.setOutputData(0,g)}GL.Texture.releaseTemporary(q)}},E.cut_pixel_shader="precision highp float;\n\tvarying vec2 v_coord;\n\tuniform sampler2D u_texture;\n\tuniform float u_threshold;\n\tvoid main() {\n\t\tgl_FragColor = max( texture2D( u_texture, v_coord ) - vec4( u_threshold ), vec4(0.0) );\n\t}",E.scale_pixel_shader="precision highp float;\n\tvarying vec2 v_coord;\n\tuniform sampler2D u_texture;\n\tuniform vec2 u_texel_size;\n\tuniform float u_delta;\n\tuniform float u_intensity;\n\t\n\tvec4 sampleBox(vec2 uv) {\n\t\tvec4 o = u_texel_size.xyxy * vec2(-u_delta, u_delta).xxyy;\n\t\tvec4 s = texture2D( u_texture, uv + o.xy ) + texture2D( u_texture, uv + o.zy) + texture2D( u_texture, uv + o.xw) + texture2D( u_texture, uv + o.zw);\n\t\treturn s * 0.25;\n\t}\n\tvoid main() {\n\t\tgl_FragColor = u_intensity * sampleBox( v_coord );\n\t}", +g&&g.width==a.width&&g.height==a.height&&g.type==h&&g.format==a.format||(g=this._final_texture=new GL.Texture(a.width,a.height,{type:h,format:a.format,filter:gl.LINEAR}));var r=this.getInputData(1),u=this.getInputOrProperty("dirt_factor");f.u_intensity=l;k=r?E._dirt_final_shader:E._final_shader;k||(k=r?E._dirt_final_shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,E.final_pixel_shader,{USE_DIRT:""}):E._final_shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,E.final_pixel_shader));g.drawTo(function(){a.bind(0); +q.bind(1);r&&(k.setUniform("u_dirt_factor",u),k.setUniform("u_dirt_texture",r.bind(2)));k.toViewport(f)});this.setOutputData(0,g)}GL.Texture.releaseTemporary(q)}},E.cut_pixel_shader="precision highp float;\n\tvarying vec2 v_coord;\n\tuniform sampler2D u_texture;\n\tuniform float u_threshold;\n\tvoid main() {\n\t\tgl_FragColor = max( texture2D( u_texture, v_coord ) - vec4( u_threshold ), vec4(0.0) );\n\t}",E.scale_pixel_shader="precision highp float;\n\tvarying vec2 v_coord;\n\tuniform sampler2D u_texture;\n\tuniform vec2 u_texel_size;\n\tuniform float u_delta;\n\tuniform float u_intensity;\n\t\n\tvec4 sampleBox(vec2 uv) {\n\t\tvec4 o = u_texel_size.xyxy * vec2(-u_delta, u_delta).xxyy;\n\t\tvec4 s = texture2D( u_texture, uv + o.xy ) + texture2D( u_texture, uv + o.zy) + texture2D( u_texture, uv + o.xw) + texture2D( u_texture, uv + o.zw);\n\t\treturn s * 0.25;\n\t}\n\tvoid main() {\n\t\tgl_FragColor = u_intensity * sampleBox( v_coord );\n\t}", E.final_pixel_shader="precision highp float;\n\tvarying vec2 v_coord;\n\tuniform sampler2D u_texture;\n\tuniform sampler2D u_glow_texture;\n\t#ifdef USE_DIRT\n\t\tuniform sampler2D u_dirt_texture;\n\t#endif\n\tuniform vec2 u_texel_size;\n\tuniform float u_delta;\n\tuniform float u_intensity;\n\tuniform float u_dirt_factor;\n\t\n\tvec4 sampleBox(vec2 uv) {\n\t\tvec4 o = u_texel_size.xyxy * vec2(-u_delta, u_delta).xxyy;\n\t\tvec4 s = texture2D( u_glow_texture, uv + o.xy ) + texture2D( u_glow_texture, uv + o.zy) + texture2D( u_glow_texture, uv + o.xw) + texture2D( u_glow_texture, uv + o.zw);\n\t\treturn s * 0.25;\n\t}\n\tvoid main() {\n\t\tvec4 glow = sampleBox( v_coord );\n\t\t#ifdef USE_DIRT\n\t\t\tglow = mix( glow, glow * texture2D( u_dirt_texture, v_coord ), u_dirt_factor );\n\t\t#endif\n\t\tgl_FragColor = texture2D( u_texture, v_coord ) + u_intensity * glow;\n\t}", D.registerNodeType("texture/glow",E),G.title="Kuwahara Filter",G.desc="Filters a texture giving an artistic oil canvas painting",G.max_radius=10,G._shaders=[],G.prototype.onExecute=function(){var a=this.getInputData(0);if(a&&this.isOutputConnected(0)){var b=this._temp_texture;b&&b.width==a.width&&b.height==a.height&&b.type==a.type||(this._temp_texture=new GL.Texture(a.width,a.height,{type:a.type,format:gl.RGBA,filter:gl.LINEAR}));b=this.properties.radius;b=Math.min(Math.floor(b),G.max_radius);if(0== b)this.setOutputData(0,a);else{var c=this.properties.intensity,d=D.camera_aspect;d||void 0===window.gl||(d=gl.canvas.height/gl.canvas.width);d||(d=1);d=this.properties.preserve_aspect?d:1;G._shaders[b]||(G._shaders[b]=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,G.pixel_shader,{RADIUS:b.toFixed(0)}));var e=G._shaders[b],h=GL.Mesh.getScreenQuad();a.bind(0);this._temp_texture.drawTo(function(){e.uniforms({u_texture:0,u_intensity:c,u_resolution:[a.width,a.height],u_iResolution:[1/a.width,1/a.height]}).draw(h)}); @@ -519,51 +519,51 @@ precision:{widget:"combo",values:c.MODE_VALUES}},M.prototype.onExecute=function( (e=M._shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,M.pixel_shader));b.u_key_color=this.properties.key_color;b.u_threshold=this.properties.threshold;b.u_slope=this.properties.slope;this._tex.drawTo(function(){a.bind(0);e.uniforms(b).draw(d)});this.setOutputData(0,this._tex)}}},M.pixel_shader="precision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_texture;\n\t\tuniform vec3 u_key_color;\n\t\tuniform float u_threshold;\n\t\tuniform float u_slope;\n\t\t\n\t\tvoid main() {\n\t\t\tvec3 color = texture2D( u_texture, v_coord ).xyz;\n\t\t\tfloat diff = length( normalize(color) - normalize(u_key_color) );\n\t\t\tfloat edge = u_threshold * (1.0 - u_slope);\n\t\t\tfloat alpha = smoothstep( edge, u_threshold, diff);\n\t\t\tgl_FragColor = vec4( color, alpha );\n\t\t}", D.registerNodeType("texture/matte",M),N.title="CubemapToTexture2D",N.desc="Transforms a CUBEMAP texture into a TEXTURE2D in Polar Representation",N.prototype.onExecute=function(){if(this.isOutputConnected(0)){var a=this.getInputData(0);if(a&&a.texture_type==GL.TEXTURE_CUBE_MAP){!this._last_tex||this._last_tex.height==a.height&&this._last_tex.type==a.type||(this._last_tex=null);var b=this.getInputOrProperty("yaw");this._last_tex=GL.Texture.cubemapToTexture2D(a,a.height,this._last_tex,!0,b);this.setOutputData(0, this._last_tex)}}},D.registerNodeType("texture/cubemapToTexture2D",N))})(this); -(function(w){function c(){this.addOutput("out","geometry");this.addOutput("points","array");this.properties={radius:1,num_points:4096,regular:!1,mode:c.SPHERE};this.points=new Float32Array(3*this.properties.num_points);this.must_update=!0;this.version=0;this.geometry={vertices:null,_id:1E5*Math.random()|0}}function r(){this.addInput("mesh","mesh");this.addOutput("out","geometry");this.geometry={};this.last_mesh=null}function l(){this.addInput("in","geometry");this.addOutput("out","geometry");this.properties= -{code:"V[1] += 0.01 * Math.sin(I + T*0.001);",execute_every_frame:!1};this.geometry=null;this.version=this.geometry_id=-1;this.must_update=!0;this.func=this.vertices=null}function f(){this.addInput("in","geometry");this.addOutput("out","geometry");this.properties={min_dist:0.4,max_dist:0.5,max_connections:0,probability:1};this.version=this.geometry_id=-1;this.my_version=1;this.must_update=!0}function s(){this.addInput("in","geometry");this.addInput("mat4","mat4");this.addInput("tex","texture");this.addOutput("mesh", +(function(w){function c(){this.addOutput("out","geometry");this.addOutput("points","array");this.properties={radius:1,num_points:4096,regular:!1,mode:c.SPHERE};this.points=new Float32Array(3*this.properties.num_points);this.must_update=!0;this.version=0;this.geometry={vertices:null,_id:1E5*Math.random()|0}}function s(){this.addInput("mesh","mesh");this.addOutput("out","geometry");this.geometry={};this.last_mesh=null}function l(){this.addInput("in","geometry");this.addOutput("out","geometry");this.properties= +{code:"V[1] += 0.01 * Math.sin(I + T*0.001);",execute_every_frame:!1};this.geometry=null;this.version=this.geometry_id=-1;this.must_update=!0;this.func=this.vertices=null}function f(){this.addInput("in","geometry");this.addOutput("out","geometry");this.properties={min_dist:0.4,max_dist:0.5,max_connections:0,probability:1};this.version=this.geometry_id=-1;this.my_version=1;this.must_update=!0}function r(){this.addInput("in","geometry");this.addInput("mat4","mat4");this.addInput("tex","texture");this.addOutput("mesh", "mesh");this.properties={enabled:!0,primitive:GL.TRIANGLES,additive:!1,color:[1,1,1],opacity:1};this.color=vec4.create([1,1,1,1]);this.uniforms={u_color:this.color};this.version=-1;this.mesh=null}function k(){this.addInput("in","geometry");this.addInput("mat4","mat4");this.addInput("tex","texture");this.properties={enabled:!0,point_size:0.1,fixed_size:!1,additive:!0,color:[1,1,1],opacity:1};this.color=vec4.create([1,1,1,1]);this.uniforms={u_point_size:1,u_perspective:1,u_point_perspective:1,u_color:this.color}; this.version=this.geometry_id=-1;this.mesh=null}var y=w.LiteGraph,u=new Float32Array(16),v=new Float32Array(16),z=new Float32Array(16),e=new Float32Array(16),x={u_view:u,u_projection:v,u_viewprojection:z,u_model:e};y.LGraphRender={onRequestCameraMatrices:null};w.LGraphPoints3D=c;c.RECTANGLE=1;c.CIRCLE=2;c.CUBE=10;c.SPHERE=11;c.HEMISPHERE=12;c.INSIDE_SPHERE=13;c.MODE_VALUES={rectangle:c.RECTANGLE,circle:c.CIRCLE,cube:c.CUBE,sphere:c.SPHERE,hemisphere:c.HEMISPHERE,inside_sphere:c.INSIDE_SPHERE};c.widgets_info= {mode:{widget:"combo",values:c.MODE_VALUES}};c.title="list of points";c.desc="returns an array of points";c.prototype.onPropertyChanged=function(c,e){this.must_update=!0};c.prototype.onExecute=function(){this.must_update&&(this.must_update=!1,this.updatePoints());this.geometry.vertices=this.points;this.geometry._version=this.version;this.setOutputData(0,this.geometry)};c.generatePoints=function(e,f,k,h,q){var p=3*f;h&&h.length==p||(h=new Float32Array(p));if(q)if(k==c.RECTANGLE){p=Math.floor(Math.sqrt(f)); for(f=0;fe&&(e=1);this.points.length!=3*e&&(this.points=new Float32Array(3*e));this.points=c.generatePoints(this.properties.radius,e,this.properties.mode,this.points,this.properties.regular);this.version++};y.registerNodeType("geometry/points3D",c);r.title="to geometry";r.desc="converts a mesh to geometry";r.prototype.onExecute=function(){var c=this.getInputData(0);if(c){if(c!= -this.last_mesh){this.last_mesh=c;for(i in c.vertexBuffers)this.geometry[i]=c.vertexBuffers[i].data;c.indexBuffers.triangles&&(this.geometry.indices=c.indexBuffers.triangles.data);this.geometry._id=1E5*Math.random()|0;this.geometry._version=0}this.setOutputData(0,this.geometry);this.geometry&&this.setOutputData(1,this.geometry.vertices)}};y.registerNodeType("geometry/toGeometry",r);l.title="geoeval";l.desc="eval code";l.widgets_info={code:{widget:"code"}};l.prototype.onConfigure=function(c){this.compileCode()}; +2]=k*a}else console.warn("wrong mode in LGraphPoints3D");return h};c.prototype.updatePoints=function(){var e=this.properties.num_points|0;1>e&&(e=1);this.points.length!=3*e&&(this.points=new Float32Array(3*e));this.points=c.generatePoints(this.properties.radius,e,this.properties.mode,this.points,this.properties.regular);this.version++};y.registerNodeType("geometry/points3D",c);s.title="to geometry";s.desc="converts a mesh to geometry";s.prototype.onExecute=function(){var c=this.getInputData(0);if(c){if(c!= +this.last_mesh){this.last_mesh=c;for(i in c.vertexBuffers)this.geometry[i]=c.vertexBuffers[i].data;c.indexBuffers.triangles&&(this.geometry.indices=c.indexBuffers.triangles.data);this.geometry._id=1E5*Math.random()|0;this.geometry._version=0}this.setOutputData(0,this.geometry);this.geometry&&this.setOutputData(1,this.geometry.vertices)}};y.registerNodeType("geometry/toGeometry",s);l.title="geoeval";l.desc="eval code";l.widgets_info={code:{widget:"code"}};l.prototype.onConfigure=function(c){this.compileCode()}; l.prototype.compileCode=function(){if(this.properties.code)try{this.func=new Function("V","I","T",this.properties.code),this.boxcolor="#AFA",this.must_update=!0}catch(c){this.boxcolor="red"}};l.prototype.onPropertyChanged=function(c,e){"code"==c&&(this.properties.code=e,this.compileCode())};l.prototype.onExecute=function(){var c=this.getInputData(0);if(c)if(this.func){if(this.geometry_id!=c._id||this.version!=c._version||this.must_update||this.properties.execute_every_frame){this.must_update=!1;this.geometry_id= c._id;this.properties.execute_every_frame?this.version++:this.version=c._version;var e=this.func,f=getTime();this.geometry||(this.geometry={});for(var h in c)null!=c[h]&&(this.geometry[h]=c[h].constructor==Float32Array?new Float32Array(c[h]):c[h]);this.geometry._id=c._id;this.geometry._version=this.properties.execute_every_frame?this.version:c._version+1;var k=vec3.create(),p=this.vertices;p&&this.vertices.length==c.vertices.length?p.set(c.vertices):p=this.vertices=new Float32Array(c.vertices);for(h= 0;hk||rp&& -pa))break}this.geometry.indices=this.indices=new Uint32Array(b)}this.indices&&this.indices.length?(this.geometry.indices=this.indices,this.setOutputData(0,this.geometry)):this.setOutputData(0,null)}};y.registerNodeType("geometry/connectPoints",f);"undefined"!=typeof GL&&(s.title="render",s.desc="renders a geometry",s.PRIMITIVE_VALUES={points:GL.POINTS,lines:GL.LINES,line_loop:GL.LINE_LOOP,line_strip:GL.LINE_STRIP,triangles:GL.TRIANGLES,triangle_fan:GL.TRIANGLE_FAN, -triangle_strip:GL.TRIANGLE_STRIP},s.widgets_info={primitive:{widget:"combo",values:s.PRIMITIVE_VALUES},color:{widget:"color"}},s.prototype.updateMesh=function(c){this.mesh||(this.mesh=new GL.Mesh);for(var e in c)if("_"!=e[0]){var f=c[e],h=GL.Mesh.common_buffers[e];if(h||"indices"==e){var h=h?h.spacing:3,k=this.mesh.vertexBuffers[e];k&&k.data.length==f.length?(k.data.set(f),k.upload(GL.DYNAMIC_DRAW)):k=new GL.Buffer("indices"==e?GL.ELEMENT_ARRAY_BUFFER:GL.ARRAY_BUFFER,f,h,GL.DYNAMIC_DRAW);this.mesh.addBuffer(e, -k)}}this.geometry_id=this.mesh.id=c._id;this.version=this.mesh.version=c._version;return this.mesh},s.prototype.onExecute=function(){if(this.properties.enabled){var c=this.getInputData(0);if(c)if(this.version==c._version&&this.geometry_id==c._id||this.updateMesh(c),y.LGraphRender.onRequestCameraMatrices){y.LGraphRender.onRequestCameraMatrices(u,v,z);c=null;this.getInputData(2)?(c=gl.shaders.textured)||(c=gl.shaders.textured=new GL.Shader(k.vertex_shader_code,k.fragment_shader_code,{USE_TEXTURE:""})): +!1;this.geometry_id=c._id;this.version=c._version;this.geometry={};for(var e in c)this.geometry[e]=c[e];this.geometry._id=1E5*Math.random()|0;this.geometry._version=this.my_version++;var c=c.vertices,f=c.length,h=this.properties.min_dist,k=this.properties.max_dist,p=this.properties.probability,a=this.properties.max_connections,b=[];for(e=0;ek||sp&& +pa))break}this.geometry.indices=this.indices=new Uint32Array(b)}this.indices&&this.indices.length?(this.geometry.indices=this.indices,this.setOutputData(0,this.geometry)):this.setOutputData(0,null)}};y.registerNodeType("geometry/connectPoints",f);"undefined"!=typeof GL&&(r.title="render",r.desc="renders a geometry",r.PRIMITIVE_VALUES={points:GL.POINTS,lines:GL.LINES,line_loop:GL.LINE_LOOP,line_strip:GL.LINE_STRIP,triangles:GL.TRIANGLES,triangle_fan:GL.TRIANGLE_FAN, +triangle_strip:GL.TRIANGLE_STRIP},r.widgets_info={primitive:{widget:"combo",values:r.PRIMITIVE_VALUES},color:{widget:"color"}},r.prototype.updateMesh=function(c){this.mesh||(this.mesh=new GL.Mesh);for(var e in c)if("_"!=e[0]){var f=c[e],h=GL.Mesh.common_buffers[e];if(h||"indices"==e){var h=h?h.spacing:3,k=this.mesh.vertexBuffers[e];k&&k.data.length==f.length?(k.data.set(f),k.upload(GL.DYNAMIC_DRAW)):k=new GL.Buffer("indices"==e?GL.ELEMENT_ARRAY_BUFFER:GL.ARRAY_BUFFER,f,h,GL.DYNAMIC_DRAW);this.mesh.addBuffer(e, +k)}}this.geometry_id=this.mesh.id=c._id;this.version=this.mesh.version=c._version;return this.mesh},r.prototype.onExecute=function(){if(this.properties.enabled){var c=this.getInputData(0);if(c)if(this.version==c._version&&this.geometry_id==c._id||this.updateMesh(c),y.LGraphRender.onRequestCameraMatrices){y.LGraphRender.onRequestCameraMatrices(u,v,z);c=null;this.getInputData(2)?(c=gl.shaders.textured)||(c=gl.shaders.textured=new GL.Shader(k.vertex_shader_code,k.fragment_shader_code,{USE_TEXTURE:""})): (c=gl.shaders.flat)||(c=gl.shaders.flat=new GL.Shader(k.vertex_shader_code,k.fragment_shader_code));this.color.set(this.properties.color);this.color[3]=this.properties.opacity;var f=this.getInputData(1);f?e.set(f):mat4.identity(e);this.uniforms.u_point_size=1;f=this.properties.primitive;c.uniforms(x);c.uniforms(this.uniforms);1<=this.properties.opacity?gl.disable(gl.BLEND):gl.enable(gl.BLEND);gl.enable(gl.DEPTH_TEST);this.properties.additive?(gl.blendFunc(gl.SRC_ALPHA,gl.ONE),gl.depthMask(!1)):gl.blendFunc(gl.SRC_ALPHA, -gl.ONE_MINUS_SRC_ALPHA);c.draw(this.mesh,f,"indices");gl.disable(gl.BLEND);gl.depthMask(!0)}else console.warn("cannot render geometry, LiteGraph.onRequestCameraMatrices is null, remember to fill this with a callback(view_matrix, projection_matrix,viewprojection_matrix) to use 3D rendering from the graph")}},y.registerNodeType("geometry/render",s),k.widgets_info={color:{widget:"color"}},k.prototype.updateMesh=function(c){this.buffer&&this.buffer.data.length==c.vertices.length?(this.buffer.data.set(c.vertices), +gl.ONE_MINUS_SRC_ALPHA);c.draw(this.mesh,f,"indices");gl.disable(gl.BLEND);gl.depthMask(!0)}else console.warn("cannot render geometry, LiteGraph.onRequestCameraMatrices is null, remember to fill this with a callback(view_matrix, projection_matrix,viewprojection_matrix) to use 3D rendering from the graph")}},y.registerNodeType("geometry/render",r),k.widgets_info={color:{widget:"color"}},k.prototype.updateMesh=function(c){this.buffer&&this.buffer.data.length==c.vertices.length?(this.buffer.data.set(c.vertices), this.buffer.upload(GL.DYNAMIC_DRAW)):this.buffer=new GL.Buffer(GL.ARRAY_BUFFER,c.vertices,3,GL.DYNAMIC_DRAW);this.mesh||(this.mesh=new GL.Mesh);this.mesh.addBuffer("vertices",this.buffer);this.geometry_id=this.mesh.id=c._id;this.version=this.mesh.version=c._version},k.prototype.onExecute=function(){if(this.properties.enabled){var c=this.getInputData(0);if(c)if(this.version==c._version&&this.geometry_id==c._id||this.updateMesh(c),y.LGraphRender.onRequestCameraMatrices){y.LGraphRender.onRequestCameraMatrices(u, v,z);c=null;this.getInputData(2)?(c=gl.shaders.textured_points)||(c=gl.shaders.textured_points=new GL.Shader(k.vertex_shader_code,k.fragment_shader_code,{USE_TEXTURED_POINTS:""})):(c=gl.shaders.points)||(c=gl.shaders.points=new GL.Shader(k.vertex_shader_code,k.fragment_shader_code,{USE_POINTS:""}));this.color.set(this.properties.color);this.color[3]=this.properties.opacity;var f=this.getInputData(1);f?e.set(f):mat4.identity(e);this.uniforms.u_point_size=this.properties.point_size;this.uniforms.u_point_perspective= this.properties.fixed_size?0:1;this.uniforms.u_perspective=gl.viewport_data[3]*v[5];c.uniforms(x);c.uniforms(this.uniforms);1<=this.properties.opacity?gl.disable(gl.BLEND):gl.enable(gl.BLEND);gl.enable(gl.DEPTH_TEST);this.properties.additive?(gl.blendFunc(gl.SRC_ALPHA,gl.ONE),gl.depthMask(!1)):gl.blendFunc(gl.SRC_ALPHA,gl.ONE_MINUS_SRC_ALPHA);c.draw(this.mesh,GL.POINTS);gl.disable(gl.BLEND);gl.depthMask(!0)}else console.warn("cannot render geometry, LiteGraph.onRequestCameraMatrices is null, remember to fill this with a callback(view_matrix, projection_matrix,viewprojection_matrix) to use 3D rendering from the graph")}}, y.registerNodeType("geometry/render_points",k),k.vertex_shader_code="\t\tprecision mediump float;\n\t\tattribute vec3 a_vertex;\n\t\tvarying vec3 v_vertex;\n\t\tattribute vec3 a_normal;\n\t\tvarying vec3 v_normal;\n\t\t#ifdef USE_COLOR\n\t\t\tattribute vec4 a_color;\n\t\t\tvarying vec4 v_color;\n\t\t#endif\n\t\tattribute vec2 a_coord;\n\t\tvarying vec2 v_coord;\n\t\t#ifdef USE_SIZE\n\t\t\tattribute float a_extra;\n\t\t#endif\n\t\t#ifdef USE_INSTANCING\n\t\t\tattribute mat4 u_model;\n\t\t#else\n\t\t\tuniform mat4 u_model;\n\t\t#endif\n\t\tuniform mat4 u_viewprojection;\n\t\tuniform float u_point_size;\n\t\tuniform float u_perspective;\n\t\tuniform float u_point_perspective;\n\t\tfloat computePointSize(float radius, float w)\n\t\t{\n\t\t\tif(radius < 0.0)\n\t\t\t\treturn -radius;\n\t\t\treturn u_perspective * radius / w;\n\t\t}\n\t\tvoid main() {\n\t\t\tv_coord = a_coord;\n\t\t\t#ifdef USE_COLOR\n\t\t\t\tv_color = a_color;\n\t\t\t#endif\n\t\t\tv_vertex = ( u_model * vec4( a_vertex, 1.0 )).xyz;\n\t\t\tv_normal = ( u_model * vec4( a_normal, 0.0 )).xyz;\n\t\t\tgl_Position = u_viewprojection * vec4(v_vertex,1.0);\n\t\t\tgl_PointSize = u_point_size;\n\t\t\t#ifdef USE_SIZE\n\t\t\t\tgl_PointSize = a_extra;\n\t\t\t#endif\n\t\t\tif(u_point_perspective != 0.0)\n\t\t\t\tgl_PointSize = computePointSize( gl_PointSize, gl_Position.w );\n\t\t}\t", k.fragment_shader_code="\t\tprecision mediump float;\n\t\tuniform vec4 u_color;\n\t\t#ifdef USE_COLOR\n\t\t\tvarying vec4 v_color;\n\t\t#endif\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_texture;\n\t\tvoid main() {\n\t\t\tvec4 color = u_color;\n\t\t\t#ifdef USE_TEXTURED_POINTS\n\t\t\t\tcolor *= texture2D(u_texture, gl_PointCoord.xy);\n\t\t\t#else\n\t\t\t\t#ifdef USE_TEXTURE\n\t\t\t\t color *= texture2D(u_texture, v_coord);\n\t\t\t\t if(color.a < 0.1)\n\t\t\t\t\tdiscard;\n\t\t\t\t#endif\n\t\t\t\t#ifdef USE_POINTS\n\t\t\t\t\tfloat dist = length( gl_PointCoord.xy - vec2(0.5) );\n\t\t\t\t\tif( dist > 0.45 )\n\t\t\t\t\t\tdiscard;\n\t\t\t\t#endif\n\t\t\t#endif\n\t\t\t#ifdef USE_COLOR\n\t\t\t\tcolor *= v_color;\n\t\t\t#endif\n\t\t\tgl_FragColor = color;\n\t\t}\t")})(this); -(function(w){var c=w.LiteGraph;if("undefined"!=typeof GL){var r=function(){this.addInput("Texture","Texture");this.addInput("Aberration","number");this.addInput("Distortion","number");this.addInput("Blur","number");this.addOutput("Texture","Texture");this.properties={aberration:1,distortion:1,blur:1,precision:LGraphTexture.DEFAULT};r._shader||(r._shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,r.pixel_shader),r._texture=new GL.Texture(3,1,{format:gl.RGB,wrap:gl.CLAMP_TO_EDGE,magFilter:gl.LINEAR, -minFilter:gl.LINEAR,pixel_data:[255,0,0,0,255,0,0,0,255]}))};r.title="Lens";r.desc="Camera Lens distortion";r.widgets_info={precision:{widget:"combo",values:LGraphTexture.MODE_VALUES}};r.prototype.onExecute=function(){var c=this.getInputData(0);if(this.properties.precision===LGraphTexture.PASS_THROUGH)this.setOutputData(0,c);else if(c){this._tex=LGraphTexture.getTargetTexture(c,this._tex,this.properties.precision);var f=this.properties.aberration;this.isInputConnected(1)&&(f=this.getInputData(1), -this.properties.aberration=f);var l=this.properties.distortion;this.isInputConnected(2)&&(l=this.getInputData(2),this.properties.distortion=l);var s=this.properties.blur;this.isInputConnected(3)&&(s=this.getInputData(3),this.properties.blur=s);gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var w=Mesh.getScreenQuad(),e=r._shader;this._tex.drawTo(function(){c.bind(0);e.uniforms({u_texture:0,u_aberration:f,u_distortion:l,u_blur:s}).draw(w)});this.setOutputData(0,this._tex)}};r.pixel_shader="precision highp float;\n\t\t\tprecision highp float;\n\t\t\tvarying vec2 v_coord;\n\t\t\tuniform sampler2D u_texture;\n\t\t\tuniform vec2 u_camera_planes;\n\t\t\tuniform float u_aberration;\n\t\t\tuniform float u_distortion;\n\t\t\tuniform float u_blur;\n\t\t\t\n\t\t\tvoid main() {\n\t\t\t\tvec2 coord = v_coord;\n\t\t\t\tfloat dist = distance(vec2(0.5), coord);\n\t\t\t\tvec2 dist_coord = coord - vec2(0.5);\n\t\t\t\tfloat percent = 1.0 + ((0.5 - dist) / 0.5) * u_distortion;\n\t\t\t\tdist_coord *= percent;\n\t\t\t\tcoord = dist_coord + vec2(0.5);\n\t\t\t\tvec4 color = texture2D(u_texture,coord, u_blur * dist);\n\t\t\t\tcolor.r = texture2D(u_texture,vec2(0.5) + dist_coord * (1.0+0.01*u_aberration), u_blur * dist ).r;\n\t\t\t\tcolor.b = texture2D(u_texture,vec2(0.5) + dist_coord * (1.0-0.01*u_aberration), u_blur * dist ).b;\n\t\t\t\tgl_FragColor = color;\n\t\t\t}\n\t\t\t"; -c.registerNodeType("fx/lens",r);w.LGraphFXLens=r;var l=function(){this.addInput("Texture","Texture");this.addInput("Blurred","Texture");this.addInput("Mask","Texture");this.addInput("Threshold","number");this.addOutput("Texture","Texture");this.properties={shape:"",size:10,alpha:1,threshold:1,high_precision:!1}};l.title="Bokeh";l.desc="applies an Bokeh effect";l.widgets_info={shape:{widget:"texture"}};l.prototype.onExecute=function(){var c=this.getInputData(0),f=this.getInputData(1),s=this.getInputData(2); -if(c&&s&&this.properties.shape){f||(f=c);var r=LGraphTexture.getTexture(this.properties.shape);if(r){var w=this.properties.threshold;this.isInputConnected(3)&&(w=this.getInputData(3),this.properties.threshold=w);var e=gl.UNSIGNED_BYTE;this.properties.high_precision&&(e=gl.half_float_ext?gl.HALF_FLOAT_OES:gl.FLOAT);this._temp_texture&&this._temp_texture.type==e&&this._temp_texture.width==c.width&&this._temp_texture.height==c.height||(this._temp_texture=new GL.Texture(c.width,c.height,{type:e,format:gl.RGBA, +(function(w){var c=w.LiteGraph;if("undefined"!=typeof GL){var s=function(){this.addInput("Texture","Texture");this.addInput("Aberration","number");this.addInput("Distortion","number");this.addInput("Blur","number");this.addOutput("Texture","Texture");this.properties={aberration:1,distortion:1,blur:1,precision:LGraphTexture.DEFAULT};s._shader||(s._shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,s.pixel_shader),s._texture=new GL.Texture(3,1,{format:gl.RGB,wrap:gl.CLAMP_TO_EDGE,magFilter:gl.LINEAR, +minFilter:gl.LINEAR,pixel_data:[255,0,0,0,255,0,0,0,255]}))};s.title="Lens";s.desc="Camera Lens distortion";s.widgets_info={precision:{widget:"combo",values:LGraphTexture.MODE_VALUES}};s.prototype.onExecute=function(){var c=this.getInputData(0);if(this.properties.precision===LGraphTexture.PASS_THROUGH)this.setOutputData(0,c);else if(c){this._tex=LGraphTexture.getTargetTexture(c,this._tex,this.properties.precision);var f=this.properties.aberration;this.isInputConnected(1)&&(f=this.getInputData(1), +this.properties.aberration=f);var l=this.properties.distortion;this.isInputConnected(2)&&(l=this.getInputData(2),this.properties.distortion=l);var r=this.properties.blur;this.isInputConnected(3)&&(r=this.getInputData(3),this.properties.blur=r);gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var w=Mesh.getScreenQuad(),e=s._shader;this._tex.drawTo(function(){c.bind(0);e.uniforms({u_texture:0,u_aberration:f,u_distortion:l,u_blur:r}).draw(w)});this.setOutputData(0,this._tex)}};s.pixel_shader="precision highp float;\n\t\t\tprecision highp float;\n\t\t\tvarying vec2 v_coord;\n\t\t\tuniform sampler2D u_texture;\n\t\t\tuniform vec2 u_camera_planes;\n\t\t\tuniform float u_aberration;\n\t\t\tuniform float u_distortion;\n\t\t\tuniform float u_blur;\n\t\t\t\n\t\t\tvoid main() {\n\t\t\t\tvec2 coord = v_coord;\n\t\t\t\tfloat dist = distance(vec2(0.5), coord);\n\t\t\t\tvec2 dist_coord = coord - vec2(0.5);\n\t\t\t\tfloat percent = 1.0 + ((0.5 - dist) / 0.5) * u_distortion;\n\t\t\t\tdist_coord *= percent;\n\t\t\t\tcoord = dist_coord + vec2(0.5);\n\t\t\t\tvec4 color = texture2D(u_texture,coord, u_blur * dist);\n\t\t\t\tcolor.r = texture2D(u_texture,vec2(0.5) + dist_coord * (1.0+0.01*u_aberration), u_blur * dist ).r;\n\t\t\t\tcolor.b = texture2D(u_texture,vec2(0.5) + dist_coord * (1.0-0.01*u_aberration), u_blur * dist ).b;\n\t\t\t\tgl_FragColor = color;\n\t\t\t}\n\t\t\t"; +c.registerNodeType("fx/lens",s);w.LGraphFXLens=s;var l=function(){this.addInput("Texture","Texture");this.addInput("Blurred","Texture");this.addInput("Mask","Texture");this.addInput("Threshold","number");this.addOutput("Texture","Texture");this.properties={shape:"",size:10,alpha:1,threshold:1,high_precision:!1}};l.title="Bokeh";l.desc="applies an Bokeh effect";l.widgets_info={shape:{widget:"texture"}};l.prototype.onExecute=function(){var c=this.getInputData(0),f=this.getInputData(1),r=this.getInputData(2); +if(c&&r&&this.properties.shape){f||(f=c);var s=LGraphTexture.getTexture(this.properties.shape);if(s){var w=this.properties.threshold;this.isInputConnected(3)&&(w=this.getInputData(3),this.properties.threshold=w);var e=gl.UNSIGNED_BYTE;this.properties.high_precision&&(e=gl.half_float_ext?gl.HALF_FLOAT_OES:gl.FLOAT);this._temp_texture&&this._temp_texture.type==e&&this._temp_texture.width==c.width&&this._temp_texture.height==c.height||(this._temp_texture=new GL.Texture(c.width,c.height,{type:e,format:gl.RGBA, filter:gl.LINEAR}));var x=l._first_shader;x||(x=l._first_shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,l._first_pixel_shader));var g=l._second_shader;g||(g=l._second_shader=new GL.Shader(l._second_vertex_shader,l._second_pixel_shader));var m=this._points_mesh;m&&m._width==c.width&&m._height==c.height&&2==m._spacing||(m=this.createPointsMesh(c.width,c.height,2));var C=Mesh.getScreenQuad(),h=this.properties.size,q=this.properties.alpha;gl.disable(gl.DEPTH_TEST);gl.disable(gl.BLEND);this._temp_texture.drawTo(function(){c.bind(0); -f.bind(1);s.bind(2);x.uniforms({u_texture:0,u_texture_blur:1,u_mask:2,u_texsize:[c.width,c.height]}).draw(C)});this._temp_texture.drawTo(function(){gl.enable(gl.BLEND);gl.blendFunc(gl.ONE,gl.ONE);c.bind(0);r.bind(3);g.uniforms({u_texture:0,u_mask:2,u_shape:3,u_alpha:q,u_threshold:w,u_pointSize:h,u_itexsize:[1/c.width,1/c.height]}).draw(m,gl.POINTS)});this.setOutputData(0,this._temp_texture)}}else this.setOutputData(0,c)};l.prototype.createPointsMesh=function(c,f,l){for(var s=Math.round(c/l),r=Math.round(f/ -l),e=new Float32Array(s*r*2),w=-1,g=2/c*l,m=2/f*l,C=0;Cg&&(g=12+g);return c.notes[g]+(f?"":a)};c.NoteStringToPitch=function(e){e=e.toUpperCase();var f=e[0],g=4;"#"==e[1]?(f+="#",2this.properties.max_value)return;this.trigger("on_midi",f)}};m.registerNodeType("midi/filter",k);y.title="MIDIEvent";y.desc="Create a MIDI Event";y.color="#243";y.prototype.onAction=function(e,f){"assign"== e?(this.properties.channel=f.channel,this.properties.cmd=f.cmd,this.properties.value1=f.data[1],this.properties.value2=f.data[2],f.cmd==c.NOTEON?this.gate=!0:f.cmd==c.NOTEOFF&&(this.gate=!1)):(f=this.midi_event,f.channel=this.properties.channel,this.properties.cmd&&this.properties.cmd.constructor===String?f.setCommandFromString(this.properties.cmd):f.cmd=this.properties.cmd,f.data[0]=f.cmd|f.channel,f.data[1]=Number(this.properties.value1),f.data[2]=Number(this.properties.value2),this.trigger("on_midi", f))};y.prototype.onExecute=function(){var e=this.properties;if(this.inputs)for(var f=0;fk+n||c[1]>d))return b}}return-1};g.prototype.onAction=function(e,f){if("reset"==e)for(var g=0;gf[1])){var g=this.getKeyIndex(f);this.keys[g]=!0;this._last_key= g;var g=12*(this.properties.start_octave-1)+29+g,a=new c;a.setup([c.NOTEON,g,100]);this.trigger("note",a);return!0}};g.prototype.onMouseMove=function(e,f){if(!(0>f[1]||-1==this._last_key)){this.setDirtyCanvas(!0);var g=this.getKeyIndex(f);if(this._last_key==g)return!0;this.keys[this._last_key]=!1;var a=12*(this.properties.start_octave-1)+29+this._last_key,b=new c;b.setup([c.NOTEOFF,a,100]);this.trigger("note",b);this.keys[g]=!0;a=12*(this.properties.start_octave-1)+29+g;b=new c;b.setup([c.NOTEON, a,100]);this.trigger("note",b);this._last_key=g;return!0}};g.prototype.onMouseUp=function(e,f){if(!(0>f[1])){var g=this.getKeyIndex(f);this.keys[g]=!1;this._last_key=-1;var g=12*(this.properties.start_octave-1)+29+g,a=new c;a.setup([c.NOTEOFF,g,100]);this.trigger("note",a);return!0}};m.registerNodeType("midi/keys",g)})(this); -(function(w){function c(){this.properties={src:"",gain:0.5,loop:!0,autoplay:!0,playbackRate:1};this._loading_audio=!1;this._audiobuffer=null;this._audionodes=[];this._last_sourcenode=null;this.addOutput("out","audio");this.addInput("gain","number");this.audionode=p.getAudioContext().createGain();this.audionode.graphnode=this;this.audionode.gain.value=this.properties.gain;this.properties.src&&this.loadSound(this.properties.src)}function r(){this.properties={gain:0.5};this._audionodes=[];this._media_stream= +(function(w){function c(){this.properties={src:"",gain:0.5,loop:!0,autoplay:!0,playbackRate:1};this._loading_audio=!1;this._audiobuffer=null;this._audionodes=[];this._last_sourcenode=null;this.addOutput("out","audio");this.addInput("gain","number");this.audionode=p.getAudioContext().createGain();this.audionode.graphnode=this;this.audionode.gain.value=this.properties.gain;this.properties.src&&this.loadSound(this.properties.src)}function s(){this.properties={gain:0.5};this._audionodes=[];this._media_stream= null;this.addOutput("out","audio");this.addInput("gain","number");this.audionode=p.getAudioContext().createGain();this.audionode.graphnode=this;this.audionode.gain.value=this.properties.gain}function l(){this.properties={fftSize:2048,minDecibels:-100,maxDecibels:-10,smoothingTimeConstant:0.5};this.audionode=p.getAudioContext().createAnalyser();this.audionode.graphnode=this;this.audionode.fftSize=this.properties.fftSize;this.audionode.minDecibels=this.properties.minDecibels;this.audionode.maxDecibels= -this.properties.maxDecibels;this.audionode.smoothingTimeConstant=this.properties.smoothingTimeConstant;this.addInput("in","audio");this.addOutput("freqs","array");this.addOutput("samples","array");this._time_bin=this._freq_bin=null}function f(){this.properties={gain:1};this.audionode=p.getAudioContext().createGain();this.addInput("in","audio");this.addInput("gain","number");this.addOutput("out","audio")}function s(){this.properties={impulse_src:"",normalize:!0};this.audionode=p.getAudioContext().createConvolver(); +this.properties.maxDecibels;this.audionode.smoothingTimeConstant=this.properties.smoothingTimeConstant;this.addInput("in","audio");this.addOutput("freqs","array");this.addOutput("samples","array");this._time_bin=this._freq_bin=null}function f(){this.properties={gain:1};this.audionode=p.getAudioContext().createGain();this.addInput("in","audio");this.addInput("gain","number");this.addOutput("out","audio")}function r(){this.properties={impulse_src:"",normalize:!0};this.audionode=p.getAudioContext().createConvolver(); this.addInput("in","audio");this.addOutput("out","audio")}function k(){this.properties={threshold:-50,knee:40,ratio:12,reduction:-20,attack:0,release:0.25};this.audionode=p.getAudioContext().createDynamicsCompressor();this.addInput("in","audio");this.addOutput("out","audio")}function y(){this.properties={};this.audionode=p.getAudioContext().createWaveShaper();this.addInput("in","audio");this.addInput("shape","waveshape");this.addOutput("out","audio")}function u(){this.properties={gain1:0.5,gain2:0.5}; this.audionode=p.getAudioContext().createGain();this.audionode1=p.getAudioContext().createGain();this.audionode1.gain.value=this.properties.gain1;this.audionode2=p.getAudioContext().createGain();this.audionode2.gain.value=this.properties.gain2;this.audionode1.connect(this.audionode);this.audionode2.connect(this.audionode);this.addInput("in1","audio");this.addInput("in1 gain","number");this.addInput("in2","audio");this.addInput("in2 gain","number");this.addOutput("out","audio")}function v(){this.properties= {A:0.1,D:0.1,S:0.1,R:0.1};this.audionode=p.getAudioContext().createGain();this.audionode.gain.value=0;this.addInput("in","audio");this.addInput("gate","bool");this.addOutput("out","audio");this.gate=!1}function z(){this.properties={delayTime:0.5};this.audionode=p.getAudioContext().createDelay(10);this.audionode.delayTime.value=this.properties.delayTime;this.addInput("in","audio");this.addInput("time","number");this.addOutput("out","audio")}function e(){this.properties={frequency:350,detune:0,Q:1}; @@ -620,15 +620,15 @@ this.properties.autoplay&&this.playBuffer(this._audiobuffer)};c.prototype.onStop 0;a