### Install React Three Fiber Source: https://r3f.docs.pmnd.rs/getting-started/introduction Install the necessary packages for React Three Fiber using npm. ```bash npm install three @types/three @react-three/fiber ``` -------------------------------- ### Install TypeScript Types Source: https://r3f.docs.pmnd.rs/getting-started/introduction Install the TypeScript types for Three.js when using TypeScript with React Three Fiber. ```bash npm install @types/three ``` -------------------------------- ### Basic React Three Fiber Scene (TypeScript) Source: https://r3f.docs.pmnd.rs/getting-started/introduction A basic scene demonstrating a re-usable Box component with state, interactivity, and animation using React Three Fiber and TypeScript. Includes setup for ambient, spot, and point lights. ```typescript import * as THREE from 'three' import { createRoot } from 'react-dom/client' import React, { useRef, useState } from 'react' import { Canvas, useFrame, ThreeElements } from '@react-three/fiber' import './styles.css' function Box(props: ThreeElements['mesh']) { const meshRef = useRef(null!) const [hovered, setHover] = useState(false) const [active, setActive] = useState(false) useFrame((state, delta) => (meshRef.current.rotation.x += delta)) return ( setActive(!active)} onPointerOver={(event) => setHover(true)} onPointerOut={(event) => setHover(false)}> ) } createRoot(document.getElementById('root')).render( , ) ``` -------------------------------- ### Basic React Native Three Fiber Scene Source: https://r3f.docs.pmnd.rs/getting-started/introduction A basic scene for React Native demonstrating a re-usable Box component with state, interactivity, and animation using React Three Fiber. Includes setup for ambient, spot, and point lights. ```jsx import React, { useRef, useState } from 'react' import { Canvas, useFrame } from '@react-three/fiber/native' function Box(props) { const meshRef = useRef(null) const [hovered, setHover] = useState(false) const [active, setActive] = useState(false) useFrame((state, delta) => (meshRef.current.rotation.x += delta)) return ( setActive(!active)} onPointerOver={(event) => setHover(true)} onPointerOut={(event) => setHover(false)}> ) } export default function App() { return ( ) } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.