Spaces:
Sleeping
Sleeping
File size: 4,809 Bytes
6a03d7f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
// Enhanced visualization types for advanced particle system
export interface ParticleSystemParams {
enabled: boolean
sphereRadius: number
innerSphereRadius: number
rotationSpeed: number
rotationSpeedMin: number
rotationSpeedMax: number
rotationSmoothness: number
particleCount: number
particleSize: number
particleLifetime: number
minFrequency: number
maxFrequency: number
minFrequencyBeat: number
maxFrequencyBeat: number
noiseScale: number
dynamicNoiseScale: boolean
minNoiseScale: number
maxNoiseScale: number
noiseStep: number
noiseSpeed: number
turbulenceStrength: number
colorStart: string
colorEnd: string
volumeChangeThreshold: number
peakSensitivity: number
beatThreshold: number
baseWaveStrength: number
beatStrength: number
gainMultiplier: number
}
export interface PeakDetection {
energyHistory: number[]
historyLength: number
lastPeakTime: number
minTimeBetweenPeaks: number
}
export interface ParticleSphere {
index: number
params: ParticleSystemParams
positions: Float32Array
velocities: Float32Array
basePositions: Float32Array
lifetimes: Float32Array
maxLifetimes: Float32Array
beatEffects: Float32Array
colors: Float32Array
lastNoiseScale: number
lastValidVolume: number
lastRotationSpeed: number
peakDetection: PeakDetection
}
export interface AudioAnalysisData {
average: number
frequencies: Uint8Array
peakDetected: boolean
rangeEnergy: number
rangeEnergyBeat: number
}
export interface FogParams {
enabled: boolean
color: string
near: number
far: number
}
export interface VisualizationPreset {
name: string
spheres: ParticleSystemParams[]
fog?: FogParams
}
export interface VisualizationState {
// Enhanced particle system state
spheres: ParticleSphere[]
beatManager?: {
currentWaveRadius: number
waveStrength: number
isWaveActive: boolean
}
// Legacy tree visualization state (for backward compatibility)
deepPulseIntensity: number
midGlowIntensity: number
highShimmerIntensity: number
worldBreathRate: number
// Animation state
lastTime: number
isAnimating: boolean
}
// Default frequency ranges for different spheres
export const DEFAULT_FREQUENCY_RANGES = [
{ minFrequency: 20, maxFrequency: 80 }, // Sub-bass
{ minFrequency: 120, maxFrequency: 250 }, // Bass
{ minFrequency: 250, maxFrequency: 800 }, // Mid
{ minFrequency: 1000, maxFrequency: 4000 }, // High mid
{ minFrequency: 5000, maxFrequency: 10000 } // High
] as const
export const DEFAULT_SPHERE_PARAMS: ParticleSystemParams = {
enabled: false,
sphereRadius: 1.0,
innerSphereRadius: 0.25,
rotationSpeed: 0.001,
rotationSpeedMin: 0,
rotationSpeedMax: 0.065,
rotationSmoothness: 0.3,
particleCount: 20000,
particleSize: 0.003,
particleLifetime: 3.0,
minFrequency: 20,
maxFrequency: 80,
minFrequencyBeat: 20,
maxFrequencyBeat: 80,
noiseScale: 4.0,
dynamicNoiseScale: true,
minNoiseScale: 0.5,
maxNoiseScale: 5.0,
noiseStep: 0.2,
noiseSpeed: 0.1,
turbulenceStrength: 0.005,
colorStart: '#ff3366',
colorEnd: '#3366ff',
volumeChangeThreshold: 0.1,
peakSensitivity: 1.1,
beatThreshold: 200,
baseWaveStrength: 20.0,
beatStrength: 0.01,
gainMultiplier: 1
}
// Legacy types for backward compatibility
export interface WorldTreeNode {
id: string;
x: number;
y: number;
size: number;
glyphType: 'root' | 'trunk' | 'branch' | 'leaf';
intensity: number; // 0-1, driven by audio
connections: string[]; // IDs of connected nodes
}
export interface TreeBranch {
id: string;
startNode: string;
endNode: string;
strokeWidth: number;
pathData: string; // SVG path
energy: number; // Current energy flowing through
pulsePhase: number; // Animation phase
}
export interface GlyphSystem {
coreGlyphs: WorldTreeNode[];
arterialPathways: TreeBranch[];
fractalBranches: TreeBranch[];
emberParticles: Particle[];
}
export interface Particle {
id: string;
x: number;
y: number;
vx: number;
vy: number;
life: number;
maxLife: number;
size: number;
opacity: number;
}
export interface VisualizationParams {
worldBreathRate: number; // Base breathing animation speed
deepPulseIntensity: number; // Trunk/root pulse strength
midGlowIntensity: number; // Core glyph glow
highShimmerCount: number; // Number of fractal branches/particles
noiseScale: number; // Perlin noise scale for organic movement
colorPalette: {
primary: string; // Deep earth tones
secondary: string; // Burnished metal
accent: string; // Mystical glow
ember: string; // Particle color
};
}
export interface InteractionState {
isDormant: boolean;
isAwakening: boolean;
isAlive: boolean;
lastInteraction: number;
} |