Infinite Archive @import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@600;700;900&family=Roboto+Mono:wght@400;500;700&display=swap'); /* --- RESET & ZÁKLAD --- */ body { margin: 0; overflow: hidden; background-color: #050505; font-family: 'Segoe UI', Roboto, sans-serif; } #vr-container { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 1; background: #050505; } /* TABS PRE PROJECT OVERLAY */ .proj-tabs { display: flex; justify-content: center; gap: 15px; margin-bottom: 25px; } .proj-tab { background: rgba(0,0,0,0.3); border: 1px solid rgba(77, 171, 255, 0.2); color: #888; padding: 8px 18px; font-family: 'Roboto Mono', monospace; font-size: 10px; font-weight: 700; letter-spacing: 1px; cursor: pointer; transition: all 0.3s ease; border-radius: 3px; } .proj-tab:hover { color: #fff; border-color: rgba(77, 171, 255, 0.6); } .proj-tab.active { background: rgba(77, 171, 255, 0.15); color: #4dabff; border-color: #4dabff; box-shadow: 0 0 10px rgba(77, 171, 255, 0.2); } .proj-tab-content { display: none; /* V základe skryté */ animation: fadeInTab 0.4s cubic-bezier(0.19, 1, 0.22, 1) forwards; } .proj-tab-content.active { display: block; /* Zobrazené iba aktívne */ } @keyframes fadeInTab { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } } /* --- UI KOMPONENTY --- */ .ui-base { background: rgba(5, 10, 18, 0.85); border: 1px solid rgba(60, 100, 255, 0.25); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); color: #eee; border-radius: 4px; pointer-events: none; user-select: none; box-shadow: 0 5px 20px rgba(0,0,0,0.6); transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); } .key-hint { background: rgba(255,255,255,0.1); padding: 2px 5px; border-radius: 3px; color: #fff; font-family: 'Roboto Mono', monospace; font-weight: 700; font-size: 9px; border: 1px solid rgba(255,255,255,0.1); min-width: 16px; text-align: center; display: inline-block; } #fps-box { position: absolute; top: 40px; left: 40px; z-index: 10; font-family: 'Roboto Mono', monospace; font-size: 10px; color: #4dabff; padding: 6px 10px; font-weight: bold; } /* --- PRAVÝ STACK (MENU) --- */ #right-ui-stack { position: absolute; top: 40px; right: 40px; z-index: 10; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; width: 220px; } .stack-item { position: relative; display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; width: 100%; box-sizing: border-box; } .stack-label { font-size: 10px; font-weight: 600; letter-spacing: 1px; color: #ccc; } .status-text { font-family: 'Roboto Mono', monospace; font-weight: bold; font-size: 10px; color: #666; transition: color 0.3s; } /* Aktívne stavy (Farby) */ .active-btn { border-color: #00ff88 !important; background: rgba(0, 255, 136, 0.1) !important; } .active-text { color: #00ff88 !important; text-shadow: 0 0 10px rgba(0,255,136,0.4); } .active-mat { border-color: #ffcc00 !important; background: rgba(255, 204, 0, 0.1) !important; } .active-mat-text { color: #ffcc00 !important; text-shadow: 0 0 10px rgba(255, 204, 0, 0.4); } .active-vox { border-color: #ff3366 !important; background: rgba(255, 51, 102, 0.1) !important; } .active-vox-text { color: #ff3366 !important; text-shadow: 0 0 10px rgba(255, 51, 102, 0.4); } .active-music { border-color: #b066ff !important; background: rgba(176, 102, 255, 0.1) !important; } .active-music-text { color: #b066ff !important; text-shadow: 0 0 10px rgba(176, 102, 255, 0.4); } #wsad-hint-box { justify-content: center; gap: 8px; } /* SUBMENU (Vysúvacie) */ .submenu-container { width: 100%; overflow: hidden; max-height: 0; opacity: 0; transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); } .submenu-container.visible { max-height: 400px; opacity: 1; } .submenu-box { display: flex; flex-direction: column; gap: 6px; padding: 12px; margin-top: 4px; width: 100%; box-sizing: border-box; } .ops-item { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: #ddd; width: 100%; } .ops-desc { font-weight: 500; font-size: 10px; letter-spacing: 0.5px; } /* --- INFO PANEL --- */ #info-panel { position: absolute; top: 12%; left: 50%; transform: translate(-50%, -20px); z-index: 900; width: 420px; opacity: 0; visibility: hidden; text-align: left; display: flex; flex-direction: column; padding: 0; border-top: 2px solid #4dabff; pointer-events: none; } #info-panel.visible { opacity: 1 !important; visibility: visible !important; transform: translate(-50%, 0px) !important; } .panel-header { padding: 15px 20px; border-bottom: 1px solid rgba(255,255,255,0.05); } .model-name-text { font-size: 24px; font-weight: 800; color: #fff; font-family: 'Montserrat', sans-serif; letter-spacing: 1px; text-transform: uppercase; } .model-id-text { font-size: 12px; color: #4dabff; font-family: 'Roboto Mono', monospace; font-weight: bold; letter-spacing: 1px; } .prompt-wrapper { padding: 15px 20px; background: rgba(0,0,0,0.2); min-height: 70px; } .label-prompt { font-size: 9px; color: #666; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; display: block; margin-bottom: 6px; } .target-prompt-text { font-size: 13px !important; color: #eee !important; line-height: 1.5 !important; font-style: italic; font-family: 'Segoe UI', sans-serif; word-wrap: break-word; display: block !important; opacity: 1 !important; visibility: visible !important; } .meta-footer { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 12px 20px; background: rgba(0,0,0,0.4); border-top: 1px solid rgba(255,255,255,0.05); } .meta-col { display: flex; flex-direction: column; gap: 2px; } .meta-label { font-size: 8px; color: #4dabff; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; } .meta-val { font-size: 11px; color: #fff; font-family: 'Roboto Mono', monospace; font-weight: 500; } /* --- PROJECT OVERLAY --- */ #project-overlay { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.95); width: 700px; max-width: 90vw; background: rgba(5, 8, 15, 0.98); border: 1px solid #4dabff; border-radius: 4px; padding: 50px; z-index: 20000; opacity: 0; visibility: hidden; transition: all 0.4s cubic-bezier(0.19, 1, 0.22, 1); text-align: center; box-shadow: 0 0 150px rgba(0,0,0,0.8); } #project-overlay.active { opacity: 1; visibility: visible; transform: translate(-50%, -50%) scale(1); } .proj-title { font-family: 'Montserrat', sans-serif; font-weight: 900; font-size: 2.2em; color: #fff; margin-bottom: 5px; letter-spacing: 2px; text-transform: uppercase; border: none !important; } .proj-title::before, .proj-title::after { display: none !important; content: none !important; } .proj-sub { color: #4dabff; font-family: 'Roboto Mono', monospace; font-size: 11px; letter-spacing: 2px; margin-bottom: 30px; display: block; text-transform: uppercase; border: none !important; } .proj-text { font-size: 14px; line-height: 1.8; color: #bbb; margin-bottom: 40px; max-width: 580px; margin-left: auto; margin-right: auto; text-align: justify; text-align-last: center; } .proj-footer { font-size: 10px; color: #555; text-transform: uppercase; letter-spacing: 2px; border-top: 1px solid #222; padding-top: 20px; font-weight: 700; } /* Responzívne YouTube video */ .video-container { width: 100%; max-width: 580px; /* Zarovnané so šírkou .proj-text */ margin: 0 auto 40px auto; aspect-ratio: 16 / 9; /* Udržuje správny formát videa */ border-radius: 4px; overflow: hidden; border: 1px solid rgba(77, 171, 255, 0.3); box-shadow: 0 5px 20px rgba(0,0,0,0.5); } .video-container iframe { width: 100%; height: 100%; display: block; } /* OSTATNÉ */ #crosshair { position: fixed; top: 50%; left: 50%; width: 20px; height: 20px; transform: translate(-50%, -50%); z-index: 100; pointer-events: none; border: 1px solid rgba(255, 255, 255, 0.4); border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: all 0.2s ease; } #crosshair::after { content: ''; width: 3px; height: 3px; background-color: white; border-radius: 50%; } .crosshair-hover { border-color: #4dabff !important; border-width: 2px !important; background-color: rgba(77, 171, 255, 0.1); transform: translate(-50%, -50%) scale(1.5) !important; border-width: 2px !important; } .crosshair-hover::after { background-color: #4dabff; box-shadow: 0 0 10px #4dabff; } #fs-btn { position: absolute; bottom: 40px; right: 40px; z-index: 20; background: rgba(10, 15, 25, 0.6); border: 1px solid rgba(255,255,255,0.2); width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: 0.2s; pointer-events: auto; backdrop-filter: blur(4px); } #fs-btn:hover { background: #4dabff; border-color: #4dabff; } #fs-btn svg { fill: white; width: 20px; height: 20px; } /* LOADER */ #loader { position: fixed; inset: 0; background: rgba(5, 5, 5, 0.95) !important; backdrop-filter: blur(10px); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 99999; transition: opacity 0.8s, visibility 0.8s; gap: 15px !important; } #loader-logo { width: 250px !important; height: auto !important; opacity: 1 !important; display: block !important; margin-bottom: 5px !important; } #title-main { font-family: 'Montserrat', sans-serif !important; font-weight: 900 !important; color: #ffffff !important; font-size: 2em !important; letter-spacing: 5px !important; text-transform: uppercase !important; margin: 0 !important; text-align: center !important; border: 0 !important; outline: 0 !important; text-decoration: none !important; box-shadow: none !important; background: transparent !important; } #title-main::before, #title-main::after { display: none !important; content: none !important; width: 0 !important; height: 0 !important; } #progress-bar { width: 180px; height: 2px; background: rgba(255,255,255,0.1); border-radius: 2px; position: relative; overflow: hidden; margin-top: 15px !important; } #progress-fill { height: 100%; width: 0%; background: #4dabff; transition: width 0.1s; box-shadow: 0 0 15px #4dabff; } #click-overlay { position: fixed; inset: 0; z-index: 100000; display: block; cursor: default; background: transparent; transition: background 0.3s; } #click-text { display: none; position: absolute; bottom: 20%; left: 50%; transform: translateX(-50%); color: #fff !important; font-size: 13px !important; letter-spacing: 4px !important; text-transform: uppercase !important; font-weight: 700 !important; font-family: 'Montserrat', sans-serif; text-shadow: 0 0 20px rgba(0,0,0,1); animation: pulse 2s infinite; pointer-events: none; opacity: 0; transition: opacity 0.5s; } @keyframes pulse { 0% { opacity: 0.4; } 50% { opacity: 1; } 100% { opacity: 0.4; } }
FPS: 0
WASD MOVE
INFO MODE
OFF I
OPERATIONS
OFF O
MATERIAL
DEF M
VOXELIZATION
OFF V
MUSIC
OFF U
ABOUT PROJECT P

