Feature: Stage torches stop spitting flame when not loud but remain visible
This commit is contained in:
parent
ee6ae3a688
commit
31debfe151
@ -104,23 +104,17 @@ export class StageTorches extends SceneFeature {
|
||||
}
|
||||
|
||||
update(deltaTime) {
|
||||
const enabled = state.config.torchesEnabled && !state.blackoutMode;
|
||||
const configEnabled = state.config.torchesEnabled;
|
||||
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) {
|
||||
this.torches.forEach(torch => {
|
||||
if (torch.light.visible) torch.light.visible = false;
|
||||
if (torch.particles.visible) torch.particles.visible = false;
|
||||
});
|
||||
return;
|
||||
}
|
||||
const fireActive = !state.blackoutMode && !(!state.partyStarted && state.music.isLoudEnough);
|
||||
|
||||
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;
|
||||
|
||||
let measurePulse = 0;
|
||||
@ -134,26 +128,35 @@ export class StageTorches extends SceneFeature {
|
||||
// --- Animate Particles ---
|
||||
const positions = torch.particles.geometry.attributes.position.array;
|
||||
let averageY = 0;
|
||||
let activeParticleCount = 0;
|
||||
for (let i = 0; i < torch.particleData.length; i++) {
|
||||
const data = torch.particleData[i];
|
||||
data.life -= deltaTime;
|
||||
const yVelocity = data.velocity.y;
|
||||
if (data.life <= 0 || positions[i * 3 + 1] < 0) {
|
||||
if (fireActive) {
|
||||
// Reset particle
|
||||
positions[i * 3] = (Math.random() - 0.5) * 0.2;
|
||||
positions[i * 3 + 1] = 1;
|
||||
positions[i * 3 + 2] = (Math.random() - 0.5) * 0.2;
|
||||
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 {
|
||||
// Update position
|
||||
positions[i * 3] += data.velocity.x * deltaTime;
|
||||
positions[i * 3 + 1] += yVelocity * deltaTime;
|
||||
positions[i * 3 + 2] += data.velocity.z * deltaTime;
|
||||
}
|
||||
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;
|
||||
|
||||
// --- Flicker Light ---
|
||||
|
||||
Loading…
Reference in New Issue
Block a user