Skip to content

Commit a0541ee

Browse files
fix(EffectComposer): harden convolution check (#244)
1 parent af2d287 commit a0541ee

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/EffectComposer.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ export type EffectComposerProps = {
4747
scene?: THREE.Scene
4848
}
4949

50+
const isConvolution = (effect: Effect): boolean =>
51+
(effect.getAttributes() & EffectAttribute.CONVOLUTION) === EffectAttribute.CONVOLUTION
52+
5053
export const EffectComposer = React.memo(
5154
forwardRef(
5255
(
@@ -136,15 +139,10 @@ export const EffectComposer = React.memo(
136139
const child = children[i]
137140

138141
if (child instanceof Effect) {
139-
const effects: Effect[] = []
140-
while (
141-
// Filter to effects
142-
children[i] instanceof Effect &&
143-
// Don't merge convolution effects
144-
((children[i] as Effect).getAttributes() & EffectAttribute.CONVOLUTION) !== 0
145-
)
142+
const effects: Effect[] = [child]
143+
while (children[i] instanceof Effect && !isConvolution(children[i] as Effect)) {
146144
effects.push(children[i++] as Effect)
147-
i--
145+
}
148146

149147
const pass = new EffectPass(camera, ...effects)
150148
passes.push(pass)

0 commit comments

Comments
 (0)