app.js: 5416 → 528 lines (entry point, animation loop, event wiring) modules/state.js: shared mutable state object modules/constants.js: color palette modules/matrix-rain.js: matrix rain canvas effect modules/scene-setup.js: scene, camera, renderer, lighting, stars modules/platform.js: glass platform, perlin noise, floating island, clouds modules/heatmap.js: commit heatmap modules/sigil.js: Timmy sigil modules/controls.js: mouse, overview, zoom, photo mode modules/effects.js: energy beam, sovereignty meter, rune ring modules/earth.js: holographic earth modules/warp.js: warp tunnel, crystals, lightning modules/dual-brain.js: dual-brain holographic panel modules/audio.js: Web Audio, spatial, portal hums modules/debug.js: debug mode, websocket, session export modules/celebrations.js: easter egg, shockwave, fireworks modules/portals.js: portal loading modules/bookshelves.js: floating bookshelves, spine textures modules/oath.js: The Oath interactive SOUL.md modules/panels.js: agent status board, LoRA panel modules/weather.js: weather system, portal health modules/extras.js: gravity zones, speech, timelapse, bitcoin Largest file: 528 lines (app.js). No file exceeds 1000. All files pass node --check. No refactoring — mechanical split only.
66 lines
2.1 KiB
JavaScript
66 lines
2.1 KiB
JavaScript
// === PORTALS ===
|
|
import * as THREE from 'three';
|
|
import { scene } from './scene-setup.js';
|
|
import { rebuildRuneRing, setPortalsRef } from './effects.js';
|
|
import { setPortalsRefAudio, startPortalHums } from './audio.js';
|
|
import { S } from './state.js';
|
|
|
|
export const portalGroup = new THREE.Group();
|
|
scene.add(portalGroup);
|
|
|
|
export let portals = [];
|
|
|
|
function createPortals() {
|
|
const portalGeo = new THREE.TorusGeometry(3.0, 0.2, 16, 100);
|
|
|
|
portals.forEach(portal => {
|
|
const isOnline = portal.status === 'online';
|
|
|
|
const portalMat = new THREE.MeshBasicMaterial({
|
|
color: new THREE.Color(portal.color).convertSRGBToLinear(),
|
|
transparent: true,
|
|
opacity: isOnline ? 0.7 : 0.15,
|
|
blending: THREE.AdditiveBlending,
|
|
side: THREE.DoubleSide,
|
|
});
|
|
|
|
const portalMesh = new THREE.Mesh(portalGeo, portalMat);
|
|
|
|
portalMesh.position.set(portal.position.x, portal.position.y + 0.5, portal.position.z);
|
|
portalMesh.rotation.y = portal.rotation.y;
|
|
portalMesh.rotation.x = Math.PI / 2;
|
|
|
|
portalMesh.name = `portal-${portal.id}`;
|
|
portalMesh.userData.destinationUrl = portal.destination?.url || null;
|
|
portalMesh.userData.portalColor = new THREE.Color(portal.color).convertSRGBToLinear();
|
|
|
|
portalGroup.add(portalMesh);
|
|
});
|
|
}
|
|
|
|
// rebuildGravityZones forward ref
|
|
let _rebuildGravityZonesFn = null;
|
|
export function setRebuildGravityZonesFn(fn) { _rebuildGravityZonesFn = fn; }
|
|
|
|
// runPortalHealthChecks forward ref
|
|
let _runPortalHealthChecksFn = null;
|
|
export function setRunPortalHealthChecksFn(fn) { _runPortalHealthChecksFn = fn; }
|
|
|
|
export async function loadPortals() {
|
|
try {
|
|
const res = await fetch('./portals.json');
|
|
if (!res.ok) throw new Error('Portals not found');
|
|
portals = await res.json();
|
|
console.log('Loaded portals:', portals);
|
|
setPortalsRef(portals);
|
|
setPortalsRefAudio(portals);
|
|
createPortals();
|
|
rebuildRuneRing();
|
|
if (_rebuildGravityZonesFn) _rebuildGravityZonesFn();
|
|
startPortalHums();
|
|
if (_runPortalHealthChecksFn) _runPortalHealthChecksFn();
|
|
} catch (error) {
|
|
console.error('Failed to load portals:', error);
|
|
}
|
|
}
|