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

This commit is contained in:
cloudion
2026-11-03 22:40:01 +00:00
parent fb13b24dd0
commit 4a3c1a54ba
2 changed files with 87 additions and 2 deletions

67
app.blade.php Normal file
View File

@@ -0,0 +1,67 @@
{{-- PL0XION hydra-visual 🌀 — LIVE CODING VISUEL WebGL (rs-4, spec MUSICION §4, prio 2, Voie A D1).
Hydra = le pendant visuel de Strudel. Éditeur + évaluer (Ctrl+↵). ÉCOUTE le bus musical
(music.note.on / music.pattern.active) pour moduler ses uniforms — SANS dépendance dure à
strudel-live (marche seul aussi, droit au silence §4.4). Cœur depuis unpkg (CSP déclaré). --}}
<style>
.hyd{display:flex;flex-direction:column;height:100%;background:#000;color:#e6ecff;font-family:var(--xr-font-ui,ui-sans-serif,system-ui);overflow:hidden}
.hyd__stage{flex:1;min-height:0;position:relative}
.hyd__stage canvas{width:100%;height:100%;display:block}
.hyd__ed{position:absolute;left:0;right:0;bottom:0;height:40%;background:rgba(6,4,14,.72);border:0;border-top:1px solid #2a2050;outline:0;color:#c8ffe0;font:13px/1.5 ui-monospace,monospace;padding:10px 12px;resize:none;backdrop-filter:blur(2px)}
.hyd__h{position:absolute;left:8px;top:7px;display:flex;gap:7px;align-items:center;z-index:2}
.hyd__btn{cursor:pointer;border:0;border-radius:8px;background:rgba(143,123,255,.85);color:#08040f;font:inherit;font-weight:800;font-size:.74rem;padding:6px 11px}
.hyd__st{font-size:.66rem;color:#b9a8ff;background:rgba(6,4,14,.5);padding:2px 7px;border-radius:6px}
</style>
<script>
(function () {
'use strict';
var CDN = 'https://unpkg.com/hydra-synth@1.3.29/dist/hydra-synth.js'; // UMD build (global Hydra)
var KEY = 'jos:hydra-visual:last';
var DEFAULT = 'osc(10, 0.1, 1.2).rotate(0.1).kaleid(4).color(0.6,0.9,1).modulate(noise(3)).out()';
function describe(){
var code=DEFAULT; try{ code=localStorage.getItem(KEY)||DEFAULT; }catch(e){}
return { v:1, id:'hydra-visual', title:'Hydra', icon:'🌀', items:[
{ p:1, kind:'stat', label:'patch', value: code===DEFAULT?'défaut':'personnalisé' }
]};
}
function mount(container, ctx) {
container.innerHTML = '<div class="hyd"><div class="hyd__stage"><canvas></canvas>'
+ '<div class="hyd__h"><button class="hyd__btn" data-eval>▶ Ctrl+↵</button><span class="hyd__st" data-st>chargement…</span></div>'
+ '<textarea class="hyd__ed" data-ed spellcheck="false"></textarea></div></div>';
var cv = container.querySelector('canvas'), ed = container.querySelector('[data-ed]'), st = container.querySelector('[data-st]');
ed.value = (function () { try { return localStorage.getItem(KEY) || DEFAULT; } catch (e) { return DEFAULT; } })();
var H = null, off = null, alive = true, energy = 0;
function setSt(t) { st.textContent = t; }
function fit() { var r = cv.getBoundingClientRect(); cv.width = r.width; cv.height = r.height; }
var ro; try { ro = new ResizeObserver(fit); ro.observe(cv); } catch (e) {}
function loadScript(src) { return new Promise(function (res, rej) { var s = document.createElement('script'); s.src = src; s.onload = res; s.onerror = function () { rej(new Error('script')); }; document.head.appendChild(s); }); }
fit();
loadScript(CDN).then(function () {
if (!alive) return; if (!window.Hydra) throw new Error('global Hydra absent');
H = new window.Hydra({ canvas: cv, detectAudio: false, makeGlobal: true, width: cv.width, height: cv.height });
setSt('prêt · WebGL'); doEval();
}).catch(function (e) { if (!alive) return; setSt('moteur indisponible'); });
function doEval() { var code = ed.value; try { localStorage.setItem(KEY, code); } catch (e) {}
if (!H) return; try { (0, eval)(code); setSt('▶ WebGL'); try { window.jOSPorts && jOSPorts.emit('visual', 'eval', { ploxion: 'hydra-visual', code: code }); } catch (x) {} }
catch (err) { setSt('erreur : ' + (err && err.message || '')); } }
container.querySelector('[data-eval]').addEventListener('click', doEval);
ed.addEventListener('keydown', function (e) { if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') { e.preventDefault(); doEval(); } });
// ÉCOUTE le bus musical (sans dépendance dure) : les notes/patterns modulent Hydra
var off1 = null, off2 = null;
try { if (window.jOSPorts && jOSPorts.on) {
off1 = jOSPorts.on('ploxion.music.note.on', function (n) { energy = Math.min(1, energy + 0.25); if (H && window.speed !== undefined) { try { window.speed = 0.3 + energy; } catch (e) {} } });
off2 = jOSPorts.on('ploxion.music.pattern.active', function () { energy = Math.min(1, energy + 0.15); });
} } catch (e) {}
var decay = setInterval(function () { energy *= 0.9; }, 120);
return { unmount: function () { alive = false; clearInterval(decay); try { off1 && off1(); off2 && off2(); } catch (e) {}
try { H && H.hush && H.hush(); } catch (e) {} try { ro && ro.disconnect(); } catch (e) {} container.innerHTML = ''; } };
}
window.jOSApps = window.jOSApps || {};
window.jOSApps['hydra-visual'] = { manifest: { id: 'hydra-visual', name: 'Hydra', icon: '🌀' }, mount: mount, describe: describe };
})();
</script>