=this.size[1]))if(this._drop_texture&&a.webgl)a.drawImage(this._drop_texture,0,0,this.size[0],this.size[1]);
-else{if(this._last_preview_tex!=this._last_tex)if(a.webgl)this._canvas=this._last_tex;else{var b=e.generateLowResTexturePreview(this._last_tex);if(!b)return;this._last_preview_tex=this._last_tex;this._canvas=cloneCanvas(b)}this._canvas&&(a.save(),a.webgl||(a.translate(0,this.size[1]),a.scale(1,-1)),a.drawImage(this._canvas,0,0,this.size[0],this.size[1]),a.restore())}};e.generateLowResTexturePreview=function(a){if(!a)return null;var b=e.image_preview_size,c=a;if(a.format==gl.DEPTH_COMPONENT)return null;
-if(a.width>b||a.height>b)c=this._preview_temp_tex,this._preview_temp_tex||(this._preview_temp_tex=c=new GL.Texture(b,b,{minFilter:gl.NEAREST})),a.copyTo(c);a=this._preview_canvas;a||(this._preview_canvas=a=createCanvas(b,b));c&&c.toCanvas(a);return a};e.prototype.getResources=function(a){a[this.properties.name]=GL.Texture;return a};e.prototype.onGetInputs=function(){return[["in","Texture"]]};e.prototype.onGetOutputs=function(){return[["width","number"],["height","number"],["aspect","number"]]};h.registerNodeType("texture/texture",
-e);var m=function(){this.addInput("Texture","Texture");this.properties={flipY:!1};this.size=[e.image_preview_size,e.image_preview_size]};m.title="Preview";m.desc="Show a texture in the graph canvas";m.allow_preview=!1;m.prototype.onDrawBackground=function(a){if(!this.flags.collapsed&&(a.webgl||m.allow_preview)){var b=this.getInputData(0);if(b){var c=null,c=!b.handle&&a.webgl?b:e.generateLowResTexturePreview(b);a.save();this.properties.flipY&&(a.translate(0,this.size[1]),a.scale(1,-1));a.drawImage(c,
-0,0,this.size[0],this.size[1]);a.restore()}}};h.registerNodeType("texture/preview",m);var d=function(){this.addInput("Texture","Texture");this.addOutput("","Texture");this.properties={name:""}};d.title="Save";d.desc="Save a texture in the repository";d.prototype.onExecute=function(){var a=this.getInputData(0);a&&(this.properties.name&&(e.storeTexture?e.storeTexture(this.properties.name,a):e.getTexturesContainer()[this.properties.name]=a),this.setOutputData(0,a))};h.registerNodeType("texture/save",
-d);var r=function(){this.addInput("Texture","Texture");this.addInput("TextureB","Texture");this.addInput("value","number");this.addOutput("Texture","Texture");this.help="pixelcode must be vec3
\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:e.DEFAULT}};r.widgets_info={uvcode:{widget:"textarea",height:100},pixelcode:{widget:"textarea",height:100},precision:{widget:"combo",values:e.MODE_VALUES}};r.title="Operation";r.desc="Texture shader operation";r.prototype.getExtraMenuOptions=function(a){var b=this;return[{content:b.properties.show?"Hide Texture":"Show Texture",callback:function(){b.properties.show=!b.properties.show}}]};r.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())};r.prototype.onExecute=function(){var a=this.getInputData(0);if(this.isOutputConnected(0))if(this.properties.precision===e.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 f=e.getTextureType(this.properties.precision,a);this._tex=a||this._tex?e.getTargetTexture(a||
-this._tex,this._tex,this.properties.precision):new GL.Texture(c,d,{type:f,format:gl.RGBA,filter:gl.LINEAR});f="";this.properties.uvcode&&(f="uv = "+this.properties.uvcode,-1!=this.properties.uvcode.indexOf(";")&&(f=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!=f+"|"+k){try{this._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,
-r.pixel_shader,{UV_CODE:f,PIXEL_CODE:k}),this.boxcolor="#00FF00"}catch(h){console.log("Error compiling shader: ",h);this.boxcolor="#FF0000";return}this.boxcolor="#FF0000";this._shader_code=f+"|"+k;g=this._shader}if(g){this.boxcolor="green";var n=this.getInputData(2);null!=n?this.properties.value=n:n=parseFloat(this.properties.value);var l=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:n,texSize:[c,d],time:l}).draw(e)});this.setOutputData(0,this._tex)}else this.boxcolor="red"}}};r.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",r);var q=function(){this.addOutput("out","Texture");this.properties={code:"",width:512,height:512,precision:e.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}};q.title="Shader";q.desc="Texture shader";q.widgets_info={code:{type:"code"},precision:{widget:"combo",values:e.MODE_VALUES}};q.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 lumaMax))\n\t\t\t\t\tcolor = vec4(rgbA, 1.0);\n\t\t\t\telse\n\t\t\t\t\tcolor = vec4(rgbB, 1.0);\n\t\t\t\tif(u_igamma != 1.0)\n\t\t\t\t\tcolor.xyz = pow( color.xyz, vec3(u_igamma) );\n\t\t\t\treturn color;\n\t\t\t}\n\t\t\t\n\t\t\tvoid main() {\n\t\t\t gl_FragColor = applyFXAA( u_texture, v_coord * uViewportSize) ;\n\t\t\t}\n\t\t\t";
-l.gamma_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_igamma;\n\t\t\tvoid main() {\n\t\t\t\tvec4 color = texture2D( u_texture, v_coord);\n\t\t\t\tcolor.xyz = pow(color.xyz, vec3(u_igamma) );\n\t\t\t gl_FragColor = color;\n\t\t\t}\n\t\t\t";h.registerNodeType("texture/toviewport",l);d=function(){this.addInput("Texture","Texture");this.addOutput("","Texture");this.properties={size:0,generate_mipmaps:!1,
-precision:e.DEFAULT}};d.title="Copy";d.desc="Copy Texture";d.widgets_info={size:{widget:"combo",values:[0,32,64,128,256,512,1024,2048]},precision:{widget:"combo",values:e.MODE_VALUES}};d.prototype.onExecute=function(){var a=this.getInputData(0);if((a||this._temp_texture)&&this.isOutputConnected(0)){if(a){var b=a.width,c=a.height;0!=this.properties.size&&(c=b=this.properties.size);var d=this._temp_texture,f=a.type;this.properties.precision===e.LOW?f=gl.UNSIGNED_BYTE:this.properties.precision===e.HIGH&&
-(f=gl.HIGH_PRECISION_FORMAT);d&&d.width==b&&d.height==c&&d.type==f||(d=gl.LINEAR,this.properties.generate_mipmaps&&isPowerOfTwo(b)&&isPowerOfTwo(c)&&(d=gl.LINEAR_MIPMAP_LINEAR),this._temp_texture=new GL.Texture(b,c,{type:f,format:gl.RGBA,minFilter:d,magFilter:gl.LINEAR}));a.copyTo(this._temp_texture);this.properties.generate_mipmaps&&(this._temp_texture.bind(0),gl.generateMipmap(this._temp_texture.texture_type),this._temp_texture.unbind(0))}this.setOutputData(0,this._temp_texture)}};h.registerNodeType("texture/copy",
-d);var n=function(){this.addInput("Texture","Texture");this.addOutput("","Texture");this.properties={iterations:1,generate_mipmaps:!1,precision:e.DEFAULT}};n.title="Downsample";n.desc="Downsample Texture";n.widgets_info={iterations:{type:"number",step:1,precision:0,min:1},precision:{widget:"combo",values:e.MODE_VALUES}};n.prototype.onExecute=function(){var a=this.getInputData(0);if((a||this._temp_texture)&&this.isOutputConnected(0)&&a&&a.texture_type===GL.TEXTURE_2D){var b=n._shader;b||(n._shader=
-b=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,n.pixel_shader));var c=a.width|0,d=a.height|0,f=a.type;this.properties.precision===e.LOW?f=gl.UNSIGNED_BYTE:this.properties.precision===e.HIGH&&(f=gl.HIGH_PRECISION_FORMAT);var k=this.properties.iterations||1,g=a,h=null,l=[],a={type:f,format:a.format},f=vec2.create(),p={u_offset:f};this._texture&&GL.Texture.releaseTemporary(this._texture);for(var m=0;m>1||0;d=d>>1||0;h=GL.Texture.getTemporary(c,d,a);l.push(h);g.setParameter(GL.TEXTURE_MAG_FILTER,
-GL.NEAREST);g.copyTo(h,b,p);if(1==c&&1==d)break;g=h}this._texture=l.pop();for(m=0;md;++d)c[d]=Math.random();b._shader.uniforms({u_samples_a:c.subarray(0,16),u_samples_b:c.subarray(16,32)})}d=this._temp_texture;c=gl.UNSIGNED_BYTE;a.type!=c&&(c=gl.FLOAT);d&&d.type==c||(this._temp_texture=new GL.Texture(1,1,{type:c,format:gl.RGBA,filter:gl.NEAREST}));
-var f=b._shader,e=this._uniforms;e.u_mipmap_offset=this.properties.mipmap_offset;this._temp_texture.drawTo(function(){a.toViewport(f,e)});this.setOutputData(0,this._temp_texture);if(this.isOutputConnected(1)||this.isOutputConnected(2))if(d=this._temp_texture.getPixels()){var k=this._luminance,c=this._temp_texture.type;k.set(d);c==gl.UNSIGNED_BYTE?vec4.scale(k,k,1/255):c!=GL.HALF_FLOAT&&c!=GL.HALF_FLOAT_OES||vec4.scale(k,k,1/65025);this.setOutputData(1,k);this.setOutputData(2,(k[0]+k[1]+k[2])/3)}}};
-b.pixel_shader="precision highp float;\n\t\t\tprecision highp float;\n\t\t\tuniform mat4 u_samples_a;\n\t\t\tuniform mat4 u_samples_b;\n\t\t\tuniform sampler2D u_texture;\n\t\t\tuniform float u_mipmap_offset;\n\t\t\tvarying vec2 v_coord;\n\t\t\t\n\t\t\tvoid main() {\n\t\t\t\tvec4 color = vec4(0.0);\n\t\t\t\tfor(int i = 0; i < 4; ++i)\n\t\t\t\t\tfor(int j = 0; j < 4; ++j)\n\t\t\t\t\t{\n\t\t\t\t\t\tcolor += texture2D(u_texture, vec2( u_samples_a[i][j], u_samples_b[i][j] ), u_mipmap_offset );\n\t\t\t\t\t\tcolor += texture2D(u_texture, vec2( 1.0 - u_samples_a[i][j], 1.0 - u_samples_b[i][j] ), u_mipmap_offset );\n\t\t\t\t\t}\n\t\t\t gl_FragColor = color * 0.03125;\n\t\t\t}\n\t\t\t";
-h.registerNodeType("texture/average",b);d=function(){this.addInput("Image","image");this.addOutput("","Texture");this.properties={}};d.title="Image to Texture";d.desc="Uploads an image to the GPU";d.prototype.onExecute=function(){var a=this.getInputData(0);if(a){var b=a.videoWidth||a.width,c=a.videoHeight||a.height;if(a.gltexture)this.setOutputData(0,a.gltexture);else{var d=this._temp_texture;d&&d.width==b&&d.height==c||(this._temp_texture=new GL.Texture(b,c,{format:gl.RGBA,filter:gl.LINEAR}));try{this._temp_texture.uploadImage(a)}catch(f){console.error("image comes from an unsafe location, cannot be uploaded to webgl: "+
-f);return}this.setOutputData(0,this._temp_texture)}}};h.registerNodeType("texture/imageToTexture",d);var a=function(){this.addInput("Texture","Texture");this.addInput("LUT","Texture");this.addInput("Intensity","number");this.addOutput("","Texture");this.properties={intensity:1,precision:e.DEFAULT,texture:null};a._shader||(a._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,a.pixel_shader))};a.widgets_info={texture:{widget:"texture"},precision:{widget:"combo",values:e.MODE_VALUES}};a.title="LUT";a.desc=
-"Apply LUT to Texture";a.prototype.onExecute=function(){if(this.isOutputConnected(0)){var b=this.getInputData(0);if(this.properties.precision===e.PASS_THROUGH)this.setOutputData(0,b);else if(b){var c=this.getInputData(1);c||(c=e.getTexture(this.properties.texture));if(c){c.bind(0);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.LINEAR);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.CLAMP_TO_EDGE);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,gl.CLAMP_TO_EDGE);gl.bindTexture(gl.TEXTURE_2D,
-null);var d=this.properties.intensity;this.isInputConnected(2)&&(this.properties.intensity=d=this.getInputData(2));this._tex=e.getTargetTexture(b,this._tex,this.properties.precision);this._tex.drawTo(function(){c.bind(1);b.toViewport(a._shader,{u_texture:0,u_textureB:1,u_amount:d})});this.setOutputData(0,this._tex)}else this.setOutputData(0,b)}}};a.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 sampler2D u_textureB;\n\t\t\tuniform float u_amount;\n\t\t\t\n\t\t\tvoid main() {\n\t\t\t\t lowp vec4 textureColor = clamp( texture2D(u_texture, v_coord), vec4(0.0), vec4(1.0) );\n\t\t\t\t mediump float blueColor = textureColor.b * 63.0;\n\t\t\t\t mediump vec2 quad1;\n\t\t\t\t quad1.y = floor(floor(blueColor) / 8.0);\n\t\t\t\t quad1.x = floor(blueColor) - (quad1.y * 8.0);\n\t\t\t\t mediump vec2 quad2;\n\t\t\t\t quad2.y = floor(ceil(blueColor) / 8.0);\n\t\t\t\t quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n\t\t\t\t highp vec2 texPos1;\n\t\t\t\t texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.r);\n\t\t\t\t texPos1.y = 1.0 - ((quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.g));\n\t\t\t\t highp vec2 texPos2;\n\t\t\t\t texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.r);\n\t\t\t\t texPos2.y = 1.0 - ((quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.g));\n\t\t\t\t lowp vec4 newColor1 = texture2D(u_textureB, texPos1);\n\t\t\t\t lowp vec4 newColor2 = texture2D(u_textureB, texPos2);\n\t\t\t\t lowp vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n\t\t\t\t gl_FragColor = vec4( mix( textureColor.rgb, newColor.rgb, u_amount), textureColor.w);\n\t\t\t}\n\t\t\t";
-h.registerNodeType("texture/LUT",a);var c=function(){this.addInput("Texture","Texture");this.addOutput("R","Texture");this.addOutput("G","Texture");this.addOutput("B","Texture");this.addOutput("A","Texture");this.properties={};c._shader||(c._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,c.pixel_shader))};c.title="Texture to Channels";c.desc="Split texture channels";c.prototype.onExecute=function(){var a=this.getInputData(0);if(a){this._channels||(this._channels=Array(4));for(var b=0,d=0;4>d;d++)this.isOutputConnected(d)?
-(this._channels[d]&&this._channels[d].width==a.width&&this._channels[d].height==a.height&&this._channels[d].type==a.type||(this._channels[d]=new GL.Texture(a.width,a.height,{type:a.type,format:gl.RGBA,filter:gl.LINEAR})),b++):this._channels[d]=null;if(b){gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);for(var f=Mesh.getScreenQuad(),e=c._shader,k=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],d=0;4>d;d++)this._channels[d]&&(this._channels[d].drawTo(function(){a.bind(0);e.uniforms({u_texture:0,u_mask:k[d]}).draw(f)}),
-this.setOutputData(d,this._channels[d]))}}};c.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 vec4 u_mask;\n\t\t\t\n\t\t\tvoid main() {\n\t\t\t gl_FragColor = vec4( vec3( length( texture2D(u_texture, v_coord) * u_mask )), 1.0 );\n\t\t\t}\n\t\t\t";h.registerNodeType("texture/textureChannels",c);var g=function(){this.addInput("R","Texture");this.addInput("G","Texture");this.addInput("B","Texture");this.addInput("A",
-"Texture");this.addOutput("Texture","Texture");this.properties={};g._shader||(g._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,g.pixel_shader))};g.title="Channels to Texture";g.desc="Split texture channels";g.prototype.onExecute=function(){var a=[this.getInputData(0),this.getInputData(1),this.getInputData(2),this.getInputData(3)];if(a[0]&&a[1]&&a[2]&&a[3]){gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var b=Mesh.getScreenQuad(),c=g._shader;this._tex=e.getTargetTexture(a[0],this._tex);this._tex.drawTo(function(){a[0].bind(0);
-a[1].bind(1);a[2].bind(2);a[3].bind(3);c.uniforms({u_textureR:0,u_textureG:1,u_textureB:2,u_textureA:3}).draw(b)});this.setOutputData(0,this._tex)}};g.pixel_shader="precision highp float;\n\t\t\tprecision highp float;\n\t\t\tvarying vec2 v_coord;\n\t\t\tuniform sampler2D u_textureR;\n\t\t\tuniform sampler2D u_textureG;\n\t\t\tuniform sampler2D u_textureB;\n\t\t\tuniform sampler2D u_textureA;\n\t\t\t\n\t\t\tvoid main() {\n\t\t\t gl_FragColor = vec4( \t\t\t\t\t\ttexture2D(u_textureR, v_coord).r,\t\t\t\t\t\ttexture2D(u_textureG, v_coord).r,\t\t\t\t\t\ttexture2D(u_textureB, v_coord).r,\t\t\t\t\t\ttexture2D(u_textureA, v_coord).r);\n\t\t\t}\n\t\t\t";
-h.registerNodeType("texture/channelsTexture",g);var w=function(){this.addInput("A","color");this.addInput("B","color");this.addOutput("Texture","Texture");this.properties={angle:0,scale:1,A:[0,0,0],B:[1,1,1],texture_size:32};w._shader||(w._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,w.pixel_shader));this._uniforms={u_angle:0,u_colorA:vec3.create(),u_colorB:vec3.create()}};w.title="Gradient";w.desc="Generates a gradient";w["@A"]={type:"color"};w["@B"]={type:"color"};w["@texture_size"]={type:"enum",
-values:[32,64,128,256,512]};w.prototype.onExecute=function(){gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var a=GL.Mesh.getScreenQuad(),b=w._shader,c=this.getInputData(0);c||(c=this.properties.A);var d=this.getInputData(1);d||(d=this.properties.B);for(var f=2;f 0.5 ? 1.0 : 0.0, diff.y > 0.5 ? 1.0 : 0.0, diff.z > 0.5 ? 1.0 : 0.0, center.a );\n\t\t\t}\n\t\t\t";
-h.registerNodeType("texture/edges",k);var p=function(){this.addInput("Texture","Texture");this.addInput("Distance","number");this.addInput("Range","number");this.addOutput("Texture","Texture");this.properties={distance:100,range:50,only_depth:!1,high_precision:!1};this._uniforms={u_texture:0,u_distance:100,u_range:50,u_camera_planes:null}};p.title="Depth Range";p.desc="Generates a texture with a depth range";p.prototype.onExecute=function(){if(this.isOutputConnected(0)){var a=this.getInputData(0);
-if(a){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==a.width&&this._temp_texture.height==a.height||(this._temp_texture=new GL.Texture(a.width,a.height,{type:b,format:gl.RGBA,filter:gl.LINEAR}));var c=this._uniforms,b=this.properties.distance;this.isInputConnected(1)&&(b=this.getInputData(1),this.properties.distance=b);var d=this.properties.range;this.isInputConnected(2)&&
-(d=this.getInputData(2),this.properties.range=d);c.u_distance=b;c.u_range=d;gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var f=Mesh.getScreenQuad();p._shader||(p._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,p.pixel_shader),p._shader_onlydepth=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,p.pixel_shader,{ONLY_DEPTH:""}));var e=this.properties.only_depth?p._shader_onlydepth:p._shader,b=null,b=a.near_far_planes?a.near_far_planes:window.LS&&LS.Renderer._main_camera?LS.Renderer._main_camera._uniforms.u_camera_planes:
-[0.1,1E3];c.u_camera_planes=b;this._temp_texture.drawTo(function(){a.bind(0);e.uniforms(c).draw(f)});this._temp_texture.near_far_planes=b;this.setOutputData(0,this._temp_texture)}}};p.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_distance;\n\t\t\tuniform float u_range;\n\t\t\t\n\t\t\tfloat LinearDepth()\n\t\t\t{\n\t\t\t\tfloat zNear = u_camera_planes.x;\n\t\t\t\tfloat zFar = u_camera_planes.y;\n\t\t\t\tfloat depth = texture2D(u_texture, v_coord).x;\n\t\t\t\tdepth = depth * 2.0 - 1.0;\n\t\t\t\treturn zNear * (depth + 1.0) / (zFar + zNear - depth * (zFar - zNear));\n\t\t\t}\n\t\t\t\n\t\t\tvoid main() {\n\t\t\t\tfloat depth = LinearDepth();\n\t\t\t\t#ifdef ONLY_DEPTH\n\t\t\t\t gl_FragColor = vec4(depth);\n\t\t\t\t#else\n\t\t\t\t\tfloat diff = abs(depth * u_camera_planes.y - u_distance);\n\t\t\t\t\tfloat dof = 1.0;\n\t\t\t\t\tif(diff <= u_range)\n\t\t\t\t\t\tdof = diff / u_range;\n\t\t\t\t gl_FragColor = vec4(dof);\n\t\t\t\t#endif\n\t\t\t}\n\t\t\t";
-h.registerNodeType("texture/depth_range",p);var C=function(){this.addInput("Texture","Texture");this.addInput("Iterations","number");this.addInput("Intensity","number");this.addOutput("Blurred","Texture");this.properties={intensity:1,iterations:1,preserve_aspect:!1,scale:[1,1],precision:e.DEFAULT}};C.title="Blur";C.desc="Blur a texture";C.widgets_info={precision:{widget:"combo",values:e.MODE_VALUES}};C.max_iterations=20;C.prototype.onExecute=function(){var a=this.getInputData(0);if(a&&this.isOutputConnected(0)){var b=
-this._final_texture;b&&b.width==a.width&&b.height==a.height&&b.type==a.type||(b=this._final_texture=new GL.Texture(a.width,a.height,{type:a.type,format:gl.RGBA,filter:gl.LINEAR}));var c=this.properties.iterations;this.isInputConnected(1)&&(c=this.getInputData(1),this.properties.iterations=c);c=Math.min(Math.floor(c),C.max_iterations);if(0==c)this.setOutputData(0,a);else{var d=this.properties.intensity;this.isInputConnected(2)&&(d=this.getInputData(2),this.properties.intensity=d);var f=h.camera_aspect;
-f||void 0===window.gl||(f=gl.canvas.height/gl.canvas.width);f||(f=1);var f=this.properties.preserve_aspect?f:1,e=this.properties.scale||[1,1];a.applyBlur(f*e[0],e[1],d,b);for(a=1;a>=1;1<(c|0)&&(c>>=1);if(2>b)break;n=g[r]=GL.Texture.getTemporary(b,c,d);m[0]=1/l.width;m[1]=1/l.height;l.blit(n,h.uniforms(k));l=n}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})),m[0]=1/l.width,m[1]=1/l.height,k.u_intensity=
-q,k.u_delta=1,l.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--)n=g[r],g[r]=null,m[0]=1/l.width,m[1]=1/l.height,l.blit(n,h.uniforms(k)),GL.Texture.releaseTemporary(l),l=n;gl.disable(gl.BLEND);this.isOutputConnected(1)&&(g=this._glow_texture,g&&g.width==a.width&&g.height==a.height&&g.type==f&&g.format==a.format||(g=this._glow_texture=new GL.Texture(a.width,a.height,{type:f,
-format:a.format,filter:gl.LINEAR})),l.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==f&&g.format==a.format||(g=this._final_texture=new GL.Texture(a.width,a.height,{type:f,format:a.format,filter:gl.LINEAR}));var s=this.getInputData(1),C=this.getInputOrProperty("dirt_factor");k.u_intensity=q;h=s?x._dirt_final_shader:x._final_shader;h||(h=s?x._dirt_final_shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,x.final_pixel_shader,
-{USE_DIRT:""}):x._final_shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,x.final_pixel_shader));g.drawTo(function(){a.bind(0);l.bind(1);s&&(h.setUniform("u_dirt_factor",C),h.setUniform("u_dirt_texture",s.bind(2)));h.toViewport(k)});this.setOutputData(0,g)}GL.Texture.releaseTemporary(l)}};x.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}";
-x.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}";
-x.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",x);var z=function(){this.addInput("Texture","Texture");this.addOutput("Filtered","Texture");this.properties={intensity:1,radius:5}};z.title="Kuwahara Filter";z.desc="Filters a texture giving an artistic oil canvas painting";z.max_radius=10;z._shaders=[];z.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),z.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;z._shaders[b]||(z._shaders[b]=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,z.pixel_shader,{RADIUS:b.toFixed(0)}));var f=z._shaders[b],e=GL.Mesh.getScreenQuad();a.bind(0);this._temp_texture.drawTo(function(){f.uniforms({u_texture:0,
-u_intensity:c,u_resolution:[a.width,a.height],u_iResolution:[1/a.width,1/a.height]}).draw(e)});this.setOutputData(0,this._temp_texture)}}};z.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",z);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&&(e.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:e.LOW};this._uniforms=
-{u_texture:0,u_factor:1}};A.title="Lens FX";A.desc="distortion and chromatic aberration";A.widgets_info={precision:{widget:"combo",values:e.MODE_VALUES}};A.prototype.onGetInputs=function(){return[["enabled","boolean"]]};A.prototype.onExecute=function(){var a=this.getInputData(0);if(a&&this.isOutputConnected(0))if(this.properties.precision===e.PASS_THROUGH||!1===this.getInputOrProperty("enabled"))this.setOutputData(0,a);else{var b=this._temp_texture;b&&b.width==a.width&&b.height==a.height&&b.type==
-a.type||(b=this._temp_texture=new GL.Texture(a.width,a.height,{type:a.type,format:gl.RGBA,filter:gl.LINEAR}));var c=A._shader;c||(c=A._shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,A.pixel_shader));var d=this.getInputData(1);null==d&&(d=this.properties.factor);var f=this._uniforms;f.u_factor=d;gl.disable(gl.DEPTH_TEST);b.drawTo(function(){a.bind(0);c.uniforms(f).draw(GL.Mesh.getScreenQuad())});this.setOutputData(0,b)}};A.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_factor;\n\t\t\tvec2 barrelDistortion(vec2 coord, float amt) {\n\t\t\t\tvec2 cc = coord - 0.5;\n\t\t\t\tfloat dist = dot(cc, cc);\n\t\t\t\treturn coord + cc * dist * amt;\n\t\t\t}\n\t\t\t\n\t\t\tfloat sat( float t )\n\t\t\t{\n\t\t\t\treturn clamp( t, 0.0, 1.0 );\n\t\t\t}\n\t\t\t\n\t\t\tfloat linterp( float t ) {\n\t\t\t\treturn sat( 1.0 - abs( 2.0*t - 1.0 ) );\n\t\t\t}\n\t\t\t\n\t\t\tfloat remap( float t, float a, float b ) {\n\t\t\t\treturn sat( (t - a) / (b - a) );\n\t\t\t}\n\t\t\t\n\t\t\tvec4 spectrum_offset( float t ) {\n\t\t\t\tvec4 ret;\n\t\t\t\tfloat lo = step(t,0.5);\n\t\t\t\tfloat hi = 1.0-lo;\n\t\t\t\tfloat w = linterp( remap( t, 1.0/6.0, 5.0/6.0 ) );\n\t\t\t\tret = vec4(lo,1.0,hi, 1.) * vec4(1.0-w, w, 1.0-w, 1.);\n\t\t\t\n\t\t\t\treturn pow( ret, vec4(1.0/2.2) );\n\t\t\t}\n\t\t\t\n\t\t\tconst float max_distort = 2.2;\n\t\t\tconst int num_iter = 12;\n\t\t\tconst float reci_num_iter_f = 1.0 / float(num_iter);\n\t\t\t\n\t\t\tvoid main()\n\t\t\t{\t\n\t\t\t\tvec2 uv=v_coord;\n\t\t\t\tvec4 sumcol = vec4(0.0);\n\t\t\t\tvec4 sumw = vec4(0.0);\t\n\t\t\t\tfor ( int i=0; i= 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",v);d=function(){this.addOutput("out","Texture");this.properties={code:"",width:512,height:512,precision:e.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:e.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(t.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 f=this,e=this.graph.getTime();d.drawTo(function(){gl.start2D();try{a.draw?a.draw.call(f,gl.canvas,gl,e,a):a.call(f,gl.canvas,gl,e,a),f.boxcolor="#00FF00"}catch(b){f.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 y=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:e.DEFAULT}};y.title="Matte";y.desc="Extracts background";y.widgets_info={key_color:{widget:"color"},precision:{widget:"combo",values:e.MODE_VALUES}};y.prototype.onExecute=function(){if(this.isOutputConnected(0)){var a=this.getInputData(0);if(this.properties.precision===e.PASS_THROUGH)this.setOutputData(0,a);else if(a){this._tex=e.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=y._shader;d||(d=y._shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,y.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)}}};y.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",y);d=function(){this.addOutput("Cubemap","Cubemap");this.properties={name:""};this.size=[e.image_preview_size,e.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=
-e.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(t){var h=t.LiteGraph;if("undefined"!=typeof GL){var e=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};e._shader||(e._shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,e.pixel_shader),e._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]}))};e.title="Lens";e.desc="Camera Lens distortion";e.widgets_info={precision:{widget:"combo",values:LGraphTexture.MODE_VALUES}};e.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 m=this.properties.distortion;this.isInputConnected(2)&&(m=this.getInputData(2),this.properties.distortion=m);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 n=Mesh.getScreenQuad(),b=e._shader;this._tex.drawTo(function(){d.bind(0);b.uniforms({u_texture:0,u_aberration:h,u_distortion:m,u_blur:l}).draw(n)});this.setOutputData(0,this._tex)}};e.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",e);t.LGraphFXLens=e;var m=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}};m.title="Bokeh";m.desc="applies an Bokeh effect";m.widgets_info={shape:{widget:"texture"}};m.prototype.onExecute=function(){var d=this.getInputData(0),e=this.getInputData(1),h=this.getInputData(2);
-if(d&&h&&this.properties.shape){e||(e=d);var l=LGraphTexture.getTexture(this.properties.shape);if(l){var n=this.properties.threshold;this.isInputConnected(3)&&(n=this.getInputData(3),this.properties.threshold=n);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=m._first_shader;a||(a=m._first_shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,m._first_pixel_shader));var c=m._second_shader;c||(c=m._second_shader=new GL.Shader(m._second_vertex_shader,m._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 r=Mesh.getScreenQuad(),f=this.properties.size,k=this.properties.alpha;gl.disable(gl.DEPTH_TEST);gl.disable(gl.BLEND);this._temp_texture.drawTo(function(){d.bind(0);
-e.bind(1);h.bind(2);a.uniforms({u_texture:0,u_texture_blur:1,u_mask:2,u_texsize:[d.width,d.height]}).draw(r)});this._temp_texture.drawTo(function(){gl.enable(gl.BLEND);gl.blendFunc(gl.ONE,gl.ONE);d.bind(0);l.bind(3);c.uniforms({u_texture:0,u_mask:2,u_shape:3,u_alpha:k,u_threshold:n,u_pointSize:f,u_itexsize:[1/d.width,1/d.height]}).draw(g,gl.POINTS)});this.setOutputData(0,this._temp_texture)}}else this.setOutputData(0,d)};m.prototype.createPointsMesh=function(d,e,h){for(var l=Math.round(d/h),n=Math.round(e/
-h),b=new Float32Array(l*n*2),a=-1,c=2/d*h,g=2/e*h,m=0;m=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;
-case h.PROGRAMCHANGE:d+="PC "+this.data[1];break;case h.PITCHBEND:d+="PITCHBEND "+this.getPitchBend();break;case h.KEYPRESSURE:d+="KEYPRESS "+this.data[1]}return d};h.prototype.toHexString=function(){for(var d="",b=0;bthis.properties.max_value||this.trigger("on_midi",b)};l.registerNodeType("midi/filter",q);s.title="MIDIEvent";s.desc="Create a MIDI Event";s.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))};s.prototype.onExecute=function(){var d=this.properties;if(this.outputs)for(var b=0;b=this.size[0]&&(e=this.size[0]-1),a.strokeStyle="red",a.beginPath(),a.moveTo(e,d),a.lineTo(e,0),a.stroke())}};b.title="Visualization";b.desc="Audio Visualization";w.registerNodeType("audio/visualization",
-b);a.prototype.onExecute=function(){if(this._freqs=this.getInputData(0)){var a=this.properties.band,b=this.getInputData(1);void 0!==b&&(a=b);b=f.getAudioContext().sampleRate/this._freqs.length;b=a/b*2;b>=this._freqs.length?b=this._freqs[this._freqs.length-1]:(a=b|0,b-=a,b=this._freqs[a]*(1-b)+this._freqs[a+1]*b);this.setOutputData(0,b/255*this.properties.amplitude)}};a.prototype.onGetInputs=function(){return[["band","number"]]};a.title="Signal";a.desc="extract the signal of some frequency";w.registerNodeType("audio/signal",
-a);c.prototype.onAdded=function(a){a.status==LGraph.STATUS_RUNNING&&(this.audionode.onaudioprocess=this._callback)};c["@code"]={widget:"code"};c.prototype.onStart=function(){this.audionode.onaudioprocess=this._callback};c.prototype.onStop=function(){this.audionode.onaudioprocess=c._bypass_function};c.prototype.onPause=function(){this.audionode.onaudioprocess=c._bypass_function};c.prototype.onUnpause=function(){this.audionode.onaudioprocess=this._callback};c.prototype.onExecute=function(){};c.prototype.onRemoved=
-function(){this.audionode.onaudioprocess=c._bypass_function};c.prototype.processCode=function(){try{this._script=new new Function("properties",this.properties.code)(this.properties),this._old_code=this.properties.code,this._callback=this._script.onaudioprocess}catch(a){console.error("Error in onaudioprocess code",a),this._callback=c._bypass_function,this.audionode.onaudioprocess=this._callback}};c.prototype.onPropertyChanged=function(a,b){"code"==a&&(this.properties.code=b,this.processCode(),this.graph&&
-this.graph.status==LGraph.STATUS_RUNNING&&(this.audionode.onaudioprocess=this._callback))};c.default_function=function(){this.onaudioprocess=function(a){var b=a.inputBuffer;a=a.outputBuffer;for(var c=0;c k && (k = Math.max(0, g + k));
+ if (null == n || n > g) {
+ n = g;
+ }
+ n = Number(n);
+ 0 > n && (n = Math.max(0, g + n));
+ for (k = Number(k || 0); k < n; k++) {
+ this[k] = 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 k = 0, n = {next:function() {
+ if (k < u.length) {
+ var g = k++;
+ return {value:f(g, u[g]), 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, k) {
+ return k;
+ });
+ };
+}, "es8", "es3");
+(function(u) {
+ function f(a) {
+ l.debug && console.log("Graph created");
+ this.list_of_graphcanvas = null;
+ this.clear();
+ a && this.configure(a);
+ }
+ function k(a) {
+ this._ctor(a);
+ }
+ function n(a) {
+ this._ctor(a);
+ }
+ function g(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 " + l.NODE_TEXT_SIZE + "px Arial";
+ this.inner_text_font = "normal " + l.NODE_SUBTEXT_SIZE + "px Arial";
+ this.node_title_color = l.NODE_TITLE_COLOR;
+ this.default_link_color = "#AAC";
+ 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.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 r(a, b, e, c, h, m) {
+ return e < a && e + h > a && c < b && c + m > b ? !0 : !1;
+ }
+ function v(a, b) {
+ var e = a[0] + a[2], c = a[1] + a[3], h = b[1] + b[3];
+ return a[0] > b[0] + b[2] || a[1] > h || e < b[0] || c < b[1] ? !1 : !0;
+ }
+ function w(a, b) {
+ function e(a) {
+ var b = parseInt(h.style.top);
+ h.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 h = document.createElement("div");
+ h.className = "litegraph litecontextmenu litemenubar-panel";
+ h.style.minWidth = 100;
+ h.style.minHeight = 100;
+ h.style.pointerEvents = "none";
+ setTimeout(function() {
+ h.style.pointerEvents = "auto";
+ }, 100);
+ h.addEventListener("mouseup", function(a) {
+ a.preventDefault();
+ return !0;
+ }, !0);
+ h.addEventListener("contextmenu", function(a) {
+ if (2 != a.button) {
+ return !1;
+ }
+ a.preventDefault();
+ return !1;
+ }, !0);
+ h.addEventListener("mousedown", function(a) {
+ if (2 == a.button) {
+ return c.close(), a.preventDefault(), !0;
+ }
+ }, !0);
+ h.addEventListener("wheel", e, !0);
+ h.addEventListener("mousewheel", e, !0);
+ this.root = h;
+ if (b.title) {
+ var m = document.createElement("div");
+ m.className = "litemenu-title";
+ m.innerHTML = b.title;
+ h.appendChild(m);
+ }
+ m = 0;
+ for (var p in a) {
+ var g = a.constructor == Array ? a[p] : p;
+ null != g && g.constructor !== String && (g = void 0 === g.content ? String(g) : g.content);
+ this.addItem(g, a[p], b);
+ m++;
+ }
+ h.addEventListener("mouseleave", function(a) {
+ c.lock || c.close(a);
+ });
+ a = document;
+ b.event && (a = b.event.target.ownerDocument);
+ a || (a = document);
+ a.body.appendChild(h);
+ 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(), m = h.getBoundingClientRect(), p > b.width - m.width - 10 && (p = b.width - m.width - 10), a > b.height - m.height - 10 && (a = b.height - m.height - 10));
+ h.style.left = p + "px";
+ h.style.top = a + "px";
+ }
+ var l = u.LiteGraph = {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, CANVAS_GRID_SIZE:10, 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:"#888", NODE_DEFAULT_SHAPE:"box", MAX_NUMBER_OF_NODES:1000, DEFAULT_POSITION:[100, 100], node_images_path:"", 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, NORMAL_TITLE:0, NO_TITLE:1, TRANSPARENT_TITLE:2, AUTOHIDE_TITLE:3, proxy:null, 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;
+ l.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 h in k.prototype) {
+ b.prototype[h] || (b.prototype[h] = k.prototype[h]);
+ }
+ }
+ Object.defineProperty(b.prototype, "shape", {set:function(a) {
+ switch(a) {
+ case "default":
+ delete this._shape;
+ break;
+ case "box":
+ this._shape = l.BOX_SHAPE;
+ break;
+ case "round":
+ this._shape = l.ROUND_SHAPE;
+ break;
+ case "circle":
+ this._shape = l.CIRCLE_SHAPE;
+ break;
+ case "card":
+ this._shape = l.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 (h in b.supported_extensions) {
+ this.node_types_by_file_extension[b.supported_extensions[h].toLowerCase()] = b;
+ }
+ }
+ }, wrapFunctionAsNode:function(a, b, e, c) {
+ for (var h = Array(b.length), m = "", y = l.getParameterNames(b), g = 0; g < y.length; ++g) {
+ m += "this.addInput('" + y[g] + "'," + (e && e[g] ? "'" + e[g] + "'" : "0") + ");\n";
+ }
+ e = Function(m + ("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 < h.length; ++a) {
+ h[a] = this.getInputData(a);
+ }
+ a = b.apply(this, h);
+ this.setOutputData(0, a);
+ };
+ this.registerNodeType(a, e);
+ }, addNodeMethod:function(a, b) {
+ k.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 l.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 = l.DEFAULT_POSITION.concat());
+ c.mode || (c.mode = l.ALWAYS);
+ if (e) {
+ for (var h in e) {
+ c[h] = e[h];
+ }
+ }
+ 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 h = this.registered_node_types[c];
+ b && h.filter && h.filter != b || ("" == a ? null == h.category && e.push(h) : h.category == a && e.push(h));
+ }
+ 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 h = e[c].src;
+ if (h && h.substr(0, a.length) == a) {
+ try {
+ l.debug && console.log("Reloading: " + h);
+ var m = document.createElement("script");
+ m.type = "text/javascript";
+ m.src = h;
+ b.appendChild(m);
+ b.removeChild(e[c]);
+ } catch (p) {
+ if (l.throw_errors) {
+ throw p;
+ }
+ l.debug && console.log("Error while reloading " + h);
+ }
+ }
+ }
+ l.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 == l.EVENT && b == l.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;
+ }};
+ l.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 = l.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 != g) {
+ 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 = l.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 = l.getTime();
+ this.globaltime = 0.001 * (e - this.starttime);
+ var c = this._nodes_executable ? this._nodes_executable : this._nodes;
+ if (c) {
+ if (b) {
+ for (var h = 0; h < a; h++) {
+ for (var m = 0, p = c.length; m < p; ++m) {
+ var g = c[m];
+ if (g.mode == l.ALWAYS && g.onExecute) {
+ g.onExecute();
+ }
+ }
+ this.fixedtime += this.fixedtime_lapse;
+ if (this.onExecuteStep) {
+ this.onExecuteStep();
+ }
+ }
+ if (this.onAfterExecute) {
+ this.onAfterExecute();
+ }
+ } else {
+ try {
+ for (h = 0; h < a; h++) {
+ m = 0;
+ for (p = c.length; m < p; ++m) {
+ if (g = c[m], g.mode == l.ALWAYS && g.onExecute) {
+ g.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 (l.throw_errors) {
+ throw G;
+ }
+ l.debug && console.log("Error during execution: " + G);
+ this.stop();
+ }
+ }
+ a = l.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 = [], h = {}, m = {}, p = {}, g = 0, d = this._nodes.length; g < d; ++g) {
+ var f = this._nodes[g];
+ if (!a || f.onExecute) {
+ h[f.id] = f;
+ var n = 0;
+ if (f.inputs) {
+ for (var k = 0, q = f.inputs.length; k < q; k++) {
+ f.inputs[k] && null != f.inputs[k].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 h[f.id], f.outputs) {
+ for (g = 0; g < f.outputs.length; g++) {
+ if (a = f.outputs[g], null != a && null != a.links && 0 != a.links.length) {
+ for (k = 0; k < a.links.length; k++) {
+ (d = this.links[a.links[k]]) && !m[d.id] && (n = this.getNodeById(d.target_id), null == n ? m[d.id] = !0 : (b && (!n._level || n._level <= f._level) && (n._level = f._level + 1), m[d.id] = !0, --p[n.id], 0 == p[n.id] && c.push(n)));
+ }
+ }
+ }
+ }
+ }
+ for (g in h) {
+ e.push(h[g]);
+ }
+ e.length != this._nodes.length && l.debug && console.warn("something went wrong, nodes missing");
+ d = e.length;
+ for (g = 0; g < d; ++g) {
+ e[g].order = g;
+ }
+ 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 (g = 0; g < d; ++g) {
+ e[g].order = g;
+ }
+ return e;
+ };
+ f.prototype.getAncestors = function(a) {
+ for (var b = [], e = [a], c = {}; e.length;) {
+ var h = e.shift();
+ if (h.inputs) {
+ c[h.id] || h == a || (c[h.id] = !0, b.push(h));
+ for (var m = 0; m < h.inputs.length; ++m) {
+ var p = h.getInputNode(m);
+ 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 h = b[c], m = h._level || 1;
+ e[m] || (e[m] = []);
+ e[m].push(h);
+ }
+ b = a;
+ for (c = 0; c < e.length; ++c) {
+ if (m = e[c]) {
+ for (var p = 100, g = a, d = 0; d < m.length; ++d) {
+ h = m[d], h.pos[0] = b, h.pos[1] = g, h.size[0] > p && (p = h.size[0]), g += h.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 || l.ALWAYS;
+ var c = this._nodes_in_order ? this._nodes_in_order : this._nodes;
+ if (c) {
+ for (var h = 0, m = c.length; h < m; ++h) {
+ var p = c[h];
+ 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 >= l.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 === l.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 h = e[c];
+ if (h.isPointInside(a, b, 2)) {
+ return h;
+ }
+ }
+ 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() {
+ l.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 h = a.links[c];
+ e[h[0]] = {id:h[0], origin_id:h[1], origin_slot:h[2], target_id:h[3], target_slot:h[4], type:h[5]};
+ }
+ a.links = e;
+ }
+ for (c in a) {
+ this[c] = a[c];
+ }
+ e = !1;
+ this._nodes = [];
+ if (b) {
+ c = 0;
+ for (h = b.length; c < h; ++c) {
+ var m = b[c], p = l.createNode(m.type, m.title);
+ p ? (p.id = m.id, this.add(p, !0)) : (l.debug && console.log("Node not found: " + m.type), e = !0);
+ }
+ c = 0;
+ for (h = b.length; c < h; ++c) {
+ m = b[c], (p = this.getNodeById(m.id)) && p.configure(m);
+ }
+ }
+ this._groups.length = 0;
+ if (a.groups) {
+ for (c = 0; c < a.groups.length; ++c) {
+ b = new l.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 = l.LGraphNode = k;
+ k.prototype._ctor = function(a) {
+ this.title = a || "Unnamed";
+ this.size = [l.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 = {};
+ };
+ k.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] = l.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 h = this.graph ? this.graph.links[e.link] : null;
+ this.onConnectionsChange(l.INPUT, c, !0, h, 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) {
+ h = this.graph ? this.graph.links[e.links[b]] : null, this.onConnectionsChange(l.OUTPUT, c, !0, h, e);
+ }
+ }
+ }
+ }
+ }
+ for (c in this.inputs) {
+ e = this.inputs[c], e.link && e.link.length && (h = e.link, "object" == typeof h && (e.link = h[0], this.graph && (this.graph.links[h[0]] = {id:h[0], origin_id:h[1], origin_slot:h[2], target_id:h[3], target_slot:h[4]})));
+ }
+ for (c in this.outputs) {
+ if (e = this.outputs[c], e.links && 0 != e.links.length) {
+ for (b in e.links) {
+ h = e.links[b], "object" == typeof h && (e.links[b] = h[0]);
+ }
+ }
+ }
+ if (this.onConfigure) {
+ this.onConfigure(a);
+ }
+ };
+ k.prototype.serialize = function() {
+ var a = {id:this.id, type:this.type, pos:this.pos, size:this.size, data:this.data, flags:l.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 = l.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;
+ };
+ k.prototype.clone = function() {
+ var a = l.createNode(this.type), b = l.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;
+ };
+ k.prototype.toString = function() {
+ return JSON.stringify(this.serialize());
+ };
+ k.prototype.getTitle = function() {
+ return this.title || this.constructor.title;
+ };
+ k.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;
+ }
+ }
+ }
+ };
+ k.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;
+ }
+ };
+ k.prototype.getInputDataByName = function(a, b) {
+ a = this.findInputSlot(a);
+ return -1 == a ? null : this.getInputData(a, b);
+ };
+ k.prototype.isInputConnected = function(a) {
+ return this.inputs ? a < this.inputs.length && null != this.inputs[a].link : !1;
+ };
+ k.prototype.getInputInfo = function(a) {
+ return this.inputs ? a < this.inputs.length ? this.inputs[a] : null : null;
+ };
+ k.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;
+ };
+ k.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];
+ };
+ k.prototype.getOutputData = function(a) {
+ return !this.outputs || a >= this.outputs.length ? null : this.outputs[a]._data;
+ };
+ k.prototype.getOutputInfo = function(a) {
+ return this.outputs ? a < this.outputs.length ? this.outputs[a] : null : null;
+ };
+ k.prototype.isOutputConnected = function(a) {
+ return this.outputs ? a < this.outputs.length && this.outputs[a].links && this.outputs[a].links.length : !1;
+ };
+ k.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;
+ };
+ k.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;
+ };
+ k.prototype.trigger = function(a, b) {
+ if (this.outputs && this.outputs.length) {
+ this.graph && (this.graph._last_trigger_time = l.getTime());
+ for (var e = 0; e < this.outputs.length; ++e) {
+ var c = this.outputs[e];
+ !c || c.type !== l.EVENT || a && c.name != a || this.triggerSlot(e, b);
+ }
+ }
+ };
+ k.prototype.triggerSlot = function(a, b) {
+ if (this.outputs && (a = this.outputs[a]) && (a = a.links) && a.length) {
+ this.graph && (this.graph._last_trigger_time = l.getTime());
+ for (var e = 0; e < a.length; ++e) {
+ var c = this.graph.links[a[e]];
+ if (c) {
+ var h = this.graph.getNodeById(c.target_id);
+ if (h) {
+ if (c._last_time = l.getTime(), c = h.inputs[c.target_slot], h.onAction) {
+ h.onAction(c.name, b);
+ } else {
+ if (h.mode === l.ON_TRIGGER && h.onExecute) {
+ h.onExecute(b);
+ }
+ }
+ }
+ }
+ }
+ }
+ };
+ k.prototype.addProperty = function(a, b, e, c) {
+ e = {name:a, type:e, default_value:b};
+ if (c) {
+ for (var h in c) {
+ e[h] = c[h];
+ }
+ }
+ this.properties_info || (this.properties_info = []);
+ this.properties_info.push(e);
+ this.properties || (this.properties = {});
+ this.properties[a] = b;
+ return e;
+ };
+ k.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;
+ };
+ k.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 h in e[2]) {
+ c[h] = e[2][h];
+ }
+ }
+ this.outputs || (this.outputs = []);
+ this.outputs.push(c);
+ if (this.onOutputAdded) {
+ this.onOutputAdded(c);
+ }
+ }
+ this.size = this.computeSize();
+ };
+ k.prototype.removeOutput = function(a) {
+ this.disconnectOutput(a);
+ this.outputs.splice(a, 1);
+ this.size = this.computeSize();
+ if (this.onOutputRemoved) {
+ this.onOutputRemoved(a);
+ }
+ };
+ k.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;
+ };
+ k.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 h in e[2]) {
+ c[h] = e[2][h];
+ }
+ }
+ this.inputs || (this.inputs = []);
+ this.inputs.push(c);
+ if (this.onInputAdded) {
+ this.onInputAdded(c);
+ }
+ }
+ this.size = this.computeSize();
+ };
+ k.prototype.removeInput = function(a) {
+ this.disconnectInput(a);
+ this.inputs.splice(a, 1);
+ this.size = this.computeSize();
+ if (this.onInputRemoved) {
+ this.onInputRemoved(a);
+ }
+ };
+ k.prototype.addConnection = function(a, b, e, c) {
+ a = {name:a, type:b, pos:e, direction:c, links:null};
+ this.connections.push(a);
+ return a;
+ };
+ k.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 = l.NODE_TEXT_SIZE;
+ b[1] = (this.constructor.slot_start_y || 0) + a * (c + 1) + (this.widgets ? this.widgets.length : 0) * (l.NODE_WIDGET_HEIGHT + 4) + 4;
+ a = e(this.title);
+ var h = 0, m = 0;
+ if (this.inputs) {
+ for (var p = 0, g = this.inputs.length; p < g; ++p) {
+ var d = this.inputs[p];
+ d = d.label || d.name || "";
+ d = e(d);
+ h < d && (h = d);
+ }
+ }
+ if (this.outputs) {
+ for (p = 0, g = this.outputs.length; p < g; ++p) {
+ d = this.outputs[p], d = d.label || d.name || "", d = e(d), m < d && (m = d);
+ }
+ }
+ b[0] = Math.max(h + m + 10, a);
+ b[0] = Math.max(b[0], l.NODE_WIDTH);
+ if (this.onResize) {
+ this.onResize(b);
+ }
+ return b;
+ };
+ k.prototype.addWidget = function(a, b, e, c, h) {
+ this.widgets || (this.widgets = []);
+ b = {type:a.toLowerCase(), name:b, value:e, callback:c, options:h || {}};
+ 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;
+ };
+ k.prototype.getBounding = function(a) {
+ a = a || new Float32Array(4);
+ a[0] = this.pos[0] - 4;
+ a[1] = this.pos[1] - l.NODE_TITLE_HEIGHT;
+ a[2] = this.size[0] + 4;
+ a[3] = this.size[1] + l.NODE_TITLE_HEIGHT;
+ return a;
+ };
+ k.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 (r(a, b, this.pos[0] - e, this.pos[1] - l.NODE_TITLE_HEIGHT - e, (this._collapsed_width || l.NODE_COLLAPSED_WIDTH) + 2 * e, l.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;
+ };
+ k.prototype.getSlotInPosition = function(a, b) {
+ if (this.inputs) {
+ for (var e = 0, c = this.inputs.length; e < c; ++e) {
+ var h = this.inputs[e], m = this.getConnectionPos(!0, e);
+ if (r(a, b, m[0] - 10, m[1] - 5, 20, 10)) {
+ return {input:h, slot:e, link_pos:m, locked:h.locked};
+ }
+ }
+ }
+ if (this.outputs) {
+ for (e = 0, c = this.outputs.length; e < c; ++e) {
+ if (h = this.outputs[e], m = this.getConnectionPos(!1, e), r(a, b, m[0] - 10, m[1] - 5, 20, 10)) {
+ return {output:h, slot:e, link_pos:m, locked:h.locked};
+ }
+ }
+ }
+ return null;
+ };
+ k.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;
+ };
+ k.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;
+ };
+ k.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 l.debug && console.log("Connect: Error, no slot of name " + a), !1;
+ }
+ } else {
+ if (!this.outputs || a >= this.outputs.length) {
+ return l.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 l.debug && console.log("Connect: Error, no slot of name " + e), !1;
+ }
+ } else {
+ if (e === l.EVENT) {
+ return !1;
+ }
+ if (!b.inputs || e >= b.inputs.length) {
+ return l.debug && console.log("Connect: Error, slot number not found"), !1;
+ }
+ }
+ null != b.inputs[e].link && b.disconnectInput(e);
+ this.setDirtyCanvas(!1, !0);
+ this.graph.connectionChange(this);
+ var c = this.outputs[a];
+ if (b.onConnectInput && !1 === b.onConnectInput(e, c.type, c)) {
+ return !1;
+ }
+ var h = b.inputs[e];
+ if (l.isValidConnection(c.type, h.type)) {
+ var m = {id:this.graph.last_link_id++, type:h.type, origin_id:this.id, origin_slot:a, target_id:b.id, target_slot:e};
+ this.graph.links[m.id] = m;
+ null == c.links && (c.links = []);
+ c.links.push(m.id);
+ b.inputs[e].link = m.id;
+ this.graph && this.graph._version++;
+ if (this.onConnectionsChange) {
+ this.onConnectionsChange(l.OUTPUT, a, !0, m, c);
+ }
+ if (b.onConnectionsChange) {
+ b.onConnectionsChange(l.INPUT, e, !0, m, h);
+ }
+ }
+ this.setDirtyCanvas(!1, !0);
+ this.graph.connectionChange(this);
+ return !0;
+ };
+ k.prototype.disconnectOutput = function(a, b) {
+ if (a.constructor === String) {
+ if (a = this.findOutputSlot(a), -1 == a) {
+ return l.debug && console.log("Connect: Error, no slot of name " + a), !1;
+ }
+ } else {
+ if (!this.outputs || a >= this.outputs.length) {
+ return l.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, h = e.links.length; c < h; c++) {
+ var m = e.links[c], p = this.graph.links[m];
+ if (p.target_id == b.id) {
+ e.links.splice(c, 1);
+ var g = b.inputs[p.target_slot];
+ g.link = null;
+ delete this.graph.links[m];
+ this.graph && this.graph._version++;
+ if (b.onConnectionsChange) {
+ b.onConnectionsChange(l.INPUT, p.target_slot, !1, p, g);
+ }
+ if (this.onConnectionsChange) {
+ this.onConnectionsChange(l.OUTPUT, a, !1, p, e);
+ }
+ break;
+ }
+ }
+ } else {
+ c = 0;
+ for (h = e.links.length; c < h; c++) {
+ if (m = e.links[c], p = this.graph.links[m]) {
+ b = this.graph.getNodeById(p.target_id);
+ this.graph && this.graph._version++;
+ if (b && (g = b.inputs[p.target_slot], g.link = null, b.onConnectionsChange)) {
+ b.onConnectionsChange(l.INPUT, p.target_slot, !1, p, g);
+ }
+ delete this.graph.links[m];
+ if (this.onConnectionsChange) {
+ this.onConnectionsChange(l.OUTPUT, a, !1, p, e);
+ }
+ }
+ }
+ e.links = null;
+ }
+ this.setDirtyCanvas(!1, !0);
+ this.graph.connectionChange(this);
+ return !0;
+ };
+ k.prototype.disconnectInput = function(a) {
+ if (a.constructor === String) {
+ if (a = this.findInputSlot(a), -1 == a) {
+ return l.debug && console.log("Connect: Error, no slot of name " + a), !1;
+ }
+ } else {
+ if (!this.inputs || a >= this.inputs.length) {
+ return l.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 h = this.graph.getNodeById(c.origin_id);
+ if (!h) {
+ return !1;
+ }
+ var m = h.outputs[c.origin_slot];
+ if (!m || !m.links || 0 == m.links.length) {
+ return !1;
+ }
+ for (var p = 0, g = m.links.length; p < g; p++) {
+ if (m.links[p] == e) {
+ m.links.splice(p, 1);
+ break;
+ }
+ }
+ delete this.graph.links[e];
+ this.graph && this.graph._version++;
+ if (this.onConnectionsChange) {
+ this.onConnectionsChange(l.INPUT, a, !1, c, b);
+ }
+ if (h.onConnectionsChange) {
+ h.onConnectionsChange(l.OUTPUT, p, !1, c, m);
+ }
+ }
+ this.setDirtyCanvas(!1, !0);
+ this.graph.connectionChange(this);
+ return !0;
+ };
+ k.prototype.getConnectionPos = function(a, b) {
+ return this.flags.collapsed ? a ? [this.pos[0], this.pos[1] - 0.5 * l.NODE_TITLE_HEIGHT] : [this.pos[0] + (this._collapsed_width || l.NODE_COLLAPSED_WIDTH), this.pos[1] - 0.5 * l.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]] :
+ a ? [this.pos[0], this.pos[1] + 10 + b * l.NODE_SLOT_HEIGHT + (this.constructor.slot_start_y || 0)] : [this.pos[0] + this.size[0] + 1, this.pos[1] + 10 + b * l.NODE_SLOT_HEIGHT + (this.constructor.slot_start_y || 0)];
+ };
+ k.prototype.alignToGrid = function() {
+ this.pos[0] = l.CANVAS_GRID_SIZE * Math.round(this.pos[0] / l.CANVAS_GRID_SIZE);
+ this.pos[1] = l.CANVAS_GRID_SIZE * Math.round(this.pos[1] / l.CANVAS_GRID_SIZE);
+ };
+ k.prototype.trace = function(a) {
+ this.console || (this.console = []);
+ this.console.push(a);
+ this.console.length > k.MAX_CONSOLE && this.console.shift();
+ this.graph.onNodeTrace(this, a);
+ };
+ k.prototype.setDirtyCanvas = function(a, b) {
+ this.graph && this.graph.sendActionToCanvas("setDirty", [a, b]);
+ };
+ k.prototype.loadImage = function(a) {
+ var b = new Image;
+ b.src = l.node_images_path + a;
+ b.ready = !1;
+ var e = this;
+ b.onload = function() {
+ this.ready = !0;
+ e.setDirtyCanvas(!0);
+ };
+ return b;
+ };
+ k.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;
+ }
+ }
+ }
+ };
+ k.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);
+ }
+ };
+ k.prototype.pin = function(a) {
+ this.graph._version++;
+ this.flags.pinned = void 0 === a ? !this.flags.pinned : a;
+ };
+ k.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 = l.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 = g.node_colors.pale_blue ? g.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 = k.prototype.isPointInside;
+ n.prototype.setDirtyCanvas = k.prototype.setDirtyCanvas;
+ u.LGraphCanvas = l.LGraphCanvas = g;
+ g.link_type_colors = {"-1":"#F85", number:"#AAC", node:"#DCA"};
+ g.gradients = {};
+ g.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();
+ }
+ };
+ g.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)));
+ };
+ g.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);
+ };
+ g.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);
+ }
+ };
+ g.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