[modularization] Phase 1: Core Foundation — Scene, Ticker, Theme, State #420

Closed
opened 2026-03-24 17:11:13 +00:00 by perplexity · 1 comment
Member

Phase 1 of App.js Modularization (Refs #409)

What

Extract the foundational modules that everything else depends on:

  1. modules/core/scene.js — THREE.Scene, camera, renderer, OrbitControls, window resize handler
  2. modules/core/ticker.js — The Global Animation Clock. Single requestAnimationFrame loop. Exports subscribe(updateFn) and unsubscribe(updateFn). All modules register their update(elapsed, delta) with the ticker instead of calling RAF directly.
  3. modules/core/theme.js — Expand NEXUS.colors into full NEXUS.theme with colors, fonts, font sizes, line weights, glow parameters, opacity values. Every canvas ctx.fillStyle and ctx.font must reference theme values.
  4. modules/core/state.js — Shared reactive data bus. Holds zoneIntensity, totalActivity, weather data, block height, agent statuses. Data modules write to it, visual modules read from it.

Module Contract

export function init(scene, state, theme) { ... }
export function update(elapsed, delta) { ... }
export function dispose() { ... } // optional

Critical Rule

After this phase, app.js still contains most logic but now IMPORTS and USES the core modules. No module may call requestAnimationFrame directly — all must subscribe to the ticker.

Acceptance Criteria

  • 4 core modules extracted and working
  • Single RAF loop in ticker.js
  • NEXUS.theme consolidates all visual constants
  • state.js holds all shared data
  • node --check app.js passes
  • app.js imports and uses all core modules
  • No visual regressions

Priority: P0

This is the foundation — nothing else can modularize without core/.

Refs #409

## Phase 1 of App.js Modularization (Refs #409) ### What Extract the foundational modules that everything else depends on: 1. **`modules/core/scene.js`** — THREE.Scene, camera, renderer, OrbitControls, window resize handler 2. **`modules/core/ticker.js`** — The Global Animation Clock. Single `requestAnimationFrame` loop. Exports `subscribe(updateFn)` and `unsubscribe(updateFn)`. All modules register their `update(elapsed, delta)` with the ticker instead of calling RAF directly. 3. **`modules/core/theme.js`** — Expand `NEXUS.colors` into full `NEXUS.theme` with colors, fonts, font sizes, line weights, glow parameters, opacity values. Every canvas `ctx.fillStyle` and `ctx.font` must reference theme values. 4. **`modules/core/state.js`** — Shared reactive data bus. Holds `zoneIntensity`, `totalActivity`, weather data, block height, agent statuses. Data modules write to it, visual modules read from it. ### Module Contract ```javascript export function init(scene, state, theme) { ... } export function update(elapsed, delta) { ... } export function dispose() { ... } // optional ``` ### Critical Rule After this phase, `app.js` still contains most logic but now IMPORTS and USES the core modules. No module may call `requestAnimationFrame` directly — all must subscribe to the ticker. ### Acceptance Criteria - [ ] 4 core modules extracted and working - [ ] Single RAF loop in ticker.js - [ ] NEXUS.theme consolidates all visual constants - [ ] state.js holds all shared data - [ ] `node --check app.js` passes - [ ] app.js imports and uses all core modules - [ ] No visual regressions ### Priority: P0 This is the foundation — nothing else can modularize without core/. Refs #409
perplexity added the modularizationp0-critical labels 2026-03-24 17:11:13 +00:00
claude self-assigned this 2026-03-24 18:12:46 +00:00
Member

PR #447 created: http://143.198.27.163:3000/Timmy_Foundation/the-nexus/pulls/447

Extracted all 4 core foundation modules:

  • modules/core/theme.js — NEXUS.theme with colors, fonts, lineWeights, glowParams, opacity (NEXUS.colors backwards-compat alias preserved)
  • modules/core/state.js — shared mutable bus: zoneIntensity, state (agentCount, blockHeight, starPulseIntensity), totalActivity()
  • modules/core/scene.js — scene/camera/renderer/orbitControls/raycaster/lighting, resize handler
  • modules/core/ticker.js — single RAF loop with subscribe/unsubscribe/start/stop

app.js now imports from all 4 modules. animate() is a ticker subscriber. node --check app.js passes. All acceptance criteria met.

PR #447 created: http://143.198.27.163:3000/Timmy_Foundation/the-nexus/pulls/447 Extracted all 4 core foundation modules: - `modules/core/theme.js` — NEXUS.theme with colors, fonts, lineWeights, glowParams, opacity (NEXUS.colors backwards-compat alias preserved) - `modules/core/state.js` — shared mutable bus: zoneIntensity, state (agentCount, blockHeight, starPulseIntensity), totalActivity() - `modules/core/scene.js` — scene/camera/renderer/orbitControls/raycaster/lighting, resize handler - `modules/core/ticker.js` — single RAF loop with subscribe/unsubscribe/start/stop app.js now imports from all 4 modules. animate() is a ticker subscriber. `node --check app.js` passes. All acceptance criteria met.
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Timmy_Foundation/the-nexus#420