WebashalarForML commited on
Commit
7492112
·
verified ·
1 Parent(s): 6529253

Upload components/Background.js with huggingface_hub

Browse files
Files changed (1) hide show
  1. components/Background.js +62 -0
components/Background.js ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use client';
2
+
3
+ import { Canvas, useFrame } from '@react-three/fiber';
4
+ import { Points, PointMaterial, Float } from '@react-three/drei';
5
+ import { useState, useRef } from 'react';
6
+ import * as random from 'maath/random/dist/maath-random.esm';
7
+
8
+ function Stars(props) {
9
+ const ref = useRef();
10
+ const [sphere] = useState(() => random.inSphere(new Float32Array(5000), { radius: 1.5 }));
11
+
12
+ useFrame((state, delta) => {
13
+ if (ref.current) {
14
+ ref.current.rotation.x -= delta / 10;
15
+ ref.current.rotation.y -= delta / 15;
16
+ }
17
+ });
18
+
19
+ return (
20
+ <group rotation={[0, 0, Math.PI / 4]}>
21
+ <Points ref={ref} positions={sphere} stride={3} frustumCulled={false} {...props}>
22
+ <PointMaterial
23
+ transparent
24
+ color="#ffffff"
25
+ size={0.002}
26
+ sizeAttenuation={true}
27
+ depthWrite={false}
28
+ />
29
+ </Points>
30
+ </group>
31
+ );
32
+ }
33
+
34
+ function DataTunnel() {
35
+ const meshRef = useRef();
36
+
37
+ useFrame((state) => {
38
+ if(meshRef.current) {
39
+ meshRef.current.rotation.z = state.clock.elapsedTime * 0.1;
40
+ }
41
+ });
42
+
43
+ return (
44
+ <Float speed={2} rotationIntensity={0.5} floatIntensity={0.5}>
45
+ <mesh ref={meshRef}>
46
+ <torusGeometry args={[10, 0.02, 16, 100]} />
47
+ <meshBasicMaterial color="#333" wireframe transparent opacity={0.3} />
48
+ </mesh>
49
+ </Float>
50
+ )
51
+ }
52
+
53
+ export default function Background() {
54
+ return (
55
+ <div className="fixed inset-0 z-0">
56
+ <Canvas camera={{ position: [0, 0, 1] }}>
57
+ <Stars />
58
+ <DataTunnel />
59
+ </Canvas>
60
+ </div>
61
+ );
62
+ }