@threlte/extras
Version:
Utilities, abstractions and plugins for your Threlte apps
53 lines (52 loc) • 1.66 kB
TypeScript
import type { RenderTargetOptions } from 'three';
import { DepthTexture, WebGLRenderTarget } from 'three';
export type UseFBOOptions = RenderTargetOptions & {
/**
* if set, the scene depth will be rendered into buffer.depthTexture
*/
depth?: {
width?: number;
height?: number;
} | DepthTexture | boolean;
/**
* if set, the render target size will be set to the corresponding width and height and not use or follow the size of the canvas
*/
size?: {
width?: number;
height?: number;
};
};
/**
* Creates a `WebGLRenderTarget` whose `size` and `depth` configuration is
* tracked through runes — pass `options` as a getter and the FBO updates when
* those values change.
*
* Other render-target construction options (`format`, `type`, `samples`, …)
* are read once at hook initialization; later changes to those properties on
* the options object are ignored.
*
* ```svelte
* <script lang="ts">
* import { useFBO } from '@threlte/extras'
*
* let resolution = $state(512)
* const target = useFBO(() => ({
* size: { width: resolution, height: resolution }
* }))
* </script>
* ```
*/
export declare function useFBO(options?: () => UseFBOOptions | undefined): WebGLRenderTarget;
/**
* @deprecated Pass `options` as a getter function instead. This signature will
* be removed in Threlte 9.
*
* ```ts
* // Before
* const target = useFBO({ size: { width: 512, height: 512 } })
*
* // After
* const target = useFBO(() => ({ size: { width: 512, height: 512 } }))
* ```
*/
export declare function useFBO(options?: UseFBOOptions): WebGLRenderTarget;