Files
the-nexus/modules/scene.js
Alexander Whitestone 4f196a175f
Some checks failed
CI / validate (pull_request) Failing after 14s
CI / auto-merge (pull_request) Has been skipped
refactor: split app.js into ES modules (scene, effects, controls, ui)
Refs #143

- modules/scene.js  — NEXUS palette, scene/camera/renderer, lighting, EffectComposer, OrbitControls
- modules/effects.js — star field, constellation lines, glass platform, sovereignty meter, commit banners, agent status board
- modules/controls.js — mouse state, overview mode (Tab), photo mode (P), resize handler
- modules/ui.js — debug toggle, WebSocket client, sovereignty easter egg

app.js is now a lean orchestrator: imports all modules, runs the
asset-loading manager, and owns the animate() loop. All files pass
`node --check` and are well under the 500 KB file-size budget.

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

55 lines
1.7 KiB
JavaScript

import * as THREE from 'three';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';
import { BokehPass } from 'three/addons/postprocessing/BokehPass.js';
// === COLOR PALETTE ===
export const NEXUS = {
colors: {
bg: 0x000008,
starCore: 0xffffff,
starDim: 0x8899cc,
constellationLine: 0x334488,
constellationFade: 0x112244,
accent: 0x4488ff,
}
};
// === SCENE SETUP ===
export const scene = new THREE.Scene();
scene.background = new THREE.Color(NEXUS.colors.bg);
export const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 2000);
camera.position.set(0, 6, 11);
// === LIGHTING ===
export const ambientLight = new THREE.AmbientLight(0x0a1428, 1.4);
scene.add(ambientLight);
export const overheadLight = new THREE.PointLight(0x8899bb, 0.6, 60);
overheadLight.position.set(0, 25, 0);
scene.add(overheadLight);
export const renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
// === POST-PROCESSING COMPOSER ===
export const composer = new EffectComposer(renderer);
composer.addPass(new RenderPass(scene, camera));
export const bokehPass = new BokehPass(scene, camera, {
focus: 5.0,
aperture: 0.00015,
maxblur: 0.004,
});
composer.addPass(bokehPass);
// === ORBIT CONTROLS (photo mode) ===
export const orbitControls = new OrbitControls(camera, renderer.domElement);
orbitControls.enableDamping = true;
orbitControls.dampingFactor = 0.05;
orbitControls.enabled = false;