From cc284f7f787f609a73dc0df1dddc9384f6c1d9e6 Mon Sep 17 00:00:00 2001 From: arsam Date: Fri, 18 Sep 2026 23:08:06 +0330 Subject: [PATCH] Import source: src/components/Player/Waveform3D Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality. --- src/components/Player/Waveform3D.jsx | 49 ++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/components/Player/Waveform3D.jsx diff --git a/src/components/Player/Waveform3D.jsx b/src/components/Player/Waveform3D.jsx new file mode 100644 index 0000000..213b97a --- /dev/null +++ b/src/components/Player/Waveform3D.jsx @@ -0,0 +1,49 @@ +import { useRef, useMemo } from 'react' +import { Canvas, useFrame } from '@react-three/fiber' +import * as THREE from 'three' + +const BAR_COUNT = 28 + +function Waveform({ isPlaying }) { + const barsRef = useRef([]) + const phases = useMemo(() => Array.from({ length: BAR_COUNT }, () => Math.random() * Math.PI * 2), []) + + useFrame(({ clock }) => { + const t = clock.getElapsedTime() + barsRef.current.forEach((mesh, i) => { + if (!mesh) return + const target = isPlaying + ? Math.abs(Math.sin(t * 3.5 + phases[i])) * 0.7 + 0.04 + : 0.04 + Math.abs(Math.sin(t * 0.4 + phases[i])) * 0.08 + mesh.scale.y = THREE.MathUtils.lerp(mesh.scale.y, target, 0.18) + mesh.position.y = mesh.scale.y * 0.5 + }) + }) + + return ( + + {Array.from({ length: BAR_COUNT }, (_, i) => ( + (barsRef.current[i] = el)} + position={[(i - BAR_COUNT / 2) * 0.075, 0.04, 0]} + > + + + + ))} + + ) +} + +export default function Waveform3D({ isPlaying }) { + return ( + + + + ) +}