Corregir rutas de Butterchurn en node_modules y aislar el arranque de cada motor
Butterchurn publica sus builds en lib/ (butterchurn.min.js y butterchurnPresets.min.js), no en dist/base.min.js. El instalador ahora busca los ficheros por nombre con find_copy, robusto a cambios de carpeta entre versiones. Ademas el escenario inicia cada motor por separado: si una libreria falta, los demas siguen funcionando (antes un fallo de Butterchurn impedia que Hydra se inicializara, de ahi el error 'src is not defined'). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e3db98b089
commit
c8b51615ba
2 changed files with 36 additions and 17 deletions
17
install.sh
17
install.sh
|
|
@ -181,10 +181,19 @@ copy_lib() { # copy_lib <origen> <destino> <descripcion>
|
||||||
warn "no se pudo copiar: $3 ($1)"
|
warn "no se pudo copiar: $3 ($1)"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
copy_lib node_modules/butterchurn/dist/butterchurn.min.js \
|
# Busca un fichero por nombre dentro de un paquete y lo copia. Es robusto a
|
||||||
lib/butterchurn.min.js "Butterchurn"
|
# que el paquete cambie de carpeta (dist/, lib/, build/) entre versiones.
|
||||||
copy_lib node_modules/butterchurn-presets/dist/base.min.js \
|
find_copy() { # find_copy <paquete> <nombre> <destino> <descripcion>
|
||||||
lib/butterchurn-presets.min.js "Presets de Butterchurn"
|
local f
|
||||||
|
f="$(find "node_modules/$1" -name "$2" -type f 2>/dev/null | head -n1)"
|
||||||
|
if [ -n "$f" ] && cp "$f" "$3" 2>/dev/null && [ -s "$3" ]; then
|
||||||
|
log_ok "$4"
|
||||||
|
else
|
||||||
|
warn "no se encontro $4 ($2 dentro de node_modules/$1)"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
find_copy butterchurn butterchurn.min.js lib/butterchurn.min.js "Butterchurn"
|
||||||
|
find_copy butterchurn-presets butterchurnPresets.min.js lib/butterchurn-presets.min.js "Presets de Butterchurn"
|
||||||
copy_lib node_modules/socket.io-client/dist/socket.io.min.js \
|
copy_lib node_modules/socket.io-client/dist/socket.io.min.js \
|
||||||
lib/socket.io.min.js "Socket.IO"
|
lib/socket.io.min.js "Socket.IO"
|
||||||
copy_lib node_modules/qrcode-generator/qrcode.js \
|
copy_lib node_modules/qrcode-generator/qrcode.js \
|
||||||
|
|
|
||||||
|
|
@ -521,6 +521,7 @@ function applyState(next) {
|
||||||
if (hydra) hydra.hush();
|
if (hydra) hydra.hush();
|
||||||
if (shaderEngine) shaderEngine.stop();
|
if (shaderEngine) shaderEngine.stop();
|
||||||
mixerSig = "";
|
mixerSig = "";
|
||||||
|
if (!bcViz) { show(null); return; }
|
||||||
show(bcCanvas);
|
show(bcCanvas);
|
||||||
startButterchurn();
|
startButterchurn();
|
||||||
const wanted = state.butterchurn.preset;
|
const wanted = state.butterchurn.preset;
|
||||||
|
|
@ -532,6 +533,7 @@ function applyState(next) {
|
||||||
stopButterchurn();
|
stopButterchurn();
|
||||||
if (shaderEngine) shaderEngine.stop();
|
if (shaderEngine) shaderEngine.stop();
|
||||||
mixerSig = "";
|
mixerSig = "";
|
||||||
|
if (!hydra) { show(null); return; }
|
||||||
show(hydraCanvas);
|
show(hydraCanvas);
|
||||||
if (state.hydra.code !== hydraCode) runHydraCode(state.hydra.code);
|
if (state.hydra.code !== hydraCode) runHydraCode(state.hydra.code);
|
||||||
|
|
||||||
|
|
@ -539,6 +541,7 @@ function applyState(next) {
|
||||||
stopButterchurn();
|
stopButterchurn();
|
||||||
if (hydra) hydra.hush();
|
if (hydra) hydra.hush();
|
||||||
mixerSig = "";
|
mixerSig = "";
|
||||||
|
if (!shaderEngine) { show(null); return; }
|
||||||
show(shaderCanvas);
|
show(shaderCanvas);
|
||||||
if (shaderEngine && state.shaders.code !== shaderCode) {
|
if (shaderEngine && state.shaders.code !== shaderCode) {
|
||||||
if (shaderEngine.load(state.shaders.code)) shaderCode = state.shaders.code;
|
if (shaderEngine.load(state.shaders.code)) shaderCode = state.shaders.code;
|
||||||
|
|
@ -548,6 +551,7 @@ function applyState(next) {
|
||||||
} else if (state.engine === "mixer") {
|
} else if (state.engine === "mixer") {
|
||||||
stopButterchurn();
|
stopButterchurn();
|
||||||
if (shaderEngine) shaderEngine.stop();
|
if (shaderEngine) shaderEngine.stop();
|
||||||
|
if (!hydra) { show(null); return; }
|
||||||
show(hydraCanvas);
|
show(hydraCanvas);
|
||||||
applyMixer(state.mixer);
|
applyMixer(state.mixer);
|
||||||
}
|
}
|
||||||
|
|
@ -579,24 +583,30 @@ window.addEventListener("resize", () => {
|
||||||
// Arranque
|
// Arranque
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
async function boot() {
|
async function boot() {
|
||||||
|
// El audio es la base de todo: si falla, no se puede continuar.
|
||||||
try {
|
try {
|
||||||
if (typeof Hydra === "undefined" || typeof butterchurn === "undefined") {
|
|
||||||
report("error", "Faltan librerias de visuales. Ejecuta install.sh "
|
|
||||||
+ "de nuevo en la Raspberry.");
|
|
||||||
msgEl.textContent = "ERROR: faltan librerias";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await initAudio();
|
await initAudio();
|
||||||
initButterchurn();
|
|
||||||
initHydra();
|
|
||||||
shaderEngine = new ShaderEngine(shaderCanvas, analyser);
|
|
||||||
beatLoop();
|
beatLoop();
|
||||||
msgEl.textContent = "FOSFENO listo";
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
report("error", "Fallo al arrancar el escenario: " + err.message
|
report("error", "No se pudo iniciar el audio: " + err.message
|
||||||
+ ". Si menciona el microfono, comprueba que esta conectado.");
|
+ ". Comprueba el microfono y recarga la pagina.");
|
||||||
msgEl.textContent = "ERROR: " + err.message;
|
msgEl.textContent = "ERROR: audio (" + err.message + ")";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
// Cada motor se inicia por separado: si una libreria falta o falla, los
|
||||||
|
// demas motores siguen funcionando igual.
|
||||||
|
try {
|
||||||
|
if (typeof butterchurn !== "undefined") initButterchurn();
|
||||||
|
else report("warn", "Butterchurn no esta disponible (libreria no copiada).");
|
||||||
|
} catch (e) { report("error", "Butterchurn fallo al iniciar: " + e.message); }
|
||||||
|
try {
|
||||||
|
if (typeof Hydra !== "undefined") initHydra();
|
||||||
|
else report("error", "Hydra no esta disponible (libreria no copiada).");
|
||||||
|
} catch (e) { report("error", "Hydra fallo al iniciar: " + e.message); }
|
||||||
|
try {
|
||||||
|
shaderEngine = new ShaderEngine(shaderCanvas, analyser);
|
||||||
|
} catch (e) { report("error", "El motor de shaders fallo: " + e.message); }
|
||||||
|
msgEl.textContent = "FOSFENO listo";
|
||||||
}
|
}
|
||||||
|
|
||||||
boot();
|
boot();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue