Spaces:
Running
Running
Update ar.html
Browse files
ar.html
CHANGED
|
@@ -32,54 +32,31 @@
|
|
| 32 |
|
| 33 |
/* --- ENGINE GRAFICO (Camera e Canvas) --- */
|
| 34 |
|
| 35 |
-
/*
|
| 36 |
-
|
| 37 |
-
Tuttavia, per sicurezza usiamo una regola che esclude il nostro #vid */
|
| 38 |
-
video:not(#vid) {
|
| 39 |
position: fixed !important;
|
| 40 |
top: 0 !important;
|
| 41 |
left: 0 !important;
|
| 42 |
width: 100vw !important;
|
| 43 |
height: 100vh !important;
|
| 44 |
-
min-width: 100vw !important;
|
| 45 |
-
min-height: 100vh !important;
|
| 46 |
object-fit: cover !important;
|
| 47 |
z-index: -2 !important;
|
| 48 |
-
margin: 0 !important;
|
| 49 |
-
padding: 0 !important;
|
| 50 |
}
|
| 51 |
|
| 52 |
-
/* Nascondiamo il video sorgente
|
| 53 |
#vid {
|
| 54 |
-
position: absolute;
|
| 55 |
-
top: 0;
|
| 56 |
-
left: 0;
|
| 57 |
-
width: 1px;
|
| 58 |
-
height: 1px;
|
| 59 |
-
opacity: 0;
|
| 60 |
-
z-index: -100;
|
| 61 |
-
pointer-events: none;
|
| 62 |
}
|
| 63 |
|
| 64 |
.a-canvas {
|
| 65 |
-
position: fixed !important;
|
| 66 |
-
|
| 67 |
-
left: 0 !important;
|
| 68 |
-
width: 100vw !important;
|
| 69 |
-
height: 100vh !important;
|
| 70 |
z-index: -1 !important;
|
| 71 |
-
margin: 0 !important;
|
| 72 |
-
padding: 0 !important;
|
| 73 |
}
|
| 74 |
|
| 75 |
a-scene {
|
| 76 |
-
position: fixed !important;
|
| 77 |
-
|
| 78 |
-
left: 0 !important;
|
| 79 |
-
width: 100vw !important;
|
| 80 |
-
height: 100vh !important;
|
| 81 |
-
margin: 0 !important;
|
| 82 |
-
padding: 0 !important;
|
| 83 |
}
|
| 84 |
|
| 85 |
.scanlines {
|
|
@@ -126,24 +103,26 @@
|
|
| 126 |
padding-bottom: env(safe-area-inset-bottom, 20px);
|
| 127 |
}
|
| 128 |
|
| 129 |
-
/*
|
| 130 |
-
#
|
| 131 |
-
display: none;
|
| 132 |
position: fixed;
|
| 133 |
-
top:
|
| 134 |
-
|
| 135 |
-
z-index:
|
| 136 |
-
|
| 137 |
-
height: 40px;
|
| 138 |
-
background: rgba(255, 0, 85, 0.8);
|
| 139 |
-
border: 1px solid #ff0055;
|
| 140 |
-
border-radius: 50%;
|
| 141 |
align-items: center;
|
| 142 |
justify-content: center;
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
}
|
| 148 |
|
| 149 |
.animate-fade-in {
|
|
@@ -180,9 +159,11 @@
|
|
| 180 |
<span id="sys-status" class="text-[#00ff41] font-bold text-lg tracking-wider animate-pulse">SCANNING...</span>
|
| 181 |
<span class="text-[8px] text-white/40 font-mono mt-1">FPS: <span id="fps-counter">60</span> | STABLE_MODE: ON</span>
|
| 182 |
</div>
|
| 183 |
-
|
|
|
|
|
|
|
| 184 |
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#00ff41" stroke-width="2"><path d="M18 6L6 18M6 6l12 12"/></svg>
|
| 185 |
-
</
|
| 186 |
</div>
|
| 187 |
|
| 188 |
<!-- MIRINO QUADRATO -->
|
|
@@ -219,10 +200,18 @@
|
|
| 219 |
</div>
|
| 220 |
</div>
|
| 221 |
|
| 222 |
-
<!--
|
| 223 |
-
<
|
| 224 |
-
<
|
| 225 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
|
| 227 |
<!-- AR SCENE -->
|
| 228 |
<a-scene
|
|
@@ -233,34 +222,10 @@
|
|
| 233 |
device-orientation-permission-ui="enabled: false">
|
| 234 |
|
| 235 |
<a-assets>
|
| 236 |
-
<!-- IL VIDEO SORGENTE (nascosto visivamente via CSS ma caricato qui) -->
|
| 237 |
<video id="vid" src="./img/video.mp4" preload="auto" loop muted playsinline webkit-playsinline crossorigin="anonymous"></video>
|
| 238 |
</a-assets>
|
| 239 |
|
| 240 |
-
|
| 241 |
-
<a-camera position="0 0 0" look-controls="enabled: false">
|
| 242 |
-
<!-- Questo gruppo è fissato alla camera (HUD) ma inizialmente INVISIBILE -->
|
| 243 |
-
<!-- Lo accendiamo solo in modalità manuale -->
|
| 244 |
-
<a-entity id="manual-hud" visible="false" position="0 0 -1.5" scale="0.5 0.5 0.5">
|
| 245 |
-
<!-- VIDEO -->
|
| 246 |
-
<a-entity
|
| 247 |
-
geometry="primitive: plane; width: 1.6; height: 0.9"
|
| 248 |
-
material="src: #vid; shader: flat; transparent: true; opacity: 1">
|
| 249 |
-
</a-entity>
|
| 250 |
-
|
| 251 |
-
<!-- CORNICI (Copiate dalla versione AR) -->
|
| 252 |
-
<a-plane position="0 0.47 0" width="1.68" height="0.03" color="#00ff41" material="shader: flat">
|
| 253 |
-
<a-animation attribute="opacity" from="1" to="0.7" dur="100" direction="alternate" repeat="indefinite"></a-animation>
|
| 254 |
-
</a-plane>
|
| 255 |
-
<a-plane position="0 -0.47 0" width="1.68" height="0.03" color="#00ff41" material="shader: flat"></a-plane>
|
| 256 |
-
<a-plane position="-0.83 0 0" width="0.03" height="0.96" color="#00ff41" material="shader: flat"></a-plane>
|
| 257 |
-
<a-plane position="0.83 0 0" width="0.03" height="0.96" color="#00ff41" material="shader: flat">
|
| 258 |
-
<a-animation attribute="opacity" from="1" to="0.7" dur="150" direction="alternate" repeat="indefinite"></a-animation>
|
| 259 |
-
</a-plane>
|
| 260 |
-
<a-text value="MANUAL_OVERRIDE" color="#ff0055" align="center" width="1.5" position="0 -0.6 0.01"
|
| 261 |
-
font="https://cdn.aframe.io/fonts/Roboto-msdf.json"></a-text>
|
| 262 |
-
</a-entity>
|
| 263 |
-
</a-camera>
|
| 264 |
|
| 265 |
<!-- TARGET MINDAR (AR REALE) -->
|
| 266 |
<a-entity id="example-target" mindar-image-target="targetIndex: 0">
|
|
@@ -308,9 +273,10 @@
|
|
| 308 |
const fpsCounter = document.querySelector("#fps-counter");
|
| 309 |
const fallbackBtn = document.querySelector("#fallback-btn");
|
| 310 |
|
| 311 |
-
|
| 312 |
-
const
|
| 313 |
-
const
|
|
|
|
| 314 |
|
| 315 |
let isAudioEnabled = false;
|
| 316 |
let loadProgress = 0;
|
|
@@ -332,9 +298,6 @@
|
|
| 332 |
smoothPositionX += (currentPos.x - smoothPositionX) * SMOOTHING_FACTOR;
|
| 333 |
smoothPositionY += (currentPos.y - smoothPositionY) * SMOOTHING_FACTOR;
|
| 334 |
smoothPositionZ += (currentPos.z - smoothPositionZ) * SMOOTHING_FACTOR;
|
| 335 |
-
|
| 336 |
-
// Nota: MindAR controlla il parent, noi non modifichiamo il target qui
|
| 337 |
-
// ma le variabili sono pronte se volessimo sganciare il contenuto
|
| 338 |
}
|
| 339 |
}, 16);
|
| 340 |
|
|
@@ -415,6 +378,7 @@
|
|
| 415 |
audioBtn.addEventListener('click', () => {
|
| 416 |
if (!isAudioEnabled) {
|
| 417 |
video.muted = false;
|
|
|
|
| 418 |
isAudioEnabled = true;
|
| 419 |
audioText.innerText = "AUDIO ON";
|
| 420 |
audioBtn.classList.add("bg-[#00ff41]", "text-black");
|
|
@@ -427,37 +391,40 @@
|
|
| 427 |
}
|
| 428 |
});
|
| 429 |
|
| 430 |
-
// MODALITÀ MANUALE (
|
| 431 |
fallbackBtn.addEventListener('click', () => {
|
| 432 |
isManualMode = true;
|
| 433 |
-
console.log("🛠 MANUAL
|
| 434 |
|
| 435 |
-
//
|
| 436 |
-
|
| 437 |
|
| 438 |
-
//
|
| 439 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 440 |
|
| 441 |
-
//
|
| 442 |
-
|
| 443 |
-
fallbackBtn.style.display = "none";
|
| 444 |
-
statusText.innerText = "MANUAL_LINK";
|
| 445 |
statusText.style.color = "#ff0055";
|
| 446 |
-
statusText.classList.remove("animate-pulse");
|
| 447 |
-
|
| 448 |
-
// 4. Mostra bottone chiusura X
|
| 449 |
-
manualCloseBtn.style.display = "flex";
|
| 450 |
-
|
| 451 |
-
// 5. Avvia video
|
| 452 |
-
video.play();
|
| 453 |
-
if(video.muted && isAudioEnabled) video.muted = false;
|
| 454 |
-
|
| 455 |
if(navigator.vibrate) navigator.vibrate([50, 50, 50]);
|
| 456 |
});
|
| 457 |
|
| 458 |
// CHIUSURA MODALITÀ MANUALE
|
| 459 |
-
|
| 460 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 461 |
});
|
| 462 |
|
| 463 |
</script>
|
|
|
|
| 32 |
|
| 33 |
/* --- ENGINE GRAFICO (Camera e Canvas) --- */
|
| 34 |
|
| 35 |
+
/* Regole generali per video webcam */
|
| 36 |
+
video:not(#vid):not(#manual-video) {
|
|
|
|
|
|
|
| 37 |
position: fixed !important;
|
| 38 |
top: 0 !important;
|
| 39 |
left: 0 !important;
|
| 40 |
width: 100vw !important;
|
| 41 |
height: 100vh !important;
|
|
|
|
|
|
|
| 42 |
object-fit: cover !important;
|
| 43 |
z-index: -2 !important;
|
|
|
|
|
|
|
| 44 |
}
|
| 45 |
|
| 46 |
+
/* Nascondiamo il video sorgente AR */
|
| 47 |
#vid {
|
| 48 |
+
position: absolute; top: 0; left: 0; opacity: 0; z-index: -100; pointer-events: none;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
}
|
| 50 |
|
| 51 |
.a-canvas {
|
| 52 |
+
position: fixed !important; top: 0 !important; left: 0 !important;
|
| 53 |
+
width: 100vw !important; height: 100vh !important;
|
|
|
|
|
|
|
|
|
|
| 54 |
z-index: -1 !important;
|
|
|
|
|
|
|
| 55 |
}
|
| 56 |
|
| 57 |
a-scene {
|
| 58 |
+
position: fixed !important; top: 0 !important; left: 0 !important;
|
| 59 |
+
width: 100vw !important; height: 100vh !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
}
|
| 61 |
|
| 62 |
.scanlines {
|
|
|
|
| 103 |
padding-bottom: env(safe-area-inset-bottom, 20px);
|
| 104 |
}
|
| 105 |
|
| 106 |
+
/* FALLBACK PLAYER STYLE (HTML OVERLAY) */
|
| 107 |
+
#fallback-player {
|
| 108 |
+
display: none; /* Nascosto di default */
|
| 109 |
position: fixed;
|
| 110 |
+
top: 0; left: 0; width: 100%; height: 100%;
|
| 111 |
+
background-color: #000; /* Copre la camera */
|
| 112 |
+
z-index: 5000;
|
| 113 |
+
flex-direction: column;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
align-items: center;
|
| 115 |
justify-content: center;
|
| 116 |
+
padding: 20px;
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
#fallback-player video {
|
| 120 |
+
width: 100%;
|
| 121 |
+
max-width: 600px;
|
| 122 |
+
border: 2px solid var(--neon-green);
|
| 123 |
+
border-radius: 10px;
|
| 124 |
+
box-shadow: 0 0 20px rgba(0, 255, 65, 0.2);
|
| 125 |
+
margin-bottom: 20px;
|
| 126 |
}
|
| 127 |
|
| 128 |
.animate-fade-in {
|
|
|
|
| 159 |
<span id="sys-status" class="text-[#00ff41] font-bold text-lg tracking-wider animate-pulse">SCANNING...</span>
|
| 160 |
<span class="text-[8px] text-white/40 font-mono mt-1">FPS: <span id="fps-counter">60</span> | STABLE_MODE: ON</span>
|
| 161 |
</div>
|
| 162 |
+
|
| 163 |
+
<!-- BUTTON X (LINK INDEX) - FIX: Ora è un tag 'a' cliccabile -->
|
| 164 |
+
<a href="./index.html" class="w-10 h-10 flex items-center justify-center border border-[#00ff41]/50 rounded-full bg-black/40 backdrop-blur-md hover:bg-[#00ff41]/20 transition-colors pointer-events-auto cursor-pointer">
|
| 165 |
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="#00ff41" stroke-width="2"><path d="M18 6L6 18M6 6l12 12"/></svg>
|
| 166 |
+
</a>
|
| 167 |
</div>
|
| 168 |
|
| 169 |
<!-- MIRINO QUADRATO -->
|
|
|
|
| 200 |
</div>
|
| 201 |
</div>
|
| 202 |
|
| 203 |
+
<!-- 4. FALLBACK PLAYER OVERLAY (HTML Puro) -->
|
| 204 |
+
<div id="fallback-player">
|
| 205 |
+
<h2 class="text-[#00ff41] text-xl font-bold mb-4 tracking-widest">MANUAL LINK</h2>
|
| 206 |
+
<!-- Video separato per il fallback manuale -->
|
| 207 |
+
<video id="manual-video" controls playsinline webkit-playsinline>
|
| 208 |
+
<source src="./img/video.mp4" type="video/mp4">
|
| 209 |
+
</video>
|
| 210 |
+
<button id="close-manual-btn" class="mt-4 px-8 py-3 bg-[#ff0055] text-white font-bold uppercase rounded tracking-widest hover:bg-[#d00045] transition-colors">
|
| 211 |
+
TORNA ALLA SCANSIONE
|
| 212 |
+
</button>
|
| 213 |
+
<p class="text-white/50 text-xs mt-4 font-mono">Modalità visualizzazione manuale attivata.</p>
|
| 214 |
+
</div>
|
| 215 |
|
| 216 |
<!-- AR SCENE -->
|
| 217 |
<a-scene
|
|
|
|
| 222 |
device-orientation-permission-ui="enabled: false">
|
| 223 |
|
| 224 |
<a-assets>
|
|
|
|
| 225 |
<video id="vid" src="./img/video.mp4" preload="auto" loop muted playsinline webkit-playsinline crossorigin="anonymous"></video>
|
| 226 |
</a-assets>
|
| 227 |
|
| 228 |
+
<a-camera position="0 0 0" look-controls="enabled: false"></a-camera>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
|
| 230 |
<!-- TARGET MINDAR (AR REALE) -->
|
| 231 |
<a-entity id="example-target" mindar-image-target="targetIndex: 0">
|
|
|
|
| 273 |
const fpsCounter = document.querySelector("#fps-counter");
|
| 274 |
const fallbackBtn = document.querySelector("#fallback-btn");
|
| 275 |
|
| 276 |
+
// Nuovi elementi Fallback HTML
|
| 277 |
+
const fallbackPlayer = document.querySelector("#fallback-player");
|
| 278 |
+
const manualVideo = document.querySelector("#manual-video");
|
| 279 |
+
const closeManualBtn = document.querySelector("#close-manual-btn");
|
| 280 |
|
| 281 |
let isAudioEnabled = false;
|
| 282 |
let loadProgress = 0;
|
|
|
|
| 298 |
smoothPositionX += (currentPos.x - smoothPositionX) * SMOOTHING_FACTOR;
|
| 299 |
smoothPositionY += (currentPos.y - smoothPositionY) * SMOOTHING_FACTOR;
|
| 300 |
smoothPositionZ += (currentPos.z - smoothPositionZ) * SMOOTHING_FACTOR;
|
|
|
|
|
|
|
|
|
|
| 301 |
}
|
| 302 |
}, 16);
|
| 303 |
|
|
|
|
| 378 |
audioBtn.addEventListener('click', () => {
|
| 379 |
if (!isAudioEnabled) {
|
| 380 |
video.muted = false;
|
| 381 |
+
manualVideo.muted = false; // Sblocca anche l'audio manuale
|
| 382 |
isAudioEnabled = true;
|
| 383 |
audioText.innerText = "AUDIO ON";
|
| 384 |
audioBtn.classList.add("bg-[#00ff41]", "text-black");
|
|
|
|
| 391 |
}
|
| 392 |
});
|
| 393 |
|
| 394 |
+
// MODALITÀ MANUALE (OVERLAY HTML)
|
| 395 |
fallbackBtn.addEventListener('click', () => {
|
| 396 |
isManualMode = true;
|
| 397 |
+
console.log("🛠 MANUAL HTML PLAYER OPENED");
|
| 398 |
|
| 399 |
+
// Pausa AR
|
| 400 |
+
video.pause();
|
| 401 |
|
| 402 |
+
// Mostra Overlay HTML
|
| 403 |
+
fallbackPlayer.style.display = 'flex';
|
| 404 |
+
|
| 405 |
+
// Avvia Video Manuale
|
| 406 |
+
manualVideo.currentTime = 0;
|
| 407 |
+
manualVideo.play();
|
| 408 |
+
if(isAudioEnabled) manualVideo.muted = false;
|
| 409 |
|
| 410 |
+
// UI Updates
|
| 411 |
+
statusText.innerText = "MANUAL_MODE";
|
|
|
|
|
|
|
| 412 |
statusText.style.color = "#ff0055";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 413 |
if(navigator.vibrate) navigator.vibrate([50, 50, 50]);
|
| 414 |
});
|
| 415 |
|
| 416 |
// CHIUSURA MODALITÀ MANUALE
|
| 417 |
+
closeManualBtn.addEventListener('click', () => {
|
| 418 |
+
isManualMode = false;
|
| 419 |
+
|
| 420 |
+
// Nascondi Overlay
|
| 421 |
+
fallbackPlayer.style.display = 'none';
|
| 422 |
+
manualVideo.pause();
|
| 423 |
+
|
| 424 |
+
// Ripristina AR UI
|
| 425 |
+
statusText.innerText = "SEARCHING...";
|
| 426 |
+
statusText.style.color = "#00ff41";
|
| 427 |
+
aimOverlay.style.opacity = "1";
|
| 428 |
});
|
| 429 |
|
| 430 |
</script>
|