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

City: moonlit night sky, horizon landscape, and free-look flight controls

[._.]/ Adam Eivyb073c199b7ed
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index ae933877fa..c6900a4972 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -9,6 +9,7 @@
## Changed
+- **City night sky, horizon, and flight controls** — Night is now a moonlit cyber-night rather than a near-black dusk: a galaxy starfield wraps the dome, distant mountains and themed terrain fill the horizon, and the sky dome cross-dissolves with daylight so the stars fade out as day comes up. Buildings gain lit floor bands and brighter facades so dark towers stay readable, and the AI Core spire gets light rings, an additive apex glow, and a point light. First-person exploration is now free-look flight: WASD moves, Q/E descend/ascend, Shift sprints, and the interact key moved to F (E is now "up"); you can fly up and over the city, with building collision disabled above rooftop height. The galaxy texture only loads at night. No change to the daytime look.
- **CyberCity is now "City"** — renamed throughout the UI (sidebar, scene title, command palette, keyboard help, billboards) since the cyberpunk look is now just one of several themes rather than the brand. The route stays `/city`.
- **City navigation is now map-style** — in orbital view, left-drag pans the camera across the city (so you can reach off-center districts without dropping into first-person), scroll zooms, right-drag (or ctrl-drag on a Mac trackpad) rotates, and arrow keys pan. Previously the only way to look away from the center was first-person mode.
- **City follows your PortOS theme** — the HUD panels (now fully opaque for readability) and the 3D scene's accent surfaces (ground grid, particles, online buildings, neon, and the CRT edge-glow) recolor to the active theme instead of being locked to dark cyan-on-black. The CRT affectations are opt-in per theme family: scanlines only on the terminal family, neon edge-glow on terminal + classic, and a cinematic vignette on all but the clean glass family. Status colors (stopped/red, warnings/amber) stay semantic.
diff --git a/.gitignore b/.gitignore
index c29018455b..dc55f1db8f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,6 +28,7 @@ npm-debug.log*
# Screenshots
*.png
!client/public/portos-logo.png
+!client/public/sky/*.png
!docs/media/portos-logo.png
!data.reference/templates/*.png
diff --git a/client/public/sky/README.md b/client/public/sky/README.md
new file mode 100644
index 0000000000..61055f4d04
--- /dev/null
+++ b/client/public/sky/README.md
@@ -0,0 +1,7 @@
+City sky textures
+=================
+
+- `city-night-galaxy-sphere.png`
+ - Generated for PortOS with the built-in image generation tool.
+ - Prompt intent: dark 2:1 equirectangular-style galaxy sphere texture for the City night sky.
+ - Constraints: no sun, moon, planets, lens flare, text, watermark, or bright central hotspot.
diff --git a/client/public/sky/city-night-galaxy-sphere.png b/client/public/sky/city-night-galaxy-sphere.png
new file mode 100644
index 0000000000..7656daaec3
Binary files /dev/null and b/client/public/sky/city-night-galaxy-sphere.png differ
diff --git a/client/src/components/city/Building.jsx b/client/src/components/city/Building.jsx
index 51e39dbc3b..5cfd2f8ab3 100644
--- a/client/src/components/city/Building.jsx
+++ b/client/src/components/city/Building.jsx
@@ -1,7 +1,7 @@
import { useRef, useState, useMemo } from 'react';
import { useFrame } from '@react-three/fiber';
import * as THREE from 'three';
-import { getBuildingColor, getBuildingHeight, getAccentColor, CITY_COLORS, BUILDING_PARAMS, PIXEL_FONT_URL, mixHex, tintStructure } from './cityConstants';
+import { getBuildingColor, getBuildingHeight, getAccentColor, BUILDING_PARAMS, PIXEL_FONT_URL, mixHex, tintStructure, seededRand } from './cityConstants';
import CityLabel from './CityLabel';
import HolographicPanel from './HolographicPanel';
import BuildingHologram from './BuildingHologram';
@@ -100,13 +100,13 @@ const createWindowTexture = (accentColor, width, height, seed) => {
canvas.height = px * rowCount;
const ctx = canvas.getContext('2d');
- // Dark base (tinted toward the theme accent, luminance preserved)
- ctx.fillStyle = tintStructure('#050510');
+ // Dark, but not black: facades need enough albedo for moon/neon bounce to
+ // reveal them. The theme tint keeps the texture in-family.
+ ctx.fillStyle = tintStructure('#24324f');
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Seeded random for consistent patterns
- let s = seed;
- const rand = () => { s = (s * 16807 + 0) % 2147483647; return (s & 0x7fffffff) / 2147483647; };
+ const rand = seededRand(seed);
// Draw random ambient windows (dimmer background pattern)
for (let r = 1; r < rowCount - 1; r++) {
@@ -122,13 +122,37 @@ const createWindowTexture = (accentColor, width, height, seed) => {
} else if (bright > 0.3) {
ctx.fillStyle = accentColor + '20';
} else {
- ctx.fillStyle = tintStructure('#0a0f1e');
+ ctx.fillStyle = tintStructure('#1d2b4a');
}
ctx.fillRect(c * px + 1, r * px + 1, px - 2, px - 2);
}
}
}
+ // Thin horizontal floor-light rows. These make large faces read as stacked
+ // occupied floors instead of a single blank slab, especially in night mode.
+ for (let r = 2; r < rowCount - 1; r += 3) {
+ const warmRow = rand() > 0.55;
+ const rowAlpha = rand() > 0.7 ? 0.44 : 0.28;
+ ctx.fillStyle = warmRow
+ ? `rgba(234, 244, 255, ${rowAlpha})`
+ : accentColor + (rowAlpha > 0.35 ? '70' : '45');
+
+ for (let c = 1; c < cols - 1; c++) {
+ if (rand() < 0.24) continue;
+ ctx.fillRect(c * px + 1, r * px + 3, px - 2, 2);
+ }
+ }
+
+ // Occasional brighter architectural bands, like stacked balcony/maintenance
+ // strips, to echo the city-light reference without covering every floor.
+ for (let r = 4 + (seed % 3); r < rowCount - 2; r += 8) {
+ ctx.fillStyle = accentColor + '85';
+ ctx.fillRect(0, r * px + 2, canvas.width, 2);
+ ctx.fillStyle = 'rgba(255,255,255,0.18)';
+ ctx.fillRect(0, r * px + 1, canvas.width, 1);
+ }
+
// Draw pixel art icon mural centered on face
const icon = PIXEL_ICONS[seed % PIXEL_ICONS.length];
const iconRows = icon.length;
@@ -267,6 +291,56 @@ function NeonEdgeStrip({ position, height, color, delay, dimMul = 1 }) {
);
}
+function FloorLightBands({ width, depth, height, color, accentColor, seed, dimMul = 1 }) {
+ const bands = useMemo(() => {
+ const rand = seededRand(seed + 97);
+ const floorCount = Math.max(4, Math.min(14, Math.floor(height / 1.05)));
+ const next = [];
+
+ for (let i = 1; i <= floorCount; i++) {
+ const y = (i / (floorCount + 1)) * height;
+ const isCrown = i === floorCount || i === floorCount - 1;
+ const show = isCrown || i % 3 === seed % 3 || rand() > 0.48;
+ if (!show) continue;
+
+ next.push({
+ key: `${i}-${Math.round(y * 100)}`,
+ y,
+ color: rand() > 0.45 ? mixHex('#f8fbff', accentColor, 0.28) : color,
+ opacity: isCrown ? 0.78 : 0.34 + rand() * 0.22,
+ thickness: isCrown ? 0.055 : 0.032,
+ });
+ }
+
+ return next;
+ }, [accentColor, color, height, seed]);
+
+ return (
+ <group>
+ {bands.map((band) => {
+ const horizontalGeo = [width * 0.96, band.thickness, 0.035];
+ const verticalGeo = [0.035, band.thickness, depth * 0.96];
+ const faces = [
+ { pos: [0, band.y, depth / 2 + 0.035], geo: horizontalGeo },
+ { pos: [0, band.y, -(depth / 2 + 0.035)], geo: horizontalGeo },
+ { pos: [width / 2 + 0.035, band.y, 0], geo: verticalGeo },
+ { pos: [-(width / 2 + 0.035), band.y, 0], geo: verticalGeo },
+ ];
+ return (
+ <group key={band.key}>
+ {faces.map((face, i) => (
+ <mesh key={i} position={face.pos}>
+ <boxGeometry args={face.geo} />
+ <meshBasicMaterial color={band.color} transparent opacity={band.opacity * dimMul} toneMapped={false} depthWrite={false} />
+ </mesh>
+ ))}
+ </group>
+ );
+ })}
+ </group>
+ );
+}
+
export default function Building({ app, position, agentCount, onClick, playSfx, neonBrightness = 1.2, isProximity = false, dimmed = false, dayMix = 0 }) {
const meshRef = useRef();
const glowRef = useRef();
@@ -294,7 +368,8 @@ export default function Building({ app, position, agentCount, onClick, playSfx,
// Mid-tone facade (not near-white) so strong daylight lands around a clean gray
// rather than clipping to white; a touch of the status color keeps variety.
const dayFacade = mixHex('#9aa0ac', edgeColor, 0.12);
- const bodyColor = mixHex(CITY_COLORS.buildingBody, dayFacade, dayMix);
+ const nightFacade = mixHex(app.archived ? '#273247' : '#26375d', edgeColor, app.archived ? 0.12 : 0.2);
+ const bodyColor = mixHex(nightFacade, dayFacade, dayMix);
const edgeLineColor = daytime ? mixHex('#4a4f57', edgeColor, 0.15) : edgeColor;
// Name hash for seeded randomness
@@ -359,14 +434,15 @@ export default function Building({ app, position, agentCount, onClick, playSfx,
>
<boxGeometry args={[width, height, depth]} />
<meshStandardMaterial
- color={bodyColor}
+ color={daytime ? bodyColor : '#ffffff'}
emissive={edgeColor}
- emissiveIntensity={0.35 * neonBrightness * dimMul * (1 - dayMix * 0.9)}
+ emissiveIntensity={0.7 * neonBrightness * dimMul * (1 - dayMix * 0.88)}
map={daytime ? undefined : windowTexture}
- roughness={daytime ? 0.9 : 1}
- metalness={daytime ? 0.05 : 0}
+ emissiveMap={daytime ? undefined : windowTexture}
+ roughness={daytime ? 0.9 : 0.78}
+ metalness={daytime ? 0.05 : 0.08}
transparent
- opacity={(app.archived ? 0.6 : 0.95) * dimMul}
+ opacity={(app.archived ? 0.78 : 1) * dimMul}
/>
</mesh>
@@ -421,6 +497,19 @@ export default function Building({ app, position, agentCount, onClick, playSfx,
</>
)}
+ {/* Lit floor bands stay on even for archived buildings so dark towers remain readable. */}
+ {!daytime && (
+ <FloorLightBands
+ width={width}
+ depth={depth}
+ height={height}
+ color={app.archived ? '#94a3b8' : edgeColor}
+ accentColor={app.archived ? '#64748b' : accentColor}
+ seed={seed}
+ dimMul={dimMul * (app.archived ? 0.58 : 1)}
+ />
+ )}
+
{/* Building name on front face - pixel font (dark ink + halo by day) */}
<CityLabel
position={[0, height * 0.88, depth / 2 + 0.02]}
diff --git a/client/src/components/city/CityAiCore.jsx b/client/src/components/city/CityAiCore.jsx
index 03e2b5582c..92c9544a8d 100644
--- a/client/src/components/city/CityAiCore.jsx
+++ b/client/src/components/city/CityAiCore.jsx
@@ -1,7 +1,7 @@
import { useMemo, useRef } from 'react';
import * as THREE from 'three';
import { useFrame } from '@react-three/fiber';
-import { PIXEL_FONT_URL, cityDayMix, tintStructure } from './cityConstants';
+import { PIXEL_FONT_URL, cityDayMix, mixHex, tintStructure } from './cityConstants';
import CityLabel from './CityLabel';
import { computeAiCore, computeAiCoreBeams, AI_CORE } from '../../utils/cityAiCore';
@@ -73,16 +73,51 @@ function TargetedBeam({ target, thickness, color, seed }) {
);
}
+function SpireLightRings({ height, color, dayMix }) {
+ const rings = useMemo(() => {
+ const count = Math.max(7, Math.floor(height / 1.6));
+ return Array.from({ length: count }, (_, i) => {
+ const ratio = (i + 1) / (count + 1);
+ return {
+ key: `ring-${i}`,
+ y: ratio * height,
+ radius: 1.4 + (0.5 - 1.4) * ratio + 0.04,
+ opacity: (i === count - 1 ? 0.58 : 0.28 + (i % 3) * 0.08) * (1 - dayMix * 0.7),
+ };
+ });
+ }, [dayMix, height]);
+
+ return (
+ <group>
+ {rings.map((ring) => (
+ <mesh key={ring.key} position={[0, ring.y, 0]} rotation={[Math.PI / 2, 0, 0]}>
+ <torusGeometry args={[ring.radius, 0.025, 6, 8]} />
+ <meshBasicMaterial color={mixHex('#f8fbff', color, 0.36)} transparent opacity={ring.opacity} toneMapped={false} depthWrite={false} />
+ </mesh>
+ ))}
+ </group>
+ );
+}
+
export default function CityAiCore({ aiActivity, positions, apps, settings }) {
const core = useMemo(
() => computeAiCore(aiActivity?.ops, aiActivity?.lastStartTs ?? 0),
[aiActivity],
);
const apexRef = useRef();
+ const apexGlowRef = useRef();
const animate = (settings?.particleDensity ?? 1) >= 0.5;
const dayMix = cityDayMix(settings);
const { position, height, apexY, color } = core;
+ const orbColor = core.busy ? color : mixHex('#67e8f9', color, 0.28);
+ const orbEmissive = (core.busy ? 0.85 : 0.48) + core.intensity * 0.45;
+ const orbGlowOpacity = (0.14 + core.intensity * 0.08) * (1 - dayMix * 0.45);
+ const nightSpireBase = mixHex(tintStructure('#2a416c'), color, 0.24);
+ const daySpireBase = mixHex('#707988', color, 0.1);
+ const spireBodyColor = mixHex(nightSpireBase, daySpireBase, dayMix);
+ const spireEdgeOpacity = 0.24 + (1 - dayMix) * 0.28;
+ const spireGlowColor = mixHex('#7dd3fc', orbColor, 0.5);
// Per-op beams: targeted at the originating building when known, radial otherwise.
// While flaring with no live op (a fast call that already cleared) keep one radial pulse.
@@ -99,7 +134,12 @@ export default function CityAiCore({ aiActivity, positions, apps, settings }) {
// Busy core pulses faster; a flare spikes it; idle breathes slowly.
const speed = core.busy ? 2.4 : core.flaring ? 3.2 : 0.7;
const pulse = 0.5 + ((Math.sin(clock.getElapsedTime() * speed) + 1) / 2) * 0.6;
- apexRef.current.material.emissiveIntensity = pulse * (core.intensity + 0.3);
+ apexRef.current.material.emissiveIntensity = orbEmissive + pulse * (core.busy ? 0.35 : 0.16);
+ if (apexGlowRef.current) {
+ apexGlowRef.current.material.opacity = orbGlowOpacity + pulse * 0.04;
+ const scale = 1 + pulse * 0.04;
+ apexGlowRef.current.scale.setScalar(scale);
+ }
});
return (
@@ -107,13 +147,44 @@ export default function CityAiCore({ aiActivity, positions, apps, settings }) {
{/* Slender spire body — tapered so it reads as a tower, not a column */}
<mesh position={[0, height / 2, 0]}>
<cylinderGeometry args={[0.5, 1.4, height, 8]} />
- <meshStandardMaterial color={tintStructure('#0a0f1c')} emissive={color} emissiveIntensity={0.1 + core.intensity * 0.15} metalness={0.7} roughness={0.4} />
+ <meshStandardMaterial
+ color={spireBodyColor}
+ emissive={spireGlowColor}
+ emissiveIntensity={0.55 + core.intensity * 0.35}
+ metalness={0.45}
+ roughness={0.46}
+ toneMapped={false}
+ />
</mesh>
+ <mesh position={[0, height / 2, 0]}>
+ <cylinderGeometry args={[0.52, 1.43, height + 0.04, 8]} />
+ <meshBasicMaterial
+ color={color}
+ wireframe
+ transparent
+ opacity={spireEdgeOpacity}
+ toneMapped={false}
+ depthWrite={false}
+ />
+ </mesh>
+ <SpireLightRings height={height} color={color} dayMix={dayMix} />
{/* Apex orb — the live AI-activity indicator */}
<mesh ref={apexRef} position={[0, apexY, 0]}>
<icosahedronGeometry args={[1.6, 1]} />
- <meshStandardMaterial color={color} emissive={color} emissiveIntensity={core.intensity} toneMapped={false} />
+ <meshStandardMaterial color={orbColor} emissive={orbColor} emissiveIntensity={orbEmissive} roughness={0.28} metalness={0.15} toneMapped={false} />
+ </mesh>
+ <mesh ref={apexGlowRef} position={[0, apexY, 0]}>
+ <sphereGeometry args={[1.95, 24, 16]} />
+ <meshBasicMaterial
+ color={orbColor}
+ transparent
+ opacity={orbGlowOpacity}
+ blending={THREE.AdditiveBlending}
+ depthWrite={false}
+ toneMapped={false}
+ />
</mesh>
+ <pointLight position={[0, apexY, 0]} color={orbColor} intensity={0.85 + core.intensity * 0.8} distance={22} decay={2} />
{/* Activity beams emanate from the apex while AI work is in flight */}
<group position={[0, apexY, 0]}>
{beams.map((b, i) => (
@@ -123,11 +194,33 @@ export default function CityAiCore({ aiActivity, positions, apps, settings }) {
))}
</group>
{/* Label above the apex */}
- <CityLabel position={[0, apexY + 2.6, 0]} fontSize={1.4} color={color} dayMix={dayMix} anchorX="center" anchorY="middle" font={PIXEL_FONT_URL} maxWidth={20}>
+ <CityLabel
+ position={[0, apexY + 4.25, 0]}
+ fontSize={1.15}
+ color={orbColor}
+ dayMix={dayMix}
+ anchorX="center"
+ anchorY="middle"
+ font={PIXEL_FONT_URL}
+ maxWidth={20}
+ renderOrder={40}
+ material-depthTest={false}
+ >
AI CORE
</CityLabel>
{core.busy && (
- <CityLabel position={[0, apexY + 1.5, 0]} fontSize={0.85} color="#94a3b8" dayMix={dayMix} anchorX="center" anchorY="middle" font={PIXEL_FONT_URL} maxWidth={20}>
+ <CityLabel
+ position={[0, apexY + 3.15, 0]}
+ fontSize={0.75}
+ color="#94a3b8"
+ dayMix={dayMix}
+ anchorX="center"
+ anchorY="middle"
+ font={PIXEL_FONT_URL}
+ maxWidth={20}
+ renderOrder={40}
+ material-depthTest={false}
+ >
{`${core.activeCount} ACTIVE`}
</CityLabel>
)}
diff --git a/client/src/components/city/CityBillboards.jsx b/client/src/components/city/CityBillboards.jsx
index fa929ea1cc..488869a911 100644
--- a/client/src/components/city/CityBillboards.jsx
+++ b/client/src/components/city/CityBillboards.jsx
@@ -110,20 +110,20 @@ function Billboard({ position, rotation, messages, color, width = 3.5, height =
return (
<group ref={groupRef} position={position} rotation={rotation}>
{/* Billboard background panel (front face only) */}
- <mesh>
+ <mesh renderOrder={20}>
<planeGeometry args={[width, height]} />
- <meshBasicMaterial color="#080820" transparent opacity={0.85} />
+ <meshBasicMaterial color="#111a36" transparent opacity={0.94} toneMapped={false} />
</mesh>
{/* Solid back blocker to prevent mirrored text bleed-through */}
- <mesh position={[0, 0, -0.01]}>
+ <mesh position={[0, 0, -0.01]} renderOrder={19}>
<planeGeometry args={[width, height]} />
- <meshBasicMaterial color="#080820" side={THREE.BackSide} />
+ <meshBasicMaterial color="#060a18" side={THREE.BackSide} toneMapped={false} />
</mesh>
{/* Neon border frame */}
- <mesh ref={borderRef} geometry={borderGeom} position={[0, 0, 0.01]}>
- <meshBasicMaterial color={color} transparent opacity={0.4} />
+ <mesh ref={borderRef} geometry={borderGeom} position={[0, 0, 0.01]} renderOrder={21}>
+ <meshBasicMaterial color={color} transparent opacity={0.7} toneMapped={false} />
</mesh>
{/* Top label */}
@@ -131,6 +131,9 @@ function Billboard({ position, rotation, messages, color, width = 3.5, height =
position={[0, height / 2 - 0.28, 0.02]}
fontSize={0.18}
color={color}
+ outlineWidth="5%"
+ outlineColor="#020617"
+ outlineOpacity={0.9}
anchorX="center"
anchorY="middle"
font={PIXEL_FONT_URL}
@@ -144,7 +147,10 @@ function Billboard({ position, rotation, messages, color, width = 3.5, height =
ref={textRef}
position={[0, -0.05, 0.02]}
fontSize={0.26}
- color="#e0e8ff"
+ color="#ffffff"
+ outlineWidth="6%"
+ outlineColor="#020617"
+ outlineOpacity={0.95}
anchorX="center"
anchorY="middle"
font={PIXEL_FONT_URL}
@@ -154,13 +160,13 @@ function Billboard({ position, rotation, messages, color, width = 3.5, height =
</Text>
{/* Accent line under label */}
- <mesh position={[0, height / 2 - 0.45, 0.01]}>
+ <mesh position={[0, height / 2 - 0.45, 0.01]} renderOrder={21}>
<planeGeometry args={[width - 0.3, 0.025]} />
- <meshBasicMaterial color={color} transparent opacity={0.6} />
+ <meshBasicMaterial color={color} transparent opacity={0.85} toneMapped={false} />
</mesh>
{/* Holographic scan line overlay */}
- <mesh position={[0, 0, 0.03]}>
+ <mesh position={[0, 0, 0.03]} renderOrder={22}>
<planeGeometry args={[width, height]} />
<shaderMaterial
ref={scanRef}
@@ -177,14 +183,15 @@ function Billboard({ position, rotation, messages, color, width = 3.5, height =
</mesh>
{/* Glow halo behind billboard */}
- <mesh ref={glowRef} position={[0, 0, -0.05]}>
+ <mesh ref={glowRef} position={[0, 0, -0.05]} renderOrder={18}>
<planeGeometry args={[width + 1.5, height + 1.0]} />
<meshBasicMaterial
color={color}
transparent
- opacity={0.18}
+ opacity={0.32}
blending={THREE.AdditiveBlending}
depthWrite={false}
+ toneMapped={false}
/>
</mesh>
diff --git a/client/src/components/city/CityDataRain.jsx b/client/src/components/city/CityDataRain.jsx
index f2ef8b6993..8d61afa0d5 100644
--- a/client/src/components/city/CityDataRain.jsx
+++ b/client/src/components/city/CityDataRain.jsx
@@ -1,6 +1,7 @@
import { useRef, useMemo } from 'react';
import { useFrame } from '@react-three/fiber';
import * as THREE from 'three';
+import { seededRand } from './cityConstants';
// Matrix-style cascading data columns falling through the sky
@@ -69,8 +70,7 @@ export default function CityDataRain() {
const bright = new Float32Array(total);
// Seeded random
- let s = 77;
- const rand = () => { s = (s * 16807 + 0) % 2147483647; return (s & 0x7fffffff) / 2147483647; };
+ const rand = seededRand(77);
for (let col = 0; col < columns; col++) {
const x = (rand() - 0.5) * 70;
diff --git a/client/src/components/city/CityEffects.jsx b/client/src/components/city/CityEffects.jsx
index fb3b8a7586..fdc1fc4434 100644
--- a/client/src/components/city/CityEffects.jsx
+++ b/client/src/components/city/CityEffects.jsx
@@ -164,6 +164,7 @@ export default function CityEffects({ settings }) {
// Daytime fades the heavy night atmospherics (bloom, grain, chromatic aberration,
// blue grade) so noon reads as clear daylight rather than a hazy dusk.
const dayMix = cityDayMix(settings);
+ const effectiveExposure = sceneExposure * (1 + (1 - dayMix) * 0.55);
const caBase = bloomStrength >= 0.6 ? 0.005 : 0.003;
useEffect(() => {
@@ -190,8 +191,8 @@ export default function CityEffects({ settings }) {
// Exposure pass — always added, enabled/disabled via ref to avoid
// recreating the composer when the slider is dragged
const exposurePass = new ShaderPass(ExposureShader);
- exposurePass.enabled = sceneExposure !== 1.0;
- exposurePass.uniforms.uExposure.value = sceneExposure;
+ exposurePass.enabled = effectiveExposure !== 1.0;
+ exposurePass.uniforms.uExposure.value = effectiveExposure;
exposurePassRef.current = exposurePass;
composer.addPass(exposurePass);
@@ -225,13 +226,13 @@ export default function CityEffects({ settings }) {
return () => {
composer.dispose();
};
- // eslint-disable-next-line react-hooks/exhaustive-deps -- sceneExposure intentionally omitted; updated via exposurePassRef in useFrame to avoid recreating the composer on slider drag
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- effectiveExposure intentionally omitted; updated via exposurePassRef in useFrame to avoid recreating the composer on slider drag
}, [gl, scene, camera, size.width, size.height, bloomEnabled, bloomStrength, chromaticAberration, filmGrain, colorGrading]);
useFrame(({ clock }) => {
if (exposurePassRef.current) {
- exposurePassRef.current.enabled = sceneExposure !== 1.0;
- exposurePassRef.current.uniforms.uExposure.value = sceneExposure;
+ exposurePassRef.current.enabled = effectiveExposure !== 1.0;
+ exposurePassRef.current.uniforms.uExposure.value = effectiveExposure;
}
if (grainPassRef.current) {
grainPassRef.current.uniforms.uTime.value = clock.getElapsedTime();
diff --git a/client/src/components/city/CityGalaxySky.jsx b/client/src/components/city/CityGalaxySky.jsx
new file mode 100644
index 0000000000..df3cd6da2f
--- /dev/null
+++ b/client/src/components/city/CityGalaxySky.jsx
@@ -0,0 +1,41 @@
+import { useEffect } from 'react';
+import { useLoader } from '@react-three/fiber';
+import * as THREE from 'three';
+import { cityDayMix } from './cityConstants';
+
+const GALAXY_TEXTURE = '/sky/city-night-galaxy-sphere.png';
+
+export default function CityGalaxySky({ settings }) {
+ const dayMix = cityDayMix(settings);
+ const nightOpacity = Math.max(0, Math.min(1, 1 - dayMix));
+ const texture = useLoader(THREE.TextureLoader, GALAXY_TEXTURE);
+
+ useEffect(() => {
+ texture.colorSpace = THREE.SRGBColorSpace;
+ texture.mapping = THREE.UVMapping;
+ texture.wrapS = THREE.RepeatWrapping;
+ texture.wrapT = THREE.ClampToEdgeWrapping;
+ texture.minFilter = THREE.LinearMipmapLinearFilter;
+ texture.magFilter = THREE.LinearFilter;
+ texture.anisotropy = 4;
+ texture.needsUpdate = true;
+ }, [texture]);
+
+ if (nightOpacity <= 0.01) return null;
+
+ return (
+ <mesh renderOrder={-1000} rotation={[0, -Math.PI * 0.18, 0]}>
+ <sphereGeometry args={[480, 64, 32]} />
+ <meshBasicMaterial
+ map={texture}
+ color="#9bbcff"
+ side={THREE.BackSide}
+ transparent={nightOpacity < 0.99}
+ opacity={nightOpacity}
+ depthTest
+ depthWrite={false}
+ toneMapped={false}
+ />
+ </mesh>
+ );
+}
diff --git a/client/src/components/city/CityGround.jsx b/client/src/components/city/CityGround.jsx
index 46852194a4..111bc8efc7 100644
--- a/client/src/components/city/CityGround.jsx
+++ b/client/src/components/city/CityGround.jsx
@@ -2,7 +2,7 @@ import { useRef, useMemo } from 'react';
import { useFrame } from '@react-three/fiber';
import { Grid } from '@react-three/drei';
import * as THREE from 'three';
-import { CITY_COLORS, getTimeOfDayPreset, cityDayMix, mixHex } from './cityConstants';
+import { CITY_COLORS, getTimeOfDayPreset, cityDayMix, mixHex, seededRand } from './cityConstants';
// Reflective puddle/wet-ground patches
function WetPatch({ position, size, color, dayMix = 0 }) {
@@ -83,8 +83,7 @@ export default function CityGround({ settings }) {
const puddles = useMemo(() => {
const result = [];
- let s = 137;
- const rand = () => { s = (s * 16807 + 0) % 2147483647; return (s & 0x7fffffff) / 2147483647; };
+ const rand = seededRand(137);
const colors = CITY_COLORS.neonAccents;
const count = reflectionsEnabled ? 40 : 20;
@@ -107,7 +106,7 @@ export default function CityGround({ settings }) {
<planeGeometry args={[120, 120]} />
<meshStandardMaterial
ref={groundMatRef}
- color="#0a0a20"
+ color={preset.groundColor ?? '#0a0a20'}
metalness={0.4}
roughness={0.7}
side={THREE.DoubleSide}
diff --git a/client/src/components/city/CityHud.jsx b/client/src/components/city/CityHud.jsx
index f872b40b10..19dee153db 100644
--- a/client/src/components/city/CityHud.jsx
+++ b/client/src/components/city/CityHud.jsx
@@ -39,8 +39,9 @@ function ControlsHint({ visible }) {
</div>
<div className="font-pixel text-[8px] text-gray-500 tracking-wide space-y-1">
<div>MOUSE: LOOK AROUND (CLICK TO LOCK)</div>
+ <div>WASD: MOVE · Q/E: DOWN/UP</div>
<div>SHIFT: SPRINT</div>
- <div>E: INTERACT WITH BUILDING</div>
+ <div>F: INTERACT WITH BUILDING</div>
<div>TAB: FLY OUT</div>
</div>
</div>
@@ -91,44 +92,6 @@ function HudCorner({ position = 'tl', color = 'cyan' }) {
);
}
-// Glitch text effect - brief visual corruption
-function GlitchTitle({ text, className }) {
- const [glitching, setGlitching] = useState(false);
- const intervalRef = useRef(null);
-
- useEffect(() => {
- intervalRef.current = setInterval(() => {
- if (Math.random() > 0.92) {
- setGlitching(true);
- setTimeout(() => setGlitching(false), 100 + Math.random() * 150);
- }
- }, 2000);
- return () => clearInterval(intervalRef.current);
- }, []);
-
- return (
- <div className={`relative ${className}`}>
- <span className={glitching ? 'opacity-0' : ''}>{text}</span>
- {glitching && (
- <>
- <span
- className="absolute inset-0 text-red-400/60"
- style={{ transform: 'translateX(2px)' }}
- >
- {text}
- </span>
- <span
- className="absolute inset-0 text-cyan-400/60"
- style={{ transform: 'translateX(-2px)' }}
- >
- {text}
- </span>
- </>
- )}
- </div>
- );
-}
-
function StatButton({ label, valueClass, value, onClick, title, prefix = null }) {
return (
<button
@@ -366,19 +329,8 @@ export default function CityHud({ cosStatus, cosAgents, agentMap, eventLogs, con
</div>
</div>
- {/* Top-center: CyberCity title with glitch effect */}
- <div className="absolute top-3 left-1/2 -translate-x-1/2 pointer-events-none">
- <GlitchTitle
- text="CITY"
- className="font-pixel text-cyan-400/50 text-sm tracking-[0.4em]"
- />
- <div className="font-pixel text-[8px] text-cyan-400/20 tracking-[0.2em] text-center mt-0.5">
- v{totalApps}.{activeApps}.{activeAgentCount}
- </div>
- </div>
-
{filter && onFilterChange && (
- <div className="absolute top-14 left-1/2 -translate-x-1/2">
+ <div className="absolute top-3 left-1/2 -translate-x-1/2">
<CityFilterBar
filter={filter}
onChange={onFilterChange}
diff --git a/client/src/components/city/CityLandscape.jsx b/client/src/components/city/CityLandscape.jsx
new file mode 100644
index 0000000000..2dc15e44e0
--- /dev/null
+++ b/client/src/components/city/CityLandscape.jsx
@@ -0,0 +1,168 @@
+import { useMemo } from 'react';
+import * as THREE from 'three';
+import { CITY_COLORS, cityDayMix, mixHex, seededRand, smoothstepRange } from './cityConstants';
+
+const TERRAIN_SIZE = 2400;
+const MOUNTAIN_INNER_RADIUS = 560;
+const MOUNTAIN_RADIUS_SPREAD = 190;
+
+const TERRAIN_VERT = `
+ varying vec2 vUv;
+ varying vec3 vWorldPosition;
+ void main() {
+ vUv = uv;
+ vec4 worldPos = modelMatrix * vec4(position, 1.0);
+ vWorldPosition = worldPos.xyz;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
+ }
+`;
+
+const TERRAIN_FRAG = `
+ uniform vec3 uInner;
+ uniform vec3 uMeadow;
+ uniform vec3 uRidge;
+ uniform vec3 uAccent;
+ uniform float uDayMix;
+ varying vec2 vUv;
+ varying vec3 vWorldPosition;
+
+ float hash(vec2 p) {
+ return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
+ }
+
+ float noise(vec2 p) {
+ vec2 i = floor(p);
+ vec2 f = fract(p);
+ f = f * f * (3.0 - 2.0 * f);
+ float a = hash(i);
+ float b = hash(i + vec2(1.0, 0.0));
+ float c = hash(i + vec2(0.0, 1.0));
+ float d = hash(i + vec2(1.0, 1.0));
+ return mix(mix(a, b, f.x), mix(c, d, f.x), f.y);
+ }
+
+ void main() {
+ float dist = length(vWorldPosition.xz);
+ float meadowMix = smoothstep(42.0, 86.0, dist);
+ float ridgeMix = smoothstep(260.0, 760.0, dist);
+ float n = noise(vWorldPosition.xz * 0.035);
+ float largeN = noise(vWorldPosition.xz * 0.006);
+ vec3 color = mix(uInner, uMeadow, meadowMix);
+ color = mix(color, uRidge, ridgeMix * mix(0.26, 0.42, uDayMix));
+ color += (n - 0.5) * mix(0.025, 0.06, uDayMix);
+ color += (largeN - 0.5) * mix(0.025, 0.045, uDayMix);
+
+ // Keep a faint themed tech trace near the city, but let nature dominate outside.
+ float cityTrace = (1.0 - meadowMix) * 0.08 * (1.0 - uDayMix * 0.65);
+ color = mix(color, uAccent, cityTrace);
+
+ gl_FragColor = vec4(color, 1.0);
+ }
+`;
+
+function TerrainPlane({ dayMix }) {
+ const material = useMemo(() => new THREE.ShaderMaterial({
+ vertexShader: TERRAIN_VERT,
+ fragmentShader: TERRAIN_FRAG,
+ uniforms: {
+ uInner: { value: new THREE.Color(mixHex('#202426', '#686d68', dayMix)) },
+ uMeadow: { value: new THREE.Color(mixHex('#172719', '#6f8758', dayMix)) },
+ uRidge: { value: new THREE.Color(mixHex('#111827', '#8d937f', dayMix)) },
+ uAccent: { value: new THREE.Color(CITY_COLORS.ground) },
+ uDayMix: { value: dayMix },
+ },
+ side: THREE.DoubleSide,
+ depthWrite: true,
+ }), [dayMix]);
+
+ return (
+ <mesh
+ rotation={[-Math.PI / 2, 0, 0]}
+ position={[0, -0.08, 0]}
+ material={material}
+ frustumCulled={false}
+ >
+ <planeGeometry args={[TERRAIN_SIZE, TERRAIN_SIZE, 1, 1]} />
+ </mesh>
+ );
+}
+
+function Mountain({ mountain, dayMix }) {
+ const geometry = useMemo(() => {
+ const geom = new THREE.ConeGeometry(mountain.radius, mountain.height, mountain.sides, 6);
+ const position = geom.getAttribute('position');
+ const colors = [];
+ const base = new THREE.Color(mixHex('#111827', '#9aa794', dayMix));
+ const lit = new THREE.Color(mixHex('#243044', '#dfe7d8', dayMix));
+ const snow = new THREE.Color(mixHex('#64748b', '#f4f7f0', dayMix));
+
+ for (let i = 0; i < position.count; i += 1) {
+ const y = (position.getY(i) + mountain.height / 2) / mountain.height;
+ const shoulder = smoothstepRange(0.22, 0.88, y);
+ const snowMix = smoothstepRange(0.68, 0.95, y) * mountain.snow;
+ const color = base.clone()
+ .lerp(lit, Math.min(1, mountain.light + shoulder * 0.28))
+ .lerp(snow, snowMix);
+ colors.push(color.r, color.g, color.b);
+ }
+
+ geom.setAttribute('color', new THREE.Float32BufferAttribute(colors, 3));
+ geom.computeVertexNormals();
+ return geom;
+ }, [dayMix, mountain.height, mountain.light, mountain.radius, mountain.sides, mountain.snow]);
+
+ return (
+ <group position={mountain.position} rotation={[0, mountain.rotation, 0]} scale={mountain.scale}>
+ <mesh position={[0, mountain.height / 2 - 0.08, 0]}>
+ <primitive attach="geometry" object={geometry} />
+ <meshStandardMaterial
+ vertexColors
+ roughness={0.92}
+ metalness={0}
+ depthWrite
+ />
+ </mesh>
+ </group>
+ );
+}
+
+export default function CityLandscape({ settings }) {
+ const dayMix = cityDayMix(settings);
+
+ const mountains = useMemo(() => {
+ const result = [];
+ const rand = seededRand(3187);
+ const count = 28;
+
+ for (let i = 0; i < count; i++) {
+ const angle = (i / count) * Math.PI * 2 + (rand() - 0.5) * 0.16;
+ const radius = MOUNTAIN_INNER_RADIUS + rand() * MOUNTAIN_RADIUS_SPREAD;
+ const height = 42 + rand() * 66;
+ const base = 72 + rand() * 86;
+ result.push({
+ id: `mountain-${i}`,
+ position: [Math.cos(angle) * radius, 0, Math.sin(angle) * radius],
+ rotation: -angle + Math.PI / 2,
+ height,
+ radius: base,
+ sides: rand() > 0.45 ? 4 : 5,
+ light: 0.18 + rand() * 0.34,
+ snow: rand() > 0.35 ? 1 : 0.35,
+ scale: [1.1 + rand() * 1.8, 1, 0.2 + rand() * 0.22],
+ });
+ }
+
+ return result;
+ }, []);
+
+ return (
+ <group>
+ <TerrainPlane dayMix={dayMix} />
+ <group>
+ {mountains.map((mountain) => (
+ <Mountain key={mountain.id} mountain={mountain} dayMix={dayMix} />
+ ))}
+ </group>
+ </group>
+ );
+}
diff --git a/client/src/components/city/CityLights.jsx b/client/src/components/city/CityLights.jsx
index 284a756505..20432db86c 100644
--- a/client/src/components/city/CityLights.jsx
+++ b/client/src/components/city/CityLights.jsx
@@ -1,7 +1,7 @@
import { useRef } from 'react';
import { useFrame } from '@react-three/fiber';
import * as THREE from 'three';
-import { getTimeOfDayPreset } from './cityConstants';
+import { CITY_COLORS, getTimeOfDayPreset } from './cityConstants';
// Animated accent light that slowly shifts color, with reactive brightness
function AnimatedLight({ position, baseColor, baseIntensity, distance, shiftRange = 0.1, speed = 0.5, brightnessRef, neonScaleRef }) {
@@ -86,6 +86,7 @@ export default function CityLights({ settings }) {
const timeOfDay = settings?.timeOfDay ?? 'sunset';
const skyTheme = settings?.skyTheme ?? 'cyberpunk';
const preset = getTimeOfDayPreset(timeOfDay, skyTheme);
+ const nightGlow = 1 - Math.min(1, preset.daylightFactor ?? 0);
// Neon scale: dim neon point lights during daytime (30% at noon, 100% at night)
const neonScaleRef = useRef(1);
@@ -136,6 +137,10 @@ export default function CityLights({ settings }) {
<ReactivePointLight position={[0, 30, 0]} baseIntensity={1.2} color="#06b6d4" distance={100} brightnessRef={brightnessRef} neonScaleRef={neonScaleRef} />
{/* Secondary overhead fill - broad white/blue */}
<ReactivePointLight position={[0, 20, 10]} baseIntensity={0.5} color="#4488cc" distance={90} brightnessRef={brightnessRef} neonScaleRef={neonScaleRef} />
+ {/* Broad nighttime city glow — signage bounce + moonlit haze, faded in daylight */}
+ <ReactivePointLight position={[0, 16, 0]} baseIntensity={1.8 * nightGlow} color={CITY_COLORS.ground} distance={150} brightnessRef={brightnessRef} neonScaleRef={neonScaleRef} />
+ <ReactivePointLight position={[-28, 10, 24]} baseIntensity={1.05 * nightGlow} color="#ec4899" distance={118} brightnessRef={brightnessRef} neonScaleRef={neonScaleRef} />
+ <ReactivePointLight position={[30, 12, -22]} baseIntensity={1.1 * nightGlow} color="#60a5fa" distance={120} brightnessRef={brightnessRef} neonScaleRef={neonScaleRef} />
{/* Magenta accent from left - animated color shift */}
<AnimatedLight position={[-20, 12, -15]} baseColor="#ec4899" baseIntensity={0.7} distance={60} speed={0.3} shiftRange={0.15} brightnessRef={brightnessRef} neonScaleRef={neonScaleRef} />
{/* Blue accent from right - animated shift */}
diff --git a/client/src/components/city/CityScanlines.jsx b/client/src/components/city/CityScanlines.jsx
index 452d8d929b..29e9edf028 100644
--- a/client/src/components/city/CityScanlines.jsx
+++ b/client/src/components/city/CityScanlines.jsx
@@ -40,7 +40,7 @@ export default function CityScanlines({ settings, crt }) {
<div
className="absolute inset-0 pointer-events-none z-10"
style={{
- background: 'radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.5) 100%)',
+ background: 'radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.35) 100%)',
}}
/>
)}
diff --git a/client/src/components/city/CityScene.jsx b/client/src/components/city/CityScene.jsx
index ce26bd1205..76313f17b5 100644
--- a/client/src/components/city/CityScene.jsx
+++ b/client/src/components/city/CityScene.jsx
@@ -37,10 +37,13 @@ import CityEffects from './CityEffects';
import CityClouds from './CityClouds';
import CitySignalBeacons from './CitySignalBeacons';
import CitySky from './CitySky';
+import CityGalaxySky from './CityGalaxySky';
+import CityLandscape from './CityLandscape';
import CityEnergyOverlay from './CityEnergyOverlay';
import PlayerController from './PlayerController';
import CameraTransition from './CameraTransition';
import CityPhotoCamera from './CityPhotoCamera';
+import { cityDayMix } from './cityConstants';
export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus, reviewCounts, instances, backupStatus, cosTasks, healthMetrics, voiceState, aiActivity, productivityData, activityCalendar, goals, character, chronotype, memoryGraph, inboxDepth, jiraTickets, photoMode, photoPresetId, onPhotoCaptureReady, settings, playSfx, keysRef, dimmedAppIds, background }) {
const [positions, setPositions] = useState(null);
@@ -86,6 +89,7 @@ export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus,
const totalCount = apps.filter(a => !a.archived).length;
const dpr = settings?.dpr || [1, 1.5];
+ const showGradientBackground = cityDayMix(settings) > 0.5;
return (
<Canvas
@@ -97,16 +101,21 @@ export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus,
// WebGL context-creation attribute, so it can't be toggled at runtime without recreating
// the renderer (which would flash the scene) — we accept it always-on. The cost on modern
// GPUs is a small per-frame copy; negligible against this scene's particle/bloom load.
- gl={{ antialias: true, preserveDrawingBuffer: true }}
+ gl={{ antialias: true, preserveDrawingBuffer: true, alpha: false }}
>
+ {showGradientBackground && <color attach="background" args={[background || '#030308']} />}
+ {/* Mount the galaxy dome only at night — keeps its 2.8MB texture from being
+ fetched/decoded in full daylight, where it's fully faded out anyway. */}
+ {!showGradientBackground && <CityGalaxySky settings={settings} />}
<CitySky settings={settings} />
<CityClouds settings={settings} />
<CityLights settings={settings} />
+ <CityLandscape settings={settings} />
<CityEnergyOverlay chronotype={chronotype} settings={settings} />
<CityStarfield settings={settings} />
<CityShootingStars playSfx={playSfx} settings={settings} />
{!explorationMode && <CityCelestial settings={settings} />}
- <CitySkyline />
+ <CitySkyline settings={settings} />
<CityFederationHorizon instances={instances} settings={settings} />
<CityBackupVault backupStatus={backupStatus} settings={settings} />
<CityTaskQueue cosTasks={cosTasks} settings={settings} />
diff --git a/client/src/components/city/CitySky.jsx b/client/src/components/city/CitySky.jsx
index d5a60d6cca..2c56bb2be5 100644
--- a/client/src/components/city/CitySky.jsx
+++ b/client/src/components/city/CitySky.jsx
@@ -36,9 +36,11 @@ const SkyDomeShader = {
uniform vec3 uMidSky;
uniform vec3 uHorizonHigh;
uniform vec3 uHorizonLow;
+ uniform vec3 uBelowHorizon;
uniform vec3 uSunDirection;
uniform float uSunIntensity;
uniform float uIsMoon;
+ uniform float uOpacity;
uniform float uTime;
varying vec3 vWorldPosition;
@@ -87,11 +89,13 @@ const SkyDomeShader = {
float n = noise(dir.xz * 3.0 + uTime * 0.02) * 0.03;
color += n;
- // Below horizon: fade to dark
- float belowFade = smoothstep(0.0, -0.05, dir.y);
- color = mix(color, vec3(0.01, 0.01, 0.03), belowFade);
+ // Below horizon: fade to dark. smoothstep requires edge0 < edge1;
+ // reverse the result instead of reversing the edges, which is undefined
+ // in GLSL and can blow the sky out on some WebGL implementations.
+ float belowFade = 1.0 - smoothstep(-0.05, 0.0, dir.y);
+ color = mix(color, uBelowHorizon, belowFade);
- gl_FragColor = vec4(color, 1.0);
+ gl_FragColor = vec4(color, uOpacity);
}
`,
};
@@ -113,16 +117,20 @@ const getPresetColors = (name, skyTheme) => {
const cacheKey = `${skyTheme}:${name}:${accent}`;
if (!presetColors[cacheKey]) {
const p = getTimeOfDayPreset(name, skyTheme);
+ const isBrightDay = (p.daylightFactor ?? 0) >= 0.75;
+ const belowHorizon = isBrightDay ? p.horizonLow : '#03030a';
presetColors[cacheKey] = {
zenith: new THREE.Color(tintTowardAccent(p.zenith, 0.16)),
midSky: new THREE.Color(tintTowardAccent(p.midSky, 0.12)),
horizonHigh: new THREE.Color(p.horizonHigh),
horizonLow: new THREE.Color(p.horizonLow),
+ belowHorizon: new THREE.Color(belowHorizon),
sunCore: new THREE.Color(p.sunCore),
sunGlow: new THREE.Color(p.sunGlow),
sunLight: new THREE.Color(p.sunLight),
hour: p.hour,
sunIntensity: p.sunIntensity,
+ overlayOpacity: isBrightDay ? 1.0 : 0.26,
sunScale: p.sunScale,
isMoon: p.isMoon,
};
@@ -213,12 +221,17 @@ export default function CitySky({ settings }) {
uMidSky: { value: preset.midSky.clone() },
uHorizonHigh: { value: preset.horizonHigh.clone() },
uHorizonLow: { value: preset.horizonLow.clone() },
+ uBelowHorizon: { value: preset.belowHorizon.clone() },
uSunDirection: { value: new THREE.Vector3(...initPos).normalize() },
uSunIntensity: { value: preset.sunIntensity },
uIsMoon: { value: preset.isMoon ? 1.0 : 0.0 },
+ uOpacity: { value: preset.overlayOpacity },
uTime: { value: 0 },
},
side: THREE.BackSide,
+ transparent: true,
+ opacity: preset.overlayOpacity,
+ blending: THREE.NormalBlending,
depthWrite: false,
});
}, []);
@@ -255,11 +268,14 @@ export default function CitySky({ settings }) {
lerpColor(skyMaterial.uniforms.uMidSky.value, skyMaterial.uniforms.uMidSky.value, preset.midSky, lerpFactor);
lerpColor(skyMaterial.uniforms.uHorizonHigh.value, skyMaterial.uniforms.uHorizonHigh.value, preset.horizonHigh, lerpFactor);
lerpColor(skyMaterial.uniforms.uHorizonLow.value, skyMaterial.uniforms.uHorizonLow.value, preset.horizonLow, lerpFactor);
+ lerpColor(skyMaterial.uniforms.uBelowHorizon.value, skyMaterial.uniforms.uBelowHorizon.value, preset.belowHorizon, lerpFactor);
// Update sun direction directly from arc position
skyMaterial.uniforms.uSunDirection.value.copy(bodyDir);
skyMaterial.uniforms.uSunIntensity.value += (preset.sunIntensity - skyMaterial.uniforms.uSunIntensity.value) * lerpFactor;
skyMaterial.uniforms.uIsMoon.value += ((preset.isMoon ? 1.0 : 0.0) - skyMaterial.uniforms.uIsMoon.value) * lerpFactor;
+ skyMaterial.uniforms.uOpacity.value += (preset.overlayOpacity - skyMaterial.uniforms.uOpacity.value) * lerpFactor;
+ skyMaterial.opacity = skyMaterial.uniforms.uOpacity.value;
skyMaterial.uniforms.uTime.value = clock.getElapsedTime();
// Move celestial body mesh
diff --git a/client/src/components/city/CitySkyline.jsx b/client/src/components/city/CitySkyline.jsx
index 22a92d6463..dc3723bf8d 100644
--- a/client/src/components/city/CitySkyline.jsx
+++ b/client/src/components/city/CitySkyline.jsx
@@ -1,5 +1,6 @@
import { useMemo } from 'react';
import * as THREE from 'three';
+import { cityDayMix, seededRand } from './cityConstants';
// Distant cyberpunk skyline silhouettes with neon trim
// Creates a ring of faint skyscraper outlines around the city perimeter
@@ -18,11 +19,12 @@ const SKYLINE_FRAG = `
uniform vec3 uColor;
uniform vec3 uAccent;
uniform float uMaxHeight;
+ uniform float uDayMix;
varying vec2 vUv;
varying float vHeight;
void main() {
// Dark body that fades near top
- float bodyAlpha = 0.15 * (1.0 - vUv.y * 0.5);
+ float bodyAlpha = mix(0.15, 0.035, uDayMix) * (1.0 - vUv.y * 0.5);
// Window dots - grid of small lit windows
float cellX = fract(vUv.x * 8.0);
@@ -33,18 +35,21 @@ const SKYLINE_FRAG = `
float lit = step(0.55, fract(sin(floor(vUv.x * 8.0) * 127.1 + floor(vUv.y * 20.0) * 311.7) * 43758.5453));
window *= lit;
- vec3 color = mix(vec3(0.02, 0.02, 0.05), uAccent, window * 0.5);
- float alpha = bodyAlpha + window * 0.15;
+ vec3 nightBase = vec3(0.02, 0.02, 0.05);
+ vec3 dayBase = vec3(0.58, 0.70, 0.78);
+ vec3 color = mix(nightBase, dayBase, uDayMix);
+ color = mix(color, uAccent, window * mix(0.5, 0.15, uDayMix));
+ float alpha = bodyAlpha + window * mix(0.15, 0.035, uDayMix);
// Neon trim at top edge
float topLine = smoothstep(0.98, 1.0, vUv.y);
color = mix(color, uAccent, topLine);
- alpha = max(alpha, topLine * 0.4);
+ alpha = max(alpha, topLine * mix(0.4, 0.12, uDayMix));
// Neon trim at bottom
float bottomLine = smoothstep(0.02, 0.0, vUv.y);
color = mix(color, uColor, bottomLine);
- alpha = max(alpha, bottomLine * 0.3);
+ alpha = max(alpha, bottomLine * mix(0.3, 0.08, uDayMix));
// Fade with distance (atmospheric perspective)
alpha *= 0.7;
@@ -54,7 +59,7 @@ const SKYLINE_FRAG = `
`;
// Create a single skyline building silhouette
-function DistantBuilding({ position, width, height, color, accent }) {
+function DistantBuilding({ position, width, height, color, accent, dayMix }) {
const colorVec = useMemo(() => new THREE.Color(color), [color]);
const accentVec = useMemo(() => new THREE.Color(accent), [accent]);
@@ -68,6 +73,7 @@ function DistantBuilding({ position, width, height, color, accent }) {
uColor: { value: colorVec },
uAccent: { value: accentVec },
uMaxHeight: { value: height },
+ uDayMix: { value: dayMix },
}}
transparent
side={THREE.DoubleSide}
@@ -77,15 +83,15 @@ function DistantBuilding({ position, width, height, color, accent }) {
);
}
-export default function CitySkyline() {
+export default function CitySkyline({ settings }) {
+ const dayMix = cityDayMix(settings);
const buildings = useMemo(() => {
const result = [];
const colors = ['#06b6d4', '#ec4899', '#8b5cf6', '#3b82f6', '#22c55e', '#f97316'];
const accents = ['#06b6d4', '#ec4899', '#8b5cf6', '#3b82f6', '#f43f5e', '#a855f7'];
// Seeded random for consistent skyline
- let s = 42;
- const rand = () => { s = (s * 16807 + 0) % 2147483647; return (s & 0x7fffffff) / 2147483647; };
+ const rand = seededRand(42);
const radius = 55;
const count = 60;
@@ -123,6 +129,7 @@ export default function CitySkyline() {
height={b.height}
color={b.color}
accent={b.accent}
+ dayMix={dayMix}
/>
))}
</group>
diff --git a/client/src/components/city/PlayerController.jsx b/client/src/components/city/PlayerController.jsx
index 18bce920ce..dd0ed1ba22 100644
--- a/client/src/components/city/PlayerController.jsx
+++ b/client/src/components/city/PlayerController.jsx
@@ -1,16 +1,18 @@
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 WALK_SPEED = 10;
+const SPRINT_SPEED = 20;
+const VERTICAL_SPEED = 8;
const BUILDING_EXCLUSION_RADIUS = 3.5;
const PROXIMITY_DISTANCE = 6;
-const WORLD_BOUND = 55;
-const HEAD_HEIGHT = 1.4;
+const WORLD_BOUND = 180;
+const EYE_HEIGHT = 1.6;
+const MAX_CAMERA_HEIGHT = 160;
+const BUILDING_FLYOVER_HEIGHT = 12; // above this the player clears rooftops, so skip collision
+const MOUSE_SENSITIVITY = 0.002;
+const PITCH_LIMIT = Math.PI / 2 - 0.02;
export default function PlayerController({
keysRef,
@@ -23,13 +25,10 @@ export default function PlayerController({
const { camera, gl } = useThree();
const playerPos = useRef(new THREE.Vector3(0, 0, 0));
const yawRef = useRef(0); // Facing toward city center (-Z direction)
- const pitchRef = useRef(0.3);
- const isMovingRef = useRef(false);
- const facingAngleRef = useRef(0);
+ const pitchRef = useRef(0);
const lastSpawnRef = useRef(null);
const pointerLockedRef = useRef(false);
const proximityAppRef = useRef(null);
- const avatarGroupRef = useRef();
// Initialize spawn position
useEffect(() => {
@@ -42,8 +41,9 @@ export default function PlayerController({
positions?.forEach((pos) => {
if (pos.z > maxZ) maxZ = pos.z;
});
- playerPos.current.set(0, 0, maxZ + 8);
+ playerPos.current.set(0, EYE_HEIGHT, maxZ + 8);
yawRef.current = 0; // Forward = (0, 0, -1), facing toward city center
+ pitchRef.current = 0;
}
}, [active, positions]);
@@ -59,9 +59,9 @@ export default function PlayerController({
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.1, Math.min(1.2, pitchRef.current));
+ yawRef.current -= e.movementX * MOUSE_SENSITIVITY;
+ pitchRef.current -= e.movementY * MOUSE_SENSITIVITY;
+ pitchRef.current = Math.max(-PITCH_LIMIT, Math.min(PITCH_LIMIT, pitchRef.current));
}, [active]);
useEffect(() => {
@@ -90,11 +90,11 @@ export default function PlayerController({
};
}, [active, gl.domElement, handleClick, handlePointerLockChange, handleMouseMove]);
- // E key for building interaction
+ // F key for building interaction. E is vertical up in free-look controls.
useEffect(() => {
if (!active) return;
const handleKeyDown = (e) => {
- if (e.key.toLowerCase() === 'e' && proximityAppRef.current) {
+ if (e.key.toLowerCase() === 'f' && proximityAppRef.current) {
onBuildingClick?.(proximityAppRef.current);
}
};
@@ -108,6 +108,7 @@ export default function PlayerController({
const keys = keysRef.current;
const isSprinting = keys.has('shift');
const speed = (isSprinting ? SPRINT_SPEED : WALK_SPEED) * delta;
+ const verticalSpeed = (isSprinting ? SPRINT_SPEED : VERTICAL_SPEED) * delta;
// Movement direction relative to camera yaw
const forward = new THREE.Vector3(-Math.sin(yawRef.current), 0, -Math.cos(yawRef.current));
@@ -119,45 +120,47 @@ export default function PlayerController({
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;
+ const hasHorizontal = moveDir.lengthSq() > 0;
+ const verticalDir = (keys.has('e') ? 1 : 0) - (keys.has('q') ? 1 : 0);
+ const moving = hasHorizontal || verticalDir !== 0;
if (moving) {
- moveDir.normalize().multiplyScalar(speed);
+ if (hasHorizontal) moveDir.normalize().multiplyScalar(speed);
const nextPos = playerPos.current.clone().add(moveDir);
- nextPos.y = 0;
+ nextPos.y += verticalDir * verticalSpeed;
- // Update facing angle to movement direction
- facingAngleRef.current = Math.atan2(moveDir.x, moveDir.z);
-
- // Collision detection with buildings
+ // Collision detection with buildings — skipped above rooftop height so the
+ // player can fly over the city.
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 (hasHorizontal && nextPos.y < BUILDING_FLYOVER_HEIGHT) {
+ 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.y = Math.max(EYE_HEIGHT, Math.min(MAX_CAMERA_HEIGHT, nextPos.y));
nextPos.z = Math.max(-WORLD_BOUND, Math.min(WORLD_BOUND, nextPos.z));
playerPos.current.copy(nextPos);
}
@@ -168,8 +171,9 @@ export default function PlayerController({
let nearestDist = PROXIMITY_DISTANCE;
positions?.forEach((pos, appId) => {
const dx = playerPos.current.x - pos.x;
+ const dy = playerPos.current.y - ((pos.height ?? 4) * 0.5);
const dz = playerPos.current.z - pos.z;
- const dist = Math.sqrt(dx * dx + dz * dz);
+ const dist = Math.sqrt(dx * dx + dy * dy + dz * dz);
if (dist < nearestDist) {
nearestDist = dist;
const app = apps?.find(a => a.id === appId);
@@ -182,39 +186,17 @@ export default function PlayerController({
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 = Math.max(0.5, 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.position.copy(playerPos.current);
+ const lookDir = new THREE.Vector3(
+ -Math.sin(yawRef.current) * Math.cos(pitchRef.current),
+ Math.sin(pitchRef.current),
+ -Math.cos(yawRef.current) * Math.cos(pitchRef.current),
);
+ const lookTarget = playerPos.current.clone().add(lookDir);
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
- isMovingRef={isMovingRef}
- facingAngleRef={facingAngleRef}
- />
- </group>
- );
+ return null;
}
diff --git a/client/src/components/city/cityConstants.js b/client/src/components/city/cityConstants.js
index e52bb42545..88f4199130 100644
--- a/client/src/components/city/cityConstants.js
+++ b/client/src/components/city/cityConstants.js
@@ -78,25 +78,27 @@ export const CITY_COLORS = {
ambientIntensity: 0.35,
},
sunset: {
- hour: 18,
- zenith: '#050520',
- midSky: '#1a0a2e',
- horizonHigh: '#ff4060',
- horizonLow: '#ff8040',
- sunCore: '#ffaa44',
- sunGlow: '#ff6080',
- sunLight: '#ffccaa',
- sunIntensity: 1.5,
- sunScale: 1.0,
- isMoon: false,
+ // Theme-night preset: moonlit cyber-night, not blackout. The city should
+ // feel nocturnal while still being readable from moonlight and neon bounce.
+ hour: 12,
+ zenith: '#071329',
+ midSky: '#0b1f38',
+ horizonHigh: '#251445',
+ horizonLow: '#080917',
+ sunCore: '#d9ecff',
+ sunGlow: '#7bbcff',
+ sunLight: '#8fc7ff',
+ sunIntensity: 1.1,
+ sunScale: 0.72,
+ isMoon: true,
daylightFactor: 0.2,
- groundColor: '#1a1830',
+ groundColor: '#283246',
groundRoughness: 0.75,
- hemiSkyColor: '#ff6644',
- hemiGroundColor: '#151520',
- hemiIntensity: 0.4,
- ambientColor: '#1a1a3a',
- ambientIntensity: 0.2,
+ hemiSkyColor: '#5c8ac6',
+ hemiGroundColor: '#121626',
+ hemiIntensity: 1.1,
+ ambientColor: '#1b2a4a',
+ ambientIntensity: 0.55,
},
midnight: {
hour: 0,
@@ -402,12 +404,23 @@ export const tintStructure = (hex) => tintTowardAccent(hex, 0.22);
// GLSL-style smoothstep with an edge remap (distinct from the plain Hermite
// smoothstep(t) in utils/easing.js — different arity, kept local on purpose).
-const smoothstepRange = (a, b, x) => {
+export const smoothstepRange = (a, b, x) => {
if (a === b) return x < a ? 0 : 1;
const t = Math.max(0, Math.min(1, (x - a) / (b - a)));
return t * t * (3 - 2 * t);
};
+// Deterministic Park-Miller LCG. Returns a () => [0,1) generator seeded from an
+// integer — the shared form of the inline seeded-random used across city scenery
+// so a given seed always yields the same building/terrain layout.
+export const seededRand = (seed) => {
+ let s = seed;
+ return () => {
+ s = (s * 16807) % 2147483647;
+ return (s & 0x7fffffff) / 2147483647;
+ };
+};
+
// The city renders just two times of day — day and night — and follows the active
// theme's mode by default ('auto'). The user can still force 'day'/'night'. Legacy
// stored values (sunrise/noon/sunset/midnight) are treated as 'auto' so existing
diff --git a/client/src/hooks/useCitySettings.js b/client/src/hooks/useCitySettings.js
index 192036c9fb..d789d08d4d 100644
--- a/client/src/hooks/useCitySettings.js
+++ b/client/src/hooks/useCitySettings.js
@@ -1,6 +1,9 @@
-import { useState, useCallback } from 'react';
+import { useEffect, useState, useCallback } from 'react';
-const STORAGE_KEY = 'portos-city-settings';
+// Exported so useTheme can reset the city's time-of-day override without
+// re-declaring these magic strings (a typo there would silently break the reset).
+export const STORAGE_KEY = 'portos-city-settings';
+export const TIME_OF_DAY_AUTO_EVENT = 'portos-city-timeofday-auto';
const QUALITY_PRESETS = {
low: {
@@ -68,6 +71,19 @@ export { QUALITY_PRESETS };
export default function useCitySettings() {
const [settings, setSettings] = useState(loadSettings);
+ useEffect(() => {
+ const handleTimeOfDayAuto = () => {
+ setSettings(prev => {
+ if (prev.timeOfDay === 'auto') return prev;
+ const next = { ...prev, timeOfDay: 'auto' };
+ localStorage.setItem(STORAGE_KEY, JSON.stringify(next));
+ return next;
+ });
+ };
+ window.addEventListener(TIME_OF_DAY_AUTO_EVENT, handleTimeOfDayAuto);
+ return () => window.removeEventListener(TIME_OF_DAY_AUTO_EVENT, handleTimeOfDayAuto);
+ }, []);
+
const updateSetting = useCallback((key, value) => {
setSettings(prev => {
// If changing quality preset, apply bulk changes
diff --git a/client/src/hooks/useTheme.js b/client/src/hooks/useTheme.js
index 78ceb5b974..858aabc882 100644
--- a/client/src/hooks/useTheme.js
+++ b/client/src/hooks/useTheme.js
@@ -6,6 +6,10 @@ import {
getPairedThemeId,
normalizeThemeId,
} from '../themes/portosThemes';
+import {
+ STORAGE_KEY as CITY_SETTINGS_KEY,
+ TIME_OF_DAY_AUTO_EVENT as CITY_TIME_OF_DAY_AUTO_EVENT,
+} from './useCitySettings';
const STORAGE_KEY = 'portos-theme';
@@ -31,6 +35,17 @@ const loadTheme = () => {
return normalized;
};
+const resetCityTimeOfDayOverride = () => {
+ try {
+ const raw = localStorage.getItem(CITY_SETTINGS_KEY);
+ const citySettings = raw ? JSON.parse(raw) : {};
+ localStorage.setItem(CITY_SETTINGS_KEY, JSON.stringify({ ...citySettings, timeOfDay: 'auto' }));
+ window.dispatchEvent(new Event(CITY_TIME_OF_DAY_AUTO_EVENT));
+ } catch {
+ // Theme switching should still work if city settings are unavailable/corrupt.
+ }
+};
+
export default function useTheme() {
const [themeId, setThemeId] = useState(() => {
const id = loadTheme();
@@ -48,6 +63,7 @@ export default function useTheme() {
const currentSaved = normalizeThemeId(localStorage.getItem(STORAGE_KEY));
if (serverTheme && serverTheme !== currentSaved) {
localStorage.setItem(STORAGE_KEY, serverTheme);
+ resetCityTimeOfDayOverride();
applyTheme(serverTheme);
setThemeId(serverTheme);
}
@@ -59,6 +75,7 @@ export default function useTheme() {
userPickedRef.current = true;
const normalized = normalizeThemeId(id);
localStorage.setItem(STORAGE_KEY, normalized);
+ resetCityTimeOfDayOverride();
applyTheme(normalized);
setThemeId(normalized);
fetch('/api/settings', {