Skip to content

Commit 3859dfa

Browse files
committed
fix(brain): origin-locked orbit, bigger shells, smoother damping, right-click deselect
- zoomToCursor was shifting the orbit target away from origin on every scroll, so zoomed-out frames showed the constellation drifting to one side. Disable zoomToCursor and explicitly reset controls.target to (0,0,0) at mount. - Bump SHELL_OUTER_RADIUS 140 → 220 and SHELL_INNER_RADIUS 80 → 130 so ~1000-node graphs breathe instead of clumping. Scale the three orbital rings, reticle (186 → 290), and crosshair (14 → 20) to match. - Lower OrbitControls dampingFactor 0.085 → 0.06, zoomSpeed 0.6 → 0.4, rotateSpeed 0.45 → 0.4, panSpeed 0.6 → 0.5 — more inertia, less stutter on small mouse motion. - Right-click on the canvas now deselects the active node and the context menu is suppressed via onContextMenu preventDefault.
1 parent d8c1e25 commit 3859dfa

3 files changed

Lines changed: 37 additions & 16 deletions

File tree

‎desktop/cortex-control-center/src/BrainVisualizer.jsx‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -409,12 +409,13 @@ function BrainVisualizerComponent({ api = null, cortexBase = "http://127.0.0.1:7
409409

410410
if ("enableDamping" in controls) {
411411
controls.enableDamping = true;
412-
controls.dampingFactor = 0.085;
412+
controls.dampingFactor = 0.06;
413413
}
414-
if ("zoomSpeed" in controls) controls.zoomSpeed = 0.6;
415-
if ("rotateSpeed" in controls) controls.rotateSpeed = 0.45;
416-
if ("panSpeed" in controls) controls.panSpeed = 0.6;
417-
if ("zoomToCursor" in controls) controls.zoomToCursor = true;
414+
if ("zoomSpeed" in controls) controls.zoomSpeed = 0.4;
415+
if ("rotateSpeed" in controls) controls.rotateSpeed = 0.4;
416+
if ("panSpeed" in controls) controls.panSpeed = 0.5;
417+
if ("zoomToCursor" in controls) controls.zoomToCursor = false;
418+
if (controls.target && typeof controls.target.set === "function") controls.target.set(0, 0, 0);
418419

419420
const handleControlsChange = () => {
420421
if (zoomFrameRef.current) return;
@@ -772,7 +773,20 @@ function BrainVisualizerComponent({ api = null, cortexBase = "http://127.0.0.1:7
772773

773774
// 3D Graph
774775
return (
775-
<div className="brain-container" data-bloom={bloomActive ? "on" : "off"} data-shell-split={useShellSplit ? "on" : "off"} onMouseDown={() => autoRotate && setAutoRotate(false)} onWheel={() => autoRotate && setAutoRotate(false)}>
776+
<div
777+
className="brain-container"
778+
data-bloom={bloomActive ? "on" : "off"}
779+
data-shell-split={useShellSplit ? "on" : "off"}
780+
onMouseDown={(e) => {
781+
if (autoRotate) setAutoRotate(false);
782+
if (e.button === 2 && selectedNodeRef.current) {
783+
selectedNodeRef.current = null;
784+
startTransition(() => setSelectedNode(null));
785+
}
786+
}}
787+
onContextMenu={(e) => e.preventDefault()}
788+
onWheel={() => autoRotate && setAutoRotate(false)}
789+
>
776790
<div className="brain-orbital-ring brain-orbital-ring-a" aria-hidden="true" />
777791
<div className="brain-orbital-ring brain-orbital-ring-b" aria-hidden="true" />
778792

‎desktop/cortex-control-center/src/brain-visualizer.test.js‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,17 @@ describe("Brain visualizer", () => {
166166
expect(source).toContain("disposeEdgeMesh(edgeMeshRef.current)");
167167
});
168168

169-
it("uses smooth orbit + zoom-to-cursor controls", () => {
169+
it("uses smooth orbit controls with damping and origin-locked target", () => {
170170
expect(source).toContain("controls.enableDamping = true");
171-
expect(source).toContain("controls.dampingFactor = 0.085");
172-
expect(source).toContain("controls.zoomToCursor = true");
171+
expect(source).toContain("controls.dampingFactor = 0.06");
172+
expect(source).toContain("controls.zoomToCursor = false");
173+
expect(source).toContain("controls.target.set(0, 0, 0)");
174+
});
175+
176+
it("right-click deselects the active node and suppresses the context menu", () => {
177+
expect(source).toContain("e.button === 2");
178+
expect(source).toContain("onContextMenu={(e) => e.preventDefault()}");
179+
expect(source).toContain("startTransition(() => setSelectedNode(null))");
173180
});
174181

175182
it("BrainVisualizer instantiates RippleEngine, ticks per frame, and fires on click", () => {

‎desktop/cortex-control-center/src/brain/ShellGeometry.js‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import * as THREE from "three";
22

33
export const CONSTELLATION_SHELL_NAME = "cortex-constellation-shell";
44

5-
export const SHELL_OUTER_RADIUS = 140;
6-
export const SHELL_INNER_RADIUS = 80;
5+
export const SHELL_OUTER_RADIUS = 220;
6+
export const SHELL_INNER_RADIUS = 130;
77

88
const OUTER_LINE_COLOR = "#40e0ff";
99
const INNER_LINE_COLOR = "#ffd166";
@@ -105,14 +105,14 @@ export function createConstellationShells() {
105105
group.add(innerShell);
106106

107107
const rings = [
108-
makeLine(ellipseRingPoints(172, 110, -10, Math.PI * 0.20, 0), OUTER_LINE_COLOR, 0.14),
109-
makeLine(ellipseRingPoints(138, 84, 24, Math.PI * 0.34, Math.PI * 0.12), INNER_LINE_COLOR, 0.10),
110-
makeLine(ellipseRingPoints(118, 68, -32, Math.PI * 0.48, -Math.PI * 0.10), OUTER_LINE_COLOR, 0.11),
108+
makeLine(ellipseRingPoints(270, 170, -16, Math.PI * 0.20, 0), OUTER_LINE_COLOR, 0.14),
109+
makeLine(ellipseRingPoints(215, 130, 38, Math.PI * 0.34, Math.PI * 0.12), INNER_LINE_COLOR, 0.10),
110+
makeLine(ellipseRingPoints(185, 105, -50, Math.PI * 0.48, -Math.PI * 0.10), OUTER_LINE_COLOR, 0.11),
111111
];
112112
for (const ring of rings) group.add(ring);
113113

114-
group.add(reticleRing(186, 96, 8, 6));
115-
group.add(centerCrosshair(14));
114+
group.add(reticleRing(290, 96, 8, 8));
115+
group.add(centerCrosshair(20));
116116

117117
for (const child of group.children) {
118118
child.renderOrder = 1;

0 commit comments

Comments
 (0)