|  |  |  | 
|---|
|  |  |  | import { Canvas, useFrame } from '@react-three/fiber' | 
|---|
|  |  |  | import { OrbitControls } from '@react-three/drei' | 
|---|
|  |  |  | import { Environment } from '@react-three/drei' | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const Box = (props) => { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const ref = useRef() | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const [hovered, hover] = useState(false) | 
|---|
|  |  |  | const [clicked, click] = useState(false) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | useFrame((state, delta) => (ref.current.rotation.x += delta)) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <mesh | 
|---|
|  |  |  | {...props} | 
|---|
|  |  |  | ref={ref} | 
|---|
|  |  |  | scale={clicked ? 1.5 : 1} | 
|---|
|  |  |  | onClick={(event) => click(!clicked)} | 
|---|
|  |  |  | onPointerOver={(event) => (event.stopPropagation(), hover(true))} | 
|---|
|  |  |  | onPointerOut={(event) => hover(false)}> | 
|---|
|  |  |  | <boxGeometry args={[1, 1, 1]} /> | 
|---|
|  |  |  | <meshStandardMaterial color={hovered ? 'hotpink' : 'orange'} /> | 
|---|
|  |  |  | </mesh> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | import Help from '@/components/help' | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const Base = () => { | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | 
|---|
|  |  |  | <Box position={[0, 0, 0]} /> | 
|---|
|  |  |  | <OrbitControls /> | 
|---|
|  |  |  | <Environment background preset="warehouse" /> | 
|---|
|  |  |  | <Help /> | 
|---|
|  |  |  | </Canvas> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const Box = (props) => { | 
|---|
|  |  |  | const ref = useRef() | 
|---|
|  |  |  | const [hovered, hover] = useState(false) | 
|---|
|  |  |  | const [clicked, click] = useState(false) | 
|---|
|  |  |  | useFrame((state, delta) => (ref.current.rotation.x += delta)) | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <mesh | 
|---|
|  |  |  | {...props} | 
|---|
|  |  |  | ref={ref} | 
|---|
|  |  |  | scale={clicked ? 1.5 : 1} | 
|---|
|  |  |  | onClick={(event) => click(!clicked)} | 
|---|
|  |  |  | onPointerOver={(event) => (event.stopPropagation(), hover(true))} | 
|---|
|  |  |  | onPointerOut={(event) => hover(false)}> | 
|---|
|  |  |  | <boxGeometry args={[1, 1, 1]} /> | 
|---|
|  |  |  | <meshStandardMaterial color={hovered ? 'hotpink' : 'orange'} /> | 
|---|
|  |  |  | </mesh> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export default Base; | 
|---|