THIS GALLERY DOES NOT EXIST

MODIFICAI 7.0 - GENERATIVE AI FURNITURE

Tomas Bata University in Zlín

  • Author of gallery: Jakub Hrdina
  • 3D models generating experiment: Valeriya Truskavetska, Marťa Hrnčiříková, Vít Olšina, Jiří Šprtel, Tristan Tvrdý, Marek Ondřej, Jakub Hrdina
  • Collaboration: Štěpán Dlabaja (FAI TBU)

-- #000
AI PROMPT:
Waiting for input...

THIS GALLERY DOES NOT EXIST

CLICK TO ENTER
const PATH = 'https://designdepths.fmk.utb.cz/wp-content/uploads/aframe/'; const VOXEL_PATH = 'https://designdepths.fmk.utb.cz/wp-content/uploads/aframe/voxel/'; const METADATA_URL = 'https://designdepths.fmk.utb.cz/wp-content/uploads/aframe/metadata.json'; const ROWS = 20, COLS = 20, SPACING = 4; const VISIBILITY_RANGE = 35; const WORLD_WIDTH = COLS * SPACING; const WORLD_DEPTH = ROWS * SPACING; const TOTAL_UNIQUE_FILES = 100; let camera, scene, renderer, controls, raycaster, dirLight; const moveState = { fwd: false, bwd: false, left: false, right: false }; const velocity = new THREE.Vector3(); const direction = new THREE.Vector3(); let prevTime = performance.now(); let hoveredObj = null; let lastVoxelizedObj = null; // -- EXCLUSIVE MODES -- let inspectionMode = false; let opsMode = false; let matMode = false; let voxMode = false; let projectMode = false; let isMusicPlaying = false; let currentMatState = 'default'; const allModels = []; const interactables = []; const voxelCache = new Map(); // -- DATA CACHE -- let METADATA_CACHE = {}; let movingGrid, movingFloor; let frames = 0, lastFpsTime = performance.now(); const fpsEl = document.getElementById('fps-box'); let loader; init(); animate(); function init() { const container = document.getElementById('vr-container'); // --- FETCH METADATA JSON --- fetch(METADATA_URL) .then(response => response.json()) .then(data => { data.forEach(item => { const idNum = parseInt(item.id.split('_')[1], 10); if (!isNaN(idNum)) { METADATA_CACHE[idNum] = item; } }); console.log("Metadata loaded for " + data.length + " items."); }) .catch(err => console.error("Error loading metadata JSON:", err)); scene = new THREE.Scene(); scene.background = new THREE.Color(0x050505); scene.fog = new THREE.Fog(0x050505, 10, VISIBILITY_RANGE); // HDR Environment new THREE.RGBELoader().load('https://dl.polyhaven.org/file/ph-assets/HDRIs/hdr/1k/studio_small_09_1k.hdr', function (texture) { texture.mapping = THREE.EquirectangularReflectionMapping; scene.environment = texture; scene.environmentIntensity = 0.6; }); camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 0.1, 150); camera.position.set(0, 2.2, 0); renderer = new THREE.WebGLRenderer({ antialias: false, powerPreference: "high-performance" }); renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.5)); renderer.setSize(window.innerWidth, window.innerHeight); renderer.toneMapping = THREE.ACESFilmicToneMapping; renderer.shadowMap.enabled = true; renderer.shadowMap.type = THREE.PCFSoftShadowMap; container.appendChild(renderer.domElement); // --- OSVETLENIE (Rozšírené tiene) --- dirLight = new THREE.DirectionalLight(0xffffff, 2.0); dirLight.position.set(20, 60, 20); dirLight.castShadow = true; dirLight.shadow.mapSize.width = 2048; dirLight.shadow.mapSize.height = 2048; // Zväčšenie priestoru pre tiene const d = 45; dirLight.shadow.camera.left = -d; dirLight.shadow.camera.right = d; dirLight.shadow.camera.top = d; dirLight.shadow.camera.bottom = -d; dirLight.shadow.camera.near = 0.1; dirLight.shadow.camera.far = 150; dirLight.shadow.bias = -0.0005; scene.add(dirLight); scene.add(dirLight.target); const hemiLight = new THREE.HemisphereLight(0xffffff, 0x444444, 0.6); scene.add(hemiLight); // Grid a Podlaha const gridSize = VISIBILITY_RANGE * 2.5; const divisions = Math.floor(gridSize / SPACING); movingGrid = new THREE.GridHelper(gridSize, divisions, 0x333333, 0x0a0a0a); movingGrid.position.y = 0.02; scene.add(movingGrid); movingFloor = new THREE.Mesh(new THREE.PlaneGeometry(gridSize, gridSize), new THREE.MeshStandardMaterial({ color: 0x050505, roughness: 0.9 })); movingFloor.rotation.x = -Math.PI / 2; movingFloor.receiveShadow = true; scene.add(movingFloor); // Loadery const dracoLoader = new THREE.DRACOLoader(); dracoLoader.setDecoderPath('https://www.gstatic.com/draco/versioned/decoders/1.5.6/'); loader = new THREE.GLTFLoader(); loader.setDRACOLoader(dracoLoader); loader.setMeshoptDecoder(MeshoptDecoder); const plasticMat = new THREE.MeshPhysicalMaterial({ color: 0xe5e5e5, roughness: 0.25, metalness: 0.0, envMapIntensity: 1.0, clearcoat: 0.3, clearcoatRoughness: 0.1 }); let loadedCount = 0; const totalModels = ROWS * COLS; const pFill = document.getElementById('progress-fill'); const modelCache = new Map(); setTimeout(() => { if (!controls.isLocked) { document.getElementById('progress-fill').style.width = '100%'; enableStart(); } }, 6000); for (let r = 0; r < ROWS; r++) { for (let c = 0; c { modelCache.set(fileName, gltf.scene); spawnModel(gltf.scene, x, z, fileId); updateProgress(); }, undefined, () => updateProgress()); } } } function spawnModel(originalModel, x, z, baseId) { const model = originalModel.clone(); model.userData.origX = x; model.userData.origZ = z; model.userData.baseId = baseId; model.userData.origY = 0; model.position.set(x, 0, z); const box = new THREE.Box3().setFromObject(model); const yOffset = -box.min.y; model.position.y = yOffset; model.userData.baseY = yOffset; const geometry = new THREE.BoxGeometry(box.max.x - box.min.x, box.max.y - box.min.y, box.max.z - box.min.z); const material = new THREE.MeshBasicMaterial({ visible: false }); const hitbox = new THREE.Mesh(geometry, material); hitbox.position.y = (box.max.y - box.min.y) / 2; model.add(hitbox); model.userData.hitbox = hitbox; model.traverse(node => { if (node.isMesh && node !== hitbox) { node.castShadow = true; node.receiveShadow = true; node.material = plasticMat.clone(); node.userData.origMat = node.material.clone(); } }); model.userData.isInteractable = true; model.userData.isLevitating = false; model.userData.rotationActive = false; model.userData.rotProgress = 0; model.visible = false; scene.add(model); allModels.push(model); } function updateProgress() { loadedCount++; pFill.style.width = (loadedCount / totalModels * 100) + '%'; if(loadedCount >= totalModels * 0.95) enableStart(); } controls = new THREE.PointerLockControls(camera, document.body); document.addEventListener('keydown', onKey); document.addEventListener('keyup', onKey); window.addEventListener('resize', onResize); document.getElementById('fs-btn').onclick = () => { if (!document.fullscreenElement) document.body.requestFullscreen(); else document.exitFullscreen(); }; raycaster = new THREE.Raycaster(); } // --- UPRAVENÝ ENABLE START (CLICK / PAUSE / RESUME LOGIKA) --- function enableStart() { const overlay = document.getElementById('click-overlay'); const overlayText = document.getElementById('click-text'); const loader = document.getElementById('loader'); // 1. Zobraziť "CLICK TO ENTER" overlayText.style.display = 'block'; overlayText.style.opacity = 1; overlay.style.cursor = 'pointer'; // 2. Event Listeners pre PointerLock (Logika Pauzy a Návratu) controls.addEventListener('lock', () => { // Hráč je v hre (Locked) overlay.style.display = 'none'; if(loader.style.visibility !== 'hidden') { loader.style.opacity = 0; setTimeout(() => { loader.style.visibility = 'hidden'; }, 500); } }); controls.addEventListener('unlock', () => { // AK JE ZAPNUTÝ PROJECT MODE -> Zablokujeme pauzovací screen if (projectMode) { overlay.style.display = 'none'; return; } // Hráč stlačil Esc alebo odišiel inak (Paused) overlay.style.display = 'block'; overlay.style.background = 'rgba(0,0,0,0.6)'; overlayText.innerText = "CLICK TO RESUME"; overlayText.style.opacity = 1; }); // 3. Listener na kliknutie overlay.addEventListener('click', () => { controls.lock(); }); } function onKey(e) { const pressed = e.type === 'keydown'; if (pressed) { // EXCLUSIVE MODE SWITCHING if (e.code === 'KeyI') setMode('inspection'); if (e.code === 'KeyO') setMode('operations'); if (e.code === 'KeyM') setMode('materials'); if (e.code === 'KeyV') setMode('voxels'); if (e.code === 'KeyP') toggleProject(); if (e.code === 'KeyU') toggleMusic(); // GLOBAL RESET (0) if (e.key === '0') { if (lastVoxelizedObj) resetVoxel(lastVoxelizedObj); if (hoveredObj && matMode) setMaterialMode(hoveredObj, 'default'); } if (hoveredObj) { // --- OPS MODE ACTIONS --- if (opsMode) { if (e.code === 'KeyR') rotateObject(hoveredObj); if (e.code === 'KeyL') levitateObject(hoveredObj); if (e.code === 'KeyG') { if (lastVoxelizedObj) resetVoxel(lastVoxelizedObj); groundObject(hoveredObj); } } // --- MAT MODE ACTIONS --- if (matMode) { if (e.key === '1') setMaterialMode(hoveredObj, 'wire'); if (e.key === '2') setMaterialMode(hoveredObj, 'glass'); if (e.key === '3') setMaterialMode(hoveredObj, 'metallic'); if (e.key === '0') setMaterialMode(hoveredObj, 'default'); } // --- VOXEL MODE ACTIONS --- if (voxMode) { if (['1','2','3','4'].includes(e.key)) setVoxel(hoveredObj, e.key); if (e.key === '0') resetVoxel(hoveredObj); } } } switch(e.code) { case 'KeyW': case 'ArrowUp': moveState.fwd = pressed; break; case 'KeyS': case 'ArrowDown': moveState.bwd = pressed; break; case 'KeyA': case 'ArrowLeft': moveState.left = pressed; break; case 'KeyD': case 'ArrowRight': moveState.right = pressed; break; } } // --- MODE MANAGER (EXCLUSIVE LOGIC) --- function setMode(mode) { const wasInspection = inspectionMode; const wasOps = opsMode; const wasMat = matMode; const wasVox = voxMode; inspectionMode = false; opsMode = false; matMode = false; voxMode = false; document.getElementById('info-mode-box').classList.remove('active-btn'); document.getElementById('status-i').innerText = "OFF"; document.getElementById('info-panel').classList.remove('visible'); document.getElementById('ops-mode-box').classList.remove('active-btn'); document.getElementById('ops-container').classList.remove('visible'); document.getElementById('status-o').innerText = "OFF"; document.getElementById('mat-mode-box').classList.remove('active-mat'); document.getElementById('mat-container').classList.remove('visible'); document.getElementById('status-m').innerText = "DEF"; document.getElementById('vox-mode-box').classList.remove('active-vox'); document.getElementById('vox-container').classList.remove('visible'); document.getElementById('status-v').innerText = "OFF"; if (mode === 'inspection' && !wasInspection) { inspectionMode = true; document.getElementById('info-mode-box').classList.add('active-btn'); document.getElementById('status-i').innerText = "ON"; if(hoveredObj) { highlight(hoveredObj, true); updateInfoPanel(hoveredObj); } } else if (mode === 'operations' && !wasOps) { opsMode = true; document.getElementById('ops-mode-box').classList.add('active-btn'); document.getElementById('ops-container').classList.add('visible'); document.getElementById('status-o').innerText = "ON"; } else if (mode === 'materials' && !wasMat) { matMode = true; document.getElementById('mat-mode-box').classList.add('active-mat'); document.getElementById('mat-container').classList.add('visible'); document.getElementById('status-m').innerText = "ON"; } else if (mode === 'voxels' && !wasVox) { voxMode = true; document.getElementById('vox-mode-box').classList.add('active-vox'); document.getElementById('vox-container').classList.add('visible'); document.getElementById('status-v').innerText = "ON"; } if (!inspectionMode && hoveredObj) { document.getElementById('crosshair').classList.remove('crosshair-hover'); } } // --- UPRAVENÝ TOGGLE PROJECT --- function toggleProject() { projectMode = !projectMode; const overlay = document.getElementById('project-overlay'); const box = document.getElementById('proj-mode-box'); const clickOverlay = document.getElementById('click-overlay'); if(projectMode) { overlay.classList.add('active'); box.classList.add('active-btn'); controls.unlock(); // Okamžite schováme "CLICK TO RESUME" pauzovací screen clickOverlay.style.display = 'none'; } else { overlay.classList.remove('active'); box.classList.remove('active-btn'); controls.lock(); } } // --- VOXEL LOGIC --- function resetVoxel(obj) { if (!obj) return; if (obj.userData.currentVoxel) { obj.remove(obj.userData.currentVoxel); obj.userData.currentVoxel = null; } obj.traverse(n => { if(n.isMesh && n !== obj.userData.hitbox) n.visible = true; }); if (voxMode) document.getElementById('status-v').innerText = "ON"; if (lastVoxelizedObj === obj) lastVoxelizedObj = null; } function setVoxel(obj, levelKey) { if (lastVoxelizedObj && lastVoxelizedObj !== obj) resetVoxel(lastVoxelizedObj); lastVoxelizedObj = obj; const mapping = { '4':'high', '3':'medium', '2':'simplified', '1':'total_simplified' }; const level = mapping[levelKey]; const id = String(obj.userData.baseId).padStart(3, '0'); const fileName = `a_${id}_voxelize_${level}_boxes.glb`; const fullPath = VOXEL_PATH + fileName; obj.traverse(n => { if(n.isMesh && n !== obj.userData.hitbox) n.visible = false; }); if (obj.userData.currentVoxel) obj.remove(obj.userData.currentVoxel); const apply = (sceneData) => { const v = sceneData.clone(); scene.add(v); v.position.set(0,0,0); v.rotation.set(0,0,0); v.scale.set(1,1,1); v.updateMatrixWorld(true); const targetBox = new THREE.Box3().setFromObject(obj.userData.hitbox); const voxelBox = new THREE.Box3().setFromObject(v); const voxelSize = new THREE.Vector3(); voxelBox.getSize(voxelSize); const targetSize = new THREE.Vector3(); targetBox.getSize(targetSize); if (voxelSize.y > 0.001) { const scaleRatio = targetSize.y / voxelSize.y; v.scale.set(scaleRatio, scaleRatio, scaleRatio); v.updateMatrixWorld(true); } const voxelBoxScaled = new THREE.Box3().setFromObject(v); const voxelCenter = new THREE.Vector3(); voxelBoxScaled.getCenter(voxelCenter); const targetCenter = new THREE.Vector3(); targetBox.getCenter(targetCenter); const offsetX = targetCenter.x - voxelCenter.x; const offsetZ = targetCenter.z - voxelCenter.z; const targetFloorY = obj.position.y - obj.userData.baseY; const offsetY = targetFloorY - voxelBoxScaled.min.y; v.position.x += offsetX; v.position.z += offsetZ; v.position.y += offsetY; v.updateMatrixWorld(true); obj.attach(v); v.traverse(n => { if(n.isMesh) { n.material = new THREE.MeshStandardMaterial({ color: 0xffffff, roughness: 1.0, metalness: 0.0, flatShading: true, side: THREE.FrontSide, polygonOffset: true, polygonOffsetFactor: 1, polygonOffsetUnits: 1 }); n.castShadow = true; n.receiveShadow = true; } }); obj.userData.currentVoxel = v; document.getElementById('status-v').innerText = "VOX-" + levelKey; }; if (voxelCache.has(fullPath)) { apply(voxelCache.get(fullPath)); } else { loader.load(fullPath, (g) => { voxelCache.set(fullPath, g.scene); apply(g.scene); }, undefined, (e) => { console.error("Load Err:", fullPath, e); document.getElementById('status-v').innerText = "ERR"; obj.traverse(n => { if(n.isMesh && n !== obj.userData.hitbox) n.visible = true; }); }); } } // --- MATERIAL LOGIC --- function setMaterialMode(obj, mode) { currentMatState = mode; if (obj.userData.currentVoxel) resetVoxel(obj); obj.traverse(c => { if (c.isMesh && c !== obj.userData.hitbox) { c.castShadow = true; c.receiveShadow = true; if (mode === 'wire') { c.material.wireframe = true; c.material.transparent = false; c.material.opacity = 1; } else if (mode === 'glass') { c.material.wireframe = false; c.material.transparent = true; c.material.opacity = 0.3; c.material.roughness = 0.1; c.material.metalness = 0.0; } else if (mode === 'metallic') { c.material.wireframe = false; c.material.transparent = false; c.material.opacity = 1.0; c.material.roughness = 0.15; c.material.metalness = 1.0; c.material.color.setHex(0xaaaaaa); } else { c.material.copy(c.userData.origMat); c.material.wireframe = false; c.material.transparent = false; } c.material.needsUpdate = true; } }); } function toggleMusic() { const audioEl = document.getElementById('bg-music'); const box = document.getElementById('music-mode-box'); const statusText = document.getElementById('status-u'); if (!audioEl) return; if (isMusicPlaying) { // Vypnutie audioEl.pause(); isMusicPlaying = false; box.classList.remove('active-music'); statusText.innerText = "OFF"; statusText.classList.remove('active-music-text'); } else { // Zapnutie audioEl.play().catch(e => console.error("Audio sa nepodarilo spustiť:", e)); isMusicPlaying = true; box.classList.add('active-music'); statusText.innerText = "ON"; statusText.classList.add('active-music-text'); } } function rotateObject(obj) { if(obj.userData.rotationActive) return; obj.userData.rotationActive = true; obj.userData.rotProgress = 0; obj.userData.startRot = obj.rotation.y; } function levitateObject(obj) { obj.userData.isLevitating = true; } function groundObject(obj) { obj.userData.isLevitating = false; obj.userData.rotationActive = false; obj.position.y = obj.userData.baseY; obj.rotation.y = 0; } function onResize() { camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); renderer.setSize(window.innerWidth, window.innerHeight); } function animate() { requestAnimationFrame(animate); frames++; const now = performance.now(); if(now - lastFpsTime >= 1000) { fpsEl.innerText = `FPS: ${frames}`; frames=0; lastFpsTime=now; } const delta = Math.min((now - prevTime) / 1000, 0.1); prevTime = now; if (controls.isLocked) { velocity.x -= velocity.x * 8.0 * delta; velocity.z -= velocity.z * 8.0 * delta; direction.z = Number(moveState.fwd) - Number(moveState.bwd); direction.x = Number(moveState.right) - Number(moveState.left); direction.normalize(); if (moveState.fwd || moveState.bwd) velocity.z -= direction.z * 60.0 * delta; if (moveState.left || moveState.right) velocity.x -= direction.x * 60.0 * delta; controls.moveRight(-velocity.x * delta); controls.moveForward(-velocity.z * delta); } const camX = camera.position.x; const camZ = camera.position.z; if (dirLight) { dirLight.position.set(camX + 20, 60, camZ + 20); dirLight.target.position.set(camX, 0, camZ); } interactables.length = 0; if(movingGrid && movingFloor) { const snapX = Math.floor(camX / SPACING) * SPACING; const snapZ = Math.floor(camZ / SPACING) * SPACING; movingGrid.position.set(snapX + SPACING/2, 0.02, snapZ + SPACING/2); movingFloor.position.set(snapX, 0, snapZ); } for(let i=0; i= Math.PI * 2) { model.rotation.y = model.userData.startRot + Math.PI * 2; model.userData.rotationActive = false; } else { model.rotation.y = model.userData.startRot + model.userData.rotProgress; } } if (model.userData.isLevitating) { const floatHeight = 1.5; const targetY = model.userData.baseY + floatHeight + Math.sin(now * 0.003 + model.id) * 0.2; model.position.y += (targetY - model.position.y) * delta * 2.0; } else { if (Math.abs(model.position.y - model.userData.baseY) > 0.01) { model.position.y += (model.userData.baseY - model.position.y) * delta * 5.0; } } const gridX = Math.round(model.position.x / SPACING); const gridZ = Math.round(model.position.z / SPACING); const seed = Math.abs(gridX * 7385 + gridZ * 1934 + model.userData.baseId); if(!model.userData.abstractName) model.userData.abstractName = generateAbstractName(seed); model.userData.gridLetter = toColumnName(Math.abs(gridX) + 1); model.userData.gridNumber = Math.abs(gridZ) + 1; const distSq = (camX - model.position.x)**2 + (camZ - model.position.z)**2; if (distSq 0) { let root = intersects[0].object; while(root.parent && !root.userData.isInteractable) root = root.parent; if (hoveredObj !== root) { if(hoveredObj) highlight(hoveredObj, false); hoveredObj = root; if(inspectionMode) { highlight(hoveredObj, true); updateInfoPanel(hoveredObj); crosshair.classList.add('crosshair-hover'); } } else { if(inspectionMode && !document.getElementById('info-panel').classList.contains('visible')) { highlight(hoveredObj, true); updateInfoPanel(hoveredObj); crosshair.classList.add('crosshair-hover'); } } } else { if (hoveredObj) { highlight(hoveredObj, false); hoveredObj = null; crosshair.classList.remove('crosshair-hover'); document.getElementById('info-panel').classList.remove('visible'); } } renderer.render(scene, camera); } function toColumnName(num) { for (var ret = '', a = 1, b = 26; (num -= a) >= 0; a = b, b *= 26) { ret = String.fromCharCode(parseInt((num % b) / a) + 65) + ret; } return ret; } function generateAbstractName(seed) { const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; let name = ""; for(let i=0; i<3; i++) { name += chars[Math.floor((Math.abs(Math.sin(seed + i * 1.1) * 10000) % 1) * chars.length)]; } name += "-"; for(let i=0; i { if(c.isMesh && c !== obj.userData.hitbox) { if (c.visible === false) return; if (currentMatState === 'wire') { c.material.color.setHex(on ? 0x00ffff : 0xffffff); } else { c.material.emissive.setHex(on ? 0x0066ff : 0x000000); c.material.emissiveIntensity = on ? 0.6 : 0; } } }); } function safeUpdate(selector, value, parent = document) { const el = parent.querySelector(selector); if (el) el.textContent = value; } function updateInfoPanel(model) { const panel = document.getElementById('info-panel'); if (!panel) return; safeUpdate('.model-name-text', model.userData.abstractName || "UNK-00", panel); const baseId = model.userData.baseId; safeUpdate('.model-id-text', `#${String(baseId).padStart(3,'0')}`, panel); const metaData = METADATA_CACHE[baseId]; if (metaData) { const allPromptBoxes = document.querySelectorAll('.target-prompt-text'); allPromptBoxes.forEach(el => { el.textContent = metaData.prompt; el.style.opacity = '1'; }); safeUpdate('.seed-val', metaData.seed, panel); const formattedPoly = metaData.poly_count ? (metaData.poly_count / 1000).toFixed(0) + 'k' : '--'; safeUpdate('.poly-val', formattedPoly, panel); } else { const allPromptBoxes = document.querySelectorAll('.target-prompt-text'); allPromptBoxes.forEach(el => { el.textContent = "Loading data..."; el.style.opacity = '0.7'; }); safeUpdate('.seed-val', "...", panel); safeUpdate('.poly-val', "...", panel); } panel.classList.add('visible'); } // --- ZÁLOŽKY (TABS) V PROJECT OVERLAY --- document.querySelectorAll('.proj-tab').forEach(button => { button.addEventListener('click', () => { // 1. Zruš aktívny stav všetkým document.querySelectorAll('.proj-tab').forEach(b => b.classList.remove('active')); document.querySelectorAll('.proj-tab-content').forEach(c => c.classList.remove('active')); // 2. Nastav aktívny stav kliknutému a jeho obsahu button.classList.add('active'); const targetId = button.getAttribute('data-tab'); document.getElementById(targetId).classList.add('active'); }); });