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: enhance OpenWorld visuals, operational aesthetics, and rendering performance
[._.]/ Adam Eivy8b07b777eacd
diff --git a/client/src/components/openworld/Building.jsx b/client/src/components/openworld/Building.jsxindex 6ddd4f82b1..02e55d0c6d 100644--- a/client/src/components/openworld/Building.jsx+++ b/client/src/components/openworld/Building.jsx@@ -9,6 +9,7 @@ import BuildingHologram from './BuildingHologram';import BuildingWindows from './BuildingWindows';import { computeRooftopKit } from '../../utils/openWorldRooftops';import { buildingHasInteriorWindows } from '../../utils/openWorldInteriorWindows';+import { computeAppMetrics, cpuTone } from '../../utils/openWorldAppMetrics';// Rooftop fixture geometry/materials are module-scope singletons shared by every// building — fixtures are tiny set dressing, so they keep fixed colors (the antenna@@ -470,6 +471,118 @@ function LowPolyFacade({ width, depth, height, bodyColor, edgeColor, dimMul, sur);}+// Always-visible façade health indicator (Roadmap 1.1) - readable at any distance+function BuildingHealthStrip({ width, height, depth, status, metrics, dimMul = 1, dayMix = 0 }) {+ const isHot = metrics?.hasMetrics && cpuTone(metrics.cpuPercent) === 'hot';+ const isBusy = metrics?.hasMetrics && cpuTone(metrics.cpuPercent) === 'busy';+ const isErrored = status === 'errored' || (metrics?.unstableRestarts > 0);++ const toneColor = isErrored+ ? '#f43f5e'+ : isHot+ ? '#ef4444'+ : isBusy+ ? '#f59e0b'+ : status === 'online'+ ? '#10b981'+ : '#64748b';++ const ref = useRef();+ useFrame(({ clock }) => {+ if (!ref.current) return;+ const t = clock.getElapsedTime();+ if (isHot || isErrored) {+ ref.current.material.opacity = (0.55 + Math.sin(t * 6) * 0.35) * dimMul;+ } else if (isBusy) {+ ref.current.material.opacity = (0.6 + Math.sin(t * 2.5) * 0.2) * dimMul;+ } else {+ ref.current.material.opacity = (0.65 - dayMix * 0.2) * dimMul;+ }+ });++ const barWidth = Math.min(width * 0.65, 1.2);+ const barY = Math.max(0.4, height * 0.76);++ return (+ <group position={[0, barY, depth / 2 + 0.03]}>+ {/* Background dark casing */}+ <mesh position={[0, 0, 0]}>+ <boxGeometry args={[barWidth + 0.06, 0.06, 0.015]} />+ <meshBasicMaterial color="#0f172a" transparent opacity={0.8 * dimMul} />+ </mesh>+ {/* LED active meter strip */}+ <mesh ref={ref} position={[0, 0, 0.01]}>+ <boxGeometry args={[barWidth, 0.035, 0.015]} />+ <meshBasicMaterial color={toneColor} transparent opacity={0.7 * dimMul} toneMapped={false} />+ </mesh>+ </group>+ );+}++// Stress smoke / sparks (Roadmap 1.2) - rises from rooftop when CPU is hot or app has errored+function StressEffects({ height, metrics, status, dimMul = 1 }) {+ const isHot = metrics?.hasMetrics && cpuTone(metrics.cpuPercent) === 'hot';+ const isErrored = status === 'errored' || (metrics?.restarts > 3 && status !== 'stopped');+ const smokeRef = useRef();+ const sparksRef = useRef();++ useFrame(({ clock }) => {+ const t = clock.getElapsedTime();+ if (smokeRef.current) {+ smokeRef.current.children.forEach((puff, i) => {+ const age = (t * 0.8 + i * 0.33) % 1.0;+ puff.position.y = age * 1.6;+ puff.position.x = Math.sin(t * 1.5 + i * 2) * 0.15 * age;+ puff.position.z = Math.cos(t * 1.2 + i * 2) * 0.15 * age;+ puff.scale.setScalar(0.08 + age * 0.22);+ if (puff.material) {+ puff.material.opacity = (1 - age) * 0.45 * dimMul;+ }+ });+ }+ if (sparksRef.current) {+ sparksRef.current.children.forEach((spark, i) => {+ const age = (t * 2.2 + i * 0.25) % 1.0;+ spark.position.y = age * 0.9;+ spark.position.x = Math.sin(t * 8 + i * 4) * 0.25;+ spark.position.z = Math.cos(t * 7 + i * 3) * 0.25;+ if (spark.material) {+ spark.material.opacity = (1 - age) * 0.8 * dimMul;+ }+ });+ }+ });++ if (!isHot && !isErrored) return null;++ return (+ <group position={[0, height + 0.1, 0]}>+ {/* Smoke puffs for persistent CPU spike */}+ {isHot && (+ <group ref={smokeRef}>+ {[0, 1, 2].map((i) => (+ <mesh key={`smoke-${i}`}>+ <sphereGeometry args={[0.2, 6, 6]} />+ <meshBasicMaterial color="#64748b" transparent opacity={0.3} depthWrite={false} />+ </mesh>+ ))}+ </group>+ )}+ {/* Sparks for recent crash / errored app */}+ {isErrored && (+ <group ref={sparksRef}>+ {[0, 1, 2, 3].map((i) => (+ <mesh key={`spark-${i}`}>+ <sphereGeometry args={[0.03, 4, 4]} />+ <meshBasicMaterial color="#f59e0b" transparent opacity={0.8} toneMapped={false} depthWrite={false} />+ </mesh>+ ))}+ </group>+ )}+ </group>+ );+}+export default function Building({ app, position, agentCount, onClick, playSfx, neonBrightness = 1.2, isProximity = false, focused = false, dimmed = false, dayMix = 0, playback = false, transitionState = null, onExited, rooftops = true, interiorWindows = false }) {const meshRef = useRef();const glowRef = useRef();@@ -530,6 +643,8 @@ export default function Building({ app, position, agentCount, onClick, playSfx,return Math.abs(h);}, [app.name, app.id]);+ const metrics = useMemo(() => computeAppMetrics(app), [app]);+const boxGeom = useMemo(() => new THREE.BoxGeometry(width, height, depth), [width, height, depth]);const edgesGeom = useMemo(() => new THREE.EdgesGeometry(boxGeom), [boxGeom]);useEffect(() => () => boxGeom.dispose(), [boxGeom]);@@ -780,6 +895,29 @@ export default function Building({ app, position, agentCount, onClick, playSfx,{displayName}</OpenWorldLabel>+ {/* Always-visible façade health indicator (Roadmap 1.1) */}+ {!app.archived && (+ <BuildingHealthStrip+ width={width}+ height={height}+ depth={depth}+ status={app.overallStatus}+ metrics={metrics}+ dimMul={dimMul}+ dayMix={dayMix}+ />+ )}++ {/* Stress smoke / sparks on rooftop when CPU is hot or crashed (Roadmap 1.2) */}+ {!app.archived && (+ <StressEffects+ height={height}+ metrics={metrics}+ status={app.overallStatus}+ dimMul={dimMul}+ />+ )}+{/* Focus selection ring (issue #2593) — a bright accent ring at the base marking theURL-focused borough. Rendered day AND night (unlike the neon glow) so the selectedbuilding is unambiguously distinguished in any lighting. */}diff --git a/client/src/components/openworld/Building.test.jsx b/client/src/components/openworld/Building.test.jsxnew file mode 100644index 0000000000..5180260408--- /dev/null+++ b/client/src/components/openworld/Building.test.jsx@@ -0,0 +1,76 @@+import { describe, it, expect, vi } from 'vitest';+import { render } from '@testing-library/react';++vi.mock('@react-three/fiber', () => ({ useFrame: () => {} }));+vi.mock('./OpenWorldPaletteContext', () => ({+ useOpenWorldPalette: () => ({+ getBuildingColor: (status, archived) => (archived ? '#475569' : status === 'online' ? '#06b6d4' : '#ef4444'),+ getAccentColor: () => '#06b6d4',+ tintStructure: (c) => c,+ surface: {},+ lowPoly: false,+ neonLayers: true,+ }),+}));+vi.mock('./BuildingHologram', () => ({ default: () => <div data-testid="hologram" /> }));+vi.mock('./HolographicPanel', () => ({ default: () => <div data-testid="panel" /> }));+vi.mock('./OpenWorldLabel', () => ({ default: ({ children }) => <div data-testid="label">{children}</div> }));+vi.mock('./BuildingWindows', () => ({ default: () => <div data-testid="windows" /> }));++import Building from './Building';++describe('Building component', () => {+ const mockApp = {+ id: 'test-app',+ name: 'Test App',+ overallStatus: 'online',+ archived: false,+ pm2Status: {+ worker1: { status: 'online', cpu: 15, memory: 104857600, uptime: 100000 },+ },+ };++ it('renders building mesh, health strip, and label for an active app', () => {+ const { container } = render(+ <Building+ app={mockApp}+ position={{ x: 0, z: 0 }}+ agentCount={1}+ />+ );+ expect(container.getElementsByTagName('mesh').length).toBeGreaterThan(0);+ expect(container.querySelector('[data-testid="label"]')?.textContent).toBe('TEST APP');+ });++ it('renders stress effects when CPU is hot', () => {+ const hotApp = {+ ...mockApp,+ pm2Status: {+ worker1: { status: 'online', cpu: 92, memory: 500000000, uptime: 100000 },+ },+ };+ const { container } = render(+ <Building+ app={hotApp}+ position={{ x: 0, z: 0 }}+ agentCount={0}+ />+ );+ expect(container.getElementsByTagName('group').length).toBeGreaterThan(0);+ });++ it('omits health strip and stress effects for archived apps', () => {+ const archivedApp = {+ ...mockApp,+ archived: true,+ };+ const { container } = render(+ <Building+ app={archivedApp}+ position={{ x: 0, z: 0 }}+ agentCount={0}+ />+ );+ expect(container).toBeTruthy();+ });+});diff --git a/client/src/components/openworld/OpenWorldCollectibles.jsx b/client/src/components/openworld/OpenWorldCollectibles.jsxindex ebbaab2a71..605e57a75d 100644--- a/client/src/components/openworld/OpenWorldCollectibles.jsx+++ b/client/src/components/openworld/OpenWorldCollectibles.jsx@@ -5,7 +5,9 @@ import { getCollectiblesList } from '../../utils/openWorldCollectibles';function ShardMesh({ shard, animate }) {const meshRef = useRef();+ const coreRef = useRef();const ringRef = useRef();+ const outerRingRef = useRef();const { color, x, y, z, pulsePhase } = shard;useFrame(({ clock }) => {@@ -15,33 +17,68 @@ function ShardMesh({ shard, animate }) {meshRef.current.rotation.y = t * 1.6 + pulsePhase * Math.PI;meshRef.current.rotation.x = Math.sin(t * 1.2 + pulsePhase) * 0.15;meshRef.current.position.y = y + Math.sin(t * 2.4 + pulsePhase * Math.PI * 2) * 0.22;+ if (coreRef.current) {+ coreRef.current.rotation.y = -t * 2.2;+ coreRef.current.rotation.z = Math.cos(t * 1.5) * 0.2;+ coreRef.current.position.y = meshRef.current.position.y;+ }if (ringRef.current) {ringRef.current.rotation.z = t * 0.8;ringRef.current.scale.setScalar(1 + Math.sin(t * 3 + pulsePhase) * 0.1);}+ if (outerRingRef.current) {+ outerRingRef.current.rotation.z = -t * 0.5;+ outerRingRef.current.scale.setScalar(1 + Math.cos(t * 2.5 + pulsePhase) * 0.08);+ }}});return (<group position={[x, 0, z]}>+ {/* Outer crystal facet */}<mesh ref={meshRef} position={[0, y, 0]}><octahedronGeometry args={[0.55, 0]} /><meshStandardMaterialcolor={color}emissive={color}- emissiveIntensity={1.4}- metalness={0.8}- roughness={0.15}+ emissiveIntensity={1.2}+ metalness={0.85}+ roughness={0.12}+ transparent+ opacity={0.92}+ toneMapped={false}+ />+ </mesh>++ {/* Inner glowing white-hot core */}+ <mesh ref={coreRef} position={[0, y, 0]} scale={0.36}>+ <octahedronGeometry args={[0.55, 0]} />+ <meshBasicMaterial+ color="#ffffff"toneMapped={false}/></mesh>+ {/* Inner ground energy ring */}<mesh ref={ringRef} rotation={[-Math.PI / 2, 0, 0]} position={[0, 0.04, 0]}>- <ringGeometry args={[0.6, 0.72, 16]} />+ <ringGeometry args={[0.55, 0.68, 16]} />+ <meshBasicMaterial+ color={color}+ transparent+ opacity={0.4}+ blending={THREE.AdditiveBlending}+ depthWrite={false}+ side={THREE.DoubleSide}+ />+ </mesh>++ {/* Outer faint shimmer halo ring */}+ <mesh ref={outerRingRef} rotation={[-Math.PI / 2, 0, 0]} position={[0, 0.035, 0]}>+ <ringGeometry args={[0.75, 0.88, 16]} /><meshBasicMaterialcolor={color}transparent- opacity={0.35}+ opacity={0.18}blending={THREE.AdditiveBlending}depthWrite={false}side={THREE.DoubleSide}diff --git a/client/src/components/openworld/OpenWorldGrass.jsx b/client/src/components/openworld/OpenWorldGrass.jsxindex fea98da296..6653a5cdbb 100644--- a/client/src/components/openworld/OpenWorldGrass.jsx+++ b/client/src/components/openworld/OpenWorldGrass.jsx@@ -56,21 +56,18 @@ function createBlades(count) {});}-function writeMatrices(ref, blades, time = 0) {- if (!ref.current) return;+function writeMatrices(ref, blades) {+ if (!ref.current || typeof ref.current.setMatrixAt !== 'function') return;blades.forEach((blade, index) => {- const gust = Math.sin(time * 0.62 + blade.x * 0.045 + blade.z * 0.032 + blade.phase) * 0.22- + Math.sin(time * 1.45 + blade.phase * 0.7) * 0.07;- const height = blade.height * (1 + Math.sin(blade.phase * 1.3) * 0.08);- dummy.position.set(blade.x, GRASS_BASE_Y + height * 0.5, blade.z);- // A triangular blade leans in two axes so the field reads as a moving volume, not- // as one synchronized sheet. The phase is deterministic, but the wind is shared.- dummy.rotation.set(gust * 0.36, blade.yaw, gust * 0.58);- dummy.scale.set(blade.width, height, blade.width);+ dummy.position.set(blade.x, GRASS_BASE_Y + blade.height * 0.5, blade.z);+ dummy.rotation.set(0, blade.yaw, 0);+ dummy.scale.set(blade.width, blade.height, blade.width);dummy.updateMatrix();ref.current.setMatrixAt(index, dummy.matrix);});- ref.current.instanceMatrix.needsUpdate = true;+ if (ref.current.instanceMatrix) {+ ref.current.instanceMatrix.needsUpdate = true;+ }}export default function OpenWorldGrass({ settings }) {@@ -79,14 +76,41 @@ export default function OpenWorldGrass({ settings }) {const blades = useMemo(() => createBlades(count), [count]);const ref = useRef();const grassColor = mixHex('#4f8a5d', accent, 0.16);+ const timeUniformRef = useRef({ value: 0 });useLayoutEffect(() => {writeMatrices(ref, blades);- if (ref.current) ref.current.instanceMatrix.setUsage(THREE.DynamicDrawUsage);}, [blades]);+ const onBeforeCompile = useMemo(() => (shader) => {+ shader.uniforms.uGrassTime = timeUniformRef.current;+ shader.vertexShader = `+ uniform float uGrassTime;+ ` + shader.vertexShader;+ shader.vertexShader = shader.vertexShader.replace(+ '#include <begin_vertex>',+ `+ #include <begin_vertex>+ // Cone geometry height 1 is centered at y=0, so base is at -0.5 and tip is at +0.5.+ float bladeHeightNorm = clamp(position.y + 0.5, 0.0, 1.0);+ float sway = bladeHeightNorm * bladeHeightNorm;++ // Instance world position from 4th column of instanceMatrix+ vec3 instPos = vec3(instanceMatrix[3][0], instanceMatrix[3][1], instanceMatrix[3][2]);++ float gust = sin(uGrassTime * 0.75 + instPos.x * 0.05 + instPos.z * 0.04) * 0.32+ + sin(uGrassTime * 1.6 + instPos.x * 0.12) * 0.1;++ transformed.x += gust * 0.38 * sway;+ transformed.z += gust * 0.62 * sway;+ `+ );+ }, []);+useFrame(({ clock }) => {- if (lowPoly && blades.length > 0) writeMatrices(ref, blades, clock.getElapsedTime());+ if (lowPoly && blades.length > 0) {+ timeUniformRef.current.value = clock.getElapsedTime();+ }});if (!lowPoly || blades.length === 0) return null;@@ -94,7 +118,13 @@ export default function OpenWorldGrass({ settings }) {return (<instancedMesh key={blades.length} ref={ref} args={[undefined, undefined, blades.length]} frustumCulled={false}><coneGeometry args={[0.12, 1, 3]} />- <meshStandardMaterial {...surface} color={grassColor} roughness={1} metalness={0} />+ <meshStandardMaterial+ {...surface}+ color={grassColor}+ roughness={1}+ metalness={0}+ onBeforeCompile={onBeforeCompile}+ /></instancedMesh>);}diff --git a/client/src/components/openworld/OpenWorldGrass.test.jsx b/client/src/components/openworld/OpenWorldGrass.test.jsxnew file mode 100644index 0000000000..07b57fc0bf--- /dev/null+++ b/client/src/components/openworld/OpenWorldGrass.test.jsx@@ -0,0 +1,27 @@+import { describe, it, expect, vi } from 'vitest';+import { render } from '@testing-library/react';++vi.mock('@react-three/fiber', () => ({ useFrame: () => {} }));+vi.mock('./OpenWorldPaletteContext', () => ({+ useOpenWorldPalette: () => ({+ accent: '#22d3ee',+ surface: {},+ lowPoly: true,+ }),+}));++import OpenWorldGrass from './OpenWorldGrass';++describe('OpenWorldGrass', () => {+ it('renders instancedMesh on lowPoly mode', () => {+ const { container } = render(<OpenWorldGrass settings={{ effectiveTier: 'high' }} />);+ const mesh = container.getElementsByTagName('instancedMesh');+ expect(mesh.length).toBe(1);+ });++ it('scales blade count per quality tier', () => {+ const { container: lowContainer } = render(<OpenWorldGrass settings={{ effectiveTier: 'low' }} />);+ const lowMesh = lowContainer.getElementsByTagName('instancedMesh');+ expect(lowMesh.length).toBe(1);+ });+});diff --git a/client/src/components/openworld/OpenWorldParticles.jsx b/client/src/components/openworld/OpenWorldParticles.jsxindex 8642d9fd2a..73b1d8d749 100644--- a/client/src/components/openworld/OpenWorldParticles.jsx+++ b/client/src/components/openworld/OpenWorldParticles.jsx@@ -3,61 +3,76 @@ import { openWorldDayMix } from './openWorldConstants';import { useOpenWorldPalette } from './OpenWorldPaletteContext';export default function OpenWorldParticles({ settings }) {- const { particles } = useOpenWorldPalette();+ const { particles, lowPoly } = useOpenWorldPalette();const density = settings?.particleDensity ?? 1.0;const scale = (base) => Math.max(1, Math.round(base * density));- // Neon atmosphere dust is a night look — fade it out in daylight.- const dayFade = 1 - openWorldDayMix(settings);+ const dayMix = openWorldDayMix(settings);+ const dayFade = 1 - dayMix;++ if (density <= 0) return null;return (<>- {/* Primary ambient sparkles — follow the themed accent (palette.particles). */}- <Sparkles- count={scale(120)}- scale={[50, 20, 50]}- size={1.8}- speed={0.3}- opacity={0.3 * dayFade}- color={particles}- />- {/* Pink/magenta secondary sparkles */}- <Sparkles- count={scale(50)}- scale={[40, 15, 40]}- size={1.2}- speed={0.25}- opacity={0.2 * dayFade}- color="#ec4899"- />- {/* Purple deep sparkles */}- <Sparkles- count={scale(35)}- scale={[45, 15, 45]}- size={1}- speed={0.2}- opacity={0.15 * dayFade}- color="#8b5cf6"- />- {/* Orange warm dust near ground */}- <Sparkles- count={scale(25)}- scale={[35, 5, 35]}- size={0.8}- speed={0.15}- opacity={0.12 * dayFade}- color="#f97316"- position={[0, 2, 0]}- />- {/* Blue high-altitude sparkles */}- <Sparkles- count={scale(30)}- scale={[50, 8, 50]}- size={0.6}- speed={0.1}- opacity={0.1 * dayFade}- color="#3b82f6"- position={[0, 15, 0]}- />+ {/* Daylight meadow motes: soft golden pollen drifting in the sunlit breeze */}+ {dayMix > 0.1 && (+ <Sparkles+ count={scale(lowPoly ? 70 : 40)}+ scale={[60, 16, 60]}+ size={1.4}+ speed={0.2}+ opacity={0.35 * dayMix}+ color="#fde047"+ position={[0, 4, 0]}+ />+ )}++ {/* Night-time neon atmospheric dust */}+ {dayFade > 0.05 && (+ <>+ <Sparkles+ count={scale(120)}+ scale={[50, 20, 50]}+ size={1.8}+ speed={0.3}+ opacity={0.3 * dayFade}+ color={particles}+ />+ <Sparkles+ count={scale(50)}+ scale={[40, 15, 40]}+ size={1.2}+ speed={0.25}+ opacity={0.2 * dayFade}+ color="#ec4899"+ />+ <Sparkles+ count={scale(35)}+ scale={[45, 15, 45]}+ size={1}+ speed={0.2}+ opacity={0.15 * dayFade}+ color="#8b5cf6"+ />+ <Sparkles+ count={scale(25)}+ scale={[35, 5, 35]}+ size={0.8}+ speed={0.15}+ opacity={0.12 * dayFade}+ color="#f97316"+ position={[0, 2, 0]}+ />+ <Sparkles+ count={scale(30)}+ scale={[50, 8, 50]}+ size={0.6}+ speed={0.1}+ opacity={0.1 * dayFade}+ color="#3b82f6"+ position={[0, 15, 0]}+ />+ </>+ )}</>);}diff --git a/client/src/components/openworld/OpenWorldParticles.test.jsx b/client/src/components/openworld/OpenWorldParticles.test.jsxnew file mode 100644index 0000000000..9f74d409af--- /dev/null+++ b/client/src/components/openworld/OpenWorldParticles.test.jsx@@ -0,0 +1,29 @@+import { describe, it, expect, vi } from 'vitest';+import { render } from '@testing-library/react';++vi.mock('@react-three/drei', () => ({+ Sparkles: ({ color, count }) => <div data-testid="sparkles" data-color={color} data-count={count} />,+}));+vi.mock('./OpenWorldPaletteContext', () => ({+ useOpenWorldPalette: () => ({+ particles: '#22d3ee',+ lowPoly: true,+ }),+}));++import OpenWorldParticles from './OpenWorldParticles';++describe('OpenWorldParticles', () => {+ it('renders daylight pollen sparkles when dayMix is high', () => {+ const { container } = render(<OpenWorldParticles settings={{ timeOfDay: 'vibesDay' }} />);+ const sparkles = container.querySelectorAll('[data-testid="sparkles"]');+ expect(sparkles.length).toBeGreaterThan(0);+ expect(sparkles[0].getAttribute('data-color')).toBe('#fde047');+ });++ it('renders neon night sparkles when at sunset/night', () => {+ const { container } = render(<OpenWorldParticles settings={{ timeOfDay: 'sunset' }} />);+ const sparkles = container.querySelectorAll('[data-testid="sparkles"]');+ expect(sparkles.length).toBeGreaterThan(1);+ });+});diff --git a/client/src/components/openworld/OpenWorldStreetProps.jsx b/client/src/components/openworld/OpenWorldStreetProps.jsxindex 5d55fc2295..e1918bfe76 100644--- a/client/src/components/openworld/OpenWorldStreetProps.jsx+++ b/client/src/components/openworld/OpenWorldStreetProps.jsx@@ -13,6 +13,7 @@ import { computeStreets, computeStreetProps } from '../../utils/openWorldPlan';// neon dressing is much heavier and the grove is already enough orientation at that tier.const dummy = new THREE.Object3D();+const swayTimeUniform = { value: 0 };// Module-scope position offsets — stable identities so the matrix-writing effect below// runs only when placements actually change, not on every parent re-render.@@ -27,34 +28,44 @@ const CANOPY_TOP_POS = [0, 2.12, 0, 0.72];// One instanced mesh whose matrices are written once from `placements`. `flat` lays the// geometry into the ground plane (used by the light-pool discs).-function writeMatrices(ref, placements, position, flat, sway, time = 0) {- if (!ref.current) return;+function writeMatrices(ref, placements, position, flat) {+ if (!ref.current || typeof ref.current.setMatrixAt !== 'function') return;const scaleMultiplier = position[3] ?? 1;placements.forEach((p, i) => {- const phase = p.seed ?? i;- const gust = sway- ? Math.sin(time * 0.72 + phase * 1.7 + p.x * 0.04 + p.z * 0.03) * 0.035- + Math.sin(time * 1.21 + phase * 0.63) * 0.016- : 0;dummy.position.set(p.x + position[0], position[1], p.z + position[2]);- dummy.rotation.set(flat ? -Math.PI / 2 : gust * 0.6, !flat && p.seed != null ? (p.seed * 1.7) % (Math.PI * 2) : 0, flat ? 0 : gust);+ dummy.rotation.set(flat ? -Math.PI / 2 : 0, !flat && p.seed != null ? (p.seed * 1.7) % (Math.PI * 2) : 0, 0);dummy.scale.setScalar((p.scale ?? 1) * scaleMultiplier);dummy.updateMatrix();ref.current.setMatrixAt(i, dummy.matrix);});- ref.current.instanceMatrix.needsUpdate = true;+ if (ref.current.instanceMatrix) {+ ref.current.instanceMatrix.needsUpdate = true;+ }}-function Instances({ placements, geometry, geometryArgs, position, flat = false, sway = false, children }) {+const onSwayCompile = (shader) => {+ shader.uniforms.uSwayTime = swayTimeUniform;+ shader.vertexShader = `+ uniform float uSwayTime;+ ` + shader.vertexShader;+ shader.vertexShader = shader.vertexShader.replace(+ '#include <begin_vertex>',+ `+ #include <begin_vertex>+ vec3 instPos = vec3(instanceMatrix[3][0], instanceMatrix[3][1], instanceMatrix[3][2]);+ float gust = sin(uSwayTime * 0.72 + instPos.x * 0.04 + instPos.z * 0.03) * 0.045+ + sin(uSwayTime * 1.21 + instPos.z * 0.08) * 0.02;+ transformed.x += gust * (position.y + 0.8);+ transformed.z += gust * 0.8 * (position.y + 0.8);+ `+ );+};++function Instances({ placements, geometry, geometryArgs, position, flat = false, children }) {const ref = useRef();useLayoutEffect(() => {- writeMatrices(ref, placements, position, flat, sway);- if (sway && ref.current) ref.current.instanceMatrix.setUsage(THREE.DynamicDrawUsage);- }, [placements, position, flat, sway]);-- useFrame(({ clock }) => {- if (sway) writeMatrices(ref, placements, position, flat, true, clock.getElapsedTime());- });+ writeMatrices(ref, placements, position, flat);+ }, [placements, position, flat]);return (<instancedMesh ref={ref} args={[undefined, undefined, placements.length]} frustumCulled={false}>@@ -91,6 +102,10 @@ export default function OpenWorldStreetProps({ settings }) {: tintStructure('#141b2c');const foliageColor = mixHex(mixHex('#6fa37f', accent, 0.22), '#d5bd83', dayMix * 0.18);+ useFrame(({ clock }) => {+ swayTimeUniform.value = clock.getElapsedTime();+ });+return (<group>{showLamps && (@@ -132,21 +147,22 @@ export default function OpenWorldStreetProps({ settings }) {floating gems; Cyber keeps the established wireframe treatment. */}{lowPoly ? (<>- <Instances placements={props.trees} geometry="sphere" geometryArgs={[0.9, 8, 5]} position={CANOPY_POS} sway>- <meshStandardMaterial {...surface} color={foliageColor} roughness={0.98} />+ <Instances placements={props.trees} geometry="sphere" geometryArgs={[0.9, 8, 5]} position={CANOPY_POS}>+ <meshStandardMaterial {...surface} color={foliageColor} roughness={0.98} onBeforeCompile={onSwayCompile} /></Instances>- <Instances placements={props.trees} geometry="sphere" geometryArgs={[0.68, 8, 5]} position={CANOPY_TOP_POS} sway>- <meshStandardMaterial {...surface} color={mixHex(foliageColor, '#d5e7a4', 0.28)} roughness={0.98} />+ <Instances placements={props.trees} geometry="sphere" geometryArgs={[0.68, 8, 5]} position={CANOPY_TOP_POS}>+ <meshStandardMaterial {...surface} color={mixHex(foliageColor, '#d5e7a4', 0.28)} roughness={0.98} onBeforeCompile={onSwayCompile} /></Instances></>) : (- <Instances placements={props.trees} geometry="icosahedron" geometryArgs={[0.8, 1]} position={CANOPY_POS} sway>+ <Instances placements={props.trees} geometry="icosahedron" geometryArgs={[0.8, 1]} position={CANOPY_POS}><meshBasicMaterialcolor={mixHex(accent, '#22c55e', 0.45)}wireframetransparentopacity={0.5 * (1 - dayMix) + 0.3 * dayMix}toneMapped={false}+ onBeforeCompile={onSwayCompile}/></Instances>)}diff --git a/client/src/components/openworld/OpenWorldTransitLoop.jsx b/client/src/components/openworld/OpenWorldTransitLoop.jsxindex 6c8d533700..cabdf3e954 100644--- a/client/src/components/openworld/OpenWorldTransitLoop.jsx+++ b/client/src/components/openworld/OpenWorldTransitLoop.jsx@@ -70,18 +70,29 @@ export default function OpenWorldTransitLoop({ settings }) {))}{showTrams && Array.from({ length: TRANSIT.tramCount }, (_, i) => (- <mesh key={i} ref={(el) => { if (el) tramRefs.current[i] = el; }}>- <boxGeometry args={TRAM_SIZE} />- <meshStandardMaterial- {...surface}- color={lowPoly ? mixHex('#d57b67', accent, 0.2) : tintStructure('#1a2440')}- emissive={accent}- emissiveIntensity={0.5 * (1 - dayMix) + 0.15 * dayMix}- metalness={lowPoly ? 0.05 : 0.5}- roughness={lowPoly ? 0.85 : 0.3}- toneMapped={false}- />- </mesh>+ <group key={i} ref={(el) => { if (el) tramRefs.current[i] = el; }}>+ <mesh>+ <boxGeometry args={TRAM_SIZE} />+ <meshStandardMaterial+ {...surface}+ color={lowPoly ? mixHex('#d57b67', accent, 0.2) : tintStructure('#1a2440')}+ emissive={accent}+ emissiveIntensity={0.5 * (1 - dayMix) + 0.15 * dayMix}+ metalness={lowPoly ? 0.05 : 0.5}+ roughness={lowPoly ? 0.85 : 0.3}+ toneMapped={false}+ />+ </mesh>+ {/* Front headlamp bar and rear brake light */}+ <mesh position={[0, 0, TRAM_SIZE[2] / 2 + 0.01]}>+ <boxGeometry args={[TRAM_SIZE[0] * 0.65, 0.08, 0.02]} />+ <meshBasicMaterial color="#fef08a" toneMapped={false} />+ </mesh>+ <mesh position={[0, 0, -TRAM_SIZE[2] / 2 - 0.01]}>+ <boxGeometry args={[TRAM_SIZE[0] * 0.6, 0.06, 0.02]} />+ <meshBasicMaterial color="#ef4444" toneMapped={false} />+ </mesh>+ </group>))}</group>);diff --git a/client/src/components/openworld/OpenWorldWater.jsx b/client/src/components/openworld/OpenWorldWater.jsxindex ab6211273d..3332b53c49 100644--- a/client/src/components/openworld/OpenWorldWater.jsx+++ b/client/src/components/openworld/OpenWorldWater.jsx@@ -83,7 +83,7 @@ export default function OpenWorldWater({ settings }) {emissiveMap={waveTex}/></mesh>- {/* Shoreline shimmer — a thin additive surf line where land meets the bay. */}+ {/* Shoreline shimmer — dual additive surf lines where land meets the bay. */}<meshref={shimmerRef}rotation={[-Math.PI / 2, 0, 0]}@@ -98,6 +98,19 @@ export default function OpenWorldWater({ settings }) {depthWrite={false}/></mesh>+ <mesh+ rotation={[-Math.PI / 2, 0, 0]}+ position={[0, WORLD.waterY + 0.012, WORLD.shorelineZ - 2.4]}+ >+ <planeGeometry args={[320, 1.2]} />+ <meshBasicMaterial+ color={mixHex(accent, '#ffffff', 0.4)}+ transparent+ opacity={0.08 * (1 - dayMix) + 0.04 * dayMix}+ blending={THREE.AdditiveBlending}+ depthWrite={false}+ />+ </mesh></group>);}diff --git a/client/src/components/openworld/PlayerAvatar.jsx b/client/src/components/openworld/PlayerAvatar.jsxindex 5a8d564162..6d692dd1d4 100644--- a/client/src/components/openworld/PlayerAvatar.jsx+++ b/client/src/components/openworld/PlayerAvatar.jsx@@ -170,21 +170,32 @@ export default function PlayerAvatar({ rigRef }) {touch down so the road ahead reads while driving at night. */}{headlightsOn && [-1, 1].map((side) => (<group key={`beam-${side}`} position={[side * CAR_WIDTH * 0.3, 0.55, -CAR_LENGTH * 0.55]} rotation={[-0.09, 0, 0]}>- {/* Cone axis is +Y by default; rotating +90° about X aims the apex- backward (+Z), so the mesh is offset half its height to plant the- apex on the lamp and spread the wide end out ahead of the rover. */}- <mesh rotation={[Math.PI / 2, 0, 0]} position={[0, 0, 2.7]}>+ {/* Cone axis is +Y by default; rotating +90° about X aims apex to +Z and base to -Z.+ With offset [0, 0, -2.7], apex is on the lamp (z=0) and wide base spreads forward (z=-5.4). */}+ <mesh rotation={[Math.PI / 2, 0, 0]} position={[0, 0, -2.7]}><coneGeometry args={[1.15, 5.4, 10, 1, true]} /><meshBasicMaterialcolor="#ffe9b8"transparent- opacity={0.13}+ opacity={0.14}blending={THREE.AdditiveBlending}depthWrite={false}side={THREE.DoubleSide}toneMapped={false}/></mesh>+ {/* Soft projected illumination spot on the road ahead */}+ <mesh rotation={[-Math.PI / 2, 0, 0]} position={[0, -0.48, -4.2]}>+ <circleGeometry args={[1.2, 16]} />+ <meshBasicMaterial+ color="#ffe9b8"+ transparent+ opacity={0.09}+ blending={THREE.AdditiveBlending}+ depthWrite={false}+ side={THREE.DoubleSide}+ />+ </mesh></group>))}