Spaces:
Running
Running
LogicalTrue commited on
Commit ·
d593a7d
1
Parent(s): 04f861a
Redesign 3D viewer mode: hide top tab bar, remove AR button, add Volver and Descargar FBX overlay buttons
Browse files- frontend/viewer.html +54 -22
frontend/viewer.html
CHANGED
|
@@ -403,7 +403,17 @@
|
|
| 403 |
</div>
|
| 404 |
|
| 405 |
<!-- 2. Interactive model viewer (shown when active) -->
|
| 406 |
-
<div id="viewer-container">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 407 |
<div id="loading-overlay">
|
| 408 |
<div class="spinner"></div>
|
| 409 |
<div id="loading-text" style="font-size: 0.9rem; color: #a1a1aa;">Cargando archivo 3D...</div>
|
|
@@ -412,27 +422,19 @@
|
|
| 412 |
<model-viewer
|
| 413 |
id="viewer"
|
| 414 |
src=""
|
| 415 |
-
ar
|
| 416 |
-
ar-modes="webxr scene-viewer quick-look"
|
| 417 |
camera-controls
|
| 418 |
touch-action="pan-y"
|
| 419 |
shadow-intensity="1"
|
| 420 |
auto-rotate
|
| 421 |
-
interaction-prompt="auto"
|
| 422 |
-
|
| 423 |
-
<button slot="ar-button" id="ar-button">
|
| 424 |
-
⚡ Proyectar en AR (Cámara)
|
| 425 |
-
</button>
|
| 426 |
-
|
| 427 |
-
<div id="ar-prompt">
|
| 428 |
-
Mueve tu celular para detectar el suelo
|
| 429 |
-
</div>
|
| 430 |
</model-viewer>
|
| 431 |
</div>
|
| 432 |
|
| 433 |
<script>
|
| 434 |
const urlParams = new URLSearchParams(window.location.search);
|
| 435 |
const modelUrl = urlParams.get('model');
|
|
|
|
| 436 |
|
| 437 |
const galleryContainer = document.getElementById('gallery-container');
|
| 438 |
const viewerContainer = document.getElementById('viewer-container');
|
|
@@ -444,20 +446,50 @@
|
|
| 444 |
const galleryGrid = document.getElementById('gallery-grid');
|
| 445 |
|
| 446 |
// Back button to list models
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 454 |
|
| 455 |
// Load 3D model in viewer
|
| 456 |
function loadModelInViewer(url) {
|
| 457 |
-
|
| 458 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 459 |
viewerContainer.style.display = 'block';
|
| 460 |
-
btnBack.style.display = 'block';
|
| 461 |
|
| 462 |
overlay.style.display = 'flex';
|
| 463 |
overlay.style.opacity = 1;
|
|
|
|
| 403 |
</div>
|
| 404 |
|
| 405 |
<!-- 2. Interactive model viewer (shown when active) -->
|
| 406 |
+
<div id="viewer-container" style="display: none; position: relative; width: 100%; height: calc(100vh - 60px);">
|
| 407 |
+
<!-- Viewer Controls Overlay -->
|
| 408 |
+
<div id="viewerControlsOverlay" style="position: absolute; top: 12px; left: 12px; right: 12px; z-index: 999; display: flex; justify-content: space-between; align-items: center; pointer-events: none;">
|
| 409 |
+
<button id="btnBackToGallery" style="pointer-events: auto; background: rgba(20, 20, 28, 0.85); border: 1px solid rgba(255, 255, 255, 0.15); color: #ffffff; padding: 8px 14px; border-radius: 20px; font-size: 0.85rem; font-weight: 700; cursor: pointer; backdrop-filter: blur(10px); box-shadow: 0 4px 12px rgba(0,0,0,0.4); display: flex; align-items: center; gap: 6px;">
|
| 410 |
+
⬅ Volver
|
| 411 |
+
</button>
|
| 412 |
+
<button id="btnDownloadViewerFBX" style="pointer-events: auto; background: linear-gradient(135deg, #10b981, #059669); border: none; color: #ffffff; padding: 8px 16px; border-radius: 20px; font-size: 0.85rem; font-weight: 700; cursor: pointer; backdrop-filter: blur(10px); box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4); display: flex; align-items: center; gap: 6px;">
|
| 413 |
+
⬇ Descargar FBX
|
| 414 |
+
</button>
|
| 415 |
+
</div>
|
| 416 |
+
|
| 417 |
<div id="loading-overlay">
|
| 418 |
<div class="spinner"></div>
|
| 419 |
<div id="loading-text" style="font-size: 0.9rem; color: #a1a1aa;">Cargando archivo 3D...</div>
|
|
|
|
| 422 |
<model-viewer
|
| 423 |
id="viewer"
|
| 424 |
src=""
|
|
|
|
|
|
|
| 425 |
camera-controls
|
| 426 |
touch-action="pan-y"
|
| 427 |
shadow-intensity="1"
|
| 428 |
auto-rotate
|
| 429 |
+
interaction-prompt="auto"
|
| 430 |
+
style="width: 100%; height: 100%;">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 431 |
</model-viewer>
|
| 432 |
</div>
|
| 433 |
|
| 434 |
<script>
|
| 435 |
const urlParams = new URLSearchParams(window.location.search);
|
| 436 |
const modelUrl = urlParams.get('model');
|
| 437 |
+
let currentViewerUrl = '';
|
| 438 |
|
| 439 |
const galleryContainer = document.getElementById('gallery-container');
|
| 440 |
const viewerContainer = document.getElementById('viewer-container');
|
|
|
|
| 446 |
const galleryGrid = document.getElementById('gallery-grid');
|
| 447 |
|
| 448 |
// Back button to list models
|
| 449 |
+
if (btnBack) {
|
| 450 |
+
btnBack.addEventListener('click', () => {
|
| 451 |
+
viewerContainer.style.display = 'none';
|
| 452 |
+
if (appHeader) appHeader.style.display = 'flex';
|
| 453 |
+
const mobNavigation = document.getElementById('mobNavigation');
|
| 454 |
+
if (mobNavigation) mobNavigation.style.display = 'flex';
|
| 455 |
+
if (galleryContainer) galleryContainer.style.display = 'flex';
|
| 456 |
+
const mobGalleryHeader = document.getElementById('mobGalleryHeader');
|
| 457 |
+
const mobFilterTabs = document.getElementById('mobFilterTabs');
|
| 458 |
+
if (mobGalleryHeader) mobGalleryHeader.style.display = 'block';
|
| 459 |
+
if (mobFilterTabs) mobFilterTabs.style.display = 'flex';
|
| 460 |
+
if (navTabGallery) setMobNavActive(navTabGallery);
|
| 461 |
+
viewer.src = '';
|
| 462 |
+
});
|
| 463 |
+
}
|
| 464 |
+
|
| 465 |
+
const btnDownloadViewerFBX = document.getElementById('btnDownloadViewerFBX');
|
| 466 |
+
if (btnDownloadViewerFBX) {
|
| 467 |
+
btnDownloadViewerFBX.addEventListener('click', () => {
|
| 468 |
+
if (!currentViewerUrl) return;
|
| 469 |
+
let fbxUrl = currentViewerUrl;
|
| 470 |
+
if (fbxUrl.endsWith('.glb')) {
|
| 471 |
+
fbxUrl = fbxUrl.replace('.glb', '.fbx');
|
| 472 |
+
}
|
| 473 |
+
const a = document.createElement('a');
|
| 474 |
+
a.href = fbxUrl;
|
| 475 |
+
a.download = fbxUrl.split('/').pop();
|
| 476 |
+
document.body.appendChild(a);
|
| 477 |
+
a.click();
|
| 478 |
+
document.body.removeChild(a);
|
| 479 |
+
});
|
| 480 |
+
}
|
| 481 |
|
| 482 |
// Load 3D model in viewer
|
| 483 |
function loadModelInViewer(url) {
|
| 484 |
+
currentViewerUrl = url;
|
| 485 |
+
const mobNavigation = document.getElementById('mobNavigation');
|
| 486 |
+
if (mobNavigation) mobNavigation.style.display = 'none';
|
| 487 |
+
if (galleryContainer) galleryContainer.style.display = 'none';
|
| 488 |
+
const creatorContainerEl = document.getElementById('creator-container');
|
| 489 |
+
if (creatorContainerEl) creatorContainerEl.style.display = 'none';
|
| 490 |
+
if (appHeader) appHeader.style.display = 'none';
|
| 491 |
+
|
| 492 |
viewerContainer.style.display = 'block';
|
|
|
|
| 493 |
|
| 494 |
overlay.style.display = 'flex';
|
| 495 |
overlay.style.opacity = 1;
|