=this.size[1]||!this.properties.show||!this._video||(c.save(),c.drawImage(this._video,0,0,this.size[0],this.size[1]),c.restore())};G.prototype.onGetOutputs=function(){return[["width","number"],["height","number"],["stream_ready",e.EVENT],["stream_closed",e.EVENT],["stream_error",e.EVENT]]};e.registerNodeType("graphics/webcam",G)})(this);
(function(B){function c(){this.addOutput("tex","Texture");this.addOutput("name","string");this.properties={name:"",filter:!0};this.size=[c.image_preview_size,c.image_preview_size]}function l(){this.addInput("Texture","Texture");this.properties={flipY:!1};this.size=[c.image_preview_size,c.image_preview_size]}function r(){this.addInput("Texture","Texture");this.addOutput("tex","Texture");this.addOutput("name","string");this.properties={name:"",generate_mipmaps:!1}}function t(){this.addInput("Texture",
"Texture");this.addInput("TextureB","Texture");this.addInput("value","number");this.addOutput("Texture","Texture");this.help="pixelcode must be vec3, uvcode must be vec2, is optional
\t\tuv: tex. coords
color: texture colorB: textureB
time: scene time value: input value
For multiline you must type: result = ...
";this.properties={value:1,pixelcode:"color + colorB * value",uvcode:"",precision:c.DEFAULT};
this.has_error=!1}function v(){this.addOutput("out","Texture");this.properties={code:"",u_value:1,u_color:[1,1,1,1],width:512,height:512,precision:c.DEFAULT};this.properties.code=v.pixel_shader;this._uniforms={u_value:1,u_color:vec4.create(),in_texture:0,texSize:vec4.create(),time:0}}function h(){this.addInput("in","Texture");this.addInput("scale","vec2");this.addInput("offset","vec2");this.addOutput("out","Texture");this.properties={offset:vec2.fromValues(0,0),scale:vec2.fromValues(1,1),precision:c.DEFAULT}}
-function E(){this.addInput("in","Texture");this.addInput("warp","Texture");this.addInput("factor","number");this.addOutput("out","Texture");this.properties={factor:.01,scale:[1,1],offset:[0,0],precision:c.DEFAULT};this._uniforms={u_texture:0,u_textureB:1,u_factor:1,u_scale:vec2.create(),u_offset:vec2.create()}}function A(){this.addInput("Texture","Texture");this.properties={additive:!1,antialiasing:!1,filter:!0,disable_alpha:!1,gamma:1,viewport:[0,0,1,1]};this.size[0]=130}function I(){this.addInput("Texture",
-"Texture");this.addOutput("","Texture");this.properties={size:0,generate_mipmaps:!1,precision:c.DEFAULT}}function J(){this.addInput("Texture","Texture");this.addOutput("","Texture");this.properties={iterations:1,generate_mipmaps:!1,precision:c.DEFAULT}}function F(){this.addInput("Texture","Texture");this.addOutput("","Texture");this.properties={size:[512,512],generate_mipmaps:!1,precision:c.DEFAULT}}function e(){this.addInput("Texture","Texture");this.addOutput("tex","Texture");this.addOutput("avg",
-"vec4");this.addOutput("lum","number");this.properties={use_previous_frame:!0,high_quality:!1};this._uniforms={u_texture:0,u_mipmap_offset:0};this._luminance=new Float32Array(4)}function D(){this.addInput("in","Texture");this.addInput("factor","Number");this.addOutput("out","Texture");this.properties={factor:.5};this._uniforms={u_texture:0,u_textureB:1,u_factor:this.properties.factor}}function H(){this.addInput("in","Texture");this.addOutput("avg","Texture");this.addOutput("array","Texture");this.properties=
+function F(){this.addInput("in","Texture");this.addInput("warp","Texture");this.addInput("factor","number");this.addOutput("out","Texture");this.properties={factor:.01,scale:[1,1],offset:[0,0],precision:c.DEFAULT};this._uniforms={u_texture:0,u_textureB:1,u_factor:1,u_scale:vec2.create(),u_offset:vec2.create()}}function C(){this.addInput("Texture","Texture");this.properties={additive:!1,antialiasing:!1,filter:!0,disable_alpha:!1,gamma:1,viewport:[0,0,1,1]};this.size[0]=130}function I(){this.addInput("Texture",
+"Texture");this.addOutput("","Texture");this.properties={size:0,generate_mipmaps:!1,precision:c.DEFAULT}}function J(){this.addInput("Texture","Texture");this.addOutput("","Texture");this.properties={iterations:1,generate_mipmaps:!1,precision:c.DEFAULT}}function G(){this.addInput("Texture","Texture");this.addOutput("","Texture");this.properties={size:[512,512],generate_mipmaps:!1,precision:c.DEFAULT}}function e(){this.addInput("Texture","Texture");this.addOutput("tex","Texture");this.addOutput("avg",
+"vec4");this.addOutput("lum","number");this.properties={use_previous_frame:!0,high_quality:!1};this._uniforms={u_texture:0,u_mipmap_offset:0};this._luminance=new Float32Array(4)}function D(){this.addInput("in","Texture");this.addInput("factor","Number");this.addOutput("out","Texture");this.properties={factor:.5};this._uniforms={u_texture:0,u_textureB:1,u_factor:this.properties.factor}}function E(){this.addInput("in","Texture");this.addOutput("avg","Texture");this.addOutput("array","Texture");this.properties=
{samples:64,frames_interval:1};this._uniforms={u_texture:0,u_textureB:1,u_samples:this.properties.samples,u_isamples:1/this.properties.samples};this.frame=0}function z(){this.addInput("Image","image");this.addOutput("","Texture");this.properties={}}function M(){this.addInput("Texture","Texture");this.addInput("LUT","Texture");this.addInput("Intensity","number");this.addOutput("","Texture");this.properties={enabled:!0,intensity:1,precision:c.DEFAULT,texture:null};M._shader||(M._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,
M.pixel_shader))}function k(){this.addInput("Texture","Texture");this.addInput("Atlas","Texture");this.addOutput("","Texture");this.properties={enabled:!0,num_row_symbols:4,symbol_size:16,brightness:1,colorize:!1,filter:!1,invert:!1,precision:c.DEFAULT,generate_mipmaps:!1,texture:null};k._shader||(k._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,k.pixel_shader));this._uniforms={u_texture:0,u_textureB:1,u_row_simbols:4,u_simbol_size:16,u_res:vec2.create()}}function n(){this.addInput("Texture","Texture");
this.addOutput("R","Texture");this.addOutput("G","Texture");this.addOutput("B","Texture");this.addOutput("A","Texture");n._shader||(n._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,n.pixel_shader))}function q(){this.addInput("R","Texture");this.addInput("G","Texture");this.addInput("B","Texture");this.addInput("A","Texture");this.addOutput("Texture","Texture");this.properties={precision:c.DEFAULT,R:1,G:1,B:1,A:1};this._color=vec4.create();this._uniforms={u_textureR:0,u_textureG:1,u_textureB:2,
@@ -552,8 +553,8 @@ u_textureA:3,u_color:this._color}}function a(){this.addOutput("Texture","Texture
"Texture");this.addInput("B","Texture");this.addInput("Mixer","Texture");this.addOutput("Texture","Texture");this.properties={factor:.5,size_from_biggest:!0,invert:!1,precision:c.DEFAULT};this._uniforms={u_textureA:0,u_textureB:1,u_textureMix:2,u_mix:vec4.create()}}function g(){this.addInput("Tex.","Texture");this.addOutput("Edges","Texture");this.properties={invert:!0,threshold:!1,factor:1,precision:c.DEFAULT};g._shader||(g._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,g.pixel_shader))}function f(){this.addInput("Texture",
"Texture");this.addInput("Distance","number");this.addInput("Range","number");this.addOutput("Texture","Texture");this.properties={distance:100,range:50,only_depth:!1,high_precision:!1};this._uniforms={u_texture:0,u_distance:100,u_range:50,u_camera_planes:null}}function m(){this.addInput("Texture","Texture");this.addOutput("Texture","Texture");this.properties={precision:c.DEFAULT,invert:!1};this._uniforms={u_texture:0,u_camera_planes:null,u_ires:vec2.create()}}function u(){this.addInput("Texture",
"Texture");this.addInput("Iterations","number");this.addInput("Intensity","number");this.addOutput("Blurred","Texture");this.properties={intensity:1,iterations:1,preserve_aspect:!1,scale:[1,1],precision:c.DEFAULT}}function O(){this.intensity=.5;this.persistence=.6;this.iterations=8;this.threshold=.8;this.scale=1;this.dirt_texture=null;this.dirt_factor=.5;this._textures=[];this._uniforms={u_intensity:1,u_texture:0,u_glow_texture:1,u_threshold:0,u_texel_size:vec2.create()}}function K(){this.addInput("in",
-"Texture");this.addInput("dirt","Texture");this.addOutput("out","Texture");this.addOutput("glow","Texture");this.properties={enabled:!0,intensity:1,persistence:.99,iterations:16,threshold:0,scale:1,dirt_factor:.5,precision:c.DEFAULT};this.fx=new O}function x(){this.addInput("Texture","Texture");this.addOutput("Filtered","Texture");this.properties={intensity:1,radius:5}}function C(){this.addInput("Texture","Texture");this.addOutput("Filtered","Texture");this.properties={sigma:1.4,k:1.6,p:21.7,epsilon:79,
-phi:.017}}function w(){this.addOutput("Webcam","Texture");this.properties={texture_name:"",facingMode:"user"};this.boxcolor="black";this.version=0}function L(){this.addInput("in","Texture");this.addInput("f","number");this.addOutput("out","Texture");this.properties={enabled:!0,factor:1,precision:c.LOW};this._uniforms={u_texture:0,u_factor:1}}function G(){this.addInput("in","");this.properties={precision:c.LOW,width:0,height:0,channels:1};this.addOutput("out","Texture")}function y(){this.addInput("in",
+"Texture");this.addInput("dirt","Texture");this.addOutput("out","Texture");this.addOutput("glow","Texture");this.properties={enabled:!0,intensity:1,persistence:.99,iterations:16,threshold:0,scale:1,dirt_factor:.5,precision:c.DEFAULT};this.fx=new O}function x(){this.addInput("Texture","Texture");this.addOutput("Filtered","Texture");this.properties={intensity:1,radius:5}}function A(){this.addInput("Texture","Texture");this.addOutput("Filtered","Texture");this.properties={sigma:1.4,k:1.6,p:21.7,epsilon:79,
+phi:.017}}function w(){this.addOutput("Webcam","Texture");this.properties={texture_name:"",facingMode:"user"};this.boxcolor="black";this.version=0}function L(){this.addInput("in","Texture");this.addInput("f","number");this.addOutput("out","Texture");this.properties={enabled:!0,factor:1,precision:c.LOW};this._uniforms={u_texture:0,u_factor:1}}function H(){this.addInput("in","");this.properties={precision:c.LOW,width:0,height:0,channels:1};this.addOutput("out","Texture")}function y(){this.addInput("in",
"Texture");this.addOutput("out","Texture");this.properties={precision:c.LOW,split_channels:!1};this._values=new Uint8Array(1024);this._values.fill(255);this._curve_texture=null;this._uniforms={u_texture:0,u_curve:1,u_range:1};this._must_update=!0;this._points={RGB:[[0,0],[1,1]],R:[[0,0],[1,1]],G:[[0,0],[1,1]],B:[[0,0],[1,1]]};this.curve_editor=null;this.addWidget("toggle","Split Channels",!1,"split_channels");this.addWidget("combo","Channel","RGB",{values:["RGB","R","G","B"]});this.curve_offset=68;
this.size=[240,160]}function P(){this.addInput("in","Texture");this.addInput("exp","number");this.addOutput("out","Texture");this.properties={exposition:1,precision:c.LOW};this._uniforms={u_texture:0,u_exposition:1}}function Q(){this.addInput("in","Texture");this.addInput("avg","number,Texture");this.addOutput("out","Texture");this.properties={enabled:!0,scale:1,gamma:1,average_lum:1,lum_white:1,precision:c.LOW};this._uniforms={u_texture:0,u_lumwhite2:1,u_igamma:1,u_scale:1,u_average_lum:1}}function S(){this.addOutput("out",
"Texture");this.properties={width:512,height:512,seed:0,persistence:.1,octaves:8,scale:1,offset:[0,0],amplitude:1,precision:c.DEFAULT};this._key=0;this._texture=null;this._uniforms={u_persistence:.1,u_seed:0,u_offset:vec2.create(),u_scale:1,u_viewport:vec2.create()}}function R(){this.addInput("v");this.addOutput("out","Texture");this.properties={code:R.default_code,width:512,height:512,clear:!0,precision:c.DEFAULT,use_html_canvas:!1};this._temp_texture=this._func=null;this.compileCode()}function T(){this.addInput("in",
@@ -571,8 +572,8 @@ a.save(),this.properties.flipY&&(a.translate(0,this.size[1]),a.scale(1,-1)),a.dr
a.unbind(0)),this.properties.name&&(c.storeTexture?c.storeTexture(this.properties.name,a):c.getTexturesContainer()[this.properties.name]=a),this._texture=a,this.setOutputData(0,a),this.setOutputData(1,this.properties.name))},N.registerNodeType("texture/save",r),t.widgets_info={uvcode:{widget:"code"},pixelcode:{widget:"code"},precision:{widget:"combo",values:c.MODE_VALUES}},t.title="Operation",t.desc="Texture shader operation",t.presets={},t.prototype.getExtraMenuOptions=function(a){var b=this;return[{content:b.properties.show?
"Hide Texture":"Show Texture",callback:function(){b.properties.show=!b.properties.show}}]},t.prototype.onPropertyChanged=function(){this.has_error=!1},t.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())},t.prototype.onExecute=function(){var a=this.getInputData(0);if(this.isOutputConnected(0))if(this.properties.precision===c.PASS_THROUGH)this.setOutputData(0,
a);else{var b=this.getInputData(1);if(this.properties.uvcode||this.properties.pixelcode){var d=512,f=512;a?(d=a.width,f=a.height):b&&(d=b.width,f=b.height);b||(b=GL.Texture.getWhiteTexture());var g=c.getTextureType(this.properties.precision,a);this._tex=a||this._tex?c.getTargetTexture(a||this._tex,this._tex,this.properties.precision):new GL.Texture(d,f,{type:g,format:gl.RGBA,filter:gl.LINEAR});g="";this.properties.uvcode&&(g="uv = "+this.properties.uvcode,-1!=this.properties.uvcode.indexOf(";")&&
-(g=this.properties.uvcode));var e="";this.properties.pixelcode&&(e="result = "+this.properties.pixelcode,-1!=this.properties.pixelcode.indexOf(";")&&(e=this.properties.pixelcode));var k=this._shader;if(!(this.has_error||k&&this._shader_code==g+"|"+e)){var m=c.replaceCode(t.pixel_shader,{UV_CODE:g,PIXEL_CODE:e});try{k=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,m),this.boxcolor="#00FF00"}catch(X){GL.Shader.dumpErrorToConsole(X,Shader.SCREEN_VERTEX_SHADER,m);this.boxcolor="#FF0000";this.has_error=!0;
-return}this._shader=k;this._shader_code=g+"|"+e}if(this._shader){var h=this.getInputData(2);null!=h?this.properties.value=h:h=parseFloat(this.properties.value);var q=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 c=Mesh.getScreenQuad();k.uniforms({u_texture:0,u_textureB:1,value:h,texSize:[d,f,1/d,1/f],time:q}).draw(c)});this.setOutputData(0,this._tex)}}}},t.pixel_shader="precision highp float;\n\t\t\n\t\tuniform sampler2D u_texture;\n\t\tuniform sampler2D u_textureB;\n\t\tvarying vec2 v_coord;\n\t\tuniform vec4 texSize;\n\t\tuniform float time;\n\t\tuniform float value;\n\t\t\n\t\tvoid main() {\n\t\t\tvec2 uv = v_coord;\n\t\t\t{{UV_CODE}};\n\t\t\tvec4 color4 = texture2D(u_texture, uv);\n\t\t\tvec3 color = color4.rgb;\n\t\t\tvec4 color4B = texture2D(u_textureB, uv);\n\t\t\tvec3 colorB = color4B.rgb;\n\t\t\tvec3 result = color;\n\t\t\tfloat alpha = 1.0;\n\t\t\t{{PIXEL_CODE}};\n\t\t\tgl_FragColor = vec4(result, alpha);\n\t\t}\n\t\t",
+(g=this.properties.uvcode));var e="";this.properties.pixelcode&&(e="result = "+this.properties.pixelcode,-1!=this.properties.pixelcode.indexOf(";")&&(e=this.properties.pixelcode));var k=this._shader;if(!(this.has_error||k&&this._shader_code==g+"|"+e)){var h=c.replaceCode(t.pixel_shader,{UV_CODE:g,PIXEL_CODE:e});try{k=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,h),this.boxcolor="#00FF00"}catch(X){GL.Shader.dumpErrorToConsole(X,Shader.SCREEN_VERTEX_SHADER,h);this.boxcolor="#FF0000";this.has_error=!0;
+return}this._shader=k;this._shader_code=g+"|"+e}if(this._shader){var m=this.getInputData(2);null!=m?this.properties.value=m:m=parseFloat(this.properties.value);var n=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 c=Mesh.getScreenQuad();k.uniforms({u_texture:0,u_textureB:1,value:m,texSize:[d,f,1/d,1/f],time:n}).draw(c)});this.setOutputData(0,this._tex)}}}},t.pixel_shader="precision highp float;\n\t\t\n\t\tuniform sampler2D u_texture;\n\t\tuniform sampler2D u_textureB;\n\t\tvarying vec2 v_coord;\n\t\tuniform vec4 texSize;\n\t\tuniform float time;\n\t\tuniform float value;\n\t\t\n\t\tvoid main() {\n\t\t\tvec2 uv = v_coord;\n\t\t\t{{UV_CODE}};\n\t\t\tvec4 color4 = texture2D(u_texture, uv);\n\t\t\tvec3 color = color4.rgb;\n\t\t\tvec4 color4B = texture2D(u_textureB, uv);\n\t\t\tvec3 colorB = color4B.rgb;\n\t\t\tvec3 result = color;\n\t\t\tfloat alpha = 1.0;\n\t\t\t{{PIXEL_CODE}};\n\t\t\tgl_FragColor = vec4(result, alpha);\n\t\t}\n\t\t",
t.registerPreset=function(a,b){t.presets[a]=b},t.registerPreset("",""),t.registerPreset("bypass","color"),t.registerPreset("add","color + colorB * value"),t.registerPreset("substract","(color - colorB) * value"),t.registerPreset("mate","mix( color, colorB, color4B.a * value)"),t.registerPreset("invert","vec3(1.0) - color"),t.registerPreset("multiply","color * colorB * value"),t.registerPreset("divide","(color / colorB) / value"),t.registerPreset("difference","abs(color - colorB) * value"),t.registerPreset("max",
"max(color, colorB) * value"),t.registerPreset("min","min(color, colorB) * value"),t.registerPreset("displace","texture2D(u_texture, uv + (colorB.xy - vec2(0.5)) * value).xyz"),t.registerPreset("grayscale","vec3(color.x + color.y + color.z) * value / 3.0"),t.registerPreset("saturation","mix( vec3(color.x + color.y + color.z) / 3.0, color, value )"),t.registerPreset("normalmap","\n\t\tfloat z0 = texture2D(u_texture, uv + vec2(-texSize.z, -texSize.w) ).x;\n\t\tfloat z1 = texture2D(u_texture, uv + vec2(0.0, -texSize.w) ).x;\n\t\tfloat z2 = texture2D(u_texture, uv + vec2(texSize.z, -texSize.w) ).x;\n\t\tfloat z3 = texture2D(u_texture, uv + vec2(-texSize.z, 0.0) ).x;\n\t\tfloat z4 = color.x;\n\t\tfloat z5 = texture2D(u_texture, uv + vec2(texSize.z, 0.0) ).x;\n\t\tfloat z6 = texture2D(u_texture, uv + vec2(-texSize.z, texSize.w) ).x;\n\t\tfloat z7 = texture2D(u_texture, uv + vec2(0.0, texSize.w) ).x;\n\t\tfloat z8 = texture2D(u_texture, uv + vec2(texSize.z, texSize.w) ).x;\n\t\tvec3 normal = vec3( z2 + 2.0*z4 + z7 - z0 - 2.0*z3 - z5, z5 + 2.0*z6 + z7 -z0 - 2.0*z1 - z2, 1.0 );\n\t\tnormal.xy *= value;\n\t\tresult.xyz = normalize(normal) * 0.5 + vec3(0.5);\n\t"),
t.registerPreset("threshold","vec3(color.x > colorB.x * value ? 1.0 : 0.0,color.y > colorB.y * value ? 1.0 : 0.0,color.z > colorB.z * value ? 1.0 : 0.0)"),t.prototype.onInspect=function(a){var b=this;a.addCombo("Presets","",{values:Object.keys(t.presets),callback:function(d){var c=t.presets[d];c&&(b.setProperty("pixelcode",c),b.title=d,a.refresh())}})},N.registerNodeType("texture/operation",t),v.title="Shader",v.desc="Texture shader",v.widgets_info={code:{type:"code",lang:"glsl"},precision:{widget:"combo",
@@ -583,31 +584,31 @@ k.u_value=this.properties.u_value;k.u_color.set(this.properties.u_color);this._t
N.registerNodeType("texture/shader",v),h.widgets_info={precision:{widget:"combo",values:c.MODE_VALUES}},h.title="Scale/Offset",h.desc="Applies an scaling and offseting",h.prototype.onExecute=function(){var a=this.getInputData(0);if(this.isOutputConnected(0)&&a)if(this.properties.precision===c.PASS_THROUGH)this.setOutputData(0,a);else{var b=a.width,d=a.height,f=this.precision===c.LOW?gl.UNSIGNED_BYTE:gl.HIGH_PRECISION_FORMAT;this.precision===c.DEFAULT&&(f=a.type);this._tex&&this._tex.width==b&&this._tex.height==
d&&this._tex.type==f||(this._tex=new GL.Texture(b,d,{type:f,format:gl.RGBA,filter:gl.LINEAR}));var g=this._shader;g||(g=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,h.pixel_shader));var e=this.getInputData(1);e?(this.properties.scale[0]=e[0],this.properties.scale[1]=e[1]):e=this.properties.scale;var k=this.getInputData(2);k?(this.properties.offset[0]=k[0],this.properties.offset[1]=k[1]):k=this.properties.offset;this._tex.drawTo(function(){gl.disable(gl.DEPTH_TEST);gl.disable(gl.CULL_FACE);gl.disable(gl.BLEND);
a.bind(0);var b=Mesh.getScreenQuad();g.uniforms({u_texture:0,u_scale:e,u_offset:k}).draw(b)});this.setOutputData(0,this._tex)}},h.pixel_shader="precision highp float;\n\t\t\n\t\tuniform sampler2D u_texture;\n\t\tuniform sampler2D u_textureB;\n\t\tvarying vec2 v_coord;\n\t\tuniform vec2 u_scale;\n\t\tuniform vec2 u_offset;\n\t\t\n\t\tvoid main() {\n\t\t\tvec2 uv = v_coord;\n\t\t\tuv = uv / u_scale - u_offset;\n\t\t\tgl_FragColor = texture2D(u_texture, uv);\n\t\t}\n\t\t",N.registerNodeType("texture/scaleOffset",
-h),E.widgets_info={precision:{widget:"combo",values:c.MODE_VALUES}},E.title="Warp",E.desc="Texture warp operation",E.prototype.onExecute=function(){var a=this.getInputData(0);if(this.isOutputConnected(0))if(this.properties.precision===c.PASS_THROUGH)this.setOutputData(0,a);else{var b=this.getInputData(1),d=512,f=512;a?(d=a.width,f=a.height):b&&(d=b.width,f=b.height);this._tex=a||this._tex?c.getTargetTexture(a||this._tex,this._tex,this.properties.precision):new GL.Texture(d,f,{type:this.precision===
-c.LOW?gl.UNSIGNED_BYTE:gl.HIGH_PRECISION_FORMAT,format:gl.RGBA,filter:gl.LINEAR});var g=this._shader;g||(g=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,E.pixel_shader));d=this.getInputData(2);null!=d?this.properties.factor=d:d=parseFloat(this.properties.factor);var e=this._uniforms;e.u_factor=d;e.u_scale.set(this.properties.scale);e.u_offset.set(this.properties.offset);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 d=
-Mesh.getScreenQuad();g.uniforms(e).draw(d)});this.setOutputData(0,this._tex)}},E.pixel_shader="precision highp float;\n\t\t\n\t\tuniform sampler2D u_texture;\n\t\tuniform sampler2D u_textureB;\n\t\tvarying vec2 v_coord;\n\t\tuniform float u_factor;\n\t\tuniform vec2 u_scale;\n\t\tuniform vec2 u_offset;\n\t\t\n\t\tvoid main() {\n\t\t\tvec2 uv = v_coord;\n\t\t\tuv += ( texture2D(u_textureB, uv).rg - vec2(0.5)) * u_factor * u_scale + u_offset;\n\t\t\tgl_FragColor = texture2D(u_texture, uv);\n\t\t}\n\t\t",
-N.registerNodeType("texture/warp",E),A.title="to Viewport",A.desc="Texture to viewport",A._prev_viewport=new Float32Array(4),A.prototype.onDrawBackground=function(a){if(!(this.flags.collapsed||40>=this.size[1])){var b=this.getInputData(0);b&&a.drawImage(a==gl?b:gl.canvas,10,30,this.size[0]-20,this.size[1]-40)}},A.prototype.onExecute=function(){var a=this.getInputData(0);if(a){this.properties.disable_alpha?gl.disable(gl.BLEND):(gl.enable(gl.BLEND),this.properties.additive?gl.blendFunc(gl.SRC_ALPHA,
-gl.ONE):gl.blendFunc(gl.SRC_ALPHA,gl.ONE_MINUS_SRC_ALPHA));gl.disable(gl.DEPTH_TEST);var b=this.properties.gamma||1;this.isInputConnected(1)&&(b=this.getInputData(1));a.setParameter(gl.TEXTURE_MAG_FILTER,this.properties.filter?gl.LINEAR:gl.NEAREST);var d=A._prev_viewport;d.set(gl.viewport_data);var c=this.properties.viewport;gl.viewport(d[0]+d[2]*c[0],d[1]+d[3]*c[1],d[2]*c[2],d[3]*c[3]);gl.getViewport();this.properties.antialiasing?(A._shader||(A._shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,
-A.aa_pixel_shader)),c=Mesh.getScreenQuad(),a.bind(0),A._shader.uniforms({u_texture:0,uViewportSize:[a.width,a.height],u_igamma:1/b,inverseVP:[1/a.width,1/a.height]}).draw(c)):1!=b?(A._gamma_shader||(A._gamma_shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,A.gamma_pixel_shader)),a.toViewport(A._gamma_shader,{u_texture:0,u_igamma:1/b})):a.toViewport();gl.viewport(d[0],d[1],d[2],d[3])}},A.prototype.onGetInputs=function(){return[["gamma","number"]]},A.aa_pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_texture;\n\t\tuniform vec2 uViewportSize;\n\t\tuniform vec2 inverseVP;\n\t\tuniform float u_igamma;\n\t\t#define FXAA_REDUCE_MIN (1.0/ 128.0)\n\t\t#define FXAA_REDUCE_MUL (1.0 / 8.0)\n\t\t#define FXAA_SPAN_MAX 8.0\n\t\t\n\t\t/* from mitsuhiko/webgl-meincraft based on the code on geeks3d.com */\n\t\tvec4 applyFXAA(sampler2D tex, vec2 fragCoord)\n\t\t{\n\t\t\tvec4 color = vec4(0.0);\n\t\t\t/*vec2 inverseVP = vec2(1.0 / uViewportSize.x, 1.0 / uViewportSize.y);*/\n\t\t\tvec3 rgbNW = texture2D(tex, (fragCoord + vec2(-1.0, -1.0)) * inverseVP).xyz;\n\t\t\tvec3 rgbNE = texture2D(tex, (fragCoord + vec2(1.0, -1.0)) * inverseVP).xyz;\n\t\t\tvec3 rgbSW = texture2D(tex, (fragCoord + vec2(-1.0, 1.0)) * inverseVP).xyz;\n\t\t\tvec3 rgbSE = texture2D(tex, (fragCoord + vec2(1.0, 1.0)) * inverseVP).xyz;\n\t\t\tvec3 rgbM = texture2D(tex, fragCoord * inverseVP).xyz;\n\t\t\tvec3 luma = vec3(0.299, 0.587, 0.114);\n\t\t\tfloat lumaNW = dot(rgbNW, luma);\n\t\t\tfloat lumaNE = dot(rgbNE, luma);\n\t\t\tfloat lumaSW = dot(rgbSW, luma);\n\t\t\tfloat lumaSE = dot(rgbSE, luma);\n\t\t\tfloat lumaM = dot(rgbM, luma);\n\t\t\tfloat lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n\t\t\tfloat lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\t\t\t\n\t\t\tvec2 dir;\n\t\t\tdir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n\t\t\tdir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n\t\t\t\n\t\t\tfloat dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n\t\t\t\n\t\t\tfloat rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\n\t\t\tdir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * inverseVP;\n\t\t\t\n\t\t\tvec3 rgbA = 0.5 * (texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz + \n\t\t\t\ttexture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\n\t\t\tvec3 rgbB = rgbA * 0.5 + 0.25 * (texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz + \n\t\t\t\ttexture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);\n\t\t\t\n\t\t\t//return vec4(rgbA,1.0);\n\t\t\tfloat lumaB = dot(rgbB, luma);\n\t\t\tif ((lumaB < lumaMin) || (lumaB > lumaMax))\n\t\t\t\tcolor = vec4(rgbA, 1.0);\n\t\t\telse\n\t\t\t\tcolor = vec4(rgbB, 1.0);\n\t\t\tif(u_igamma != 1.0)\n\t\t\t\tcolor.xyz = pow( color.xyz, vec3(u_igamma) );\n\t\t\treturn color;\n\t\t}\n\t\t\n\t\tvoid main() {\n\t\t gl_FragColor = applyFXAA( u_texture, v_coord * uViewportSize) ;\n\t\t}\n\t\t",
-A.gamma_pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_texture;\n\t\tuniform float u_igamma;\n\t\tvoid main() {\n\t\t\tvec4 color = texture2D( u_texture, v_coord);\n\t\t\tcolor.xyz = pow(color.xyz, vec3(u_igamma) );\n\t\t gl_FragColor = color;\n\t\t}\n\t\t",N.registerNodeType("texture/toviewport",A),I.title="Copy",I.desc="Copy Texture",I.widgets_info={size:{widget:"combo",values:[0,32,64,128,256,512,1024,2048]},precision:{widget:"combo",
+h),F.widgets_info={precision:{widget:"combo",values:c.MODE_VALUES}},F.title="Warp",F.desc="Texture warp operation",F.prototype.onExecute=function(){var a=this.getInputData(0);if(this.isOutputConnected(0))if(this.properties.precision===c.PASS_THROUGH)this.setOutputData(0,a);else{var b=this.getInputData(1),d=512,f=512;a?(d=a.width,f=a.height):b&&(d=b.width,f=b.height);this._tex=a||this._tex?c.getTargetTexture(a||this._tex,this._tex,this.properties.precision):new GL.Texture(d,f,{type:this.precision===
+c.LOW?gl.UNSIGNED_BYTE:gl.HIGH_PRECISION_FORMAT,format:gl.RGBA,filter:gl.LINEAR});var g=this._shader;g||(g=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,F.pixel_shader));d=this.getInputData(2);null!=d?this.properties.factor=d:d=parseFloat(this.properties.factor);var e=this._uniforms;e.u_factor=d;e.u_scale.set(this.properties.scale);e.u_offset.set(this.properties.offset);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 d=
+Mesh.getScreenQuad();g.uniforms(e).draw(d)});this.setOutputData(0,this._tex)}},F.pixel_shader="precision highp float;\n\t\t\n\t\tuniform sampler2D u_texture;\n\t\tuniform sampler2D u_textureB;\n\t\tvarying vec2 v_coord;\n\t\tuniform float u_factor;\n\t\tuniform vec2 u_scale;\n\t\tuniform vec2 u_offset;\n\t\t\n\t\tvoid main() {\n\t\t\tvec2 uv = v_coord;\n\t\t\tuv += ( texture2D(u_textureB, uv).rg - vec2(0.5)) * u_factor * u_scale + u_offset;\n\t\t\tgl_FragColor = texture2D(u_texture, uv);\n\t\t}\n\t\t",
+N.registerNodeType("texture/warp",F),C.title="to Viewport",C.desc="Texture to viewport",C._prev_viewport=new Float32Array(4),C.prototype.onDrawBackground=function(a){if(!(this.flags.collapsed||40>=this.size[1])){var b=this.getInputData(0);b&&a.drawImage(a==gl?b:gl.canvas,10,30,this.size[0]-20,this.size[1]-40)}},C.prototype.onExecute=function(){var a=this.getInputData(0);if(a){this.properties.disable_alpha?gl.disable(gl.BLEND):(gl.enable(gl.BLEND),this.properties.additive?gl.blendFunc(gl.SRC_ALPHA,
+gl.ONE):gl.blendFunc(gl.SRC_ALPHA,gl.ONE_MINUS_SRC_ALPHA));gl.disable(gl.DEPTH_TEST);var b=this.properties.gamma||1;this.isInputConnected(1)&&(b=this.getInputData(1));a.setParameter(gl.TEXTURE_MAG_FILTER,this.properties.filter?gl.LINEAR:gl.NEAREST);var d=C._prev_viewport;d.set(gl.viewport_data);var c=this.properties.viewport;gl.viewport(d[0]+d[2]*c[0],d[1]+d[3]*c[1],d[2]*c[2],d[3]*c[3]);gl.getViewport();this.properties.antialiasing?(C._shader||(C._shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,
+C.aa_pixel_shader)),c=Mesh.getScreenQuad(),a.bind(0),C._shader.uniforms({u_texture:0,uViewportSize:[a.width,a.height],u_igamma:1/b,inverseVP:[1/a.width,1/a.height]}).draw(c)):1!=b?(C._gamma_shader||(C._gamma_shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,C.gamma_pixel_shader)),a.toViewport(C._gamma_shader,{u_texture:0,u_igamma:1/b})):a.toViewport();gl.viewport(d[0],d[1],d[2],d[3])}},C.prototype.onGetInputs=function(){return[["gamma","number"]]},C.aa_pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_texture;\n\t\tuniform vec2 uViewportSize;\n\t\tuniform vec2 inverseVP;\n\t\tuniform float u_igamma;\n\t\t#define FXAA_REDUCE_MIN (1.0/ 128.0)\n\t\t#define FXAA_REDUCE_MUL (1.0 / 8.0)\n\t\t#define FXAA_SPAN_MAX 8.0\n\t\t\n\t\t/* from mitsuhiko/webgl-meincraft based on the code on geeks3d.com */\n\t\tvec4 applyFXAA(sampler2D tex, vec2 fragCoord)\n\t\t{\n\t\t\tvec4 color = vec4(0.0);\n\t\t\t/*vec2 inverseVP = vec2(1.0 / uViewportSize.x, 1.0 / uViewportSize.y);*/\n\t\t\tvec3 rgbNW = texture2D(tex, (fragCoord + vec2(-1.0, -1.0)) * inverseVP).xyz;\n\t\t\tvec3 rgbNE = texture2D(tex, (fragCoord + vec2(1.0, -1.0)) * inverseVP).xyz;\n\t\t\tvec3 rgbSW = texture2D(tex, (fragCoord + vec2(-1.0, 1.0)) * inverseVP).xyz;\n\t\t\tvec3 rgbSE = texture2D(tex, (fragCoord + vec2(1.0, 1.0)) * inverseVP).xyz;\n\t\t\tvec3 rgbM = texture2D(tex, fragCoord * inverseVP).xyz;\n\t\t\tvec3 luma = vec3(0.299, 0.587, 0.114);\n\t\t\tfloat lumaNW = dot(rgbNW, luma);\n\t\t\tfloat lumaNE = dot(rgbNE, luma);\n\t\t\tfloat lumaSW = dot(rgbSW, luma);\n\t\t\tfloat lumaSE = dot(rgbSE, luma);\n\t\t\tfloat lumaM = dot(rgbM, luma);\n\t\t\tfloat lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n\t\t\tfloat lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\t\t\t\n\t\t\tvec2 dir;\n\t\t\tdir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n\t\t\tdir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n\t\t\t\n\t\t\tfloat dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n\t\t\t\n\t\t\tfloat rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);\n\t\t\tdir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * inverseVP;\n\t\t\t\n\t\t\tvec3 rgbA = 0.5 * (texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz + \n\t\t\t\ttexture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);\n\t\t\tvec3 rgbB = rgbA * 0.5 + 0.25 * (texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz + \n\t\t\t\ttexture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);\n\t\t\t\n\t\t\t//return vec4(rgbA,1.0);\n\t\t\tfloat lumaB = dot(rgbB, luma);\n\t\t\tif ((lumaB < lumaMin) || (lumaB > lumaMax))\n\t\t\t\tcolor = vec4(rgbA, 1.0);\n\t\t\telse\n\t\t\t\tcolor = vec4(rgbB, 1.0);\n\t\t\tif(u_igamma != 1.0)\n\t\t\t\tcolor.xyz = pow( color.xyz, vec3(u_igamma) );\n\t\t\treturn color;\n\t\t}\n\t\t\n\t\tvoid main() {\n\t\t gl_FragColor = applyFXAA( u_texture, v_coord * uViewportSize) ;\n\t\t}\n\t\t",
+C.gamma_pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_texture;\n\t\tuniform float u_igamma;\n\t\tvoid main() {\n\t\t\tvec4 color = texture2D( u_texture, v_coord);\n\t\t\tcolor.xyz = pow(color.xyz, vec3(u_igamma) );\n\t\t gl_FragColor = color;\n\t\t}\n\t\t",N.registerNodeType("texture/toviewport",C),I.title="Copy",I.desc="Copy Texture",I.widgets_info={size:{widget:"combo",values:[0,32,64,128,256,512,1024,2048]},precision:{widget:"combo",
values:c.MODE_VALUES}},I.prototype.onExecute=function(){var a=this.getInputData(0);if((a||this._temp_texture)&&this.isOutputConnected(0)){if(a){var b=a.width,d=a.height;0!=this.properties.size&&(d=b=this.properties.size);var f=this._temp_texture,g=a.type;this.properties.precision===c.LOW?g=gl.UNSIGNED_BYTE:this.properties.precision===c.HIGH&&(g=gl.HIGH_PRECISION_FORMAT);f&&f.width==b&&f.height==d&&f.type==g||(f=gl.LINEAR,this.properties.generate_mipmaps&&isPowerOfTwo(b)&&isPowerOfTwo(d)&&(f=gl.LINEAR_MIPMAP_LINEAR),
this._temp_texture=new GL.Texture(b,d,{type:g,format:gl.RGBA,minFilter:f,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)}},N.registerNodeType("texture/copy",I),J.title="Downsample",J.desc="Downsample Texture",J.widgets_info={iterations:{type:"number",step:1,precision:0,min:0},precision:{widget:"combo",values:c.MODE_VALUES}},
-J.prototype.onExecute=function(){var a=this.getInputData(0);if((a||this._temp_texture)&&this.isOutputConnected(0)&&a&&a.texture_type===GL.TEXTURE_2D)if(1>this.properties.iterations)this.setOutputData(0,a);else{var b=J._shader;b||(J._shader=b=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,J.pixel_shader));var d=a.width|0,f=a.height|0,g=a.type;this.properties.precision===c.LOW?g=gl.UNSIGNED_BYTE:this.properties.precision===c.HIGH&&(g=gl.HIGH_PRECISION_FORMAT);var e=this.properties.iterations||1,k=a,m=
-[];g={type:g,format:a.format};var h=vec2.create(),q={u_offset:h};this._texture&&GL.Texture.releaseTemporary(this._texture);for(var n=0;n>1||0;f=f>>1||0;a=GL.Texture.getTemporary(d,f,g);m.push(a);k.setParameter(GL.TEXTURE_MAG_FILTER,GL.NEAREST);k.copyTo(a,b,q);if(1==d&&1==f)break;k=a}this._texture=m.pop();for(n=0;nthis.properties.iterations)this.setOutputData(0,a);else{var b=J._shader;b||(J._shader=b=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,J.pixel_shader));var d=a.width|0,f=a.height|0,g=a.type;this.properties.precision===c.LOW?g=gl.UNSIGNED_BYTE:this.properties.precision===c.HIGH&&(g=gl.HIGH_PRECISION_FORMAT);var e=this.properties.iterations||1,k=a,h=
+[];g={type:g,format:a.format};var m=vec2.create(),n={u_offset:m};this._texture&&GL.Texture.releaseTemporary(this._texture);for(var q=0;q>1||0;f=f>>1||0;a=GL.Texture.getTemporary(d,f,g);h.push(a);k.setParameter(GL.TEXTURE_MAG_FILTER,GL.NEAREST);k.copyTo(a,b,n);if(1==d&&1==f)break;k=a}this._texture=h.pop();for(q=0;qc;c++)this.isOutputConnected(c)?(this._channels[c]&&this._channels[c].width==a.width&&this._channels[c].height==a.height&&this._channels[c].type==a.type&&this._channels[c].format==b||(this._channels[c]=new GL.Texture(a.width,a.height,{type:a.type,format:b,filter:gl.LINEAR})),
d++):this._channels[c]=null;if(d){gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var f=Mesh.getScreenQuad(),g=n._shader,e=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];for(c=0;4>c;c++)this._channels[c]&&(this._channels[c].drawTo(function(){a.bind(0);g.uniforms({u_texture:0,u_mask:e[c]}).draw(f)}),this.setOutputData(c,this._channels[c]))}}},n.pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_texture;\n\t\tuniform vec4 u_mask;\n\t\t\n\t\tvoid main() {\n\t\t gl_FragColor = vec4( vec3( length( texture2D(u_texture, v_coord) * u_mask )), 1.0 );\n\t\t}\n\t\t",
N.registerNodeType("texture/textureChannels",n),q.title="Channels to Texture",q.desc="Split texture channels",q.widgets_info={precision:{widget:"combo",values:c.MODE_VALUES}},q.prototype.onExecute=function(){var a=c.getWhiteTexture(),b=this.getInputData(0)||a,d=this.getInputData(1)||a,f=this.getInputData(2)||a,g=this.getInputData(3)||a;gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var e=Mesh.getScreenQuad();q._shader||(q._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,q.pixel_shader));var k=q._shader;
-a=Math.max(b.width,d.width,f.width,g.width);var m=Math.max(b.height,d.height,f.height,g.height),h=this.properties.precision==c.HIGH?c.HIGH_PRECISION_FORMAT:gl.UNSIGNED_BYTE;this._texture&&this._texture.width==a&&this._texture.height==m&&this._texture.type==h||(this._texture=new GL.Texture(a,m,{type:h,format:gl.RGBA,filter:gl.LINEAR}));a=this._color;a[0]=this.properties.R;a[1]=this.properties.G;a[2]=this.properties.B;a[3]=this.properties.A;var n=this._uniforms;this._texture.drawTo(function(){b.bind(0);
+a=Math.max(b.width,d.width,f.width,g.width);var h=Math.max(b.height,d.height,f.height,g.height),m=this.properties.precision==c.HIGH?c.HIGH_PRECISION_FORMAT:gl.UNSIGNED_BYTE;this._texture&&this._texture.width==a&&this._texture.height==h&&this._texture.type==m||(this._texture=new GL.Texture(a,h,{type:m,format:gl.RGBA,filter:gl.LINEAR}));a=this._color;a[0]=this.properties.R;a[1]=this.properties.G;a[2]=this.properties.B;a[3]=this.properties.A;var n=this._uniforms;this._texture.drawTo(function(){b.bind(0);
d.bind(1);f.bind(2);g.bind(3);k.uniforms(n).draw(e)});this.setOutputData(0,this._texture)},q.pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_textureR;\n\t\tuniform sampler2D u_textureG;\n\t\tuniform sampler2D u_textureB;\n\t\tuniform sampler2D u_textureA;\n\t\tuniform vec4 u_color;\n\t\t\n\t\tvoid main() {\n\t\t gl_FragColor = u_color * vec4( \t\t\t\t\ttexture2D(u_textureR, v_coord).r,\t\t\t\t\ttexture2D(u_textureG, v_coord).r,\t\t\t\t\ttexture2D(u_textureB, v_coord).r,\t\t\t\t\ttexture2D(u_textureA, v_coord).r);\n\t\t}\n\t\t",
N.registerNodeType("texture/channelsTexture",q),a.title="Color",a.desc="Generates a 1x1 texture with a constant color",a.widgets_info={precision:{widget:"combo",values:c.MODE_VALUES}},a.prototype.onDrawBackground=function(a){var b=this.properties.color;a.fillStyle="rgb("+Math.floor(255*Math.clamp(b[0],0,1))+","+Math.floor(255*Math.clamp(b[1],0,1))+","+Math.floor(255*Math.clamp(b[2],0,1))+")";this.flags.collapsed?this.boxcolor=a.fillStyle:a.fillRect(0,0,this.size[0],this.size[1])},a.prototype.onExecute=
function(){var a=this.properties.precision==c.HIGH?c.HIGH_PRECISION_FORMAT:gl.UNSIGNED_BYTE;this._tex&&this._tex.type==a||(this._tex=new GL.Texture(1,1,{format:gl.RGBA,type:a,minFilter:gl.NEAREST}));a=this.properties.color;if(this.inputs)for(var b=0;ba.width?b:
-a,this._tex,this.properties.precision);gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var e=Mesh.getScreenQuad(),k=null,m=this._uniforms;f?(k=d._shader_tex,k||(k=d._shader_tex=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,d.pixel_shader,{MIX_TEX:""}))):(k=d._shader_factor,k||(k=d._shader_factor=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,d.pixel_shader)),g=null==g?this.properties.factor:g,m.u_mix.set([g,g,g,g]));var h=this.properties.invert;this._tex.drawTo(function(){a.bind(h?1:0);b.bind(h?0:1);f&&f.bind(2);
-k.uniforms(m).draw(e)});this.setOutputData(0,this._tex)}}},d.prototype.onGetInputs=function(){return[["factor","number"]]},d.pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_textureA;\n\t\tuniform sampler2D u_textureB;\n\t\t#ifdef MIX_TEX\n\t\t\tuniform sampler2D u_textureMix;\n\t\t#else\n\t\t\tuniform vec4 u_mix;\n\t\t#endif\n\t\t\n\t\tvoid main() {\n\t\t\t#ifdef MIX_TEX\n\t\t\t vec4 f = texture2D(u_textureMix, v_coord);\n\t\t\t#else\n\t\t\t vec4 f = u_mix;\n\t\t\t#endif\n\t\t gl_FragColor = mix( texture2D(u_textureA, v_coord), texture2D(u_textureB, v_coord), f );\n\t\t}\n\t\t",
+a,this._tex,this.properties.precision);gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var e=Mesh.getScreenQuad(),k=null,h=this._uniforms;f?(k=d._shader_tex,k||(k=d._shader_tex=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,d.pixel_shader,{MIX_TEX:""}))):(k=d._shader_factor,k||(k=d._shader_factor=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,d.pixel_shader)),g=null==g?this.properties.factor:g,h.u_mix.set([g,g,g,g]));var m=this.properties.invert;this._tex.drawTo(function(){a.bind(m?1:0);b.bind(m?0:1);f&&f.bind(2);
+k.uniforms(h).draw(e)});this.setOutputData(0,this._tex)}}},d.prototype.onGetInputs=function(){return[["factor","number"]]},d.pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_textureA;\n\t\tuniform sampler2D u_textureB;\n\t\t#ifdef MIX_TEX\n\t\t\tuniform sampler2D u_textureMix;\n\t\t#else\n\t\t\tuniform vec4 u_mix;\n\t\t#endif\n\t\t\n\t\tvoid main() {\n\t\t\t#ifdef MIX_TEX\n\t\t\t vec4 f = texture2D(u_textureMix, v_coord);\n\t\t\t#else\n\t\t\t vec4 f = u_mix;\n\t\t\t#endif\n\t\t gl_FragColor = mix( texture2D(u_textureA, v_coord), texture2D(u_textureB, v_coord), f );\n\t\t}\n\t\t",
N.registerNodeType("texture/mix",d),g.title="Edges",g.desc="Detects edges",g.widgets_info={precision:{widget:"combo",values:c.MODE_VALUES}},g.prototype.onExecute=function(){if(this.isOutputConnected(0)){var a=this.getInputData(0);if(this.properties.precision===c.PASS_THROUGH)this.setOutputData(0,a);else if(a){this._tex=c.getTargetTexture(a,this._tex,this.properties.precision);gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var b=Mesh.getScreenQuad(),d=g._shader,f=this.properties.invert,e=this.properties.factor,
k=this.properties.threshold?1:0;this._tex.drawTo(function(){a.bind(0);d.uniforms({u_texture:0,u_isize:[1/a.width,1/a.height],u_factor:e,u_threshold:k,u_invert:f?1:0}).draw(b)});this.setOutputData(0,this._tex)}}},g.pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_texture;\n\t\tuniform vec2 u_isize;\n\t\tuniform int u_invert;\n\t\tuniform float u_factor;\n\t\tuniform float u_threshold;\n\t\t\n\t\tvoid main() {\n\t\t\tvec4 center = texture2D(u_texture, v_coord);\n\t\t\tvec4 up = texture2D(u_texture, v_coord + u_isize * vec2(0.0,1.0) );\n\t\t\tvec4 down = texture2D(u_texture, v_coord + u_isize * vec2(0.0,-1.0) );\n\t\t\tvec4 left = texture2D(u_texture, v_coord + u_isize * vec2(1.0,0.0) );\n\t\t\tvec4 right = texture2D(u_texture, v_coord + u_isize * vec2(-1.0,0.0) );\n\t\t\tvec4 diff = abs(center - up) + abs(center - down) + abs(center - left) + abs(center - right);\n\t\t\tdiff *= u_factor;\n\t\t\tif(u_invert == 1)\n\t\t\t\tdiff.xyz = vec3(1.0) - diff.xyz;\n\t\t\tif( u_threshold == 0.0 )\n\t\t\t\tgl_FragColor = vec4( diff.xyz, center.a );\n\t\t\telse\n\t\t\t\tgl_FragColor = vec4( diff.x > 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}\n\t\t",
N.registerNodeType("texture/edges",g),f.title="Depth Range",f.desc="Generates a texture with a depth range",f.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,
@@ -638,10 +639,10 @@ this._temp_texture.height==a.height||(this._temp_texture=new GL.Texture(a.width,
d.u_camera_planes=b;d.u_ires.set([0,0]);this._temp_texture.drawTo(function(){a.bind(0);g.uniforms(d).draw(f)});this._temp_texture.near_far_planes=b;this.setOutputData(0,this._temp_texture)}}},m.pixel_shader="precision highp float;\n\t\tprecision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_texture;\n\t\tuniform vec2 u_camera_planes;\n\t\tuniform int u_invert;\n\t\tuniform vec2 u_ires;\n\t\t\n\t\tvoid main() {\n\t\t\tfloat zNear = u_camera_planes.x;\n\t\t\tfloat zFar = u_camera_planes.y;\n\t\t\tfloat depth = texture2D(u_texture, v_coord + u_ires*0.5).x * 2.0 - 1.0;\n\t\t\tfloat f = zNear * (depth + 1.0) / (zFar + zNear - depth * (zFar - zNear));\n\t\t\tif( u_invert == 1 )\n\t\t\t\tf = 1.0 - f;\n\t\t\tgl_FragColor = vec4(vec3(f),1.0);\n\t\t}\n\t\t",
N.registerNodeType("texture/linear_depth",m),u.title="Blur",u.desc="Blur a texture",u.widgets_info={precision:{widget:"combo",values:c.MODE_VALUES}},u.max_iterations=20,u.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 d=this.properties.iterations;this.isInputConnected(1)&&
(d=this.getInputData(1),this.properties.iterations=d);d=Math.min(Math.floor(d),u.max_iterations);if(0==d)this.setOutputData(0,a);else{var c=this.properties.intensity;this.isInputConnected(2)&&(c=this.getInputData(2),this.properties.intensity=c);var f=N.camera_aspect;f||void 0===window.gl||(f=gl.canvas.height/gl.canvas.width);f||(f=1);f=this.properties.preserve_aspect?f:1;var g=this.properties.scale||[1,1];a.applyBlur(f*g[0],g[1],c,b);for(a=1;a>=1;1<(g|0)&&(g>>=1);if(2>f)break;q=m[u]=GL.Texture.getTemporary(f,g,e);l[0]=1/n.width;l[1]=1/n.height;n.blit(q,h.uniforms(k));n=q}c&&(l[0]=1/n.width,l[1]=1/n.height,k.u_intensity=G,k.u_delta=1,n.blit(c,h.uniforms(k)));gl.enable(gl.BLEND);gl.blendFunc(gl.ONE,gl.ONE);k.u_intensity=this.persistence;
-k.u_delta=.5;for(u-=2;0<=u;u--)q=m[u],m[u]=null,l[0]=1/n.width,l[1]=1/n.height,n.blit(q,h.uniforms(k)),GL.Texture.releaseTemporary(n),n=q;gl.disable(gl.BLEND);d&&n.blit(d);if(b){var t=this.dirt_texture,w=this.dirt_factor;k.u_intensity=G;h=t?O._dirt_final_shader:O._final_shader;h||(h=t?O._dirt_final_shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,O.final_pixel_shader,{USE_DIRT:""}):O._final_shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,O.final_pixel_shader));b.drawTo(function(){a.bind(0);
-n.bind(1);t&&(h.setUniform("u_dirt_factor",w),h.setUniform("u_dirt_texture",t.bind(2)));h.toViewport(k)})}GL.Texture.releaseTemporary(n)},O.cut_pixel_shader="precision highp float;\n\tvarying vec2 v_coord;\n\tuniform sampler2D u_texture;\n\tuniform float u_threshold;\n\tvoid main() {\n\t\tgl_FragColor = max( texture2D( u_texture, v_coord ) - vec4( u_threshold ), vec4(0.0) );\n\t}",O.scale_pixel_shader="precision highp float;\n\tvarying vec2 v_coord;\n\tuniform sampler2D u_texture;\n\tuniform vec2 u_texel_size;\n\tuniform float u_delta;\n\tuniform float u_intensity;\n\t\n\tvec4 sampleBox(vec2 uv) {\n\t\tvec4 o = u_texel_size.xyxy * vec2(-u_delta, u_delta).xxyy;\n\t\tvec4 s = texture2D( u_texture, uv + o.xy ) + texture2D( u_texture, uv + o.zy) + texture2D( u_texture, uv + o.xw) + texture2D( u_texture, uv + o.zw);\n\t\treturn s * 0.25;\n\t}\n\tvoid main() {\n\t\tgl_FragColor = u_intensity * sampleBox( v_coord );\n\t}",
+b)}}},N.registerNodeType("texture/blur",u),O.prototype.applyFX=function(a,b,d,c){var f=a.width,g=a.height,e={format:a.format,type:a.type,minFilter:GL.LINEAR,magFilter:GL.LINEAR,wrap:gl.CLAMP_TO_EDGE},k=this._uniforms,h=this._textures,m=O._cut_shader;m||(m=O._cut_shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,O.cut_pixel_shader));gl.disable(gl.DEPTH_TEST);gl.disable(gl.BLEND);k.u_threshold=this.threshold;var n=h[0]=GL.Texture.getTemporary(f,g,e);a.blit(n,m.uniforms(k));var q=n,y=this.iterations;
+y=Math.clamp(y,1,16)|0;var l=k.u_texel_size,H=this.intensity;k.u_intensity=1;k.u_delta=this.scale;m=O._shader;m||(m=O._shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,O.scale_pixel_shader));for(var u=1;u>=1;1<(g|0)&&(g>>=1);if(2>f)break;n=h[u]=GL.Texture.getTemporary(f,g,e);l[0]=1/q.width;l[1]=1/q.height;q.blit(n,m.uniforms(k));q=n}c&&(l[0]=1/q.width,l[1]=1/q.height,k.u_intensity=H,k.u_delta=1,q.blit(c,m.uniforms(k)));gl.enable(gl.BLEND);gl.blendFunc(gl.ONE,gl.ONE);k.u_intensity=this.persistence;
+k.u_delta=.5;for(u-=2;0<=u;u--)n=h[u],h[u]=null,l[0]=1/q.width,l[1]=1/q.height,q.blit(n,m.uniforms(k)),GL.Texture.releaseTemporary(q),q=n;gl.disable(gl.BLEND);d&&q.blit(d);if(b){var t=this.dirt_texture,w=this.dirt_factor;k.u_intensity=H;m=t?O._dirt_final_shader:O._final_shader;m||(m=t?O._dirt_final_shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,O.final_pixel_shader,{USE_DIRT:""}):O._final_shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,O.final_pixel_shader));b.drawTo(function(){a.bind(0);
+q.bind(1);t&&(m.setUniform("u_dirt_factor",w),m.setUniform("u_dirt_texture",t.bind(2)));m.toViewport(k)})}GL.Texture.releaseTemporary(q)},O.cut_pixel_shader="precision highp float;\n\tvarying vec2 v_coord;\n\tuniform sampler2D u_texture;\n\tuniform float u_threshold;\n\tvoid main() {\n\t\tgl_FragColor = max( texture2D( u_texture, v_coord ) - vec4( u_threshold ), vec4(0.0) );\n\t}",O.scale_pixel_shader="precision highp float;\n\tvarying vec2 v_coord;\n\tuniform sampler2D u_texture;\n\tuniform vec2 u_texel_size;\n\tuniform float u_delta;\n\tuniform float u_intensity;\n\t\n\tvec4 sampleBox(vec2 uv) {\n\t\tvec4 o = u_texel_size.xyxy * vec2(-u_delta, u_delta).xxyy;\n\t\tvec4 s = texture2D( u_texture, uv + o.xy ) + texture2D( u_texture, uv + o.zy) + texture2D( u_texture, uv + o.xw) + texture2D( u_texture, uv + o.zw);\n\t\treturn s * 0.25;\n\t}\n\tvoid main() {\n\t\tgl_FragColor = u_intensity * sampleBox( v_coord );\n\t}",
O.final_pixel_shader="precision highp float;\n\tvarying vec2 v_coord;\n\tuniform sampler2D u_texture;\n\tuniform sampler2D u_glow_texture;\n\t#ifdef USE_DIRT\n\t\tuniform sampler2D u_dirt_texture;\n\t#endif\n\tuniform vec2 u_texel_size;\n\tuniform float u_delta;\n\tuniform float u_intensity;\n\tuniform float u_dirt_factor;\n\t\n\tvec4 sampleBox(vec2 uv) {\n\t\tvec4 o = u_texel_size.xyxy * vec2(-u_delta, u_delta).xxyy;\n\t\tvec4 s = texture2D( u_glow_texture, uv + o.xy ) + texture2D( u_glow_texture, uv + o.zy) + texture2D( u_glow_texture, uv + o.xw) + texture2D( u_glow_texture, uv + o.zw);\n\t\treturn s * 0.25;\n\t}\n\tvoid main() {\n\t\tvec4 glow = sampleBox( v_coord );\n\t\t#ifdef USE_DIRT\n\t\t\tglow = mix( glow, glow * texture2D( u_dirt_texture, v_coord ), u_dirt_factor );\n\t\t#endif\n\t\tgl_FragColor = texture2D( u_texture, v_coord ) + u_intensity * glow;\n\t}",
K.title="Glow",K.desc="Filters a texture giving it a glow effect",K.widgets_info={iterations:{type:"number",min:0,max:16,step:1,precision:0},threshold:{type:"number",min:0,max:10,step:.01,precision:2},precision:{widget:"combo",values:c.MODE_VALUES}},K.prototype.onGetInputs=function(){return[["enabled","boolean"],["threshold","number"],["intensity","number"],["persistence","number"],["iterations","number"],["dirt_factor","number"]]},K.prototype.onGetOutputs=function(){return[["average","Texture"]]},
K.prototype.onExecute=function(){var a=this.getInputData(0);if(a&&this.isAnyOutputConnected())if(this.properties.precision===c.PASS_THROUGH||!1===this.getInputOrProperty("enabled"))this.setOutputData(0,a);else{var b=this.fx;b.threshold=this.getInputOrProperty("threshold");b.iterations=this.getInputOrProperty("iterations");b.intensity=this.getInputOrProperty("intensity");b.persistence=this.getInputOrProperty("persistence");b.dirt_texture=this.getInputData(1);b.dirt_factor=this.getInputOrProperty("dirt_factor");
@@ -649,17 +650,17 @@ b.scale=this.properties.scale;var d=c.getTextureType(this.properties.precision,a
var e=null;this.isOutputConnected(0)&&(e=this._final_texture,e&&e.width==a.width&&e.height==a.height&&e.type==d&&e.format==a.format||(e=this._final_texture=new GL.Texture(a.width,a.height,{type:d,format:a.format,filter:gl.LINEAR})));b.applyFX(a,e,g,f);this.isOutputConnected(0)&&this.setOutputData(0,e);this.isOutputConnected(1)&&this.setOutputData(1,f);this.isOutputConnected(2)&&this.setOutputData(2,g)}},N.registerNodeType("texture/glow",K),x.title="Kuwahara Filter",x.desc="Filters a texture giving an artistic oil canvas painting",
x.max_radius=10,x._shaders=[],x.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),x.max_radius);if(0==b)this.setOutputData(0,a);else{var d=this.properties.intensity,c=N.camera_aspect;c||void 0===window.gl||(c=gl.canvas.height/gl.canvas.width);
c||(c=1);c=this.properties.preserve_aspect?c:1;x._shaders[b]||(x._shaders[b]=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,x.pixel_shader,{RADIUS:b.toFixed(0)}));var f=x._shaders[b],g=GL.Mesh.getScreenQuad();a.bind(0);this._temp_texture.drawTo(function(){f.uniforms({u_texture:0,u_intensity:d,u_resolution:[a.width,a.height],u_iResolution:[1/a.width,1/a.height]}).draw(g)});this.setOutputData(0,this._temp_texture)}}},x.pixel_shader="\nprecision highp float;\nvarying vec2 v_coord;\nuniform sampler2D u_texture;\nuniform float u_intensity;\nuniform vec2 u_resolution;\nuniform vec2 u_iResolution;\n#ifndef RADIUS\n\t#define RADIUS 7\n#endif\nvoid main() {\n\n\tconst int radius = RADIUS;\n\tvec2 fragCoord = v_coord;\n\tvec2 src_size = u_iResolution;\n\tvec2 uv = v_coord;\n\tfloat n = float((radius + 1) * (radius + 1));\n\tint i;\n\tint j;\n\tvec3 m0 = vec3(0.0); vec3 m1 = vec3(0.0); vec3 m2 = vec3(0.0); vec3 m3 = vec3(0.0);\n\tvec3 s0 = vec3(0.0); vec3 s1 = vec3(0.0); vec3 s2 = vec3(0.0); vec3 s3 = vec3(0.0);\n\tvec3 c;\n\t\n\tfor (int j = -radius; j <= 0; ++j) {\n\t\tfor (int i = -radius; i <= 0; ++i) {\n\t\t\tc = texture2D(u_texture, uv + vec2(i,j) * src_size).rgb;\n\t\t\tm0 += c;\n\t\t\ts0 += c * c;\n\t\t}\n\t}\n\t\n\tfor (int j = -radius; j <= 0; ++j) {\n\t\tfor (int i = 0; i <= radius; ++i) {\n\t\t\tc = texture2D(u_texture, uv + vec2(i,j) * src_size).rgb;\n\t\t\tm1 += c;\n\t\t\ts1 += c * c;\n\t\t}\n\t}\n\t\n\tfor (int j = 0; j <= radius; ++j) {\n\t\tfor (int i = 0; i <= radius; ++i) {\n\t\t\tc = texture2D(u_texture, uv + vec2(i,j) * src_size).rgb;\n\t\t\tm2 += c;\n\t\t\ts2 += c * c;\n\t\t}\n\t}\n\t\n\tfor (int j = 0; j <= radius; ++j) {\n\t\tfor (int i = -radius; i <= 0; ++i) {\n\t\t\tc = texture2D(u_texture, uv + vec2(i,j) * src_size).rgb;\n\t\t\tm3 += c;\n\t\t\ts3 += c * c;\n\t\t}\n\t}\n\t\n\tfloat min_sigma2 = 1e+2;\n\tm0 /= n;\n\ts0 = abs(s0 / n - m0 * m0);\n\t\n\tfloat sigma2 = s0.r + s0.g + s0.b;\n\tif (sigma2 < min_sigma2) {\n\t\tmin_sigma2 = sigma2;\n\t\tgl_FragColor = vec4(m0, 1.0);\n\t}\n\t\n\tm1 /= n;\n\ts1 = abs(s1 / n - m1 * m1);\n\t\n\tsigma2 = s1.r + s1.g + s1.b;\n\tif (sigma2 < min_sigma2) {\n\t\tmin_sigma2 = sigma2;\n\t\tgl_FragColor = vec4(m1, 1.0);\n\t}\n\t\n\tm2 /= n;\n\ts2 = abs(s2 / n - m2 * m2);\n\t\n\tsigma2 = s2.r + s2.g + s2.b;\n\tif (sigma2 < min_sigma2) {\n\t\tmin_sigma2 = sigma2;\n\t\tgl_FragColor = vec4(m2, 1.0);\n\t}\n\t\n\tm3 /= n;\n\ts3 = abs(s3 / n - m3 * m3);\n\t\n\tsigma2 = s3.r + s3.g + s3.b;\n\tif (sigma2 < min_sigma2) {\n\t\tmin_sigma2 = sigma2;\n\t\tgl_FragColor = vec4(m3, 1.0);\n\t}\n}\n",
-N.registerNodeType("texture/kuwahara",x),C.title="XDoG Filter",C.desc="Filters a texture giving an artistic ink style",C.max_radius=10,C._shaders=[],C.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}));C._xdog_shader||(C._xdog_shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,C.xdog_pixel_shader));
-var d=C._xdog_shader,c=GL.Mesh.getScreenQuad(),f=this.properties.sigma,g=this.properties.k,e=this.properties.p,k=this.properties.epsilon,m=this.properties.phi;a.bind(0);this._temp_texture.drawTo(function(){d.uniforms({src:0,sigma:f,k:g,p:e,epsilon:k,phi:m,cvsWidth:a.width,cvsHeight:a.height}).draw(c)});this.setOutputData(0,this._temp_texture)}},C.xdog_pixel_shader="\nprecision highp float;\nuniform sampler2D src;\n\nuniform float cvsHeight;\nuniform float cvsWidth;\n\nuniform float sigma;\nuniform float k;\nuniform float p;\nuniform float epsilon;\nuniform float phi;\nvarying vec2 v_coord;\n\nfloat cosh(float val)\n{\n\tfloat tmp = exp(val);\n\tfloat cosH = (tmp + 1.0 / tmp) / 2.0;\n\treturn cosH;\n}\n\nfloat tanh(float val)\n{\n\tfloat tmp = exp(val);\n\tfloat tanH = (tmp - 1.0 / tmp) / (tmp + 1.0 / tmp);\n\treturn tanH;\n}\n\nfloat sinh(float val)\n{\n\tfloat tmp = exp(val);\n\tfloat sinH = (tmp - 1.0 / tmp) / 2.0;\n\treturn sinH;\n}\n\nvoid main(void){\n\tvec3 destColor = vec3(0.0);\n\tfloat tFrag = 1.0 / cvsHeight;\n\tfloat sFrag = 1.0 / cvsWidth;\n\tvec2 Frag = vec2(sFrag,tFrag);\n\tvec2 uv = gl_FragCoord.st;\n\tfloat twoSigmaESquared = 2.0 * sigma * sigma;\n\tfloat twoSigmaRSquared = twoSigmaESquared * k * k;\n\tint halfWidth = int(ceil( 1.0 * sigma * k ));\n\n\tconst int MAX_NUM_ITERATION = 99999;\n\tvec2 sum = vec2(0.0);\n\tvec2 norm = vec2(0.0);\n\n\tfor(int cnt=0;cnt (2*halfWidth+1)*(2*halfWidth+1)){break;}\n\t\tint i = int(cnt / (2*halfWidth+1)) - halfWidth;\n\t\tint j = cnt - halfWidth - int(cnt / (2*halfWidth+1)) * (2*halfWidth+1);\n\n\t\tfloat d = length(vec2(i,j));\n\t\tvec2 kernel = vec2( exp( -d * d / twoSigmaESquared ), \n\t\t\t\t\t\t\texp( -d * d / twoSigmaRSquared ));\n\n\t\tvec2 L = texture2D(src, (uv + vec2(i,j)) * Frag).xx;\n\n\t\tnorm += kernel;\n\t\tsum += kernel * L;\n\t}\n\n\tsum /= norm;\n\n\tfloat H = 100.0 * ((1.0 + p) * sum.x - p * sum.y);\n\tfloat edge = ( H > epsilon )? 1.0 : 1.0 + tanh( phi * (H - epsilon));\n\tdestColor = vec3(edge);\n\tgl_FragColor = vec4(destColor, 1.0);\n}",
-N.registerNodeType("texture/xDoG",C),w.title="Webcam",w.desc="Webcam texture",w.is_webcam_open=!1,w.prototype.openStream=function(){if(navigator.getUserMedia){this._waiting_confirmation=!0;navigator.mediaDevices.getUserMedia({audio:!1,video:{facingMode:this.properties.facingMode}}).then(this.streamReady.bind(this)).catch(function(b){w.is_webcam_open=!1;console.log("Webcam rejected",b);a._webcam_stream=!1;a.boxcolor="red";a.trigger("stream_error")});var a=this}},w.prototype.closeStream=function(){if(this._webcam_stream){var a=
+N.registerNodeType("texture/kuwahara",x),A.title="XDoG Filter",A.desc="Filters a texture giving an artistic ink style",A.max_radius=10,A._shaders=[],A.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}));A._xdog_shader||(A._xdog_shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,A.xdog_pixel_shader));
+var d=A._xdog_shader,c=GL.Mesh.getScreenQuad(),f=this.properties.sigma,g=this.properties.k,e=this.properties.p,k=this.properties.epsilon,h=this.properties.phi;a.bind(0);this._temp_texture.drawTo(function(){d.uniforms({src:0,sigma:f,k:g,p:e,epsilon:k,phi:h,cvsWidth:a.width,cvsHeight:a.height}).draw(c)});this.setOutputData(0,this._temp_texture)}},A.xdog_pixel_shader="\nprecision highp float;\nuniform sampler2D src;\n\nuniform float cvsHeight;\nuniform float cvsWidth;\n\nuniform float sigma;\nuniform float k;\nuniform float p;\nuniform float epsilon;\nuniform float phi;\nvarying vec2 v_coord;\n\nfloat cosh(float val)\n{\n\tfloat tmp = exp(val);\n\tfloat cosH = (tmp + 1.0 / tmp) / 2.0;\n\treturn cosH;\n}\n\nfloat tanh(float val)\n{\n\tfloat tmp = exp(val);\n\tfloat tanH = (tmp - 1.0 / tmp) / (tmp + 1.0 / tmp);\n\treturn tanH;\n}\n\nfloat sinh(float val)\n{\n\tfloat tmp = exp(val);\n\tfloat sinH = (tmp - 1.0 / tmp) / 2.0;\n\treturn sinH;\n}\n\nvoid main(void){\n\tvec3 destColor = vec3(0.0);\n\tfloat tFrag = 1.0 / cvsHeight;\n\tfloat sFrag = 1.0 / cvsWidth;\n\tvec2 Frag = vec2(sFrag,tFrag);\n\tvec2 uv = gl_FragCoord.st;\n\tfloat twoSigmaESquared = 2.0 * sigma * sigma;\n\tfloat twoSigmaRSquared = twoSigmaESquared * k * k;\n\tint halfWidth = int(ceil( 1.0 * sigma * k ));\n\n\tconst int MAX_NUM_ITERATION = 99999;\n\tvec2 sum = vec2(0.0);\n\tvec2 norm = vec2(0.0);\n\n\tfor(int cnt=0;cnt (2*halfWidth+1)*(2*halfWidth+1)){break;}\n\t\tint i = int(cnt / (2*halfWidth+1)) - halfWidth;\n\t\tint j = cnt - halfWidth - int(cnt / (2*halfWidth+1)) * (2*halfWidth+1);\n\n\t\tfloat d = length(vec2(i,j));\n\t\tvec2 kernel = vec2( exp( -d * d / twoSigmaESquared ), \n\t\t\t\t\t\t\texp( -d * d / twoSigmaRSquared ));\n\n\t\tvec2 L = texture2D(src, (uv + vec2(i,j)) * Frag).xx;\n\n\t\tnorm += kernel;\n\t\tsum += kernel * L;\n\t}\n\n\tsum /= norm;\n\n\tfloat H = 100.0 * ((1.0 + p) * sum.x - p * sum.y);\n\tfloat edge = ( H > epsilon )? 1.0 : 1.0 + tanh( phi * (H - epsilon));\n\tdestColor = vec3(edge);\n\tgl_FragColor = vec4(destColor, 1.0);\n}",
+N.registerNodeType("texture/xDoG",A),w.title="Webcam",w.desc="Webcam texture",w.is_webcam_open=!1,w.prototype.openStream=function(){if(navigator.getUserMedia){this._waiting_confirmation=!0;navigator.mediaDevices.getUserMedia({audio:!1,video:{facingMode:this.properties.facingMode}}).then(this.streamReady.bind(this)).catch(function(b){w.is_webcam_open=!1;console.log("Webcam rejected",b);a._webcam_stream=!1;a.boxcolor="red";a.trigger("stream_error")});var a=this}},w.prototype.closeStream=function(){if(this._webcam_stream){var a=
this._webcam_stream.getTracks();if(a.length)for(var b=0;b=this.size[1]||!this._video||(a.save(),a.webgl?this._video_texture&&a.drawImage(this._video_texture,0,0,this.size[0],this.size[1]):a.drawImage(this._video,
0,0,this.size[0],this.size[1]),a.restore())},w.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,d=this._video_texture;d&&d.width==a&&d.height==b||(this._video_texture=new GL.Texture(a,b,{format:gl.RGB,filter:gl.LINEAR}));this._video_texture.uploadImage(this._video);this._video_texture.version=++this.version;this.properties.texture_name&&(c.getTexturesContainer()[this.properties.texture_name]=
this._video_texture);this.setOutputData(0,this._video_texture);for(a=1;aTex",G.desc="Generates or applies a curve to a texture",G.widgets_info={precision:{widget:"combo",values:c.MODE_VALUES}},G.prototype.onExecute=function(){if(this.isOutputConnected(0)){var a=this.getInputData(0);if(a){var b=this.properties.channels,d=this.properties.width,f=this.properties.height;d&&f||(d=Math.floor(a.length/b),f=1);var g=gl.RGBA;3==b?g=gl.RGB:1==b&&(g=gl.LUMINANCE);b=this._temp_texture;var e=c.getTextureType(this.properties.precision);
-b&&b.width==d&&b.height==f&&b.type==e||(b=this._temp_texture=new GL.Texture(d,f,{type:e,format:g,filter:gl.LINEAR}));b.uploadData(a);this.setOutputData(0,b)}}},N.registerNodeType("texture/fromdata",G),y.title="Curve",y.desc="Generates or applies a curve to a texture",y.widgets_info={precision:{widget:"combo",values:c.MODE_VALUES}},y.prototype.onExecute=function(){if(this.isOutputConnected(0)){var a=this.getInputData(0),b=this._temp_texture;if(a){var d=c.getTextureType(this.properties.precision,a);
+N.registerNodeType("texture/lensfx",L),H.title="Data->Tex",H.desc="Generates or applies a curve to a texture",H.widgets_info={precision:{widget:"combo",values:c.MODE_VALUES}},H.prototype.onExecute=function(){if(this.isOutputConnected(0)){var a=this.getInputData(0);if(a){var b=this.properties.channels,d=this.properties.width,f=this.properties.height;d&&f||(d=Math.floor(a.length/b),f=1);var g=gl.RGBA;3==b?g=gl.RGB:1==b&&(g=gl.LUMINANCE);b=this._temp_texture;var e=c.getTextureType(this.properties.precision);
+b&&b.width==d&&b.height==f&&b.type==e||(b=this._temp_texture=new GL.Texture(d,f,{type:e,format:g,filter:gl.LINEAR}));b.uploadData(a);this.setOutputData(0,b)}}},N.registerNodeType("texture/fromdata",H),y.title="Curve",y.desc="Generates or applies a curve to a texture",y.widgets_info={precision:{widget:"combo",values:c.MODE_VALUES}},y.prototype.onExecute=function(){if(this.isOutputConnected(0)){var a=this.getInputData(0),b=this._temp_texture;if(a){var d=c.getTextureType(this.properties.precision,a);
b&&b.type==d&&b.width==a.width&&b.height==a.height&&b.format==a.format||(b=this._temp_texture=new GL.Texture(a.width,a.height,{type:d,format:a.format,filter:gl.LINEAR}));var f=y._shader;f||(f=y._shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,y.pixel_shader));!this._must_update&&this._curve_texture||this.updateCurve();var g=this._uniforms,e=this._curve_texture;b.drawTo(function(){gl.disable(gl.DEPTH_TEST);a.bind(0);e.bind(1);f.uniforms(g).draw(GL.Mesh.getScreenQuad())});this.setOutputData(0,b)}else!this._must_update&&
this._curve_texture||this.updateCurve(),this.setOutputData(0,this._curve_texture)}},y.prototype.sampleCurve=function(a,b){if(b=b||this._points.RGB){for(var d=0;dMath.abs(b))return c[1];a=(a-c[0])/b;return c[1]*(1-a)+f[1]*a}}return 0}},y.prototype.updateCurve=function(){for(var a=this._values,b=a.length/4,d=this.properties.split_channels,c=0;c= res)\n\t\t\t\t\tbreak;\n\t\t\t\tiCount++;\n\t\t\t}\n\t\t\tfloat nf = n/normK;\n\t\t\treturn nf*nf*nf*nf;\n\t\t}\n\t\tvoid main() {\n\t\t\tvec2 uv = v_coord * u_scale * u_viewport + u_offset * u_scale;\n\t\t\tvec4 color = vec4( pNoise( uv, u_octaves ) * u_amplitude );\n\t\t\tgl_FragColor = color;\n\t\t}",
+this.properties.width|0,b=this.properties.height|0;0==a&&(a=gl.viewport_data[2]);0==b&&(b=gl.viewport_data[3]);var d=c.getTextureType(this.properties.precision),f=this._texture;f&&f.width==a&&f.height==b&&f.type==d||(f=this._texture=new GL.Texture(a,b,{type:d,format:gl.RGB,filter:gl.LINEAR}));var g=this.getInputOrProperty("persistence"),e=this.getInputOrProperty("octaves"),k=this.getInputOrProperty("offset"),h=this.getInputOrProperty("scale"),m=this.getInputOrProperty("amplitude"),n=this.getInputOrProperty("seed");
+d=""+a+b+d+g+e+h+n+k[0]+k[1]+m;if(d!=this._key){this._key=d;var q=this._uniforms;q.u_persistence=g;q.u_octaves=e;q.u_offset.set(k);q.u_scale=h;q.u_amplitude=m;q.u_seed=128*n;q.u_viewport[0]=a;q.u_viewport[1]=b;var y=S._shader;y||(y=S._shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,S.pixel_shader));gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);f.drawTo(function(){y.uniforms(q).draw(GL.Mesh.getScreenQuad())})}this.setOutputData(0,f)}},S.pixel_shader="precision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform vec2 u_offset;\n\t\tuniform float u_scale;\n\t\tuniform float u_persistence;\n\t\tuniform int u_octaves;\n\t\tuniform float u_amplitude;\n\t\tuniform vec2 u_viewport;\n\t\tuniform float u_seed;\n\t\t#define M_PI 3.14159265358979323846\n\t\t\n\t\tfloat rand(vec2 c){\treturn fract(sin(dot(c.xy ,vec2( 12.9898 + u_seed,78.233 + u_seed))) * 43758.5453); }\n\t\t\n\t\tfloat noise(vec2 p, float freq ){\n\t\t\tfloat unit = u_viewport.x/freq;\n\t\t\tvec2 ij = floor(p/unit);\n\t\t\tvec2 xy = mod(p,unit)/unit;\n\t\t\t//xy = 3.*xy*xy-2.*xy*xy*xy;\n\t\t\txy = .5*(1.-cos(M_PI*xy));\n\t\t\tfloat a = rand((ij+vec2(0.,0.)));\n\t\t\tfloat b = rand((ij+vec2(1.,0.)));\n\t\t\tfloat c = rand((ij+vec2(0.,1.)));\n\t\t\tfloat d = rand((ij+vec2(1.,1.)));\n\t\t\tfloat x1 = mix(a, b, xy.x);\n\t\t\tfloat x2 = mix(c, d, xy.x);\n\t\t\treturn mix(x1, x2, xy.y);\n\t\t}\n\t\t\n\t\tfloat pNoise(vec2 p, int res){\n\t\t\tfloat persistance = u_persistence;\n\t\t\tfloat n = 0.;\n\t\t\tfloat normK = 0.;\n\t\t\tfloat f = 4.;\n\t\t\tfloat amp = 1.0;\n\t\t\tint iCount = 0;\n\t\t\tfor (int i = 0; i<50; i++){\n\t\t\t\tn+=amp*noise(p, f);\n\t\t\t\tf*=2.;\n\t\t\t\tnormK+=amp;\n\t\t\t\tamp*=persistance;\n\t\t\t\tif (iCount >= res)\n\t\t\t\t\tbreak;\n\t\t\t\tiCount++;\n\t\t\t}\n\t\t\tfloat nf = n/normK;\n\t\t\treturn nf*nf*nf*nf;\n\t\t}\n\t\tvoid main() {\n\t\t\tvec2 uv = v_coord * u_scale * u_viewport + u_offset * u_scale;\n\t\t\tvec4 color = vec4( pNoise( uv, u_octaves ) * u_amplitude );\n\t\t\tgl_FragColor = color;\n\t\t}",
N.registerNodeType("texture/perlin",S),R.title="Canvas2D",R.desc="Executes Canvas2D code inside a texture or the viewport.",R.help="Set width and height to 0 to match viewport size.",R.default_code="//vars: canvas,ctx,time\nctx.fillStyle='red';\nctx.fillRect(0,0,50,50);\n",R.widgets_info={precision:{widget:"combo",values:c.MODE_VALUES},code:{type:"code"},width:{type:"number",precision:0,step:1},height:{type:"number",precision:0,step:1}},R.prototype.onPropertyChanged=function(a,b){"code"==a&&this.compileCode(b)},
R.prototype.compileCode=function(a){this._func=null;if(N.allow_scripts)try{this._func=new Function("canvas","ctx","time","script","v",a),this.boxcolor="#00FF00"}catch(W){this.boxcolor="#FF0000",console.error("Error parsing script"),console.error(W)}},R.prototype.onExecute=function(){var a=this._func;a&&this.isOutputConnected(0)&&this.executeDraw(a)},R.prototype.executeDraw=function(a){var b=this.properties.width||gl.canvas.width,d=this.properties.height||gl.canvas.height,f=this._temp_texture,g=c.getTextureType(this.properties.precision);
-f&&f.width==b&&f.height==d&&f.type==g||(f=this._temp_texture=new GL.Texture(b,d,{format:gl.RGBA,filter:gl.LINEAR,type:g}));var e=this.getInputData(0),k=this.properties,m=this,h=this.graph.getTime(),q=gl,n=gl.canvas;if(this.properties.use_html_canvas||!B.enableWebGLCanvas)this._canvas?(n=this._canvas,q=this._ctx):(n=this._canvas=createCanvas(b.height),q=this._ctx=n.getContext("2d")),n.width=b,n.height=d;if(q==gl)f.drawTo(function(){gl.start2D();k.clear&&(gl.clearColor(0,0,0,0),gl.clear(gl.COLOR_BUFFER_BIT));
-try{a.draw?a.draw.call(m,n,q,h,a,e):a.call(m,n,q,h,a,e),m.boxcolor="#00FF00"}catch(V){m.boxcolor="#FF0000",console.error("Error executing script"),console.error(V)}gl.finish2D()});else{k.clear&&q.clearRect(0,0,n.width,n.height);try{a.draw?a.draw.call(this,n,q,h,a,e):a.call(this,n,q,h,a,e),this.boxcolor="#00FF00"}catch(V){this.boxcolor="#FF0000",console.error("Error executing script"),console.error(V)}f.uploadImage(n)}this.setOutputData(0,f)},N.registerNodeType("texture/canvas2D",R),T.title="Matte",
+f&&f.width==b&&f.height==d&&f.type==g||(f=this._temp_texture=new GL.Texture(b,d,{format:gl.RGBA,filter:gl.LINEAR,type:g}));var e=this.getInputData(0),k=this.properties,h=this,m=this.graph.getTime(),q=gl,n=gl.canvas;if(this.properties.use_html_canvas||!B.enableWebGLCanvas)this._canvas?(n=this._canvas,q=this._ctx):(n=this._canvas=createCanvas(b.height),q=this._ctx=n.getContext("2d")),n.width=b,n.height=d;if(q==gl)f.drawTo(function(){gl.start2D();k.clear&&(gl.clearColor(0,0,0,0),gl.clear(gl.COLOR_BUFFER_BIT));
+try{a.draw?a.draw.call(h,n,q,m,a,e):a.call(h,n,q,m,a,e),h.boxcolor="#00FF00"}catch(V){h.boxcolor="#FF0000",console.error("Error executing script"),console.error(V)}gl.finish2D()});else{k.clear&&q.clearRect(0,0,n.width,n.height);try{a.draw?a.draw.call(this,n,q,m,a,e):a.call(this,n,q,m,a,e),this.boxcolor="#00FF00"}catch(V){this.boxcolor="#FF0000",console.error("Error executing script"),console.error(V)}f.uploadImage(n)}this.setOutputData(0,f)},N.registerNodeType("texture/canvas2D",R),T.title="Matte",
T.desc="Extracts background",T.widgets_info={key_color:{widget:"color"},precision:{widget:"combo",values:c.MODE_VALUES}},T.prototype.onExecute=function(){if(this.isOutputConnected(0)){var a=this.getInputData(0);if(this.properties.precision===c.PASS_THROUGH)this.setOutputData(0,a);else if(a){this._tex=c.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,d=Mesh.getScreenQuad(),f=T._shader;f||(f=T._shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,T.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);f.uniforms(b).draw(d)});this.setOutputData(0,this._tex)}}},T.pixel_shader="precision highp float;\n\t\tvarying vec2 v_coord;\n\t\tuniform sampler2D u_texture;\n\t\tuniform vec3 u_key_color;\n\t\tuniform float u_threshold;\n\t\tuniform float u_slope;\n\t\t\n\t\tvoid main() {\n\t\t\tvec3 color = texture2D( u_texture, v_coord ).xyz;\n\t\t\tfloat diff = length( normalize(color) - normalize(u_key_color) );\n\t\t\tfloat edge = u_threshold * (1.0 - u_slope);\n\t\t\tfloat alpha = smoothstep( edge, u_threshold, diff);\n\t\t\tgl_FragColor = vec4( color, alpha );\n\t\t}",
N.registerNodeType("texture/matte",T),U.title="CubemapToTexture2D",U.desc="Transforms a CUBEMAP texture into a TEXTURE2D in Polar Representation",U.prototype.onExecute=function(){if(this.isOutputConnected(0)){var a=this.getInputData(0);if(a&&a.texture_type==GL.TEXTURE_CUBE_MAP){!this._last_tex||this._last_tex.height==a.height&&this._last_tex.type==a.type||(this._last_tex=null);var b=this.getInputOrProperty("yaw");this._last_tex=GL.Texture.cubemapToTexture2D(a,a.height,this._last_tex,!0,b);this.setOutputData(0,
this._last_tex)}}},N.registerNodeType("texture/cubemapToTexture2D",U))})(this);
(function(B){function c(){x.length=0;for(var a in O){var b=O[a],d=b.indexOf(" "),c=b.substr(0,d),f=b.indexOf("(",d);d=b.substr(d,f-d).trim();b=b.substr(f+1,b.length-f-2).split(",");for(var g in b)f=b[g].split(" ").filter(function(a){return a}),b[g]={type:f[0].trim(),name:f[1].trim()},"="==f[2]&&(b[g].value=f[3].trim());K[a]={return_type:c,func:d,params:b};x.push(d)}}function l(a,b){b.color="#345";b.filter="shader";b.prototype.clearDestination=function(){this.shader_destination={}};b.prototype.propagateDestination=
function(a){this.shader_destination[a]=!0;if(this.inputs)for(var b=0;bd+f.NODE_TITLE_HEIGHT&&a.drawImage(b,10,g,this.size[0]-20,this.size[1]-d-f.NODE_TITLE_HEIGHT);var g=this.size[1]-f.NODE_TITLE_HEIGHT+.5;c=f.isInsideRectangle(c[0],c[1],this.pos[0],this.pos[1]+g,this.size[0],f.NODE_TITLE_HEIGHT);a.fillStyle=c?"#555":"#222";a.beginPath();this._shape==f.BOX_SHAPE?a.rect(0,g,this.size[0]+1,f.NODE_TITLE_HEIGHT):a.roundRect(0,g,this.size[0]+1,f.NODE_TITLE_HEIGHT,0,8);a.fill();a.textAlign="center";a.font="24px Arial";a.fillStyle=
-c?"#DDD":"#999";a.fillText("+",.5*this.size[0],g+24)}};E.prototype.onMouseDown=function(a,b,d){b[1]>this.size[1]-f.NODE_TITLE_HEIGHT+.5&&d.showSubgraphPropertiesDialog(this)};E.prototype.onDrawSubgraphBackground=function(a){};E.prototype.getExtraMenuOptions=function(a){var b=this;return[{content:"Print Code",callback:function(){var a=b._context.computeShaderCode();console.log(a.vs_code,a.fs_code)}}]};f.registerNodeType("texture/shaderGraph",E);A.title="Uniform";A.desc="Input data for the shader";
-A.prototype.getTitle=function(){return this.properties.name&&this.flags.collapsed?this.properties.type+" "+this.properties.name:"Uniform"};A.prototype.onPropertyChanged=function(a,b){this.outputs[0].name=this.properties.type+" "+this.properties.name};A.prototype.onGetCode=function(a){if(this.shader_destination){var b=this.properties.type;if(!b){if(!a.onGetPropertyInfo)return;b=a.onGetPropertyInfo(this.property.name);if(!b)return;b=b.type}"number"==b?b="float":"texture"==b&&(b="sampler2D");-1!=m.GLSL_types.indexOf(b)&&
-(a.addUniform("u_"+this.properties.name,b),this.setOutputData(0,b))}};A.prototype.getOutputVarName=function(a){return"u_"+this.properties.name};l("input/uniform",A);I.title="Attribute";I.desc="Input data from mesh attribute";I.prototype.getTitle=function(){return"att. "+this.properties.name};I.prototype.onGetCode=function(a){if(this.shader_destination){var b=this.properties.type;b&&-1!=m.GLSL_types.indexOf(b)&&("number"==b&&(b="float"),"coord"!=this.properties.name&&a.addCode("varying"," varying "+
+c?"#DDD":"#999";a.fillText("+",.5*this.size[0],g+24)}};F.prototype.onMouseDown=function(a,b,d){b[1]>this.size[1]-f.NODE_TITLE_HEIGHT+.5&&d.showSubgraphPropertiesDialog(this)};F.prototype.onDrawSubgraphBackground=function(a){};F.prototype.getExtraMenuOptions=function(a){var b=this;return[{content:"Print Code",callback:function(){var a=b._context.computeShaderCode();console.log(a.vs_code,a.fs_code)}}]};f.registerNodeType("texture/shaderGraph",F);C.title="Uniform";C.desc="Input data for the shader";
+C.prototype.getTitle=function(){return this.properties.name&&this.flags.collapsed?this.properties.type+" "+this.properties.name:"Uniform"};C.prototype.onPropertyChanged=function(a,b){this.outputs[0].name=this.properties.type+" "+this.properties.name};C.prototype.onGetCode=function(a){if(this.shader_destination){var b=this.properties.type;if(!b){if(!a.onGetPropertyInfo)return;b=a.onGetPropertyInfo(this.property.name);if(!b)return;b=b.type}"number"==b?b="float":"texture"==b&&(b="sampler2D");-1!=m.GLSL_types.indexOf(b)&&
+(a.addUniform("u_"+this.properties.name,b),this.setOutputData(0,b))}};C.prototype.getOutputVarName=function(a){return"u_"+this.properties.name};l("input/uniform",C);I.title="Attribute";I.desc="Input data from mesh attribute";I.prototype.getTitle=function(){return"att. "+this.properties.name};I.prototype.onGetCode=function(a){if(this.shader_destination){var b=this.properties.type;b&&-1!=m.GLSL_types.indexOf(b)&&("number"==b&&(b="float"),"coord"!=this.properties.name&&a.addCode("varying"," varying "+
b+" v_"+this.properties.name+";"),this.setOutputData(0,b))}};I.prototype.getOutputVarName=function(a){return"v_"+this.properties.name};l("input/attribute",I);J.title="Sampler2D";J.desc="Reads a pixel from a texture";J.prototype.onGetCode=function(a){if(this.shader_destination){var b=t(this,0),d=r(this),c="vec4 "+d+" = vec4(0.0);\n";if(b){var f=t(this,1)||a.buffer_names.uvs;c+=d+" = texture2D("+b+","+f+");\n"}v(this,0)&&(c+="vec4 "+v(this,0)+" = "+d+";\n");v(this,1)&&(c+="vec3 "+v(this,1)+" = "+d+
-".xyz;\n");a.addCode("code",c,this.shader_destination);this.setOutputData(0,"vec4");this.setOutputData(1,"vec3")}};l("texture/sampler2D",J);F.title="const";F.prototype.getTitle=function(){return this.flags.collapsed?C(this.properties.value,this.properties.type,2):"Const"};F.prototype.onPropertyChanged=function(a,b){"type"==a&&(this.outputs[0].type!=b&&(this.disconnectOutput(0),this.outputs[0].type=b),this.widgets.length=1,this.updateWidgets());"value"==a&&(b.length?(this.widgets[1].value=b[1],2d;++d)b.push({name:t(this,d),type:this.getInputData(d)||"float"});var c=v(this,0);if(c){var f=b[0].type,g=this.properties.operation,
e=[];for(d=0;2>d;++d){var k=b[d].name;null==k&&(k=null!=p.value?p.value:"(1.0)",b[d].type="float");b[d].type!=f&&("float"!=b[d].type||"*"!=g&&"/"!=g)&&(k=L(k,b[d].type,f));e.push(k)}a.addCode("code",f+" "+c+" = "+e[0]+g+e[1]+";",this.shader_destination);this.setOutputData(0,f)}}};l("math/operation",M);k.title="Func";k.prototype.onPropertyChanged=function(a,b){this.graph&&this.graph._version++;if("func"==a&&(a=K[b])){for(b=a.params.length;bd;++d)b.push({name:t(this,d),type:this.getInputData(d)||"float"});var c=v(this,0);if(c){var f=K[this.properties.func];if(f){var g=b[0].type,e=f.return_type;"T"==e&&(e=g);var k=[];for(d=
-0;d=c;){e=.5*(k+c)|0;b=a[e];if(b==d)break;if(c==k-1)return c;ba&&(a=1);this.points&&this.points.length==3*a||(this.points=new Float32Array(3*a));this.properties.generate_normals?this.normals&&this.normals.length==this.points.length||(this.normals=new Float32Array(this.points.length)):this.normals=null;var d=this._last_radius||this.properties.radius,c=this.properties.mode,f=this.getInputData(0);this._old_obj_version=f?f._version:null;this.points=l.generatePoints(d,a,c,this.points,this.normals,
-this.properties.regular,f);this.version++};l.generatePoints=function(a,d,c,f,e,k,h){var b=3*d;f&&f.length==b||(f=new Float32Array(b));var g=new Float32Array(3),n=new Float32Array([0,1,0]);if(k)if(c==l.RECTANGLE){b=Math.floor(Math.sqrt(d));for(d=0;dk||yh&&hq))break}this.geometry.indices=this.indices=new Uint32Array(n)}this.indices&&this.indices.length?(this.geometry.indices=this.indices,this.setOutputData(0,this.geometry)):this.setOutputData(0,null)}};z.registerNodeType("geometry/connectPoints",I);"undefined"!=typeof GL&&(J.title="to geometry",J.desc="converts a mesh to geometry",J.prototype.onExecute=function(){var a=this.getInputData(0);if(a){if(a!=this.last_mesh){this.last_mesh=a;for(i in a.vertexBuffers)this.geometry[i]=
-a.vertexBuffers[i].data;a.indexBuffers.triangles&&(this.geometry.indices=a.indexBuffers.triangles.data);this.geometry._id=c();this.geometry._version=0}this.setOutputData(0,this.geometry);this.geometry&&this.setOutputData(1,this.geometry.vertices)}},z.registerNodeType("geometry/toGeometry",J),F.title="Geo to Mesh",F.prototype.updateMesh=function(a){this.mesh||(this.mesh=new GL.Mesh);for(var b in a)if("_"!=b[0]){var c=a[b],f=GL.Mesh.common_buffers[b];if(f||"indices"==b){f=f?f.spacing:3;var e=this.mesh.vertexBuffers[b];
+0;fe||yk&&kh))break}this.geometry.indices=this.indices=new Uint32Array(q)}this.indices&&this.indices.length?(this.geometry.indices=this.indices,this.setOutputData(0,this.geometry)):this.setOutputData(0,null)}};z.registerNodeType("geometry/connectPoints",I);"undefined"!=typeof GL&&(J.title="to geometry",J.desc="converts a mesh to geometry",J.prototype.onExecute=function(){var a=this.getInputData(0);if(a){if(a!=this.last_mesh){this.last_mesh=a;for(i in a.vertexBuffers)this.geometry[i]=
+a.vertexBuffers[i].data;a.indexBuffers.triangles&&(this.geometry.indices=a.indexBuffers.triangles.data);this.geometry._id=c();this.geometry._version=0}this.setOutputData(0,this.geometry);this.geometry&&this.setOutputData(1,this.geometry.vertices)}},z.registerNodeType("geometry/toGeometry",J),G.title="Geo to Mesh",G.prototype.updateMesh=function(a){this.mesh||(this.mesh=new GL.Mesh);for(var b in a)if("_"!=b[0]){var c=a[b],f=GL.Mesh.common_buffers[b];if(f||"indices"==b){f=f?f.spacing:3;var e=this.mesh.vertexBuffers[b];
e&&e.data.length==c.length?(e.data.set(c),e.upload(GL.DYNAMIC_DRAW)):e=new GL.Buffer("indices"==b?GL.ELEMENT_ARRAY_BUFFER:GL.ARRAY_BUFFER,c,f,GL.DYNAMIC_DRAW);this.mesh.addBuffer(b,e)}}if(this.mesh.vertexBuffers.normals&&this.mesh.vertexBuffers.normals.data.length!=this.mesh.vertexBuffers.vertices.data.length){c=new Float32Array([0,1,0]);f=new Float32Array(this.mesh.vertexBuffers.vertices.data.length);for(b=0;b 0.45 )\n\r\n\t\t\t\t\t\tdiscard;\n\r\n\t\t\t\t#endif\n\r\n\t\t\t#endif\n\r\n\t\t\t#ifdef USE_COLOR\n\r\n\t\t\t\tcolor *= v_color;\n\r\n\t\t\t#endif\n\r\n\t\t\tgl_FragColor = color;\n\r\n\t\t}\r\n\t")})(this);
+z.registerNodeType("geometry/render_points",E),E.vertex_shader_code="\r\n\t\tprecision mediump float;\n\r\n\t\tattribute vec3 a_vertex;\n\r\n\t\tvarying vec3 v_vertex;\n\r\n\t\tattribute vec3 a_normal;\n\r\n\t\tvarying vec3 v_normal;\n\r\n\t\t#ifdef USE_COLOR\n\r\n\t\t\tattribute vec4 a_color;\n\r\n\t\t\tvarying vec4 v_color;\n\r\n\t\t#endif\n\r\n\t\tattribute vec2 a_coord;\n\r\n\t\tvarying vec2 v_coord;\n\r\n\t\t#ifdef USE_SIZE\n\r\n\t\t\tattribute float a_extra;\n\r\n\t\t#endif\n\r\n\t\t#ifdef USE_INSTANCING\n\r\n\t\t\tattribute mat4 u_model;\n\r\n\t\t#else\n\r\n\t\t\tuniform mat4 u_model;\n\r\n\t\t#endif\n\r\n\t\tuniform mat4 u_viewprojection;\n\r\n\t\tuniform float u_point_size;\n\r\n\t\tuniform float u_perspective;\n\r\n\t\tuniform float u_point_perspective;\n\r\n\t\tfloat computePointSize(float radius, float w)\n\r\n\t\t{\n\r\n\t\t\tif(radius < 0.0)\n\r\n\t\t\t\treturn -radius;\n\r\n\t\t\treturn u_perspective * radius / w;\n\r\n\t\t}\n\r\n\t\tvoid main() {\n\r\n\t\t\tv_coord = a_coord;\n\r\n\t\t\t#ifdef USE_COLOR\n\r\n\t\t\t\tv_color = a_color;\n\r\n\t\t\t#endif\n\r\n\t\t\tv_vertex = ( u_model * vec4( a_vertex, 1.0 )).xyz;\n\r\n\t\t\tv_normal = ( u_model * vec4( a_normal, 0.0 )).xyz;\n\r\n\t\t\tgl_Position = u_viewprojection * vec4(v_vertex,1.0);\n\r\n\t\t\tgl_PointSize = u_point_size;\n\r\n\t\t\t#ifdef USE_SIZE\n\r\n\t\t\t\tgl_PointSize = a_extra;\n\r\n\t\t\t#endif\n\r\n\t\t\tif(u_point_perspective != 0.0)\n\r\n\t\t\t\tgl_PointSize = computePointSize( gl_PointSize, gl_Position.w );\n\r\n\t\t}\r\n\t",
+E.fragment_shader_code="\r\n\t\tprecision mediump float;\n\r\n\t\tuniform vec4 u_color;\n\r\n\t\t#ifdef USE_COLOR\n\r\n\t\t\tvarying vec4 v_color;\n\r\n\t\t#endif\n\r\n\t\tvarying vec2 v_coord;\n\r\n\t\tuniform sampler2D u_texture;\n\r\n\t\tvoid main() {\n\r\n\t\t\tvec4 color = u_color;\n\r\n\t\t\t#ifdef USE_TEXTURED_POINTS\n\r\n\t\t\t\tcolor *= texture2D(u_texture, gl_PointCoord.xy);\n\r\n\t\t\t#else\n\r\n\t\t\t\t#ifdef USE_TEXTURE\n\r\n\t\t\t\t color *= texture2D(u_texture, v_coord);\n\r\n\t\t\t\t if(color.a < 0.1)\n\r\n\t\t\t\t\tdiscard;\n\r\n\t\t\t\t#endif\n\r\n\t\t\t\t#ifdef USE_POINTS\n\r\n\t\t\t\t\tfloat dist = length( gl_PointCoord.xy - vec2(0.5) );\n\r\n\t\t\t\t\tif( dist > 0.45 )\n\r\n\t\t\t\t\t\tdiscard;\n\r\n\t\t\t\t#endif\n\r\n\t\t\t#endif\n\r\n\t\t\t#ifdef USE_COLOR\n\r\n\t\t\t\tcolor *= v_color;\n\r\n\t\t\t#endif\n\r\n\t\t\tgl_FragColor = color;\n\r\n\t\t}\r\n\t")})(this);
(function(B){var c=B.LiteGraph,l=B.LGraphTexture;if("undefined"!=typeof GL){var r=function(){this.addInput("Tex.","Texture");this.addInput("intensity","number");this.addOutput("Texture","Texture");this.properties={intensity:1,invert:!1,precision:l.DEFAULT};r._shader||(r._shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,r.pixel_shader))},t=function(){this.addInput("Texture","Texture");this.addInput("value1","number");this.addInput("value2","number");this.addOutput("Texture","Texture");this.properties=
{fx:"halftone",value1:1,value2:1,precision:l.DEFAULT}},v=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}},h=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:l.DEFAULT};h._shader||(h._shader=new GL.Shader(GL.Shader.SCREEN_VERTEX_SHADER,h.pixel_shader),h._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]}))};h.title="Lens";h.desc="Camera Lens distortion";h.widgets_info={precision:{widget:"combo",values:l.MODE_VALUES}};h.prototype.onExecute=function(){var c=this.getInputData(0);if(this.properties.precision===
l.PASS_THROUGH)this.setOutputData(0,c);else if(c){this._tex=l.getTargetTexture(c,this._tex,this.properties.precision);var t=this.properties.aberration;this.isInputConnected(1)&&(t=this.getInputData(1),this.properties.aberration=t);var r=this.properties.distortion;this.isInputConnected(2)&&(r=this.getInputData(2),this.properties.distortion=r);var v=this.properties.blur;this.isInputConnected(3)&&(v=this.getInputData(3),this.properties.blur=v);gl.disable(gl.BLEND);gl.disable(gl.DEPTH_TEST);var B=Mesh.getScreenQuad(),
e=h._shader;this._tex.drawTo(function(){c.bind(0);e.uniforms({u_texture:0,u_aberration:t,u_distortion:r,u_blur:v}).draw(B)});this.setOutputData(0,this._tex)}};h.pixel_shader="precision highp float;\n\r\n\t\t\tprecision highp float;\n\r\n\t\t\tvarying vec2 v_coord;\n\r\n\t\t\tuniform sampler2D u_texture;\n\r\n\t\t\tuniform vec2 u_camera_planes;\n\r\n\t\t\tuniform float u_aberration;\n\r\n\t\t\tuniform float u_distortion;\n\r\n\t\t\tuniform float u_blur;\n\r\n\t\t\t\n\r\n\t\t\tvoid main() {\n\r\n\t\t\t\tvec2 coord = v_coord;\n\r\n\t\t\t\tfloat dist = distance(vec2(0.5), coord);\n\r\n\t\t\t\tvec2 dist_coord = coord - vec2(0.5);\n\r\n\t\t\t\tfloat percent = 1.0 + ((0.5 - dist) / 0.5) * u_distortion;\n\r\n\t\t\t\tdist_coord *= percent;\n\r\n\t\t\t\tcoord = dist_coord + vec2(0.5);\n\r\n\t\t\t\tvec4 color = texture2D(u_texture,coord, u_blur * dist);\n\r\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\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\r\n\t\t\t\tgl_FragColor = color;\n\r\n\t\t\t}\n\r\n\t\t\t";
c.registerNodeType("fx/lens",h);B.LGraphFXLens=h;v.title="Bokeh";v.desc="applies an Bokeh effect";v.widgets_info={shape:{widget:"texture"}};v.prototype.onExecute=function(){var c=this.getInputData(0),h=this.getInputData(1),t=this.getInputData(2);if(c&&t&&this.properties.shape){h||(h=c);var r=l.getTexture(this.properties.shape);if(r){var B=this.properties.threshold;this.isInputConnected(3)&&(B=this.getInputData(3),this.properties.threshold=B);var e=gl.UNSIGNED_BYTE;this.properties.high_precision&&
-(e=gl.half_float_ext?gl.HALF_FLOAT_OES:gl.FLOAT);this._temp_texture&&this._temp_texture.type==e&&this._temp_texture.width==c.width&&this._temp_texture.height==c.height||(this._temp_texture=new GL.Texture(c.width,c.height,{type:e,format:gl.RGBA,filter:gl.LINEAR}));var D=v._first_shader;D||(D=v._first_shader=new GL.Shader(Shader.SCREEN_VERTEX_SHADER,v._first_pixel_shader));var H=v._second_shader;H||(H=v._second_shader=new GL.Shader(v._second_vertex_shader,v._second_pixel_shader));var z=this._points_mesh;
-z&&z._width==c.width&&z._height==c.height&&2==z._spacing||(z=this.createPointsMesh(c.width,c.height,2));var M=Mesh.getScreenQuad(),k=this.properties.size,n=this.properties.alpha;gl.disable(gl.DEPTH_TEST);gl.disable(gl.BLEND);this._temp_texture.drawTo(function(){c.bind(0);h.bind(1);t.bind(2);D.uniforms({u_texture:0,u_texture_blur:1,u_mask:2,u_texsize:[c.width,c.height]}).draw(M)});this._temp_texture.drawTo(function(){gl.enable(gl.BLEND);gl.blendFunc(gl.ONE,gl.ONE);c.bind(0);r.bind(3);H.uniforms({u_texture:0,
-u_mask:2,u_shape:3,u_alpha:n,u_threshold:B,u_pointSize:k,u_itexsize:[1/c.width,1/c.height]}).draw(z,gl.POINTS)});this.setOutputData(0,this._temp_texture)}}else this.setOutputData(0,c)};v.prototype.createPointsMesh=function(c,h,l){for(var t=Math.round(c/l),r=Math.round(h/l),e=new Float32Array(t*r*2),v=-1,A=2/c*l,z=2/h*l,B=0;B=c.NOTEON||k<=c.NOTEOFF)this.channel=e&15};Object.defineProperty(c.prototype,"velocity",{get:function(){return this.cmd==c.NOTEON?this.data[2]:-1},set:function(c){this.data[2]=c},enumerable:!0});c.notes="A A# B C C# D D# E F F# G G#".split(" ");c.note_to_index={A:0,"A#":1,B:2,C:3,"C#":4,D:5,"D#":6,E:7,F:8,"F#":9,G:10,"G#":11};Object.defineProperty(c.prototype,"note",{get:function(){return this.cmd!=
c.NOTEON?-1:c.toNoteString(this.data[1],!0)},set:function(c){throw"notes cannot be assigned this way, must modify the data[1]";},enumerable:!0});Object.defineProperty(c.prototype,"octave",{get:function(){return this.cmd!=c.NOTEON?-1:Math.floor((this.data[1]-24)/12+1)},set:function(c){throw"octave cannot be assigned this way, must modify the data[1]";},enumerable:!0});c.prototype.getPitch=function(){return 440*Math.pow(2,(this.data[1]-69)/12)};c.computePitch=function(c){return 440*Math.pow(2,(c-69)/
12)};c.prototype.getCC=function(){return this.data[1]};c.prototype.getCCValue=function(){return this.data[2]};c.prototype.getPitchBend=function(){return this.data[1]+(this.data[2]<<7)-8192};c.computePitchBend=function(c,e){return c+(e<<7)-8192};c.prototype.setCommandFromString=function(e){this.cmd=c.computeCommandFromString(e)};c.computeCommandFromString=function(e){if(!e)return 0;if(e&&e.constructor===Number)return e;e=e.toUpperCase();switch(e){case "NOTE ON":case "NOTEON":return c.NOTEON;case "NOTE OFF":case "NOTEOFF":return c.NOTEON;
@@ -829,33 +830,33 @@ t.default_ports={0:"unknown"};t.prototype.getMIDIOutputs=function(){var c={};if(
function(){return[["on_midi",z.EVENT]]};z.registerNodeType("midi/output",t);v.title="MIDI Show";v.desc="Shows MIDI in the graph";v.color="#243";v.prototype.getTitle=function(){return this.flags.collapsed?this._str:this.title};v.prototype.onAction=function(e,h){h&&(this._str=h.constructor===c?h.toString():"???")};v.prototype.onDrawForeground=function(c){this._str&&!this.flags.collapsed&&(c.font="30px Arial",c.fillText(this._str,10,.8*this.size[1]))};v.prototype.onGetInputs=function(){return[["in",
z.ACTION]]};v.prototype.onGetOutputs=function(){return[["on_midi",z.EVENT]]};z.registerNodeType("midi/show",v);h.title="MIDI Filter";h.desc="Filters MIDI messages";h.color="#243";h["@cmd"]={type:"enum",title:"Command",values:c.commands_reversed};h.prototype.getTitle=function(){var e=-1==this.properties.cmd?"Nothing":c.commands_short[this.properties.cmd]||"Unknown";-1!=this.properties.min_value&&-1!=this.properties.max_value&&(e+=" "+(this.properties.min_value==this.properties.max_value?this.properties.max_value:
this.properties.min_value+".."+this.properties.max_value));return"Filter: "+e};h.prototype.onPropertyChanged=function(e,h){"cmd"==e&&(e=Number(h),isNaN(e)&&(e=c.commands[h]||0),this.properties.cmd=e)};h.prototype.onAction=function(e,h){if(h&&h.constructor===c){if(this._learning)this._learning=!1,this.boxcolor="#AAA",this.properties.channel=h.channel,this.properties.cmd=h.cmd,this.properties.min_value=this.properties.max_value=h.data[1];else if(-1!=this.properties.channel&&h.channel!=this.properties.channel||
--1!=this.properties.cmd&&h.cmd!=this.properties.cmd||-1!=this.properties.min_value&&h.data[1]this.properties.max_value)return;this.trigger("on_midi",h)}};z.registerNodeType("midi/filter",h);E.title="MIDIEvent";E.desc="Create a MIDI Event";E.color="#243";E.prototype.onAction=function(e,h){"assign"==e?(this.properties.channel=h.channel,this.properties.cmd=h.cmd,this.properties.value1=h.data[1],this.properties.value2=h.data[2],h.cmd==
-c.NOTEON?this.gate=!0:h.cmd==c.NOTEOFF&&(this.gate=!1)):(h=this.midi_event,h.channel=this.properties.channel,this.properties.cmd&&this.properties.cmd.constructor===String?h.setCommandFromString(this.properties.cmd):h.cmd=this.properties.cmd,h.data[0]=h.cmd|h.channel,h.data[1]=Number(this.properties.value1),h.data[2]=Number(this.properties.value2),this.trigger("on_midi",h))};E.prototype.onExecute=function(){var e=this.properties;if(this.inputs)for(var h=0;hthis.properties.max_value)return;this.trigger("on_midi",h)}};z.registerNodeType("midi/filter",h);F.title="MIDIEvent";F.desc="Create a MIDI Event";F.color="#243";F.prototype.onAction=function(e,h){"assign"==e?(this.properties.channel=h.channel,this.properties.cmd=h.cmd,this.properties.value1=h.data[1],this.properties.value2=h.data[2],h.cmd==
+c.NOTEON?this.gate=!0:h.cmd==c.NOTEOFF&&(this.gate=!1)):(h=this.midi_event,h.channel=this.properties.channel,this.properties.cmd&&this.properties.cmd.constructor===String?h.setCommandFromString(this.properties.cmd):h.cmd=this.properties.cmd,h.data[0]=h.cmd|h.channel,h.data[1]=Number(this.properties.value1),h.data[2]=Number(this.properties.value2),this.trigger("on_midi",h))};F.prototype.onExecute=function(){var e=this.properties;if(this.inputs)for(var h=0;hc;++c)this.valid_notes[c]=-1!=this.notes_pitches.indexOf(c);for(c=0;12>c;++c)if(this.valid_notes[c])this.offset_notes[c]=0;else for(var e=1;12>e;++e){if(this.valid_notes[(c-e)%12]){this.offset_notes[c]=-e;break}if(this.valid_notes[(c+e)%12]){this.offset_notes[c]=e;break}}};F.prototype.onAction=function(e,h){h&&h.constructor===c&&(h.data[0]==c.NOTEON||h.data[0]==c.NOTEOFF?(this.midi_event=new c,this.midi_event.setup(h.data),this.midi_event.data[1]+=this.offset_notes[c.note_to_index[h.note]],
-this.trigger("out",this.midi_event)):this.trigger("out",h))};F.prototype.onExecute=function(){var c=this.getInputData(1);null!=c&&c!=this._current_scale&&this.processScale(c)};z.registerNodeType("midi/quantize",F);e.title="MIDI fromFile";e.desc="Plays a MIDI file";e.color="#243";e.prototype.onAction=function(c){"play"==c?this.play():"pause"==c&&(this._playing=!this._playing)};e.prototype.onPropertyChanged=function(c,e){"url"==c&&this.loadMIDIFile(e)};e.prototype.onExecute=function(){if(this._midi&&
+Math.round(this.midi_event.data[1]+this.properties.amount),this.trigger("out",this.midi_event)):this.trigger("out",h))};J.prototype.onExecute=function(){var c=this.getInputData(1);null!=c&&(this.properties.amount=c)};z.registerNodeType("midi/transpose",J);G.title="MIDI Quantize Pitch";G.desc="Transpose a MIDI note tp fit an scale";G.color="#243";G.prototype.onPropertyChanged=function(c,e){"scale"==c&&this.processScale(e)};G.prototype.processScale=function(c){this._current_scale=c;this.notes_pitches=
+I.processScale(c);for(c=0;12>c;++c)this.valid_notes[c]=-1!=this.notes_pitches.indexOf(c);for(c=0;12>c;++c)if(this.valid_notes[c])this.offset_notes[c]=0;else for(var e=1;12>e;++e){if(this.valid_notes[(c-e)%12]){this.offset_notes[c]=-e;break}if(this.valid_notes[(c+e)%12]){this.offset_notes[c]=e;break}}};G.prototype.onAction=function(e,h){h&&h.constructor===c&&(h.data[0]==c.NOTEON||h.data[0]==c.NOTEOFF?(this.midi_event=new c,this.midi_event.setup(h.data),this.midi_event.data[1]+=this.offset_notes[c.note_to_index[h.note]],
+this.trigger("out",this.midi_event)):this.trigger("out",h))};G.prototype.onExecute=function(){var c=this.getInputData(1);null!=c&&c!=this._current_scale&&this.processScale(c)};z.registerNodeType("midi/quantize",G);e.title="MIDI fromFile";e.desc="Plays a MIDI file";e.color="#243";e.prototype.onAction=function(c){"play"==c?this.play():"pause"==c&&(this._playing=!this._playing)};e.prototype.onPropertyChanged=function(c,e){"url"==c&&this.loadMIDIFile(e)};e.prototype.onExecute=function(){if(this._midi&&
this._playing){this._current_time+=this.graph.elapsed_time;for(var e=100*this._current_time,h=0;hb;b++)for(var d=0;dg+f||c[1]>d))return b}}return-1};H.prototype.onAction=function(e,h){if("reset"==e)for(h=0;hh[1]))return e=this.getKeyIndex(h),this.keys[e]=!0,this._last_key=e,e=12*(this.properties.start_octave-1)+29+e,h=new c,h.setup([c.NOTEON,e,100]),this.trigger("note",h),!0};H.prototype.onMouseMove=function(e,h){if(!(0>h[1]||-1==this._last_key)){this.setDirtyCanvas(!0);
-e=this.getKeyIndex(h);if(this._last_key==e)return!0;this.keys[this._last_key]=!1;h=12*(this.properties.start_octave-1)+29+this._last_key;var k=new c;k.setup([c.NOTEOFF,h,100]);this.trigger("note",k);this.keys[e]=!0;h=12*(this.properties.start_octave-1)+29+e;k=new c;k.setup([c.NOTEON,h,100]);this.trigger("note",k);this._last_key=e;return!0}};H.prototype.onMouseUp=function(e,h){if(!(0>h[1]))return e=this.getKeyIndex(h),this.keys[e]=!1,this._last_key=-1,e=12*(this.properties.start_octave-1)+29+e,h=new c,
-h.setup([c.NOTEOFF,e,100]),this.trigger("note",h),!0};z.registerNodeType("midi/keys",H)})(this);
+c){if(this.instrument&&h.data[0]==c.NOTEON){e=h.note;if(!e||"undefined"==e||e.constructor!==String)return;this.instrument.play(e,h.octave,this.properties.duration,this.properties.volume)}this.trigger("note",h)}};D.prototype.onExecute=function(){var c=this.getInputData(1);null!=c&&(this.properties.volume=c);c=this.getInputData(2);null!=c&&(this.properties.duration=c)};z.registerNodeType("midi/play",D);E.title="MIDI Keys";E.desc="Keyboard to play notes";E.color="#243";E.keys=[{x:0,w:1,h:1,t:0},{x:.75,
+w:.5,h:.6,t:1},{x:1,w:1,h:1,t:0},{x:1.75,w:.5,h:.6,t:1},{x:2,w:1,h:1,t:0},{x:2.75,w:.5,h:.6,t:1},{x:3,w:1,h:1,t:0},{x:4,w:1,h:1,t:0},{x:4.75,w:.5,h:.6,t:1},{x:5,w:1,h:1,t:0},{x:5.75,w:.5,h:.6,t:1},{x:6,w:1,h:1,t:0}];E.prototype.onDrawForeground=function(c){if(!this.flags.collapsed){var e=12*this.properties.num_octaves;this.keys.length=e;var h=this.size[0]/(7*this.properties.num_octaves),a=this.size[1];c.globalAlpha=1;for(var b=0;2>b;b++)for(var d=0;dg+f||c[1]>d))return b}}return-1};E.prototype.onAction=function(e,h){if("reset"==e)for(h=0;hh[1]))return e=this.getKeyIndex(h),this.keys[e]=!0,this._last_key=e,e=12*(this.properties.start_octave-1)+29+e,h=new c,h.setup([c.NOTEON,e,100]),this.trigger("note",h),!0};E.prototype.onMouseMove=function(e,h){if(!(0>h[1]||-1==this._last_key)){this.setDirtyCanvas(!0);
+e=this.getKeyIndex(h);if(this._last_key==e)return!0;this.keys[this._last_key]=!1;h=12*(this.properties.start_octave-1)+29+this._last_key;var k=new c;k.setup([c.NOTEOFF,h,100]);this.trigger("note",k);this.keys[e]=!0;h=12*(this.properties.start_octave-1)+29+e;k=new c;k.setup([c.NOTEON,h,100]);this.trigger("note",k);this._last_key=e;return!0}};E.prototype.onMouseUp=function(e,h){if(!(0>h[1]))return e=this.getKeyIndex(h),this.keys[e]=!1,this._last_key=-1,e=12*(this.properties.start_octave-1)+29+e,h=new c,
+h.setup([c.NOTEOFF,e,100]),this.trigger("note",h),!0};z.registerNodeType("midi/keys",E)})(this);
(function(B){function c(){this.properties={src:"",gain:.5,loop:!0,autoplay:!0,playbackRate:1};this._loading_audio=!1;this._audiobuffer=null;this._audionodes=[];this._last_sourcenode=null;this.addOutput("out","audio");this.addInput("gain","number");this.audionode=n.getAudioContext().createGain();this.audionode.graphnode=this;this.audionode.gain.value=this.properties.gain;this.properties.src&&this.loadSound(this.properties.src)}function l(){this.properties={gain:.5};this._audionodes=[];this._media_stream=
null;this.addOutput("out","audio");this.addInput("gain","number");this.audionode=n.getAudioContext().createGain();this.audionode.graphnode=this;this.audionode.gain.value=this.properties.gain}function r(){this.properties={fftSize:2048,minDecibels:-100,maxDecibels:-10,smoothingTimeConstant:.5};this.audionode=n.getAudioContext().createAnalyser();this.audionode.graphnode=this;this.audionode.fftSize=this.properties.fftSize;this.audionode.minDecibels=this.properties.minDecibels;this.audionode.maxDecibels=
this.properties.maxDecibels;this.audionode.smoothingTimeConstant=this.properties.smoothingTimeConstant;this.addInput("in","audio");this.addOutput("freqs","array");this.addOutput("samples","array");this._time_bin=this._freq_bin=null}function t(){this.properties={gain:1};this.audionode=n.getAudioContext().createGain();this.addInput("in","audio");this.addInput("gain","number");this.addOutput("out","audio")}function v(){this.properties={impulse_src:"",normalize:!0};this.audionode=n.getAudioContext().createConvolver();
-this.addInput("in","audio");this.addOutput("out","audio")}function h(){this.properties={threshold:-50,knee:40,ratio:12,reduction:-20,attack:0,release:.25};this.audionode=n.getAudioContext().createDynamicsCompressor();this.addInput("in","audio");this.addOutput("out","audio")}function E(){this.properties={};this.audionode=n.getAudioContext().createWaveShaper();this.addInput("in","audio");this.addInput("shape","waveshape");this.addOutput("out","audio")}function A(){this.properties={gain1:.5,gain2:.5};
+this.addInput("in","audio");this.addOutput("out","audio")}function h(){this.properties={threshold:-50,knee:40,ratio:12,reduction:-20,attack:0,release:.25};this.audionode=n.getAudioContext().createDynamicsCompressor();this.addInput("in","audio");this.addOutput("out","audio")}function F(){this.properties={};this.audionode=n.getAudioContext().createWaveShaper();this.addInput("in","audio");this.addInput("shape","waveshape");this.addOutput("out","audio")}function C(){this.properties={gain1:.5,gain2:.5};
this.audionode=n.getAudioContext().createGain();this.audionode1=n.getAudioContext().createGain();this.audionode1.gain.value=this.properties.gain1;this.audionode2=n.getAudioContext().createGain();this.audionode2.gain.value=this.properties.gain2;this.audionode1.connect(this.audionode);this.audionode2.connect(this.audionode);this.addInput("in1","audio");this.addInput("in1 gain","number");this.addInput("in2","audio");this.addInput("in2 gain","number");this.addOutput("out","audio")}function I(){this.properties=
-{A:.1,D:.1,S:.1,R:.1};this.audionode=n.getAudioContext().createGain();this.audionode.gain.value=0;this.addInput("in","audio");this.addInput("gate","boolean");this.addOutput("out","audio");this.gate=!1}function J(){this.properties={delayTime:.5};this.audionode=n.getAudioContext().createDelay(10);this.audionode.delayTime.value=this.properties.delayTime;this.addInput("in","audio");this.addInput("time","number");this.addOutput("out","audio")}function F(){this.properties={frequency:350,detune:0,Q:1};this.addProperty("type",
+{A:.1,D:.1,S:.1,R:.1};this.audionode=n.getAudioContext().createGain();this.audionode.gain.value=0;this.addInput("in","audio");this.addInput("gate","boolean");this.addOutput("out","audio");this.gate=!1}function J(){this.properties={delayTime:.5};this.audionode=n.getAudioContext().createDelay(10);this.audionode.delayTime.value=this.properties.delayTime;this.addInput("in","audio");this.addInput("time","number");this.addOutput("out","audio")}function G(){this.properties={frequency:350,detune:0,Q:1};this.addProperty("type",
"lowpass","enum",{values:"lowpass highpass bandpass lowshelf highshelf peaking notch allpass".split(" ")});this.audionode=n.getAudioContext().createBiquadFilter();this.addInput("in","audio");this.addOutput("out","audio")}function e(){this.properties={frequency:440,detune:0,type:"sine"};this.addProperty("type","sine","enum",{values:["sine","square","sawtooth","triangle","custom"]});this.audionode=n.getAudioContext().createOscillator();this.addOutput("out","audio")}function D(){this.properties={continuous:!0,
-mark:-1};this.addInput("data","array");this.addInput("mark","number");this.size=[300,200];this._last_buffer=null}function H(){this.properties={band:440,amplitude:1};this.addInput("freqs","array");this.addOutput("signal","number")}function z(){if(!z.default_code){var c=z.default_function.toString(),a=c.indexOf("{")+1,b=c.lastIndexOf("}");z.default_code=c.substr(a,b-a)}this.properties={code:z.default_code};c=n.getAudioContext();c.createScriptProcessor?this.audionode=c.createScriptProcessor(4096,1,1):
+mark:-1};this.addInput("data","array");this.addInput("mark","number");this.size=[300,200];this._last_buffer=null}function E(){this.properties={band:440,amplitude:1};this.addInput("freqs","array");this.addOutput("signal","number")}function z(){if(!z.default_code){var c=z.default_function.toString(),a=c.indexOf("{")+1,b=c.lastIndexOf("}");z.default_code=c.substr(a,b-a)}this.properties={code:z.default_code};c=n.getAudioContext();c.createScriptProcessor?this.audionode=c.createScriptProcessor(4096,1,1):
(console.warn("ScriptProcessorNode deprecated"),this.audionode=c.createGain());this.processCode();z._bypass_function||(z._bypass_function=this.audionode.onaudioprocess);this.addInput("in","audio");this.addOutput("out","audio")}function M(){this.audionode=n.getAudioContext().destination;this.addInput("in","audio")}var k=B.LiteGraph,n={};B.LGAudio=n;n.getAudioContext=function(){if(!this._audio_context){window.AudioContext=window.AudioContext||window.webkitAudioContext;if(!window.AudioContext)return console.error("AudioContext not supported by browser"),
null;this._audio_context=new AudioContext;this._audio_context.onmessage=function(c){console.log("msg",c)};this._audio_context.onended=function(c){console.log("ended",c)};this._audio_context.oncomplete=function(c){console.log("complete",c)}}return this._audio_context};n.connect=function(c,a){try{c.connect(a)}catch(b){console.warn("LGraphAudio:",b)}};n.disconnect=function(c,a){try{c.disconnect(a)}catch(b){console.warn("LGraphAudio:",b)}};n.changeAllAudiosConnections=function(c,a){if(c.inputs)for(var b=
0;b=this.size[0]&&(e=this.size[0]-1),c.strokeStyle=
-"red",c.beginPath(),c.moveTo(e,d),c.lineTo(e,0),c.stroke())}};D.title="Visualization";D.desc="Audio Visualization";k.registerNodeType("audio/visualization",D);H.prototype.onExecute=function(){if(this._freqs=this.getInputData(0)){var c=this.properties.band,a=this.getInputData(1);void 0!==a&&(c=a);a=n.getAudioContext().sampleRate/this._freqs.length;a=c/a*2;a>=this._freqs.length?a=this._freqs[this._freqs.length-1]:(c=a|0,a-=c,a=this._freqs[c]*(1-a)+this._freqs[c+1]*a);this.setOutputData(0,a/255*this.properties.amplitude)}};
-H.prototype.onGetInputs=function(){return[["band","number"]]};H.title="Signal";H.desc="extract the signal of some frequency";k.registerNodeType("audio/signal",H);z.prototype.onAdded=function(c){c.status==LGraph.STATUS_RUNNING&&(this.audionode.onaudioprocess=this._callback)};z["@code"]={widget:"code",type:"code"};z.prototype.onStart=function(){this.audionode.onaudioprocess=this._callback};z.prototype.onStop=function(){this.audionode.onaudioprocess=z._bypass_function};z.prototype.onPause=function(){this.audionode.onaudioprocess=
+"red",c.beginPath(),c.moveTo(e,d),c.lineTo(e,0),c.stroke())}};D.title="Visualization";D.desc="Audio Visualization";k.registerNodeType("audio/visualization",D);E.prototype.onExecute=function(){if(this._freqs=this.getInputData(0)){var c=this.properties.band,a=this.getInputData(1);void 0!==a&&(c=a);a=n.getAudioContext().sampleRate/this._freqs.length;a=c/a*2;a>=this._freqs.length?a=this._freqs[this._freqs.length-1]:(c=a|0,a-=c,a=this._freqs[c]*(1-a)+this._freqs[c+1]*a);this.setOutputData(0,a/255*this.properties.amplitude)}};
+E.prototype.onGetInputs=function(){return[["band","number"]]};E.title="Signal";E.desc="extract the signal of some frequency";k.registerNodeType("audio/signal",E);z.prototype.onAdded=function(c){c.status==LGraph.STATUS_RUNNING&&(this.audionode.onaudioprocess=this._callback)};z["@code"]={widget:"code",type:"code"};z.prototype.onStart=function(){this.audionode.onaudioprocess=this._callback};z.prototype.onStop=function(){this.audionode.onaudioprocess=z._bypass_function};z.prototype.onPause=function(){this.audionode.onaudioprocess=
z._bypass_function};z.prototype.onUnpause=function(){this.audionode.onaudioprocess=this._callback};z.prototype.onExecute=function(){};z.prototype.onRemoved=function(){this.audionode.onaudioprocess=z._bypass_function};z.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(q){console.error("Error in onaudioprocess code",q),this._callback=z._bypass_function,
this.audionode.onaudioprocess=this._callback}};z.prototype.onPropertyChanged=function(c,a){"code"==c&&(this.properties.code=a,this.processCode(),this.graph&&this.graph.status==LGraph.STATUS_RUNNING&&(this.audionode.onaudioprocess=this._callback))};z.default_function=function(){this.onaudioprocess=function(c){var a=c.inputBuffer;c=c.outputBuffer;for(var b=0;b max_size) {
max_size = node.size[max_size_index];
}
- node_size_index = (layout == LiteGraph.VERTICAL_LAYOUT) ? 0 : 1;
+ var node_size_index = (layout == LiteGraph.VERTICAL_LAYOUT) ? 0 : 1;
y += node.size[node_size_index] + margin + LiteGraph.NODE_TITLE_HEIGHT;
}
x += max_size + margin;
@@ -3194,6 +3194,15 @@
return;
}
+ if(slot == null)
+ {
+ console.error("slot must be a number");
+ return;
+ }
+
+ if(slot.constructor !== Number)
+ console.warn("slot must be a number, use node.trigger('name') if you want to use a string");
+
var output = this.outputs[slot];
if (!output) {
return;
@@ -7483,8 +7492,8 @@ LGraphNode.prototype.executeAction = function(action)
clientY_rel = e.clientY;
}
- e.deltaX = clientX_rel - this.last_mouse_position[0];
- e.deltaY = clientY_rel- this.last_mouse_position[1];
+ // e.deltaX = clientX_rel - this.last_mouse_position[0];
+ // e.deltaY = clientY_rel- this.last_mouse_position[1];
this.last_mouse_position[0] = clientX_rel;
this.last_mouse_position[1] = clientY_rel;
@@ -9921,7 +9930,8 @@ LGraphNode.prototype.executeAction = function(action)
case "combo":
var old_value = w.value;
if (event.type == LiteGraph.pointerevents_method+"move" && w.type == "number") {
- w.value += event.deltaX * 0.1 * (w.options.step || 1);
+ if(event.deltaX)
+ w.value += event.deltaX * 0.1 * (w.options.step || 1);
if ( w.options.min != null && w.value < w.options.min ) {
w.value = w.options.min;
}
@@ -11987,7 +11997,8 @@ LGraphNode.prototype.executeAction = function(action)
if (root.onClose && typeof root.onClose == "function"){
root.onClose();
}
- root.parentNode.removeChild(root);
+ if(root.parentNode)
+ root.parentNode.removeChild(root);
/* XXX CHECK THIS */
if(this.parentNode){
this.parentNode.removeChild(this);
@@ -15606,7 +15617,7 @@ if (typeof exports != "undefined") {
};
NodeScript.title = "Script";
- NodeScript.desc = "executes a code (max 100 characters)";
+ NodeScript.desc = "executes a code (max 256 characters)";
NodeScript.widgets_info = {
onExecute: { type: "code" }
@@ -16208,7 +16219,32 @@ if (typeof exports != "undefined") {
LiteGraph.registerNodeType("events/semaphore", SemaphoreEvent);
+ function OnceEvent() {
+ this.addInput("in", LiteGraph.ACTION );
+ this.addInput("reset", LiteGraph.ACTION );
+ this.addOutput("out", LiteGraph.EVENT );
+ this._once = false;
+ this.properties = {};
+ var that = this;
+ this.addWidget("button","reset","",function(){
+ that._once = false;
+ });
+ }
+ OnceEvent.title = "Once";
+ OnceEvent.desc = "Only passes an event once, then gets locked";
+
+ OnceEvent.prototype.onAction = function(action, param) {
+ if( action == "in" && !this._once )
+ {
+ this._once = true;
+ this.triggerSlot( 0, param );
+ }
+ else if( action == "reset" )
+ this._once = false;
+ };
+
+ LiteGraph.registerNodeType("events/once", OnceEvent);
function DataStore() {
this.addInput("data", 0);
diff --git a/build/litegraph_mini.min.js b/build/litegraph_mini.min.js
index 567f3cd4b..446d5b0aa 100644
--- a/build/litegraph_mini.min.js
+++ b/build/litegraph_mini.min.js
@@ -2,61 +2,61 @@ var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO
$jscomp.polyfill=function(x,m,t,l){if(m){t=$jscomp.global;x=x.split(".");for(l=0;lt&&(t=Math.max(0,w+t));if(null==l||l>w)l=w;l=Number(l);0>l&&(l=Math.max(0,w+l));for(t=Number(t||0);t=z}},"es6","es3");
-$jscomp.findInternal=function(x,m,t){x instanceof String&&(x=String(x));for(var l=x.length,w=0;w=A}},"es6","es3");
+$jscomp.findInternal=function(x,m,t){x instanceof String&&(x=String(x));for(var l=x.length,w=0;wa&&db?!0:!1}function A(a,b){var c=a[0]+a[2],d=a[1]+a[3],e=b[1]+b[3];return a[0]>b[0]+b[2]||a[1]>e||ca&&db?!0:!1}function B(a,b){var c=a[0]+a[2],d=a[1]+a[3],e=b[1]+b[3];return a[0]>b[0]+b[2]||a[1]>e||c