Feature: Stage torches stop spitting flame when not loud but remain visible

This commit is contained in:
Dejvino 2026-01-04 17:59:22 +00:00
parent ee6ae3a688
commit 31debfe151

View File

@ -104,23 +104,17 @@ export class StageTorches extends SceneFeature {
} }
update(deltaTime) { update(deltaTime) {
const enabled = state.config.torchesEnabled && !state.blackoutMode; const configEnabled = state.config.torchesEnabled;
this.torches.forEach(torch => { this.torches.forEach(torch => {
if (torch.group.visible !== enabled) torch.group.visible = enabled; if (torch.group.visible !== configEnabled) torch.group.visible = configEnabled;
}); });
if (!enabled) return; if (!configEnabled) return;
if (!state.partyStarted && state.music.isLoudEnough) { const fireActive = !state.blackoutMode && !(!state.partyStarted && state.music.isLoudEnough);
this.torches.forEach(torch => {
if (torch.light.visible) torch.light.visible = false;
if (torch.particles.visible) torch.particles.visible = false;
});
return;
}
this.torches.forEach(torch => { this.torches.forEach(torch => {
if (!torch.light.visible) torch.light.visible = true; if (torch.light.visible !== fireActive) torch.light.visible = fireActive;
if (!torch.particles.visible) torch.particles.visible = true; if (!torch.particles.visible) torch.particles.visible = true;
let measurePulse = 0; let measurePulse = 0;
@ -134,26 +128,35 @@ export class StageTorches extends SceneFeature {
// --- Animate Particles --- // --- Animate Particles ---
const positions = torch.particles.geometry.attributes.position.array; const positions = torch.particles.geometry.attributes.position.array;
let averageY = 0; let averageY = 0;
let activeParticleCount = 0;
for (let i = 0; i < torch.particleData.length; i++) { for (let i = 0; i < torch.particleData.length; i++) {
const data = torch.particleData[i]; const data = torch.particleData[i];
data.life -= deltaTime; data.life -= deltaTime;
const yVelocity = data.velocity.y; const yVelocity = data.velocity.y;
if (data.life <= 0 || positions[i * 3 + 1] < 0) { if (data.life <= 0 || positions[i * 3 + 1] < 0) {
// Reset particle if (fireActive) {
positions[i * 3] = (Math.random() - 0.5) * 0.2; // Reset particle
positions[i * 3 + 1] = 1; positions[i * 3] = (Math.random() - 0.5) * 0.2;
positions[i * 3 + 2] = (Math.random() - 0.5) * 0.2; positions[i * 3 + 1] = 1;
data.life = Math.random() * 1.0; positions[i * 3 + 2] = (Math.random() - 0.5) * 0.2;
data.velocity.y = Math.random() * 1.2 + measurePulse; data.life = Math.random() * 1.0;
data.velocity.y = Math.random() * 1.2 + measurePulse;
} else {
// Stop producing: move out of view
positions[i * 3 + 1] = -100;
}
} else { } else {
// Update position // Update position
positions[i * 3] += data.velocity.x * deltaTime; positions[i * 3] += data.velocity.x * deltaTime;
positions[i * 3 + 1] += yVelocity * deltaTime; positions[i * 3 + 1] += yVelocity * deltaTime;
positions[i * 3 + 2] += data.velocity.z * deltaTime; positions[i * 3 + 2] += data.velocity.z * deltaTime;
} }
averageY += positions[i * 3 + 1]; if (positions[i * 3 + 1] > -50) {
averageY += positions[i * 3 + 1];
activeParticleCount++;
}
} }
averageY = averageY / positions.length; averageY = activeParticleCount > 0 ? averageY / activeParticleCount : 0;
torch.particles.geometry.attributes.position.needsUpdate = true; torch.particles.geometry.attributes.position.needsUpdate = true;
// --- Flicker Light --- // --- Flicker Light ---