Skip to content

Commit d9a66ed

Browse files
committed
remove invalid connections
1 parent 44135ce commit d9a66ed

File tree

1 file changed

+35
-13
lines changed

1 file changed

+35
-13
lines changed

editor/index.html

+35-13
Original file line numberDiff line numberDiff line change
@@ -252,25 +252,47 @@
252252
return true;
253253
},
254254
disconnect: function(nodeA, outputA, nodeB, inputB){
255-
var state = this.state;
256-
var connToRemove = state.connections.find(function(conn){
257-
return (
258-
conn.nodeA === nodeA &&
259-
conn.nodeB === nodeB &&
260-
conn.outputA === outputA &&
261-
conn.inputB === inputB
262-
);
263-
});
255+
var state = this.state;
256+
var connToRemove = state.connections.find(function(conn){
257+
return (
258+
conn.nodeA === nodeA &&
259+
conn.nodeB === nodeB &&
260+
conn.outputA === outputA &&
261+
conn.inputB === inputB
262+
);
263+
});
264264
var idx = state.connections.indexOf(connToRemove);
265265
if(idx !== -1){
266266
state.connections.splice(idx, 1);
267267
}
268268

269-
// var nA = this.shader.fragmentGraph.getNodeById(nodeA);
270-
// var nB = this.shader.fragmentGraph.getNodeById(nodeB);
271-
// nB.disconnect(inputB, nA, outputA);
269+
// Test it!
270+
var nA = this.shader.fragmentGraph.getNodeById(nodeA);
271+
var nB = this.shader.fragmentGraph.getNodeById(nodeB);
272+
nB.disconnect(inputB, nA, outputA);
273+
274+
// Delete any other invalid connections
275+
/*
276+
var invalidConnections = this.shader.fragmentGraph.connections.filter(function(conn){
277+
return !conn.isValid();
278+
}).forEach(function(conn){
279+
console.log('removing', conn)
280+
var connToRemove = state.connections.find(function(connData){
281+
return (
282+
connData.nodeA === conn.fromNode &&
283+
connData.nodeB === conn.toNode &&
284+
connData.outputA === conn.fromPortKey &&
285+
connData.inputB === conn.toPortKey
286+
);
287+
});
288+
var idx = state.connections.indexOf(connToRemove);
289+
if(idx !== -1){
290+
state.connections.splice(idx, 1);
291+
}
292+
});
293+
*/
272294

273-
this.setState(state);
295+
this.setState(state);
274296
}
275297
});
276298

0 commit comments

Comments
 (0)