import { Card, Title, Box, useMantineTheme } from '@mantine/core'; import { Canvas, extend, useFrame, useThree } from '@react-three/fiber'; import { useRef, useMemo } from 'react'; import * as THREE from 'three'; // 🎨 Utilidad para convertir hex a RGB [0–1] function hexToRGBArray(hex: string): [number, number, number] { const bigint = parseInt(hex.replace('#', ''), 16); return [ ((bigint >> 16) & 255) / 255, ((bigint >> 8) & 255) / 255, (bigint & 255) / 255, ]; } // ✨ Shader personalizado estilo holográfico, con color dinámico class HoloShaderMaterial extends THREE.ShaderMaterial { constructor(color: [number, number, number]) { super({ uniforms: { u_time: { value: 0 }, u_resolution: { value: new THREE.Vector2() }, u_color: { value: new THREE.Vector3(...color) }, }, vertexShader: ` void main() { gl_Position = vec4(position, 1.0); } `, fragmentShader: ` precision mediump float; uniform float u_time; uniform vec2 u_resolution; uniform vec3 u_color; void main() { vec2 uv = gl_FragCoord.xy / u_resolution; vec2 pos = uv * 10.0; pos.x += u_time * 0.3; pos.y += sin(u_time * 0.2) * 2.0; float color = sin(pos.x + sin(pos.y + sin(pos.x))) * 0.5 + 0.5; vec3 c = vec3( u_color.r + 0.2 * sin(u_time + pos.x), u_color.g + 0.2 * cos(u_time + pos.y), u_color.b + 0.2 * sin(pos.x + pos.y + u_time) ); gl_FragColor = vec4(c * color, 1.0); } `, }); } } extend({ HoloShaderMaterial }); // 🎥 Plano con el shader function HoloPlane({ color }: { color: [number, number, number] }) { const mat = useRef(null); const { size } = useThree(); useFrame(({ clock }) => { if (mat.current) { mat.current.uniforms.u_time.value = clock.getElapsedTime(); mat.current.uniforms.u_resolution.value.set(size.width, size.height); } }); const material = useMemo(() => new HoloShaderMaterial(color), [color]); return ( ); } // 🎨 Fondo que ocupa todo el contenedor function HolographicBackground({ color }: { color: [number, number, number] }) { return ( ); } // 🧩 Componente final con fondo shader y texto 404 export function MantineCardWithShader() { const theme = useMantineTheme(); const hex = theme.colors[theme.primaryColor][6]; const rgb = hexToRGBArray(hex); return ( 404 ); }