Spaces:
Sleeping
Sleeping
Update src/components/WorldTreeVisualizer.tsx
Browse files
src/components/WorldTreeVisualizer.tsx
CHANGED
|
@@ -1493,6 +1493,14 @@ export const WorldTreeVisualizer: React.FC<WorldTreeVisualizerProps> = ({ audioE
|
|
| 1493 |
// Calculate distance and sphere radius early for use in forces
|
| 1494 |
const dist = Math.sqrt(x*x + y*y + z*z)
|
| 1495 |
const sphereRadius = params.sphereRadius
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1496 |
|
| 1497 |
// Apply noise-based turbulence with distance-based scaling
|
| 1498 |
const ns = params.noiseScale * adaptiveLevel // Scale noise with performance
|
|
@@ -1513,10 +1521,10 @@ export const WorldTreeVisualizer: React.FC<WorldTreeVisualizerProps> = ({ audioE
|
|
| 1513 |
// STABILITY: Scale turbulence by performance, distance, and containment zones
|
| 1514 |
const performanceScale = Math.min(1.0, 60 * clampedDeltaTime) // Scale down for low FPS
|
| 1515 |
|
| 1516 |
-
//
|
| 1517 |
-
const distanceScale = Math.max(0.
|
| 1518 |
|
| 1519 |
-
const turbulenceScale = params.turbulenceStrength * performanceScale * distanceScale * 0.
|
| 1520 |
|
| 1521 |
vx += noiseX * turbulenceScale
|
| 1522 |
vy += noiseY * turbulenceScale
|
|
@@ -1536,13 +1544,9 @@ export const WorldTreeVisualizer: React.FC<WorldTreeVisualizerProps> = ({ audioE
|
|
| 1536 |
const dz = z / dist
|
| 1537 |
|
| 1538 |
// Modified beat force to prevent dispersion with stronger containment awareness
|
| 1539 |
-
const baseBeatForce = be * params.beatStrength * 0.
|
| 1540 |
|
| 1541 |
-
//
|
| 1542 |
-
const coreZone = sphereRadius * 0.4
|
| 1543 |
-
const innerZone = sphereRadius * 0.65
|
| 1544 |
-
const boundaryZone = sphereRadius * 0.8
|
| 1545 |
-
const dangerZone = sphereRadius * 0.92
|
| 1546 |
|
| 1547 |
if (dist < coreZone) {
|
| 1548 |
// Normal outward beat force in core zone only
|
|
@@ -1589,13 +1593,10 @@ export const WorldTreeVisualizer: React.FC<WorldTreeVisualizerProps> = ({ audioE
|
|
| 1589 |
const dy = y / dist
|
| 1590 |
const dz = z / dist
|
| 1591 |
|
| 1592 |
-
//
|
| 1593 |
-
const baseWaveIntensity = 0.
|
| 1594 |
|
| 1595 |
-
//
|
| 1596 |
-
const coreZone = sphereRadius * 0.4
|
| 1597 |
-
const innerZone = sphereRadius * 0.65
|
| 1598 |
-
const boundaryZone = sphereRadius * 0.8
|
| 1599 |
|
| 1600 |
let waveIntensity = baseWaveIntensity
|
| 1601 |
let waveDirection = 1 // 1 = outward, -1 = inward, 0 = tangential
|
|
@@ -1642,21 +1643,18 @@ export const WorldTreeVisualizer: React.FC<WorldTreeVisualizerProps> = ({ audioE
|
|
| 1642 |
// Create geometric patterns based on frequency
|
| 1643 |
const geometricPattern = getCymatePattern(x, y, z, freq, currentTime * 0.001)
|
| 1644 |
|
| 1645 |
-
// Scale cymatic intensity
|
| 1646 |
-
const coreZone = sphereRadius * 0.4
|
| 1647 |
-
const boundaryZone = sphereRadius * 0.8
|
| 1648 |
-
|
| 1649 |
let cymateScale = 1.0
|
| 1650 |
if (dist > boundaryZone) {
|
| 1651 |
-
//
|
| 1652 |
-
cymateScale = 0.
|
| 1653 |
} else if (dist > coreZone) {
|
| 1654 |
-
//
|
| 1655 |
-
cymateScale = 1.0 - ((dist - coreZone) / (boundaryZone - coreZone)) * 0.
|
| 1656 |
}
|
| 1657 |
|
| 1658 |
-
//
|
| 1659 |
-
const organicIntensity = 0.
|
| 1660 |
vx += geometricPattern.x * organicIntensity
|
| 1661 |
vy += geometricPattern.y * organicIntensity
|
| 1662 |
vz += geometricPattern.z * organicIntensity
|
|
@@ -1700,19 +1698,25 @@ export const WorldTreeVisualizer: React.FC<WorldTreeVisualizerProps> = ({ audioE
|
|
| 1700 |
avgVy /= neighborCount
|
| 1701 |
avgVz /= neighborCount
|
| 1702 |
|
| 1703 |
-
//
|
| 1704 |
-
const flockInfluence = entronautParams.coupling * 0.2
|
| 1705 |
-
|
| 1706 |
-
|
| 1707 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1708 |
}
|
| 1709 |
}
|
| 1710 |
|
| 1711 |
-
//
|
| 1712 |
if (entronautEnabled && adaptiveCoupling) {
|
| 1713 |
-
const metabolicPulse = entronautParams.diffusion * 0.5
|
| 1714 |
-
|
| 1715 |
-
|
|
|
|
|
|
|
| 1716 |
}
|
| 1717 |
|
| 1718 |
// STABILITY: Velocity clamping to prevent runaway particles
|
|
@@ -1724,34 +1728,24 @@ export const WorldTreeVisualizer: React.FC<WorldTreeVisualizerProps> = ({ audioE
|
|
| 1724 |
vz *= scale
|
| 1725 |
}
|
| 1726 |
|
| 1727 |
-
// Apply adaptive drag/damping with
|
| 1728 |
let dampingFactor = entronautParams.damping
|
| 1729 |
|
| 1730 |
-
//
|
| 1731 |
-
if (dist >
|
| 1732 |
-
dampingFactor *= 0.
|
| 1733 |
-
} else if (dist > sphereRadius * 0.6) {
|
| 1734 |
-
dampingFactor *= 0.9 // Medium extra damping
|
| 1735 |
}
|
| 1736 |
|
| 1737 |
-
//
|
| 1738 |
-
const velocityDecay = config?.visualization?.physics?.velocityDecay || 0.995
|
| 1739 |
-
dampingFactor = Math.
|
| 1740 |
|
| 1741 |
vx *= dampingFactor
|
| 1742 |
vy *= dampingFactor
|
| 1743 |
vz *= dampingFactor
|
| 1744 |
|
| 1745 |
// ENHANCED MULTI-LAYER CONTAINMENT SYSTEM
|
| 1746 |
-
// (dist and
|
| 1747 |
-
|
| 1748 |
-
// Define containment zones with much tighter control
|
| 1749 |
-
const coreZone = sphereRadius * 0.4 // Core zone - natural movement
|
| 1750 |
-
const innerZone = sphereRadius * 0.65 // Inner zone - gentle forces
|
| 1751 |
-
const boundaryZone = sphereRadius * 0.8 // Warning zone - medium forces
|
| 1752 |
-
const dangerZone = sphereRadius * 0.92 // Danger zone - strong forces
|
| 1753 |
-
const emergencyZone = sphereRadius * 0.98 // Emergency zone - very strong forces
|
| 1754 |
-
const hardBoundary = sphereRadius * 1.02 // Hard boundary - immediate reset
|
| 1755 |
|
| 1756 |
// HARD BOUNDARY - Immediate containment for escaped particles
|
| 1757 |
if (dist > hardBoundary) {
|
|
@@ -1840,28 +1834,26 @@ export const WorldTreeVisualizer: React.FC<WorldTreeVisualizerProps> = ({ audioE
|
|
| 1840 |
vz -= dz * innerForce
|
| 1841 |
}
|
| 1842 |
|
| 1843 |
-
//
|
| 1844 |
-
if (dist >
|
| 1845 |
const dx = x / dist
|
| 1846 |
const dy = y / dist
|
| 1847 |
const dz = z / dist
|
| 1848 |
|
| 1849 |
-
//
|
| 1850 |
-
const
|
| 1851 |
-
vx -= dx *
|
| 1852 |
-
vy -= dy *
|
| 1853 |
-
vz -= dz *
|
| 1854 |
}
|
| 1855 |
|
| 1856 |
-
// VELOCITY CLAMPING -
|
| 1857 |
-
let maxVel = config?.visualization?.physics?.maxVelocity || 0.
|
| 1858 |
|
| 1859 |
-
if (dist >
|
| 1860 |
-
maxVel *= 0.
|
| 1861 |
-
} else if (dist >
|
| 1862 |
-
maxVel *= 0.
|
| 1863 |
-
} else if (dist > innerZone) {
|
| 1864 |
-
maxVel *= 0.8 // Slightly limit velocity in inner zone
|
| 1865 |
}
|
| 1866 |
|
| 1867 |
const velMag = Math.sqrt(vx*vx + vy*vy + vz*vz)
|
|
|
|
| 1493 |
// Calculate distance and sphere radius early for use in forces
|
| 1494 |
const dist = Math.sqrt(x*x + y*y + z*z)
|
| 1495 |
const sphereRadius = params.sphereRadius
|
| 1496 |
+
|
| 1497 |
+
// Define containment zones for use throughout particle update
|
| 1498 |
+
const coreZone = sphereRadius * 0.4 // Core zone - natural movement
|
| 1499 |
+
const innerZone = sphereRadius * 0.65 // Inner zone - gentle forces
|
| 1500 |
+
const boundaryZone = sphereRadius * 0.8 // Warning zone - medium forces
|
| 1501 |
+
const dangerZone = sphereRadius * 0.92 // Danger zone - strong forces
|
| 1502 |
+
const emergencyZone = sphereRadius * 0.98 // Emergency zone - very strong forces
|
| 1503 |
+
const hardBoundary = sphereRadius * 1.02 // Hard boundary - immediate reset
|
| 1504 |
|
| 1505 |
// Apply noise-based turbulence with distance-based scaling
|
| 1506 |
const ns = params.noiseScale * adaptiveLevel // Scale noise with performance
|
|
|
|
| 1521 |
// STABILITY: Scale turbulence by performance, distance, and containment zones
|
| 1522 |
const performanceScale = Math.min(1.0, 60 * clampedDeltaTime) // Scale down for low FPS
|
| 1523 |
|
| 1524 |
+
// Scale turbulence to maintain audio reactivity while preventing boundary escape
|
| 1525 |
+
const distanceScale = Math.max(0.3, 1 - (dist / sphereRadius) * 0.6) // Less aggressive reduction
|
| 1526 |
|
| 1527 |
+
const turbulenceScale = params.turbulenceStrength * performanceScale * distanceScale * 0.9 // Preserve more turbulence
|
| 1528 |
|
| 1529 |
vx += noiseX * turbulenceScale
|
| 1530 |
vy += noiseY * turbulenceScale
|
|
|
|
| 1544 |
const dz = z / dist
|
| 1545 |
|
| 1546 |
// Modified beat force to prevent dispersion with stronger containment awareness
|
| 1547 |
+
const baseBeatForce = be * params.beatStrength * 0.8 // Increased to preserve audio reactivity
|
| 1548 |
|
| 1549 |
+
// Use containment zones already defined above
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1550 |
|
| 1551 |
if (dist < coreZone) {
|
| 1552 |
// Normal outward beat force in core zone only
|
|
|
|
| 1593 |
const dy = y / dist
|
| 1594 |
const dz = z / dist
|
| 1595 |
|
| 1596 |
+
// Balance wave force intensity to preserve audio reactivity while maintaining containment
|
| 1597 |
+
const baseWaveIntensity = 0.0006 // Increased to preserve audio reactivity
|
| 1598 |
|
| 1599 |
+
// Use containment zones already defined above for wave behavior
|
|
|
|
|
|
|
|
|
|
| 1600 |
|
| 1601 |
let waveIntensity = baseWaveIntensity
|
| 1602 |
let waveDirection = 1 // 1 = outward, -1 = inward, 0 = tangential
|
|
|
|
| 1643 |
// Create geometric patterns based on frequency
|
| 1644 |
const geometricPattern = getCymatePattern(x, y, z, freq, currentTime * 0.001)
|
| 1645 |
|
| 1646 |
+
// Scale cymatic intensity to balance audio reactivity with containment
|
|
|
|
|
|
|
|
|
|
| 1647 |
let cymateScale = 1.0
|
| 1648 |
if (dist > boundaryZone) {
|
| 1649 |
+
// Moderate reduction near boundaries while preserving some reactivity
|
| 1650 |
+
cymateScale = 0.4
|
| 1651 |
} else if (dist > coreZone) {
|
| 1652 |
+
// Gentle reduction outside core
|
| 1653 |
+
cymateScale = 1.0 - ((dist - coreZone) / (boundaryZone - coreZone)) * 0.4
|
| 1654 |
}
|
| 1655 |
|
| 1656 |
+
// Maintain stronger cymatic intensity for audio reactivity
|
| 1657 |
+
const organicIntensity = 0.0012 * cymateScale * (0.8 + 0.2 * Math.sin(currentTime * 0.0005))
|
| 1658 |
vx += geometricPattern.x * organicIntensity
|
| 1659 |
vy += geometricPattern.y * organicIntensity
|
| 1660 |
vz += geometricPattern.z * organicIntensity
|
|
|
|
| 1698 |
avgVy /= neighborCount
|
| 1699 |
avgVz /= neighborCount
|
| 1700 |
|
| 1701 |
+
// Reduce flocking influence to prevent convergence and preserve individuality
|
| 1702 |
+
const flockInfluence = entronautParams.coupling * 0.08 // Reduced from 0.2
|
| 1703 |
+
|
| 1704 |
+
// Add some randomness to promote emergence rather than convergence
|
| 1705 |
+
const emergenceRandomness = (Math.random() - 0.5) * 0.001
|
| 1706 |
+
|
| 1707 |
+
vx += (avgVx - vx) * flockInfluence + emergenceRandomness
|
| 1708 |
+
vy += (avgVy - vy) * flockInfluence + emergenceRandomness
|
| 1709 |
+
vz += (avgVz - vz) * flockInfluence + emergenceRandomness
|
| 1710 |
}
|
| 1711 |
}
|
| 1712 |
|
| 1713 |
+
// Light metabolic pulsing to add organic variation without dampening
|
| 1714 |
if (entronautEnabled && adaptiveCoupling) {
|
| 1715 |
+
const metabolicPulse = entronautParams.diffusion * 0.3 // Reduced from 0.5
|
| 1716 |
+
const timeVariation = currentTime * 0.0001 // Add time-based variation
|
| 1717 |
+
vx += metabolicPulse * Math.cos(i * 0.01 + timeVariation)
|
| 1718 |
+
vy += metabolicPulse * Math.sin(i * 0.01 + timeVariation)
|
| 1719 |
+
vz += metabolicPulse * Math.sin(i * 0.007 + timeVariation) * 0.5 // Add Z variation
|
| 1720 |
}
|
| 1721 |
|
| 1722 |
// STABILITY: Velocity clamping to prevent runaway particles
|
|
|
|
| 1728 |
vz *= scale
|
| 1729 |
}
|
| 1730 |
|
| 1731 |
+
// Apply adaptive drag/damping with preservation of audio reactivity
|
| 1732 |
let dampingFactor = entronautParams.damping
|
| 1733 |
|
| 1734 |
+
// Only apply extra damping in extreme zones to preserve energy
|
| 1735 |
+
if (dist > emergencyZone) {
|
| 1736 |
+
dampingFactor *= 0.9 // Light extra damping only near hard boundary
|
|
|
|
|
|
|
| 1737 |
}
|
| 1738 |
|
| 1739 |
+
// Use less aggressive velocity decay to maintain particle liveliness
|
| 1740 |
+
const velocityDecay = config?.visualization?.physics?.velocityDecay || 0.998 // Increased from 0.995
|
| 1741 |
+
dampingFactor = Math.max(dampingFactor, velocityDecay) // Use max to preserve energy
|
| 1742 |
|
| 1743 |
vx *= dampingFactor
|
| 1744 |
vy *= dampingFactor
|
| 1745 |
vz *= dampingFactor
|
| 1746 |
|
| 1747 |
// ENHANCED MULTI-LAYER CONTAINMENT SYSTEM
|
| 1748 |
+
// (dist, sphereRadius, and containment zones already calculated above)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1749 |
|
| 1750 |
// HARD BOUNDARY - Immediate containment for escaped particles
|
| 1751 |
if (dist > hardBoundary) {
|
|
|
|
| 1834 |
vz -= dz * innerForce
|
| 1835 |
}
|
| 1836 |
|
| 1837 |
+
// GENTLE CENTER BIAS - Only for particles very far from center
|
| 1838 |
+
if (dist > sphereRadius * 0.9 && dist > 0) {
|
| 1839 |
const dx = x / dist
|
| 1840 |
const dy = y / dist
|
| 1841 |
const dz = z / dist
|
| 1842 |
|
| 1843 |
+
// Very gentle pull only when approaching boundaries
|
| 1844 |
+
const centerBias = (dist - sphereRadius * 0.9) / (sphereRadius * 0.1) * 0.0008
|
| 1845 |
+
vx -= dx * centerBias
|
| 1846 |
+
vy -= dy * centerBias
|
| 1847 |
+
vz -= dz * centerBias
|
| 1848 |
}
|
| 1849 |
|
| 1850 |
+
// VELOCITY CLAMPING - Less restrictive to preserve audio reactivity
|
| 1851 |
+
let maxVel = config?.visualization?.physics?.maxVelocity || 0.025 // Increased base velocity
|
| 1852 |
|
| 1853 |
+
if (dist > emergencyZone) {
|
| 1854 |
+
maxVel *= 0.6 // Moderate limit only in emergency zone
|
| 1855 |
+
} else if (dist > dangerZone) {
|
| 1856 |
+
maxVel *= 0.8 // Light limit in danger zone
|
|
|
|
|
|
|
| 1857 |
}
|
| 1858 |
|
| 1859 |
const velMag = Math.sqrt(vx*vx + vy*vy + vz*vz)
|