-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcyberpunk-network.html
More file actions
574 lines (492 loc) · 24.2 KB
/
cyberpunk-network.html
File metadata and controls
574 lines (492 loc) · 24.2 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
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Cyberpunk Network - Miles Waite</title>
<style>
body {
margin: 0;
padding: 0;
overflow: hidden;
background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
font-family: 'Courier New', monospace;
cursor: crosshair;
}
#network-canvas {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1;
}
.text-label {
position: absolute;
color: #333;
font-size: 14px;
font-weight: bold;
pointer-events: none;
z-index: 10;
opacity: 0;
transition: opacity 0.5s ease;
background: rgba(255, 255, 255, 0.3);
padding: 8px 12px;
border: 2px solid rgba(102, 102, 102, 0.4);
box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.text-label.square {
border-radius: 0px;
border-style: solid;
min-width: 80px;
text-align: center;
padding: 10px 15px;
}
.text-label.rectangle {
border-radius: 3px;
border-style: solid;
padding: 15px 25px;
min-width: 120px;
min-height: 40px;
display: flex;
align-items: center;
justify-content: center;
border-width: 1px;
}
.text-label.visible {
opacity: 1;
}
</style>
</head>
<body>
<canvas id="network-canvas"></canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script>
class CyberpunkNetwork {
constructor() {
this.canvas = document.getElementById('network-canvas');
this.scene = new THREE.Scene();
this.camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
this.renderer = new THREE.WebGLRenderer({ canvas: this.canvas, antialias: true });
this.nodes = [];
this.connections = [];
this.textLabels = [];
this.verticalRects = [];
this.centralSphere = null;
this.mouse = new THREE.Vector2();
this.time = 0;
// Mixed text and number labels for the network
this.labelTexts = [
"0.847", "Neural pathways", "3.142", "To the feeling", "127.0.0.1",
"Take me back", "99.7%", "Data streams", "404", "Say it again",
"Complex systems", "2048", "Emergent patterns", "0xFF", "Adaptive networks",
"Information flow", "1337", "Cognitive maps", "0.001ms", "I'm losing myself",
"Memory traces", "512MB", "Signal processing", "3.14159", "Pattern recognition",
"System dynamics", "0xDEADBEEF", "Processing...", "100%", "Connection established"
];
this.init();
this.createNetwork();
this.createCentralSphere();
this.createVerticalRectangles();
this.createTextLabels();
this.animate();
this.setupEventListeners();
}
init() {
this.renderer.setSize(window.innerWidth, window.innerHeight);
this.renderer.setClearColor(0xfafafa, 1);
this.camera.position.z = 50;
}
createNetwork() {
// Create glowing nodes in 3D layers
for (let i = 0; i < 40; i++) {
const node = this.createGlowingNode(i);
this.nodes.push(node);
this.scene.add(node.mesh);
}
this.updateConnections();
}
createGlowingNode(index) {
// Core wireframe sphere - very clear black lattice lines
const coreSize = 0.3 + Math.random() * 0.5;
const coreGeometry = new THREE.SphereGeometry(coreSize, 20, 20);
const coreMaterial = new THREE.MeshBasicMaterial({
color: 0x000000,
transparent: false,
wireframe: true
});
const core = new THREE.Mesh(coreGeometry, coreMaterial);
// Outer glow effect - subtle gray
const glowSize = 1 + Math.random() * 1.5;
const glowGeometry = new THREE.SphereGeometry(glowSize, 16, 16);
const glowMaterial = new THREE.MeshBasicMaterial({
color: 0x666666,
transparent: true,
opacity: 0.15
});
const glow = new THREE.Mesh(glowGeometry, glowMaterial);
// Lattice wireframe effect - black lines for clarity
const sparkleSize = glowSize * 1.2;
const sparkleGeometry = new THREE.SphereGeometry(sparkleSize, 16, 16);
const sparkleMaterial = new THREE.MeshBasicMaterial({
color: 0x000000,
transparent: true,
opacity: 0.6,
wireframe: true
});
const sparkle = new THREE.Mesh(sparkleGeometry, sparkleMaterial);
// Group them together
const group = new THREE.Group();
group.add(core);
group.add(glow);
group.add(sparkle);
// 3D layered positioning - create depth
const layer = Math.floor(index / 10); // 4 layers
const zDepth = -60 + (layer * 40); // Spread across Z axis
group.position.set(
(Math.random() - 0.5) * (100 + layer * 20),
(Math.random() - 0.5) * (80 + layer * 15),
zDepth + (Math.random() - 0.5) * 20
);
return {
mesh: group,
core: core,
glow: glow,
sparkle: sparkle,
connections: [],
energy: Math.random(),
phase: Math.random() * Math.PI * 2,
pulseSpeed: 1 + Math.random() * 2,
layer: layer,
size: coreSize
};
}
updateConnections() {
// Remove old connections
this.connections.forEach(connection => {
this.scene.remove(connection);
});
this.connections = [];
// Clear node connections
this.nodes.forEach(node => {
node.connections = [];
});
// Create 3D layered connections
for (let i = 0; i < this.nodes.length; i++) {
for (let j = i + 1; j < this.nodes.length; j++) {
const node1 = this.nodes[i];
const node2 = this.nodes[j];
const distance = node1.mesh.position.distanceTo(node2.mesh.position);
// Different connection rules for different layers
const layerDiff = Math.abs(node1.layer - node2.layer);
let connectionChance = 0.3;
let maxDistance = 35;
// Same layer connections are more likely and closer
if (layerDiff === 0) {
connectionChance = 0.5;
maxDistance = 30;
}
// Cross-layer connections (create depth)
else if (layerDiff === 1) {
connectionChance = 0.4;
maxDistance = 45;
}
// Long-range depth connections
else if (layerDiff >= 2) {
connectionChance = 0.2;
maxDistance = 60;
}
if (distance < maxDistance && Math.random() < connectionChance) {
const connection = this.createLaserConnection(node1, node2, layerDiff);
this.connections.push(connection);
this.scene.add(connection);
node1.connections.push(node2);
node2.connections.push(node1);
}
}
}
}
createLaserConnection(node1, node2, layerDiff) {
const geometry = new THREE.BufferGeometry();
const positions = new Float32Array([
node1.mesh.position.x, node1.mesh.position.y, node1.mesh.position.z,
node2.mesh.position.x, node2.mesh.position.y, node2.mesh.position.z
]);
geometry.setAttribute('position', new THREE.BufferAttribute(positions, 3));
// Dark gray connection lines based on depth
let lineColor = 0x666666;
let opacity = 0.8;
// Background connections are dimmer
if (layerDiff === 0) {
opacity = 0.9; // Same layer - darkest
lineColor = 0x333333;
} else if (layerDiff === 1) {
opacity = 0.6; // Adjacent layers
lineColor = 0x555555;
} else {
opacity = 0.3; // Far layers - lightest
lineColor = 0x777777;
}
const material = new THREE.LineBasicMaterial({
color: lineColor,
transparent: true,
opacity: opacity,
linewidth: 2
});
const line = new THREE.Line(geometry, material);
line.userData = {
node1,
node2,
phase: Math.random() * Math.PI * 2,
layerDiff: layerDiff,
baseOpacity: opacity
};
return line;
}
createCentralSphere() {
// Create a large central wireframe sphere - always prominent
const sphereGeometry = new THREE.SphereGeometry(8, 32, 32);
const sphereWireframe = new THREE.EdgesGeometry(sphereGeometry);
const sphereMaterial = new THREE.LineBasicMaterial({
color: 0x000000,
transparent: true,
opacity: 0.4
});
this.centralSphere = new THREE.LineSegments(sphereWireframe, sphereMaterial);
// Position it prominently in the frame
this.centralSphere.position.set(5, -5, 0);
this.scene.add(this.centralSphere);
}
createVerticalRectangles() {
// Create 2 outline-only rectangular structures
for (let i = 0; i < 2; i++) {
const rectGroup = new THREE.Group();
// Different sizes - one large, one normal
let width, height;
if (i === 0) {
// Large rectangle that extends beyond screen
width = 12;
height = 80; // Very tall to go off-screen
} else {
// Normal sized rectangle
width = 6;
height = 25;
}
// Create only wireframe outline - no fill
const rectGeometry = new THREE.PlaneGeometry(width, height);
const wireframeGeometry = new THREE.EdgesGeometry(rectGeometry);
const wireframeMaterial = new THREE.LineBasicMaterial({
color: 0x000000,
transparent: true,
opacity: 0.7
});
const wireframe = new THREE.LineSegments(wireframeGeometry, wireframeMaterial);
rectGroup.add(wireframe); // Only add wireframe, no fill
// Position rectangles strategically
if (i === 0) {
// Place large rectangle so 1/3 extends off screen
rectGroup.position.set(-35, 0, -30); // Moved further left
rectGroup.rotation.y = 0.1; // Slight angle
} else {
// Position smaller rectangle to the side
rectGroup.position.set(25, -3, -15);
rectGroup.rotation.y = -0.2;
}
this.verticalRects.push({
group: rectGroup,
originalPosition: rectGroup.position.clone(),
phase: Math.random() * Math.PI * 2,
rotationSpeed: 0.0003 + Math.random() * 0.0005,
isLarge: i === 0
});
this.scene.add(rectGroup);
}
}
createTextLabels() {
this.labelTexts.forEach((text, index) => {
const label = document.createElement('div');
// Only use squares and rectangles
label.textContent = text;
label.style.left = Math.random() * (window.innerWidth - 350) + 'px';
label.style.top = Math.random() * (window.innerHeight - 120) + 'px';
// Smart styling based on content type
if (/^[0-9.%x]+$/i.test(text) || text.includes('MB') || text.includes('ms') || text.includes('127.0.0.1') || text.includes('404')) {
// Numbers and technical data get square frames
label.className = 'text-label square';
label.style.fontFamily = 'monospace';
} else {
// Text phrases get rectangle frames
label.className = 'text-label rectangle';
}
document.body.appendChild(label);
this.textLabels.push({
element: label,
showTime: Math.random() * 15 + 5, // Spread out start times more
duration: 4 + Math.random() * 6, // Longer duration
isActive: false
});
});
}
animate() {
this.time += 0.016;
this.updateNodes();
// Update connections much slower for gentle flickering
if (Math.floor(this.time * 10) % 150 === 0) {
this.updateConnections();
} else {
this.updateConnectionVisuals();
}
this.updateCentralSphere();
this.updateVerticalRectangles();
this.updateTextLabels();
this.updateCamera();
this.renderer.render(this.scene, this.camera);
requestAnimationFrame(() => this.animate());
}
updateNodes() {
this.nodes.forEach((node, index) => {
// Pulsing glow effect
const pulse = Math.sin(this.time * node.pulseSpeed + node.phase) * 0.5 + 0.5;
// Update core brightness
node.core.material.opacity = 0.8 + pulse * 0.2;
// Update glow intensity
node.glow.material.opacity = 0.05 + pulse * 0.1;
node.glow.scale.setScalar(1 + pulse * 0.3);
// Update sparkle effect
node.sparkle.material.opacity = 0.02 + pulse * 0.03;
node.sparkle.rotation.x += 0.01;
node.sparkle.rotation.y += 0.015;
// Gentle floating movement
node.mesh.position.x += Math.sin(this.time * 0.3 + node.phase) * 0.02;
node.mesh.position.y += Math.cos(this.time * 0.2 + node.phase * 1.5) * 0.015;
node.mesh.position.z += Math.sin(this.time * 0.4 + node.phase * 0.7) * 0.01;
// Connection-based brightness
const connectionCount = node.connections.length;
const brightness = Math.min(connectionCount * 0.1 + 0.5, 1);
node.core.material.color.setScalar(brightness);
});
}
updateCentralSphere() {
// Gentle rotation to show the wireframe structure
this.centralSphere.rotation.x += 0.003;
this.centralSphere.rotation.y += 0.005;
// Subtle floating movement
this.centralSphere.position.y = -5 + Math.sin(this.time * 0.3) * 2;
// Gentle opacity pulsing
const pulse = Math.sin(this.time * 0.8) * 0.1 + 0.4;
this.centralSphere.material.opacity = pulse;
}
updateVerticalRectangles() {
this.verticalRects.forEach(rectData => {
if (rectData.isLarge) {
// Large rectangle moves very slowly and subtly
rectData.group.position.y = rectData.originalPosition.y + Math.sin(this.time * 0.15 + rectData.phase) * 3;
rectData.group.rotation.y += rectData.rotationSpeed * 0.3; // Very slow rotation
// Subtle opacity changes for wireframe only
const pulse = Math.sin(this.time * 0.6 + rectData.phase) * 0.1 + 0.7;
rectData.group.children[0].material.opacity = pulse; // Only wireframe now
} else {
// Normal rectangle with standard movement
rectData.group.position.y = rectData.originalPosition.y + Math.sin(this.time * 0.4 + rectData.phase) * 2;
rectData.group.rotation.y += rectData.rotationSpeed;
const pulse = Math.sin(this.time * 1.0 + rectData.phase) * 0.15 + 0.7;
rectData.group.children[0].material.opacity = pulse; // Only wireframe now
}
});
}
updateConnectionVisuals() {
this.connections.forEach(connection => {
// Keep connections stable - no flickering
connection.material.opacity = connection.userData.baseOpacity;
// Update positions smoothly
const positions = connection.geometry.attributes.position.array;
positions[0] = connection.userData.node1.mesh.position.x;
positions[1] = connection.userData.node1.mesh.position.y;
positions[2] = connection.userData.node1.mesh.position.z;
positions[3] = connection.userData.node2.mesh.position.x;
positions[4] = connection.userData.node2.mesh.position.y;
positions[5] = connection.userData.node2.mesh.position.z;
connection.geometry.attributes.position.needsUpdate = true;
});
}
updateTextLabels() {
// Count currently active labels
let activeCount = 0;
this.textLabels.forEach(label => {
if (label.element.classList.contains('visible')) {
activeCount++;
}
});
this.textLabels.forEach(label => {
const shouldShow = this.time > label.showTime && this.time < label.showTime + label.duration;
const isCurrentlyVisible = label.element.classList.contains('visible');
// Only show if we have less than 7 active labels or if it's already visible
if (shouldShow && (!isCurrentlyVisible && activeCount < 7 || isCurrentlyVisible)) {
if (!isCurrentlyVisible) {
activeCount++;
}
label.element.classList.add('visible');
label.isActive = true;
} else {
label.element.classList.remove('visible');
label.isActive = false;
}
// Reset cycle with longer delays
if (this.time > label.showTime + label.duration + 3) {
label.showTime = this.time + Math.random() * 8 + 3; // Longer gaps between appearances
label.duration = 4 + Math.random() * 6;
// Reposition
label.element.style.left = Math.random() * (window.innerWidth - 350) + 'px';
label.element.style.top = Math.random() * (window.innerHeight - 120) + 'px';
}
});
}
updateCamera() {
// More dramatic 3D camera movement
this.camera.position.x += (this.mouse.x * 8 - this.camera.position.x) * 0.02;
this.camera.position.y += (this.mouse.y * 6 - this.camera.position.y) * 0.02;
// Subtle Z movement for depth perception
this.camera.position.z = 50 + Math.sin(this.time * 0.1) * 10;
this.camera.lookAt(this.scene.position);
// Gentle camera drift in 3D space
this.camera.position.x += Math.sin(this.time * 0.1) * 0.1;
this.camera.position.y += Math.cos(this.time * 0.08) * 0.08;
// Slight rotation for dynamic perspective
this.camera.rotation.z = Math.sin(this.time * 0.05) * 0.02;
}
setupEventListeners() {
window.addEventListener('resize', () => {
this.camera.aspect = window.innerWidth / window.innerHeight;
this.camera.updateProjectionMatrix();
this.renderer.setSize(window.innerWidth, window.innerHeight);
});
document.addEventListener('mousemove', (event) => {
this.mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
this.mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
});
// Regenerate network on click
document.addEventListener('click', () => {
this.regenerateNetwork();
});
}
regenerateNetwork() {
// Clear existing
this.nodes.forEach(node => {
this.scene.remove(node.mesh);
});
this.connections.forEach(connection => {
this.scene.remove(connection);
});
this.nodes = [];
this.connections = [];
// Recreate
this.createNetwork();
}
}
// Initialize
window.addEventListener('load', () => {
new CyberpunkNetwork();
});
</script>
</body>
</html>