synchro du labo (0bf0da65) : app.blade.php, README.md

This commit is contained in:
cloudion
2026-11-03 22:42:17 +00:00
parent e1da09fc3f
commit 7aabd13392
2 changed files with 418 additions and 2 deletions

398
app.blade.php Normal file
View File

@@ -0,0 +1,398 @@
{{-- PL0XI0N galaxion 🌌 — la GALAXIE des ploxions (RS-7). Canvas étoilé : chaque ploxion
branché (window.__PLOXIONS__) = une ÉTOILE, position déterministe par hash du nom
(spirale à 3 bras) ; chaque cubion (/cubions.json) = une CONSTELLATION (lignes entre
ses membres présents). Tap une étoile → ouvre le ploxion (jOSMobile/jOSOp/jOS).
Pan au doigt, pince/molette = zoom, caméra persistée (jOSStore/localStorage).
Ports : IN galaxion.focus {id} = centre + surligne l'étoile ;
IN galaxion.plot ⇐ space.located (chaîne de zoom : l'objet localisé — ISS/
xerbot/satellite — s'affiche à l'échelle galactique, en orbite + traînée).
Aucun out. window.jOSApps['galaxion']. mount(c,ctx)->{unmount}. --}}
<style>
.glx{position:relative;height:100%;min-height:240px;overflow:hidden;background:var(--xr-bg,#070a14);color:var(--xr-text,#e7f0ff);font-family:var(--xr-font-ui,system-ui,sans-serif);user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}
.glx *{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
.glx__cv{position:absolute;inset:0;width:100%;height:100%;display:block;touch-action:none;cursor:grab}
.glx__bar{position:absolute;top:10px;left:10px;right:10px;display:flex;align-items:center;gap:8px;padding:8px 11px;border:1px solid var(--xr-border,#22324f);border-radius:12px;background:var(--xr-surface,#0f1626);opacity:.94;pointer-events:auto}
.glx__bar b{font-size:.98rem}
.glx__pill{font-size:.62rem;color:var(--xr-muted,#8aa0c0);margin-left:auto;text-align:right;line-height:1.25}
.glx__btn{flex:0 0 auto;width:34px;height:34px;border-radius:10px;border:1px solid var(--xr-border,#22324f);background:transparent;color:var(--xr-text,#e7f0ff);font-size:1.05rem;line-height:1;cursor:pointer}
.glx__btn:active{background:var(--xr-accent,#7fd0ff);color:var(--xr-bg,#070a14)}
.glx__note{position:absolute;top:62px;left:50%;transform:translateX(-50%);max-width:92%;padding:7px 12px;border-radius:999px;border:1px solid var(--xr-accent,#7fd0ff);background:var(--xr-surface,#0f1626);color:var(--xr-text,#e7f0ff);font-size:.7rem;cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;z-index:3}
.glx__hint{position:absolute;left:50%;transform:translateX(-50%);bottom:calc(10px + env(safe-area-inset-bottom,0px));max-width:94%;padding:5px 11px;border-radius:999px;border:1px solid var(--xr-border,#22324f);background:var(--xr-surface,#0f1626);color:var(--xr-muted,#8aa0c0);font-size:.6rem;text-align:center;opacity:.85;pointer-events:none}
</style>
<script>
(function () {
"use strict";
function esc(s) { return (s == null ? '' : String(s)).replace(/[&<>"]/g, function (c) { return { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]; }); }
function hash(s) { var h = 2166136261, i; s = String(s || ''); for (i = 0; i < s.length; i++) { h ^= s.charCodeAt(i); h = (h * 16777619) >>> 0; } return h >>> 0; }
function openApp(id) { try { if (window.jOSMobile && window.jOSMobile.open) { window.jOSMobile.open(id, id); return; } } catch (e) {} try { if (window.jOSOp && window.jOSOp.openPloxion) { window.jOSOp.openPloxion(id); return; } } catch (e) {} try { if (window.jOS && window.jOS.openPloxion) window.jOS.openPloxion(id); } catch (e) {} }
// payload bus tolérant : string JSON, string nue (= id), objet ; strip des clés de câblage.
function norm(p) {
if (typeof p === 'string') { var t = p.trim(); if (t.charAt(0) === '{') { try { p = JSON.parse(t); } catch (e) { return null; } } else { return t ? { id: t } : null; } }
if (!p || typeof p !== 'object' || Array.isArray(p)) return null;
if (p.__wired != null || p.__via != null) { try { delete p.__wired; delete p.__via; } catch (e) {} }
return p;
}
function trunc(s, n) { s = String(s == null ? '' : s); return s.length > n ? s.slice(0, n - 1) + '…' : s; }
function hsl(h, s, l) { return 'hsl(' + h + ',' + s + '%,' + l + '%)'; }
function clampZoom(z) { return Math.max(0.4, Math.min(3, z)); }
function kindGlyph(k) { k = String(k || '').toLowerCase(); if (k.indexOf('station') >= 0) return '🛰'; if (k.indexOf('sat') >= 0) return '📡'; if (k.indexOf('bot') >= 0) return '🤖'; return '✦'; }
// position déterministe d'une étoile par hash du nom : bras de spirale + jitter.
function starPos(id) {
var h = hash('px:' + id);
var t = ((h >>> 3) % 1024) / 1023;
var a = (h % 3) * 2.0944 + t * 2.6 + ((((h >>> 13) % 629) / 100) - 3.14) * 0.24;
var r = 0.14 + 0.86 * Math.sqrt(t) + ((((h >>> 22) % 201) / 1000) - 0.1);
if (r < 0.05) r = 0.05; if (r > 1.02) r = 1.02;
return { x: Math.cos(a) * r, y: Math.sin(a) * r, hue: h % 360, ph: (h % 6283) / 1000, sz: 2 + ((h >>> 9) % 3) };
}
function describe() {
var it = null;
try { if (window.jOSStore) { var S = window.jOSStore('galaxion'); it = (S && S.find) ? S.find(function (x) { return x && x.id === 'cam'; }) : null; } } catch (e) {}
if (!it) { try { var raw = localStorage.getItem('px-galaxion-cam'); if (raw) it = JSON.parse(raw); } catch (e) {} }
var z = (it && typeof it.z === 'number') ? it.z : null;
return { v: 1, id: 'galaxion', title: 'Galaxion', icon: '🌌', items: [
{ p: 1, kind: 'stat', label: 'zoom caméra', value: z == null ? 'défaut' : z.toFixed(2) }
] };
}
function mount(container, ctx) {
container.innerHTML =
'<div class="glx">'
+ '<canvas class="glx__cv"></canvas>'
+ '<div class="glx__bar"><span style="font-size:1.15rem">🌌</span><b>Galaxion</b><span class="glx__pill" data-pill></span><button class="glx__btn" data-center title="Recentrer sur le cœur">⌖</button></div>'
+ '<button class="glx__note" data-note hidden></button>'
+ '<div class="glx__hint">Glisse pour naviguer · pince ou molette pour zoomer · tape une étoile pour ouvrir son ploxion</div>'
+ '</div>';
var root = container.querySelector('.glx'), cv = root.querySelector('.glx__cv'), c2 = cv.getContext('2d');
var pill = root.querySelector('[data-pill]'), note = root.querySelector('[data-note]');
// ---- état ----
var stars = [], byId = {}, constes = [];
var plots = {}, plotN = 0; // objets localisés (in plot) : id -> {a,rr,trail…}
var W = 0, H = 0, GR = 320; // GR = rayon galaxie en px
var cam = { x: 0, y: 0 }, zoom = 1, camT = null, zoomT = null;
var focusId = null, focusUntil = 0;
var dirty = true, lastDraw = 0, raf = 0, themeAt = 0;
var TXT = '#e7f0ff', ACC = '#7fd0ff', MUT = '#8aa0c0', dark = true;
(window.__PLOXIONS__ || []).forEach(function (p) {
if (!p || !p.id || byId[p.id]) return;
var sp = starPos(p.id);
var s = { id: p.id, name: p.name || p.id, icon: p.icon || '▣', x: sp.x, y: sp.y, hue: sp.hue, ph: sp.ph, sz: sp.sz };
stars.push(s); byId[p.id] = s;
});
var decor = [], i;
for (i = 0; i < 110; i++) { var dh = hash('bg:' + i); decor.push({ x: ((dh % 2000) / 1000 - 1) * 1.9, y: (((dh >>> 11) % 2000) / 1000 - 1) * 1.9, ph: (dh % 6283) / 1000, sz: 0.5 + ((dh >>> 5) % 10) / 9 }); }
// constellations = cubions (lignes entre membres présents dans la galaxie)
fetch('/cubions.json').then(function (r) { return r.json(); }).then(function (d) {
(((d || {}).cubions) || []).forEach(function (cb) {
if (!cb || !cb.members || !cb.members.length) return;
var pts = cb.members.map(function (m) { return byId[m]; }).filter(function (x) { return !!x; });
if (pts.length < 2) return;
constes.push({ id: cb.id, name: String(cb.name || cb.id).replace(/^CUBION\s+/i, ''), hue: hash('cb:' + cb.id) % 360, pts: pts });
});
count(); dirty = true;
}).catch(function () {});
// ---- thème (canvas ⇒ on lit les variables calculées ; relu périodiquement) ----
function cssVar(n, fb) { try { var v = getComputedStyle(root).getPropertyValue(n).trim(); return v || fb; } catch (e) { return fb; } }
function lum(c) {
var m = /^#([0-9a-f]{3})$/i.exec(c); if (m) c = '#' + m[1].charAt(0) + m[1].charAt(0) + m[1].charAt(1) + m[1].charAt(1) + m[1].charAt(2) + m[1].charAt(2);
m = /^#([0-9a-f]{6})/i.exec(c); var r, g, b;
if (m) { r = parseInt(m[1].slice(0, 2), 16); g = parseInt(m[1].slice(2, 4), 16); b = parseInt(m[1].slice(4, 6), 16); }
else { m = /rgba?\(\s*(\d+)[ ,]+(\d+)[ ,]+(\d+)/.exec(c); if (!m) return null; r = +m[1]; g = +m[2]; b = +m[3]; }
return (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255;
}
function theme() { TXT = cssVar('--xr-text', '#e7f0ff'); ACC = cssVar('--xr-accent', '#7fd0ff'); MUT = cssVar('--xr-muted', '#8aa0c0'); var l = lum(TXT); dark = (l == null) ? true : l > 0.5; themeAt = Date.now(); }
// ---- caméra persistée (ratios de GR ⇒ portable entre écrans) ----
function loadCam() {
try { if (window.jOSStore) { var S = window.jOSStore('galaxion'); var it = S && S.find ? S.find(function (x) { return x && x.id === 'cam'; }) : null; if (it) return it; } } catch (e) {}
try { var raw = localStorage.getItem('px-galaxion-cam'); if (raw) return JSON.parse(raw); } catch (e) {}
return null;
}
var saveT = null;
function saveCam() {
if (saveT) clearTimeout(saveT);
saveT = setTimeout(function () {
saveT = null;
var v = { id: 'cam', x: GR ? cam.x / GR : 0, y: GR ? cam.y / GR : 0, z: zoom };
try { if (window.jOSStore) { var S = window.jOSStore('galaxion'); if (S && S.upsert) { S.upsert(function (x) { return x && x.id === 'cam'; }, v); return; } } } catch (e) {}
try { localStorage.setItem('px-galaxion-cam', JSON.stringify(v)); } catch (e) {}
}, 700);
}
var restore = loadCam();
function sx(wx) { return (wx - cam.x) * zoom + W / 2; }
function sy(wy) { return (wy - cam.y) * zoom + H / 2; }
function plotXY(a, rr) { return { x: Math.cos(a) * rr * GR, y: Math.sin(a) * rr * GR }; }
function resize() {
var r = root.getBoundingClientRect(), w = Math.round(r.width), h = Math.round(r.height);
if (!w || !h) return;
W = w; H = h;
var dpr = Math.max(1, Math.min(3, window.devicePixelRatio || 1));
cv.width = Math.round(W * dpr); cv.height = Math.round(H * dpr);
c2.setTransform(dpr, 0, 0, dpr, 0, 0);
GR = Math.max(300, Math.min(W, H) * 0.62);
if (restore) { if (isFinite(restore.x)) cam.x = restore.x * GR; if (isFinite(restore.y)) cam.y = restore.y * GR; if (restore.z > 0.3 && restore.z < 4) zoom = restore.z; restore = null; }
dirty = true;
}
function count() {
var pl = Object.keys(plots).length;
pill.textContent = stars.length + ' étoiles · ' + constes.length + ' constellations' + (pl ? ' · ' + pl + ' en orbite' : '');
}
// ---- note (toast cliquable → focus) ----
var noteT = null, noteFocus = null;
function showNote(txt, focusTo) {
note.innerHTML = esc(txt); note.hidden = false; noteFocus = focusTo || null;
if (noteT) clearTimeout(noteT);
noteT = setTimeout(function () { note.hidden = true; }, 7000);
}
note.addEventListener('click', function () { note.hidden = true; if (noteFocus) focusOn(noteFocus); });
// ---- focus : centre la caméra + surligne (étoile OU objet en orbite) ----
function focusOn(id) {
var s = byId[id];
if (s) { camT = { x: s.x * GR, y: s.y * GR }; focusId = id; focusUntil = Date.now() + 3200; dirty = true; return true; }
var o = plots[id];
if (o) { var xy = plotXY(o.a, o.rr); camT = { x: xy.x, y: xy.y }; focusId = id; focusUntil = Date.now() + 3200; dirty = true; return true; }
return false;
}
// ---- in plot ⇐ space.located : l'objet localisé passe à l'échelle galactique ----
function ingestPlot(payload) {
var p = norm(payload); if (!p) return;
var id = p.id != null ? String(p.id) : (p.name != null ? String(p.name) : ''); if (!id) return;
var h = hash('plot:' + id);
var a = (typeof p.lng === 'number' && isFinite(p.lng)) ? p.lng * Math.PI / 180 : (h % 6283) / 1000;
var la = (typeof p.lat === 'number' && isFinite(p.lat)) ? Math.max(-90, Math.min(90, p.lat)) : 0;
var rr = 1.14 + (la / 90) * 0.05; // anneau « orbite locale » autour de la galaxie
var o = plots[id], neuf = false;
if (!o) { o = plots[id] = { id: id, name: id, kind: '', trail: [], n: ++plotN }; neuf = true; trimPlots(); }
if (p.name != null) o.name = String(p.name);
if (p.kind != null) o.kind = String(p.kind);
if (typeof p.alt === 'number' && isFinite(p.alt)) o.alt = p.alt;
o.a = a; o.rr = rr; o.ts = Date.now();
o.trail.push({ a: a, rr: rr }); if (o.trail.length > 40) o.trail.shift();
if (focusId === id && focusUntil > Date.now()) camT = plotXY(a, rr); // la caméra suit l'objet surligné
count(); dirty = true;
if (neuf) showNote(kindGlyph(o.kind) + ' ' + trunc(o.name, 24) + ' localisé — tape ici pour le voir', id);
}
function trimPlots() {
var ids = Object.keys(plots); if (ids.length <= 20) return;
ids.sort(function (a, b) { return plots[a].n - plots[b].n; });
while (ids.length > 20) delete plots[ids.shift()];
}
// ---- bus : ins (focus + plot) ; on écoute AUSSI la source directe space.located
// (chaîne de zoom réelle, même sans câblage intermédiaire). Aucun out. ----
var offs = [];
function sub(topic, fn) { try { if (window.jOSPorts && window.jOSPorts.on) offs.push(window.jOSPorts.on(topic, fn)); } catch (e) {} }
sub('ploxion.galaxion.focus', function (payload) {
var p = norm(payload); if (!p) return;
var id = p.id != null ? String(p.id) : ''; if (!id) return;
if (!focusOn(id)) showNote('Étoile « ' + trunc(id, 18) + ' » introuvable dans la galaxie');
});
sub('ploxion.galaxion.plot', ingestPlot);
sub('ploxion.space.located', ingestPlot);
// ---- interactions : pan (drag), pince/molette (zoom), tap (ouvrir) ----
var ptrs = {}, panStart = null, pinch0 = null, movedFar = false;
function pcount() { return Object.keys(ptrs).length; }
function pdist(A, B) { return Math.hypot(A.x - B.x, A.y - B.y); }
cv.addEventListener('pointerdown', function (e) {
try { if (cv.setPointerCapture) cv.setPointerCapture(e.pointerId); } catch (er) {}
ptrs[e.pointerId] = { x: e.clientX, y: e.clientY };
camT = null; zoomT = null;
if (pcount() === 1) { panStart = { px: e.clientX, py: e.clientY, cx: cam.x, cy: cam.y }; movedFar = false; pinch0 = null; }
else if (pcount() === 2) {
var ids = Object.keys(ptrs), A = ptrs[ids[0]], B = ptrs[ids[1]], r = cv.getBoundingClientRect();
pinch0 = { d: Math.max(20, pdist(A, B)), z: zoom, mx: (A.x + B.x) / 2 - r.left, my: (A.y + B.y) / 2 - r.top, cx: cam.x, cy: cam.y };
panStart = null; movedFar = true;
}
e.preventDefault();
});
cv.addEventListener('pointermove', function (e) {
var pt = ptrs[e.pointerId]; if (!pt) return;
pt.x = e.clientX; pt.y = e.clientY;
if (pinch0 && pcount() >= 2) {
var ids = Object.keys(ptrs), A = ptrs[ids[0]], B = ptrs[ids[1]], r = cv.getBoundingClientRect();
var nz = clampZoom(pinch0.z * pdist(A, B) / pinch0.d);
var mx = (A.x + B.x) / 2 - r.left, my = (A.y + B.y) / 2 - r.top;
var wx = pinch0.cx + (pinch0.mx - W / 2) / pinch0.z, wy = pinch0.cy + (pinch0.my - H / 2) / pinch0.z;
cam.x = wx - (mx - W / 2) / nz; cam.y = wy - (my - H / 2) / nz; zoom = nz; dirty = true;
} else if (panStart && pcount() === 1) {
var dx = e.clientX - panStart.px, dy = e.clientY - panStart.py;
if (Math.abs(dx) + Math.abs(dy) > 7) movedFar = true;
cam.x = panStart.cx - dx / zoom; cam.y = panStart.cy - dy / zoom; dirty = true;
}
});
function endPtr(e) {
if (!ptrs[e.pointerId]) return;
delete ptrs[e.pointerId];
if (pcount() < 2) pinch0 = null;
if (pcount() === 1) { var rid = Object.keys(ptrs)[0]; panStart = { px: ptrs[rid].x, py: ptrs[rid].y, cx: cam.x, cy: cam.y }; }
if (pcount() === 0) {
if (!movedFar && panStart && e.type === 'pointerup') tapAt(e);
panStart = null; movedFar = false; saveCam();
}
}
cv.addEventListener('pointerup', endPtr);
cv.addEventListener('pointercancel', endPtr);
cv.addEventListener('wheel', function (e) {
e.preventDefault();
var r = cv.getBoundingClientRect(), x = e.clientX - r.left, y = e.clientY - r.top;
var nz = clampZoom(zoom * Math.exp(-e.deltaY * 0.0016));
var wx = cam.x + (x - W / 2) / zoom, wy = cam.y + (y - H / 2) / zoom;
cam.x = wx - (x - W / 2) / nz; cam.y = wy - (y - H / 2) / nz; zoom = nz;
camT = null; dirty = true; saveCam();
}, { passive: false });
function tapAt(e) {
var r = cv.getBoundingClientRect(), x = e.clientX - r.left, y = e.clientY - r.top;
var best = null, bd = 26; // rayon de tap « doigt »
stars.forEach(function (s) { var d = Math.hypot(sx(s.x * GR) - x, sy(s.y * GR) - y); if (d < bd) { bd = d; best = { kind: 'star', id: s.id }; } });
Object.keys(plots).forEach(function (k) { var o = plots[k], p = plotXY(o.a, o.rr), d = Math.hypot(sx(p.x) - x, sy(p.y) - y); if (d < bd) { bd = d; best = { kind: 'plot', id: o.id }; } });
if (!best) return;
try { if (window.jXsfx && window.jXsfx.tap) window.jXsfx.tap(); } catch (er) {}
if (best.kind === 'star') { focusOn(best.id); setTimeout(function () { openApp(best.id); }, 160); }
else { var o = plots[best.id]; focusOn(best.id); showNote(kindGlyph(o.kind) + ' ' + trunc(o.name, 22) + (o.alt != null ? ' · alt ' + Math.round(o.alt) + ' km' : '') + ' — vu depuis la galaxie'); }
}
root.querySelector('[data-center]').addEventListener('click', function () { camT = { x: 0, y: 0 }; zoomT = 1; dirty = true; });
// ---- rendu (redraw paresseux : interactions/anim + tic lent pour le scintillement) ----
function draw(now) {
c2.clearRect(0, 0, W, H);
var t = now;
// cœur galactique
var gx = sx(0), gy = sy(0), gr = Math.max(10, GR * 0.55 * zoom);
var core = c2.createRadialGradient(gx, gy, 0, gx, gy, gr);
core.addColorStop(0, ACC); core.addColorStop(1, 'rgba(0,0,0,0)');
c2.globalAlpha = dark ? 0.12 : 0.08; c2.fillStyle = core;
c2.fillRect(gx - gr, gy - gr, gr * 2, gr * 2);
// poussière d'étoiles (décor, parallaxe)
c2.fillStyle = MUT;
decor.forEach(function (d) {
var px = (d.x * GR * 1.7 - cam.x * 0.5) * zoom + W / 2, py = (d.y * GR * 1.7 - cam.y * 0.5) * zoom + H / 2;
if (px < -20 || px > W + 20 || py < -20 || py > H + 20) return;
c2.globalAlpha = 0.1 + 0.09 * (1 + Math.sin(t / 1900 + d.ph)) / 2;
c2.beginPath(); c2.arc(px, py, d.sz, 0, 6.2832); c2.fill();
});
// constellations (cubions)
c2.lineWidth = 1;
constes.forEach(function (cb) {
var col = hsl(cb.hue, 60, dark ? 62 : 36), mx = 0, my = 0;
c2.strokeStyle = col; c2.globalAlpha = 0.3; c2.beginPath();
cb.pts.forEach(function (s, j) { var px = sx(s.x * GR), py = sy(s.y * GR); mx += px; my += py; if (j === 0) c2.moveTo(px, py); else c2.lineTo(px, py); });
c2.stroke();
mx /= cb.pts.length; my /= cb.pts.length;
if (mx > -60 && mx < W + 60 && my > -30 && my < H + 30) {
c2.globalAlpha = 0.55; c2.fillStyle = col; c2.font = '700 9px system-ui,sans-serif'; c2.textAlign = 'center'; c2.textBaseline = 'middle';
c2.fillText(cb.name.toUpperCase(), mx, my);
}
});
// orbite locale + objets localisés (in plot ⇐ space.located)
var pids = Object.keys(plots);
if (pids.length) {
c2.globalAlpha = 0.12; c2.strokeStyle = MUT; c2.setLineDash([4, 7]);
c2.beginPath(); c2.arc(gx, gy, 1.14 * GR * zoom, 0, 6.2832); c2.stroke();
c2.setLineDash([]);
pids.forEach(function (k) {
var o = plots[k];
if (o.trail.length > 1) {
c2.globalAlpha = 0.25; c2.strokeStyle = ACC; c2.beginPath();
o.trail.forEach(function (tp, j) { var w = plotXY(tp.a, tp.rr), px = sx(w.x), py = sy(w.y); if (j === 0) c2.moveTo(px, py); else c2.lineTo(px, py); });
c2.stroke();
}
var w = plotXY(o.a, o.rr), px = sx(w.x), py = sy(w.y);
if (px < -60 || px > W + 60 || py < -60 || py > H + 60) return;
var pr = 5 + 1.6 * Math.sin(t / 280 + o.n);
c2.globalAlpha = 0.95; c2.fillStyle = ACC;
c2.beginPath(); c2.moveTo(px, py - pr); c2.lineTo(px + pr, py); c2.lineTo(px, py + pr); c2.lineTo(px - pr, py); c2.closePath(); c2.fill();
c2.globalAlpha = 0.35; c2.strokeStyle = ACC;
c2.beginPath(); c2.arc(px, py, pr + 4, 0, 6.2832); c2.stroke();
c2.globalAlpha = 0.9; c2.fillStyle = TXT; c2.font = '600 10px system-ui,sans-serif'; c2.textAlign = 'left'; c2.textBaseline = 'middle';
c2.fillText(kindGlyph(o.kind) + ' ' + trunc(o.name, 16), px + pr + 7, py - 5);
if (o.alt != null) { c2.globalAlpha = 0.6; c2.fillStyle = MUT; c2.font = '9px system-ui,sans-serif'; c2.fillText('alt ' + Math.round(o.alt) + ' km', px + pr + 7, py + 7); }
});
}
// les étoiles-ploxions
var k = Math.max(0.7, Math.min(1.6, zoom)), labels = zoom >= 0.7;
stars.forEach(function (s) {
var px = sx(s.x * GR), py = sy(s.y * GR);
if (px < -60 || px > W + 60 || py < -60 || py > H + 60) return;
c2.globalAlpha = 0.38; c2.fillStyle = hsl(s.hue, 70, dark ? 62 : 38);
c2.beginPath(); c2.arc(px, py, (s.sz + 2.6) * k, 0, 6.2832); c2.fill();
c2.globalAlpha = 0.65 + 0.3 * (1 + Math.sin(t / 650 + s.ph)) / 2; c2.fillStyle = TXT;
c2.beginPath(); c2.arc(px, py, s.sz * 0.9 * k, 0, 6.2832); c2.fill();
if (labels) {
c2.globalAlpha = 0.85; c2.font = '10px system-ui,sans-serif'; c2.textAlign = 'center'; c2.textBaseline = 'top';
c2.fillText(s.icon + ' ' + trunc(s.name, 13), px, py + (s.sz + 4) * k + 3);
}
});
// surlignage du focus (in focus / tap)
if (focusId && focusUntil > t) {
var f = byId[focusId] ? { x: byId[focusId].x * GR, y: byId[focusId].y * GR } : (plots[focusId] ? plotXY(plots[focusId].a, plots[focusId].rr) : null);
if (f) {
var fx = sx(f.x), fy = sy(f.y), ph = (t % 900) / 900;
c2.strokeStyle = ACC; c2.lineWidth = 2;
c2.globalAlpha = 0.9 * (1 - ph);
c2.beginPath(); c2.arc(fx, fy, 10 + ph * 18, 0, 6.2832); c2.stroke();
c2.globalAlpha = 0.85;
c2.beginPath(); c2.arc(fx, fy, 9, 0, 6.2832); c2.stroke();
c2.lineWidth = 1;
}
}
if (!stars.length) {
c2.globalAlpha = 0.7; c2.fillStyle = MUT; c2.font = '12px system-ui,sans-serif'; c2.textAlign = 'center'; c2.textBaseline = 'middle';
c2.fillText('Aucun ploxion branché — la galaxie est vide.', W / 2, H / 2);
}
c2.globalAlpha = 1;
}
function loop() {
raf = requestAnimationFrame(loop);
if (!W || !H) { resize(); if (!W || !H) return; }
var now = Date.now();
if (now - themeAt > 2500) theme();
var anim = false;
if (camT) {
cam.x += (camT.x - cam.x) * 0.16; cam.y += (camT.y - cam.y) * 0.16;
if (Math.abs(camT.x - cam.x) + Math.abs(camT.y - cam.y) < 0.6) { cam.x = camT.x; cam.y = camT.y; camT = null; saveCam(); }
anim = true;
}
if (zoomT != null) {
zoom += (zoomT - zoom) * 0.16;
if (Math.abs(zoomT - zoom) < 0.004) { zoom = zoomT; zoomT = null; saveCam(); }
anim = true;
}
if (focusUntil > now) anim = true;
if (dirty || anim || now - lastDraw > 140) { draw(now); lastDraw = now; dirty = false; }
}
var ro = null;
try { if (window.ResizeObserver) { ro = new ResizeObserver(function () { resize(); }); ro.observe(root); } } catch (e) {}
window.addEventListener('resize', resize);
theme(); resize(); count();
raf = requestAnimationFrame(loop);
return { unmount: function () {
try { cancelAnimationFrame(raf); } catch (e) {}
offs.forEach(function (off) { try { off(); } catch (e) {} });
try { window.removeEventListener('resize', resize); } catch (e) {}
try { if (ro) ro.disconnect(); } catch (e) {}
if (saveT) clearTimeout(saveT);
if (noteT) clearTimeout(noteT);
container.innerHTML = '';
} };
}
window.jOSApps = window.jOSApps || {};
window.jOSApps['galaxion'] = { manifest: { id: 'galaxion', name: 'Galaxion', icon: '🌌' }, mount: mount, describe: describe };
})();
</script>