diff --git a/.changeset/red-months-attend.md b/.changeset/red-months-attend.md new file mode 100644 index 000000000..400564e46 --- /dev/null +++ b/.changeset/red-months-attend.md @@ -0,0 +1,5 @@ +--- +"render-composer": patch +--- + +**New:** `` now offers three new props, `clearColor`, `clearDepth` and `clearStencil`, that allow the user to configure which information the built-in clear pass should actually clear when enabled. diff --git a/packages/render-composer/src/passes/RenderPass.tsx b/packages/render-composer/src/passes/RenderPass.tsx index 7ba2cc28b..4e323ff00 100644 --- a/packages/render-composer/src/passes/RenderPass.tsx +++ b/packages/render-composer/src/passes/RenderPass.tsx @@ -15,10 +15,24 @@ export type RenderPassProps = { scene?: THREE.Scene ignoreBackground?: boolean clear?: boolean + clearColor?: boolean + clearDepth?: boolean + clearStencil?: boolean } export const RenderPass = forwardRef( - ({ camera, scene, ignoreBackground = false, clear = false }, ref) => { + ( + { + camera, + scene, + ignoreBackground = false, + clear = false, + clearColor = true, + clearDepth = true, + clearStencil = true + }, + ref + ) => { const r3fCamera = useThree((state) => state.camera) const r3fScene = useThree((state) => state.scene) @@ -30,6 +44,7 @@ export const RenderPass = forwardRef( useLayoutEffect(() => { pass.ignoreBackground = ignoreBackground pass.clearPass.enabled = clear + pass.clearPass.setClearFlags(clearColor, clearDepth, clearStencil) }) useImperativeHandle(ref, () => pass)