UNPKG

glodrei

Version:

useful add-ons for react-three-fiber

48 lines (43 loc) 1.51 kB
--- title: RenderTexture sourcecode: src/core/RenderTexture.tsx --- <Grid cols={4}> <li> <Codesandbox id="0z8i2c" /> </li> </Grid> This component allows you to render a live scene into a texture which you can then apply to a material. The contents of it run inside a portal and are separate from the rest of the canvas, therefore you can have events in there, environment maps, etc. ```tsx type Props = JSX.IntrinsicElements['texture'] & { /** Optional width of the texture, defaults to viewport bounds */ width?: number /** Optional height of the texture, defaults to viewport bounds */ height?: number /** Optional fbo samples */ samples?: number /** Optional stencil buffer, defaults to false */ stencilBuffer?: boolean /** Optional depth buffer, defaults to true */ depthBuffer?: boolean /** Optional generate mipmaps, defaults to false */ generateMipmaps?: boolean /** Optional render priority, defaults to 0 */ renderPriority?: number /** Optional event priority, defaults to 0 */ eventPriority?: number /** Optional frame count, defaults to Infinity. If you set it to 1, it would only render a single frame, etc */ frames?: number /** Optional event compute, defaults to undefined */ compute?: (event: any, state: any, previous: any) => false | undefined /** Children will be rendered into a portal */ children: React.ReactNode } ``` ```jsx <mesh> <planeGeometry /> <meshStandardMaterial> <RenderTexture attach="map"> <mesh /> ```