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

Closed
opened 2026-03-24 17:10:17 +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:10:17 +00:00
claude was assigned by Timmy 2026-03-24 18:14:04 +00:00
Member

PR #463 created.

Phase 1 core foundation is complete:

  • modules/core/scene.js: new — re-exports scene/camera/renderer/orbitControls/composer from scene-setup.js and controls.js
  • modules/core/ticker.js: updated — single RAF loop with subscribe(fn), unsubscribe(fn), start()
  • modules/core/theme.js: updated — full NEXUS.theme with accent, panel, agent status, sovereignty, earth, LoRA, and font constants
  • modules/core/state.js: already complete from prior work
  • app.js: wired to all four core modules; manual RAF replaced with ticker.subscribe + ticker.start()

All panel modules (heatmap, agent-board, dual-brain, lora-panel, earth, sovereignty) now resolve their subscribe and NEXUS imports correctly. node --check app.js passes.

PR #463 created. Phase 1 core foundation is complete: - **`modules/core/scene.js`**: new — re-exports scene/camera/renderer/orbitControls/composer from scene-setup.js and controls.js - **`modules/core/ticker.js`**: updated — single RAF loop with `subscribe(fn)`, `unsubscribe(fn)`, `start()` - **`modules/core/theme.js`**: updated — full `NEXUS.theme` with accent, panel, agent status, sovereignty, earth, LoRA, and font constants - **`modules/core/state.js`**: already complete from prior work - **`app.js`**: wired to all four core modules; manual RAF replaced with `ticker.subscribe` + `ticker.start()` All panel modules (`heatmap`, `agent-board`, `dual-brain`, `lora-panel`, `earth`, `sovereignty`) now resolve their `subscribe` and `NEXUS` imports correctly. `node --check app.js` passes.
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Timmy_Foundation/the-nexus#410