M-Zeki's picture
Upload components/Hero3D.js with huggingface_hub
1326b37 verified
Raw
History Blame Contribute Delete
1.58 kB
import { Canvas, useFrame } from '@react-three/fiber';
import { Points, PointMaterial } from '@react-three/drei';
import { useRef, useMemo } from 'react';
import * as THREE from 'three';
function NeuralMesh(props) {
const ref = useRef();
const [sphere] = useState(() => new Float32Array(2000 * 3));
// Generate random points in a spherical distribution
useMemo(() => {
for (let i = 0; i < 2000; i++) {
const r = 1.5 * Math.cbrt(Math.random());
const theta = Math.random() * 2 * Math.PI;
const phi = Math.acos(2 * Math.random() - 1);
const x = r * Math.sin(phi) * Math.cos(theta);
const y = r * Math.sin(phi) * Math.sin(theta);
const z = r * Math.cos(phi);
sphere[i * 3] = x;
sphere[i * 3 + 1] = y;
sphere[i * 3 + 2] = z;
}
}, [sphere]);
useFrame((state, delta) => {
ref.current.rotation.x -= delta / 10;
ref.current.rotation.y -= delta / 15;
});
return (
<group rotation={[0, 0, Math.PI / 4]}>
<Points ref={ref} positions={sphere} stride={3} frustumCulled={false} {...props}>
<PointMaterial
transparent
color="#00E5FF"
size={0.005}
sizeAttenuation={true}
depthWrite={false}
opacity={0.6}
/>
</Points>
</group>
);
}
import { useState } from 'react';
export default function Hero3D() {
return (
<div className="absolute inset-0 z-0 opacity-40 pointer-events-none">
<Canvas camera={{ position: [0, 0, 2] }}>
<NeuralMesh />
</Canvas>
</div>
);
}