diff --git a/build/litegraph.js b/build/litegraph.js index 0acdb4083..5c4a5569c 100644 --- a/build/litegraph.js +++ b/build/litegraph.js @@ -2359,6 +2359,7 @@ LGraphNode.prototype.addOutput = function(name,type,extra_info) if(this.onOutputAdded) this.onOutputAdded(o); this.size = this.computeSize(); + this.setDirtyCanvas(true,true); return o; } @@ -2385,6 +2386,7 @@ LGraphNode.prototype.addOutputs = function(array) } this.size = this.computeSize(); + this.setDirtyCanvas(true,true); } /** @@ -2396,9 +2398,24 @@ LGraphNode.prototype.removeOutput = function(slot) { this.disconnectOutput(slot); this.outputs.splice(slot,1); + for(var i = slot; i < this.outputs.length; ++i) + { + if( !this.outputs[i] || !this.outputs[i].links ) + continue; + var links = this.outputs[i].links; + for(var j = 0; j < links.length; ++j) + { + var link = this.graph.links[ links[j] ]; + if(!link) + continue; + link.origin_slot -= 1; + } + } + this.size = this.computeSize(); if(this.onOutputRemoved) this.onOutputRemoved(slot); + this.setDirtyCanvas(true,true); } /** @@ -2422,6 +2439,7 @@ LGraphNode.prototype.addInput = function(name,type,extra_info) this.size = this.computeSize(); if(this.onInputAdded) this.onInputAdded(o); + this.setDirtyCanvas(true,true); return o; } @@ -2448,6 +2466,7 @@ LGraphNode.prototype.addInputs = function(array) } this.size = this.computeSize(); + this.setDirtyCanvas(true,true); } /** @@ -2459,9 +2478,19 @@ LGraphNode.prototype.removeInput = function(slot) { this.disconnectInput(slot); this.inputs.splice(slot,1); + for(var i = slot; i < this.inputs.length; ++i) + { + if(!this.inputs[i]) + continue; + var link = this.graph.links[ this.inputs[i].link ]; + if(!link) + continue; + link.target_slot -= 1; + } this.size = this.computeSize(); if(this.onInputRemoved) this.onInputRemoved(slot); + this.setDirtyCanvas(true,true); } /** @@ -6914,17 +6943,7 @@ LGraphCanvas.prototype.showSearchBox = function(event) if (that.onSearchBox){ that.onSearchBox(help, str, graphcanvas); } else { - function addResult(result) { - var help = document.createElement("div"); - if (!first) first = result; - help.innerText = result; - help.className = "litegraph lite-search-item"; - help.addEventListener("click", function (e) { - select(this.innerText); - }); - helper.appendChild(help); - } - let c = 0; + var c = 0; if(LGraphCanvas.search_filter) { str = str.toLowerCase(); @@ -6934,17 +6953,30 @@ LGraphCanvas.prototype.showSearchBox = function(event) }); for(var i = 0; i < filtered.length; i++) { addResult(filtered[i]); - if(LGraphCanvas.search_limit !== -1 && c++ > LGraphCanvas.search_limit) break; + if(LGraphCanvas.search_limit !== -1 && c++ > LGraphCanvas.search_limit) + break; } } else { for (var i in LiteGraph.registered_node_types) { if (i.indexOf(str) != -1) { addResult(i); - if(LGraphCanvas.search_limit !== -1 && c++ > LGraphCanvas.search_limit) break; + if(LGraphCanvas.search_limit !== -1 && c++ > LGraphCanvas.search_limit) + break; } } } } + + function addResult(result) { + var help = document.createElement("div"); + if (!first) first = result; + help.innerText = result; + help.className = "litegraph lite-search-item"; + help.addEventListener("click", function (e) { + select(this.innerText); + }); + helper.appendChild(help); + } } return dialog; diff --git a/build/litegraph.min.js b/build/litegraph.min.js index 26f54b391..289479abb 100755 --- a/build/litegraph.min.js +++ b/build/litegraph.min.js @@ -1,8465 +1,230 @@ -var $jscomp = $jscomp || {}; -$jscomp.scope = {}; -$jscomp.ASSUME_ES5 = !1; -$jscomp.ASSUME_NO_NATIVE_MAP = !1; -$jscomp.ASSUME_NO_NATIVE_SET = !1; -$jscomp.defineProperty = $jscomp.ASSUME_ES5 || "function" == typeof Object.defineProperties ? Object.defineProperty : function(u, f, h) { - u != Array.prototype && u != Object.prototype && (u[f] = h.value); -}; -$jscomp.getGlobal = function(u) { - return "undefined" != typeof window && window === u ? u : "undefined" != typeof global && null != global ? global : u; -}; -$jscomp.global = $jscomp.getGlobal(this); -$jscomp.polyfill = function(u, f, h, n) { - if (f) { - h = $jscomp.global; - u = u.split("."); - for (n = 0; n < u.length - 1; n++) { - var d = u[n]; - d in h || (h[d] = {}); - h = h[d]; - } - u = u[u.length - 1]; - n = h[u]; - f = f(n); - f != n && null != f && $jscomp.defineProperty(h, u, {configurable:!0, writable:!0, value:f}); - } -}; -$jscomp.polyfill("Array.prototype.fill", function(u) { - return u ? u : function(f, h, n) { - var d = this.length || 0; - 0 > h && (h = Math.max(0, d + h)); - if (null == n || n > d) { - n = d; - } - n = Number(n); - 0 > n && (n = Math.max(0, d + n)); - for (h = Number(h || 0); h < n; h++) { - this[h] = f; - } - return this; - }; -}, "es6", "es3"); -$jscomp.SYMBOL_PREFIX = "jscomp_symbol_"; -$jscomp.initSymbol = function() { - $jscomp.initSymbol = function() { - }; - $jscomp.global.Symbol || ($jscomp.global.Symbol = $jscomp.Symbol); -}; -$jscomp.Symbol = function() { - var u = 0; - return function(f) { - return $jscomp.SYMBOL_PREFIX + (f || "") + u++; - }; -}(); -$jscomp.initSymbolIterator = function() { - $jscomp.initSymbol(); - var u = $jscomp.global.Symbol.iterator; - u || (u = $jscomp.global.Symbol.iterator = $jscomp.global.Symbol("iterator")); - "function" != typeof Array.prototype[u] && $jscomp.defineProperty(Array.prototype, u, {configurable:!0, writable:!0, value:function() { - return $jscomp.arrayIterator(this); - }}); - $jscomp.initSymbolIterator = function() { - }; -}; -$jscomp.arrayIterator = function(u) { - var f = 0; - return $jscomp.iteratorPrototype(function() { - return f < u.length ? {done:!1, value:u[f++]} : {done:!0}; - }); -}; -$jscomp.iteratorPrototype = function(u) { - $jscomp.initSymbolIterator(); - u = {next:u}; - u[$jscomp.global.Symbol.iterator] = function() { - return this; - }; - return u; -}; -$jscomp.iteratorFromArray = function(u, f) { - $jscomp.initSymbolIterator(); - u instanceof String && (u += ""); - var h = 0, n = {next:function() { - if (h < u.length) { - var d = h++; - return {value:f(d, u[d]), done:!1}; - } - n.next = function() { - return {done:!0, value:void 0}; - }; - return n.next(); - }}; - n[Symbol.iterator] = function() { - return n; - }; - return n; -}; -$jscomp.polyfill("Array.prototype.values", function(u) { - return u ? u : function() { - return $jscomp.iteratorFromArray(this, function(f, h) { - return h; - }); - }; -}, "es8", "es3"); -$jscomp.polyfill("Array.prototype.keys", function(u) { - return u ? u : function() { - return $jscomp.iteratorFromArray(this, function(f) { - return f; - }); - }; -}, "es6", "es3"); -(function(u) { - function f(a) { - k.debug && console.log("Graph created"); - this.list_of_graphcanvas = null; - this.clear(); - a && this.configure(a); - } - function h(a) { - this._ctor(a); - } - function n(a) { - this._ctor(a); - } - function d(a, b, e) { - e = e || {}; - 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.max_zoom = 10; - this.min_zoom = 0.1; - this.zoom_modify_alpha = !0; - this.title_text_font = "bold " + k.NODE_TEXT_SIZE + "px Arial"; - this.inner_text_font = "normal " + k.NODE_SUBTEXT_SIZE + "px Arial"; - this.node_title_color = k.NODE_TITLE_COLOR; - this.default_link_color = k.LINK_COLOR; - this.default_connection_color = {input_off:"#AAB", input_on:"#7F7", output_off:"#AAB", output_on:"#7F7"}; - this.highquality_render = !0; - this.use_gradients = !1; - this.editor_alpha = 1; - this.pause_rendering = !1; - this.render_only_selected = this.clear_background = this.render_shadows = !0; - this.live_mode = !1; - this.allow_searchbox = this.allow_interaction = this.allow_dragnodes = this.allow_dragcanvas = this.show_info = !0; - this.drag_mode = !1; - this.filter = this.dragging_rectangle = null; - this.always_render_background = !1; - this.render_canvas_border = !0; - this.render_connections_shadows = !1; - this.render_connection_arrows = this.render_curved_connections = this.render_connections_border = !0; - this.render_execution_order = !1; - this.canvas_mouse = [0, 0]; - this.onSearchBoxSelection = this.onSearchBox = null; - this.connections_width = 3; - this.round_radius = 8; - this.node_widget = this.current_node = null; - this.last_mouse_position = [0, 0]; - b && b.attachCanvas(this); - this.setCanvas(a); - this.clear(); - e.skip_render || this.startRendering(); - this.autoresize = e.autoresize; - } - function q(a, b) { - return Math.sqrt((b[0] - a[0]) * (b[0] - a[0]) + (b[1] - a[1]) * (b[1] - a[1])); - } - function t(a, b, e, c, g, l) { - return e < a && e + g > a && c < b && c + l > b ? !0 : !1; - } - function v(a, b) { - var e = a[0] + a[2], c = a[1] + a[3], g = b[1] + b[3]; - return a[0] > b[0] + b[2] || a[1] > g || e < b[0] || c < b[1] ? !1 : !0; - } - function w(a, b) { - function e(a) { - var b = parseInt(g.style.top); - g.style.top = (b + 0.1 * a.deltaY).toFixed() + "px"; - a.preventDefault(); - return !0; - } - this.options = b = b || {}; - var c = this; - b.parentMenu && (b.parentMenu.constructor !== this.constructor ? (console.error("parentMenu must be of class ContextMenu, ignoring it"), b.parentMenu = null) : (this.parentMenu = b.parentMenu, this.parentMenu.lock = !0, this.parentMenu.current_submenu = this)); - b.event && b.event.constructor !== MouseEvent && b.event.constructor !== CustomEvent && (console.error("Event passed to ContextMenu is not of type MouseEvent or CustomEvent. Ignoring it."), b.event = null); - var g = document.createElement("div"); - g.className = "litegraph litecontextmenu litemenubar-panel"; - g.style.minWidth = 100; - g.style.minHeight = 100; - g.style.pointerEvents = "none"; - setTimeout(function() { - g.style.pointerEvents = "auto"; - }, 100); - g.addEventListener("mouseup", function(a) { - a.preventDefault(); - return !0; - }, !0); - g.addEventListener("contextmenu", function(a) { - if (2 != a.button) { - return !1; - } - a.preventDefault(); - return !1; - }, !0); - g.addEventListener("mousedown", function(a) { - if (2 == a.button) { - return c.close(), a.preventDefault(), !0; - } - }, !0); - g.addEventListener("wheel", e, !0); - g.addEventListener("mousewheel", e, !0); - this.root = g; - if (b.title) { - var l = document.createElement("div"); - l.className = "litemenu-title"; - l.innerHTML = b.title; - g.appendChild(l); - } - l = 0; - for (var p in a) { - var k = a.constructor == Array ? a[p] : p; - null != k && k.constructor !== String && (k = void 0 === k.content ? String(k) : k.content); - this.addItem(k, a[p], b); - l++; - } - g.addEventListener("mouseleave", function(a) { - c.lock || c.close(a); - }); - a = document; - b.event && (a = b.event.target.ownerDocument); - a || (a = document); - a.body.appendChild(g); - p = b.left || 0; - a = b.top || 0; - b.event && (p = b.event.pageX - 10, a = b.event.pageY - 10, b.title && (a -= 20), b.parentMenu && (b = b.parentMenu.root.getBoundingClientRect(), p = b.left + b.width), b = document.body.getBoundingClientRect(), l = g.getBoundingClientRect(), p > b.width - l.width - 10 && (p = b.width - l.width - 10), a > b.height - l.height - 10 && (a = b.height - l.height - 10)); - g.style.left = p + "px"; - g.style.top = a + "px"; - } - var k = u.LiteGraph = {CANVAS_GRID_SIZE:10, NODE_TITLE_HEIGHT:20, NODE_SLOT_HEIGHT:15, 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:"#444", NODE_DEFAULT_BOXCOLOR:"#666", NODE_DEFAULT_SHAPE:"box", DEFAULT_SHADOW_COLOR:"rgba(0,0,0,0.5)", LINK_COLOR:"#AAD", EVENT_LINK_COLOR:"#F85", CONNECTING_LINK_COLOR:"#AFA", - MAX_NUMBER_OF_NODES:1000, 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, NORMAL_TITLE:0, NO_TITLE:1, TRANSPARENT_TITLE:2, AUTOHIDE_TITLE:3, proxy:null, node_images_path:"", debug:!1, throw_errors:!0, allow_scripts:!0, registered_node_types:{}, node_types_by_file_extension:{}, - Nodes:{}, registerNodeType:function(a, b) { - if (!b.prototype) { - throw "Cannot register a simple object, it must be a class with a prototype"; - } - b.type = a; - k.debug && console.log("Node registered: " + a); - a.split("/"); - var e = b.name, c = a.lastIndexOf("/"); - b.category = a.substr(0, c); - b.title || (b.title = e); - if (b.prototype) { - for (var g in h.prototype) { - b.prototype[g] || (b.prototype[g] = h.prototype[g]); - } - } - Object.defineProperty(b.prototype, "shape", {set:function(a) { - switch(a) { - case "default": - delete this._shape; - break; - case "box": - this._shape = k.BOX_SHAPE; - break; - case "round": - this._shape = k.ROUND_SHAPE; - break; - case "circle": - this._shape = k.CIRCLE_SHAPE; - break; - case "card": - this._shape = k.CARD_SHAPE; - break; - default: - this._shape = a; - } - }, get:function(a) { - return this._shape; - }, enumerable:!0}); - this.registered_node_types[a] = b; - b.constructor.name && (this.Nodes[e] = b); - b.prototype.onPropertyChange && console.warn("LiteGraph node class " + a + " has onPropertyChange method, it must be called onPropertyChanged with d at the end"); - if (b.supported_extensions) { - for (g in b.supported_extensions) { - this.node_types_by_file_extension[b.supported_extensions[g].toLowerCase()] = b; - } - } - }, wrapFunctionAsNode:function(a, b, e, c) { - for (var g = Array(b.length), l = "", z = k.getParameterNames(b), d = 0; d < z.length; ++d) { - l += "this.addInput('" + z[d] + "'," + (e && e[d] ? "'" + e[d] + "'" : "0") + ");\n"; - } - e = Function(l + ("this.addOutput('out'," + (c ? "'" + c + "'" : 0) + ");\n")); - e.title = a.split("/").pop(); - e.desc = "Generated from " + b.name; - e.prototype.onExecute = function() { - for (var a = 0; a < g.length; ++a) { - g[a] = this.getInputData(a); - } - a = b.apply(this, g); - this.setOutputData(0, a); - }; - this.registerNodeType(a, e); - }, addNodeMethod:function(a, b) { - h.prototype[a] = b; - for (var e in this.registered_node_types) { - var c = this.registered_node_types[e]; - c.prototype[a] && (c.prototype["_" + a] = c.prototype[a]); - c.prototype[a] = b; - } - }, createNode:function(a, b, e) { - var c = this.registered_node_types[a]; - if (!c) { - return k.debug && console.log('GraphNode type "' + a + '" not registered.'), null; - } - b = b || c.title || a; - c = new c(b); - c.type = a; - !c.title && b && (c.title = b); - c.properties || (c.properties = {}); - c.properties_info || (c.properties_info = []); - c.flags || (c.flags = {}); - c.size || (c.size = c.computeSize()); - c.pos || (c.pos = k.DEFAULT_POSITION.concat()); - c.mode || (c.mode = k.ALWAYS); - if (e) { - for (var g in e) { - c[g] = e[g]; - } - } - return c; - }, getNodeType:function(a) { - return this.registered_node_types[a]; - }, getNodeTypesInCategory:function(a, b) { - var e = [], c; - for (c in this.registered_node_types) { - var g = this.registered_node_types[c]; - b && g.filter && g.filter != b || ("" == a ? null == g.category && e.push(g) : g.category == a && e.push(g)); - } - return e; - }, getNodeTypesCategories:function() { - var a = {"":1}, b; - for (b in this.registered_node_types) { - this.registered_node_types[b].category && !this.registered_node_types[b].skip_list && (a[this.registered_node_types[b].category] = 1); - } - var e = []; - for (b in a) { - e.push(b); - } - return e; - }, reloadNodes:function(a) { - var b = document.getElementsByTagName("script"), e = [], c; - for (c in b) { - e.push(b[c]); - } - b = document.getElementsByTagName("head")[0]; - a = document.location.href + a; - for (c in e) { - var g = e[c].src; - if (g && g.substr(0, a.length) == a) { - try { - k.debug && console.log("Reloading: " + g); - var l = document.createElement("script"); - l.type = "text/javascript"; - l.src = g; - b.appendChild(l); - b.removeChild(e[c]); - } catch (p) { - if (k.throw_errors) { - throw p; - } - k.debug && console.log("Error while reloading " + g); - } - } - } - k.debug && console.log("Nodes reloaded"); - }, cloneObject:function(a, b) { - if (null == a) { - return null; - } - a = JSON.parse(JSON.stringify(a)); - if (!b) { - return a; - } - for (var e in a) { - b[e] = a[e]; - } - return b; - }, isValidConnection:function(a, b) { - if (!a || !b || a == b || a == k.EVENT && b == k.ACTION) { - return !0; - } - a = String(a); - b = String(b); - a = a.toLowerCase(); - b = b.toLowerCase(); - if (-1 == a.indexOf(",") && -1 == b.indexOf(",")) { - return a == b; - } - a = a.split(","); - b = b.split(","); - for (var e = 0; e < a.length; ++e) { - for (var c = 0; c < b.length; ++c) { - if (a[e] == b[c]) { - return !0; - } - } - } - return !1; - }}; - k.getTime = "undefined" != typeof performance ? performance.now.bind(performance) : "undefined" != typeof Date && Date.now ? Date.now.bind(Date) : "undefined" != typeof process ? function() { - var a = process.hrtime(); - return 0.001 * a[0] + 1e-6 * a[1]; - } : function() { - return (new Date).getTime(); - }; - u.LGraph = k.LGraph = f; - f.supported_types = ["number", "string", "boolean"]; - f.prototype.getSupportedTypes = function() { - return this.supported_types || f.supported_types; - }; - f.STATUS_STOPPED = 1; - f.STATUS_RUNNING = 2; - f.prototype.clear = function() { - this.stop(); - this.status = f.STATUS_STOPPED; - this.last_link_id = this.last_node_id = 1; - this._version = -1; - this._nodes = []; - this._nodes_by_id = {}; - this._nodes_in_order = []; - this._nodes_executable = null; - this._groups = []; - this.links = {}; - this.iteration = 0; - this.config = {}; - this.fixedtime = this.runningtime = this.globaltime = 0; - this.elapsed_time = this.fixedtime_lapse = 0.01; - this.starttime = this.last_update_time = 0; - this.catch_errors = !0; - this.global_inputs = {}; - this.global_outputs = {}; - this.change(); - this.sendActionToCanvas("clear"); - }; - f.prototype.attachCanvas = function(a) { - if (a.constructor != d) { - throw "attachCanvas expects a LGraphCanvas instance"; - } - a.graph && a.graph != this && a.graph.detachCanvas(a); - a.graph = this; - this.list_of_graphcanvas || (this.list_of_graphcanvas = []); - this.list_of_graphcanvas.push(a); - }; - f.prototype.detachCanvas = function(a) { - if (this.list_of_graphcanvas) { - var b = this.list_of_graphcanvas.indexOf(a); - -1 != b && (a.graph = null, this.list_of_graphcanvas.splice(b, 1)); - } - }; - f.prototype.start = function(a) { - if (this.status != f.STATUS_RUNNING) { - this.status = f.STATUS_RUNNING; - if (this.onPlayEvent) { - this.onPlayEvent(); - } - this.sendEventToAllNodes("onStart"); - this.last_update_time = this.starttime = k.getTime(); - var b = this; - this.execution_timer_id = setInterval(function() { - b.runStep(1, !this.catch_errors); - }, a || 1); - } - }; - f.prototype.stop = function() { - if (this.status != f.STATUS_STOPPED) { - this.status = f.STATUS_STOPPED; - if (this.onStopEvent) { - this.onStopEvent(); - } - null != this.execution_timer_id && clearInterval(this.execution_timer_id); - this.execution_timer_id = null; - this.sendEventToAllNodes("onStop"); - } - }; - f.prototype.runStep = function(a, b) { - a = a || 1; - var e = k.getTime(); - this.globaltime = 0.001 * (e - this.starttime); - var c = this._nodes_executable ? this._nodes_executable : this._nodes; - if (c) { - if (b) { - for (var g = 0; g < a; g++) { - for (var l = 0, p = c.length; l < p; ++l) { - var d = c[l]; - if (d.mode == k.ALWAYS && d.onExecute) { - d.onExecute(); - } - } - this.fixedtime += this.fixedtime_lapse; - if (this.onExecuteStep) { - this.onExecuteStep(); - } - } - if (this.onAfterExecute) { - this.onAfterExecute(); - } - } else { - try { - for (g = 0; g < a; g++) { - l = 0; - for (p = c.length; l < p; ++l) { - if (d = c[l], d.mode == k.ALWAYS && d.onExecute) { - d.onExecute(); - } - } - this.fixedtime += this.fixedtime_lapse; - if (this.onExecuteStep) { - this.onExecuteStep(); - } - } - if (this.onAfterExecute) { - this.onAfterExecute(); - } - this.errors_in_execution = !1; - } catch (G) { - this.errors_in_execution = !0; - if (k.throw_errors) { - throw G; - } - k.debug && console.log("Error during execution: " + G); - this.stop(); - } - } - a = k.getTime(); - e = a - e; - 0 == e && (e = 1); - this.execution_time = 0.001 * e; - this.globaltime += 0.001 * e; - this.iteration += 1; - this.elapsed_time = 0.001 * (a - this.last_update_time); - this.last_update_time = a; - } - }; - f.prototype.updateExecutionOrder = function() { - this._nodes_in_order = this.computeExecutionOrder(!1); - this._nodes_executable = []; - for (var a = 0; a < this._nodes_in_order.length; ++a) { - this._nodes_in_order[a].onExecute && this._nodes_executable.push(this._nodes_in_order[a]); - } - }; - f.prototype.computeExecutionOrder = function(a, b) { - for (var e = [], c = [], g = {}, l = {}, p = {}, d = 0, m = this._nodes.length; d < m; ++d) { - var f = this._nodes[d]; - if (!a || f.onExecute) { - g[f.id] = f; - var n = 0; - if (f.inputs) { - for (var h = 0, q = f.inputs.length; h < q; h++) { - f.inputs[h] && null != f.inputs[h].link && (n += 1); - } - } - 0 == n ? (c.push(f), b && (f._level = 1)) : (b && (f._level = 0), p[f.id] = n); - } - } - for (; 0 != c.length;) { - if (f = c.shift(), e.push(f), delete g[f.id], f.outputs) { - for (d = 0; d < f.outputs.length; d++) { - if (a = f.outputs[d], null != a && null != a.links && 0 != a.links.length) { - for (h = 0; h < a.links.length; h++) { - (m = this.links[a.links[h]]) && !l[m.id] && (n = this.getNodeById(m.target_id), null == n ? l[m.id] = !0 : (b && (!n._level || n._level <= f._level) && (n._level = f._level + 1), l[m.id] = !0, --p[n.id], 0 == p[n.id] && c.push(n))); - } - } - } - } - } - for (d in g) { - e.push(g[d]); - } - e.length != this._nodes.length && k.debug && console.warn("something went wrong, nodes missing"); - m = e.length; - for (d = 0; d < m; ++d) { - e[d].order = d; - } - e = e.sort(function(a, b) { - var e = a.constructor.priority || a.priority || 0, c = b.constructor.priority || b.priority || 0; - return e == c ? a.order - b.order : e - c; - }); - for (d = 0; d < m; ++d) { - e[d].order = d; - } - return e; - }; - f.prototype.getAncestors = function(a) { - for (var b = [], e = [a], c = {}; e.length;) { - var g = e.shift(); - if (g.inputs) { - c[g.id] || g == a || (c[g.id] = !0, b.push(g)); - for (var l = 0; l < g.inputs.length; ++l) { - var p = g.getInputNode(l); - p && -1 == b.indexOf(p) && e.push(p); - } - } - } - b.sort(function(a, b) { - return a.order - b.order; - }); - return b; - }; - f.prototype.arrange = function(a) { - a = a || 40; - for (var b = this.computeExecutionOrder(!1, !0), e = [], c = 0; c < b.length; ++c) { - var g = b[c], l = g._level || 1; - e[l] || (e[l] = []); - e[l].push(g); - } - b = a; - for (c = 0; c < e.length; ++c) { - if (l = e[c]) { - for (var p = 100, k = a, d = 0; d < l.length; ++d) { - g = l[d], g.pos[0] = b, g.pos[1] = k, g.size[0] > p && (p = g.size[0]), k += g.size[1] + a; - } - b += p + a; - } - } - this.setDirtyCanvas(!0, !0); - }; - f.prototype.getTime = function() { - return this.globaltime; - }; - f.prototype.getFixedTime = function() { - return this.fixedtime; - }; - f.prototype.getElapsedTime = function() { - return this.elapsed_time; - }; - f.prototype.sendEventToAllNodes = function(a, b, e) { - e = e || k.ALWAYS; - var c = this._nodes_in_order ? this._nodes_in_order : this._nodes; - if (c) { - for (var g = 0, l = c.length; g < l; ++g) { - var p = c[g]; - if (p[a] && p.mode == e) { - if (void 0 === b) { - p[a](); - } else { - if (b && b.constructor === Array) { - p[a].apply(p, b); - } else { - p[a](b); - } - } - } - } - } - }; - f.prototype.sendActionToCanvas = function(a, b) { - if (this.list_of_graphcanvas) { - for (var e = 0; e < this.list_of_graphcanvas.length; ++e) { - var c = this.list_of_graphcanvas[e]; - c[a] && c[a].apply(c, b); - } - } - }; - f.prototype.add = function(a, b) { - if (a) { - if (a.constructor === n) { - this._groups.push(a), this.setDirtyCanvas(!0), this.change(), a.graph = this, this._version++; - } else { - -1 != a.id && null != this._nodes_by_id[a.id] && (console.warn("LiteGraph: there is already a node with this ID, changing it"), a.id = ++this.last_node_id); - if (this._nodes.length >= k.MAX_NUMBER_OF_NODES) { - throw "LiteGraph: max number of nodes in a graph reached"; - } - null == a.id || -1 == a.id ? a.id = ++this.last_node_id : this.last_node_id < a.id && (this.last_node_id = a.id); - a.graph = this; - this._version++; - this._nodes.push(a); - this._nodes_by_id[a.id] = a; - if (a.onAdded) { - a.onAdded(this); - } - this.config.align_to_grid && a.alignToGrid(); - b || this.updateExecutionOrder(); - if (this.onNodeAdded) { - this.onNodeAdded(a); - } - this.setDirtyCanvas(!0); - this.change(); - return a; - } - } - }; - f.prototype.remove = function(a) { - if (a.constructor === k.LGraphGroup) { - var b = this._groups.indexOf(a); - -1 != b && this._groups.splice(b, 1); - a.graph = null; - this._version++; - this.setDirtyCanvas(!0, !0); - this.change(); - } else { - if (null != this._nodes_by_id[a.id] && !a.ignore_remove) { - if (a.inputs) { - for (b = 0; b < a.inputs.length; b++) { - var e = a.inputs[b]; - null != e.link && a.disconnectInput(b); - } - } - if (a.outputs) { - for (b = 0; b < a.outputs.length; b++) { - e = a.outputs[b], null != e.links && e.links.length && a.disconnectOutput(b); - } - } - if (a.onRemoved) { - a.onRemoved(); - } - a.graph = null; - this._version++; - if (this.list_of_graphcanvas) { - for (b = 0; b < this.list_of_graphcanvas.length; ++b) { - e = this.list_of_graphcanvas[b], e.selected_nodes[a.id] && delete e.selected_nodes[a.id], e.node_dragged == a && (e.node_dragged = null); - } - } - b = this._nodes.indexOf(a); - -1 != b && this._nodes.splice(b, 1); - delete this._nodes_by_id[a.id]; - if (this.onNodeRemoved) { - this.onNodeRemoved(a); - } - this.setDirtyCanvas(!0, !0); - this.change(); - this.updateExecutionOrder(); - } - } - }; - f.prototype.getNodeById = function(a) { - return null == a ? null : this._nodes_by_id[a]; - }; - f.prototype.findNodesByClass = function(a) { - for (var b = [], e = 0, c = this._nodes.length; e < c; ++e) { - this._nodes[e].constructor === a && b.push(this._nodes[e]); - } - return b; - }; - f.prototype.findNodesByType = function(a) { - a = a.toLowerCase(); - for (var b = [], e = 0, c = this._nodes.length; e < c; ++e) { - this._nodes[e].type.toLowerCase() == a && b.push(this._nodes[e]); - } - return b; - }; - f.prototype.findNodesByTitle = function(a) { - for (var b = [], e = 0, c = this._nodes.length; e < c; ++e) { - this._nodes[e].title == a && b.push(this._nodes[e]); - } - return b; - }; - f.prototype.getNodeOnPos = function(a, b, e) { - e = e || this._nodes; - for (var c = e.length - 1; 0 <= c; c--) { - var g = e[c]; - if (g.isPointInside(a, b, 2)) { - return g; - } - } - return null; - }; - f.prototype.getGroupOnPos = function(a, b) { - for (var e = this._groups.length - 1; 0 <= e; e--) { - var c = this._groups[e]; - if (c.isPointInside(a, b, 2)) { - return c; - } - } - return null; - }; - f.prototype.addGlobalInput = function(a, b, e) { - this.global_inputs[a] = {name:a, type:b, value:e}; - this._version++; - if (this.onGlobalInputAdded) { - this.onGlobalInputAdded(a, b); - } - if (this.onGlobalsChange) { - this.onGlobalsChange(); - } - }; - f.prototype.setGlobalInputData = function(a, b) { - if (a = this.global_inputs[a]) { - a.value = b; - } - }; - f.prototype.setInputData = f.prototype.setGlobalInputData; - f.prototype.getGlobalInputData = function(a) { - return (a = this.global_inputs[a]) ? a.value : null; - }; - f.prototype.renameGlobalInput = function(a, b) { - if (b != a) { - if (!this.global_inputs[a]) { - return !1; - } - if (this.global_inputs[b]) { - return console.error("there is already one input with that name"), !1; - } - this.global_inputs[b] = this.global_inputs[a]; - delete this.global_inputs[a]; - this._version++; - if (this.onGlobalInputRenamed) { - this.onGlobalInputRenamed(a, b); - } - if (this.onGlobalsChange) { - this.onGlobalsChange(); - } - } - }; - f.prototype.changeGlobalInputType = function(a, b) { - if (!this.global_inputs[a]) { - return !1; - } - if (!this.global_inputs[a].type || this.global_inputs[a].type.toLowerCase() != b.toLowerCase()) { - if (this.global_inputs[a].type = b, this._version++, this.onGlobalInputTypeChanged) { - this.onGlobalInputTypeChanged(a, b); - } - } - }; - f.prototype.removeGlobalInput = function(a) { - if (!this.global_inputs[a]) { - return !1; - } - delete this.global_inputs[a]; - this._version++; - if (this.onGlobalInputRemoved) { - this.onGlobalInputRemoved(a); - } - if (this.onGlobalsChange) { - this.onGlobalsChange(); - } - return !0; - }; - f.prototype.addGlobalOutput = function(a, b, e) { - this.global_outputs[a] = {name:a, type:b, value:e}; - this._version++; - if (this.onGlobalOutputAdded) { - this.onGlobalOutputAdded(a, b); - } - if (this.onGlobalsChange) { - this.onGlobalsChange(); - } - }; - f.prototype.setGlobalOutputData = function(a, b) { - if (a = this.global_outputs[a]) { - a.value = b; - } - }; - f.prototype.getGlobalOutputData = function(a) { - return (a = this.global_outputs[a]) ? a.value : null; - }; - f.prototype.getOutputData = f.prototype.getGlobalOutputData; - f.prototype.renameGlobalOutput = function(a, b) { - if (!this.global_outputs[a]) { - return !1; - } - if (this.global_outputs[b]) { - return console.error("there is already one output with that name"), !1; - } - this.global_outputs[b] = this.global_outputs[a]; - delete this.global_outputs[a]; - this._version++; - if (this.onGlobalOutputRenamed) { - this.onGlobalOutputRenamed(a, b); - } - if (this.onGlobalsChange) { - this.onGlobalsChange(); - } - }; - f.prototype.changeGlobalOutputType = function(a, b) { - if (!this.global_outputs[a]) { - return !1; - } - if (!this.global_outputs[a].type || this.global_outputs[a].type.toLowerCase() != b.toLowerCase()) { - if (this.global_outputs[a].type = b, this._version++, this.onGlobalOutputTypeChanged) { - this.onGlobalOutputTypeChanged(a, b); - } - } - }; - f.prototype.removeGlobalOutput = function(a) { - if (!this.global_outputs[a]) { - return !1; - } - delete this.global_outputs[a]; - this._version++; - if (this.onGlobalOutputRemoved) { - this.onGlobalOutputRemoved(a); - } - if (this.onGlobalsChange) { - this.onGlobalsChange(); - } - return !0; - }; - f.prototype.triggerInput = function(a, b) { - a = this.findNodesByTitle(a); - for (var e = 0; e < a.length; ++e) { - a[e].onTrigger(b); - } - }; - f.prototype.setCallback = function(a, b) { - a = this.findNodesByTitle(a); - for (var e = 0; e < a.length; ++e) { - a[e].setTrigger(b); - } - }; - f.prototype.connectionChange = function(a) { - this.updateExecutionOrder(); - if (this.onConnectionChange) { - this.onConnectionChange(a); - } - this._version++; - this.sendActionToCanvas("onConnectionChange"); - }; - f.prototype.isLive = function() { - if (!this.list_of_graphcanvas) { - return !1; - } - for (var a = 0; a < this.list_of_graphcanvas.length; ++a) { - if (this.list_of_graphcanvas[a].live_mode) { - return !0; - } - } - return !1; - }; - f.prototype.change = function() { - k.debug && console.log("Graph changed"); - this.sendActionToCanvas("setDirty", [!0, !0]); - if (this.on_change) { - this.on_change(this); - } - }; - f.prototype.setDirtyCanvas = function(a, b) { - this.sendActionToCanvas("setDirty", [a, b]); - }; - f.prototype.serialize = function() { - for (var a = [], b = 0, e = this._nodes.length; b < e; ++b) { - a.push(this._nodes[b].serialize()); - } - e = []; - for (b in this.links) { - var c = this.links[b]; - e.push([c.id, c.origin_id, c.origin_slot, c.target_id, c.target_slot, c.type]); - } - c = []; - for (b = 0; b < this._groups.length; ++b) { - c.push(this._groups[b].serialize()); - } - return {last_node_id:this.last_node_id, last_link_id:this.last_link_id, nodes:a, links:e, groups:c, config:this.config}; - }; - f.prototype.configure = function(a, b) { - if (a) { - b || this.clear(); - b = a.nodes; - if (a.links && a.links.constructor === Array) { - for (var e = [], c = 0; c < a.links.length; ++c) { - var g = a.links[c]; - e[g[0]] = {id:g[0], origin_id:g[1], origin_slot:g[2], target_id:g[3], target_slot:g[4], type:g[5]}; - } - a.links = e; - } - for (c in a) { - this[c] = a[c]; - } - e = !1; - this._nodes = []; - if (b) { - c = 0; - for (g = b.length; c < g; ++c) { - var l = b[c], p = k.createNode(l.type, l.title); - p ? (p.id = l.id, this.add(p, !0)) : (k.debug && console.log("Node not found: " + l.type), e = !0); - } - c = 0; - for (g = b.length; c < g; ++c) { - l = b[c], (p = this.getNodeById(l.id)) && p.configure(l); - } - } - this._groups.length = 0; - if (a.groups) { - for (c = 0; c < a.groups.length; ++c) { - b = new k.LGraphGroup, b.configure(a.groups[c]), this.add(b); - } - } - this.updateExecutionOrder(); - this._version++; - this.setDirtyCanvas(!0, !0); - return e; - } - }; - f.prototype.load = function(a) { - var b = this, e = new XMLHttpRequest; - e.open("GET", a, !0); - e.send(null); - e.onload = function(a) { - 200 !== e.status ? console.error("Error loading graph:", e.status, e.response) : (a = JSON.parse(e.response), b.configure(a)); - }; - e.onerror = function(a) { - console.error("Error loading graph:", a); - }; - }; - f.prototype.onNodeTrace = function(a, b, e) { - }; - u.LGraphNode = k.LGraphNode = h; - h.prototype._ctor = function(a) { - this.title = a || "Unnamed"; - this.size = [k.NODE_WIDTH, 60]; - this.graph = null; - this._pos = new Float32Array(10, 10); - Object.defineProperty(this, "pos", {set:function(a) { - !a || 2 > a.length || (this._pos[0] = a[0], this._pos[1] = a[1]); - }, get:function() { - return this._pos; - }, enumerable:!0}); - this.id = -1; - this.type = null; - this.inputs = []; - this.outputs = []; - this.connections = []; - this.properties = {}; - this.properties_info = []; - this.data = null; - this.flags = {}; - }; - h.prototype.configure = function(a) { - this.graph && this.graph._version++; - for (var b in a) { - if ("console" != b) { - if ("properties" == b) { - for (var e in a.properties) { - if (this.properties[e] = a.properties[e], this.onPropertyChanged) { - this.onPropertyChanged(e, a.properties[e]); - } - } - } else { - null != a[b] && ("object" == typeof a[b] ? this[b] && this[b].configure ? this[b].configure(a[b]) : this[b] = k.cloneObject(a[b], this[b]) : this[b] = a[b]); - } - } - } - a.title || (this.title = this.constructor.title); - if (this.onConnectionsChange) { - if (this.inputs) { - for (var c = 0; c < this.inputs.length; ++c) { - e = this.inputs[c]; - var g = this.graph ? this.graph.links[e.link] : null; - this.onConnectionsChange(k.INPUT, c, !0, g, e); - } - } - if (this.outputs) { - for (c = 0; c < this.outputs.length; ++c) { - if (e = this.outputs[c], e.links) { - for (b = 0; b < e.links.length; ++b) { - g = this.graph ? this.graph.links[e.links[b]] : null, this.onConnectionsChange(k.OUTPUT, c, !0, g, e); - } - } - } - } - } - for (c in this.inputs) { - e = this.inputs[c], e.link && e.link.length && (g = e.link, "object" == typeof g && (e.link = g[0], this.graph && (this.graph.links[g[0]] = {id:g[0], origin_id:g[1], origin_slot:g[2], target_id:g[3], target_slot:g[4]}))); - } - for (c in this.outputs) { - if (e = this.outputs[c], e.links && 0 != e.links.length) { - for (b in e.links) { - g = e.links[b], "object" == typeof g && (e.links[b] = g[0]); - } - } - } - if (this.onConfigure) { - this.onConfigure(a); - } - }; - h.prototype.serialize = function() { - var a = {id:this.id, type:this.type, pos:this.pos, size:this.size, data:this.data, flags:k.cloneObject(this.flags), mode:this.mode}; - this.inputs && (a.inputs = this.inputs); - if (this.outputs) { - for (var b = 0; b < this.outputs.length; b++) { - delete this.outputs[b]._data; - } - a.outputs = this.outputs; - } - this.title && this.title != this.constructor.title && (a.title = this.title); - this.properties && (a.properties = k.cloneObject(this.properties)); - a.type || (a.type = this.constructor.type); - this.color && (a.color = this.color); - this.bgcolor && (a.bgcolor = this.bgcolor); - this.boxcolor && (a.boxcolor = this.boxcolor); - this.shape && (a.shape = this.shape); - if (this.onSerialize) { - this.onSerialize(a); - } - return a; - }; - h.prototype.clone = function() { - var a = k.createNode(this.type), b = k.cloneObject(this.serialize()); - if (b.inputs) { - for (var e = 0; e < b.inputs.length; ++e) { - b.inputs[e].link = null; - } - } - if (b.outputs) { - for (e = 0; e < b.outputs.length; ++e) { - b.outputs[e].links && (b.outputs[e].links.length = 0); - } - } - delete b.id; - a.configure(b); - return a; - }; - h.prototype.toString = function() { - return JSON.stringify(this.serialize()); - }; - h.prototype.getTitle = function() { - return this.title || this.constructor.title; - }; - h.prototype.setOutputData = function(a, b) { - if (this.outputs && !(-1 == a || a >= this.outputs.length)) { - var e = this.outputs[a]; - if (e && (e._data = b, this.outputs[a].links)) { - for (e = 0; e < this.outputs[a].links.length; e++) { - this.graph.links[this.outputs[a].links[e]].data = b; - } - } - } - }; - h.prototype.getInputData = function(a, b) { - if (this.inputs && !(a >= this.inputs.length || null == this.inputs[a].link)) { - a = this.graph.links[this.inputs[a].link]; - if (!a) { - return null; - } - if (!b) { - return a.data; - } - b = this.graph.getNodeById(a.origin_id); - if (!b) { - return a.data; - } - if (b.updateOutputData) { - b.updateOutputData(a.origin_slot); - } else { - if (b.onExecute) { - b.onExecute(); - } - } - return a.data; - } - }; - h.prototype.getInputDataByName = function(a, b) { - a = this.findInputSlot(a); - return -1 == a ? null : this.getInputData(a, b); - }; - h.prototype.isInputConnected = function(a) { - return this.inputs ? a < this.inputs.length && null != this.inputs[a].link : !1; - }; - h.prototype.getInputInfo = function(a) { - return this.inputs ? a < this.inputs.length ? this.inputs[a] : null : null; - }; - h.prototype.getInputNode = function(a) { - if (!this.inputs || a >= this.inputs.length) { - return null; - } - a = this.inputs[a]; - return a && null !== a.link ? (a = this.graph.links[a.link]) ? this.graph.getNodeById(a.origin_id) : null : null; - }; - h.prototype.getInputOrProperty = function(a) { - if (!this.inputs || !this.inputs.length) { - return this.properties ? this.properties[a] : null; - } - for (var b = 0, e = this.inputs.length; b < e; ++b) { - if (a == this.inputs[b].name) { - return (a = this.graph.links[this.inputs[b].link]) ? a.data : null; - } - } - return this.properties[a]; - }; - h.prototype.getOutputData = function(a) { - return !this.outputs || a >= this.outputs.length ? null : this.outputs[a]._data; - }; - h.prototype.getOutputInfo = function(a) { - return this.outputs ? a < this.outputs.length ? this.outputs[a] : null : null; - }; - h.prototype.isOutputConnected = function(a) { - return this.outputs ? a < this.outputs.length && this.outputs[a].links && this.outputs[a].links.length : !1; - }; - h.prototype.isAnyOutputConnected = function() { - if (!this.outputs) { - return !1; - } - for (var a = 0; a < this.outputs.length; ++a) { - if (this.outputs[a].links && this.outputs[a].links.length) { - return !0; - } - } - return !1; - }; - h.prototype.getOutputNodes = function(a) { - if (!this.outputs || 0 == this.outputs.length || a >= this.outputs.length) { - return null; - } - a = this.outputs[a]; - if (!a.links || 0 == a.links.length) { - return null; - } - for (var b = [], e = 0; e < a.links.length; e++) { - var c = this.graph.links[a.links[e]]; - c && (c = this.graph.getNodeById(c.target_id)) && b.push(c); - } - return b; - }; - h.prototype.trigger = function(a, b) { - if (this.outputs && this.outputs.length) { - this.graph && (this.graph._last_trigger_time = k.getTime()); - for (var e = 0; e < this.outputs.length; ++e) { - var c = this.outputs[e]; - !c || c.type !== k.EVENT || a && c.name != a || this.triggerSlot(e, b); - } - } - }; - h.prototype.triggerSlot = function(a, b) { - if (this.outputs && (a = this.outputs[a]) && (a = a.links) && a.length) { - this.graph && (this.graph._last_trigger_time = k.getTime()); - for (var e = 0; e < a.length; ++e) { - var c = this.graph.links[a[e]]; - if (c) { - var g = this.graph.getNodeById(c.target_id); - if (g) { - if (c._last_time = k.getTime(), c = g.inputs[c.target_slot], g.onAction) { - g.onAction(c.name, b); - } else { - if (g.mode === k.ON_TRIGGER && g.onExecute) { - g.onExecute(b); - } - } - } - } - } - } - }; - h.prototype.addProperty = function(a, b, e, c) { - e = {name:a, type:e, default_value:b}; - if (c) { - for (var g in c) { - e[g] = c[g]; - } - } - this.properties_info || (this.properties_info = []); - this.properties_info.push(e); - this.properties || (this.properties = {}); - this.properties[a] = b; - return e; - }; - h.prototype.addOutput = function(a, b, e) { - a = {name:a, type:b, links:null}; - if (e) { - for (var c in e) { - a[c] = e[c]; - } - } - this.outputs || (this.outputs = []); - this.outputs.push(a); - if (this.onOutputAdded) { - this.onOutputAdded(a); - } - this.size = this.computeSize(); - return a; - }; - h.prototype.addOutputs = function(a) { - for (var b = 0; b < a.length; ++b) { - var e = a[b], c = {name:e[0], type:e[1], link:null}; - if (a[2]) { - for (var g in e[2]) { - c[g] = e[2][g]; - } - } - this.outputs || (this.outputs = []); - this.outputs.push(c); - if (this.onOutputAdded) { - this.onOutputAdded(c); - } - } - this.size = this.computeSize(); - }; - h.prototype.removeOutput = function(a) { - this.disconnectOutput(a); - this.outputs.splice(a, 1); - this.size = this.computeSize(); - if (this.onOutputRemoved) { - this.onOutputRemoved(a); - } - }; - h.prototype.addInput = function(a, b, e) { - a = {name:a, type:b || 0, link:null}; - if (e) { - for (var c in e) { - a[c] = e[c]; - } - } - this.inputs || (this.inputs = []); - this.inputs.push(a); - this.size = this.computeSize(); - if (this.onInputAdded) { - this.onInputAdded(a); - } - return a; - }; - h.prototype.addInputs = function(a) { - for (var b = 0; b < a.length; ++b) { - var e = a[b], c = {name:e[0], type:e[1], link:null}; - if (a[2]) { - for (var g in e[2]) { - c[g] = e[2][g]; - } - } - this.inputs || (this.inputs = []); - this.inputs.push(c); - if (this.onInputAdded) { - this.onInputAdded(c); - } - } - this.size = this.computeSize(); - }; - h.prototype.removeInput = function(a) { - this.disconnectInput(a); - this.inputs.splice(a, 1); - this.size = this.computeSize(); - if (this.onInputRemoved) { - this.onInputRemoved(a); - } - }; - h.prototype.addConnection = function(a, b, e, c) { - a = {name:a, type:b, pos:e, direction:c, links:null}; - this.connections.push(a); - return a; - }; - h.prototype.computeSize = function(a, b) { - function e(a) { - return a ? c * a.length * 0.6 : 0; - } - a = Math.max(this.inputs ? this.inputs.length : 1, this.outputs ? this.outputs.length : 1); - b = b || new Float32Array([0, 0]); - a = Math.max(a, 1); - var c = k.NODE_TEXT_SIZE; - b[1] = (this.constructor.slot_start_y || 0) + a * (c + 1) + (this.widgets ? this.widgets.length : 0) * (k.NODE_WIDGET_HEIGHT + 4) + 4; - a = e(this.title); - var g = 0, l = 0; - if (this.inputs) { - for (var p = 0, d = this.inputs.length; p < d; ++p) { - var m = this.inputs[p]; - m = m.label || m.name || ""; - m = e(m); - g < m && (g = m); - } - } - if (this.outputs) { - for (p = 0, d = this.outputs.length; p < d; ++p) { - m = this.outputs[p], m = m.label || m.name || "", m = e(m), l < m && (l = m); - } - } - b[0] = Math.max(g + l + 10, a); - b[0] = Math.max(b[0], k.NODE_WIDTH); - if (this.onResize) { - this.onResize(b); - } - return b; - }; - h.prototype.addWidget = function(a, b, e, c, g) { - this.widgets || (this.widgets = []); - b = {type:a.toLowerCase(), name:b, value:e, callback:c, options:g || {}}; - void 0 !== b.options.y && (b.y = b.options.y); - if ("combo" == a && !b.options.values) { - throw "LiteGraph addWidget('combo',...) requires to pass values in options: { values:['red','blue'] }"; - } - this.widgets.push(b); - return b; - }; - h.prototype.getBounding = function(a) { - a = a || new Float32Array(4); - a[0] = this.pos[0] - 4; - a[1] = this.pos[1] - k.NODE_TITLE_HEIGHT; - a[2] = this.size[0] + 4; - a[3] = this.size[1] + k.NODE_TITLE_HEIGHT; - return a; - }; - h.prototype.isPointInside = function(a, b, e) { - e = e || 0; - var c = this.graph && this.graph.isLive() ? 0 : 20; - if (this.flags && this.flags.collapsed) { - if (t(a, b, this.pos[0] - e, this.pos[1] - k.NODE_TITLE_HEIGHT - e, (this._collapsed_width || k.NODE_COLLAPSED_WIDTH) + 2 * e, k.NODE_TITLE_HEIGHT + 2 * e)) { - return !0; - } - } else { - if (this.pos[0] - 4 - e < a && this.pos[0] + this.size[0] + 4 + e > a && this.pos[1] - c - e < b && this.pos[1] + this.size[1] + e > b) { - return !0; - } - } - return !1; - }; - h.prototype.getSlotInPosition = function(a, b) { - if (this.inputs) { - for (var e = 0, c = this.inputs.length; e < c; ++e) { - var g = this.inputs[e], l = this.getConnectionPos(!0, e); - if (t(a, b, l[0] - 10, l[1] - 5, 20, 10)) { - return {input:g, slot:e, link_pos:l, locked:g.locked}; - } - } - } - if (this.outputs) { - for (e = 0, c = this.outputs.length; e < c; ++e) { - if (g = this.outputs[e], l = this.getConnectionPos(!1, e), t(a, b, l[0] - 10, l[1] - 5, 20, 10)) { - return {output:g, slot:e, link_pos:l, locked:g.locked}; - } - } - } - return null; - }; - h.prototype.findInputSlot = function(a) { - if (!this.inputs) { - return -1; - } - for (var b = 0, e = this.inputs.length; b < e; ++b) { - if (a == this.inputs[b].name) { - return b; - } - } - return -1; - }; - h.prototype.findOutputSlot = function(a) { - if (!this.outputs) { - return -1; - } - for (var b = 0, e = this.outputs.length; b < e; ++b) { - if (a == this.outputs[b].name) { - return b; - } - } - return -1; - }; - h.prototype.connect = function(a, b, e) { - e = e || 0; - if (!this.graph) { - return console.log("Connect: Error, node doesnt belong to any graph. Nodes must be added first to a graph before connecting them."), !1; - } - if (a.constructor === String) { - if (a = this.findOutputSlot(a), -1 == a) { - return k.debug && console.log("Connect: Error, no slot of name " + a), !1; - } - } else { - if (!this.outputs || a >= this.outputs.length) { - return k.debug && console.log("Connect: Error, slot number not found"), !1; - } - } - b && b.constructor === Number && (b = this.graph.getNodeById(b)); - if (!b) { - throw "target node is null"; - } - if (b == this) { - return !1; - } - if (e.constructor === String) { - if (e = b.findInputSlot(e), -1 == e) { - return k.debug && console.log("Connect: Error, no slot of name " + e), !1; - } - } else { - if (e === k.EVENT) { - return !1; - } - if (!b.inputs || e >= b.inputs.length) { - return k.debug && console.log("Connect: Error, slot number not found"), !1; - } - } - null != b.inputs[e].link && b.disconnectInput(e); - var c = this.outputs[a]; - if (b.onConnectInput && !1 === b.onConnectInput(e, c.type, c)) { - return !1; - } - var g = b.inputs[e]; - if (k.isValidConnection(c.type, g.type)) { - var l = {id:this.graph.last_link_id++, type:g.type, origin_id:this.id, origin_slot:a, target_id:b.id, target_slot:e}; - this.graph.links[l.id] = l; - null == c.links && (c.links = []); - c.links.push(l.id); - b.inputs[e].link = l.id; - this.graph && this.graph._version++; - if (this.onConnectionsChange) { - this.onConnectionsChange(k.OUTPUT, a, !0, l, c); - } - if (b.onConnectionsChange) { - b.onConnectionsChange(k.INPUT, e, !0, l, g); - } - if (this.graph && this.graph.onNodeConnectionChange) { - this.graph.onNodeConnectionChange(k.OUTPUT, this, a, b, e); - } - } - this.setDirtyCanvas(!1, !0); - this.graph.connectionChange(this); - return !0; - }; - h.prototype.disconnectOutput = function(a, b) { - if (a.constructor === String) { - if (a = this.findOutputSlot(a), -1 == a) { - return k.debug && console.log("Connect: Error, no slot of name " + a), !1; - } - } else { - if (!this.outputs || a >= this.outputs.length) { - return k.debug && console.log("Connect: Error, slot number not found"), !1; - } - } - var e = this.outputs[a]; - if (!e.links || 0 == e.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, g = e.links.length; c < g; c++) { - var l = e.links[c], p = this.graph.links[l]; - if (p.target_id == b.id) { - e.links.splice(c, 1); - var d = b.inputs[p.target_slot]; - d.link = null; - delete this.graph.links[l]; - this.graph && this.graph._version++; - if (b.onConnectionsChange) { - b.onConnectionsChange(k.INPUT, p.target_slot, !1, p, d); - } - if (this.onConnectionsChange) { - this.onConnectionsChange(k.OUTPUT, a, !1, p, e); - } - if (this.graph && this.graph.onNodeConnectionChange) { - this.graph.onNodeConnectionChange(k.OUTPUT, this, a); - } - if (this.graph && this.graph.onNodeConnectionChange) { - this.graph.onNodeConnectionChange(k.INPUT, b, p.target_slot); - } - break; - } - } - } else { - c = 0; - for (g = e.links.length; c < g; c++) { - if (l = e.links[c], p = this.graph.links[l]) { - b = this.graph.getNodeById(p.target_id); - this.graph && this.graph._version++; - if (b) { - d = b.inputs[p.target_slot]; - d.link = null; - if (b.onConnectionsChange) { - b.onConnectionsChange(k.INPUT, p.target_slot, !1, p, d); - } - if (this.graph && this.graph.onNodeConnectionChange) { - this.graph.onNodeConnectionChange(k.INPUT, b, p.target_slot); - } - } - delete this.graph.links[l]; - if (this.onConnectionsChange) { - this.onConnectionsChange(k.OUTPUT, a, !1, p, e); - } - if (this.graph && this.graph.onNodeConnectionChange) { - this.graph.onNodeConnectionChange(k.OUTPUT, this, a); - } - } - } - e.links = null; - } - this.setDirtyCanvas(!1, !0); - this.graph.connectionChange(this); - return !0; - }; - h.prototype.disconnectInput = function(a) { - if (a.constructor === String) { - if (a = this.findInputSlot(a), -1 == a) { - return k.debug && console.log("Connect: Error, no slot of name " + a), !1; - } - } else { - if (!this.inputs || a >= this.inputs.length) { - return k.debug && console.log("Connect: Error, slot number not found"), !1; - } - } - var b = this.inputs[a]; - if (!b) { - return !1; - } - var e = this.inputs[a].link; - this.inputs[a].link = null; - var c = this.graph.links[e]; - if (c) { - var g = this.graph.getNodeById(c.origin_id); - if (!g) { - return !1; - } - var l = g.outputs[c.origin_slot]; - if (!l || !l.links || 0 == l.links.length) { - return !1; - } - for (var p = 0, d = l.links.length; p < d; p++) { - if (l.links[p] == e) { - l.links.splice(p, 1); - break; - } - } - delete this.graph.links[e]; - this.graph && this.graph._version++; - if (this.onConnectionsChange) { - this.onConnectionsChange(k.INPUT, a, !1, c, b); - } - if (g.onConnectionsChange) { - g.onConnectionsChange(k.OUTPUT, p, !1, c, l); - } - } - this.setDirtyCanvas(!1, !0); - this.graph.connectionChange(this); - return !0; - }; - h.prototype.getConnectionPos = function(a, b) { - return this.flags.collapsed ? a ? [this.pos[0], this.pos[1] - 0.5 * k.NODE_TITLE_HEIGHT] : [this.pos[0] + (this._collapsed_width || k.NODE_COLLAPSED_WIDTH), this.pos[1] - 0.5 * k.NODE_TITLE_HEIGHT] : a && -1 == b ? [this.pos[0] + 10, this.pos[1] + 10] : a && this.inputs.length > b && this.inputs[b].pos ? [this.pos[0] + this.inputs[b].pos[0], this.pos[1] + this.inputs[b].pos[1]] : !a && this.outputs.length > b && this.outputs[b].pos ? [this.pos[0] + this.outputs[b].pos[0], this.pos[1] + this.outputs[b].pos[1]] : - this.flags.horizontal ? a ? [this.pos[0] + this.size[0] / this.inputs.length * (b + 0.5), this.pos[1] - k.NODE_TITLE_HEIGHT] : [this.pos[0] + this.size[0] / this.outputs.length * (b + 0.5), this.pos[1] + this.size[1]] : a ? [this.pos[0], this.pos[1] + 10 + b * k.NODE_SLOT_HEIGHT + (this.constructor.slot_start_y || 0)] : [this.pos[0] + this.size[0] + 1, this.pos[1] + 10 + b * k.NODE_SLOT_HEIGHT + (this.constructor.slot_start_y || 0)]; - }; - h.prototype.alignToGrid = function() { - this.pos[0] = k.CANVAS_GRID_SIZE * Math.round(this.pos[0] / k.CANVAS_GRID_SIZE); - this.pos[1] = k.CANVAS_GRID_SIZE * Math.round(this.pos[1] / k.CANVAS_GRID_SIZE); - }; - h.prototype.trace = function(a) { - this.console || (this.console = []); - this.console.push(a); - this.console.length > h.MAX_CONSOLE && this.console.shift(); - this.graph.onNodeTrace(this, a); - }; - h.prototype.setDirtyCanvas = function(a, b) { - this.graph && this.graph.sendActionToCanvas("setDirty", [a, b]); - }; - h.prototype.loadImage = function(a) { - var b = new Image; - b.src = k.node_images_path + a; - b.ready = !1; - var e = this; - b.onload = function() { - this.ready = !0; - e.setDirtyCanvas(!0); - }; - return b; - }; - h.prototype.captureInput = function(a) { - if (this.graph && this.graph.list_of_graphcanvas) { - for (var b = this.graph.list_of_graphcanvas, e = 0; e < b.length; ++e) { - var c = b[e]; - if (a || c.node_capturing_input == this) { - c.node_capturing_input = a ? this : null; - } - } - } - }; - h.prototype.collapse = function(a) { - this.graph._version++; - if (!1 !== this.constructor.collapsable || a) { - this.flags.collapsed = this.flags.collapsed ? !1 : !0, this.setDirtyCanvas(!0, !0); - } - }; - h.prototype.pin = function(a) { - this.graph._version++; - this.flags.pinned = void 0 === a ? !this.flags.pinned : a; - }; - h.prototype.localToScreen = function(a, b, e) { - return [(a + this.pos[0]) * e.scale + e.offset[0], (b + this.pos[1]) * e.scale + e.offset[1]]; - }; - u.LGraphGroup = k.LGraphGroup = n; - n.prototype._ctor = function(a) { - this.title = a || "Group"; - this._bounding = new Float32Array([10, 10, 140, 80]); - this._pos = this._bounding.subarray(0, 2); - this._size = this._bounding.subarray(2, 4); - this._nodes = []; - this.color = d.node_colors.pale_blue ? d.node_colors.pale_blue.groupcolor : "#AAA"; - this.graph = null; - Object.defineProperty(this, "pos", {set:function(a) { - !a || 2 > a.length || (this._pos[0] = a[0], this._pos[1] = a[1]); - }, get:function() { - return this._pos; - }, enumerable:!0}); - Object.defineProperty(this, "size", {set:function(a) { - !a || 2 > a.length || (this._size[0] = Math.max(140, a[0]), this._size[1] = Math.max(80, a[1])); - }, get:function() { - return this._size; - }, enumerable:!0}); - }; - n.prototype.configure = function(a) { - this.title = a.title; - this._bounding.set(a.bounding); - this.color = a.color; - }; - n.prototype.serialize = function() { - var a = this._bounding; - return {title:this.title, bounding:[a[0], a[1], a[2], a[3]], color:this.color}; - }; - n.prototype.move = function(a, b, e) { - this._pos[0] += a; - this._pos[1] += b; - if (!e) { - for (e = 0; e < this._nodes.length; ++e) { - var c = this._nodes[e]; - c.pos[0] += a; - c.pos[1] += b; - } - } - }; - n.prototype.recomputeInsideNodes = function() { - this._nodes.length = 0; - for (var a = this.graph._nodes, b = new Float32Array(4), e = 0; e < a.length; ++e) { - var c = a[e]; - c.getBounding(b); - v(this._bounding, b) && this._nodes.push(c); - } - }; - n.prototype.isPointInside = h.prototype.isPointInside; - n.prototype.setDirtyCanvas = h.prototype.setDirtyCanvas; - u.LGraphCanvas = k.LGraphCanvas = d; - d.link_type_colors = {"-1":"#F85", number:"#AAC", node:"#DCA"}; - d.gradients = {}; - d.prototype.clear = function() { - this.fps = this.render_time = this.last_draw_time = this.frame = 0; - this.scale = 1; - this.offset = [0, 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; - if (this.onClear) { - this.onClear(); - } - }; - d.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))); - }; - d.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); - }; - d.prototype.closeSubgraph = function() { - if (this._graph_stack && 0 != this._graph_stack.length) { - var a = this._graph_stack.pop(); - this.selected_nodes = {}; - this.highlighted_links = {}; - a.attachCanvas(this); - this.setDirty(!0, !0); - } - }; - d.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)) { - a.className += " lgraphcanvas"; - a.data = this; - this.bgcanvas = null; - this.bgcanvas || (this.bgcanvas = document.createElement("canvas"), this.bgcanvas.width = this.canvas.width, this.bgcanvas.height = this.canvas.height); - if (null == a.getContext) { - if ("canvas" != a.localName) { - throw "Element supplied for LGraphCanvas must be a
\t\t\tuvcode must be vec2, is optional
\t\t\tuv: tex. coords
color: texture
colorB: textureB
time: scene time
value: input value
";this.properties={value:1,uvcode:"",pixelcode:"color + colorB * value", +precision:f.DEFAULT}};n.widgets_info={uvcode:{widget:"textarea",height:100},pixelcode:{widget:"textarea",height:100},precision:{widget:"combo",values:f.MODE_VALUES}};n.title="Operation";n.desc="Texture shader operation";n.prototype.getExtraMenuOptions=function(a){var b=this;return[{content:b.properties.show?"Hide Texture":"Show Texture",callback:function(){b.properties.show=!b.properties.show}}]};n.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())};n.prototype.onExecute=function(){var a=this.getInputData(0);if(this.isOutputConnected(0))if(this.properties.precision===f.PASS_THROUGH)this.setOutputData(0,a);else{var b=this.getInputData(1);if(this.properties.uvcode||this.properties.pixelcode){var c=512,d=512;a?(c=a.width,d=a.height):b&&(c=b.width,d=b.height);var e=f.getTextureType(this.properties.precision,a);this._tex=a||this._tex?f.getTargetTexture(a|| +this._tex,this._tex,this.properties.precision):new GL.Texture(c,d,{type:e,format:gl.RGBA,filter:gl.LINEAR});e="";this.properties.uvcode&&(e="uv = "+this.properties.uvcode,-1!=this.properties.uvcode.indexOf(";")&&(e=this.properties.uvcode));var k="";this.properties.pixelcode&&(k="result = "+this.properties.pixelcode,-1!=this.properties.pixelcode.indexOf(";")&&(k=this.properties.pixelcode));var g=this._shader;if(!g||this._shader_code!=e+"|"+k){try{this._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER, +n.pixel_shader,{UV_CODE:e,PIXEL_CODE:k}),this.boxcolor="#00FF00"}catch(h){console.log("Error compiling shader: ",h);this.boxcolor="#FF0000";return}this.boxcolor="#FF0000";this._shader_code=e+"|"+k;g=this._shader}if(g){this.boxcolor="green";var l=this.getInputData(2);null!=l?this.properties.value=l:l=parseFloat(this.properties.value);var m=this.graph.getTime();this._tex.drawTo(function(){gl.disable(gl.DEPTH_TEST);gl.disable(gl.CULL_FACE);gl.disable(gl.BLEND);a&&a.bind(0);b&&b.bind(1);var e=Mesh.getScreenQuad(); +g.uniforms({u_texture:0,u_textureB:1,value:l,texSize:[c,d],time:m}).draw(e)});this.setOutputData(0,this._tex)}else this.boxcolor="red"}}};n.pixel_shader="precision highp float;\n\t\t\t\n\t\t\tuniform sampler2D u_texture;\n\t\t\tuniform sampler2D u_textureB;\n\t\t\tvarying vec2 v_coord;\n\t\t\tuniform vec2 texSize;\n\t\t\tuniform float time;\n\t\t\tuniform float value;\n\t\t\t\n\t\t\tvoid main() {\n\t\t\t\tvec2 uv = v_coord;\n\t\t\t\tUV_CODE;\n\t\t\t\tvec4 color4 = texture2D(u_texture, uv);\n\t\t\t\tvec3 color = color4.rgb;\n\t\t\t\tvec4 color4B = texture2D(u_textureB, uv);\n\t\t\t\tvec3 colorB = color4B.rgb;\n\t\t\t\tvec3 result = color;\n\t\t\t\tfloat alpha = 1.0;\n\t\t\t\tPIXEL_CODE;\n\t\t\t\tgl_FragColor = vec4(result, alpha);\n\t\t\t}\n\t\t\t"; +h.registerNodeType("texture/operation",n);var s=function(){this.addOutput("out","Texture");this.properties={code:"",width:512,height:512,precision:f.DEFAULT};this.properties.code="\nvoid main() {\n vec2 uv = v_coord;\n vec3 color = vec3(0.0);\n//your code here\n\ngl_FragColor = vec4(color, 1.0);\n}\n";this._uniforms={in_texture:0,texSize:vec2.create(),time:0}};s.title="Shader";s.desc="Texture shader";s.widgets_info={code:{type:"code"},precision:{widget:"combo",values:f.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=0;f>=1;1<(c|0)&&(c>>=1);if(2>b)break;l=g[r]=GL.Texture.getTemporary(b,c,d);n[0]=1/m.width;n[1]=1/m.height;m.blit(l,h.uniforms(k));m=l}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/m.width,n[1]=1/m.height,k.u_intensity= +s,k.u_delta=1,m.blit(b,h.uniforms(k)),this.setOutputData(2,b));gl.enable(gl.BLEND);gl.blendFunc(gl.ONE,gl.ONE);k.u_intensity=this.getInputOrProperty("persistence");k.u_delta=0.5;for(r-=2;0<=r;r--)l=g[r],g[r]=null,n[0]=1/m.width,n[1]=1/m.height,m.blit(l,h.uniforms(k)),GL.Texture.releaseTemporary(m),m=l;gl.disable(gl.BLEND);this.isOutputConnected(1)&&(g=this._glow_texture,g&&g.width==a.width&&g.height==a.height&&g.type==e&&g.format==a.format||(g=this._glow_texture=new GL.Texture(a.width,a.height,{type:e, +format:a.format,filter:gl.LINEAR})),m.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==e&&g.format==a.format||(g=this._final_texture=new GL.Texture(a.width,a.height,{type:e,format:a.format,filter:gl.LINEAR}));var p=this.getInputData(1),v=this.getInputOrProperty("dirt_factor");k.u_intensity=s;h=p?y._dirt_final_shader:y._final_shader;h||(h=p?y._dirt_final_shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,y.final_pixel_shader, +{USE_DIRT:""}):y._final_shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,y.final_pixel_shader));g.drawTo(function(){a.bind(0);m.bind(1);p&&(h.setUniform("u_dirt_factor",v),h.setUniform("u_dirt_texture",p.bind(2)));h.toViewport(k)});this.setOutputData(0,g)}GL.Texture.releaseTemporary(m)}};y.cut_pixel_shader="precision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_texture;\n\t\tuniform float u_threshold;\n\t\tvoid main() {\n\t\t\tgl_FragColor = max( texture2D( u_texture, v_coord ) - vec4( u_threshold ), vec4(0.0) );\n\t\t}"; y.scale_pixel_shader="precision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_texture;\n\t\tuniform vec2 u_texel_size;\n\t\tuniform float u_delta;\n\t\tuniform float u_intensity;\n\t\t\n\t\tvec4 sampleBox(vec2 uv) {\n\t\t\tvec4 o = u_texel_size.xyxy * vec2(-u_delta, u_delta).xxyy;\n\t\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\t\treturn s * 0.25;\n\t\t}\n\t\tvoid main() {\n\t\t\tgl_FragColor = u_intensity * sampleBox( v_coord );\n\t\t}"; y.final_pixel_shader="precision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_texture;\n\t\tuniform sampler2D u_glow_texture;\n\t\t#ifdef USE_DIRT\n\t\t\tuniform sampler2D u_dirt_texture;\n\t\t#endif\n\t\tuniform vec2 u_texel_size;\n\t\tuniform float u_delta;\n\t\tuniform float u_intensity;\n\t\tuniform float u_dirt_factor;\n\t\t\n\t\tvec4 sampleBox(vec2 uv) {\n\t\t\tvec4 o = u_texel_size.xyxy * vec2(-u_delta, u_delta).xxyy;\n\t\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\t\treturn s * 0.25;\n\t\t}\n\t\tvoid main() {\n\t\t\tvec4 glow = sampleBox( v_coord );\n\t\t\t#ifdef USE_DIRT\n\t\t\t\tglow = mix( glow, glow * texture2D( u_dirt_texture, v_coord ), u_dirt_factor );\n\t\t\t#endif\n\t\t\tgl_FragColor = texture2D( u_texture, v_coord ) + u_intensity * glow;\n\t\t}"; -h.registerNodeType("texture/glow",y);var n=function(){this.addInput("Texture","Texture");this.addOutput("Filtered","Texture");this.properties={intensity:1,radius:5}};n.title="Kuwahara Filter";n.desc="Filters a texture giving an artistic oil canvas painting";n.max_radius=10;n._shaders=[];n.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),n.max_radius);if(0==b)this.setOutputData(0,a);else{var c=this.properties.intensity,d=h.camera_aspect;d||void 0===window.gl||(d=gl.canvas.height/gl.canvas.width);d||(d=1);d=this.properties.preserve_aspect?d:1;n._shaders[b]||(n._shaders[b]=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,n.pixel_shader,{RADIUS:b.toFixed(0)}));var e=n._shaders[b],l=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(l)});this.setOutputData(0,this._temp_texture)}}};n.pixel_shader="\n\tprecision highp float;\n\tvarying vec2 v_coord;\n\tuniform sampler2D u_texture;\n\tuniform float u_intensity;\n\tuniform vec2 u_resolution;\n\tuniform vec2 u_iResolution;\n\t#ifndef RADIUS\n\t\t#define RADIUS 7\n\t#endif\n\tvoid main() {\n\t\n\t\tconst int radius = RADIUS;\n\t\tvec2 fragCoord = v_coord;\n\t\tvec2 src_size = u_iResolution;\n\t\tvec2 uv = v_coord;\n\t\tfloat n = float((radius + 1) * (radius + 1));\n\t\tint i;\n\t\tint j;\n\t\tvec3 m0 = vec3(0.0); vec3 m1 = vec3(0.0); vec3 m2 = vec3(0.0); vec3 m3 = vec3(0.0);\n\t\tvec3 s0 = vec3(0.0); vec3 s1 = vec3(0.0); vec3 s2 = vec3(0.0); vec3 s3 = vec3(0.0);\n\t\tvec3 c;\n\t\t\n\t\tfor (int j = -radius; j <= 0; ++j) {\n\t\t\tfor (int i = -radius; i <= 0; ++i) {\n\t\t\t\tc = texture2D(u_texture, uv + vec2(i,j) * src_size).rgb;\n\t\t\t\tm0 += c;\n\t\t\t\ts0 += c * c;\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor (int j = -radius; j <= 0; ++j) {\n\t\t\tfor (int i = 0; i <= radius; ++i) {\n\t\t\t\tc = texture2D(u_texture, uv + vec2(i,j) * src_size).rgb;\n\t\t\t\tm1 += c;\n\t\t\t\ts1 += c * c;\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor (int j = 0; j <= radius; ++j) {\n\t\t\tfor (int i = 0; i <= radius; ++i) {\n\t\t\t\tc = texture2D(u_texture, uv + vec2(i,j) * src_size).rgb;\n\t\t\t\tm2 += c;\n\t\t\t\ts2 += c * c;\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor (int j = 0; j <= radius; ++j) {\n\t\t\tfor (int i = -radius; i <= 0; ++i) {\n\t\t\t\tc = texture2D(u_texture, uv + vec2(i,j) * src_size).rgb;\n\t\t\t\tm3 += c;\n\t\t\t\ts3 += c * c;\n\t\t\t}\n\t\t}\n\t\t\n\t\tfloat min_sigma2 = 1e+2;\n\t\tm0 /= n;\n\t\ts0 = abs(s0 / n - m0 * m0);\n\t\t\n\t\tfloat sigma2 = s0.r + s0.g + s0.b;\n\t\tif (sigma2 < min_sigma2) {\n\t\t\tmin_sigma2 = sigma2;\n\t\t\tgl_FragColor = vec4(m0, 1.0);\n\t\t}\n\t\t\n\t\tm1 /= n;\n\t\ts1 = abs(s1 / n - m1 * m1);\n\t\t\n\t\tsigma2 = s1.r + s1.g + s1.b;\n\t\tif (sigma2 < min_sigma2) {\n\t\t\tmin_sigma2 = sigma2;\n\t\t\tgl_FragColor = vec4(m1, 1.0);\n\t\t}\n\t\t\n\t\tm2 /= n;\n\t\ts2 = abs(s2 / n - m2 * m2);\n\t\t\n\t\tsigma2 = s2.r + s2.g + s2.b;\n\t\tif (sigma2 < min_sigma2) {\n\t\t\tmin_sigma2 = sigma2;\n\t\t\tgl_FragColor = vec4(m2, 1.0);\n\t\t}\n\t\t\n\t\tm3 /= n;\n\t\ts3 = abs(s3 / n - m3 * m3);\n\t\t\n\t\tsigma2 = s3.r + s3.g + s3.b;\n\t\tif (sigma2 < min_sigma2) {\n\t\t\tmin_sigma2 = sigma2;\n\t\t\tgl_FragColor = vec4(m3, 1.0);\n\t\t}\n\t}\n\t"; -h.registerNodeType("texture/kuwahara",n);d=function(){this.addOutput("Webcam","Texture");this.properties={texture_name:""}};d.title="Webcam";d.desc="Webcam texture";d.prototype.openStream=function(){function a(c){console.log("Webcam rejected",c);b._webcam_stream=!1;b.box_color="red"}navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;window.URL=window.URL||window.webkitURL;if(navigator.getUserMedia){this._waiting_confirmation= +h.registerNodeType("texture/glow",y);var r=function(){this.addInput("Texture","Texture");this.addOutput("Filtered","Texture");this.properties={intensity:1,radius:5}};r.title="Kuwahara Filter";r.desc="Filters a texture giving an artistic oil canvas painting";r.max_radius=10;r._shaders=[];r.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),r.max_radius);if(0==b)this.setOutputData(0,a);else{var c=this.properties.intensity,d=h.camera_aspect;d||void 0===window.gl||(d=gl.canvas.height/gl.canvas.width);d||(d=1);d=this.properties.preserve_aspect?d:1;r._shaders[b]||(r._shaders[b]=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,r.pixel_shader,{RADIUS:b.toFixed(0)}));var e=r._shaders[b],k=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(k)});this.setOutputData(0,this._temp_texture)}}};r.pixel_shader="\n\tprecision highp float;\n\tvarying vec2 v_coord;\n\tuniform sampler2D u_texture;\n\tuniform float u_intensity;\n\tuniform vec2 u_resolution;\n\tuniform vec2 u_iResolution;\n\t#ifndef RADIUS\n\t\t#define RADIUS 7\n\t#endif\n\tvoid main() {\n\t\n\t\tconst int radius = RADIUS;\n\t\tvec2 fragCoord = v_coord;\n\t\tvec2 src_size = u_iResolution;\n\t\tvec2 uv = v_coord;\n\t\tfloat n = float((radius + 1) * (radius + 1));\n\t\tint i;\n\t\tint j;\n\t\tvec3 m0 = vec3(0.0); vec3 m1 = vec3(0.0); vec3 m2 = vec3(0.0); vec3 m3 = vec3(0.0);\n\t\tvec3 s0 = vec3(0.0); vec3 s1 = vec3(0.0); vec3 s2 = vec3(0.0); vec3 s3 = vec3(0.0);\n\t\tvec3 c;\n\t\t\n\t\tfor (int j = -radius; j <= 0; ++j) {\n\t\t\tfor (int i = -radius; i <= 0; ++i) {\n\t\t\t\tc = texture2D(u_texture, uv + vec2(i,j) * src_size).rgb;\n\t\t\t\tm0 += c;\n\t\t\t\ts0 += c * c;\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor (int j = -radius; j <= 0; ++j) {\n\t\t\tfor (int i = 0; i <= radius; ++i) {\n\t\t\t\tc = texture2D(u_texture, uv + vec2(i,j) * src_size).rgb;\n\t\t\t\tm1 += c;\n\t\t\t\ts1 += c * c;\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor (int j = 0; j <= radius; ++j) {\n\t\t\tfor (int i = 0; i <= radius; ++i) {\n\t\t\t\tc = texture2D(u_texture, uv + vec2(i,j) * src_size).rgb;\n\t\t\t\tm2 += c;\n\t\t\t\ts2 += c * c;\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor (int j = 0; j <= radius; ++j) {\n\t\t\tfor (int i = -radius; i <= 0; ++i) {\n\t\t\t\tc = texture2D(u_texture, uv + vec2(i,j) * src_size).rgb;\n\t\t\t\tm3 += c;\n\t\t\t\ts3 += c * c;\n\t\t\t}\n\t\t}\n\t\t\n\t\tfloat min_sigma2 = 1e+2;\n\t\tm0 /= n;\n\t\ts0 = abs(s0 / n - m0 * m0);\n\t\t\n\t\tfloat sigma2 = s0.r + s0.g + s0.b;\n\t\tif (sigma2 < min_sigma2) {\n\t\t\tmin_sigma2 = sigma2;\n\t\t\tgl_FragColor = vec4(m0, 1.0);\n\t\t}\n\t\t\n\t\tm1 /= n;\n\t\ts1 = abs(s1 / n - m1 * m1);\n\t\t\n\t\tsigma2 = s1.r + s1.g + s1.b;\n\t\tif (sigma2 < min_sigma2) {\n\t\t\tmin_sigma2 = sigma2;\n\t\t\tgl_FragColor = vec4(m1, 1.0);\n\t\t}\n\t\t\n\t\tm2 /= n;\n\t\ts2 = abs(s2 / n - m2 * m2);\n\t\t\n\t\tsigma2 = s2.r + s2.g + s2.b;\n\t\tif (sigma2 < min_sigma2) {\n\t\t\tmin_sigma2 = sigma2;\n\t\t\tgl_FragColor = vec4(m2, 1.0);\n\t\t}\n\t\t\n\t\tm3 /= n;\n\t\ts3 = abs(s3 / n - m3 * m3);\n\t\t\n\t\tsigma2 = s3.r + s3.g + s3.b;\n\t\tif (sigma2 < min_sigma2) {\n\t\t\tmin_sigma2 = sigma2;\n\t\t\tgl_FragColor = vec4(m3, 1.0);\n\t\t}\n\t}\n\t"; +h.registerNodeType("texture/kuwahara",r);d=function(){this.addOutput("Webcam","Texture");this.properties={texture_name:""}};d.title="Webcam";d.desc="Webcam texture";d.prototype.openStream=function(){function a(c){console.log("Webcam rejected",c);b._webcam_stream=!1;b.box_color="red"}navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;window.URL=window.URL||window.webkitURL;if(navigator.getUserMedia){this._waiting_confirmation= !0;var b=this;navigator.getUserMedia({video:!0},this.streamReady.bind(this),a)}};d.prototype.streamReady=function(a){this._webcam_stream=a;var b=this._video;b||(b=document.createElement("video"),b.autoplay=!0,b.src=window.URL.createObjectURL(a),this._video=b,b.onloadedmetadata=function(a){console.log(a)})};d.prototype.onRemoved=function(){if(this._webcam_stream){var a=this._webcam_stream.getVideoTracks();a.length&&(a=a[0],a.stop&&a.stop());this._video=this._webcam_stream=null}};d.prototype.onDrawBackground= function(a){this.flags.collapsed||20>=this.size[1]||!this._video||(a.save(),a.webgl?this._temp_texture&&a.drawImage(this._temp_texture,0,0,this.size[0],this.size[1]):(a.translate(0,this.size[1]),a.scale(1,-1),a.drawImage(this._video,0,0,this.size[0],this.size[1])),a.restore())};d.prototype.onExecute=function(){null!=this._webcam_stream||this._waiting_confirmation||this.openStream();if(this._video&&this._video.videoWidth){var a=this._video.videoWidth,b=this._video.videoHeight,c=this._temp_texture; c&&c.width==a&&c.height==b||(this._temp_texture=new GL.Texture(a,b,{format:gl.RGB,filter:gl.LINEAR}));this._temp_texture.uploadImage(this._video);this.properties.texture_name&&(f.getTexturesContainer()[this.properties.texture_name]=this._temp_texture);this.setOutputData(0,this._temp_texture)}};h.registerNodeType("texture/webcam",d);var A=function(){this.addInput("in","Texture");this.addInput("f","number");this.addOutput("out","Texture");this.properties={enabled:!0,factor:1,precision:f.LOW};this._uniforms= @@ -8639,37 +403,37 @@ a);else{var b=this._temp_texture;b&&b.width==a.width&&b.height==a.height&&b.type e.u_igamma=1/this.properties.gamma;gl.disable(gl.DEPTH_TEST);b.drawTo(function(){a.bind(0);c.uniforms(e).draw(GL.Mesh.getScreenQuad())});this.setOutputData(0,this._temp_texture)}};B.pixel_shader="precision highp float;\n\t\t\tvarying vec2 v_coord;\n\t\t\tuniform sampler2D u_texture;\n\t\t\tuniform float u_scale;\n\t\t\tuniform float u_average_lum;\n\t\t\tuniform float u_lumwhite2;\n\t\t\tuniform float u_igamma;\n\t\t\tvec3 RGB2xyY (vec3 rgb)\n\t\t\t{\n\t\t\t\t const mat3 RGB2XYZ = mat3(0.4124, 0.3576, 0.1805,\n\t\t\t\t\t\t\t\t\t\t 0.2126, 0.7152, 0.0722,\n\t\t\t\t\t\t\t\t\t\t 0.0193, 0.1192, 0.9505);\n\t\t\t\tvec3 XYZ = RGB2XYZ * rgb;\n\t\t\t\t\n\t\t\t\tfloat f = (XYZ.x + XYZ.y + XYZ.z);\n\t\t\t\treturn vec3(XYZ.x / f,\n\t\t\t\t\t\t\tXYZ.y / f,\n\t\t\t\t\t\t\tXYZ.y);\n\t\t\t}\n\t\t\t\n\t\t\tvoid main() {\n\t\t\t\tvec4 color = texture2D( u_texture, v_coord );\n\t\t\t\tvec3 rgb = color.xyz;\n\t\t\t\t//Ld - this part of the code is the same for both versions\n\t\t\t\tfloat lum = dot(rgb, vec3(0.2126, 0.7152, 0.0722));\n\t\t\t\tfloat L = (u_scale / u_average_lum) * lum;\n\t\t\t\tfloat Ld = (L * (1.0 + L / u_lumwhite2)) / (1.0 + L);\n\t\t\t\t//first\n\t\t\t\t//vec3 xyY = RGB2xyY(rgb);\n\t\t\t\t//xyY.z *= Ld;\n\t\t\t\t//rgb = xyYtoRGB(xyY);\n\t\t\t\t//second\n\t\t\t\trgb = (rgb / lum) * Ld;\n\t\t\t\trgb = pow( rgb, vec3( u_igamma ) );\n\t\t\t\tgl_FragColor = vec4( rgb, color.a );\n\t\t\t}"; h.registerNodeType("texture/tonemapping",B);var x=function(){this.addOutput("out","Texture");this.properties={width:512,height:512,seed:0,persistence:0.1,octaves:8,scale:1,offset:[0,0],amplitude:1,precision:f.DEFAULT};this._key=0;this._uniforms={u_persistence:0.1,u_seed:0,u_offset:vec2.create(),u_scale:1,u_viewport:vec2.create()}};x.title="Perlin";x.desc="Generates a perlin noise texture";x.widgets_info={precision:{widget:"combo",values:f.MODE_VALUES},width:{type:"Number",precision:0,step:1},height:{type:"Number", precision:0,step:1},octaves:{type:"Number",precision:0,step:1,min:1,max:50}};x.prototype.onExecute=function(){if(this.isOutputConnected(0)){var a=this.properties.width|0,b=this.properties.height|0;0==a&&(a=gl.viewport_data[2]);0==b&&(b=gl.viewport_data[3]);var c=f.getTextureType(this.properties.precision),d=this._temp_texture;d&&d.width==a&&d.height==b&&d.type==c||(d=this._temp_texture=new GL.Texture(a,b,{type:c,format:gl.RGB,filter:gl.LINEAR}));c=a+b+c+this.properties.persistence+this.properties.octaves+ -this.properties.scale+this.properties.seed+this.properties.offset[0]+this.properties.offset[1]+this.properties.amplitude;if(c!=this._key){this._key=c;var e=this._uniforms;e.u_persistence=this.properties.persistence;e.u_octaves=this.properties.octaves;e.u_offset[0]=this.properties.offset[0];e.u_offset[1]=this.properties.offset[1];e.u_scale=this.properties.scale;e.u_amplitude=this.properties.amplitude;e.u_viewport[0]=a;e.u_viewport[1]=b;e.u_seed=128*this.properties.seed;var l=x._shader;l||(l=x._shader= -new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,x.pixel_shader));gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);d.drawTo(function(){l.uniforms(e).draw(GL.Mesh.getScreenQuad())})}this.setOutputData(0,d)}};x.pixel_shader="precision highp float;\n\t\t\tvarying vec2 v_coord;\n\t\t\tuniform vec2 u_offset;\n\t\t\tuniform float u_scale;\n\t\t\tuniform float u_persistence;\n\t\t\tuniform int u_octaves;\n\t\t\tuniform float u_amplitude;\n\t\t\tuniform vec2 u_viewport;\n\t\t\tuniform float u_seed;\n\t\t\t#define M_PI 3.14159265358979323846\n\t\t\t\n\t\t\tfloat rand(vec2 c){\treturn fract(sin(dot(c.xy ,vec2( 12.9898 + u_seed,78.233 + u_seed))) * 43758.5453); }\n\t\t\t\n\t\t\tfloat noise(vec2 p, float freq ){\n\t\t\t\tfloat unit = u_viewport.x/freq;\n\t\t\t\tvec2 ij = floor(p/unit);\n\t\t\t\tvec2 xy = mod(p,unit)/unit;\n\t\t\t\t//xy = 3.*xy*xy-2.*xy*xy*xy;\n\t\t\t\txy = .5*(1.-cos(M_PI*xy));\n\t\t\t\tfloat a = rand((ij+vec2(0.,0.)));\n\t\t\t\tfloat b = rand((ij+vec2(1.,0.)));\n\t\t\t\tfloat c = rand((ij+vec2(0.,1.)));\n\t\t\t\tfloat d = rand((ij+vec2(1.,1.)));\n\t\t\t\tfloat x1 = mix(a, b, xy.x);\n\t\t\t\tfloat x2 = mix(c, d, xy.x);\n\t\t\t\treturn mix(x1, x2, xy.y);\n\t\t\t}\n\t\t\t\n\t\t\tfloat pNoise(vec2 p, int res){\n\t\t\t\tfloat persistance = u_persistence;\n\t\t\t\tfloat n = 0.;\n\t\t\t\tfloat normK = 0.;\n\t\t\t\tfloat f = 4.;\n\t\t\t\tfloat amp = 1.0;\n\t\t\t\tint iCount = 0;\n\t\t\t\tfor (int i = 0; i<50; i++){\n\t\t\t\t\tn+=amp*noise(p, f);\n\t\t\t\t\tf*=2.;\n\t\t\t\t\tnormK+=amp;\n\t\t\t\t\tamp*=persistance;\n\t\t\t\t\tif (iCount >= res)\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tiCount++;\n\t\t\t\t}\n\t\t\t\tfloat nf = n/normK;\n\t\t\t\treturn nf*nf*nf*nf;\n\t\t\t}\n\t\t\tvoid main() {\n\t\t\t\tvec2 uv = v_coord * u_scale * u_viewport + u_offset * u_scale;\n\t\t\t\tvec4 color = vec4( pNoise( uv, u_octaves ) * u_amplitude );\n\t\t\t\tgl_FragColor = color;\n\t\t\t}"; +this.properties.scale+this.properties.seed+this.properties.offset[0]+this.properties.offset[1]+this.properties.amplitude;if(c!=this._key){this._key=c;var e=this._uniforms;e.u_persistence=this.properties.persistence;e.u_octaves=this.properties.octaves;e.u_offset[0]=this.properties.offset[0];e.u_offset[1]=this.properties.offset[1];e.u_scale=this.properties.scale;e.u_amplitude=this.properties.amplitude;e.u_viewport[0]=a;e.u_viewport[1]=b;e.u_seed=128*this.properties.seed;var k=x._shader;k||(k=x._shader= +new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,x.pixel_shader));gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);d.drawTo(function(){k.uniforms(e).draw(GL.Mesh.getScreenQuad())})}this.setOutputData(0,d)}};x.pixel_shader="precision highp float;\n\t\t\tvarying vec2 v_coord;\n\t\t\tuniform vec2 u_offset;\n\t\t\tuniform float u_scale;\n\t\t\tuniform float u_persistence;\n\t\t\tuniform int u_octaves;\n\t\t\tuniform float u_amplitude;\n\t\t\tuniform vec2 u_viewport;\n\t\t\tuniform float u_seed;\n\t\t\t#define M_PI 3.14159265358979323846\n\t\t\t\n\t\t\tfloat rand(vec2 c){\treturn fract(sin(dot(c.xy ,vec2( 12.9898 + u_seed,78.233 + u_seed))) * 43758.5453); }\n\t\t\t\n\t\t\tfloat noise(vec2 p, float freq ){\n\t\t\t\tfloat unit = u_viewport.x/freq;\n\t\t\t\tvec2 ij = floor(p/unit);\n\t\t\t\tvec2 xy = mod(p,unit)/unit;\n\t\t\t\t//xy = 3.*xy*xy-2.*xy*xy*xy;\n\t\t\t\txy = .5*(1.-cos(M_PI*xy));\n\t\t\t\tfloat a = rand((ij+vec2(0.,0.)));\n\t\t\t\tfloat b = rand((ij+vec2(1.,0.)));\n\t\t\t\tfloat c = rand((ij+vec2(0.,1.)));\n\t\t\t\tfloat d = rand((ij+vec2(1.,1.)));\n\t\t\t\tfloat x1 = mix(a, b, xy.x);\n\t\t\t\tfloat x2 = mix(c, d, xy.x);\n\t\t\t\treturn mix(x1, x2, xy.y);\n\t\t\t}\n\t\t\t\n\t\t\tfloat pNoise(vec2 p, int res){\n\t\t\t\tfloat persistance = u_persistence;\n\t\t\t\tfloat n = 0.;\n\t\t\t\tfloat normK = 0.;\n\t\t\t\tfloat f = 4.;\n\t\t\t\tfloat amp = 1.0;\n\t\t\t\tint iCount = 0;\n\t\t\t\tfor (int i = 0; i<50; i++){\n\t\t\t\t\tn+=amp*noise(p, f);\n\t\t\t\t\tf*=2.;\n\t\t\t\t\tnormK+=amp;\n\t\t\t\t\tamp*=persistance;\n\t\t\t\t\tif (iCount >= res)\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tiCount++;\n\t\t\t\t}\n\t\t\t\tfloat nf = n/normK;\n\t\t\t\treturn nf*nf*nf*nf;\n\t\t\t}\n\t\t\tvoid main() {\n\t\t\t\tvec2 uv = v_coord * u_scale * u_viewport + u_offset * u_scale;\n\t\t\t\tvec4 color = vec4( pNoise( uv, u_octaves ) * u_amplitude );\n\t\t\t\tgl_FragColor = color;\n\t\t\t}"; h.registerNodeType("texture/perlin",x);d=function(){this.addOutput("out","Texture");this.properties={code:"",width:512,height:512,precision:f.DEFAULT};this._temp_texture=this._func=null};d.title="Canvas2D";d.desc="Executes Canvas2D code inside a texture or the viewport";d.widgets_info={precision:{widget:"combo",values:f.MODE_VALUES},code:{type:"code"},width:{type:"Number",precision:0,step:1},height:{type:"Number",precision:0,step:1}};d.prototype.onPropertyChanged=function(a,b){if("code"==a&&h.allow_scripts){this._func= null;try{this._func=new Function("canvas","ctx","time","script",b),this.boxcolor="#00FF00"}catch(c){this.boxcolor="#FF0000",console.error("Error parsing script"),console.error(c)}}};d.prototype.onExecute=function(){var a=this._func;if(a&&this.isOutputConnected(0))if(u.enableWebGLCanvas){var b=this.properties.width||gl.canvas.width,c=this.properties.height||gl.canvas.height,d=this._temp_texture;d&&d.width==b&&d.height==c||(d=this._temp_texture=new GL.Texture(b,c,{format:gl.RGBA,filter:gl.LINEAR})); -var e=this,l=this.graph.getTime();d.drawTo(function(){gl.start2D();try{a.draw?a.draw.call(e,gl.canvas,gl,l,a):a.call(e,gl.canvas,gl,l,a),e.boxcolor="#00FF00"}catch(b){e.boxcolor="#FF0000",console.error("Error executing script"),console.error(b)}gl.finish2D()});this.setOutputData(0,d)}else console.warn("cannot use LGraphTextureCanvas2D if Canvas2DtoWebGL is not included")};h.registerNodeType("texture/canvas2D",d);var z=function(){this.addInput("in","Texture");this.addOutput("out","Texture");this.properties= +var e=this,k=this.graph.getTime();d.drawTo(function(){gl.start2D();try{a.draw?a.draw.call(e,gl.canvas,gl,k,a):a.call(e,gl.canvas,gl,k,a),e.boxcolor="#00FF00"}catch(b){e.boxcolor="#FF0000",console.error("Error executing script"),console.error(b)}gl.finish2D()});this.setOutputData(0,d)}else console.warn("cannot use LGraphTextureCanvas2D if Canvas2DtoWebGL is not included")};h.registerNodeType("texture/canvas2D",d);var z=function(){this.addInput("in","Texture");this.addOutput("out","Texture");this.properties= {key_color:vec3.fromValues(0,1,0),threshold:0.8,slope:0.2,precision:f.DEFAULT}};z.title="Matte";z.desc="Extracts background";z.widgets_info={key_color:{widget:"color"},precision:{widget:"combo",values:f.MODE_VALUES}};z.prototype.onExecute=function(){if(this.isOutputConnected(0)){var a=this.getInputData(0);if(this.properties.precision===f.PASS_THROUGH)this.setOutputData(0,a);else if(a){this._tex=f.getTargetTexture(a,this._tex,this.properties.precision);gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST); this._uniforms||(this._uniforms={u_texture:0,u_key_color:this.properties.key_color,u_threshold:1,u_slope:1});var b=this._uniforms,c=Mesh.getScreenQuad(),d=z._shader;d||(d=z._shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,z.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);d.uniforms(b).draw(c)});this.setOutputData(0,this._tex)}}};z.pixel_shader="precision highp float;\n\t\t\tvarying vec2 v_coord;\n\t\t\tuniform sampler2D u_texture;\n\t\t\tuniform vec3 u_key_color;\n\t\t\tuniform float u_threshold;\n\t\t\tuniform float u_slope;\n\t\t\t\n\t\t\tvoid main() {\n\t\t\t\tvec3 color = texture2D( u_texture, v_coord ).xyz;\n\t\t\t\tfloat diff = length( normalize(color) - normalize(u_key_color) );\n\t\t\t\tfloat edge = u_threshold * (1.0 - u_slope);\n\t\t\t\tfloat alpha = smoothstep( edge, u_threshold, diff);\n\t\t\t\tgl_FragColor = vec4( color, alpha );\n\t\t\t}"; h.registerNodeType("texture/matte",z);d=function(){this.addOutput("Cubemap","Cubemap");this.properties={name:""};this.size=[f.image_preview_size,f.image_preview_size]};d.title="Cubemap";d.prototype.onDropFile=function(a,b,c){a?(this._drop_texture="string"==typeof a?GL.Texture.fromURL(a):GL.Texture.fromDDSInMemory(a),this.properties.name=b):(this._drop_texture=null,this.properties.name="")};d.prototype.onExecute=function(){if(this._drop_texture)this.setOutputData(0,this._drop_texture);else if(this.properties.name){var a= f.getTexture(this.properties.name);a&&(this._last_tex=a,this.setOutputData(0,a))}};d.prototype.onDrawBackground=function(a){this.flags.collapsed||20>=this.size[1]||a.webgl&&(gl.meshes.cube||(gl.meshes.cube=GL.Mesh.cube({size:1})))};h.registerNodeType("texture/cubemap",d)}})(this); (function(u){var h=u.LiteGraph;if("undefined"!=typeof GL){var f=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};f._shader||(f._shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,f.pixel_shader),f._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]}))};f.title="Lens";f.desc="Camera Lens distortion";f.widgets_info={precision:{widget:"combo",values:LGraphTexture.MODE_VALUES}};f.prototype.onExecute=function(){var d=this.getInputData(0);if(this.properties.precision===LGraphTexture.PASS_THROUGH)this.setOutputData(0,d);else if(d){this._tex=LGraphTexture.getTargetTexture(d,this._tex,this.properties.precision);var h=this.properties.aberration;this.isInputConnected(1)&&(h=this.getInputData(1), -this.properties.aberration=h);var q=this.properties.distortion;this.isInputConnected(2)&&(q=this.getInputData(2),this.properties.distortion=q);var k=this.properties.blur;this.isInputConnected(3)&&(k=this.getInputData(3),this.properties.blur=k);gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var m=Mesh.getScreenQuad(),b=f._shader;this._tex.drawTo(function(){d.bind(0);b.uniforms({u_texture:0,u_aberration:h,u_distortion:q,u_blur:k}).draw(m)});this.setOutputData(0,this._tex)}};f.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"; +this.properties.aberration=h);var n=this.properties.distortion;this.isInputConnected(2)&&(n=this.getInputData(2),this.properties.distortion=n);var l=this.properties.blur;this.isInputConnected(3)&&(l=this.getInputData(3),this.properties.blur=l);gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var m=Mesh.getScreenQuad(),b=f._shader;this._tex.drawTo(function(){d.bind(0);b.uniforms({u_texture:0,u_aberration:h,u_distortion:n,u_blur:l}).draw(m)});this.setOutputData(0,this._tex)}};f.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"; h.registerNodeType("fx/lens",f);u.LGraphFXLens=f;var p=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}};p.title="Bokeh";p.desc="applies an Bokeh effect";p.widgets_info={shape:{widget:"texture"}};p.prototype.onExecute=function(){var d=this.getInputData(0),f=this.getInputData(1),h=this.getInputData(2); -if(d&&h&&this.properties.shape){f||(f=d);var k=LGraphTexture.getTexture(this.properties.shape);if(k){var m=this.properties.threshold;this.isInputConnected(3)&&(m=this.getInputData(3),this.properties.threshold=m);var b=gl.UNSIGNED_BYTE;this.properties.high_precision&&(b=gl.half_float_ext?gl.HALF_FLOAT_OES:gl.FLOAT);this._temp_texture&&this._temp_texture.type==b&&this._temp_texture.width==d.width&&this._temp_texture.height==d.height||(this._temp_texture=new GL.Texture(d.width,d.height,{type:b,format:gl.RGBA, -filter:gl.LINEAR}));var a=p._first_shader;a||(a=p._first_shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,p._first_pixel_shader));var c=p._second_shader;c||(c=p._second_shader=new GL.Shader(p._second_vertex_shader,p._second_pixel_shader));var g=this._points_mesh;g&&g._width==d.width&&g._height==d.height&&2==g._spacing||(g=this.createPointsMesh(d.width,d.height,2));var q=Mesh.getScreenQuad(),e=this.properties.size,l=this.properties.alpha;gl.disable(gl.DEPTH_TEST);gl.disable(gl.BLEND);this._temp_texture.drawTo(function(){d.bind(0); -f.bind(1);h.bind(2);a.uniforms({u_texture:0,u_texture_blur:1,u_mask:2,u_texsize:[d.width,d.height]}).draw(q)});this._temp_texture.drawTo(function(){gl.enable(gl.BLEND);gl.blendFunc(gl.ONE,gl.ONE);d.bind(0);k.bind(3);c.uniforms({u_texture:0,u_mask:2,u_shape:3,u_alpha:l,u_threshold:m,u_pointSize:e,u_itexsize:[1/d.width,1/d.height]}).draw(g,gl.POINTS)});this.setOutputData(0,this._temp_texture)}}else this.setOutputData(0,d)};p.prototype.createPointsMesh=function(d,f,h){for(var k=Math.round(d/h),m=Math.round(f/ -h),b=new Float32Array(k*m*2),a=-1,c=2/d*h,g=2/f*h,q=0;q=h.NOTEON||b<=h.NOTEOFF)this.channel=d&15};Object.defineProperty(h.prototype,"velocity",{get:function(){return this.cmd==h.NOTEON?this.data[2]: +d.pixel_shader_gamma="precision highp float;\n\t\t\tvarying vec2 v_coord;\n\t\t\tuniform sampler2D u_texture;\n\t\t\tuniform float u_value1;\n\t\t\t\n\t\t\tvoid main() {\n\t\t\t\tvec4 color = texture2D(u_texture, v_coord);\n\t\t\t\tfloat gamma = 1.0 / u_value1;\n\t\t\t\tgl_FragColor = vec4( pow( color.xyz, vec3(gamma) ), color.a );\n\t\t\t}\n";h.registerNodeType("fx/generic",d);u.LGraphFXGeneric=d;var n=function(){this.addInput("Tex.","Texture");this.addInput("intensity","number");this.addOutput("Texture", +"Texture");this.properties={intensity:1,invert:!1,precision:LGraphTexture.DEFAULT};n._shader||(n._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,n.pixel_shader))};n.title="Vigneting";n.desc="Vigneting";n.widgets_info={precision:{widget:"combo",values:LGraphTexture.MODE_VALUES}};n.prototype.onExecute=function(){var d=this.getInputData(0);if(this.properties.precision===LGraphTexture.PASS_THROUGH)this.setOutputData(0,d);else if(d){this._tex=LGraphTexture.getTargetTexture(d,this._tex,this.properties.precision); +var f=this.properties.intensity;this.isInputConnected(1)&&(f=this.getInputData(1),this.properties.intensity=f);gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var h=Mesh.getScreenQuad(),l=n._shader,m=this.properties.invert;this._tex.drawTo(function(){d.bind(0);l.uniforms({u_texture:0,u_intensity:f,u_isize:[1/d.width,1/d.height],u_invert:m?1:0}).draw(h)});this.setOutputData(0,this._tex)}};n.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 float u_intensity;\n\t\t\tuniform int u_invert;\n\t\t\t\n\t\t\tvoid main() {\n\t\t\t\tfloat luminance = 1.0 - length( v_coord - vec2(0.5) ) * 1.414;\n\t\t\t\tvec4 color = texture2D(u_texture, v_coord);\n\t\t\t\tif(u_invert == 1)\n\t\t\t\t\tluminance = 1.0 - luminance;\n\t\t\t\tluminance = mix(1.0, luminance, u_intensity);\n\t\t\t gl_FragColor = vec4( luminance * color.xyz, color.a);\n\t\t\t}\n\t\t\t"; +h.registerNodeType("fx/vigneting",n);u.LGraphFXVigneting=n}})(this); +(function(u){function h(d){this.cmd=this.channel=0;d?this.setup(d):this.data=[0,0,0]}function f(d,b){navigator.requestMIDIAccess?(this.on_ready=d,this.state={note:[],cc:[]},navigator.requestMIDIAccess().then(this.onMIDISuccess.bind(this),this.onMIDIFailure.bind(this))):(this.error="not suppoorted",b?b("Not supported"):console.error("MIDI NOT SUPPORTED, enable by chrome://flags"))}function p(){this.addOutput("on_midi",l.EVENT);this.addOutput("out","midi");this.properties={port:0};this._current_midi_event= +this._last_midi_event=null;var d=this;new f(function(b){d._midi=b;if(d._waiting)d.onStart();d._waiting=!1})}function d(){this.addInput("send",l.EVENT);this.properties={port:0};var d=this;new f(function(b){d._midi=b})}function n(){this.addInput("on_midi",l.EVENT);this._str="";this.size=[200,40]}function s(){this.properties={channel:-1,cmd:-1,min_value:-1,max_value:-1};this.addInput("in",l.EVENT);this.addOutput("on_midi",l.EVENT)}function v(){this.properties={channel:0,cmd:"CC",value1:1,value2:1};this.addInput("send", +l.EVENT);this.addInput("assign",l.EVENT);this.addOutput("on_midi",l.EVENT)}function t(){this.properties={cc:1,value:0};this.addOutput("value","number")}var l=u.LiteGraph;h.prototype.setup=function(d){this.data=d;this.status=d=d[0];var b=d&240;this.cmd=240<=d?d:b;this.cmd==h.NOTEON&&0==this.velocity&&(this.cmd=h.NOTEOFF);this.cmd_str=h.commands[this.cmd]||"";if(b>=h.NOTEON||b<=h.NOTEOFF)this.channel=d&15};Object.defineProperty(h.prototype,"velocity",{get:function(){return this.cmd==h.NOTEON?this.data[2]: -1},set:function(d){this.data[2]=d},enumerable:!0});h.notes="A A# B C C# D D# E F F# G G#".split(" ");h.prototype.getPitch=function(){return 440*Math.pow(2,(this.data[1]-69)/12)};h.computePitch=function(d){return 440*Math.pow(2,(d-69)/12)};h.prototype.getCC=function(){return this.data[1]};h.prototype.getCCValue=function(){return this.data[2]};h.prototype.getPitchBend=function(){return this.data[1]+(this.data[2]<<7)-8192};h.computePitchBend=function(d,b){return d+(b<<7)-8192};h.prototype.setCommandFromString= function(d){this.cmd=h.computeCommandFromString(d)};h.computeCommandFromString=function(d){if(!d)return 0;if(d&&d.constructor===Number)return d;d=d.toUpperCase();switch(d){case "NOTE ON":case "NOTEON":return h.NOTEON;case "NOTE OFF":case "NOTEOFF":return h.NOTEON;case "KEY PRESSURE":case "KEYPRESSURE":return h.KEYPRESSURE;case "CONTROLLER CHANGE":case "CONTROLLERCHANGE":case "CC":return h.CONTROLLERCHANGE;case "PROGRAM CHANGE":case "PROGRAMCHANGE":case "PC":return h.PROGRAMCHANGE;case "CHANNEL PRESSURE":case "CHANNELPRESSURE":return h.CHANNELPRESSURE; case "PITCH BEND":case "PITCHBEND":return h.PITCHBEND;case "TIME TICK":case "TIMETICK":return h.TIMETICK;default:return Number(d)}};h.toNoteString=function(d){var b;b=(d-21)%12;0>b&&(b=12+b);return h.notes[b]+Math.floor((d-24)/12+1)};h.prototype.toString=function(){var d=""+this.channel+". ";switch(this.cmd){case h.NOTEON:d+="NOTEON "+h.toNoteString(this.data[1]);break;case h.NOTEOFF:d+="NOTEOFF "+h.toNoteString(this.data[1]);break;case h.CONTROLLERCHANGE:d+="CC "+this.data[1]+" "+this.data[2];break; @@ -8679,25 +443,25 @@ case h.PROGRAMCHANGE:d+="PC "+this.data[1];break;case h.PITCHBEND:d+="PITCHBEND function(d){console.error("Failed to get MIDI access - "+d)};f.prototype.openInputPort=function(d,b){var a=this.input_ports.get("input-"+d);if(!a)return!1;f.input=this;var c=this;a.onmidimessage=function(a){var d=new h(a.data);c.updateState(d);b&&b(a.data,d);if(f.on_message)f.on_message(a.data,d)};console.log("port open: ",a);return!0};f.parseMsg=function(d){};f.prototype.updateState=function(d){switch(d.cmd){case h.NOTEON:this.state.note[d.value1|0]=d.value2;break;case h.NOTEOFF:this.state.note[d.value1| 0]=0;break;case h.CONTROLLERCHANGE:this.state.cc[d.getCC()]=d.getCCValue()}};f.prototype.sendMIDI=function(d,b){if(b){var a=this.output_ports.get("output-"+d);a&&(f.output=this,b.constructor===h?a.send(b.data):a.send(b))}};p.MIDIInterface=f;p.title="MIDI Input";p.desc="Reads MIDI from a input port";p.prototype.getPropertyInfo=function(d){if(this._midi&&"port"==d){d={};for(var b=0;b this.properties.max_value||this.trigger("on_midi",b)};k.registerNodeType("midi/filter",s);v.title="MIDIEvent";v.desc="Create a MIDI Event";v.prototype.onAction=function(d,b){"assign"==d?(this.properties.channel=b.channel,this.properties.cmd=b.cmd,this.properties.value1= +this._last_midi_event,b=0;b this.properties.max_value||this.trigger("on_midi",b)};l.registerNodeType("midi/filter",s);v.title="MIDIEvent";v.desc="Create a MIDI Event";v.prototype.onAction=function(d,b){"assign"==d?(this.properties.channel=b.channel,this.properties.cmd=b.cmd,this.properties.value1= b.data[1],this.properties.value2=b.data[2]):(b=new h,b.channel=this.properties.channel,this.properties.cmd&&this.properties.cmd.constructor===String?b.setCommandFromString(this.properties.cmd):b.cmd=this.properties.cmd,b.data[0]=b.cmd|b.channel,b.data[1]=Number(this.properties.value1),b.data[2]=Number(this.properties.value2),this.trigger("on_midi",b))};v.prototype.onExecute=function(){var d=this.properties;if(this.outputs)for(var b=0;b =this.size[0]&&(f=this.size[0]-1),a.strokeStyle="red",a.beginPath(),a.moveTo(f,d),a.lineTo(f,0),a.stroke())}};b.title="Visualization";b.desc="Audio Visualization";w.registerNodeType("audio/visualization", @@ -8730,4 +494,3 @@ h);f.title="SillyClient";f.desc="Connects to SillyServer to broadcast messages"; h||(this._server.sendMessage({type:0,channel:f,data:h}),this._last_input_data[f]=h)}for(f=1;f LGraphCanvas.search_limit) break; + if(LGraphCanvas.search_limit !== -1 && c++ > LGraphCanvas.search_limit) + break; } } else { for (var i in LiteGraph.registered_node_types) { if (i.indexOf(str) != -1) { addResult(i); - if(LGraphCanvas.search_limit !== -1 && c++ > LGraphCanvas.search_limit) break; + if(LGraphCanvas.search_limit !== -1 && c++ > LGraphCanvas.search_limit) + break; } } } } + + function addResult(result) { + var help = document.createElement("div"); + if (!first) first = result; + help.innerText = result; + help.className = "litegraph lite-search-item"; + help.addEventListener("click", function (e) { + select(this.innerText); + }); + helper.appendChild(help); + } } return dialog;