feat: add ctrl+l to select linked nodes
This commit is contained in:
parent
767c798ae6
commit
8dfd05fc63
@ -444,9 +444,17 @@
|
||||
document?.activeElement?.id === "graph";
|
||||
|
||||
if (event.key === "l") {
|
||||
if (event.ctrlKey) {
|
||||
const activeNode = graph.getNode($activeNodeId);
|
||||
if (activeNode) {
|
||||
const nodes = graph.getLinkedNodes(activeNode);
|
||||
$selectedNodes = new Set(nodes.map((n) => n.id));
|
||||
}
|
||||
} else {
|
||||
const activeNode = graph.getNode($activeNodeId);
|
||||
console.log(activeNode);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.key === "Escape") {
|
||||
$activeNodeId = -1;
|
||||
|
@ -40,7 +40,7 @@ void main(){
|
||||
vec2 size = vec2(uWidth, uHeight);
|
||||
vec2 uv = (vUv - 0.5) * 2.0;
|
||||
|
||||
float u_border_radius = 1.5;
|
||||
float u_border_radius = 0.4;
|
||||
vec4 distance = roundedBoxSDF(uv * size, size, u_border_radius*2.0, 0.0);
|
||||
|
||||
if (distance.w > 0.0 ) {
|
||||
|
@ -62,6 +62,21 @@ export class GraphManager extends EventEmitter<{ "save": Graph }> {
|
||||
return this.nodeRegistry.getAllNodes();
|
||||
}
|
||||
|
||||
getLinkedNodes(node: Node) {
|
||||
const nodes = new Set<Node>();
|
||||
const stack = [node];
|
||||
while (stack.length) {
|
||||
const n = stack.pop();
|
||||
if (!n) continue;
|
||||
nodes.add(n);
|
||||
const children = this.getChildrenOfNode(n);
|
||||
const parents = this.getParentsOfNode(n);
|
||||
const newNodes = [...children, ...parents].filter(n => !nodes.has(n));
|
||||
stack.push(...newNodes);
|
||||
}
|
||||
return [...nodes.values()];
|
||||
}
|
||||
|
||||
|
||||
private _init(graph: Graph) {
|
||||
const nodes = new Map(graph.nodes.map(node => {
|
||||
@ -92,6 +107,8 @@ export class GraphManager extends EventEmitter<{ "save": Graph }> {
|
||||
this.edges.set(edges);
|
||||
this.nodes.set(nodes);
|
||||
|
||||
this.execute();
|
||||
|
||||
}
|
||||
|
||||
async load(graph: Graph) {
|
||||
@ -126,10 +143,7 @@ export class GraphManager extends EventEmitter<{ "save": Graph }> {
|
||||
|
||||
this.loaded = true;
|
||||
const f = performance.now();
|
||||
requestAnimationFrame(() => {
|
||||
console.log(`Loading took ${f - a}ms; a-b: ${b - a}ms; b-c: ${c - b}ms; c-d: ${d - c}ms; d-e: ${e - d}ms; e-f: ${f - e}ms`);
|
||||
this.execute();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user