Feature: higher flames from stage torches
This commit is contained in:
parent
09a2dd03bc
commit
390189e116
@ -4,6 +4,8 @@ import { SceneFeature } from './SceneFeature.js';
|
|||||||
import sceneFeatureManager from './SceneFeatureManager.js';
|
import sceneFeatureManager from './SceneFeatureManager.js';
|
||||||
import sparkTextureUrl from '/textures/spark.png';
|
import sparkTextureUrl from '/textures/spark.png';
|
||||||
|
|
||||||
|
const lightPositionBaseY = 1.2;
|
||||||
|
|
||||||
export class StageTorches extends SceneFeature {
|
export class StageTorches extends SceneFeature {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
@ -48,7 +50,7 @@ export class StageTorches extends SceneFeature {
|
|||||||
|
|
||||||
// --- Point Light ---
|
// --- Point Light ---
|
||||||
const pointLight = new THREE.PointLight(0xffaa44, 2.5, 8);
|
const pointLight = new THREE.PointLight(0xffaa44, 2.5, 8);
|
||||||
pointLight.position.y = 1.2;
|
pointLight.position.y = lightPositionBaseY;
|
||||||
pointLight.castShadow = true;
|
pointLight.castShadow = true;
|
||||||
pointLight.shadow.mapSize.width = 128;
|
pointLight.shadow.mapSize.width = 128;
|
||||||
pointLight.shadow.mapSize.height = 128;
|
pointLight.shadow.mapSize.height = 128;
|
||||||
@ -88,29 +90,32 @@ export class StageTorches extends SceneFeature {
|
|||||||
this.torches.forEach(torch => {
|
this.torches.forEach(torch => {
|
||||||
let measurePulse = 0;
|
let measurePulse = 0;
|
||||||
if (state.music) {
|
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 ---
|
// --- Animate Particles ---
|
||||||
const positions = torch.particles.geometry.attributes.position.array;
|
const positions = torch.particles.geometry.attributes.position.array;
|
||||||
|
let averageY = 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 + measurePulse;
|
const yVelocity = data.velocity.y;
|
||||||
|
|
||||||
if (data.life <= 0) {
|
if (data.life <= 0) {
|
||||||
// Reset particle
|
// Reset particle
|
||||||
positions[i * 3] = 0;
|
positions[i * 3] = 0;
|
||||||
positions[i * 3 + 1] = 1;
|
positions[i * 3 + 1] = 1;
|
||||||
positions[i * 3 + 2] = 0;
|
positions[i * 3 + 2] = 0;
|
||||||
data.life = Math.random() * 1.0;
|
data.life = Math.random() * 1.0;
|
||||||
|
data.velocity.y = Math.random() * 1.5 + measurePulse;
|
||||||
} 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];
|
||||||
}
|
}
|
||||||
|
averageY = averageY / positions.length;
|
||||||
torch.particles.geometry.attributes.position.needsUpdate = true;
|
torch.particles.geometry.attributes.position.needsUpdate = true;
|
||||||
|
|
||||||
// --- Flicker Light ---
|
// --- Flicker Light ---
|
||||||
@ -122,6 +127,7 @@ export class StageTorches extends SceneFeature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
torch.light.intensity = baseIntensity + flicker + beatPulse;
|
torch.light.intensity = baseIntensity + flicker + beatPulse;
|
||||||
|
torch.light.position.y = lightPositionBaseY + averageY;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user