({
topColor = "#5227FF",
bottomColor = "#FF9FFC",
intensity = 1.0,
rotationSpeed = 0.3,
interactive = false,
className = "",
glowAmount = 0.005,
pillarWidth = 3.0,
pillarHeight = 0.4,
noiseIntensity = 0.5,
mixBlendMode = "screen",
pillarRotation = 0,
opacity = 1,
})
| 20 | } |
| 21 | |
| 22 | const LightPillar: React.FC<LightPillarProps> = ({ |
| 23 | topColor = "#5227FF", |
| 24 | bottomColor = "#FF9FFC", |
| 25 | intensity = 1.0, |
| 26 | rotationSpeed = 0.3, |
| 27 | interactive = false, |
| 28 | className = "", |
| 29 | glowAmount = 0.005, |
| 30 | pillarWidth = 3.0, |
| 31 | pillarHeight = 0.4, |
| 32 | noiseIntensity = 0.5, |
| 33 | mixBlendMode = "screen", |
| 34 | pillarRotation = 0, |
| 35 | opacity = 1, |
| 36 | }) => { |
| 37 | const containerRef = useRef<HTMLDivElement>(null); |
| 38 | const rafRef = useRef<number | null>(null); |
| 39 | const rendererRef = useRef<THREE.WebGLRenderer | null>(null); |
| 40 | const materialRef = useRef<THREE.ShaderMaterial | null>(null); |
| 41 | const sceneRef = useRef<THREE.Scene | null>(null); |
| 42 | const cameraRef = useRef<THREE.OrthographicCamera | null>(null); |
| 43 | const geometryRef = useRef<THREE.PlaneGeometry | null>(null); |
| 44 | const mouseRef = useRef<THREE.Vector2>(new THREE.Vector2(0, 0)); |
| 45 | const timeRef = useRef<number>(0); |
| 46 | const [webGLSupported, setWebGLSupported] = useState<boolean>(true); |
| 47 | |
| 48 | useEffect(() => { |
| 49 | if (!containerRef.current || !webGLSupported) return; |
| 50 | |
| 51 | const container = containerRef.current; |
| 52 | const width = container.clientWidth; |
| 53 | const height = container.clientHeight; |
| 54 | |
| 55 | // Scene setup |
| 56 | const scene = new THREE.Scene(); |
| 57 | sceneRef.current = scene; |
| 58 | const camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1); |
| 59 | cameraRef.current = camera; |
| 60 | |
| 61 | let renderer: THREE.WebGLRenderer; |
| 62 | try { |
| 63 | renderer = new THREE.WebGLRenderer({ |
| 64 | antialias: false, |
| 65 | alpha: true, |
| 66 | preserveDrawingBuffer: true, |
| 67 | powerPreference: "high-performance", |
| 68 | precision: "lowp", |
| 69 | stencil: false, |
| 70 | depth: false, |
| 71 | }); |
| 72 | } catch (error) { |
| 73 | console.error("Failed to create WebGL renderer:", error); |
| 74 | setTimeout(() => setWebGLSupported(false), 0); |
| 75 | return; |
| 76 | } |
| 77 | |
| 78 | renderer.setSize(width, height); |
| 79 | renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2)); |
nothing calls this directly
no test coverage detected