Spaces:
Running
Running
Update index.html
Browse files- index.html +33 -25
index.html
CHANGED
|
@@ -520,10 +520,13 @@
|
|
| 520 |
|
| 521 |
if (user.isAnonymous) {
|
| 522 |
console.log("Usuario es anónimo.");
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
|
|
|
|
|
|
|
|
|
| 527 |
tryStartApp();
|
| 528 |
} else {
|
| 529 |
console.log("Usuario registrado.");
|
|
@@ -548,20 +551,26 @@
|
|
| 548 |
isAnonymous = false;
|
| 549 |
userProfile = null;
|
| 550 |
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
|
| 556 |
-
|
| 557 |
-
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 565 |
}
|
| 566 |
}
|
| 567 |
});
|
|
@@ -1128,13 +1137,12 @@
|
|
| 1128 |
});
|
| 1129 |
|
| 1130 |
Object.keys(userMaps).forEach(uid => {
|
| 1131 |
-
|
| 1132 |
-
|
| 1133 |
-
|
| 1134 |
-
|
| 1135 |
-
|
| 1136 |
-
|
| 1137 |
-
}
|
| 1138 |
});
|
| 1139 |
|
| 1140 |
const userListElement = document.getElementById('userList');
|
|
|
|
| 520 |
|
| 521 |
if (user.isAnonymous) {
|
| 522 |
console.log("Usuario es anónimo.");
|
| 523 |
+
const anonName = `Anon-${user.uid.substring(0,6)}`;
|
| 524 |
+
userProfile = { username: anonName };
|
| 525 |
+
// guardar perfil anónimo si no existe
|
| 526 |
+
await saveUserProfile(user.uid, anonName);
|
| 527 |
+
// para modo solo anónimo, ocultar botón de iniciar sesión y mostrar cerrar sesión
|
| 528 |
+
mainLoginButton.style.display = 'none';
|
| 529 |
+
mainLogoutButton.style.display = 'inline-block';
|
| 530 |
tryStartApp();
|
| 531 |
} else {
|
| 532 |
console.log("Usuario registrado.");
|
|
|
|
| 551 |
isAnonymous = false;
|
| 552 |
userProfile = null;
|
| 553 |
|
| 554 |
+
// Modo solo anónimo: iniciar sesión anónima automáticamente
|
| 555 |
+
try {
|
| 556 |
+
await signInAnonymously(auth);
|
| 557 |
+
console.log('Sesión anónima iniciada automáticamente.');
|
| 558 |
+
} catch (e) {
|
| 559 |
+
console.error('No se pudo iniciar sesión anónima automáticamente:', e);
|
| 560 |
+
// Si falla, mostrar modal básico con opción anónima
|
| 561 |
+
loginOverlay.style.display = 'flex';
|
| 562 |
+
loginOverlay.style.opacity = '1';
|
| 563 |
+
loginForm.style.display = 'block';
|
| 564 |
+
usernameForm.style.display = 'none';
|
| 565 |
+
loginMessage.innerText = "No se pudo iniciar sesión automática. Usa 'Explorar como Anónimo'.";
|
| 566 |
+
loginMessage.classList.remove('text-red-500');
|
| 567 |
+
if (anonymousLoginButton) anonymousLoginButton.style.display = 'block';
|
| 568 |
+
mainLoginButton.style.display = 'inline-block';
|
| 569 |
+
mainLogoutButton.style.display = 'none';
|
| 570 |
+
if (authStatus) {
|
| 571 |
+
authStatus.textContent = 'Estado: No autenticado';
|
| 572 |
+
authStatus.classList.remove('hidden');
|
| 573 |
+
}
|
| 574 |
}
|
| 575 |
}
|
| 576 |
});
|
|
|
|
| 1137 |
});
|
| 1138 |
|
| 1139 |
Object.keys(userMaps).forEach(uid => {
|
| 1140 |
+
const userMapOrigins = userMaps[uid];
|
| 1141 |
+
const centroid = new THREE.Vector3(0, 0, 0);
|
| 1142 |
+
userMapOrigins.forEach(origin => centroid.add(origin));
|
| 1143 |
+
centroid.divideScalar(userMapOrigins.length);
|
| 1144 |
+
// Mostrar siempre un sol central con el nombre del usuario, incluido el propio
|
| 1145 |
+
visualizeUserPlaceholder(uid, centroid);
|
|
|
|
| 1146 |
});
|
| 1147 |
|
| 1148 |
const userListElement = document.getElementById('userList');
|