"use client"; import { useRef, useMemo } from "react"; import { Canvas, useFrame } from "@react-three/fiber"; import { Float, MeshDistortMaterial, Environment } from "@react-three/drei"; import * as THREE from "three"; function FloatingWrench({ position, scale, speed, color, }: { position: [number, number, number]; scale: number; speed: number; color: string; }) { const meshRef = useRef(null); useFrame((state) => { if (meshRef.current) { meshRef.current.rotation.x = Math.sin(state.clock.elapsedTime * speed) * 0.3; meshRef.current.rotation.y = state.clock.elapsedTime * speed * 0.5; meshRef.current.rotation.z = Math.cos(state.clock.elapsedTime * speed) * 0.2; } }); return ( {/* Wrench body */} {/* Wrench head */} {/* Wrench ring */} ); } function FloatingGear({ position, scale, speed, color, }: { position: [number, number, number]; scale: number; speed: number; color: string; }) { const meshRef = useRef(null); useFrame((state) => { if (meshRef.current) { meshRef.current.rotation.x = state.clock.elapsedTime * speed * 0.3; meshRef.current.rotation.z = state.clock.elapsedTime * speed * 0.5; } }); return ( ); } function FloatingCube({ position, scale, speed, color, }: { position: [number, number, number]; scale: number; speed: number; color: string; }) { const meshRef = useRef(null); useFrame((state) => { if (meshRef.current) { meshRef.current.rotation.x = state.clock.elapsedTime * speed * 0.4; meshRef.current.rotation.y = state.clock.elapsedTime * speed * 0.6; } }); return ( ); } function FloatingSphere({ position, scale, speed, color, }: { position: [number, number, number]; scale: number; speed: number; color: string; }) { const meshRef = useRef(null); useFrame((state) => { if (meshRef.current) { meshRef.current.rotation.y = state.clock.elapsedTime * speed * 0.3; } }); return ( ); } function Scene() { const objects = useMemo( () => [ { type: "wrench", position: [-3, 1, -2] as [number, number, number], scale: 1.2, speed: 0.3, color: "#00F5FF", }, { type: "gear", position: [2, -1, -3] as [number, number, number], scale: 0.8, speed: 0.4, color: "#9945FF", }, { type: "cube", position: [-1, 2, -4] as [number, number, number], scale: 1, speed: 0.5, color: "#14F195", }, { type: "wrench", position: [3, 0, -2] as [number, number, number], scale: 0.9, speed: 0.35, color: "#B87333", }, { type: "sphere", position: [0, -2, -3] as [number, number, number], scale: 1.1, speed: 0.25, color: "#4A5568", }, { type: "gear", position: [-2, -1, -4] as [number, number, number], scale: 0.6, speed: 0.45, color: "#00F5FF", }, { type: "cube", position: [1, 1, -5] as [number, number, number], scale: 0.7, speed: 0.55, color: "#9945FF", }, { type: "sphere", position: [-3, -2, -3] as [number, number, number], scale: 0.5, speed: 0.3, color: "#14F195", }, { type: "wrench", position: [2, 2, -4] as [number, number, number], scale: 0.7, speed: 0.4, color: "#B87333", }, { type: "gear", position: [0, 0, -6] as [number, number, number], scale: 1.5, speed: 0.2, color: "#00F5FF", }, ], [] ); return ( <> {objects.map((obj, index) => { switch (obj.type) { case "wrench": return ( ); case "gear": return ( ); case "cube": return ( ); case "sphere": return ( ); default: return null; } })} {/* Particles */} ); } function Particles() { const pointsRef = useRef(null); const count = 200; const positions = useMemo(() => { const pos = new Float32Array(count * 3); for (let i = 0; i < count; i++) { pos[i * 3] = (Math.random() - 0.5) * 20; pos[i * 3 + 1] = (Math.random() - 0.5) * 20; pos[i * 3 + 2] = (Math.random() - 0.5) * 20; } return pos; }, []); useFrame((state) => { if (pointsRef.current) { pointsRef.current.rotation.y = state.clock.elapsedTime * 0.02; pointsRef.current.rotation.x = state.clock.elapsedTime * 0.01; } }); return ( ); } export function FloatingTools() { return ( ); }