File size: 12,487 Bytes
d1989ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b58fde2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d1989ab
 
 
b58fde2
 
d1989ab
d2a0afe
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Neural Network Visualization</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
    <style>
        body {
            margin: 0;
            overflow: hidden;
            background-color: #000;
        }
        #canvas-container {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }
        .overlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: 10;
        }
        .title {
            position: absolute;
            top: 20%;
            left: 50%;
            transform: translate(-50%, -50%);
            color: #00f3ff;
            font-family: 'Arial', sans-serif;
            font-size: 3rem;
            text-align: center;
            text-shadow: 0 0 10px #00f3ff, 0 0 20px #00f3ff;
            opacity: 0.9;
        }
        .subtitle {
            position: absolute;
            top: 30%;
            left: 50%;
            transform: translate(-50%, -50%);
            color: #ffffff;
            font-family: 'Arial', sans-serif;
            font-size: 1.5rem;
            text-align: center;
            opacity: 0.7;
        }
        .controls {
            position: absolute;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            color: white;
            font-family: 'Arial', sans-serif;
            text-align: center;
            background: rgba(0, 0, 0, 0.5);
            padding: 10px 20px;
            border-radius: 10px;
        }
    </style>
</head>
<body>
    <div id="canvas-container"></div>
    <div class="overlay">
        <div class="title">GENETIC NEURAL NETWORK</div>
        <div class="subtitle">DYNAMIC PATHWAY ACTIVATION</div>
        <div class="controls">Broadcast Visualization</div>
    </div>

    <script>
        // Main Three.js variables
        let scene, camera, renderer;
        let nodes = [];
        let connections = [];
        let connectionLines = [];
        let nodeMeshes = [];
        let lightningGroup = new THREE.Group();
        let networkGroup = new THREE.Group();
        
        // Configuration
        const NODE_COUNT = 80;
        const CONNECTION_DENSITY = 0.15;
        const NODE_RADIUS = 0.2;
        const CONNECTION_WIDTH = 0.03;
        const ROTATION_SPEED = 0.001;
        const PULSE_SPEED = 0.02;
        const LIGHTNING_CHANCE = 0.005;
        let currentCameraAngle = 0;
        let cameraRadius = 25;
        let targetCameraRadius = 25;
        
        // Initialize Three.js
        function init() {
            // Create scene
            scene = new THREE.Scene();
            scene.background = new THREE.Color(0x000011);
            scene.fog = new THREE.Fog(0x000011, 15, 30);
            
            // Create camera
            camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
            camera.position.set(0, 0, 25);
            
            // Create renderer
            renderer = new THREE.WebGLRenderer({ antialias: true });
            renderer.setSize(window.innerWidth, window.innerHeight);
            renderer.setPixelRatio(window.devicePixelRatio);
            document.getElementById('canvas-container').appendChild(renderer.domElement);
            
            // Add groups to scene
            scene.add(networkGroup);
            scene.add(lightningGroup);
            
            // Create neural network
            createNodes();
            createConnections();
            
            // Add ambient light
            const ambientLight = new THREE.AmbientLight(0x222255);
            scene.add(ambientLight);
            
            // Add directional light
            const directionalLight = new THREE.DirectionalLight(0x00aaff, 1);
            directionalLight.position.set(5, 5, 5);
            scene.add(directionalLight);
            
            // Add point lights for more dynamic lighting
            const pointLight1 = new THREE.PointLight(0xff00ff, 1, 100);
            pointLight1.position.set(10, 10, 10);
            scene.add(pointLight1);
            
            const pointLight2 = new THREE.PointLight(0x00ffff, 1, 100);
            pointLight2.position.set(-10, -10, -10);
            scene.add(pointLight2);
            
            // Handle window resize
            window.addEventListener('resize', onWindowResize);
            
            // Start animation loop
            animate();
        }
        
        function createNodes() {
            // Create nodes in a spherical distribution
            for (let i = 0; i < NODE_COUNT; i++) {
                const phi = Math.acos(-1 + (2 * i) / NODE_COUNT);
                const theta = Math.sqrt(NODE_COUNT * Math.PI) * phi;
                
                const x = 10 * Math.cos(theta) * Math.sin(phi);
                const y = 10 * Math.sin(theta) * Math.sin(phi);
                const z = 10 * Math.cos(phi);
                
                nodes.push(new THREE.Vector3(x, y, z));
                
                // Create node mesh
                const geometry = new THREE.SphereGeometry(NODE_RADIUS, 16, 16);
                const material = new THREE.MeshPhongMaterial({ 
                    color: 0x00ffff,
                    emissive: 0x0066aa,
                    emissiveIntensity: 0.5,
                    transparent: true,
                    opacity: 0.8
                });
                
                const nodeMesh = new THREE.Mesh(geometry, material);
                nodeMesh.position.copy(nodes[i]);
                nodeMesh.userData.originalScale = 1;
                nodeMesh.userData.pulsePhase = Math.random() * Math.PI * 2;
                nodeMeshes.push(nodeMesh);
                networkGroup.add(nodeMesh);
            }
        }
        
        function createConnections() {
            // Create connections between nodes
            for (let i = 0; i < NODE_COUNT; i++) {
                for (let j = i + 1; j < NODE_COUNT; j++) {
                    // Randomly create connections based on density
                    if (Math.random() < CONNECTION_DENSITY) {
                        connections.push([i, j]);
                        
                        // Create connection line
                        const material = new THREE.LineBasicMaterial({ 
                            color: 0x00aaff,
                            transparent: true,
                            opacity: 0.3
                        });
                        
                        const points = [
                            nodes[i].clone(),
                            nodes[j].clone()
                        ];
                        
                        const geometry = new THREE.BufferGeometry().setFromPoints(points);
                        const line = new THREE.Line(geometry, material);
                        line.userData.nodes = [i, j];
                        line.userData.active = false;
                        line.userData.intensity = 0;
                        connectionLines.push(line);
                        networkGroup.add(line);
                    }
                }
            }
        }
        
        function animateLightning() {
            // Randomly activate connections
            connectionLines.forEach(line => {
                if (Math.random() < LIGHTNING_CHANCE && !line.userData.active) {
                    line.userData.active = true;
                    line.userData.intensity = 1;
                    line.material.color.set(0xffffff);
                    line.material.opacity = 1;
                }
                
                // Animate active connections
                if (line.userData.active) {
                    line.userData.intensity -= 0.02;
                    line.material.opacity = line.userData.intensity;
                    
                    // Add lightning effect
                    if (Math.random() < 0.3) {
                        line.material.color.set(0xffff00);
                    } else {
                        line.material.color.set(0xffffff);
                    }
                    
                    // Deactivate when animation complete
                    if (line.userData.intensity <= 0) {
                        line.userData.active = false;
                        line.material.color.set(0x00aaff);
                        line.material.opacity = 0.3;
                    }
                }
            });
        }
        
        function animateNodes() {
            // Pulsing animation for nodes
            const time = Date.now() * 0.001;
            
            nodeMeshes.forEach((mesh, index) => {
                const pulse = Math.sin(time * PULSE_SPEED + mesh.userData.pulsePhase) * 0.2 + 0.8;
                mesh.scale.set(pulse, pulse, pulse);
                
                // Color cycling
                const hue = (time * 0.1 + index * 0.01) % 1;
                const color = new THREE.Color().setHSL(hue, 1, 0.5);
                mesh.material.emissive = color;
            });
        }
        
        function animateNetwork() {
            // Rotate the entire network
            networkGroup.rotation.x += ROTATION_SPEED * 0.5;
            networkGroup.rotation.y += ROTATION_SPEED;
            
            // Scale pulsing effect for growing/shrinking
            const time = Date.now() * 0.001;
            const scale = Math.sin(time * 0.5) * 0.3 + 0.7;
            networkGroup.scale.set(scale, scale, scale);
            
            // Dynamic camera movement
            currentCameraAngle += 0.002;
            targetCameraRadius = 20 + Math.sin(time * 0.3) * 5;
            cameraRadius += (targetCameraRadius - cameraRadius) * 0.05;
            
            camera.position.x = cameraRadius * Math.sin(currentCameraAngle);
            camera.position.z = cameraRadius * Math.cos(currentCameraAngle);
            camera.position.y = Math.sin(time * 0.4) * 5;
            camera.lookAt(scene.position);
        }
        
        function animate() {
            requestAnimationFrame(animate);
            
            animateLightning();
            animateNodes();
            animateNetwork();
            
            renderer.render(scene, camera);
        }
        function onWindowResize() {
            camera.aspect = window.innerWidth / window.innerHeight;
            camera.updateProjectionMatrix();
            renderer.setSize(window.innerWidth, window.innerHeight);
        }

        // Mouse interaction variables
        let isDragging = false;
        let previousMousePosition = { x: 0, y: 0 };
        
        // Mouse event handlers
        function onMouseDown(event) {
            isDragging = true;
            previousMousePosition = {
                x: event.clientX,
                y: event.clientY
            };
        }
        
        function onMouseMove(event) {
            if (!isDragging) return;
            
            const deltaX = event.clientX - previousMousePosition.x;
            const deltaY = event.clientY - previousMousePosition.y;
            
            networkGroup.rotation.y += deltaX * 0.01;
            networkGroup.rotation.x += deltaY * 0.01;
            
            previousMousePosition = {
                x: event.clientX,
                y: event.clientY
            };
        }
        
        function onMouseUp() {
            isDragging = false;
        }
        
        // Add mouse event listeners
        function addMouseControls() {
            renderer.domElement.addEventListener('mousedown', onMouseDown, false);
            renderer.domElement.addEventListener('mousemove', onMouseMove, false);
            renderer.domElement.addEventListener('mouseup', onMouseUp, false);
            renderer.domElement.addEventListener('mouseleave', onMouseUp, false);
            
            // Change cursor style
            renderer.domElement.style.cursor = 'grab';
        }
        
        // Initialize the visualization
        init();
        addMouseControls();
</script>
</body>
</html>