Skip to content

Commit bfd1588

Browse files
committed
Fix particles prop in Emitter
1 parent d68c614 commit bfd1588

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

.changeset/strong-bikes-bathe.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"vfx-composer": patch
3+
---
4+
5+
**Fixed:** `<Emitter>` could no longer work with `<Particles>` refs passed into its `particles` prop. Woops!

packages/vfx-composer/src/fiber/Emitter.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const Emitter = forwardRef<Object3D, EmitterProps>(
3535
ref
3636
) => {
3737
const object = useRef<Object3D>(null!)
38-
const particles = particlesProp?.current || useParticlesContext()
38+
const particlesFromContext = useParticlesContext()
3939

4040
const emitterSetup = useCallback<InstanceSetupCallback>(
4141
(props) => {
@@ -46,17 +46,22 @@ export const Emitter = forwardRef<Object3D, EmitterProps>(
4646

4747
setup?.(props)
4848
},
49-
[particles, setup]
49+
[setup]
5050
)
5151

5252
useEffect(() => {
53+
const particles = particlesProp?.current || particlesFromContext
54+
5355
if (!particles) return
5456
if (continuous) return
57+
5558
particlesMatrix.copy(particles!.matrixWorld).invert()
5659
particles.emit(count, emitterSetup)
57-
}, [particles])
60+
}, [])
5861

5962
useFrame(() => {
63+
const particles = particlesProp?.current || particlesFromContext
64+
6065
if (!particles) return
6166
if (!continuous) return
6267
particlesMatrix.copy(particles!.matrixWorld).invert()

0 commit comments

Comments
 (0)