Skip to content

Commit

Permalink
fix(SelectiveBloom): apply ignoreBackground and inverted props (#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
breathingcyborg authored Jan 18, 2025
1 parent 1c4f72f commit 9eb6982
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/effects/SelectiveBloom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export type SelectiveBloomProps = BloomEffectOptions &
lights: Object3D[] | ObjectRef[]
selection: Object3D | Object3D[] | ObjectRef | ObjectRef[]
selectionLayer: number
inverted: boolean
ignoreBackground: boolean
}>

const addLight = (light: Object3D, effect: SelectiveBloomEffect) => light.layers.enable(effect.selection.layer)
Expand All @@ -24,6 +26,8 @@ export const SelectiveBloom = forwardRef(function SelectiveBloom(
selection = [],
selectionLayer = 10,
lights = [],
inverted = false,
ignoreBackground = false,
luminanceThreshold,
luminanceSmoothing,
intensity,
Expand All @@ -43,8 +47,8 @@ export const SelectiveBloom = forwardRef(function SelectiveBloom(
const invalidate = useThree((state) => state.invalidate)
const { scene, camera } = useContext(EffectComposerContext)
const effect = useMemo(
() =>
new SelectiveBloomEffect(scene, camera, {
() => {
const effect = new SelectiveBloomEffect(scene, camera, {
blendFunction: BlendFunction.ADD,
luminanceThreshold,
luminanceSmoothing,
Expand All @@ -54,8 +58,12 @@ export const SelectiveBloom = forwardRef(function SelectiveBloom(
kernelSize,
mipmapBlur,
...props,
}),
[scene, camera, luminanceThreshold, luminanceSmoothing, intensity, width, height, kernelSize, mipmapBlur, props]
});
effect.inverted = inverted;
effect.ignoreBackground = ignoreBackground;
return effect;
},
[scene, camera, luminanceThreshold, luminanceSmoothing, intensity, width, height, kernelSize, mipmapBlur, inverted, ignoreBackground, props]
)

const api = useContext(selectionContext)
Expand Down

0 comments on commit 9eb6982

Please sign in to comment.