v50 : étape 8 « crédibilité »
- Voyant de fiabilité en direct (Fiable / Approximatif / Peu fiable, avec forme ● ◐ ○ et mot, lisible pour les daltoniens) : GPS, boussole (calée ou non, absolue), relief chargé ; détail dans le bandeau (ligne « Qualité »). - Écran « Sources et limites » (accueil, réglages, toucher le voyant) : ce qui est réel, ce qui est estimé, marges d'erreur, vie privée, fiabilité actuelle. - Photo avant/après : ligne « Fiabilité » au moment de la prise et lien « Vérifie sur place : sillycone-village.be/bdh-ar ». Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
542c21cf82
commit
0b6f09449d
6 files changed
+134
-20
No files matched your search
+67
-11
@@ -5,16 +5,16 @@ import * as THREE from './lib/three.module.js';
|
||||
// ?v=lib2 : fichiers de lib/ modifiés (imports relatifs) ; changer lib2 si on les retouche, sinon le
|
||||
// navigateur peut garder l'ancienne version en cache (et LineSegments2.js doit importer les mêmes URL).
|
||||
import * as LocAR from './lib/locar.es.js?v=lib2';
|
||||
import { PYLON_TYPES } from './pylon.js?v=49';
|
||||
import { BuildingOccluders } from './buildings.js?v=49';
|
||||
import { LidarOccluders } from './lidar.js?v=49';
|
||||
import { Terrain, TerrainOccluders } from './terrain.js?v=49';
|
||||
import { registerServiceWorker, offlineSupported, offlineStatus, downloadAll, clearOffline, sourceSize } from './offline.js?v=49';
|
||||
import { PYLON_TYPES } from './pylon.js?v=50';
|
||||
import { BuildingOccluders } from './buildings.js?v=50';
|
||||
import { LidarOccluders } from './lidar.js?v=50';
|
||||
import { Terrain, TerrainOccluders } from './terrain.js?v=50';
|
||||
import { registerServiceWorker, offlineSupported, offlineStatus, downloadAll, clearOffline, sourceSize } from './offline.js?v=50';
|
||||
import { LineSegments2 } from './lib/lines/LineSegments2.js?v=lib2';
|
||||
import { LineSegmentsGeometry } from './lib/lines/LineSegmentsGeometry.js?v=lib2';
|
||||
import { LineMaterial } from './lib/lines/LineMaterial.js?v=lib2';
|
||||
|
||||
const APP_VERSION = 'v49'; // affichée à gauche de l'indication « Tourne à… »
|
||||
const APP_VERSION = 'v50'; // affichée à gauche de l'indication « Tourne à… »
|
||||
window.__bdhLoaded = true; // vu par boot.js : l'app s'est bien chargée
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -212,7 +212,7 @@ const $ = (id) => document.getElementById(id);
|
||||
const ui = {
|
||||
intro: $('intro'), start: $('start'), error: $('error'),
|
||||
hud: $('hud'), gps: $('h-gps'), heading: $('h-heading'), trace: $('h-trace'), pylon: $('h-pylon'), prec: $('h-prec'),
|
||||
hint: $('h-hint'), err: $('h-err'), sensors: $('h-sensors'),
|
||||
hint: $('h-hint'), err: $('h-err'), sensors: $('h-sensors'), quality: $('h-quality'), qPill: $('btn-quality'),
|
||||
bar: $('bar'), toggle: $('btn-toggle'),
|
||||
fov: $('fov'), fovOut: $('fov-out'), color: $('btn-color'),
|
||||
shotBtn: $('btn-shot'), shot: $('shot'), shotImg: $('shot-img'), shotShare: $('shot-share'),
|
||||
@@ -650,6 +650,58 @@ function drawMiniMap() {
|
||||
c.fillText(miniMapRadius < 1000 ? `${miniMapRadius} m` : `${miniMapRadius / 1000} km`, r, size - 6 * dpr);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Fiabilité de la vue en ce moment (étape 8) : GPS, boussole, relief.
|
||||
// Niveau = le pire des trois : ok (vert) / moyen (orange) / faible (rouge), toujours avec un mot.
|
||||
// ---------------------------------------------------------------------------
|
||||
const compassAbsolute = () => fakeMode || app?.deviceOrientationControls?.orientationChangeEventName === 'deviceorientationabsolute'
|
||||
|| /iPhone|iPad|iPod|Macintosh/.test(navigator.userAgent);
|
||||
const Q_RANK = { ok: 0, moyen: 1, faible: 2 };
|
||||
const Q_WORD = { ok: 'Fiable', moyen: 'Approximatif', faible: 'Peu fiable' };
|
||||
const Q_ICON = { ok: '●', moyen: '◐', faible: '○' };
|
||||
function quality() {
|
||||
const items = []; // [niveau, texte]
|
||||
// GPS
|
||||
const g = fakeMode ? (me && { ...me, t: Date.now() }) : raw;
|
||||
if (fakeMode) items.push(['moyen', 'position simulée (mode test)']);
|
||||
else if (!g) items.push(['faible', 'GPS : en attente de position']);
|
||||
else {
|
||||
const age = (Date.now() - g.t) / 1000, acc = Math.round(g.acc);
|
||||
if (age > 15) items.push(['faible', `GPS : pas de mesure depuis ${Math.round(age)} s`]);
|
||||
else if (acc <= 10) items.push(['ok', `GPS ± ${acc} m`]);
|
||||
else if (acc <= 30) items.push(['moyen', `GPS ± ${acc} m (approximatif)`]);
|
||||
else items.push(['faible', `GPS ± ${acc} m (imprécis)`]);
|
||||
}
|
||||
// Boussole
|
||||
if (!fakeMode && (oriRate === 0 || nullRate >= oriRate) && Date.now() - lastOriValid > 2000) items.push(['faible', 'boussole : aucune donnée']);
|
||||
else if (!compassAbsolute()) items.push(['faible', 'boussole non absolue : la direction peut être fausse']);
|
||||
else if (calDone) items.push(['ok', `boussole calée${compassOffset ? ` (${fmtOffset(compassOffset)})` : ''}`]);
|
||||
else items.push(['moyen', 'boussole non calée : décalage possible de 10 à 20° (Réglages › 🎯 Caler la vue)']);
|
||||
// Relief / masquage
|
||||
if (!occlOn) items.push(['moyen', 'masquage désactivé : la ligne est dessinée devant tout']);
|
||||
else if (groundMe === null || !buildings?.count) items.push(['moyen', 'relief en cours de chargement']);
|
||||
else items.push(['ok', `relief chargé (${occlSrc === 'osm' ? 'bâtiments OSM' : `LiDAR ${OCCL_SOURCES[occlSrc].short.toLowerCase()}`})`]);
|
||||
const level = items.reduce((w, [l]) => (Q_RANK[l] > Q_RANK[w] ? l : w), 'ok');
|
||||
return { level, word: Q_WORD[level], items };
|
||||
}
|
||||
function showQuality() {
|
||||
const q = quality();
|
||||
ui.qPill.textContent = `${Q_ICON[q.level]} ${q.word}`;
|
||||
ui.qPill.className = `q-pill q-${q.level}`;
|
||||
ui.quality.innerHTML = q.items.map(([l, t]) => `<span class="q-${l}-t">${t}</span>`).join(' · ');
|
||||
if (!$('limits').hidden) fillLimitsNow(q);
|
||||
}
|
||||
function fillLimitsNow(q = quality()) {
|
||||
$('limits-now').hidden = !app;
|
||||
$('limits-quality').innerHTML = `<b class="q-${q.level}-t">${Q_ICON[q.level]} ${q.word}</b>`;
|
||||
$('limits-details').innerHTML = q.items.map(([l, t]) => `<li class="q-${l}-t">${t}</li>`).join('');
|
||||
}
|
||||
function openLimits() { fillLimitsNow(); $('limits').hidden = false; }
|
||||
$('limits-close').addEventListener('click', () => { $('limits').hidden = true; });
|
||||
$('btn-limits-intro').addEventListener('click', openLimits);
|
||||
$('btn-limits-settings').addEventListener('click', openLimits);
|
||||
ui.qPill.addEventListener('click', (e) => { e.stopPropagation(); openLimits(); });
|
||||
|
||||
// Ligne « Précision » du bandeau : précision du masquage choisie, relief, zone sans obstacle
|
||||
function precisionText() {
|
||||
if (!occlOn) return 'masquage désactivé (la ligne est dessinée par-dessus tout) · relief 10 m';
|
||||
@@ -665,8 +717,7 @@ function updateHud() {
|
||||
applyFov(); // la vidéo peut changer de dimensions (rotation, reprise)
|
||||
|
||||
const h = cameraHeading();
|
||||
const abs = fakeMode || app.deviceOrientationControls?.orientationChangeEventName === 'deviceorientationabsolute'
|
||||
|| /iPhone|iPad|iPod|Macintosh/.test(navigator.userAgent);
|
||||
const abs = compassAbsolute();
|
||||
ui.heading.innerHTML = `${Math.round(h)}° ${cardinal(h)}` + (abs ? '' : ' <span class="warn">(boussole non absolue ?)</span>')
|
||||
+ (compassOffset ? ` <span class="warn">(correction ${fmtOffset(compassOffset)})</span>` : '');
|
||||
drawMiniMap();
|
||||
@@ -721,6 +772,7 @@ function updateHud() {
|
||||
}
|
||||
|
||||
ui.prec.textContent = precisionText();
|
||||
showQuality();
|
||||
if (!me) { ui.trace.textContent = '–'; ui.pylon.textContent = '–'; setHint('Recherche du GPS…'); return; }
|
||||
|
||||
// Ligne la plus proche + contrôle de vraisemblance de la position
|
||||
@@ -979,7 +1031,7 @@ async function capturePhoto() {
|
||||
// Mise en page : côte à côte en portrait, l'une sous l'autre en paysage
|
||||
const portrait = H >= W, gap = Math.round(Math.min(W, H) * 0.015);
|
||||
const fs = Math.round(Math.max(14, Math.min(W, H) * 0.035)); // taille de texte
|
||||
const capH = Math.round(fs * 4.6); // bandeau de légende
|
||||
const capH = Math.round(fs * 7.1); // bandeau de légende (5 lignes)
|
||||
const outW = portrait ? W * 2 + gap : W, outH = (portrait ? H : H * 2 + gap) + capH;
|
||||
const out = document.createElement('canvas');
|
||||
out.width = outW; out.height = outH;
|
||||
@@ -1009,11 +1061,14 @@ async function capturePhoto() {
|
||||
const h = Math.round(cameraHeading());
|
||||
const pos = me ? `${me.lat.toFixed(5)}, ${me.lon.toFixed(5)} (± ${Math.round(me.acc)} m)` : 'position inconnue';
|
||||
const t = curType();
|
||||
const q = quality();
|
||||
const lines = [
|
||||
`Boucle du Hainaut (380 kV) – simulation en réalité augmentée ${APP_VERSION} · ${when}`,
|
||||
`Position ${pos} · regard vers ${h}° ${cardinal(h)} · pylônes ${t.label}, un tous les ${t.span} m`,
|
||||
`Fiabilité : ${q.word.toUpperCase()} – ${q.items.map(([, s]) => s.replace(/ \(Réglages.*\)$/, '')).join(' · ')}`,
|
||||
'Tracé : carte limonier.be/carte-bdh · emplacements estimés, pas officiels · relief : SPW 2021-2022'
|
||||
+ (occlSrc === 'osm' ? ' · bâtiments OSM' : ' (LiDAR) + bâtiments OSM proches'),
|
||||
'Vérifie sur place avec ton téléphone : sillycone-village.be/bdh-ar',
|
||||
];
|
||||
const y0 = outH - capH;
|
||||
o.fillStyle = '#111'; o.fillRect(0, y0, outW, capH);
|
||||
@@ -1079,8 +1134,9 @@ function setCompassOffset(v) {
|
||||
// Mode « Caler la vue » : on fait glisser le paysage virtuel (bâtiments en bleu, pylônes)
|
||||
// à gauche ou à droite jusqu'à ce qu'il se superpose au réel → règle la correction de boussole.
|
||||
// ---------------------------------------------------------------------------
|
||||
let calMode = false, calLast = null;
|
||||
let calMode = false, calLast = null, calDone = false; // calDone : calage fait pendant cette session
|
||||
function setCalMode(on) {
|
||||
if (calMode && !on) calDone = true;
|
||||
calMode = on;
|
||||
ui.cal.classList.toggle('on', on);
|
||||
ui.calInfo.hidden = !on;
|
||||
|
||||
Reference in new issue
Block a user