Files
the-nexus/app.js
Alexander Whitestone 538e88f972
Some checks failed
CI / validate (pull_request) Failing after 14s
CI / auto-merge (pull_request) Has been skipped
feat: Phase 1 core foundation — scene, ticker, theme, state
- modules/core/scene.js: new module exporting scene, camera, renderer,
  OrbitControls, composer, and resize handler via re-exports from
  scene-setup.js and controls.js
- modules/core/ticker.js: single RAF loop with subscribe(fn)/unsubscribe(fn)/
  start() — no module calls requestAnimationFrame directly
- modules/core/theme.js: expand NEXUS export with full theme object covering
  accent, panel, agent-status, sovereignty, earth, LoRA, and font constants;
  retain THEME for SovOS.js consumers
- app.js: wire to all four core modules; replace manual RAF loop with
  ticker subscribe + start()

Fixes #410

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

48 lines
1.7 KiB
JavaScript

// === THE NEXUS — Main Entry Point ===
// Thin orchestrator: imports core modules, wires updates, starts the ticker.
import * as THREE from 'three';
import { scene, composer } from './modules/core/scene.js';
import { subscribe, start } from './modules/core/ticker.js';
import { NEXUS } from './modules/core/theme.js'; // eslint-disable-line no-unused-vars
import { state } from './modules/core/state.js'; // eslint-disable-line no-unused-vars
import { S } from './modules/state.js';
import { warpPass } from './modules/warp.js';
import { nostr } from './modules/nostr.js';
import { createNostrPanelTexture } from './modules/nostr-panel.js';
// === NOSTR INIT ===
nostr.connect();
const { canvas: nostrCanvas, update: updateNostrUI } = createNostrPanelTexture();
const nostrTexture = new THREE.CanvasTexture(nostrCanvas);
const nostrMat = new THREE.MeshBasicMaterial({ map: nostrTexture, transparent: true, side: THREE.DoubleSide });
const nostrPanel = new THREE.Mesh(new THREE.PlaneGeometry(3, 3), nostrMat);
nostrPanel.position.set(-6, 3.5, -7.5);
nostrPanel.rotation.y = 0.4;
scene.add(nostrPanel);
// === MAIN UPDATE — subscribed to the single RAF loop in ticker.js ===
subscribe((elapsed, delta) => {
// Update Nostr UI periodically
if (Math.random() > 0.95) {
updateNostrUI();
nostrTexture.needsUpdate = true;
}
// Visual pulse on energy beam
if (S.energyBeamPulse > 0) {
S.energyBeamPulse -= delta * 2;
if (S.energyBeamPulse < 0) S.energyBeamPulse = 0;
}
// Warp pass time uniform
if (S.isWarping) {
warpPass.uniforms['time'].value = elapsed;
}
composer.render();
});
// === START THE SINGLE RAF LOOP ===
start();
console.log('Nexus Sovereign Node: ONLINE.');