Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat: add CyberCity street-level exploration mode with 3rd-person avatar

Adam Eivy8bf0a48096ae
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 7586917399..de02abd7ac 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -17,6 +17,7 @@
- **Deep-linkable GSD Views**: Phase expansion and document selection persist in URL params (`?phase=03-apple-health-integration&doc=ROADMAP.md`)
- **AI thought evaluation**: Brain classifier adds commentary, insights, and connections about each captured thought — surfacing questions worth exploring and suggested next steps
- **Slop cleanup**: Raw brain dumps are automatically cleaned up — grammar fixed, shorthand expanded, restructured for clarity while preserving original meaning and voice
+- **CyberCity Drop In Mode**: Street-level 3rd-person exploration with a cyberpunk wireframe avatar — walk around the city with WASD, sprint with Shift, mouse look via pointer lock, approach buildings to see expanded holographic panels, press E to enter. Toggle between orbital and street view via HUD button or Tab hotkey
## Changed
diff --git a/client/src/components/city/Borough.jsx b/client/src/components/city/Borough.jsx
index 379ce8c6f6..fbed0e1dfe 100644
--- a/client/src/components/city/Borough.jsx
+++ b/client/src/components/city/Borough.jsx
@@ -13,7 +13,7 @@ const hashString = (str) => {
return Math.abs(hash);
};
-export default function Borough({ app, position, agentMap, onBuildingClick, playSfx, neonBrightness }) {
+export default function Borough({ app, position, agentMap, onBuildingClick, playSfx, neonBrightness, isProximity }) {
const agentData = agentMap.get(app.id);
const agents = agentData?.agents || [];
const height = getBuildingHeight(app);
@@ -54,6 +54,7 @@ export default function Borough({ app, position, agentMap, onBuildingClick, play
onClick={() => onBuildingClick?.(app)}
playSfx={playSfx}
neonBrightness={neonBrightness}
+ isProximity={isProximity}
/>
{/* Process buildings in ring around main building */}
diff --git a/client/src/components/city/Building.jsx b/client/src/components/city/Building.jsx
index 0f497bf7d6..ae42724fad 100644
--- a/client/src/components/city/Building.jsx
+++ b/client/src/components/city/Building.jsx
@@ -267,7 +267,7 @@ function NeonEdgeStrip({ position, height, color, delay }) {
);
}
-export default function Building({ app, position, agentCount, onClick, playSfx, neonBrightness = 1.2 }) {
+export default function Building({ app, position, agentCount, onClick, playSfx, neonBrightness = 1.2, isProximity = false }) {
const meshRef = useRef();
const glowRef = useRef();
const haloRef = useRef();
@@ -485,11 +485,12 @@ export default function Building({ app, position, agentCount, onClick, playSfx,
/>
{/* Holographic label */}
- {(hovered || isOnline || app.archived) && (
+ {(hovered || isOnline || app.archived || isProximity) && (
<HolographicPanel
app={app}
agentCount={agentCount}
position={[0, height + 1.8, 0]}
+ expanded={isProximity}
/>
)}
</group>
diff --git a/client/src/components/city/BuildingCluster.jsx b/client/src/components/city/BuildingCluster.jsx
index 8d02293366..fda582524f 100644
--- a/client/src/components/city/BuildingCluster.jsx
+++ b/client/src/components/city/BuildingCluster.jsx
@@ -4,7 +4,7 @@ import { computeCityLayout } from './cityLayout';
import { DISTRICT_PARAMS, PIXEL_FONT_URL } from './cityConstants';
import Borough from './Borough';
-export default function BuildingCluster({ apps, agentMap, onBuildingClick, onPositionsReady, playSfx, settings }) {
+export default function BuildingCluster({ apps, agentMap, onBuildingClick, onPositionsReady, playSfx, settings, proximityAppId }) {
const positions = useMemo(() => computeCityLayout(apps), [apps]);
// Notify parent when positions change (for data streams, roads, traffic)
@@ -37,6 +37,7 @@ export default function BuildingCluster({ apps, agentMap, onBuildingClick, onPos
onBuildingClick={onBuildingClick}
playSfx={playSfx}
neonBrightness={settings?.neonBrightness ?? 1.2}
+ isProximity={proximityAppId === app.id}
/>
);
})}
diff --git a/client/src/components/city/CameraTransition.jsx b/client/src/components/city/CameraTransition.jsx
new file mode 100644
index 0000000000..caa658af41
--- /dev/null
+++ b/client/src/components/city/CameraTransition.jsx
@@ -0,0 +1,56 @@
+import { useRef } from 'react';
+import { useThree, useFrame } from '@react-three/fiber';
+import * as THREE from 'three';
+
+const ORBITAL_POS = new THREE.Vector3(0, 25, 45);
+const ORBITAL_TARGET = new THREE.Vector3(0, 0, 0);
+const DURATION = 0.8;
+
+// Smoothstep easing
+const smoothstep = (t) => t * t * (3 - 2 * t);
+
+export default function CameraTransition({ active, targetPos, targetLookAt, onTransitionComplete }) {
+ const { camera } = useThree();
+ const progressRef = useRef(0);
+ const startPosRef = useRef(new THREE.Vector3());
+ const startTargetRef = useRef(new THREE.Vector3());
+ const wasActiveRef = useRef(false);
+ const completedRef = useRef(false);
+
+ useFrame((_, delta) => {
+ // Detect transition start
+ if (active !== wasActiveRef.current) {
+ wasActiveRef.current = active;
+ progressRef.current = 0;
+ completedRef.current = false;
+ startPosRef.current.copy(camera.position);
+ // Approximate current look-at from camera direction
+ const dir = new THREE.Vector3(0, 0, -1).applyQuaternion(camera.quaternion);
+ startTargetRef.current.copy(camera.position).add(dir.multiplyScalar(10));
+ }
+
+ if (completedRef.current) return;
+
+ progressRef.current += delta / DURATION;
+ if (progressRef.current >= 1) {
+ progressRef.current = 1;
+ completedRef.current = true;
+ }
+
+ const t = smoothstep(Math.min(progressRef.current, 1));
+
+ const endPos = active ? (targetPos || new THREE.Vector3(0, 2, 15)) : ORBITAL_POS;
+ const endTarget = active ? (targetLookAt || new THREE.Vector3(0, 1.4, 10)) : ORBITAL_TARGET;
+
+ camera.position.lerpVectors(startPosRef.current, endPos, t);
+
+ const currentTarget = new THREE.Vector3().lerpVectors(startTargetRef.current, endTarget, t);
+ camera.lookAt(currentTarget);
+
+ if (completedRef.current) {
+ onTransitionComplete?.();
+ }
+ });
+
+ return null;
+}
diff --git a/client/src/components/city/CityHud.jsx b/client/src/components/city/CityHud.jsx
index eb895f8373..3988244967 100644
--- a/client/src/components/city/CityHud.jsx
+++ b/client/src/components/city/CityHud.jsx
@@ -3,6 +3,48 @@ import { useNavigate, useLocation } from 'react-router-dom';
import CityActivityLog from './CityActivityLog';
import CityAgentBar from './CityAgentBar';
+// WASD controls hint shown briefly on first exploration entry
+function ControlsHint({ visible }) {
+ const [show, setShow] = useState(false);
+ const hasShownRef = useRef(false);
+
+ useEffect(() => {
+ if (visible && !hasShownRef.current) {
+ hasShownRef.current = true;
+ setShow(true);
+ const timer = setTimeout(() => setShow(false), 5000);
+ return () => clearTimeout(timer);
+ }
+ if (!visible) setShow(false);
+ }, [visible]);
+
+ if (!show) return null;
+
+ return (
+ <div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 pointer-events-none animate-in fade-in duration-500">
+ <div className="bg-black/85 border border-cyan-500/40 rounded-lg px-6 py-4 text-center">
+ <div className="font-pixel text-[11px] text-cyan-400 tracking-wider mb-3" style={{ textShadow: '0 0 8px rgba(6,182,212,0.5)' }}>
+ EXPLORATION MODE
+ </div>
+ <div className="grid grid-cols-3 gap-1 w-fit mx-auto mb-3">
+ <div />
+ <div className="font-pixel text-[10px] text-gray-300 bg-gray-800/60 border border-gray-600/40 rounded px-2 py-1 text-center">W</div>
+ <div />
+ <div className="font-pixel text-[10px] text-gray-300 bg-gray-800/60 border border-gray-600/40 rounded px-2 py-1 text-center">A</div>
+ <div className="font-pixel text-[10px] text-gray-300 bg-gray-800/60 border border-gray-600/40 rounded px-2 py-1 text-center">S</div>
+ <div className="font-pixel text-[10px] text-gray-300 bg-gray-800/60 border border-gray-600/40 rounded px-2 py-1 text-center">D</div>
+ </div>
+ <div className="font-pixel text-[8px] text-gray-500 tracking-wide space-y-1">
+ <div>MOUSE: LOOK AROUND (CLICK TO LOCK)</div>
+ <div>SHIFT: SPRINT</div>
+ <div>E: INTERACT WITH BUILDING</div>
+ <div>TAB: FLY OUT</div>
+ </div>
+ </div>
+ </div>
+ );
+}
+
// Format uptime from page load
const formatUptime = (seconds) => {
const h = Math.floor(seconds / 3600);
@@ -94,7 +136,7 @@ function HealthBar({ value, max, color }) {
);
}
-export default function CityHud({ cosStatus, cosAgents, agentMap, eventLogs, connected, apps, productivityData }) {
+export default function CityHud({ cosStatus, cosAgents, agentMap, eventLogs, connected, apps, productivityData, onToggleExploration, explorationMode }) {
const navigate = useNavigate();
const location = useLocation();
const [time, setTime] = useState(new Date());
@@ -274,6 +316,22 @@ export default function CityHud({ cosStatus, cosAgents, agentMap, eventLogs, con
{/* Bottom: Agent status bar */}
<CityAgentBar cosAgents={cosAgents} agentMap={agentMap} />
+ {/* Center crosshair in exploration mode */}
+ {explorationMode && (
+ <div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 pointer-events-none">
+ <div className="relative w-6 h-6">
+ <div className="absolute top-0 left-1/2 -translate-x-1/2 w-px h-2 bg-cyan-400/60" />
+ <div className="absolute bottom-0 left-1/2 -translate-x-1/2 w-px h-2 bg-cyan-400/60" />
+ <div className="absolute left-0 top-1/2 -translate-y-1/2 w-2 h-px bg-cyan-400/60" />
+ <div className="absolute right-0 top-1/2 -translate-y-1/2 w-2 h-px bg-cyan-400/60" />
+ <div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-1 h-1 rounded-full bg-cyan-400/40" />
+ </div>
+ </div>
+ )}
+
+ {/* Controls hint overlay */}
+ <ControlsHint visible={explorationMode} />
+
{/* Bottom-left: Settings gear + legend + corner decoration */}
<div className="absolute bottom-16 left-3">
{/* Status legend */}
@@ -297,6 +355,24 @@ export default function CityHud({ cosStatus, cosAgents, agentMap, eventLogs, con
</div>
</div>
+ {/* Drop In / Fly Out button */}
+ <button
+ onClick={onToggleExploration}
+ className={`pointer-events-auto mb-2 relative bg-black/85 backdrop-blur-sm border rounded-lg px-3 py-2 hover:bg-cyan-500/10 transition-all group ${
+ explorationMode
+ ? 'border-cyan-400/60 shadow-[0_0_8px_rgba(6,182,212,0.3)]'
+ : 'border-cyan-500/30 hover:border-cyan-400/60'
+ }`}
+ title={explorationMode ? 'Return to orbital view (Tab)' : 'Enter street-level exploration (Tab)'}
+ >
+ <HudCorner position="tl" />
+ <HudCorner position="br" />
+ <div className="font-pixel text-[10px] text-cyan-400 tracking-wider" style={{ textShadow: '0 0 6px rgba(6,182,212,0.4)' }}>
+ {explorationMode ? '[ FLY OUT ]' : '[ DROP IN ]'}
+ </div>
+ <div className="font-pixel text-[7px] text-cyan-500/40 tracking-wide mt-0.5 text-center">(Tab)</div>
+ </button>
+
<button
onClick={() => navigate(location.pathname === '/city/settings' ? '/city' : '/city/settings')}
className="pointer-events-auto mb-2 relative bg-black/85 backdrop-blur-sm border border-cyan-500/30 rounded-lg w-10 h-10 flex items-center justify-center hover:border-cyan-400/60 hover:bg-cyan-500/10 transition-all group"
diff --git a/client/src/components/city/CityScene.jsx b/client/src/components/city/CityScene.jsx
index 59a8383dcd..573db0fe9a 100644
--- a/client/src/components/city/CityScene.jsx
+++ b/client/src/components/city/CityScene.jsx
@@ -20,14 +20,28 @@ import CityNeonSigns from './CityNeonSigns';
import CityEmbers from './CityEmbers';
import CityEffects from './CityEffects';
import CitySky from './CitySky';
+import PlayerController from './PlayerController';
+import CameraTransition from './CameraTransition';
-export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus, productivityData, settings, playSfx }) {
+export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus, productivityData, settings, playSfx, keysRef }) {
const [positions, setPositions] = useState(null);
+ const [proximityApp, setProximityApp] = useState(null);
+ const [transitioning, setTransitioning] = useState(false);
+
+ const explorationMode = settings?.explorationMode || false;
const handlePositionsReady = useCallback((pos) => {
setPositions(pos);
}, []);
+ const handleBuildingProximity = useCallback((app) => {
+ setProximityApp(app);
+ }, []);
+
+ const handleTransitionComplete = useCallback(() => {
+ setTransitioning(false);
+ }, []);
+
const stoppedCount = apps.filter(a => !a.archived && a.overallStatus !== 'online').length;
const totalCount = apps.filter(a => !a.archived).length;
@@ -38,7 +52,7 @@ export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus,
camera={{ position: [0, 25, 45], fov: 50 }}
dpr={dpr}
shadows={false}
- style={{ background: '#030308' }}
+ style={{ background: '#030308', cursor: explorationMode ? 'crosshair' : 'auto' }}
gl={{ antialias: true }}
>
<CitySky settings={settings} />
@@ -56,6 +70,7 @@ export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus,
onPositionsReady={handlePositionsReady}
playSfx={playSfx}
settings={settings}
+ proximityAppId={proximityApp?.id}
/>
<CityDataStreams positions={positions} />
<CityTraffic positions={positions} />
@@ -72,12 +87,28 @@ export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus,
<CityEmbers />
<CityParticles settings={settings} />
<CityEffects settings={settings} />
- <OrbitControls
- maxPolarAngle={Math.PI / 2.2}
- minDistance={5}
- maxDistance={120}
- enableDamping
- dampingFactor={0.05}
+ {explorationMode && (
+ <PlayerController
+ keysRef={keysRef}
+ positions={positions}
+ onBuildingProximity={handleBuildingProximity}
+ onBuildingClick={onBuildingClick}
+ apps={apps}
+ active={explorationMode}
+ />
+ )}
+ {!explorationMode && !transitioning && (
+ <OrbitControls
+ maxPolarAngle={Math.PI / 2.2}
+ minDistance={5}
+ maxDistance={120}
+ enableDamping
+ dampingFactor={0.05}
+ />
+ )}
+ <CameraTransition
+ active={explorationMode}
+ onTransitionComplete={handleTransitionComplete}
/>
</Canvas>
);
diff --git a/client/src/components/city/CitySettingsPanel.jsx b/client/src/components/city/CitySettingsPanel.jsx
index fb2d6faa2e..0c1e0dc811 100644
--- a/client/src/components/city/CitySettingsPanel.jsx
+++ b/client/src/components/city/CitySettingsPanel.jsx
@@ -270,6 +270,19 @@ export default function CitySettingsPanel() {
<div className="border-t border-cyan-500/10" />
+ {/* Exploration */}
+ <div>
+ <SectionHeader title="EXPLORATION" subtitle="Street-level 3rd-person mode" />
+ <SettingToggle
+ label="DROP IN MODE"
+ value={settings.explorationMode}
+ onChange={(v) => updateSetting('explorationMode', v)}
+ description="Toggle street-level exploration (Tab)"
+ />
+ </div>
+
+ <div className="border-t border-cyan-500/10" />
+
{/* Reset */}
<button
onClick={resetSettings}
diff --git a/client/src/components/city/HolographicPanel.jsx b/client/src/components/city/HolographicPanel.jsx
index 78dd76ba50..e14c13dccb 100644
--- a/client/src/components/city/HolographicPanel.jsx
+++ b/client/src/components/city/HolographicPanel.jsx
@@ -7,7 +7,7 @@ const STATUS_ICONS = {
not_found: '\u25CB',
};
-export default function HolographicPanel({ app, agentCount, position }) {
+export default function HolographicPanel({ app, agentCount, position, expanded = false }) {
const statusColors = {
online: 'border-cyan-500/50 text-cyan-400',
stopped: 'border-red-500/50 text-red-400',
@@ -36,12 +36,12 @@ export default function HolographicPanel({ app, agentCount, position }) {
<Html
position={position}
center
- distanceFactor={15}
+ distanceFactor={expanded ? 8 : 15}
occlude
style={{ pointerEvents: 'none' }}
>
- <div className={`bg-black/90 border ${colorClass} rounded-md px-3 py-2 whitespace-nowrap backdrop-blur-sm`} style={{ boxShadow: '0 0 12px rgba(0,0,0,0.5)' }}>
- <div className="font-pixel text-[12px] tracking-wider truncate max-w-[160px] font-bold">{app.name}</div>
+ <div className={`bg-black/90 border ${colorClass} rounded-md ${expanded ? 'px-4 py-3' : 'px-3 py-2'} whitespace-nowrap backdrop-blur-sm`} style={{ boxShadow: expanded ? '0 0 20px rgba(6,182,212,0.3)' : '0 0 12px rgba(0,0,0,0.5)' }}>
+ <div className={`font-pixel tracking-wider truncate font-bold ${expanded ? 'text-[14px] max-w-[200px]' : 'text-[12px] max-w-[160px]'}`}>{app.name}</div>
<div className="flex items-center gap-2 text-[9px] font-pixel tracking-wide mt-1">
<span className={dotColor}>
{STATUS_ICONS[app.overallStatus] || '\u25CB'}
@@ -54,7 +54,9 @@ export default function HolographicPanel({ app, agentCount, position }) {
<span className="opacity-50">| {agentCount} AGENT{agentCount > 1 ? 'S' : ''}</span>
)}
</div>
- <div className="font-pixel text-[8px] text-cyan-500/30 tracking-widest mt-1">CLICK TO VIEW</div>
+ <div className="font-pixel text-[8px] text-cyan-500/30 tracking-widest mt-1">
+ {expanded ? 'PRESS E TO ENTER' : 'CLICK TO VIEW'}
+ </div>
</div>
</Html>
);
diff --git a/client/src/components/city/PlayerAvatar.jsx b/client/src/components/city/PlayerAvatar.jsx
new file mode 100644
index 0000000000..60f563f80e
--- /dev/null
+++ b/client/src/components/city/PlayerAvatar.jsx
@@ -0,0 +1,150 @@
+import { useRef, useMemo } from 'react';
+import { useFrame } from '@react-three/fiber';
+import * as THREE from 'three';
+
+const BODY_COLOR = '#0c0c24';
+const NEON_COLOR = '#06b6d4';
+const VISOR_COLOR = '#06b6d4';
+const EYE_COLOR = '#ff3366';
+
+export default function PlayerAvatar({ isMoving, facingAngle }) {
+ const groupRef = useRef();
+ const leftArmRef = useRef();
+ const rightArmRef = useRef();
+ const leftLegRef = useRef();
+ const rightLegRef = useRef();
+ const walkPhaseRef = useRef(0);
+
+ const torsoEdges = useMemo(() => {
+ const geom = new THREE.BoxGeometry(0.3, 0.4, 0.2);
+ return new THREE.EdgesGeometry(geom);
+ }, []);
+
+ useFrame((_, delta) => {
+ if (!groupRef.current) return;
+
+ // Facing direction
+ groupRef.current.rotation.y = facingAngle;
+
+ // Idle bob
+ const t = performance.now() / 1000;
+ const bob = Math.sin(t * 2) * 0.03;
+ groupRef.current.position.y = bob;
+
+ // Walk animation
+ if (isMoving) {
+ walkPhaseRef.current += delta * 12;
+ } else {
+ // Damp walk phase toward zero
+ walkPhaseRef.current *= 0.85;
+ }
+
+ const swing = Math.sin(walkPhaseRef.current) * 0.6;
+
+ if (leftArmRef.current) leftArmRef.current.rotation.x = swing;
+ if (rightArmRef.current) rightArmRef.current.rotation.x = -swing;
+ if (leftLegRef.current) leftLegRef.current.rotation.x = -swing;
+ if (rightLegRef.current) rightLegRef.current.rotation.x = swing;
+ });
+
+ return (
+ <group ref={groupRef}>
+ {/* Head - wireframe icosahedron */}
+ <group position={[0, 1.05, 0]}>
+ <mesh>
+ <icosahedronGeometry args={[0.12, 0]} />
+ <meshBasicMaterial color={NEON_COLOR} wireframe transparent opacity={0.7} />
+ </mesh>
+ {/* Visor */}
+ <mesh position={[0, 0, 0.08]}>
+ <boxGeometry args={[0.18, 0.05, 0.04]} />
+ <meshBasicMaterial color={VISOR_COLOR} transparent opacity={0.8} />
+ </mesh>
+ {/* Eyes */}
+ <mesh position={[-0.04, 0, 0.11]}>
+ <boxGeometry args={[0.03, 0.02, 0.01]} />
+ <meshBasicMaterial color={EYE_COLOR} />
+ </mesh>
+ <mesh position={[0.04, 0, 0.11]}>
+ <boxGeometry args={[0.03, 0.02, 0.01]} />
+ <meshBasicMaterial color={EYE_COLOR} />
+ </mesh>
+ </group>
+
+ {/* Torso */}
+ <group position={[0, 0.75, 0]}>
+ <mesh>
+ <boxGeometry args={[0.3, 0.4, 0.2]} />
+ <meshBasicMaterial color={BODY_COLOR} transparent opacity={0.9} />
+ </mesh>
+ {/* Neon wireframe edges */}
+ <lineSegments geometry={torsoEdges}>
+ <lineBasicMaterial color={NEON_COLOR} transparent opacity={0.8} />
+ </lineSegments>
+ </group>
+
+ {/* Left arm - pivoted at shoulder */}
+ <group position={[-0.22, 0.9, 0]}>
+ <group ref={leftArmRef}>
+ <mesh position={[0, -0.125, 0]}>
+ <cylinderGeometry args={[0.04, 0.04, 0.25, 6]} />
+ <meshBasicMaterial color={BODY_COLOR} transparent opacity={0.9} />
+ </mesh>
+ </group>
+ </group>
+
+ {/* Right arm - pivoted at shoulder */}
+ <group position={[0.22, 0.9, 0]}>
+ <group ref={rightArmRef}>
+ <mesh position={[0, -0.125, 0]}>
+ <cylinderGeometry args={[0.04, 0.04, 0.25, 6]} />
+ <meshBasicMaterial color={BODY_COLOR} transparent opacity={0.9} />
+ </mesh>
+ </group>
+ </group>
+
+ {/* Left leg - pivoted at hip */}
+ <group position={[-0.08, 0.55, 0]}>
+ <group ref={leftLegRef}>
+ <mesh position={[0, -0.15, 0]}>
+ <cylinderGeometry args={[0.05, 0.05, 0.3, 6]} />
+ <meshBasicMaterial color={BODY_COLOR} transparent opacity={0.9} />
+ </mesh>
+ {/* Foot */}
+ <mesh position={[0, -0.32, 0.03]}>
+ <boxGeometry args={[0.07, 0.04, 0.12]} />
+ <meshBasicMaterial color={NEON_COLOR} transparent opacity={0.6} />
+ </mesh>
+ </group>
+ </group>
+
+ {/* Right leg - pivoted at hip */}
+ <group position={[0.08, 0.55, 0]}>
+ <group ref={rightLegRef}>
+ <mesh position={[0, -0.15, 0]}>
+ <cylinderGeometry args={[0.05, 0.05, 0.3, 6]} />
+ <meshBasicMaterial color={BODY_COLOR} transparent opacity={0.9} />
+ </mesh>
+ {/* Foot */}
+ <mesh position={[0, -0.32, 0.03]}>
+ <boxGeometry args={[0.07, 0.04, 0.12]} />
+ <meshBasicMaterial color={NEON_COLOR} transparent opacity={0.6} />
+ </mesh>
+ </group>
+ </group>
+
+ {/* Glow disc at feet */}
+ <mesh rotation={[-Math.PI / 2, 0, 0]} position={[0, 0.02, 0]}>
+ <circleGeometry args={[0.4, 16]} />
+ <meshBasicMaterial
+ color={NEON_COLOR}
+ transparent
+ opacity={0.15}
+ side={THREE.DoubleSide}
+ blending={THREE.AdditiveBlending}
+ depthWrite={false}
+ />
+ </mesh>
+ </group>
+ );
+}
diff --git a/client/src/components/city/PlayerController.jsx b/client/src/components/city/PlayerController.jsx
new file mode 100644
index 0000000000..835f3da277
--- /dev/null
+++ b/client/src/components/city/PlayerController.jsx
@@ -0,0 +1,220 @@
+import { useRef, useEffect, useCallback } from 'react';
+import { useThree, useFrame } from '@react-three/fiber';
+import * as THREE from 'three';
+import PlayerAvatar from './PlayerAvatar';
+
+const WALK_SPEED = 8;
+const SPRINT_SPEED = 14;
+const CAMERA_DISTANCE = 5;
+const CAMERA_LERP = 0.08;
+const BUILDING_EXCLUSION_RADIUS = 3.5;
+const PROXIMITY_DISTANCE = 6;
+const WORLD_BOUND = 55;
+const HEAD_HEIGHT = 1.4;
+
+export default function PlayerController({
+ keysRef,
+ positions,
+ onBuildingProximity,
+ onBuildingClick,
+ apps,
+ active,
+}) {
+ const { camera, gl } = useThree();
+ const playerPos = useRef(new THREE.Vector3(0, 0, 0));
+ const yawRef = useRef(Math.PI); // Facing toward city center
+ const pitchRef = useRef(0.3);
+ const isMovingRef = useRef(false);
+ const facingAngleRef = useRef(Math.PI);
+ const lastSpawnRef = useRef(null);
+ const pointerLockedRef = useRef(false);
+ const proximityAppRef = useRef(null);
+ const avatarGroupRef = useRef();
+
+ // Initialize spawn position
+ useEffect(() => {
+ if (!active) return;
+ if (lastSpawnRef.current) {
+ playerPos.current.copy(lastSpawnRef.current);
+ } else {
+ // Spawn behind front row, facing downtown
+ let maxZ = 0;
+ positions?.forEach((pos) => {
+ if (pos.z > maxZ) maxZ = pos.z;
+ });
+ playerPos.current.set(0, 0, maxZ + 8);
+ yawRef.current = Math.PI;
+ }
+ }, [active, positions]);
+
+ // Pointer lock management
+ const handleClick = useCallback(() => {
+ if (!active) return;
+ gl.domElement.requestPointerLock?.();
+ }, [active, gl.domElement]);
+
+ const handlePointerLockChange = useCallback(() => {
+ pointerLockedRef.current = document.pointerLockElement === gl.domElement;
+ }, [gl.domElement]);
+
+ const handleMouseMove = useCallback((e) => {
+ if (!pointerLockedRef.current || !active) return;
+ yawRef.current -= e.movementX * 0.002;
+ pitchRef.current += e.movementY * 0.002;
+ pitchRef.current = Math.max(-0.4, Math.min(1.2, pitchRef.current));
+ }, [active]);
+
+ useEffect(() => {
+ if (!active) {
+ // Release pointer lock when leaving exploration mode
+ if (document.pointerLockElement === gl.domElement) {
+ document.exitPointerLock?.();
+ }
+ // Save last position for re-entry
+ lastSpawnRef.current = playerPos.current.clone();
+ return;
+ }
+
+ const canvas = gl.domElement;
+ canvas.addEventListener('click', handleClick);
+ document.addEventListener('pointerlockchange', handlePointerLockChange);
+ document.addEventListener('mousemove', handleMouseMove);
+
+ return () => {
+ canvas.removeEventListener('click', handleClick);
+ document.removeEventListener('pointerlockchange', handlePointerLockChange);
+ document.removeEventListener('mousemove', handleMouseMove);
+ if (document.pointerLockElement === canvas) {
+ document.exitPointerLock?.();
+ }
+ };
+ }, [active, gl.domElement, handleClick, handlePointerLockChange, handleMouseMove]);
+
+ // E key for building interaction
+ useEffect(() => {
+ if (!active) return;
+ const handleKeyDown = (e) => {
+ if (e.key.toLowerCase() === 'e' && proximityAppRef.current) {
+ onBuildingClick?.(proximityAppRef.current);
+ }
+ };
+ window.addEventListener('keydown', handleKeyDown);
+ return () => window.removeEventListener('keydown', handleKeyDown);
+ }, [active, onBuildingClick]);
+
+ useFrame((_, delta) => {
+ if (!active) return;
+
+ const keys = keysRef.current;
+ const isSprinting = keys.has('shift');
+ const speed = (isSprinting ? SPRINT_SPEED : WALK_SPEED) * delta;
+
+ // Movement direction relative to camera yaw
+ const forward = new THREE.Vector3(-Math.sin(yawRef.current), 0, -Math.cos(yawRef.current));
+ const right = new THREE.Vector3(forward.z, 0, -forward.x);
+
+ const moveDir = new THREE.Vector3(0, 0, 0);
+ if (keys.has('w') || keys.has('arrowup')) moveDir.add(forward);
+ if (keys.has('s') || keys.has('arrowdown')) moveDir.sub(forward);
+ if (keys.has('a') || keys.has('arrowleft')) moveDir.sub(right);
+ if (keys.has('d') || keys.has('arrowright')) moveDir.add(right);
+
+ const moving = moveDir.lengthSq() > 0;
+ isMovingRef.current = moving;
+
+ if (moving) {
+ moveDir.normalize().multiplyScalar(speed);
+ const nextPos = playerPos.current.clone().add(moveDir);
+ nextPos.y = 0;
+
+ // Update facing angle to movement direction
+ facingAngleRef.current = Math.atan2(moveDir.x, moveDir.z);
+
+ // Collision detection with buildings
+ let blocked = false;
+ positions?.forEach((pos) => {
+ const dx = nextPos.x - pos.x;
+ const dz = nextPos.z - pos.z;
+ const dist = Math.sqrt(dx * dx + dz * dz);
+ if (dist < BUILDING_EXCLUSION_RADIUS) {
+ // Slide along boundary tangent
+ const nx = dx / dist;
+ const nz = dz / dist;
+ const dot = moveDir.x * nx + moveDir.z * nz;
+ if (dot < 0) {
+ // Moving toward building - project movement onto tangent
+ nextPos.x = playerPos.current.x + (moveDir.x - dot * nx) * 0.8;
+ nextPos.z = playerPos.current.z + (moveDir.z - dot * nz) * 0.8;
+ // Re-check distance after slide
+ const dx2 = nextPos.x - pos.x;
+ const dz2 = nextPos.z - pos.z;
+ if (Math.sqrt(dx2 * dx2 + dz2 * dz2) < BUILDING_EXCLUSION_RADIUS) {
+ blocked = true;
+ }
+ }
+ }
+ });
+
+ if (!blocked) {
+ // World bounds
+ nextPos.x = Math.max(-WORLD_BOUND, Math.min(WORLD_BOUND, nextPos.x));
+ nextPos.z = Math.max(-WORLD_BOUND, Math.min(WORLD_BOUND, nextPos.z));
+ playerPos.current.copy(nextPos);
+ }
+ }
+
+ // Building proximity detection
+ let nearestApp = null;
+ let nearestDist = PROXIMITY_DISTANCE;
+ positions?.forEach((pos, appId) => {
+ const dx = playerPos.current.x - pos.x;
+ const dz = playerPos.current.z - pos.z;
+ const dist = Math.sqrt(dx * dx + dz * dz);
+ if (dist < nearestDist) {
+ nearestDist = dist;
+ const app = apps?.find(a => a.id === appId);
+ if (app) nearestApp = app;
+ }
+ });
+
+ if (nearestApp !== proximityAppRef.current) {
+ proximityAppRef.current = nearestApp;
+ onBuildingProximity?.(nearestApp);
+ }
+
+ // Camera follow - spherical offset from player
+ const camX = playerPos.current.x + Math.sin(yawRef.current) * Math.cos(pitchRef.current) * CAMERA_DISTANCE;
+ const camY = playerPos.current.y + HEAD_HEIGHT + Math.sin(pitchRef.current) * CAMERA_DISTANCE;
+ const camZ = playerPos.current.z + Math.cos(yawRef.current) * Math.cos(pitchRef.current) * CAMERA_DISTANCE;
+
+ const targetCamPos = new THREE.Vector3(camX, camY, camZ);
+ camera.position.lerp(targetCamPos, CAMERA_LERP);
+
+ const lookTarget = new THREE.Vector3(
+ playerPos.current.x,
+ playerPos.current.y + HEAD_HEIGHT,
+ playerPos.current.z,
+ );
+ camera.lookAt(lookTarget);
+
+ // Update avatar position
+ if (avatarGroupRef.current) {
+ avatarGroupRef.current.position.set(
+ playerPos.current.x,
+ playerPos.current.y,
+ playerPos.current.z,
+ );
+ }
+ });
+
+ if (!active) return null;
+
+ return (
+ <group ref={avatarGroupRef}>
+ <PlayerAvatar
+ isMoving={isMovingRef.current}
+ facingAngle={facingAngleRef.current}
+ />
+ </group>
+ );
+}
diff --git a/client/src/hooks/useCitySettings.js b/client/src/hooks/useCitySettings.js
index 73c8d89862..6ffffea8b1 100644
--- a/client/src/hooks/useCitySettings.js
+++ b/client/src/hooks/useCitySettings.js
@@ -48,6 +48,7 @@ const DEFAULT_SETTINGS = {
sfxVolume: 0.5,
qualityPreset: 'high',
timeOfDay: 'sunset',
+ explorationMode: false,
...QUALITY_PRESETS.high,
};
diff --git a/client/src/hooks/useKeyboardControls.js b/client/src/hooks/useKeyboardControls.js
new file mode 100644
index 0000000000..a181a83628
--- /dev/null
+++ b/client/src/hooks/useKeyboardControls.js
@@ -0,0 +1,35 @@
+import { useRef, useEffect, useCallback } from 'react';
+
+export default function useKeyboardControls(onToggleMode) {
+ const keysRef = useRef(new Set());
+
+ const handleKeyDown = useCallback((e) => {
+ if (e.key === 'Tab') {
+ e.preventDefault();
+ onToggleMode?.();
+ return;
+ }
+ keysRef.current.add(e.key.toLowerCase());
+ }, [onToggleMode]);
+
+ const handleKeyUp = useCallback((e) => {
+ keysRef.current.delete(e.key.toLowerCase());
+ }, []);
+
+ const handleBlur = useCallback(() => {
+ keysRef.current.clear();
+ }, []);
+
+ useEffect(() => {
+ window.addEventListener('keydown', handleKeyDown);
+ window.addEventListener('keyup', handleKeyUp);
+ window.addEventListener('blur', handleBlur);
+ return () => {
+ window.removeEventListener('keydown', handleKeyDown);
+ window.removeEventListener('keyup', handleKeyUp);
+ window.removeEventListener('blur', handleBlur);
+ };
+ }, [handleKeyDown, handleKeyUp, handleBlur]);
+
+ return keysRef;
+}
diff --git a/client/src/pages/CyberCity.jsx b/client/src/pages/CyberCity.jsx
index 10cd3009a4..2b38476c5e 100644
--- a/client/src/pages/CyberCity.jsx
+++ b/client/src/pages/CyberCity.jsx
@@ -2,6 +2,7 @@ import { useCallback, useState, useEffect } from 'react';
import { useNavigate, useLocation } from 'react-router-dom';
import { useCityData } from '../hooks/useCityData';
import useCityAudio from '../hooks/useCityAudio';
+import useKeyboardControls from '../hooks/useKeyboardControls';
import * as api from '../services/api';
import CityScene from '../components/city/CityScene';
import CityHud from '../components/city/CityHud';
@@ -11,7 +12,7 @@ import CitySettingsPanel from '../components/city/CitySettingsPanel';
function CyberCityInner() {
const { apps, cosAgents, cosStatus, eventLogs, agentMap, loading, connected } = useCityData();
- const { settings } = useCitySettingsContext();
+ const { settings, updateSetting } = useCitySettingsContext();
const { playSfx } = useCityAudio(settings);
const navigate = useNavigate();
const location = useLocation();
@@ -19,6 +20,12 @@ function CyberCityInner() {
const showSettings = location.pathname === '/city/settings';
+ const handleToggleExploration = useCallback(() => {
+ updateSetting('explorationMode', !settings?.explorationMode);
+ }, [updateSetting, settings?.explorationMode]);
+
+ const keysRef = useKeyboardControls(handleToggleExploration);
+
// Fetch productivity data for HUD vitals and billboards
useEffect(() => {
const fetchProductivity = async () => {
@@ -64,6 +71,7 @@ function CyberCityInner() {
productivityData={productivityData}
settings={settings}
playSfx={playSfx}
+ keysRef={keysRef}
/>
<CityHud
cosStatus={cosStatus}
@@ -73,6 +81,8 @@ function CyberCityInner() {
connected={connected}
apps={apps}
productivityData={productivityData}
+ onToggleExploration={handleToggleExploration}
+ explorationMode={settings?.explorationMode}
/>
<CityScanlines settings={settings} />
{showSettings && <CitySettingsPanel />}