Fixed exception. Added candleflicker.

This commit is contained in:
2025-04-04 19:33:14 +00:00
parent 49a5af252c
commit c27ba8be6b
3 changed files with 807 additions and 727 deletions
+755 -723
View File
File diff suppressed because it is too large Load Diff
+19 -1
View File
@@ -44,7 +44,8 @@ class TTSFactoryModule extends BaseModule {
'pause',
'resume',
'getVoices',
'getPreference'
'getPreference',
'isSpeaking'
]);
// Add dependencies
@@ -369,6 +370,23 @@ class TTSFactoryModule extends BaseModule {
return defaultValue;
}
/**
* Check if any TTS handler is currently speaking
* @returns {boolean} - True if speaking, false otherwise
*/
isSpeaking() {
if (!this.activeHandler || !this.handlers[this.activeHandler]) {
return false;
}
try {
return this.handlers[this.activeHandler].isSpeaking();
} catch (error) {
console.error("Error checking speaking status:", error);
return false;
}
}
/**
* Clean up when module is disposed
*/
+33 -3
View File
@@ -42,7 +42,8 @@ class UIEffects extends BaseModule {
'applyShakeEffect',
'applyFlashEffect',
'applyTextEmphasis',
'processCommand'
'processCommand',
'handleLightingAnimationEnd'
]);
console.log('UIEffects: Constructor initialized');
@@ -62,6 +63,9 @@ class UIEffects extends BaseModule {
// Set up ambient effect animations
this.setupAmbientEffects();
// Start ambient effects immediately after initialization
this.startAmbientEffects();
this.reportProgress(100, 'UI Effects ready');
// Use the parent's dispatchEvent method
@@ -124,6 +128,31 @@ class UIEffects extends BaseModule {
setupCandleFlickerEffect() {
// Store the animation frame ID for later cancellation
this.candleAnimationId = null;
// Add animation end event listener to create continuous random animations
if (this.lightingElement) {
this.lightingElement.addEventListener('animationend', this.handleLightingAnimationEnd.bind(this));
}
}
/**
* Handle the end of a lighting animation by setting a new random duration
* @param {AnimationEvent} event - The animation end event
*/
handleLightingAnimationEnd(event) {
if (!this.lightingElement || !this.ambientEffectsActive) return;
// Generate a random duration between 0.5 and 4 seconds
const randomDuration = Math.random() * 3.5 + 0.5;
// Toggle between grow and shrink animations
const previousAnimation = event.animationName;
if (previousAnimation === 'gradient-animation-grow') {
this.lightingElement.style.animation = `gradient-animation-shrink ${randomDuration}s 1`;
} else {
this.lightingElement.style.animation = `gradient-animation-grow ${randomDuration}s 1`;
}
}
updateCandleEffect() {
@@ -153,9 +182,10 @@ class UIEffects extends BaseModule {
this.updateCandleEffect();
}
// Apply lighting animation
// Apply lighting animation with initial random duration
if (this.lightingElement) {
this.lightingElement.style.animation = 'gradient-animation-shrink 2s infinite alternate';
const initialDuration = Math.random() * 3.5 + 0.5;
this.lightingElement.style.animation = `gradient-animation-shrink ${initialDuration}s 1`;
}
}