({ toolSelector })
| 19 | import { toaster } from '../../components/setup/toaster'; |
| 20 | |
| 21 | export default function TextureLab({ toolSelector }) { |
| 22 | const isMobile = useBreakpointValue({ base: true, lg: false }); |
| 23 | const [mobileControlsOpen, setMobileControlsOpen] = useState(false); |
| 24 | |
| 25 | const canvasRef = useRef(null); |
| 26 | const rendererRef = useRef(null); |
| 27 | const renderTimeoutRef = useRef(null); |
| 28 | const videoRef = useRef(null); |
| 29 | const videoAnimationRef = useRef(null); |
| 30 | |
| 31 | const [state, setState] = useState(createInitialState); |
| 32 | const { |
| 33 | image, |
| 34 | video, |
| 35 | mediaType, |
| 36 | corsError, |
| 37 | effects, |
| 38 | seed, |
| 39 | previewQuality, |
| 40 | exportFormat, |
| 41 | exportQuality, |
| 42 | exportScale, |
| 43 | viewMode, |
| 44 | isPlaying, |
| 45 | currentTime, |
| 46 | duration, |
| 47 | isExporting, |
| 48 | exportProgress, |
| 49 | exportStatus |
| 50 | } = state; |
| 51 | |
| 52 | useEffect(() => { |
| 53 | if (canvasRef.current && !rendererRef.current) { |
| 54 | try { |
| 55 | rendererRef.current = createRenderer(canvasRef.current); |
| 56 | } catch (err) { |
| 57 | console.error('Failed to create renderer:', err); |
| 58 | toaster.create({ |
| 59 | title: 'Renderer Error', |
| 60 | description: 'Failed to initialize graphics renderer.', |
| 61 | type: 'error', |
| 62 | duration: 5000 |
| 63 | }); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | return () => { |
| 68 | if (rendererRef.current) { |
| 69 | rendererRef.current.destroy(); |
| 70 | rendererRef.current = null; |
| 71 | } |
| 72 | if (videoRef.current) { |
| 73 | videoRef.current.pause(); |
| 74 | if (videoRef.current.src && videoRef.current.src.startsWith('blob:')) { |
| 75 | URL.revokeObjectURL(videoRef.current.src); |
| 76 | } |
| 77 | videoRef.current.src = ''; |
| 78 | videoRef.current = null; |
nothing calls this directly
no test coverage detected