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
City night sky: use the galaxy as a three.js environment map (background + IBL)
[._.]/ Adam Eivyad38adfb1dfd
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 378cdc0ae6..b50f7aaa1a 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -25,6 +25,7 @@## Fixed-- **City daytime sky no longer washes out to white; night reads as a galaxy backdrop** — The bright-day sky and pavement were tuned so light, so the dome and ground turned into a near-white fog sheet over the city; daytime now keeps real blue in the horizon bands and a muted blue-gray street so the city stays legible in full sun. At night the bundled galaxy map is the backdrop (with an inner horizon wall so the star band stays visible behind the down-tilted default camera), the shader sky-dome gets out of the way, and the moon is a smaller, softer disc instead of an over-bright bloom. The experimental "Dreamworld" sky-theme picker (and its drifting clouds) has been removed — the City now has one canonical look that follows your theme's day/night mode; any previously-saved Dreamworld setting falls back to it automatically.+- **City daytime sky no longer washes out to white; night reads as a galaxy backdrop** — The bright-day sky and pavement were tuned so light, so the dome and ground turned into a near-white fog sheet over the city; daytime now keeps real blue in the horizon bands and a muted blue-gray street so the city stays legible in full sun. At night the galaxy map is the backdrop, the shader sky-dome gets out of the way, and the moon is a smaller, softer disc instead of an over-bright bloom. The experimental "Dreamworld" sky-theme picker (and its drifting clouds) has been removed — the City now has one canonical look that follows your theme's day/night mode; any previously-saved Dreamworld setting falls back to it automatically.+- **City night sky is a real environment map (the galaxy now also lights the scene)** — The night galaxy was a pair of hand-placed meshes that frequently didn't show and contributed no light. It's now wired through three.js's environment system the way an HDRI is: the equirectangular panorama is assigned to `scene.background` (a true 360° spheremap, visible in every camera direction) and, via `PMREMGenerator`, to `scene.environment` — so the galaxy also tints reflections and lighting on the metallic building/ground materials. The low-resolution (1774×887) AI-generated panorama that read as pixelated was replaced with a crisp 8192×4096 Milky Way (Solar System Scope, CC BY 4.0), brightness/saturation graded for the stylized night. Day is unchanged.- **City no longer flashes a blank white scene when the GPU drops the WebGL context** — Heavy post-processing plus an always-on frame-readback buffer made Chromium lose the City's WebGL context easily, leaving a white canvas with no recovery. The readback buffer is now only enabled while taking a postcard, the render resolution is capped to keep the context stable, and a lost context is detected and either recovered on restore or surfaced over the page background instead of a white void. Known THREE.js deprecation and expected context-loss console messages are also filtered out so the browser console stays usable. With the post-processing pass gone, the City settings panel drops the now-inert Bloom, Film Grain, Chromatic Aberration, Color Grading, and Exposure controls so nothing toggles an effect that no longer renders.- **Browser download keep-alive no longer spams JSON-parse errors** — The browser service's CDP keep-alive treated any `200 OK` on its DevTools port as a live Chrome endpoint and called `res.json()` on it unconditionally. When another process answers on that port with HTML (e.g. the Vite dev server auto-incrementing onto it), the parse threw `Unexpected token '<', "<!DOCTYPE "...`, which the reconnect loop logged every 2 seconds. The CDP check now validates the response is actually Chrome's JSON (`webSocketDebuggerUrl` present) and treats anything else as "not reachable." Separately, the Vite dev server now uses `strictPort` so it fails loudly instead of silently walking up onto a reserved PortOS port (5555 API, 5556 browser CDP).diff --git a/client/public/sky/README.md b/client/public/sky/README.mdindex 61055f4d04..3377f62f55 100644--- a/client/public/sky/README.md+++ b/client/public/sky/README.md@@ -1,7 +1,16 @@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.+- `city-night-galaxy-8k.jpg`+ - 8192×4096 equirectangular (2:1) Milky Way panorama used as the City night sky.+ - Wired through three.js's environment system in `CityGalaxySky.jsx`: assigned to+ `scene.background` (the 360° spheremap backdrop) and, via `PMREMGenerator`, to+ `scene.environment` (image-based lighting on the PBR building/ground materials).+ - Source: "Stars Milky Way" 8K texture, Solar System Scope+ (https://www.solarsystemscope.com/textures/). License: **CC BY 4.0**.+ Attribution: *Textures by Solar System Scope (solarsystemscope.com), CC BY 4.0.*+ - Brightness/saturation graded up for the City's stylized night (the raw panorama is a+ realistic, dark sky); regenerate from the original with `sharp().modulate(...)`.+ - Replaced the prior AI-generated `city-night-galaxy-sphere.png` (1774×887), which was+ too low-resolution for a full-sky background — a ~50° FOV samples only ~14% of the+ panorama width, so the small source was visibly pixelated when upscaled.diff --git a/client/public/sky/city-night-galaxy-8k.jpg b/client/public/sky/city-night-galaxy-8k.jpgnew file mode 100644index 0000000000..0bb24e40adBinary files /dev/null and b/client/public/sky/city-night-galaxy-8k.jpg differdiff --git a/client/public/sky/city-night-galaxy-sphere.png b/client/public/sky/city-night-galaxy-sphere.pngdeleted file mode 100644index 7656daaec3..0000000000Binary files a/client/public/sky/city-night-galaxy-sphere.png and /dev/null differdiff --git a/client/src/components/city/CityGalaxySky.jsx b/client/src/components/city/CityGalaxySky.jsxindex d347c60518..8c00b63315 100644--- a/client/src/components/city/CityGalaxySky.jsx+++ b/client/src/components/city/CityGalaxySky.jsx@@ -1,56 +1,71 @@-import { useEffect, useMemo } from 'react';-import { useLoader } from '@react-three/fiber';+import { useEffect } from 'react';+import { useThree, useLoader } from '@react-three/fiber';import * as THREE from 'three';import { cityDayMix } from './cityConstants';-const GALAXY_TEXTURE_URL = '/sky/city-night-galaxy-sphere.png';+const GALAXY_TEXTURE_URL = '/sky/city-night-galaxy-8k.jpg';+// Artistic yaw so the brightest stretch of the Milky Way band sits behind the city+// rather than dead-ahead. Applied to both the visible background and the IBL probe so+// reflections line up with what's on screen.+const GALAXY_ROTATION = new THREE.Euler(0, -Math.PI * 0.18, 0);+// Brightness knobs (multiplied by how deep into night we are). The panorama is a real,+// dark Milky Way, so the background gets a >1 lift to read clearly against the night sky;+// the IBL multiplier controls how strongly the galaxy tints the metallic facades.+const BACKGROUND_INTENSITY = 2.4;+const ENVIRONMENT_INTENSITY = 1.3;++// The night sky is the equirectangular galaxy panorama wired through three.js's+// environment system the way an HDRI is: the texture is mapped equirectangular, run+// through a PMREMGenerator, and assigned to BOTH scene.background (the 360° spheremap+// backdrop, visible in every camera direction) AND scene.environment (image-based+// lighting, so the galaxy tints reflections/lighting on the PBR building + ground+// materials). drei's <Environment files> can't load a .png panorama (its loader only+// recognises .hdr/.exr/cube), so we do the PMREM wiring directly — the canonical setup.+//+// Mounted only at night (CityScene gates on !showGradientBackground), so the 2.8MB+// panorama isn't fetched/decoded or PMREM-processed in daylight.export default function CityGalaxySky({ settings }) {- const dayMix = cityDayMix(settings);- const nightOpacity = Math.max(0, Math.min(1, 1 - dayMix));+ const { gl, scene } = useThree();const texture = useLoader(THREE.TextureLoader, GALAXY_TEXTURE_URL);+ const nightOpacity = Math.max(0, Math.min(1, 1 - cityDayMix(settings)));+ // Build the PMREM environment once per texture and bind it to the scene; restore the+ // previous background/environment (and free the GPU targets) when night ends / unmounts.useEffect(() => {+ texture.mapping = THREE.EquirectangularReflectionMapping;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]);-- // One material shared by the sphere backing and the inner horizon wall — both- // sample the same galaxy map at the same opacity, so there's no reason to- // allocate two. opacity/transparent track nightOpacity on each render (a- // settings-rate change, not per-frame).- const galaxyMaterial = useMemo(() => new THREE.MeshBasicMaterial({- map: texture,- color: '#ffffff',- side: THREE.BackSide,- depthTest: true,- depthWrite: false,- toneMapped: false,- }), [texture]);- useEffect(() => () => galaxyMaterial.dispose(), [galaxyMaterial]);- galaxyMaterial.opacity = nightOpacity;- galaxyMaterial.transparent = nightOpacity < 0.99;-- if (nightOpacity <= 0.01) return null;-- return (- <group rotation={[0, -Math.PI * 0.18, 0]}>- {/* Distant full-sphere backing for free-look/orbit cameras. */}- <mesh renderOrder={-1000} material={galaxyMaterial}>- <sphereGeometry args={[1500, 64, 32]} />- </mesh>- {/* The default City camera points down across the horizon, so the- equirectangular sphere can look like plain darkness. This inner- horizon wall keeps the custom galaxy band visible behind the city. */}- <mesh renderOrder={-999} position={[0, 220, 0]} material={galaxyMaterial}>- <cylinderGeometry args={[1420, 1420, 960, 96, 1, true]} />- </mesh>- </group>- );++ const pmrem = new THREE.PMREMGenerator(gl);+ const envTarget = pmrem.fromEquirectangular(texture);++ const prevBackground = scene.background;+ const prevEnvironment = scene.environment;+ scene.background = texture;+ scene.environment = envTarget.texture;+ scene.backgroundRotation.copy(GALAXY_ROTATION);+ scene.environmentRotation.copy(GALAXY_ROTATION);++ return () => {+ scene.background = prevBackground;+ scene.environment = prevEnvironment;+ // Reset the intensities to three's defaults so the daytime color background (set by+ // CityScene once this unmounts) isn't left dimmed by the last night value.+ scene.backgroundIntensity = 1;+ scene.environmentIntensity = 1;+ envTarget.dispose();+ pmrem.dispose();+ };+ }, [gl, scene, texture]);++ // Cross-fade with daylight without rebuilding the PMREM map: scale the background and+ // the IBL by how deep into night we are. The panorama is mostly dark space, so the IBL+ // gets a >1 multiplier to read as a light source on metallic facades.+ useEffect(() => {+ scene.backgroundIntensity = nightOpacity * BACKGROUND_INTENSITY;+ scene.environmentIntensity = nightOpacity * ENVIRONMENT_INTENSITY;+ }, [scene, nightOpacity]);++ return null;}diff --git a/client/src/components/city/CityScene.jsx b/client/src/components/city/CityScene.jsxindex e7a486b9e9..33e3a3687d 100644--- a/client/src/components/city/CityScene.jsx+++ b/client/src/components/city/CityScene.jsx@@ -163,12 +163,16 @@ export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus,// dashboard, which reads as a blank white scene.gl={{ antialias: true, preserveDrawingBuffer: Boolean(photoMode), alpha: false, powerPreference: 'high-performance' }}>- <color attach="background" args={[sceneClearColor]} />- {/* 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.- Suspense keeps the useLoader fetch from suspending the whole canvas while- it streams in; the error boundary degrades to the plain dark sky if the- texture is missing/corrupt (e.g. a partial checkout) instead of crashing. */}+ {/* By day, the solid clear color is the scene background. At night, the galaxy+ Environment below owns scene.background (the equirectangular spheremap), so we+ must NOT also drive <color attach="background"> — both write scene.background and+ would fight every frame. */}+ {showGradientBackground && <color attach="background" args={[sceneClearColor]} />}+ {/* Mount the galaxy environment only at night — keeps its 2.8MB panorama from being+ fetched/decoded (and PMREM-processed) in full daylight, where it's faded out+ anyway. Suspense keeps the texture load from suspending the whole canvas while it+ streams in; the error boundary degrades to the plain dark sky if the texture is+ missing/corrupt (e.g. a partial checkout) instead of crashing. */}{!showGradientBackground && (<ErrorBoundary fallback={null}><Suspense fallback={null}>