Skip to content

Commit

Permalink
[RC] clearColor etc. flags
Browse files Browse the repository at this point in the history
  • Loading branch information
hmans committed Oct 8, 2022
1 parent 3b1d516 commit 1d74dfc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/red-months-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"render-composer": patch
---

**New:** `<RC.RenderPass>` 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.
17 changes: 16 additions & 1 deletion packages/render-composer/src/passes/RenderPass.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,24 @@ export type RenderPassProps = {
scene?: THREE.Scene
ignoreBackground?: boolean
clear?: boolean
clearColor?: boolean
clearDepth?: boolean
clearStencil?: boolean
}

export const RenderPass = forwardRef<PP.RenderPass, RenderPassProps>(
({ 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)

Expand All @@ -30,6 +44,7 @@ export const RenderPass = forwardRef<PP.RenderPass, RenderPassProps>(
useLayoutEffect(() => {
pass.ignoreBackground = ignoreBackground
pass.clearPass.enabled = clear
pass.clearPass.setClearFlags(clearColor, clearDepth, clearStencil)
})

useImperativeHandle(ref, () => pass)
Expand Down

0 comments on commit 1d74dfc

Please sign in to comment.