@react-three/postprocessing 3.0.3 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +81 -81
- package/dist/EffectComposer.d.ts +28 -0
- package/dist/Selection.d.ts +17 -0
- package/dist/effects/ASCII.d.ts +19 -0
- package/dist/effects/Autofocus.d.ts +23 -0
- package/dist/effects/Bloom.d.ts +2 -0
- package/dist/effects/BrightnessContrast.d.ts +2 -0
- package/dist/effects/ChromaticAberration.d.ts +8 -0
- package/dist/effects/ColorAverage.d.ts +7 -0
- package/dist/effects/ColorDepth.d.ts +2 -0
- package/dist/effects/Depth.d.ts +2 -0
- package/dist/effects/DepthOfField.d.ts +14 -0
- package/dist/effects/DotScreen.d.ts +2 -0
- package/dist/effects/FXAA.d.ts +2 -0
- package/dist/effects/Glitch.d.ts +13 -0
- package/dist/effects/GodRays.d.ts +9 -0
- package/dist/effects/Grid.d.ts +11 -0
- package/dist/effects/HueSaturation.d.ts +2 -0
- package/dist/effects/LUT.d.ts +10 -0
- package/dist/effects/LensFlare.d.ts +54 -0
- package/dist/effects/N8AO.d.ts +19 -0
- package/dist/effects/Noise.d.ts +2 -0
- package/dist/effects/Outline.d.ts +11 -0
- package/dist/effects/Pixelation.d.ts +7 -0
- package/dist/effects/Ramp.d.ts +74 -0
- package/dist/effects/SMAA.d.ts +2 -0
- package/dist/effects/SSAO.d.ts +7 -0
- package/dist/effects/ScanlineEffect.d.ts +2 -0
- package/dist/effects/SelectiveBloom.d.ts +15 -0
- package/dist/effects/Sepia.d.ts +2 -0
- package/dist/effects/ShockWave.d.ts +2 -0
- package/dist/effects/Texture.d.ts +10 -0
- package/dist/effects/TiltShift.d.ts +2 -0
- package/dist/effects/TiltShift2.d.ts +18 -0
- package/dist/effects/ToneMapping.d.ts +4 -0
- package/dist/effects/Vignette.d.ts +2 -0
- package/dist/effects/Water.d.ts +8 -0
- package/dist/index.d.ts +38 -1
- package/dist/index.js +855 -551
- package/dist/index.js.map +1 -1
- package/dist/tests/test-utils.d.ts +12 -0
- package/dist/util.d.ts +25 -0
- package/dist/wrapEffect.d.ts +12 -0
- package/package.json +73 -66
- package/src/EffectComposer.tsx +278 -200
- package/src/Selection.tsx +86 -46
- package/src/effects/ASCII.tsx +136 -135
- package/src/effects/Autofocus.tsx +175 -153
- package/src/effects/Bloom.tsx +6 -6
- package/src/effects/BrightnessContrast.tsx +4 -4
- package/src/effects/ChromaticAberration.tsx +30 -5
- package/src/effects/ColorAverage.tsx +17 -15
- package/src/effects/ColorDepth.tsx +4 -4
- package/src/effects/Depth.tsx +4 -4
- package/src/effects/DepthOfField.tsx +87 -89
- package/src/effects/DotScreen.tsx +4 -4
- package/src/effects/FXAA.tsx +4 -4
- package/src/effects/Glitch.tsx +37 -40
- package/src/effects/GodRays.tsx +20 -16
- package/src/effects/Grid.tsx +28 -21
- package/src/effects/HueSaturation.tsx +4 -4
- package/src/effects/LUT.tsx +27 -26
- package/src/effects/LensFlare.tsx +611 -611
- package/src/effects/N8AO.tsx +81 -81
- package/src/effects/Noise.tsx +4 -4
- package/src/effects/Outline.tsx +85 -117
- package/src/effects/Pixelation.tsx +17 -15
- package/src/effects/Ramp.tsx +150 -150
- package/src/effects/SMAA.tsx +4 -4
- package/src/effects/SSAO.tsx +44 -41
- package/src/effects/ScanlineEffect.tsx +7 -7
- package/src/effects/SelectiveBloom.tsx +116 -126
- package/src/effects/Sepia.tsx +4 -4
- package/src/effects/ShockWave.tsx +4 -4
- package/src/effects/Texture.tsx +27 -23
- package/src/effects/TiltShift.tsx +4 -4
- package/src/effects/TiltShift2.tsx +90 -90
- package/src/effects/ToneMapping.tsx +6 -6
- package/src/effects/Vignette.tsx +4 -4
- package/src/effects/Water.tsx +35 -35
- package/src/index.ts +41 -40
- package/src/tests/ChromaticAberration.test.tsx +31 -0
- package/src/tests/EffectComposer.test.tsx +911 -0
- package/src/tests/Outline.test.tsx +89 -0
- package/src/tests/Selection.test.tsx +324 -0
- package/src/tests/SelectiveBloom.test.tsx +118 -0
- package/src/tests/effects.smoke.test.tsx +234 -0
- package/src/tests/test-utils.tsx +96 -0
- package/src/tests/wrapEffect.test.tsx +209 -0
- package/src/util.tsx +96 -55
- package/src/wrapEffect.tsx +122 -0
- package/src/EffectComposer.test.tsx +0 -126
|
@@ -1,5 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type { ReactThreeFiber } from '@react-three/fiber'
|
|
2
|
+
import { ChromaticAberrationEffect } from 'postprocessing'
|
|
3
|
+
import type { Ref } from 'react'
|
|
4
|
+
import { useMemo } from 'react'
|
|
5
|
+
import { useDispose, useVector2 } from '../util'
|
|
6
|
+
|
|
7
|
+
export type ChromaticAberrationProps = Omit<
|
|
8
|
+
Partial<ConstructorParameters<typeof ChromaticAberrationEffect>[0]>,
|
|
9
|
+
'offset'
|
|
10
|
+
> & {
|
|
11
|
+
ref?: Ref<ChromaticAberrationEffect>
|
|
12
|
+
offset?: ReactThreeFiber.Vector2
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function ChromaticAberration({ ref, ...props }: ChromaticAberrationProps) {
|
|
16
|
+
const offset = useVector2(props, 'offset')
|
|
17
|
+
|
|
18
|
+
const effect = useMemo(
|
|
19
|
+
() =>
|
|
20
|
+
new ChromaticAberrationEffect({
|
|
21
|
+
...props,
|
|
22
|
+
offset,
|
|
23
|
+
} as ConstructorParameters<typeof ChromaticAberrationEffect>[0]),
|
|
24
|
+
[offset, props]
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
useDispose(effect)
|
|
28
|
+
|
|
29
|
+
return <primitive object={effect} ref={ref} />
|
|
30
|
+
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { BlendFunction, ColorAverageEffect } from 'postprocessing'
|
|
2
|
+
import type { Ref } from 'react'
|
|
3
|
+
import { useMemo } from 'react'
|
|
4
|
+
import { useDispose } from '../util'
|
|
5
|
+
|
|
6
|
+
export type ColorAverageProps = {
|
|
7
|
+
blendFunction?: BlendFunction
|
|
8
|
+
ref?: Ref<ColorAverageEffect>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function ColorAverage({ blendFunction = BlendFunction.NORMAL, ref }: ColorAverageProps) {
|
|
12
|
+
const effect = useMemo(() => new ColorAverageEffect(blendFunction), [blendFunction])
|
|
13
|
+
|
|
14
|
+
useDispose(effect)
|
|
15
|
+
|
|
16
|
+
return <primitive object={effect} ref={ref} />
|
|
17
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColorDepthEffect } from 'postprocessing'
|
|
2
|
-
import { wrapEffect } from '../
|
|
3
|
-
|
|
4
|
-
export const ColorDepth = /* @__PURE__ */ wrapEffect(ColorDepthEffect)
|
|
1
|
+
import { ColorDepthEffect } from 'postprocessing'
|
|
2
|
+
import { wrapEffect } from '../wrapEffect'
|
|
3
|
+
|
|
4
|
+
export const ColorDepth = /* @__PURE__ */ wrapEffect(ColorDepthEffect)
|
package/src/effects/Depth.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DepthEffect } from 'postprocessing'
|
|
2
|
-
import { wrapEffect } from '../
|
|
3
|
-
|
|
4
|
-
export const Depth = /* @__PURE__ */ wrapEffect(DepthEffect)
|
|
1
|
+
import { DepthEffect } from 'postprocessing'
|
|
2
|
+
import { wrapEffect } from '../wrapEffect'
|
|
3
|
+
|
|
4
|
+
export const Depth = /* @__PURE__ */ wrapEffect(DepthEffect)
|
|
@@ -1,89 +1,87 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
//
|
|
59
|
-
if (
|
|
60
|
-
//
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return <primitive {...props} ref={ref} object={effect} target={target} />
|
|
89
|
-
})
|
|
1
|
+
import type { ReactThreeFiber } from '@react-three/fiber'
|
|
2
|
+
import { DepthOfFieldEffect, MaskFunction } from 'postprocessing'
|
|
3
|
+
import type { Ref } from 'react'
|
|
4
|
+
import { use, useMemo } from 'react'
|
|
5
|
+
import { type DepthPackingStrategies, type Texture, Vector3 } from 'three'
|
|
6
|
+
import { EffectComposerContext } from '../EffectComposer'
|
|
7
|
+
import { useDispose } from '../util'
|
|
8
|
+
|
|
9
|
+
export type DepthOfFieldProps = ConstructorParameters<typeof DepthOfFieldEffect>[1] &
|
|
10
|
+
Partial<{
|
|
11
|
+
ref: Ref<DepthOfFieldEffect>
|
|
12
|
+
target: ReactThreeFiber.Vector3
|
|
13
|
+
depthTexture: {
|
|
14
|
+
texture: Texture
|
|
15
|
+
// TODO: narrow to DepthPackingStrategies
|
|
16
|
+
packing: number
|
|
17
|
+
}
|
|
18
|
+
// TODO: not used
|
|
19
|
+
blur: number
|
|
20
|
+
}>
|
|
21
|
+
|
|
22
|
+
export function DepthOfField({
|
|
23
|
+
ref,
|
|
24
|
+
blendFunction,
|
|
25
|
+
worldFocusDistance,
|
|
26
|
+
worldFocusRange,
|
|
27
|
+
focusDistance,
|
|
28
|
+
focusRange,
|
|
29
|
+
focalLength,
|
|
30
|
+
bokehScale,
|
|
31
|
+
resolutionScale,
|
|
32
|
+
resolutionX,
|
|
33
|
+
resolutionY,
|
|
34
|
+
width,
|
|
35
|
+
height,
|
|
36
|
+
target,
|
|
37
|
+
depthTexture,
|
|
38
|
+
...props
|
|
39
|
+
}: DepthOfFieldProps) {
|
|
40
|
+
const { camera } = use(EffectComposerContext)
|
|
41
|
+
const autoFocus = target != null
|
|
42
|
+
|
|
43
|
+
const effect = useMemo(() => {
|
|
44
|
+
const effect = new DepthOfFieldEffect(camera, {
|
|
45
|
+
blendFunction,
|
|
46
|
+
worldFocusDistance,
|
|
47
|
+
worldFocusRange,
|
|
48
|
+
focusDistance,
|
|
49
|
+
focusRange,
|
|
50
|
+
focalLength,
|
|
51
|
+
bokehScale,
|
|
52
|
+
resolutionScale,
|
|
53
|
+
resolutionX,
|
|
54
|
+
resolutionY,
|
|
55
|
+
width,
|
|
56
|
+
height,
|
|
57
|
+
})
|
|
58
|
+
// Creating a target enables autofocus, R3F will set via props
|
|
59
|
+
if (autoFocus) effect.target = new Vector3()
|
|
60
|
+
// Depth texture for depth picking with optional packing strategy
|
|
61
|
+
if (depthTexture) effect.setDepthTexture(depthTexture.texture, depthTexture.packing as DepthPackingStrategies)
|
|
62
|
+
// Temporary fix that restores DOF 6.21.3 behavior, everything since then lets shapes leak through the blur
|
|
63
|
+
const maskPass = (effect as any).maskPass
|
|
64
|
+
maskPass.maskFunction = MaskFunction.MULTIPLY_RGB_SET_ALPHA
|
|
65
|
+
return effect
|
|
66
|
+
}, [
|
|
67
|
+
camera,
|
|
68
|
+
blendFunction,
|
|
69
|
+
worldFocusDistance,
|
|
70
|
+
worldFocusRange,
|
|
71
|
+
focusDistance,
|
|
72
|
+
focusRange,
|
|
73
|
+
focalLength,
|
|
74
|
+
bokehScale,
|
|
75
|
+
resolutionScale,
|
|
76
|
+
resolutionX,
|
|
77
|
+
resolutionY,
|
|
78
|
+
width,
|
|
79
|
+
height,
|
|
80
|
+
autoFocus,
|
|
81
|
+
depthTexture,
|
|
82
|
+
])
|
|
83
|
+
|
|
84
|
+
useDispose(effect)
|
|
85
|
+
|
|
86
|
+
return <primitive {...props} object={effect} ref={ref} target={target} />
|
|
87
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DotScreenEffect } from 'postprocessing'
|
|
2
|
-
import { wrapEffect } from '../
|
|
3
|
-
|
|
4
|
-
export const DotScreen = /* @__PURE__ */ wrapEffect(DotScreenEffect)
|
|
1
|
+
import { DotScreenEffect } from 'postprocessing'
|
|
2
|
+
import { wrapEffect } from '../wrapEffect'
|
|
3
|
+
|
|
4
|
+
export const DotScreen = /* @__PURE__ */ wrapEffect(DotScreenEffect)
|
package/src/effects/FXAA.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FXAAEffect } from 'postprocessing'
|
|
2
|
-
import { wrapEffect } from '../
|
|
3
|
-
|
|
4
|
-
export const FXAA = /* @__PURE__ */ wrapEffect(FXAAEffect)
|
|
1
|
+
import { FXAAEffect } from 'postprocessing'
|
|
2
|
+
import { wrapEffect } from '../wrapEffect'
|
|
3
|
+
|
|
4
|
+
export const FXAA = /* @__PURE__ */ wrapEffect(FXAAEffect)
|
package/src/effects/Glitch.tsx
CHANGED
|
@@ -1,40 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { GlitchEffect, GlitchMode } from 'postprocessing'
|
|
3
|
-
import { Ref,
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}>
|
|
16
|
-
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
)
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}, [effect])
|
|
39
|
-
return <primitive ref={ref} object={effect} dispose={null} />
|
|
40
|
-
})
|
|
1
|
+
import { ReactThreeFiber, useThree } from '@react-three/fiber'
|
|
2
|
+
import { GlitchEffect, GlitchMode } from 'postprocessing'
|
|
3
|
+
import { Ref, useLayoutEffect, useMemo } from 'react'
|
|
4
|
+
import { useDispose, useVector2 } from '../util'
|
|
5
|
+
|
|
6
|
+
export type GlitchProps = ConstructorParameters<typeof GlitchEffect>[0] &
|
|
7
|
+
Partial<{
|
|
8
|
+
mode: GlitchMode
|
|
9
|
+
active: boolean
|
|
10
|
+
delay: ReactThreeFiber.Vector2
|
|
11
|
+
duration: ReactThreeFiber.Vector2
|
|
12
|
+
chromaticAberrationOffset: ReactThreeFiber.Vector2
|
|
13
|
+
strength: ReactThreeFiber.Vector2
|
|
14
|
+
ref?: Ref<GlitchEffect>
|
|
15
|
+
}>
|
|
16
|
+
|
|
17
|
+
export function Glitch({ active = true, ref, ...props }: GlitchProps) {
|
|
18
|
+
const invalidate = useThree((state) => state.invalidate)
|
|
19
|
+
const delay = useVector2(props, 'delay')
|
|
20
|
+
const duration = useVector2(props, 'duration')
|
|
21
|
+
const strength = useVector2(props, 'strength')
|
|
22
|
+
const chromaticAberrationOffset = useVector2(props, 'chromaticAberrationOffset')
|
|
23
|
+
|
|
24
|
+
const effect = useMemo(
|
|
25
|
+
() => new GlitchEffect({ ...props, delay, duration, strength, chromaticAberrationOffset }),
|
|
26
|
+
[delay, duration, props, strength, chromaticAberrationOffset]
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
useLayoutEffect(() => {
|
|
30
|
+
effect.mode = active ? props.mode || GlitchMode.SPORADIC : GlitchMode.DISABLED
|
|
31
|
+
invalidate()
|
|
32
|
+
}, [active, effect, invalidate, props.mode])
|
|
33
|
+
|
|
34
|
+
useDispose(effect)
|
|
35
|
+
|
|
36
|
+
return <primitive ref={ref} object={effect} />
|
|
37
|
+
}
|
package/src/effects/GodRays.tsx
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import { GodRaysEffect } from 'postprocessing'
|
|
2
|
-
import
|
|
3
|
-
import { Mesh, Points } from 'three'
|
|
4
|
-
import { EffectComposerContext } from '../EffectComposer'
|
|
5
|
-
import { resolveRef } from '../util'
|
|
6
|
-
|
|
7
|
-
type GodRaysProps = ConstructorParameters<typeof GodRaysEffect>[2] & {
|
|
8
|
-
sun: Mesh | Points |
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { GodRaysEffect } from 'postprocessing'
|
|
2
|
+
import { Ref, RefObject, useContext, useLayoutEffect, useMemo } from 'react'
|
|
3
|
+
import { Mesh, Points } from 'three'
|
|
4
|
+
import { EffectComposerContext } from '../EffectComposer'
|
|
5
|
+
import { resolveRef, useDispose } from '../util'
|
|
6
|
+
|
|
7
|
+
type GodRaysProps = ConstructorParameters<typeof GodRaysEffect>[2] & {
|
|
8
|
+
sun: Mesh | Points | RefObject<Mesh | Points>
|
|
9
|
+
ref?: Ref<GodRaysEffect>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function GodRays({ ref, ...props }: GodRaysProps) {
|
|
13
|
+
const { camera } = useContext(EffectComposerContext)
|
|
14
|
+
const effect = useMemo(() => new GodRaysEffect(camera, resolveRef(props.sun), props), [camera, props])
|
|
15
|
+
useLayoutEffect(() => void (effect.lightSource = resolveRef(props.sun)), [effect, props.sun])
|
|
16
|
+
|
|
17
|
+
useDispose(effect)
|
|
18
|
+
|
|
19
|
+
return <primitive ref={ref} object={effect} />
|
|
20
|
+
}
|
package/src/effects/Grid.tsx
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { GridEffect } from 'postprocessing'
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import { useThree } from '@react-three/fiber'
|
|
2
|
+
import { GridEffect } from 'postprocessing'
|
|
3
|
+
import { Ref, useLayoutEffect, useMemo } from 'react'
|
|
4
|
+
import { useDispose } from '../util'
|
|
5
|
+
|
|
6
|
+
type GridProps = ConstructorParameters<typeof GridEffect>[0] &
|
|
7
|
+
Partial<{
|
|
8
|
+
size: {
|
|
9
|
+
width: number
|
|
10
|
+
height: number
|
|
11
|
+
}
|
|
12
|
+
ref: Ref<GridEffect>
|
|
13
|
+
}>
|
|
14
|
+
|
|
15
|
+
export function Grid({ size, ref, ...props }: GridProps) {
|
|
16
|
+
const invalidate = useThree((state) => state.invalidate)
|
|
17
|
+
|
|
18
|
+
const effect = useMemo(() => new GridEffect(props), [props])
|
|
19
|
+
|
|
20
|
+
useLayoutEffect(() => {
|
|
21
|
+
if (size) effect.setSize(size.width, size.height)
|
|
22
|
+
invalidate()
|
|
23
|
+
}, [effect, size, invalidate])
|
|
24
|
+
|
|
25
|
+
useDispose(effect)
|
|
26
|
+
|
|
27
|
+
return <primitive ref={ref} object={effect} />
|
|
28
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HueSaturationEffect } from 'postprocessing'
|
|
2
|
-
import { wrapEffect } from '../
|
|
3
|
-
|
|
4
|
-
export const HueSaturation = /* @__PURE__ */ wrapEffect(HueSaturationEffect)
|
|
1
|
+
import { HueSaturationEffect } from 'postprocessing'
|
|
2
|
+
import { wrapEffect } from '../wrapEffect'
|
|
3
|
+
|
|
4
|
+
export const HueSaturation = /* @__PURE__ */ wrapEffect(HueSaturationEffect)
|
package/src/effects/LUT.tsx
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import { useThree } from '@react-three/fiber'
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import type { Texture } from 'three'
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
)
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
1
|
+
import { useThree } from '@react-three/fiber'
|
|
2
|
+
import { BlendFunction, LUT3DEffect } from 'postprocessing'
|
|
3
|
+
import { Ref, useLayoutEffect, useMemo } from 'react'
|
|
4
|
+
import type { Texture } from 'three'
|
|
5
|
+
import { useDispose } from '../util'
|
|
6
|
+
|
|
7
|
+
export type LUTProps = {
|
|
8
|
+
lut: Texture
|
|
9
|
+
blendFunction?: BlendFunction
|
|
10
|
+
tetrahedralInterpolation?: boolean
|
|
11
|
+
ref?: Ref<LUT3DEffect>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function LUT({ lut, tetrahedralInterpolation, ref, ...props }: LUTProps) {
|
|
15
|
+
const effect = useMemo(() => new LUT3DEffect(lut, props), [lut, props])
|
|
16
|
+
const invalidate = useThree((state) => state.invalidate)
|
|
17
|
+
|
|
18
|
+
useLayoutEffect(() => {
|
|
19
|
+
if (tetrahedralInterpolation) effect.tetrahedralInterpolation = tetrahedralInterpolation
|
|
20
|
+
if (lut) effect.lut = lut
|
|
21
|
+
invalidate()
|
|
22
|
+
}, [effect, invalidate, lut, tetrahedralInterpolation])
|
|
23
|
+
|
|
24
|
+
useDispose(effect)
|
|
25
|
+
|
|
26
|
+
return <primitive ref={ref} object={effect} />
|
|
27
|
+
}
|