|
10 | 10 |
|
11 | 11 | <!-- Brand Portfolio Styles --> |
12 | 12 | <link rel="stylesheet" href="styles/brand-portfolio.css"> |
| 13 | + |
| 14 | + <!-- Three.js for 3D Background --> |
| 15 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script> |
13 | 16 | </head> |
14 | 17 | <body> |
| 18 | + <!-- 3D Background Canvas --> |
| 19 | + <canvas id="bg-canvas"></canvas> |
| 20 | + |
| 21 | + <!-- Vignette Overlay --> |
| 22 | + <div class="vignette-overlay"></div> |
| 23 | + |
15 | 24 | <!-- Hero Section --> |
16 | 25 | <section class="hero"> |
17 | 26 | <div class="container"> |
@@ -170,5 +179,85 @@ <h3 class="committee-year-title">2024</h3> |
170 | 179 | </div> |
171 | 180 | </div> |
172 | 181 | </footer> |
| 182 | + |
| 183 | + <!-- Three.js 3D Background Script --> |
| 184 | + <script> |
| 185 | + // Three.js setup for animated cubes background |
| 186 | + const canvas = document.getElementById('bg-canvas'); |
| 187 | + const scene = new THREE.Scene(); |
| 188 | + const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); |
| 189 | + const renderer = new THREE.WebGLRenderer({ canvas, alpha: true, antialias: true }); |
| 190 | + |
| 191 | + renderer.setSize(window.innerWidth, window.innerHeight); |
| 192 | + renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2)); |
| 193 | + |
| 194 | + // Create cubes |
| 195 | + const cubes = []; |
| 196 | + const cubeCount = 30; |
| 197 | + |
| 198 | + for (let i = 0; i < cubeCount; i++) { |
| 199 | + const size = Math.random() * 0.8 + 0.2; |
| 200 | + const geometry = new THREE.BoxGeometry(size, size, size); |
| 201 | + |
| 202 | + // Randomly choose between black wireframe and white wireframe |
| 203 | + const isWhite = Math.random() > 0.5; |
| 204 | + const material = new THREE.MeshBasicMaterial({ |
| 205 | + color: isWhite ? 0xffffff : 0x1d1d1f, |
| 206 | + wireframe: true, |
| 207 | + transparent: true, |
| 208 | + opacity: 0.15 |
| 209 | + }); |
| 210 | + |
| 211 | + const cube = new THREE.Mesh(geometry, material); |
| 212 | + |
| 213 | + // Random positions spread across the scene |
| 214 | + cube.position.x = (Math.random() - 0.5) * 20; |
| 215 | + cube.position.y = (Math.random() - 0.5) * 20; |
| 216 | + cube.position.z = (Math.random() - 0.5) * 15 - 5; |
| 217 | + |
| 218 | + // Random rotation speeds |
| 219 | + cube.userData = { |
| 220 | + rotationSpeedX: (Math.random() - 0.5) * 0.01, |
| 221 | + rotationSpeedY: (Math.random() - 0.5) * 0.01, |
| 222 | + rotationSpeedZ: (Math.random() - 0.5) * 0.005, |
| 223 | + floatAmplitude: Math.random() * 0.5 + 0.2, |
| 224 | + floatSpeed: Math.random() * 0.5 + 0.3, |
| 225 | + floatOffset: Math.random() * Math.PI * 2, |
| 226 | + initialY: cube.position.y |
| 227 | + }; |
| 228 | + |
| 229 | + scene.add(cube); |
| 230 | + cubes.push(cube); |
| 231 | + } |
| 232 | + |
| 233 | + camera.position.z = 5; |
| 234 | + |
| 235 | + // Animation loop |
| 236 | + let time = 0; |
| 237 | + function animate() { |
| 238 | + requestAnimationFrame(animate); |
| 239 | + time += 0.01; |
| 240 | + |
| 241 | + cubes.forEach(cube => { |
| 242 | + cube.rotation.x += cube.userData.rotationSpeedX; |
| 243 | + cube.rotation.y += cube.userData.rotationSpeedY; |
| 244 | + cube.rotation.z += cube.userData.rotationSpeedZ; |
| 245 | + |
| 246 | + // Gentle floating motion - oscillate around initial position |
| 247 | + cube.position.y = cube.userData.initialY + Math.sin(time * cube.userData.floatSpeed + cube.userData.floatOffset) * cube.userData.floatAmplitude; |
| 248 | + }); |
| 249 | + |
| 250 | + renderer.render(scene, camera); |
| 251 | + } |
| 252 | + |
| 253 | + animate(); |
| 254 | + |
| 255 | + // Handle window resize |
| 256 | + window.addEventListener('resize', () => { |
| 257 | + camera.aspect = window.innerWidth / window.innerHeight; |
| 258 | + camera.updateProjectionMatrix(); |
| 259 | + renderer.setSize(window.innerWidth, window.innerHeight); |
| 260 | + }); |
| 261 | + </script> |
173 | 262 | </body> |
174 | 263 | </html> |
0 commit comments