Skip to content

Commit 723cc02

Browse files
fix(types): make args optional in EffectProps
1 parent d422ccc commit 723cc02

File tree

7 files changed

+7
-12
lines changed

7 files changed

+7
-12
lines changed

src/effects/Bloom.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ import { wrapEffect } from '../util'
33

44
export const Bloom = /* @__PURE__ */ wrapEffect(BloomEffect, {
55
blendFunction: BlendFunction.ADD,
6-
args: [],
76
})

src/effects/Noise.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { NoiseEffect, BlendFunction } from 'postprocessing'
22
import { wrapEffect } from '../util'
33

4-
export const Noise = /* @__PURE__ */ wrapEffect(NoiseEffect, { blendFunction: BlendFunction.COLOR_DODGE, args: [] })
4+
export const Noise = /* @__PURE__ */ wrapEffect(NoiseEffect, { blendFunction: BlendFunction.COLOR_DODGE })

src/effects/ScanlineEffect.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ import { wrapEffect } from '../util'
44
export const Scanline = /* @__PURE__ */ wrapEffect(ScanlineEffect, {
55
blendFunction: BlendFunction.OVERLAY,
66
density: 1.25,
7-
args: [],
87
})

src/effects/TiltShift.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { TiltShiftEffect, BlendFunction } from 'postprocessing'
22
import { wrapEffect } from '../util'
33

4-
export const TiltShift = /* @__PURE__ */ wrapEffect(TiltShiftEffect, { blendFunction: BlendFunction.ADD, args: [] })
4+
export const TiltShift = /* @__PURE__ */ wrapEffect(TiltShiftEffect, { blendFunction: BlendFunction.ADD })

src/effects/TiltShift2.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,4 @@ export class TiltShiftEffect extends Effect {
8787
}
8888
}
8989

90-
export const TiltShift2 = /* @__PURE__ */ wrapEffect(TiltShiftEffect, { blendFunction: BlendFunction.NORMAL, args: [] })
90+
export const TiltShift2 = /* @__PURE__ */ wrapEffect(TiltShiftEffect, { blendFunction: BlendFunction.NORMAL })

src/effects/Water.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ export class WaterEffectImpl extends Effect {
3232

3333
export const WaterEffect = /* @__PURE__ */ wrapEffect(WaterEffectImpl, {
3434
blendFunction: BlendFunction.NORMAL,
35-
args: [],
3635
})

src/util.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@ import React, { RefObject } from 'react'
22
import { Vector2 } from 'three'
33
import * as THREE from 'three'
44
import { type ReactThreeFiber, type ThreeElement, extend, useThree } from '@react-three/fiber'
5-
import type { Effect, BlendFunction } from 'postprocessing'
5+
import type { Effect, Pass, BlendFunction } from 'postprocessing'
66

77
export const resolveRef = <T,>(ref: T | React.RefObject<T>) =>
88
typeof ref === 'object' && ref != null && 'current' in ref ? ref.current : ref
99

10-
export type EffectConstructor = new (...args: any[]) => Effect
10+
export type EffectConstructor = new (...args: any[]) => Effect | Pass
1111

12-
export type EffectProps<T extends EffectConstructor> = ThreeElement<
13-
T extends Function ? T['prototype'] : InstanceType<T>
14-
> &
12+
export type EffectProps<T extends EffectConstructor> = ThreeElement<T> &
1513
ConstructorParameters<T>[0] & {
1614
blendFunction?: BlendFunction
1715
opacity?: number
@@ -31,7 +29,7 @@ export const wrapEffect = <T extends EffectConstructor>(effect: T, defaults?: Ef
3129

3230
const camera = useThree((state) => state.camera)
3331
const args = React.useMemo(
34-
() => [...((defaults?.args ?? []) as any[]), ...((props.args ?? [{ ...defaults, ...props }]) as any[])],
32+
() => [...(defaults?.args ?? []), ...(props.args ?? [{ ...defaults, ...props }])],
3533
// eslint-disable-next-line react-hooks/exhaustive-deps
3634
[JSON.stringify(props)]
3735
)

0 commit comments

Comments
 (0)