mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-05 05:00:03 +00:00
fix
This commit is contained in:
Binary file not shown.
@@ -1357,7 +1357,7 @@ LiteGraph.registerNodeType("audio/waveShaper", LGAudioWaveShaper);
|
||||
}
|
||||
};
|
||||
|
||||
LGAudioScript["@code"] = { widget: "code" };
|
||||
LGAudioScript["@code"] = { widget: "code", type: "code" };
|
||||
|
||||
LGAudioScript.prototype.onStart = function() {
|
||||
this.audionode.onaudioprocess = this._callback;
|
||||
|
||||
@@ -301,12 +301,17 @@
|
||||
{
|
||||
var type = this.properties.type;
|
||||
this.type_widget.value = type;
|
||||
if(this.outputs[0].type != type)
|
||||
{
|
||||
this.outputs[0].type = type;
|
||||
this.disconnectOutput(0);
|
||||
}
|
||||
if(type == "number")
|
||||
{
|
||||
this.value_widget.type = "number";
|
||||
this.value_widget.value = 0;
|
||||
}
|
||||
else if(type == "bool")
|
||||
else if(type == "boolean")
|
||||
{
|
||||
this.value_widget.type = "toggle";
|
||||
this.value_widget.value = true;
|
||||
@@ -372,8 +377,10 @@
|
||||
var data = this.graph.inputs[name];
|
||||
if (!data) {
|
||||
this.setOutputData(0, this.properties.value );
|
||||
return;
|
||||
}
|
||||
this.setOutputData(0, data.value === undefined ? this.properties.value : data.value);
|
||||
|
||||
this.setOutputData(0, data.value !== undefined ? data.value : this.properties.value );
|
||||
};
|
||||
|
||||
GraphInput.prototype.onRemoved = function() {
|
||||
@@ -493,6 +500,14 @@
|
||||
function ConstantNumber() {
|
||||
this.addOutput("value", "number");
|
||||
this.addProperty("value", 1.0);
|
||||
this.widget = this.addWidget(
|
||||
"number",
|
||||
"value",
|
||||
1,
|
||||
"value"
|
||||
);
|
||||
this.widgets_up = true;
|
||||
this.size = [180, 30];
|
||||
}
|
||||
|
||||
ConstantNumber.title = "Const Number";
|
||||
@@ -509,10 +524,6 @@
|
||||
return this.title;
|
||||
};
|
||||
|
||||
ConstantNumber.prototype.setValue = function(v) {
|
||||
this.properties.value = v;
|
||||
};
|
||||
|
||||
ConstantNumber.prototype.onDrawBackground = function(ctx) {
|
||||
//show the current value
|
||||
this.outputs[0].label = this.properties["value"].toFixed(3);
|
||||
@@ -520,6 +531,29 @@
|
||||
|
||||
LiteGraph.registerNodeType("basic/const", ConstantNumber);
|
||||
|
||||
function ConstantBoolean() {
|
||||
this.addOutput("", "boolean");
|
||||
this.addProperty("value", true);
|
||||
this.widget = this.addWidget(
|
||||
"toggle",
|
||||
"value",
|
||||
true,
|
||||
"value"
|
||||
);
|
||||
this.widgets_up = true;
|
||||
this.size = [140, 30];
|
||||
}
|
||||
|
||||
ConstantBoolean.title = "Const Boolean";
|
||||
ConstantBoolean.desc = "Constant boolean";
|
||||
ConstantBoolean.prototype.getTitle = ConstantNumber.prototype.getTitle;
|
||||
|
||||
ConstantBoolean.prototype.onExecute = function() {
|
||||
this.setOutputData(0, this.properties["value"]);
|
||||
};
|
||||
|
||||
LiteGraph.registerNodeType("basic/boolean", ConstantBoolean);
|
||||
|
||||
function ConstantString() {
|
||||
this.addOutput("", "string");
|
||||
this.addProperty("value", "");
|
||||
@@ -527,23 +561,15 @@
|
||||
"text",
|
||||
"value",
|
||||
"",
|
||||
this.setValue.bind(this)
|
||||
"value" //link to property value
|
||||
);
|
||||
this.widgets_up = true;
|
||||
this.size = [100, 30];
|
||||
this.size = [180, 30];
|
||||
}
|
||||
|
||||
ConstantString.title = "Const String";
|
||||
ConstantString.desc = "Constant string";
|
||||
|
||||
ConstantString.prototype.setValue = function(v) {
|
||||
this.properties.value = v;
|
||||
};
|
||||
|
||||
ConstantString.prototype.onPropertyChanged = function(name, value) {
|
||||
this.widget.value = value;
|
||||
};
|
||||
|
||||
ConstantString.prototype.getTitle = ConstantNumber.prototype.getTitle;
|
||||
|
||||
ConstantString.prototype.onExecute = function() {
|
||||
|
||||
@@ -20,22 +20,30 @@
|
||||
//convert to Event if the value is true
|
||||
function TriggerEvent() {
|
||||
this.size = [60, 30];
|
||||
this.addInput("in", "");
|
||||
this.addInput("if", "");
|
||||
this.addOutput("true", LiteGraph.EVENT);
|
||||
this.addOutput("change", LiteGraph.EVENT);
|
||||
this.was_true = false;
|
||||
this.addOutput("false", LiteGraph.EVENT);
|
||||
this.properties = { only_on_change: true };
|
||||
this.prev = 0;
|
||||
}
|
||||
|
||||
TriggerEvent.title = "TriggerEvent";
|
||||
TriggerEvent.desc = "Triggers event if value is true";
|
||||
TriggerEvent.desc = "Triggers event if input evaluates to true";
|
||||
|
||||
TriggerEvent.prototype.onExecute = function(action, param) {
|
||||
var v = this.getInputData(0);
|
||||
if(v)
|
||||
var changed = (v != this.prev);
|
||||
if(this.prev === 0)
|
||||
changed = false;
|
||||
var must_resend = (changed && this.properties.only_on_change) || (!changed && !this.properties.only_on_change);
|
||||
if(v && must_resend )
|
||||
this.triggerSlot(0, param);
|
||||
if(v && !this.was_true)
|
||||
if(!v && must_resend)
|
||||
this.triggerSlot(2, param);
|
||||
if(changed)
|
||||
this.triggerSlot(1, param);
|
||||
this.was_true = v;
|
||||
this.prev = v;
|
||||
};
|
||||
|
||||
LiteGraph.registerNodeType("events/trigger", TriggerEvent);
|
||||
|
||||
@@ -65,8 +65,9 @@
|
||||
|
||||
LGraphPoints3D.OBJECT = 20;
|
||||
LGraphPoints3D.OBJECT_UNIFORMLY = 21;
|
||||
LGraphPoints3D.OBJECT_INSIDE = 22;
|
||||
|
||||
LGraphPoints3D.MODE_VALUES = { "rectangle":LGraphPoints3D.RECTANGLE, "circle":LGraphPoints3D.CIRCLE, "cube":LGraphPoints3D.CUBE, "sphere":LGraphPoints3D.SPHERE, "hemisphere":LGraphPoints3D.HEMISPHERE, "inside_sphere":LGraphPoints3D.INSIDE_SPHERE, "object":LGraphPoints3D.OBJECT, "object_uniformly":LGraphPoints3D.OBJECT_UNIFORMLY };
|
||||
LGraphPoints3D.MODE_VALUES = { "rectangle":LGraphPoints3D.RECTANGLE, "circle":LGraphPoints3D.CIRCLE, "cube":LGraphPoints3D.CUBE, "sphere":LGraphPoints3D.SPHERE, "hemisphere":LGraphPoints3D.HEMISPHERE, "inside_sphere":LGraphPoints3D.INSIDE_SPHERE, "object":LGraphPoints3D.OBJECT, "object_uniformly":LGraphPoints3D.OBJECT_UNIFORMLY, "object_inside":LGraphPoints3D.OBJECT_INSIDE };
|
||||
|
||||
LGraphPoints3D.widgets_info = {
|
||||
mode: { widget: "combo", values: LGraphPoints3D.MODE_VALUES }
|
||||
@@ -164,7 +165,7 @@
|
||||
if(normals)
|
||||
{
|
||||
for(var i = 0; i < normals.length; i+=3)
|
||||
normals.set(i, UP);
|
||||
normals.set(UP, i);
|
||||
}
|
||||
}
|
||||
else if( mode == LGraphPoints3D.SPHERE)
|
||||
@@ -195,7 +196,7 @@
|
||||
if(normals)
|
||||
{
|
||||
for(var i = 0; i < normals.length; i+=3)
|
||||
normals.set(i, UP);
|
||||
normals.set(UP, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -212,7 +213,7 @@
|
||||
if(normals)
|
||||
{
|
||||
for(var i = 0; i < normals.length; i+=3)
|
||||
normals.set(i, UP);
|
||||
normals.set(UP, i);
|
||||
}
|
||||
}
|
||||
else if( mode == LGraphPoints3D.CUBE)
|
||||
@@ -226,7 +227,7 @@
|
||||
if(normals)
|
||||
{
|
||||
for(var i = 0; i < normals.length; i+=3)
|
||||
normals.set(i, UP);
|
||||
normals.set(UP, i);
|
||||
}
|
||||
}
|
||||
else if( mode == LGraphPoints3D.SPHERE)
|
||||
@@ -261,6 +262,12 @@
|
||||
{
|
||||
LGraphPoints3D.generateFromObject( points, normals, size, obj, true );
|
||||
}
|
||||
else if( mode == LGraphPoints3D.OBJECT_INSIDE)
|
||||
{
|
||||
LGraphPoints3D.generateFromInsideObject( points, size, obj );
|
||||
//if(normals)
|
||||
// LGraphPoints3D.generateSphericalNormals( points, normals );
|
||||
}
|
||||
else
|
||||
console.warn("wrong mode in LGraphPoints3D");
|
||||
}
|
||||
@@ -466,6 +473,36 @@
|
||||
}
|
||||
}
|
||||
|
||||
LGraphPoints3D.generateFromInsideObject = function( points, size, mesh )
|
||||
{
|
||||
if(!mesh || mesh.constructor !== GL.Mesh)
|
||||
return;
|
||||
|
||||
var aabb = mesh.getBoundingBox();
|
||||
if(!mesh.octree)
|
||||
mesh.octree = new GL.Octree( mesh );
|
||||
var octree = mesh.octree;
|
||||
var origin = vec3.create();
|
||||
var direction = vec3.fromValues(1,0,0);
|
||||
var temp = vec3.create();
|
||||
var i = 0;
|
||||
var tries = 0;
|
||||
while(i < size && tries < points.length * 10) //limit to avoid problems
|
||||
{
|
||||
tries += 1
|
||||
var r = vec3.random(temp); //random point inside the aabb
|
||||
r[0] = (r[0] * 2 - 1) * aabb[3] + aabb[0];
|
||||
r[1] = (r[1] * 2 - 1) * aabb[4] + aabb[1];
|
||||
r[2] = (r[2] * 2 - 1) * aabb[5] + aabb[2];
|
||||
origin.set(r);
|
||||
var hit = octree.testRay( origin, direction, 0, 10000, true, GL.Octree.ALL );
|
||||
if(!hit || hit.length % 2 == 0) //not inside
|
||||
continue;
|
||||
points.set( r, i );
|
||||
i+=3;
|
||||
}
|
||||
}
|
||||
|
||||
LiteGraph.registerNodeType( "geometry/points3D", LGraphPoints3D );
|
||||
|
||||
|
||||
@@ -474,11 +511,13 @@
|
||||
this.addInput("points", "geometry");
|
||||
this.addOutput("instances", "[mat4]");
|
||||
this.properties = {
|
||||
mode: 1
|
||||
mode: 1,
|
||||
autoupdate: true
|
||||
};
|
||||
|
||||
this.must_update = true;
|
||||
this.matrices = [];
|
||||
this.first_time = true;
|
||||
}
|
||||
|
||||
LGraphPointsToInstances.NORMAL = 0;
|
||||
@@ -506,8 +545,13 @@
|
||||
if( !this.isOutputConnected(0) )
|
||||
return;
|
||||
|
||||
if( geo._version != this._version || geo._id != this._geometry_id )
|
||||
var has_changed = (geo._version != this._version || geo._id != this._geometry_id);
|
||||
|
||||
if( has_changed && this.properties.autoupdate || this.first_time )
|
||||
{
|
||||
this.first_time = false;
|
||||
this.updateInstances( geo );
|
||||
}
|
||||
|
||||
this.setOutputData( 0, this.matrices );
|
||||
}
|
||||
@@ -611,7 +655,8 @@
|
||||
this.geometry = {
|
||||
type: "triangles",
|
||||
vertices: null,
|
||||
_id: generateGeometryId()
|
||||
_id: generateGeometryId(),
|
||||
_version: 0
|
||||
};
|
||||
|
||||
this._last_geometry_id = -1;
|
||||
@@ -730,7 +775,7 @@
|
||||
this.addInput("sides", "number");
|
||||
this.addInput("radius", "number");
|
||||
this.addOutput("out", "geometry");
|
||||
this.properties = { sides: 6, radius: 1 }
|
||||
this.properties = { sides: 6, radius: 1, uvs: false }
|
||||
|
||||
this.geometry = {
|
||||
type: "line_loop",
|
||||
@@ -768,6 +813,13 @@
|
||||
if( !vertices || vertices.length != num )
|
||||
vertices = this.geometry.vertices = new Float32Array( 3*sides );
|
||||
var delta = (Math.PI * 2) / sides;
|
||||
var gen_uvs = this.properties.uvs;
|
||||
if(gen_uvs)
|
||||
{
|
||||
uvs = this.geometry.coords = new Float32Array( 3*sides );
|
||||
}
|
||||
|
||||
|
||||
for(var i = 0; i < sides; ++i)
|
||||
{
|
||||
var angle = delta * -i;
|
||||
@@ -777,6 +829,12 @@
|
||||
vertices[i*3] = x;
|
||||
vertices[i*3+1] = y;
|
||||
vertices[i*3+2] = z;
|
||||
|
||||
if(gen_uvs)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
this.geometry._id = ++this.geometry_id;
|
||||
this.geometry._version = ++this.version;
|
||||
|
||||
@@ -742,15 +742,14 @@
|
||||
precision: LGraphTexture.DEFAULT
|
||||
};
|
||||
|
||||
this.properties.code =
|
||||
"//time: time in seconds\n//texSize: vec2 with res\nuniform float u_value;\nuniform vec4 u_color;\n\nvoid main() {\n vec2 uv = v_coord;\n vec3 color = vec3(0.0);\n //your code here\n color.xy=uv;\n\ngl_FragColor = vec4(color, 1.0);\n}\n";
|
||||
this.properties.code = LGraphTextureShader.pixel_shader;
|
||||
this._uniforms = { u_value: 1, u_color: vec4.create(), in_texture: 0, texSize: vec2.create(), time: 0 };
|
||||
}
|
||||
|
||||
LGraphTextureShader.title = "Shader";
|
||||
LGraphTextureShader.desc = "Texture shader";
|
||||
LGraphTextureShader.widgets_info = {
|
||||
code: { type: "code" },
|
||||
code: { type: "code", lang: "glsl" },
|
||||
precision: { widget: "combo", values: LGraphTexture.MODE_VALUES }
|
||||
};
|
||||
|
||||
@@ -853,10 +852,7 @@
|
||||
}
|
||||
|
||||
this._shader_code = this.properties.code;
|
||||
this._shader = new GL.Shader(
|
||||
Shader.SCREEN_VERTEX_SHADER,
|
||||
LGraphTextureShader.pixel_shader + this.properties.code
|
||||
);
|
||||
this._shader = new GL.Shader( Shader.SCREEN_VERTEX_SHADER, this.properties.code );
|
||||
if (!this._shader) {
|
||||
this.boxcolor = "red";
|
||||
return null;
|
||||
@@ -929,10 +925,20 @@
|
||||
};
|
||||
|
||||
LGraphTextureShader.pixel_shader =
|
||||
"precision highp float;\n\
|
||||
\n\
|
||||
varying vec2 v_coord;\n\
|
||||
uniform float time;\n\
|
||||
"precision highp float;\n\
|
||||
\n\
|
||||
varying vec2 v_coord;\n\
|
||||
uniform float time; //time in seconds\n\
|
||||
uniform vec2 texSize; //tex resolution\n\
|
||||
uniform float u_value;\n\
|
||||
uniform vec4 u_color;\n\n\
|
||||
void main() {\n\
|
||||
vec2 uv = v_coord;\n\
|
||||
vec3 color = vec3(0.0);\n\
|
||||
//your code here\n\
|
||||
color.xy=uv;\n\n\
|
||||
gl_FragColor = vec4(color, 1.0);\n\
|
||||
}\n\
|
||||
";
|
||||
|
||||
LiteGraph.registerNodeType("texture/shader", LGraphTextureShader);
|
||||
@@ -4893,7 +4899,7 @@ void main(void){\n\
|
||||
this.addInput("v");
|
||||
this.addOutput("out", "Texture");
|
||||
this.properties = {
|
||||
code: "",
|
||||
code: LGraphTextureCanvas2D.default_code,
|
||||
width: 512,
|
||||
height: 512,
|
||||
clear: true,
|
||||
@@ -4902,12 +4908,15 @@ void main(void){\n\
|
||||
};
|
||||
this._func = null;
|
||||
this._temp_texture = null;
|
||||
this.compileCode();
|
||||
}
|
||||
|
||||
LGraphTextureCanvas2D.title = "Canvas2D";
|
||||
LGraphTextureCanvas2D.desc = "Executes Canvas2D code inside a texture or the viewport.";
|
||||
LGraphTextureCanvas2D.help = "Set width and height to 0 to match viewport size.";
|
||||
|
||||
LGraphTextureCanvas2D.default_code = "//vars: canvas,ctx,time\nctx.fillStyle='red';\nctx.fillRect(0,0,50,50);\n";
|
||||
|
||||
LGraphTextureCanvas2D.widgets_info = {
|
||||
precision: { widget: "combo", values: LGraphTexture.MODE_VALUES },
|
||||
code: { type: "code" },
|
||||
|
||||
@@ -642,6 +642,8 @@
|
||||
new MIDIInterface(function(midi) {
|
||||
that._midi = midi;
|
||||
});
|
||||
|
||||
this.addWidget("combo","Device",this.properties.port,{ property: "port", values: this.getMIDIOutputs.bind(this) });
|
||||
}
|
||||
|
||||
LGMIDIOut.MIDIInterface = MIDIInterface;
|
||||
@@ -650,22 +652,28 @@
|
||||
LGMIDIOut.desc = "Sends MIDI to output channel";
|
||||
LGMIDIOut.color = MIDI_COLOR;
|
||||
|
||||
LGMIDIOut.prototype.getPropertyInfo = function(name) {
|
||||
LGMIDIOut.prototype.onGetPropertyInfo = function(name) {
|
||||
if (!this._midi) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (name == "port") {
|
||||
var values = {};
|
||||
for (var i = 0; i < this._midi.output_ports.size; ++i) {
|
||||
var output = this._midi.output_ports.get(i);
|
||||
values[i] =
|
||||
i + ".- " + output.name + " version:" + output.version;
|
||||
}
|
||||
var values = this.getMIDIOutputs();
|
||||
return { type: "enum", values: values };
|
||||
}
|
||||
};
|
||||
|
||||
LGMIDIOut.prototype.getMIDIOutputs = function()
|
||||
{
|
||||
var values = {};
|
||||
for (var i = 0; i < this._midi.output_ports.size; ++i) {
|
||||
var output = this._midi.output_ports.get(i);
|
||||
if(output)
|
||||
values[i] = i + ".- " + output.name + " version:" + output.version;
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
LGMIDIOut.prototype.onAction = function(event, midi_event) {
|
||||
//console.log(midi_event);
|
||||
if (!this._midi) {
|
||||
@@ -687,6 +695,7 @@
|
||||
|
||||
LiteGraph.registerNodeType("midi/output", LGMIDIOut);
|
||||
|
||||
|
||||
function LGMIDIShow() {
|
||||
this.addInput("on_midi", LiteGraph.EVENT);
|
||||
this._str = "";
|
||||
|
||||
Reference in New Issue
Block a user