// --- Global Variables --- let scene, camera, renderer, tvScreen, videoTexture, dust, screenLight, lampLightPoint, lampLightSpot; // VCR Display related variables let simulatedPlaybackTime = 0; let lastUpdateTime = -1; let baseTime = 0; let isVideoLoaded = false; let videoUrls = []; // Array to hold all video URLs let currentVideoIndex = -1; // Index of the currently playing video const originalLampIntensity = 0.8; // Base intensity for the flickering lamp const originalScreenIntensity = 0.2; // Base intensity for the screen glow const screenIntensityPulse = 0.2; const roomSize = 5; const roomHeight = 3; const container = document.body; const videoElement = document.getElementById('video'); const fileInput = document.getElementById('fileInput'); const loadTapeButton = document.getElementById('loadTapeButton'); const loader = new THREE.TextureLoader(); const debugLight = false; const FLIES_COUNT = 2; // Flies const flies = []; let landingSurfaces = []; // Array to hold floor and table for fly landings const raycaster = new THREE.Raycaster(); // --- Configuration --- const ROOM_SIZE = roomSize; const FLIGHT_HEIGHT_MIN = 0.5; // Min height for flying const FLIGHT_HEIGHT_MAX = roomHeight * 0.9; // Max height for flying const FLY_FLIGHT_SPEED_FACTOR = 0.01; // How quickly 't' increases per frame const DAMPING_FACTOR = 0.05; const FLY_WAIT_BASE = 1000; const FLY_LAND_CHANCE = 0.3; // --- Seedable Random Number Generator (Mulberry32) --- let seed = 12345; // Default seed, will be overridden per shelf