Feature: higher flames from stage torches

This commit is contained in:
Dejvino 2025-11-22 06:44:22 +01:00
parent 09a2dd03bc
commit 390189e116

View File

@ -4,6 +4,8 @@ import { SceneFeature } from './SceneFeature.js';
import sceneFeatureManager from './SceneFeatureManager.js';
import sparkTextureUrl from '/textures/spark.png';
const lightPositionBaseY = 1.2;
export class StageTorches extends SceneFeature {
constructor() {
super();
@ -48,7 +50,7 @@ export class StageTorches extends SceneFeature {
// --- Point Light ---
const pointLight = new THREE.PointLight(0xffaa44, 2.5, 8);
pointLight.position.y = 1.2;
pointLight.position.y = lightPositionBaseY;
pointLight.castShadow = true;
pointLight.shadow.mapSize.width = 128;
pointLight.shadow.mapSize.height = 128;
@ -88,29 +90,32 @@ export class StageTorches extends SceneFeature {
this.torches.forEach(torch => {
let measurePulse = 0;
if (state.music) {
measurePulse = state.music.measurePulse * 2.0; // Make flames jump higher
measurePulse = state.music.measurePulse * 4.0; // Make flames jump higher
}
// --- Animate Particles ---
const positions = torch.particles.geometry.attributes.position.array;
let averageY = 0;
for (let i = 0; i < torch.particleData.length; i++) {
const data = torch.particleData[i];
data.life -= deltaTime;
const yVelocity = data.velocity.y + measurePulse;
const yVelocity = data.velocity.y;
if (data.life <= 0) {
// Reset particle
positions[i * 3] = 0;
positions[i * 3 + 1] = 1;
positions[i * 3 + 2] = 0;
data.life = Math.random() * 1.0;
data.velocity.y = Math.random() * 1.5 + measurePulse;
} else {
// Update position
positions[i * 3] += data.velocity.x * deltaTime;
positions[i * 3 + 1] += yVelocity * deltaTime;
positions[i * 3 + 2] += data.velocity.z * deltaTime;
}
averageY += positions[i * 3 + 1];
}
averageY = averageY / positions.length;
torch.particles.geometry.attributes.position.needsUpdate = true;
// --- Flicker Light ---
@ -122,6 +127,7 @@ export class StageTorches extends SceneFeature {
}
torch.light.intensity = baseIntensity + flicker + beatPulse;
torch.light.position.y = lightPositionBaseY + averageY;
});
}
}