import React, { useRef, useEffect } from 'react'; import { CNNx2UL, GANUUL, render } from 'anime4k-webgpu'; export const ReactRenderer: React.FC = () => { const canvasRef = useRef(null); const videoRef = useRef(null); useEffect(() => { const video = videoRef.current!; const canvas = canvasRef.current!; video.muted = true; video.src = '/OnePunchMan.mp4'; async function init() { await render({ video, canvas, // function to build custom pipeline // return all pipelines in render pass order pipelineBuilder: (device, inputTexture) => { const upscale = new CNNx2UL({ device, inputTexture, }); const restore = new GANUUL({ device, inputTexture: upscale.getOutputTexture(), }); return [upscale, restore]; }, }); // play video await video.play(); } init(); }, []) return (
); };