-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode-galaxy.html
More file actions
417 lines (371 loc) · 19.4 KB
/
code-galaxy.html
File metadata and controls
417 lines (371 loc) · 19.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://cdnjs.cloudflare.com; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://cdnjs.cloudflare.com https://fonts.googleapis.com; font-src https://fonts.gstatic.com https://cdnjs.cloudflare.com; img-src 'self' data: https:; connect-src 'self' https://api.github.com https://api.willbracken.com; object-src 'none'; frame-src 'none'; base-uri 'self';">
<title>Code Galaxy | Will Bracken</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<link rel="icon" href="assets/img/favicon.svg" type="image/svg+xml">
<!-- Open Graph -->
<meta property="og:title" content="Code Galaxy | Will Bracken">
<meta property="og:description" content="Interactive 3D galaxy visualization of all GitHub repositories. Click any orbiting node to explore repo details.">
<meta property="og:url" content="https://brackenw3.github.io/code-galaxy.html">
<style>
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
:root{
--bg:#080c14;--accent:#00d4ff;--green:#00e5a0;
--text:#e8edf5;--muted:#7a8ba0;--card:#111827;
--border:rgba(0,212,255,.12);--nav-h:60px;
--font-sans:'Inter',sans-serif;--font-mono:'JetBrains Mono',monospace
}
html,body{height:100%;overflow:hidden;background:var(--bg);color:var(--text);font-family:var(--font-sans)}
canvas{display:block}
/* ── Nav ── */
.site-nav{position:fixed;top:0;left:0;right:0;height:var(--nav-h);z-index:100;background:rgba(8,12,20,.85);backdrop-filter:blur(12px);border-bottom:1px solid var(--border)}
.nav-inner{max-width:1200px;margin:0 auto;padding:0 1.5rem;height:100%;display:flex;align-items:center;gap:2rem}
.nav-brand{font-family:var(--font-mono);font-size:1.1rem;font-weight:600;color:var(--text);text-decoration:none}
.brand-bracket{color:var(--accent)}
.nav-links{display:flex;align-items:center;gap:1.5rem;margin-left:auto}
.nav-links a{color:var(--muted);text-decoration:none;font-size:.85rem;transition:color .2s}
.nav-links a:hover,.nav-links a.active{color:var(--text)}
.nav-links .nav-gh{color:var(--accent)}
@media(max-width:700px){.nav-links{display:none}}
/* ── Canvas container ── */
#galaxy{position:fixed;inset:0;top:var(--nav-h)}
/* ── Loading screen ── */
#loader{position:fixed;inset:0;top:var(--nav-h);background:var(--bg);display:flex;flex-direction:column;align-items:center;justify-content:center;z-index:50;transition:opacity .6s}
#loader.hidden{opacity:0;pointer-events:none}
.loader-ring{width:48px;height:48px;border:3px solid var(--border);border-top-color:var(--accent);border-radius:50%;animation:spin 1s linear infinite;margin-bottom:1.25rem}
@keyframes spin{to{transform:rotate(360deg)}}
.loader-text{font-family:var(--font-mono);font-size:.85rem;color:var(--muted)}
/* ── Repo info panel ── */
#infoPanel{position:fixed;right:1.5rem;top:calc(var(--nav-h)+1.5rem);width:280px;background:rgba(13,19,33,.95);border:1px solid var(--border);border-radius:14px;padding:1.25rem;z-index:60;opacity:0;transform:translateX(20px);transition:opacity .3s,transform .3s;pointer-events:none}
#infoPanel.visible{opacity:1;transform:translateX(0);pointer-events:auto}
.info-name{font-family:var(--font-mono);font-size:1rem;font-weight:600;color:var(--accent);margin-bottom:.4rem;word-break:break-word}
.info-desc{font-size:.82rem;color:var(--muted);line-height:1.55;margin-bottom:.85rem;min-height:2.5rem}
.info-meta{display:flex;gap:1rem;flex-wrap:wrap;margin-bottom:.85rem}
.info-stat{font-size:.78rem;color:var(--muted);display:flex;align-items:center;gap:.3rem}
.info-stat span{color:var(--text)}
.info-lang{display:inline-flex;align-items:center;gap:.4rem;font-size:.78rem;color:var(--muted)}
.lang-dot{width:9px;height:9px;border-radius:50%}
.info-btn{display:inline-flex;align-items:center;gap:.4rem;padding:.45rem 1rem;border-radius:7px;font-size:.8rem;font-weight:600;text-decoration:none;background:rgba(0,212,255,.12);border:1px solid rgba(0,212,255,.3);color:var(--accent);transition:all .2s;margin-top:.1rem}
.info-btn:hover{background:rgba(0,212,255,.22);color:#22ddff}
.info-close{position:absolute;top:.75rem;right:.75rem;background:none;border:none;color:var(--muted);cursor:pointer;font-size:.9rem;padding:.2rem;line-height:1;transition:color .2s}
.info-close:hover{color:var(--text)}
/* ── HUD ── */
#hud{position:fixed;bottom:1.5rem;left:50%;transform:translateX(-50%);background:rgba(13,19,33,.85);border:1px solid var(--border);border-radius:30px;padding:.6rem 1.25rem;display:flex;gap:1.5rem;align-items:center;z-index:60;backdrop-filter:blur(8px)}
.hud-item{font-size:.75rem;color:var(--muted);display:flex;align-items:center;gap:.4rem;white-space:nowrap}
.hud-item i{color:var(--accent);font-size:.7rem}
/* ── Center label ── */
#centerLabel{position:fixed;left:50%;top:50%;transform:translate(-50%,-50%);text-align:center;pointer-events:none;z-index:30;opacity:0;transition:opacity 1s 1.5s}
#centerLabel.visible{opacity:1}
.center-wb{font-family:var(--font-mono);font-size:2rem;font-weight:700;color:var(--accent);text-shadow:0 0 30px rgba(0,212,255,.6),0 0 60px rgba(0,212,255,.3);letter-spacing:.15em}
.center-sub{font-size:.8rem;color:var(--muted);margin-top:.3rem;letter-spacing:.12em;text-transform:uppercase}
/* ── Scanline overlay ── */
#scanlines{position:fixed;inset:0;top:var(--nav-h);pointer-events:none;z-index:20;background:repeating-linear-gradient(0deg,transparent,transparent 2px,rgba(0,0,0,.03) 2px,rgba(0,0,0,.03) 4px);opacity:.4}
</style>
</head>
<body>
<nav class="site-nav" id="siteNav">
<div class="nav-inner">
<a class="nav-brand" href="index.html"><span class="brand-bracket">[</span>wb<span class="brand-bracket">]</span></a>
<button class="nav-toggle" type="button" data-bs-toggle="collapse" data-bs-target="#navLinksGalaxy" aria-label="Toggle navigation" aria-expanded="false" aria-controls="navLinksGalaxy">
<i class="fas fa-bars"></i>
</button>
<div class="collapse nav-links" id="navLinksGalaxy">
<a class="nav-link-item" href="index.html">Dashboard</a>
<a class="nav-link-item" href="projects.html">Projects</a>
<a class="nav-link-item" href="data-science.html">Data Science</a>
<a class="nav-link-item" href="ai-lab.html">AI Lab</a>
<a class="nav-link-item" href="go-systems.html">Go Systems</a>
<a class="nav-link-item active" href="code-galaxy.html">Code Galaxy</a>
<a class="nav-link-item" href="analytics.html">Analytics</a>
<a class="nav-link-item" href="https://github.com/brackenw3" target="_blank" rel="noopener noreferrer"><i class="fab fa-github"></i> GitHub</a>
</div>
</div>
</nav>
<div id="loader">
<div class="loader-ring"></div>
<div class="loader-text" id="loaderText">Initialising galaxy…</div>
</div>
<div id="galaxy"></div>
<div id="scanlines" aria-hidden="true"></div>
<div id="centerLabel" aria-hidden="true">
<div class="center-wb">WB</div>
<div class="center-sub">brackenw3</div>
</div>
<div id="infoPanel" role="dialog" aria-label="Repository info">
<button class="info-close" id="infoClose" aria-label="Close panel"><i class="fas fa-xmark"></i></button>
<div class="info-name" id="infoName">—</div>
<div class="info-desc" id="infoDesc">—</div>
<div class="info-meta">
<span class="info-stat"><i class="fas fa-star" style="color:#ffd700;font-size:.85rem"></i> <span id="infoStars">0</span></span>
<span class="info-stat"><i class="fas fa-code-branch" style="font-size:.85rem"></i> <span id="infoForks">0</span></span>
<span class="info-lang"><span class="lang-dot" id="infoLangDot"></span><span id="infoLang">—</span></span>
</div>
<a class="info-btn" id="infoLink" href="#" target="_blank" rel="noopener noreferrer">View on GitHub ↗</a>
</div>
<div id="hud" aria-label="Controls">
<span class="hud-item"><i class="fas fa-arrows-alt"></i> Drag to rotate</span>
<span class="hud-item"><i class="fas fa-search-plus"></i> Scroll to zoom</span>
<span class="hud-item"><i class="fas fa-hand-pointer"></i> Click node to explore</span>
<span class="hud-item" id="hudRepos">— repos</span>
</div>
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/"
}
}
</script>
<script type="module">
import * as THREE from 'three';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
const LANG_COLORS = {
Go:'#00ADD8',Python:'#3776AB',JavaScript:'#F7DF1E',TypeScript:'#3178C6',
HTML:'#E34F26',CSS:'#1572B6',Shell:'#4EAA25',Dockerfile:'#2496ED',default:'#8892a4'
};
// ── Scene setup ──
const container = document.getElementById('galaxy');
const W = () => window.innerWidth;
const H = () => window.innerHeight - 60;
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false });
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(W(), H());
renderer.setClearColor(0x080c14);
container.appendChild(renderer.domElement);
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(60, W() / H(), 0.1, 1000);
camera.position.set(0, 20, 60);
const controls = new OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
controls.dampingFactor = 0.06;
controls.minDistance = 15;
controls.maxDistance = 150;
controls.autoRotate = true;
controls.autoRotateSpeed = 0.35;
// ── Star field ──
function buildStars(count) {
const geo = new THREE.BufferGeometry();
const pos = new Float32Array(count * 3);
const col = new Float32Array(count * 3);
for (let i = 0; i < count; i++) {
const r = 80 + Math.random() * 200;
const theta = Math.random() * Math.PI * 2;
const phi = Math.acos(2 * Math.random() - 1);
pos[i*3] = r * Math.sin(phi) * Math.cos(theta);
pos[i*3+1] = r * Math.cos(phi) * 0.4;
pos[i*3+2] = r * Math.sin(phi) * Math.sin(theta);
const brightness = 0.4 + Math.random() * 0.6;
const hue = Math.random() < 0.15 ? 0.55 : (Math.random() < 0.08 ? 0.1 : 0);
col[i*3] = brightness + (hue === 0.55 ? 0 : brightness * 0.1);
col[i*3+1] = brightness + (hue === 0.55 ? brightness * 0.2 : 0);
col[i*3+2] = brightness + (hue === 0.55 ? brightness * 0.2 : 0);
}
geo.setAttribute('position', new THREE.BufferAttribute(pos, 3));
geo.setAttribute('color', new THREE.BufferAttribute(col, 3));
const mat = new THREE.PointsMaterial({ size: 0.28, vertexColors: true, sizeAttenuation: true });
return new THREE.Points(geo, mat);
}
scene.add(buildStars(5000));
// ── Nebula particles ──
function buildNebula() {
const geo = new THREE.BufferGeometry();
const pos = new Float32Array(800 * 3);
for (let i = 0; i < 800; i++) {
const r = 25 + Math.random() * 30;
const a = Math.random() * Math.PI * 2;
pos[i*3] = Math.cos(a) * r + (Math.random()-.5)*8;
pos[i*3+1] = (Math.random()-.5) * 5;
pos[i*3+2] = Math.sin(a) * r + (Math.random()-.5)*8;
}
geo.setAttribute('position', new THREE.BufferAttribute(pos, 3));
const mat = new THREE.PointsMaterial({ size: 0.9, color: 0x003344, transparent: true, opacity: 0.4, sizeAttenuation: true });
return new THREE.Points(geo, mat);
}
scene.add(buildNebula());
// ── Central WB node ──
const coreGeo = new THREE.SphereGeometry(2.2, 32, 32);
const coreMat = new THREE.MeshBasicMaterial({ color: 0x00d4ff });
const core = new THREE.Mesh(coreGeo, coreMat);
scene.add(core);
// Glow ring
const ringGeo = new THREE.RingGeometry(3.0, 3.6, 64);
const ringMat = new THREE.MeshBasicMaterial({ color: 0x00d4ff, transparent: true, opacity: 0.2, side: THREE.DoubleSide });
const ring = new THREE.Mesh(ringGeo, ringMat);
ring.rotation.x = Math.PI / 2;
scene.add(ring);
// Pulse sphere
const pulseGeo = new THREE.SphereGeometry(2.5, 32, 32);
const pulseMat = new THREE.MeshBasicMaterial({ color: 0x00d4ff, transparent: true, opacity: 0.08, wireframe: true });
const pulse = new THREE.Mesh(pulseGeo, pulseMat);
scene.add(pulse);
// ── Repo nodes ──
const repoMeshes = [];
let repos = [];
function buildOrbitLine(radius) {
const pts = [];
for (let i = 0; i <= 128; i++) {
const a = (i / 128) * Math.PI * 2;
pts.push(new THREE.Vector3(Math.cos(a) * radius, 0, Math.sin(a) * radius));
}
const geo = new THREE.BufferGeometry().setFromPoints(pts);
const mat = new THREE.LineBasicMaterial({ color: 0x00d4ff, transparent: true, opacity: 0.07 });
return new THREE.Line(geo, mat);
}
function hexToInt(hex) {
return parseInt((hex || '#8892a4').replace('#',''), 16);
}
function buildRepoNodes(repoList) {
const orbitRadii = [10, 15, 20, 26, 32];
const counts = [2, 2, 3, 2, 1]; // repos per orbit
let ri = 0;
orbitRadii.forEach((radius, oi) => {
scene.add(buildOrbitLine(radius));
const n = counts[oi];
for (let j = 0; j < n && ri < repoList.length; j++, ri++) {
const repo = repoList[ri];
const angle = (j / n) * Math.PI * 2 + oi * 0.7;
const langCol = LANG_COLORS[repo.language] || LANG_COLORS.default;
const color = hexToInt(langCol);
const geo = new THREE.SphereGeometry(0.75, 16, 16);
const mat = new THREE.MeshBasicMaterial({ color });
const mesh = new THREE.Mesh(geo, mat);
mesh.position.set(Math.cos(angle) * radius, (Math.random()-.5)*2, Math.sin(angle) * radius);
mesh.userData = { repo, radius, angle, speed: 0.0015 + Math.random()*0.001, color };
scene.add(mesh);
// Glow halo
const hGeo = new THREE.SphereGeometry(1.1, 16, 16);
const hMat = new THREE.MeshBasicMaterial({ color, transparent: true, opacity: 0.12, wireframe: false });
const halo = new THREE.Mesh(hGeo, hMat);
mesh.add(halo);
// Connection line to core
const linePts = [new THREE.Vector3(0,0,0), mesh.position.clone()];
const lineGeo = new THREE.BufferGeometry().setFromPoints(linePts);
const lineMat = new THREE.LineBasicMaterial({ color, transparent: true, opacity: 0.12 });
const line = new THREE.Line(lineGeo, lineMat);
scene.add(line);
mesh.userData.line = line;
mesh.userData.lineMat = lineMat;
repoMeshes.push(mesh);
}
});
}
// ── Raycasting / click ──
const raycaster = new THREE.Raycaster();
const mouse = new THREE.Vector2();
let hoveredMesh = null;
function showPanel(repo, langCol) {
document.getElementById('infoName').textContent = repo.name;
document.getElementById('infoDesc').textContent = repo.description || 'No description.';
document.getElementById('infoStars').textContent = repo.stargazers_count;
document.getElementById('infoForks').textContent = repo.forks_count;
document.getElementById('infoLang').textContent = repo.language || '—';
document.getElementById('infoLangDot').style.background = langCol;
document.getElementById('infoLink').href = repo.html_url;
document.getElementById('infoPanel').classList.add('visible');
controls.autoRotate = false;
}
document.getElementById('infoClose').addEventListener('click', () => {
document.getElementById('infoPanel').classList.remove('visible');
controls.autoRotate = true;
});
renderer.domElement.addEventListener('click', e => {
const rect = renderer.domElement.getBoundingClientRect();
mouse.x = ((e.clientX - rect.left) / rect.width) * 2 - 1;
mouse.y = -((e.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(mouse, camera);
const hits = raycaster.intersectObjects(repoMeshes);
if (hits.length) {
const m = hits[0].object;
const lc = LANG_COLORS[m.userData.repo.language] || LANG_COLORS.default;
showPanel(m.userData.repo, lc);
}
});
renderer.domElement.addEventListener('mousemove', e => {
const rect = renderer.domElement.getBoundingClientRect();
mouse.x = ((e.clientX - rect.left) / rect.width) * 2 - 1;
mouse.y = -((e.clientY - rect.top) / rect.height) * 2 + 1;
raycaster.setFromCamera(mouse, camera);
const hits = raycaster.intersectObjects(repoMeshes);
if (hoveredMesh && (!hits.length || hits[0].object !== hoveredMesh)) {
hoveredMesh.scale.setScalar(1);
renderer.domElement.style.cursor = 'default';
hoveredMesh = null;
}
if (hits.length) {
hoveredMesh = hits[0].object;
hoveredMesh.scale.setScalar(1.35);
renderer.domElement.style.cursor = 'pointer';
}
});
// ── Fetch repos ──
async function loadRepos() {
document.getElementById('loaderText').textContent = 'Fetching repositories…';
try {
const res = await fetch('https://api.github.com/users/brackenw3/repos?per_page=100&sort=stars');
if (!res.ok) throw new Error(res.status);
repos = (await res.json()).filter(r => !r.fork && !r.private).slice(0, 10);
document.getElementById('hudRepos').textContent = repos.length + ' repos';
buildRepoNodes(repos);
} catch {
document.getElementById('hudRepos').textContent = 'offline mode';
// Fallback static repos
const fallback = [
{name:'VSCode_Folders',description:'Main monorepo',language:'TypeScript',stargazers_count:0,forks_count:0,html_url:'https://github.com/brackenw3/VSCode_Folders'},
{name:'brackenw3.github.io',description:'Portfolio site',language:'JavaScript',stargazers_count:0,forks_count:0,html_url:'https://github.com/brackenw3/brackenw3.github.io'},
{name:'Go-Scripts',description:'Go tooling',language:'Go',stargazers_count:0,forks_count:0,html_url:'https://github.com/brackenw3/Go-Scripts'},
{name:'GH_Models',description:'AI gateway',language:'Python',stargazers_count:0,forks_count:0,html_url:'https://github.com/brackenw3/GH_Models'},
{name:'ClaudeAI',description:'AI integration',language:'JavaScript',stargazers_count:0,forks_count:0,html_url:'https://github.com/brackenw3/ClaudeAI'},
{name:'WSL_Docker',description:'Dev environment',language:'Shell',stargazers_count:0,forks_count:0,html_url:'https://github.com/brackenw3/WSL_Docker'},
];
buildRepoNodes(fallback);
}
// Hide loader
const loader = document.getElementById('loader');
loader.classList.add('hidden');
setTimeout(() => { loader.style.display='none'; }, 700);
document.getElementById('centerLabel').classList.add('visible');
}
// ── Animate ──
const clock = new THREE.Clock();
function animate() {
requestAnimationFrame(animate);
const t = clock.getElapsedTime();
// Pulse core
const s = 1 + Math.sin(t * 1.8) * 0.06;
pulse.scale.setScalar(s);
pulseMat.opacity = 0.05 + Math.sin(t * 1.8) * 0.04;
ring.rotation.z = t * 0.25;
// Orbit repo nodes
repoMeshes.forEach(m => {
m.userData.angle += m.userData.speed;
const a = m.userData.angle;
const r = m.userData.radius;
m.position.x = Math.cos(a) * r;
m.position.z = Math.sin(a) * r;
// Update connection line
if (m.userData.line) {
const positions = m.userData.line.geometry.attributes.position;
positions.setXYZ(1, m.position.x, m.position.y, m.position.z);
positions.needsUpdate = true;
}
});
controls.update();
renderer.render(scene, camera);
}
window.addEventListener('resize', () => {
camera.aspect = W() / H();
camera.updateProjectionMatrix();
renderer.setSize(W(), H());
});
loadRepos();
animate();
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>