salomonsky commited on
Commit
a8d9018
·
verified ·
1 Parent(s): 036b018

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +33 -25
index.html CHANGED
@@ -520,10 +520,13 @@
520
 
521
  if (user.isAnonymous) {
522
  console.log("Usuario es anónimo.");
523
- userProfile = { username: "Anónimo" };
524
- // show the login button in UI header to allow upgrade
525
- mainLoginButton.style.display = 'inline-block';
526
- mainLogoutButton.style.display = 'none';
 
 
 
527
  tryStartApp();
528
  } else {
529
  console.log("Usuario registrado.");
@@ -548,20 +551,26 @@
548
  isAnonymous = false;
549
  userProfile = null;
550
 
551
- loginOverlay.style.display = 'flex';
552
- loginOverlay.style.opacity = '1';
553
- loginForm.style.display = 'block';
554
- usernameForm.style.display = 'none';
555
- loginMessage.innerText = "Por favor, inicia sesión o regístrate.";
556
- loginMessage.classList.remove('text-red-500');
557
-
558
- mainLoginButton.style.display = 'inline-block';
559
- mainLogoutButton.style.display = 'none';
560
- // Restaurar botón de anónimo cuando no hay usuario autenticado
561
- if (anonymousLoginButton) anonymousLoginButton.style.display = 'block';
562
- if (authStatus) {
563
- authStatus.textContent = 'Estado: No autenticado';
564
- authStatus.classList.remove('hidden');
 
 
 
 
 
 
565
  }
566
  }
567
  });
@@ -1128,13 +1137,12 @@
1128
  });
1129
 
1130
  Object.keys(userMaps).forEach(uid => {
1131
- if (uid !== userId) {
1132
- const userMapOrigins = userMaps[uid];
1133
- const centroid = new THREE.Vector3(0, 0, 0);
1134
- userMapOrigins.forEach(origin => centroid.add(origin));
1135
- centroid.divideScalar(userMapOrigins.length);
1136
- visualizeUserPlaceholder(uid, centroid);
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');