File size: 7,399 Bytes
adfbea1
333a7a1
 
 
 
 
adfbea1
 
 
 
 
 
333a7a1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
adfbea1
12078f7
 
 
 
62cae6c
adfbea1
 
 
 
 
62cae6c
adfbea1
 
 
62cae6c
adfbea1
 
 
 
 
 
 
12078f7
 
adfbea1
62cae6c
adfbea1
 
 
 
62cae6c
adfbea1
 
12078f7
62cae6c
adfbea1
 
12078f7
62cae6c
adfbea1
 
 
 
 
12078f7
 
adfbea1
 
12078f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
adfbea1
 
12078f7
adfbea1
12078f7
adfbea1
12078f7
adfbea1
 
12078f7
 
 
 
 
 
 
 
 
 
 
 
 
62cae6c
12078f7
 
 
 
 
 
 
 
 
62cae6c
adfbea1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62cae6c
12078f7
 
 
 
 
 
62cae6c
12078f7
 
 
 
62cae6c
 
12078f7
62cae6c
 
 
 
 
 
 
 
12078f7
adfbea1
 
12078f7
 
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

// Mobile menu toggle
document.addEventListener('DOMContentLoaded', function() {
    const mobileMenuButton = document.getElementById('mobile-menu-button');
    const mobileMenu = document.getElementById('mobile-menu');
    
    // Initialize 3D AI Scene
    initAIScene();
    
    // Scroll-based animation for 3D scene
    window.addEventListener('scroll', updateAIScene);
if (mobileMenuButton && mobileMenu) {
        mobileMenuButton.addEventListener('click', function() {
            mobileMenu.classList.toggle('hidden');
            
            // Change icon based on state
            const icon = mobileMenuButton.querySelector('i');
            if (mobileMenu.classList.contains('hidden')) {
                icon.setAttribute('data-feather', 'menu');
            } else {
                icon.setAttribute('data-feather', 'x');
            }
            feather.replace();
        });
    }
    
    // Close mobile menu when clicking outside
    document.addEventListener('click', function(event) {
        const isClickInsideNav = mobileMenuButton.contains(event.target) || mobileMenu.contains(event.target);
        
        if (!isClickInsideNav && !mobileMenu.classList.contains('hidden')) {
            mobileMenu.classList.add('hidden');
            const icon = mobileMenuButton.querySelector('i');
            icon.setAttribute('data-feather', 'menu');
            feather.replace();
        }
    });
    
    // Add fade-in animation to sections when they come into view
    const sections = document.querySelectorAll('section');
    
    const observerOptions = {
        root: null,
        rootMargin: '0px',
        threshold: 0.1
    };
    
    const observer = new IntersectionObserver((entries, observer) => {
        entries.forEach(entry => {
            if (entry.isIntersecting) {
                entry.target.classList.add('fade-in');
                observer.unobserve(entry.target);
            }
        });
    }, observerOptions);
    sections.forEach(section => {
        observer.observe(section);
    });
});

// Technology-inspired 3D Scene Implementation
let scene, camera, renderer;
let particles = [];
let connections = [];
let scrollProgress = 0;

function initAIScene() {
    // Create scene
    scene = new THREE.Scene();
    scene.background = new THREE.Color(0x000000);
    
    // Create camera
    camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
    camera.position.z = 15;
    
    // Create renderer
    renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
    renderer.setSize(window.innerWidth, window.innerHeight);
    renderer.setPixelRatio(window.devicePixelRatio);
    document.getElementById('ai-3d-canvas').appendChild(renderer.domElement);
    
    // Create technology-inspired particle network
    createParticleNetwork();
    
    // Add lighting
    const ambientLight = new THREE.AmbientLight(0x404040, 2);
    scene.add(ambientLight);
    
    const directionalLight = new THREE.DirectionalLight(0x00ffff, 1);
    directionalLight.position.set(5, 5, 5);
    scene.add(directionalLight);
    
    const pointLight1 = new THREE.PointLight(0x4dabf7, 1, 100);
    pointLight1.position.set(10, 10, 10);
    scene.add(pointLight1);
    
    const pointLight2 = new THREE.PointLight(0xe599f7, 1, 100);
    pointLight2.position.set(-10, -10, -10);
    scene.add(pointLight2);
    
    // Handle window resize
    window.addEventListener('resize', onWindowResize);
    
    // Initial render
    renderer.render(scene, camera);
}

function createParticleNetwork() {
    // Create particles in a grid formation
    const particleGeometry = new THREE.SphereGeometry(0.1, 16, 16);
    const particleMaterial = new THREE.MeshPhongMaterial({ 
        color: 0x4dabf7,
        emissive: 0x4dabf7,
        emissiveIntensity: 0.3,
        shininess: 100
    });
    
    // Create particles in a structured grid
    for (let x = -8; x <= 8; x += 2) {
        for (let y = -5; y <= 5; y += 2) {
            for (let z = -3; z <= 3; z += 2) {
                // Skip some particles to create a more interesting pattern
                if (Math.random() > 0.3) {
                    const particle = new THREE.Mesh(particleGeometry, particleMaterial.clone());
                    particle.position.set(x, y, z);
                    particle.userData = {
                        originalPosition: new THREE.Vector3(x, y, z),
                        connected: false
                    };
                    
                    scene.add(particle);
                    particles.push(particle);
                }
            }
        }
    }
    
    // Create connections between nearby particles
    const connectionMaterial = new THREE.LineBasicMaterial({ 
        color: 0x4dabf7,
        transparent: true,
        opacity: 0.3
    });
    
    // Connect particles that are close to each other
    for (let i = 0; i < particles.length; i++) {
        for (let j = i + 1; j < particles.length; j++) {
            const particleA = particles[i];
            const particleB = particles[j];
            const distance = particleA.position.distanceTo(particleB.position);
            
            // Only connect particles that are relatively close
            if (distance < 4) {
                const points = [
                    particleA.position.clone(),
                    particleB.position.clone()
                ];
                
                const connectionGeometry = new THREE.BufferGeometry().setFromPoints(points);
                const connection = new THREE.Line(connectionGeometry, connectionMaterial.clone());
                connection.userData = {
                    source: particleA,
                    target: particleB
                };
                
                scene.add(connection);
                connections.push(connection);
            }
        }
    }
}

function onWindowResize() {
    camera.aspect = window.innerWidth / window.innerHeight;
    camera.updateProjectionMatrix();
    renderer.setSize(window.innerWidth, window.innerHeight);
}

function updateAIScene() {
    // Calculate scroll progress (0 to 1)
    const scrollTop = window.pageYOffset;
    const docHeight = document.body.scrollHeight - window.innerHeight;
    scrollProgress = docHeight > 0 ? Math.min(1, scrollTop / docHeight) : 0;
    
    // Move particles based on scroll progress
    particles.forEach(particle => {
        const offset = scrollProgress * 5;
        particle.position.y = particle.userData.originalPosition.y + offset;
        particle.position.x = particle.userData.originalPosition.x + Math.sin(offset) * 0.5;
        particle.position.z = particle.userData.originalPosition.z + Math.cos(offset) * 0.5;
        
        // Change color based on position
        const hue = (offset * 0.1) % 1;
        particle.material.color.setHSL(hue, 1, 0.7);
        particle.material.emissive.setHSL(hue, 1, 0.3);
    });
    
    // Update connections
    connections.forEach(connection => {
        const points = [
            connection.userData.source.position.clone(),
            connection.userData.target.position.clone()
        ];
        connection.geometry.setFromPoints(points);
    });
    
    // Render the scene
    renderer.render(scene, camera);
}

// Remove the animate function since we're not doing automatic animations