document.addEventListener('DOMContentLoaded', () => { // Initialize Three.js scene const init3DScene = () => { const canvas = document.getElementById('robot-canvas'); const loadingOverlay = document.getElementById('loading-overlay'); // Set up Three.js scene const scene = new THREE.Scene(); scene.background = new THREE.Color(0x111827); const camera = new THREE.PerspectiveCamera(75, canvas.clientWidth / canvas.clientHeight, 0.1, 1000); camera.position.z = 5; const renderer = new THREE.WebGLRenderer({ canvas, antialias: true }); renderer.setSize(canvas.clientWidth, canvas.clientHeight); renderer.setPixelRatio(window.devicePixelRatio); // Add lighting const ambientLight = new THREE.AmbientLight(0x404040); scene.add(ambientLight); const directionalLight = new THREE.DirectionalLight(0xffffff, 1); directionalLight.position.set(1, 1, 1); scene.add(directionalLight); // Add initial robot placeholder const geometry = new THREE.BoxGeometry(1, 1, 1); const material = new THREE.MeshPhongMaterial({ color: 0x3a86ff }); const cube = new THREE.Mesh(geometry, material); scene.add(cube); // Animation loop const animate = () => { requestAnimationFrame(animate); cube.rotation.x += 0.01; cube.rotation.y += 0.01; renderer.render(scene, camera); }; animate(); // Hide loading overlay setTimeout(() => { loadingOverlay.style.opacity = '0'; setTimeout(() => { loadingOverlay.style.display = 'none'; }, 300); }, 1500); // Handle window resize window.addEventListener('resize', () => { camera.aspect = canvas.clientWidth / canvas.clientHeight; camera.updateProjectionMatrix(); renderer.setSize(canvas.clientWidth, canvas.clientHeight); }); }; init3DScene(); // Reset button functionality document.getElementById('reset-btn').addEventListener('click', () => { alert('Robot design has been reset!'); // This would reset the 3D scene in a real implementation }); });