-
Notifications
You must be signed in to change notification settings - Fork 708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to connect two outputs to one input? #36
Comments
nop, because a node can only read one data from one input slot. Imagine a node with two inputs connected to the same slot, one connection comes with value 5 and the other one with value 9, which data reads the node from that slot? But you can create nodes that have a variable number of inputs so you can connect as many things as you want to different slots |
Thank you for the answer! |
but what if they are to strings? you could concatenate them but in which order?, or what if they are arrays? or images? I think the best solution is to create mixing nodes, nodes that do that thing you want to do (concatenate, add, etc) |
Because AudioNode can be connected from multiple node, I would also need this feature to visualize Web Audio API. I think we can ignore the order of connected node because we can handle these input as an array. I'm not pretty sure how the For the example of multiplying number: function MyMultiply()
{
this.addInput("*", "number", "multiple");
this.addOutput("=", "number");
}
// Function to call when the node is executed
MyMultiply.prototype.onExecute = function()
{
// getInputData(0) will return an array because we set the input to 'multiple'
var inputs = this.getInputData(0);
if(inputs.length === 0)
this.setOutputData(0, 0);
var value = inputs[0];
for (var i = 1; i < inputs.length; i++) {
value = value * inputs[i];
}
this.setOutputData(0, value);
} |
you approach seems clean, I like it, but still is lots of code to refactor and it will require a shift in the interaction, and I do not have much time now to undergo that overhaul. while output slots have an array of links, input slots only have one reference to the incoming link, the first step would be to change that, then create a way to disconnect links by clicking on them (not easy, you need to detect if the mouse is ontop of a curve). If you want to give it a try I will start forking and working on those steps. On the other hand, if you are interested in audio, there is already a mixer that allows to input many audio signals and blend them using other inputs as gain. Im sorry I cant help you more now. |
Thanks! I think it would be amazing if I use this library to visualize my project. |
Hi there, I need this behavior too. Let's build it together? |
Hi there, the multiple input is an interesting upgrade, but as Javi said it's quite a big refactoring. |
@Caumaker Hi, sadly my design requirement is also higher than current litegraph.js feature. A few month ago I decided to develop Blackprint that could have multiple port connection, data type validation with the actual object reference, and some performance and development optimization (like hot reload). But it's still experimental and I'm still freelancing on other project. I'm sorry that I haven't contribute to litegraph.js. |
Litegraph was created as a flow mechanism for data. Two connections in a single input broke the system as when reading from the input what should you read? the first? a blend? an array of N? The only place where using multiple connections make sense is in Events, but that will require to change lots of code so for now I leave it like this. |
Yep. I read the source and it appear to be a really heavy task. Thanks for every reply. I choosed another approach to overpass it. I created a button in my interface that appear when the user select the node. I shown this button dynamicly throught |
Could you explain how to do that? i can't seem to find how to do it in the documentation. Thanks. |
@gemul probably some edge cases here, but this is the idea export class NodeConsoleLog extends BaseNode {
private counter: number = 0;
constructor() {
super();
this.title = "Console Log";
this.addInput("message", "string");
this.addInput(`data${this.counter}`, 0 as any);
}
onConnectInput(
inputIndex: number,
outputType: string | -1,
outputSlot: INodeOutputSlot,
outputNode: LGraphNode,
outputIndex: number
): boolean {
if (inputIndex >= 1) {
this.addInput(`data${++this.counter}`, 0 as any);
}
return true;
}
onConnectionsChange(
type: number,
slotIndex: number,
isConnected: boolean,
link: LLink,
ioSlot: INodeInputSlot | INodeOutputSlot
): void {
if (type === LiteGraph.INPUT && slotIndex >= 1) {
if (!isConnected) {
this.removeInput(slotIndex);
}
}
}
} |
you can add a button widget using addWidget and assign it to a function that calls addInput. |
First I connect an output to an input and that works.
Then I connect another output to the same input.
The second connection is created but this causes the first connection to break.
Is it possible to connect two outputs to one input?
The text was updated successfully, but these errors were encountered: