import { useRef, useEffect } from 'react'
import { Scene, GLTFLoaderAsync, SweepLight } from 'react-three-lite'
import type * as THREE from 'three'
export default function App() {
const sweepLightRef = useRef<SweepLight | null>(null)
const handleCreated = async (scene: THREE.Scene) => {
const model = await GLTFLoaderAsync('/models/perseverance-draco.glb', true)
model.scale.set(0.8, 0.8, 0.8)
scene.add(model)
sweepLightRef.current = new SweepLight(model)
}
useEffect(() => {
return () => {
sweepLightRef.current?.dispose()
sweepLightRef.current = null
}
}, [])
return (
<Scene
bgColor="#0a0a0a"
onCreated={handleCreated}
style={{ marginTop: '10px', width: '100%', height: '300px' }}
/>
)
}