import React, { Suspense, useMemo, useRef } from 'react'; import { Canvas, useFrame, useLoader } from '@react-three/fiber'; import { Clock, Euler, Vector3 } from 'three'; import { TextureLoader } from 'three/src/loaders/TextureLoader'; import styled from 'styled-components'; const smoke = require('./smoke.png'); const Wrapper = styled.div` position: absolute; left: 0; right: 0; top: 0; bottom: 0; `; const FrameLimiter = () => { const [clock] = React.useState(new Clock()); const [fps] = React.useState(10); useFrame((state: any) => { state.ready = false; const timeUntilNextFrame = 1000 / fps - clock.getDelta(); setTimeout(() => { state.ready = true; state.invalidate(); }, Math.max(0, timeUntilNextFrame)); }); return <>; }; const Cloud = ({ texture }) => { const ref = useRef(); const width = window.innerWidth / 2; const height = window.innerHeight / 2; useFrame(() => { if (!ref.current) { return; } ref.current.rotation.z -= 0.003; }); return ( ); }; const Clouds = () => { const colorMap = useLoader(TextureLoader, smoke); const items = useMemo(() => new Array(30).fill(undefined), []); return ( <> {items.map((_, i) => ( ))} ); }; const Scene = () => { return ( { gl.setClearColor('red'); }} gl={{ antialias: false, }} camera={{ fov: 60, aspect: 1, near: 1, far: 1000, position: [0, 0, 1], rotation: [1.16, -0.12, 0.27], }} > ); }; const Background = () => { return ( {typeof window !== 'undefined' && } ); }; export { Background };