Fix: lightshafts do not reset
This commit is contained in:
parent
e6487de0a7
commit
43ad03cd8b
@ -11,19 +11,10 @@ function updateShaderTime() {
|
||||
}
|
||||
|
||||
// --- Animation Loop ---
|
||||
let lastTime = -1;
|
||||
export function animate() {
|
||||
requestAnimationFrame(animate);
|
||||
|
||||
let deltaTime = 0;
|
||||
if (lastTime === -1) {
|
||||
lastTime = state.clock.getElapsedTime();
|
||||
deltaTime = 1;
|
||||
} else {
|
||||
const newTime = state.clock.getElapsedTime();
|
||||
deltaTime = newTime - lastTime;
|
||||
lastTime = newTime;
|
||||
}
|
||||
const deltaTime = state.clock.getDelta();
|
||||
|
||||
if (deltaTime > 0) {
|
||||
sceneFeatureManager.update(deltaTime);
|
||||
|
||||
@ -64,8 +64,6 @@ export class MusicPlayer extends SceneFeature {
|
||||
this.stopParty();
|
||||
uiContainer.style.display = 'flex'; // Show the button again
|
||||
});
|
||||
|
||||
state.clock.stop();
|
||||
}
|
||||
|
||||
startParty() {
|
||||
|
||||
@ -19,11 +19,11 @@ export class RoseWindowLightshafts extends SceneFeature {
|
||||
const stageWidth = naveWidth - 1;
|
||||
|
||||
const roseWindowRadius = naveWidth / 2 - 2;
|
||||
const roseWindowCenter = new THREE.Vector3(0, naveHeight - 2, -length / 2 + 0.1);
|
||||
const roseWindowCenter = new THREE.Vector3(0, naveHeight, -length / 2 - 1.1);
|
||||
|
||||
// --- Procedural Noise Texture for Light Shafts ---
|
||||
const createNoiseTexture = () => {
|
||||
const width = 64;
|
||||
const width = 128;
|
||||
const height = 512;
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = width;
|
||||
@ -45,23 +45,23 @@ export class RoseWindowLightshafts extends SceneFeature {
|
||||
return new THREE.CanvasTexture(canvas);
|
||||
};
|
||||
|
||||
const texture = createNoiseTexture();
|
||||
texture.wrapS = THREE.RepeatWrapping;
|
||||
texture.wrapT = THREE.RepeatWrapping;
|
||||
|
||||
const baseMaterial = new THREE.MeshBasicMaterial({
|
||||
map: texture,
|
||||
//map: texture,
|
||||
blending: THREE.AdditiveBlending,
|
||||
transparent: true,
|
||||
depthWrite: false,
|
||||
opacity: 0.3,
|
||||
opacity: 1.0,
|
||||
color: 0x88aaff, // Give the light a cool blueish tint
|
||||
});
|
||||
|
||||
// --- Create multiple thin light shafts ---
|
||||
const numShafts = 12;
|
||||
const numShafts = 16;
|
||||
for (let i = 0; i < numShafts; i++) {
|
||||
const texture = createNoiseTexture();
|
||||
texture.wrapS = THREE.RepeatWrapping;
|
||||
texture.wrapT = THREE.RepeatWrapping;
|
||||
const material = baseMaterial.clone(); // Each shaft needs its own material for individual opacity
|
||||
material.map = texture;
|
||||
|
||||
const startAngle = Math.random() * Math.PI * 2;
|
||||
const startRadius = Math.random() * roseWindowRadius;
|
||||
@ -73,18 +73,18 @@ export class RoseWindowLightshafts extends SceneFeature {
|
||||
|
||||
// Define a linear path on the floor for the beam to travel
|
||||
const floorStartPoint = new THREE.Vector3(
|
||||
(Math.random() - 0.5) * stageWidth * 1.0,
|
||||
(Math.random() - 0.5) * stageWidth * 0.75,
|
||||
0,
|
||||
-length / 2 + Math.random() * 10 + 0
|
||||
-length / 2 + Math.random() * 8 + 0
|
||||
);
|
||||
const floorEndPoint = new THREE.Vector3(
|
||||
(Math.random() - 0.5) * stageWidth * 1.0,
|
||||
(Math.random() - 0.5) * stageWidth * 0.75,
|
||||
0,
|
||||
-length / 2 + Math.random() * 10 + 3
|
||||
-length / 2 + Math.random() * 8 + 3
|
||||
);
|
||||
|
||||
const distance = startPoint.distanceTo(floorStartPoint);
|
||||
const geometry = new THREE.CylinderGeometry(0.1, 0.5 + Math.random() * 0.5, distance, 16, 1, true);
|
||||
const geometry = new THREE.CylinderGeometry(0.01, 0.5 + Math.random() * 0.5, distance, 16, 1, true);
|
||||
const lightShaft = new THREE.Mesh(geometry, material);
|
||||
|
||||
state.scene.add(lightShaft);
|
||||
@ -94,7 +94,7 @@ export class RoseWindowLightshafts extends SceneFeature {
|
||||
endPoint: floorStartPoint.clone(), // The current position of the beam on the floor
|
||||
floorStartPoint: floorStartPoint, // The start of the sweep path
|
||||
floorEndPoint: floorEndPoint, // The end of the sweep path
|
||||
moveSpeed: 0.5 + Math.random() * 1.5, // Each shaft has a different speed
|
||||
moveSpeed: 0.01 + Math.random() * 0.5, // Each shaft has a different speed
|
||||
// No 'state' needed anymore
|
||||
});
|
||||
}
|
||||
@ -107,7 +107,8 @@ export class RoseWindowLightshafts extends SceneFeature {
|
||||
const { mesh, startPoint, endPoint, floorStartPoint, floorEndPoint, moveSpeed } = shaft;
|
||||
|
||||
// Animate texture for dust motes
|
||||
mesh.material.map.offset.y -= deltaTime * 0.001;
|
||||
mesh.material.map.offset.y += deltaTime * 0.004;
|
||||
mesh.material.map.offset.x -= deltaTime * 0.02;
|
||||
|
||||
// --- Movement Logic ---
|
||||
const pathDirection = floorEndPoint.clone().sub(floorStartPoint).normalize();
|
||||
@ -130,7 +131,7 @@ export class RoseWindowLightshafts extends SceneFeature {
|
||||
|
||||
// --- Update Mesh Position and Orientation ---
|
||||
const distance = startPoint.distanceTo(endPoint);
|
||||
mesh.scale.y = distance;
|
||||
mesh.scale.y = -distance/5;
|
||||
mesh.position.lerpVectors(startPoint, endPoint, 0.5);
|
||||
|
||||
const quaternion = new THREE.Quaternion();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user