// --- Initialization --- function init() { // 1. Scene Setup (Dark, Ambient) scene = new THREE.Scene(); scene.background = new THREE.Color(0x000000); // 2. Camera Setup const FOV = 65; camera = new THREE.PerspectiveCamera(FOV, window.innerWidth / window.innerHeight, 0.1, 1000); camera.position.set(0, 1.5, 4); // 3. Renderer Setup renderer = new THREE.WebGLRenderer({ antialias: true }); renderer.setSize(window.innerWidth, window.innerHeight); renderer.setPixelRatio(window.devicePixelRatio); // Enable shadows on the renderer renderer.shadowMap.enabled = true; renderer.shadowMap.type = THREE.PCFSoftShadowMap; // Softer shadows container.appendChild(renderer.domElement); // 4. Lighting (Minimal and focused) const ambientLight = new THREE.AmbientLight(0x111111); scene.add(ambientLight); const roomLight = new THREE.PointLight(0xffaa55, 0.05, roomSize); roomLight.position.set(0, 1.8, 0); scene.add(roomLight); // 5. Build the entire scene with TV and surrounding objects createSceneObjects(); // 6. Initialize all visual effects via the manager effectsManager = new EffectsManager(scene); // 7. Create the Room Walls and Ceiling createRoomWalls(); // --- 8. Debug Visualization Helpers --- // Visual aids for the light source positions if (debugLight && THREE.PointLightHelper) { const screenHelper = new THREE.PointLightHelper(screenLight, 0.1, 0xff0000); // Red for screen scene.add(screenHelper); // Lamp Helper will now work since lampLight is added to the scene const lampHelperPoint = new THREE.PointLightHelper(lampLightPoint, 0.1, 0x00ff00); // Green for lamp scene.add(lampHelperPoint); } // 9. Event Listeners window.addEventListener('resize', onWindowResize, false); fileInput.addEventListener('change', loadVideoFile); // Button logic loadTapeButton.addEventListener('click', () => { fileInput.click(); }); // Auto-advance to the next video when the current one finishes. videoElement.addEventListener('ended', playNextVideo); // Start the animation loop animate(); } // Start everything on window load window.onload = init;