Files
the-nexus/modules/core/theme.js
Alexander Whitestone 4f207605ce
All checks were successful
CI / validate (pull_request) Successful in 6s
CI / auto-merge (pull_request) Successful in 0s
feat: extract core foundation modules — scene, ticker, theme, state (#420)
Phase 1 of app.js modularization (Refs #409, Fixes #420).

Adds four modules under modules/core/:

- theme.js: exports NEXUS with full NEXUS.theme (colors, fonts, lineWeights,
  glowParams, opacity). NEXUS.colors preserved as backwards-compat alias.

- state.js: exports zoneIntensity (shared mutable object), state (agentCount,
  blockHeight, starPulseIntensity, weather), and totalActivity().

- scene.js: creates and exports scene, camera, renderer, orbitControls,
  raycaster, lighting. Registers camera+renderer resize handler. Intentionally
  does not append renderer.domElement — app.js controls DOM insertion order.

- ticker.js: single requestAnimationFrame loop. Exports subscribe(), unsubscribe(),
  start(), stop(). app.js registers animate() via tickerSubscribe and calls
  tickerStart() instead of RAF directly.

app.js changes:
- Imports NEXUS from theme.js (removes inline NEXUS definition)
- Imports scene/camera/renderer/orbitControls/raycaster from scene.js
  (removes duplicate creation blocks)
- Imports zoneIntensity/state/totalActivity from state.js (removes local defs)
- animate() is now a ticker subscriber function, not a recursive RAF caller
- _activeAgentCount → state.agentCount
- _starPulseIntensity → state.starPulseIntensity
- lastKnownBlockHeight → state.blockHeight
- EffectComposer resize listener preserved separately in app.js

node --check app.js passes. No visual regressions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-24 14:24:00 -04:00

63 lines
1.6 KiB
JavaScript

/**
* modules/core/theme.js — NEXUS.theme: authoritative source for all visual constants.
*
* NEXUS.colors is preserved as a backwards-compatible alias so existing code
* that references NEXUS.colors.xxx continues to work unchanged.
*
* Category: STRUCTURAL (no data source required — purely declarative constants)
*/
const _colors = {
bg: 0x000008,
starCore: 0xffffff,
starDim: 0x8899cc,
constellationLine: 0x334488,
constellationFade: 0x112244,
accent: 0x4488ff,
};
export const NEXUS = {
/** Backwards-compat alias — identical to theme.colors. */
colors: _colors,
theme: {
/** Colour palette used across all visual elements. */
colors: _colors,
/** Typography definitions for canvas and HUD text. */
fonts: {
mono: 'monospace',
matrixSize: 14, // px — matrix rain character size
hud: '12px monospace',
panel: '11px monospace',
panelLabel: 'bold 11px monospace',
},
/** Line/stroke weights for geometry outlines and connections. */
lineWeights: {
constellation: 0.18,
portalRing: 0.6,
glassEdge: 0.55,
runeRing: 0.7,
},
/** Post-processing and emissive glow parameters. */
glowParams: {
bloomStrength: 0.35,
bloomRadius: 0.4,
bloomThreshold: 0.1,
emissiveScale: 0.06, // multiplier for emissive colour on platform frame
},
/** Canonical opacity values — keeps visual language consistent. */
opacity: {
glassTile: 0.09,
starBase: 0.3,
starPeak: 1.0,
heatmapBase: 0.75,
constellationBase: 0.12,
constellationPulse: 0.06,
},
},
};