Feature: spotlight from main window

This commit is contained in:
Dejvino 2025-11-22 10:03:51 +01:00
parent 8abdb94182
commit 1c8eb8534e
3 changed files with 74 additions and 11 deletions

View File

@ -33,17 +33,6 @@ export function init() {
// 6. Initialize all visual effects via the manager // 6. Initialize all visual effects via the manager
state.effectsManager = new EffectsManager(state.scene); state.effectsManager = new EffectsManager(state.scene);
// --- 8. Debug Visualization Helpers ---
// Visual aids for the light source positions
if (state.debugLight && THREE.PointLightHelper) {
const screenHelper = new THREE.PointLightHelper(state.screenLight, 0.1, 0xff0000); // Red for screen
state.scene.add(screenHelper);
// Lamp Helper will now work since lampLight is added to the scene
const lampHelperPoint = new THREE.PointLightHelper(state.lampLightPoint, 0.1, 0x00ff00); // Green for lamp
state.scene.add(lampHelperPoint);
}
// 9. Event Listeners // 9. Event Listeners
window.addEventListener('resize', onWindowResize, false); window.addEventListener('resize', onWindowResize, false);

View File

@ -12,6 +12,7 @@ import { PartyGuests } from './party-guests.js';
import { StageTorches } from './stage-torches.js'; import { StageTorches } from './stage-torches.js';
import { Dancers } from './dancers.js'; import { Dancers } from './dancers.js';
import { MusicVisualizer } from './music-visualizer.js'; import { MusicVisualizer } from './music-visualizer.js';
import { RoseWindowLight } from './rose-window-light.js';
// Scene Features ^^^ // Scene Features ^^^
// --- Scene Modeling Function --- // --- Scene Modeling Function ---
@ -42,5 +43,12 @@ export function createSceneObjects() {
// Add a HemisphereLight for more natural, general illumination in a large space. // Add a HemisphereLight for more natural, general illumination in a large space.
const hemisphereLight = new THREE.HemisphereLight(0xffffff, 0x444444, 0.2); const hemisphereLight = new THREE.HemisphereLight(0xffffff, 0x444444, 0.2);
// Visual aids for the light source positions
if (state.debugLight && THREE.HemisphereLightHelper) {
// Lamp Helper will now work since lampLight is added to the scene
const hemisphereLightHelper = new THREE.HemisphereLightHelper(hemisphereLight, 0.1, 0x00ff00); // Green for lamp
state.scene.add(hemisphereLightHelper);
}
state.scene.add(hemisphereLight); state.scene.add(hemisphereLight);
} }

View File

@ -0,0 +1,66 @@
import * as THREE from 'three';
import { state } from '../state.js';
import { SceneFeature } from './SceneFeature.js';
import sceneFeatureManager from './SceneFeatureManager.js';
export class RoseWindowLight extends SceneFeature {
constructor() {
super();
this.spotlight = null;
this.helper = null;
sceneFeatureManager.register(this);
}
init() {
// --- Dimensions for positioning ---
const length = 40;
const naveHeight = 15;
const stageDepth = 5;
// --- Create the spotlight ---
this.spotlight = new THREE.SpotLight(0xffffff, 100.0); // White light, high intensity
this.spotlight.position.set(0, naveHeight, -length / 2 + 10); // Position it at the rose window
this.spotlight.angle = Math.PI / 9; // A reasonably focused beam
this.spotlight.penumbra = 0.3; // Soft edges
this.spotlight.decay = 0.9;
this.spotlight.distance = 30;
this.spotlight.castShadow = false;
this.spotlight.shadow.mapSize.width = 1024;
this.spotlight.shadow.mapSize.height = 1024;
this.spotlight.shadow.camera.near = 1;
this.spotlight.shadow.camera.far = 30;
this.spotlight.shadow.focus = 1;
// --- Create a target for the spotlight to aim at ---
const targetObject = new THREE.Object3D();
targetObject.position.set(0, 0, -length / 2 + stageDepth); // Aim at the center of the stage
state.scene.add(targetObject);
this.spotlight.target = targetObject;
state.scene.add(this.spotlight);
// --- Add a debug helper ---
if (state.debugLight) {
this.helper = new THREE.SpotLightHelper(this.spotlight);
state.scene.add(this.helper);
}
}
update(deltaTime) {
if (!this.spotlight) return;
// Make the light pulse with the music
if (state.music) {
const baseIntensity = 4.0;
this.spotlight.intensity = baseIntensity + state.music.beatIntensity * 1.0;
}
// Update the helper if it exists
if (this.helper) {
this.helper.update();
}
}
}
new RoseWindowLight();