MCPcopy Create free account
hub / github.com/DavidHDev/react-bits / TextureLab

Function TextureLab

src/tools/texture-lab/TextureLab.jsx:21–891  ·  view source on GitHub ↗
({ toolSelector })

Source from the content-addressed store, hash-verified

19import { toaster } from '../../components/setup/toaster';
20
21export 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;

Callers

nothing calls this directly

Calls 15

createRendererFunction · 0.90
loadImageFromFileFunction · 0.90
loadImageFromURLFunction · 0.90
loadVideoFromFileFunction · 0.90
loadVideoFromURLFunction · 0.90
copyCanvasToClipboardFunction · 0.90
copyDataURLToClipboardFunction · 0.90
exportCanvasFunction · 0.90
loadOverlayTexturesFunction · 0.85
updateVideoFrameMethod · 0.80
handleImageLoadFunction · 0.50

Tested by

no test coverage detected