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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat(city): add sky theme selector with dreamworld mode
Ilya Eivy6b2776f9708a
diff --git a/client/src/components/city/CityCelestial.jsx b/client/src/components/city/CityCelestial.jsxindex ef43beadf4..451e9b5a78 100644--- a/client/src/components/city/CityCelestial.jsx+++ b/client/src/components/city/CityCelestial.jsx@@ -1,7 +1,7 @@import { useRef, useMemo } from 'react';import { useFrame } from '@react-three/fiber';import * as THREE from 'three';-import { CITY_COLORS } from './cityConstants';+import { CITY_COLORS, getTimeOfDayPreset } from './cityConstants';// Orbital ring line geometryfunction OrbitalRing({ radius, tilt, color, opacity = 0.15, nightFactorRef }) {@@ -69,7 +69,8 @@ export default function CityCelestial({ settings }) {const nightFactorRef = useRef(1);const timeOfDay = settings?.timeOfDay ?? 'sunset';- const preset = CITY_COLORS.timeOfDay[timeOfDay] ?? CITY_COLORS.timeOfDay.sunset;+ const skyTheme = settings?.skyTheme ?? 'cyberpunk';+ const preset = getTimeOfDayPreset(timeOfDay, skyTheme);const targetDaylight = preset.daylightFactor ?? 0;useFrame(({ clock }, delta) => {diff --git a/client/src/components/city/CityClouds.jsx b/client/src/components/city/CityClouds.jsxnew file mode 100644index 0000000000..bf9a504312--- /dev/null+++ b/client/src/components/city/CityClouds.jsx@@ -0,0 +1,138 @@+import { useRef, useMemo } from 'react';+import { useFrame } from '@react-three/fiber';+import * as THREE from 'three';++const CLOUD_COUNT = 18;+const CLOUD_SPREAD_X = 200;+const CLOUD_SPREAD_Z = 200;+const CLOUD_MIN_Y = 60;+const CLOUD_MAX_Y = 100;+const WIND_SPEED = 1.5;++// Soft cloud billboard shader+const CLOUD_VERT = `+ varying vec2 vUv;+ void main() {+ vUv = uv;+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);+ }+`;++const CLOUD_FRAG = `+ uniform float uOpacity;+ uniform vec3 uColor;+ uniform float uTime;+ varying vec2 vUv;++ 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() {+ vec2 uv = vUv;+ // Cloud shape: soft ellipse with noise-based edges+ vec2 centered = (uv - 0.5) * 2.0;+ // Stretch horizontally for flatter clouds+ centered.x *= 0.7;+ float dist = length(centered);+ // Noise for irregular edges+ float n = noise(uv * 4.0 + uTime * 0.05) * 0.3;+ n += noise(uv * 8.0 - uTime * 0.03) * 0.15;+ float shape = smoothstep(1.0 + n, 0.3, dist);+ // Inner brightness variation+ float inner = noise(uv * 3.0 + uTime * 0.02) * 0.2 + 0.8;+ vec3 color = uColor * inner;+ float alpha = shape * uOpacity;+ gl_FragColor = vec4(color, alpha);+ }+`;++function Cloud({ position, scale, speed, seed }) {+ const meshRef = useRef();+ const initialX = position[0];++ const material = useMemo(() => new THREE.ShaderMaterial({+ vertexShader: CLOUD_VERT,+ fragmentShader: CLOUD_FRAG,+ uniforms: {+ uOpacity: { value: 0.6 },+ uColor: { value: new THREE.Color('#ffffff') },+ uTime: { value: seed * 100 },+ },+ transparent: true,+ depthWrite: false,+ side: THREE.DoubleSide,+ blending: THREE.NormalBlending,+ }), [seed]);++ useFrame(({ clock, camera }) => {+ if (!meshRef.current) return;+ const t = clock.getElapsedTime();+ material.uniforms.uTime.value = t + seed * 100;++ // Drift with wind, wrap around+ const drift = ((t * speed * WIND_SPEED + initialX + CLOUD_SPREAD_X) % (CLOUD_SPREAD_X * 2)) - CLOUD_SPREAD_X;+ meshRef.current.position.x = drift;++ // Billboard: face camera+ meshRef.current.quaternion.copy(camera.quaternion);+ });++ return (+ <mesh ref={meshRef} position={position} scale={scale} material={material}>+ <planeGeometry args={[1, 1]} />+ </mesh>+ );+}++export default function CityClouds({ settings }) {+ const skyTheme = settings?.skyTheme ?? 'cyberpunk';+ const visible = skyTheme === 'dreamworld';++ const clouds = useMemo(() => {+ const items = [];+ for (let i = 0; i < CLOUD_COUNT; i++) {+ const seed = i / CLOUD_COUNT;+ const x = (Math.random() - 0.5) * CLOUD_SPREAD_X * 2;+ const y = CLOUD_MIN_Y + Math.random() * (CLOUD_MAX_Y - CLOUD_MIN_Y);+ const z = (Math.random() - 0.5) * CLOUD_SPREAD_Z * 2;+ const baseScale = 15 + Math.random() * 25;+ const scaleY = baseScale * (0.3 + Math.random() * 0.3);+ const speed = 0.3 + Math.random() * 0.7;+ items.push({+ key: i,+ position: [x, y, z],+ scale: [baseScale, scaleY, 1],+ speed,+ seed,+ });+ }+ return items;+ }, []);++ if (!visible) return null;++ return (+ <group>+ {clouds.map(c => (+ <Cloud+ key={c.key}+ position={c.position}+ scale={c.scale}+ speed={c.speed}+ seed={c.seed}+ />+ ))}+ </group>+ );+}diff --git a/client/src/components/city/CityGround.jsx b/client/src/components/city/CityGround.jsxindex be4625f482..d83fb98fe6 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 } from './cityConstants';+import { CITY_COLORS, getTimeOfDayPreset } from './cityConstants';// Reflective puddle/wet-ground patchesfunction WetPatch({ position, size, color }) {@@ -58,7 +58,8 @@ export default function CityGround({ settings }) {const groundMatRef = useRef();const timeOfDay = settings?.timeOfDay ?? 'sunset';- const preset = CITY_COLORS.timeOfDay[timeOfDay] ?? CITY_COLORS.timeOfDay.sunset;+ const skyTheme = settings?.skyTheme ?? 'cyberpunk';+ const preset = getTimeOfDayPreset(timeOfDay, skyTheme);const groundColorTarget = useRef(new THREE.Color(preset.groundColor ?? '#0a0a20'));groundColorTarget.current.set(preset.groundColor ?? '#0a0a20');const targetRoughness = preset.groundRoughness ?? 0.7;diff --git a/client/src/components/city/CityLights.jsx b/client/src/components/city/CityLights.jsxindex 17d16d8c73..3fbb29d586 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 { CITY_COLORS } from './cityConstants';+import { CITY_COLORS, getTimeOfDayPreset } from './cityConstants';// Animated accent light that slowly shifts color, with reactive brightnessfunction AnimatedLight({ position, baseColor, baseIntensity, distance, shiftRange = 0.1, speed = 0.5, brightnessRef, neonScaleRef }) {@@ -84,7 +84,8 @@ export default function CityLights({ settings }) {brightnessRef.current = settings?.ambientBrightness ?? 1.2;const timeOfDay = settings?.timeOfDay ?? 'sunset';- const preset = CITY_COLORS.timeOfDay[timeOfDay] ?? CITY_COLORS.timeOfDay.sunset;+ const skyTheme = settings?.skyTheme ?? 'cyberpunk';+ const preset = getTimeOfDayPreset(timeOfDay, skyTheme);// Neon scale: dim neon point lights during daytime (30% at noon, 100% at night)const neonScaleRef = useRef(1);diff --git a/client/src/components/city/CityScene.jsx b/client/src/components/city/CityScene.jsxindex 59a8383dcd..333b81689e 100644--- a/client/src/components/city/CityScene.jsx+++ b/client/src/components/city/CityScene.jsx@@ -19,6 +19,7 @@ import CityDataRain from './CityDataRain';import CityNeonSigns from './CityNeonSigns';import CityEmbers from './CityEmbers';import CityEffects from './CityEffects';+import CityClouds from './CityClouds';import CitySky from './CitySky';export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus, productivityData, settings, playSfx }) {@@ -42,6 +43,7 @@ export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus,gl={{ antialias: true }}><CitySky settings={settings} />+ <CityClouds settings={settings} /><CityLights settings={settings} /><CityStarfield settings={settings} /><CityShootingStars playSfx={playSfx} settings={settings} />diff --git a/client/src/components/city/CitySettingsPanel.jsx b/client/src/components/city/CitySettingsPanel.jsxindex fb2d6faa2e..a8eff82b12 100644--- a/client/src/components/city/CitySettingsPanel.jsx+++ b/client/src/components/city/CitySettingsPanel.jsx@@ -225,6 +225,32 @@ export default function CitySettingsPanel() {<div className="border-t border-cyan-500/10" />+ {/* Sky Theme */}+ <div>+ <SectionHeader title="SKY THEME" subtitle="Change the world atmosphere" />+ <div className="grid grid-cols-2 gap-1.5">+ {[+ { key: 'cyberpunk', label: 'CYBERPUNK', desc: 'Dark neon-lit night city' },+ { key: 'dreamworld', label: 'DREAMWORLD', desc: 'Bright open-world sky with clouds' },+ ].map(theme => (+ <button+ key={theme.key}+ onClick={() => updateSetting('skyTheme', theme.key)}+ title={theme.desc}+ className={`font-pixel text-[9px] py-2 rounded border transition-all tracking-wide ${+ settings.skyTheme === theme.key+ ? 'bg-cyan-500/20 border-cyan-500/50 text-cyan-400 shadow-[0_0_8px_rgba(6,182,212,0.2)]'+ : 'bg-gray-800/40 border-gray-700/40 text-gray-500 hover:border-gray-600 hover:text-gray-400'+ }`}+ >+ {theme.label}+ </button>+ ))}+ </div>+ </div>++ <div className="border-t border-cyan-500/10" />+{/* Scene Lighting */}<div><SectionHeader title="SCENE LIGHTING" subtitle="Brightness and time of day" />diff --git a/client/src/components/city/CityShootingStars.jsx b/client/src/components/city/CityShootingStars.jsxindex d6aa56ee1e..c520cbdf8b 100644--- a/client/src/components/city/CityShootingStars.jsx+++ b/client/src/components/city/CityShootingStars.jsx@@ -1,7 +1,7 @@import { useRef, useMemo } from 'react';import { useFrame } from '@react-three/fiber';import * as THREE from 'three';-import { CITY_COLORS } from './cityConstants';+import { getTimeOfDayPreset } from './cityConstants';// Vertex shader for shooting star trailconst TRAIL_VERT = `@@ -193,7 +193,8 @@ function ShootingStar({ index, playSfx, daylightRef }) {export default function CityShootingStars({ playSfx, settings }) {const daylightRef = useRef(0);const timeOfDay = settings?.timeOfDay ?? 'sunset';- const preset = CITY_COLORS.timeOfDay[timeOfDay] ?? CITY_COLORS.timeOfDay.sunset;+ const skyTheme = settings?.skyTheme ?? 'cyberpunk';+ const preset = getTimeOfDayPreset(timeOfDay, skyTheme);const targetDaylight = preset.daylightFactor ?? 0;useFrame((_, delta) => {diff --git a/client/src/components/city/CitySky.jsx b/client/src/components/city/CitySky.jsxindex 1f026672aa..56f3931a8c 100644--- a/client/src/components/city/CitySky.jsx+++ b/client/src/components/city/CitySky.jsx@@ -1,7 +1,7 @@import { useRef, useMemo } from 'react';import { useFrame } from '@react-three/fiber';import * as THREE from 'three';-import { CITY_COLORS } from './cityConstants';+import { CITY_COLORS, getTimeOfDayPreset } from './cityConstants';const SUN_RADIUS = 100;@@ -103,12 +103,13 @@ const lerpColor = (target, a, b, t) => {target.b = a.b + (b.b - a.b) * t;};-// Pre-allocate parsed preset colors+// Pre-allocate parsed preset colors (keyed by "theme:timeOfDay")const presetColors = {};-const getPresetColors = (name) => {- if (!presetColors[name]) {- const p = CITY_COLORS.timeOfDay[name];- presetColors[name] = {+const getPresetColors = (name, skyTheme = 'cyberpunk') => {+ const cacheKey = `${skyTheme}:${name}`;+ if (!presetColors[cacheKey]) {+ const p = getTimeOfDayPreset(name, skyTheme);+ presetColors[cacheKey] = {zenith: new THREE.Color(p.zenith),midSky: new THREE.Color(p.midSky),horizonHigh: new THREE.Color(p.horizonHigh),@@ -122,7 +123,7 @@ const getPresetColors = (name) => {isMoon: p.isMoon,};}- return presetColors[name];+ return presetColors[cacheKey];};// Sun/Moon mesh@@ -173,6 +174,9 @@ export default function CitySky({ settings }) {const timeOfDayRef = useRef(settings?.timeOfDay ?? 'sunset');timeOfDayRef.current = settings?.timeOfDay ?? 'sunset';+ const skyThemeRef = useRef(settings?.skyTheme ?? 'cyberpunk');+ skyThemeRef.current = settings?.skyTheme ?? 'cyberpunk';+const currentPresetRef = useRef(timeOfDayRef.current);const transitionRef = useRef(1.0);@@ -214,7 +218,7 @@ export default function CitySky({ settings }) {transitionRef.current = Math.min(1.0, transitionRef.current + delta * 1.5);const lerpFactor = transitionRef.current < 1 ? delta * 3 : 1;- const preset = getPresetColors(target);+ const preset = getPresetColors(target, skyThemeRef.current);// Lerp hour along shortest path on the 24h clocklet hourDiff = preset.hour - currentHourRef.current;diff --git a/client/src/components/city/CityStarfield.jsx b/client/src/components/city/CityStarfield.jsxindex 4799508625..c01063d382 100644--- a/client/src/components/city/CityStarfield.jsx+++ b/client/src/components/city/CityStarfield.jsx@@ -1,7 +1,7 @@import { useRef, useMemo } from 'react';import { useFrame } from '@react-three/fiber';import * as THREE from 'three';-import { CITY_COLORS } from './cityConstants';+import { getTimeOfDayPreset } from './cityConstants';const STAR_VERT = `attribute float size;@@ -83,7 +83,8 @@ export default function CityStarfield({ settings }) {}, []);const timeOfDay = settings?.timeOfDay ?? 'sunset';- const preset = CITY_COLORS.timeOfDay[timeOfDay] ?? CITY_COLORS.timeOfDay.sunset;+ const skyTheme = settings?.skyTheme ?? 'cyberpunk';+ const preset = getTimeOfDayPreset(timeOfDay, skyTheme);const targetDaylight = preset.daylightFactor ?? 0;useFrame(({ clock }, delta) => {diff --git a/client/src/components/city/cityConstants.js b/client/src/components/city/cityConstants.jsindex c0a4bab296..0715dfab58 100644--- a/client/src/components/city/cityConstants.js+++ b/client/src/components/city/cityConstants.js@@ -109,6 +109,98 @@ export const CITY_COLORS = {ambientIntensity: 0.1,},},+ // Sky themes: visual palette overrides for time-of-day presets+ // 'cyberpunk' uses default timeOfDay colors above+ // 'dreamworld' bright purple/blue open-world sky with clouds+ skyThemes: {+ cyberpunk: null, // uses default timeOfDay colors+ dreamworld: {+ sunrise: {+ hour: 6,+ zenith: '#4a2080',+ midSky: '#6a3aaa',+ horizonHigh: '#ff9070',+ horizonLow: '#ffcc88',+ sunCore: '#ffdd66',+ sunGlow: '#ffaa55',+ sunLight: '#ffeecc',+ sunIntensity: 3.0,+ sunScale: 1.2,+ isMoon: false,+ daylightFactor: 0.5,+ groundColor: '#4a4a60',+ groundRoughness: 0.5,+ hemiSkyColor: '#cc88ff',+ hemiGroundColor: '#4a3a50',+ hemiIntensity: 0.8,+ ambientColor: '#6644aa',+ ambientIntensity: 0.35,+ },+ noon: {+ hour: 12,+ zenith: '#4466cc',+ midSky: '#6688dd',+ horizonHigh: '#88aaee',+ horizonLow: '#aaccff',+ sunCore: '#ffffee',+ sunGlow: '#ffffcc',+ sunLight: '#ffffff',+ sunIntensity: 5.0,+ sunScale: 0.8,+ isMoon: false,+ daylightFactor: 1.0,+ groundColor: '#556680',+ groundRoughness: 0.4,+ hemiSkyColor: '#99bbff',+ hemiGroundColor: '#445566',+ hemiIntensity: 1.6,+ ambientColor: '#7799cc',+ ambientIntensity: 0.5,+ },+ sunset: {+ hour: 18,+ zenith: '#2a1860',+ midSky: '#5530a0',+ horizonHigh: '#ff6088',+ horizonLow: '#ffaa60',+ sunCore: '#ffcc44',+ sunGlow: '#ff8866',+ sunLight: '#ffddbb',+ sunIntensity: 2.5,+ sunScale: 1.2,+ isMoon: false,+ daylightFactor: 0.4,+ groundColor: '#302848',+ groundRoughness: 0.55,+ hemiSkyColor: '#bb6688',+ hemiGroundColor: '#2a2040',+ hemiIntensity: 0.6,+ ambientColor: '#4a2266',+ ambientIntensity: 0.3,+ },+ midnight: {+ hour: 0,+ zenith: '#0a0830',+ midSky: '#161248',+ horizonHigh: '#2a2266',+ horizonLow: '#3a3080',+ sunCore: '#ccccff',+ sunGlow: '#9999dd',+ sunLight: '#556688',+ sunIntensity: 0.3,+ sunScale: 0.7,+ isMoon: true,+ daylightFactor: 0.05,+ groundColor: '#141230',+ groundRoughness: 0.7,+ hemiSkyColor: '#221e55',+ hemiGroundColor: '#0a0818',+ hemiIntensity: 0.1,+ ambientColor: '#1a1644',+ ambientIntensity: 0.15,+ },+ },+ },};export const BOROUGH_PARAMS = {@@ -170,6 +262,14 @@ export const getBuildingHeight = (app) => {return base + processBonus + variation;};+// Resolve the time-of-day preset for a given sky theme+// Returns theme-specific overrides if available, otherwise default timeOfDay preset+export const getTimeOfDayPreset = (timeOfDay, skyTheme) => {+ const themeOverrides = CITY_COLORS.skyThemes[skyTheme];+ if (themeOverrides && themeOverrides[timeOfDay]) return themeOverrides[timeOfDay];+ return CITY_COLORS.timeOfDay[timeOfDay] ?? CITY_COLORS.timeOfDay.sunset;+};+// Get a deterministic neon accent color per app (for windows/decorations)export const getAccentColor = (app) => {const hash = hashString(app.name || app.id);diff --git a/client/src/hooks/useCitySettings.js b/client/src/hooks/useCitySettings.jsindex 73c8d89862..fe25abaee4 100644--- a/client/src/hooks/useCitySettings.js+++ b/client/src/hooks/useCitySettings.js@@ -47,6 +47,7 @@ const DEFAULT_SETTINGS = {sfxEnabled: true,sfxVolume: 0.5,qualityPreset: 'high',+ skyTheme: 'cyberpunk',timeOfDay: 'sunset',...QUALITY_PRESETS.high,};