diff --git a/frontend/src/lib/components/graph/Graph.svelte b/frontend/src/lib/components/graph/Graph.svelte index ca1a10e..df3246c 100644 --- a/frontend/src/lib/components/graph/Graph.svelte +++ b/frontend/src/lib/components/graph/Graph.svelte @@ -444,8 +444,16 @@ document?.activeElement?.id === "graph"; if (event.key === "l") { - const activeNode = graph.getNode($activeNodeId); - console.log(activeNode); + 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") { diff --git a/frontend/src/lib/components/node/Node.frag b/frontend/src/lib/components/node/Node.frag index 2ba282d..22da461 100644 --- a/frontend/src/lib/components/node/Node.frag +++ b/frontend/src/lib/components/node/Node.frag @@ -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 ) { diff --git a/frontend/src/lib/graph-manager.ts b/frontend/src/lib/graph-manager.ts index 19d33a9..b9ce070 100644 --- a/frontend/src/lib/graph-manager.ts +++ b/frontend/src/lib/graph-manager.ts @@ -62,6 +62,21 @@ export class GraphManager extends EventEmitter<{ "save": Graph }> { return this.nodeRegistry.getAllNodes(); } + getLinkedNodes(node: Node) { + const nodes = new Set(); + 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(); - }); + 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`); }