@react-three/postprocessing 3.0.2 → 3.0.4
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 +27 -0
- package/dist/Selection.d.ts +17 -0
- package/dist/effects/ASCII.d.ts +18 -0
- package/dist/effects/Autofocus.d.ts +22 -0
- package/dist/effects/Bloom.d.ts +5 -0
- package/dist/effects/BrightnessContrast.d.ts +5 -0
- package/dist/effects/ChromaticAberration.d.ts +8 -0
- package/dist/effects/ColorAverage.d.ts +8 -0
- package/dist/effects/ColorDepth.d.ts +5 -0
- package/dist/effects/Depth.d.ts +5 -0
- package/dist/effects/DepthOfField.d.ts +25 -0
- package/dist/effects/DotScreen.d.ts +5 -0
- package/dist/effects/FXAA.d.ts +5 -0
- package/dist/effects/Glitch.d.ts +30 -0
- package/dist/effects/GodRays.d.ts +21 -0
- package/dist/effects/Grid.d.ts +12 -0
- package/dist/effects/HueSaturation.d.ts +5 -0
- package/dist/effects/LUT.d.ts +9 -0
- package/dist/effects/LensFlare.d.ts +54 -0
- package/dist/effects/N8AO.d.ts +17 -0
- package/dist/effects/Noise.d.ts +5 -0
- package/dist/effects/Outline.d.ts +30 -0
- package/dist/effects/Pixelation.d.ts +6 -0
- package/dist/effects/Ramp.d.ts +78 -0
- package/dist/effects/SMAA.d.ts +5 -0
- package/dist/effects/SSAO.d.ts +30 -0
- package/dist/effects/ScanlineEffect.d.ts +5 -0
- package/dist/effects/SelectiveBloom.d.ts +20 -0
- package/dist/effects/Sepia.d.ts +5 -0
- package/dist/effects/ShockWave.d.ts +5 -0
- package/dist/effects/Texture.d.ts +11 -0
- package/dist/effects/TiltShift.d.ts +5 -0
- package/dist/effects/TiltShift2.d.ts +22 -0
- package/dist/effects/ToneMapping.d.ts +8 -0
- package/dist/effects/Vignette.d.ts +5 -0
- package/dist/effects/Water.d.ts +12 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +555 -0
- package/dist/index.js.map +1 -0
- package/dist/util.d.ts +17 -0
- package/package.json +67 -68
- package/src/EffectComposer.test.tsx +126 -126
- package/src/EffectComposer.tsx +200 -200
- package/src/Selection.tsx +46 -46
- package/src/effects/ASCII.tsx +135 -135
- package/src/effects/Autofocus.tsx +153 -153
- package/src/effects/Bloom.tsx +6 -6
- package/src/effects/BrightnessContrast.tsx +4 -4
- package/src/effects/ChromaticAberration.tsx +5 -5
- package/src/effects/ColorAverage.tsx +15 -15
- package/src/effects/ColorDepth.tsx +4 -4
- package/src/effects/Depth.tsx +4 -4
- package/src/effects/DepthOfField.tsx +89 -89
- package/src/effects/DotScreen.tsx +4 -4
- package/src/effects/FXAA.tsx +4 -4
- package/src/effects/Glitch.tsx +40 -40
- package/src/effects/GodRays.tsx +16 -16
- package/src/effects/Grid.tsx +21 -21
- package/src/effects/HueSaturation.tsx +4 -4
- package/src/effects/LUT.tsx +26 -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 +117 -117
- package/src/effects/Pixelation.tsx +15 -15
- package/src/effects/Ramp.tsx +150 -150
- package/src/effects/SMAA.tsx +4 -4
- package/src/effects/SSAO.tsx +41 -41
- package/src/effects/ScanlineEffect.tsx +7 -7
- package/src/effects/SelectiveBloom.tsx +126 -126
- package/src/effects/Sepia.tsx +4 -4
- package/src/effects/ShockWave.tsx +4 -4
- package/src/effects/Texture.tsx +23 -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 +40 -40
- package/src/util.tsx +55 -55
package/src/effects/N8AO.tsx
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
// From https://github.com/N8python/n8ao
|
|
2
|
-
// https://twitter.com/N8Programs/status/1660996748485984261
|
|
3
|
-
|
|
4
|
-
import { Ref, forwardRef, useLayoutEffect, useMemo } from 'react'
|
|
5
|
-
/* @ts-ignore */
|
|
6
|
-
import { N8AOPostPass } from 'n8ao'
|
|
7
|
-
import { useThree, ReactThreeFiber, applyProps } from '@react-three/fiber'
|
|
8
|
-
|
|
9
|
-
export type N8AOProps = {
|
|
10
|
-
aoRadius?: number
|
|
11
|
-
distanceFalloff?: number
|
|
12
|
-
intensity?: number
|
|
13
|
-
quality?: 'performance' | 'low' | 'medium' | 'high' | 'ultra'
|
|
14
|
-
aoSamples?: number
|
|
15
|
-
denoiseSamples?: number
|
|
16
|
-
denoiseRadius?: number
|
|
17
|
-
color?: ReactThreeFiber.Color
|
|
18
|
-
halfRes?: boolean
|
|
19
|
-
depthAwareUpsampling?: boolean
|
|
20
|
-
screenSpaceRadius?: boolean
|
|
21
|
-
renderMode?: 0 | 1 | 2 | 3 | 4
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const N8AO = /* @__PURE__ */ forwardRef<N8AOPostPass, N8AOProps>(
|
|
25
|
-
(
|
|
26
|
-
{
|
|
27
|
-
halfRes,
|
|
28
|
-
screenSpaceRadius,
|
|
29
|
-
quality,
|
|
30
|
-
depthAwareUpsampling = true,
|
|
31
|
-
aoRadius = 5,
|
|
32
|
-
aoSamples = 16,
|
|
33
|
-
denoiseSamples = 4,
|
|
34
|
-
denoiseRadius = 12,
|
|
35
|
-
distanceFalloff = 1,
|
|
36
|
-
intensity = 1,
|
|
37
|
-
color,
|
|
38
|
-
renderMode = 0,
|
|
39
|
-
},
|
|
40
|
-
ref: Ref<N8AOPostPass>
|
|
41
|
-
) => {
|
|
42
|
-
const { camera, scene } = useThree()
|
|
43
|
-
const effect = useMemo(() => new N8AOPostPass(scene, camera), [camera, scene])
|
|
44
|
-
|
|
45
|
-
// TODO: implement dispose upstream; this effect has memory leaks without
|
|
46
|
-
useLayoutEffect(() => {
|
|
47
|
-
applyProps(effect.configuration, {
|
|
48
|
-
color,
|
|
49
|
-
aoRadius,
|
|
50
|
-
distanceFalloff,
|
|
51
|
-
intensity,
|
|
52
|
-
aoSamples,
|
|
53
|
-
denoiseSamples,
|
|
54
|
-
denoiseRadius,
|
|
55
|
-
screenSpaceRadius,
|
|
56
|
-
renderMode,
|
|
57
|
-
halfRes,
|
|
58
|
-
depthAwareUpsampling,
|
|
59
|
-
})
|
|
60
|
-
}, [
|
|
61
|
-
screenSpaceRadius,
|
|
62
|
-
color,
|
|
63
|
-
aoRadius,
|
|
64
|
-
distanceFalloff,
|
|
65
|
-
intensity,
|
|
66
|
-
aoSamples,
|
|
67
|
-
denoiseSamples,
|
|
68
|
-
denoiseRadius,
|
|
69
|
-
renderMode,
|
|
70
|
-
halfRes,
|
|
71
|
-
depthAwareUpsampling,
|
|
72
|
-
effect,
|
|
73
|
-
])
|
|
74
|
-
|
|
75
|
-
useLayoutEffect(() => {
|
|
76
|
-
if (quality) effect.setQualityMode(quality.charAt(0).toUpperCase() + quality.slice(1))
|
|
77
|
-
}, [effect, quality])
|
|
78
|
-
|
|
79
|
-
return <primitive ref={ref} object={effect} />
|
|
80
|
-
}
|
|
81
|
-
)
|
|
1
|
+
// From https://github.com/N8python/n8ao
|
|
2
|
+
// https://twitter.com/N8Programs/status/1660996748485984261
|
|
3
|
+
|
|
4
|
+
import { Ref, forwardRef, useLayoutEffect, useMemo } from 'react'
|
|
5
|
+
/* @ts-ignore */
|
|
6
|
+
import { N8AOPostPass } from 'n8ao'
|
|
7
|
+
import { useThree, ReactThreeFiber, applyProps } from '@react-three/fiber'
|
|
8
|
+
|
|
9
|
+
export type N8AOProps = {
|
|
10
|
+
aoRadius?: number
|
|
11
|
+
distanceFalloff?: number
|
|
12
|
+
intensity?: number
|
|
13
|
+
quality?: 'performance' | 'low' | 'medium' | 'high' | 'ultra'
|
|
14
|
+
aoSamples?: number
|
|
15
|
+
denoiseSamples?: number
|
|
16
|
+
denoiseRadius?: number
|
|
17
|
+
color?: ReactThreeFiber.Color
|
|
18
|
+
halfRes?: boolean
|
|
19
|
+
depthAwareUpsampling?: boolean
|
|
20
|
+
screenSpaceRadius?: boolean
|
|
21
|
+
renderMode?: 0 | 1 | 2 | 3 | 4
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const N8AO = /* @__PURE__ */ forwardRef<N8AOPostPass, N8AOProps>(
|
|
25
|
+
(
|
|
26
|
+
{
|
|
27
|
+
halfRes,
|
|
28
|
+
screenSpaceRadius,
|
|
29
|
+
quality,
|
|
30
|
+
depthAwareUpsampling = true,
|
|
31
|
+
aoRadius = 5,
|
|
32
|
+
aoSamples = 16,
|
|
33
|
+
denoiseSamples = 4,
|
|
34
|
+
denoiseRadius = 12,
|
|
35
|
+
distanceFalloff = 1,
|
|
36
|
+
intensity = 1,
|
|
37
|
+
color,
|
|
38
|
+
renderMode = 0,
|
|
39
|
+
},
|
|
40
|
+
ref: Ref<N8AOPostPass>
|
|
41
|
+
) => {
|
|
42
|
+
const { camera, scene } = useThree()
|
|
43
|
+
const effect = useMemo(() => new N8AOPostPass(scene, camera), [camera, scene])
|
|
44
|
+
|
|
45
|
+
// TODO: implement dispose upstream; this effect has memory leaks without
|
|
46
|
+
useLayoutEffect(() => {
|
|
47
|
+
applyProps(effect.configuration, {
|
|
48
|
+
color,
|
|
49
|
+
aoRadius,
|
|
50
|
+
distanceFalloff,
|
|
51
|
+
intensity,
|
|
52
|
+
aoSamples,
|
|
53
|
+
denoiseSamples,
|
|
54
|
+
denoiseRadius,
|
|
55
|
+
screenSpaceRadius,
|
|
56
|
+
renderMode,
|
|
57
|
+
halfRes,
|
|
58
|
+
depthAwareUpsampling,
|
|
59
|
+
})
|
|
60
|
+
}, [
|
|
61
|
+
screenSpaceRadius,
|
|
62
|
+
color,
|
|
63
|
+
aoRadius,
|
|
64
|
+
distanceFalloff,
|
|
65
|
+
intensity,
|
|
66
|
+
aoSamples,
|
|
67
|
+
denoiseSamples,
|
|
68
|
+
denoiseRadius,
|
|
69
|
+
renderMode,
|
|
70
|
+
halfRes,
|
|
71
|
+
depthAwareUpsampling,
|
|
72
|
+
effect,
|
|
73
|
+
])
|
|
74
|
+
|
|
75
|
+
useLayoutEffect(() => {
|
|
76
|
+
if (quality) effect.setQualityMode(quality.charAt(0).toUpperCase() + quality.slice(1))
|
|
77
|
+
}, [effect, quality])
|
|
78
|
+
|
|
79
|
+
return <primitive ref={ref} object={effect} />
|
|
80
|
+
}
|
|
81
|
+
)
|
package/src/effects/Noise.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NoiseEffect, BlendFunction } from 'postprocessing'
|
|
2
|
-
import { wrapEffect } from '../util'
|
|
3
|
-
|
|
4
|
-
export const Noise = /* @__PURE__ */ wrapEffect(NoiseEffect, { blendFunction: BlendFunction.COLOR_DODGE })
|
|
1
|
+
import { NoiseEffect, BlendFunction } from 'postprocessing'
|
|
2
|
+
import { wrapEffect } from '../util'
|
|
3
|
+
|
|
4
|
+
export const Noise = /* @__PURE__ */ wrapEffect(NoiseEffect, { blendFunction: BlendFunction.COLOR_DODGE })
|
package/src/effects/Outline.tsx
CHANGED
|
@@ -1,117 +1,117 @@
|
|
|
1
|
-
import { OutlineEffect } from 'postprocessing'
|
|
2
|
-
import { Ref, RefObject, forwardRef, useMemo, useEffect, useContext, useRef } from 'react'
|
|
3
|
-
import { Object3D } from 'three'
|
|
4
|
-
import { useThree } from '@react-three/fiber'
|
|
5
|
-
import { EffectComposerContext } from '../EffectComposer'
|
|
6
|
-
import { selectionContext } from '../Selection'
|
|
7
|
-
import { resolveRef } from '../util'
|
|
8
|
-
|
|
9
|
-
type ObjectRef = RefObject<Object3D>
|
|
10
|
-
|
|
11
|
-
export type OutlineProps = ConstructorParameters<typeof OutlineEffect>[2] &
|
|
12
|
-
Partial<{
|
|
13
|
-
selection: Object3D | Object3D[] | ObjectRef | ObjectRef[]
|
|
14
|
-
selectionLayer: number
|
|
15
|
-
}>
|
|
16
|
-
|
|
17
|
-
export const Outline = /* @__PURE__ */ forwardRef(function Outline(
|
|
18
|
-
{
|
|
19
|
-
selection = [],
|
|
20
|
-
selectionLayer = 10,
|
|
21
|
-
blendFunction,
|
|
22
|
-
patternTexture,
|
|
23
|
-
edgeStrength,
|
|
24
|
-
pulseSpeed,
|
|
25
|
-
visibleEdgeColor,
|
|
26
|
-
hiddenEdgeColor,
|
|
27
|
-
width,
|
|
28
|
-
height,
|
|
29
|
-
kernelSize,
|
|
30
|
-
blur,
|
|
31
|
-
xRay,
|
|
32
|
-
...props
|
|
33
|
-
}: OutlineProps,
|
|
34
|
-
forwardRef: Ref<OutlineEffect>
|
|
35
|
-
) {
|
|
36
|
-
const invalidate = useThree((state) => state.invalidate)
|
|
37
|
-
const { scene, camera } = useContext(EffectComposerContext)
|
|
38
|
-
|
|
39
|
-
const effect = useMemo(
|
|
40
|
-
() =>
|
|
41
|
-
new OutlineEffect(scene, camera, {
|
|
42
|
-
blendFunction,
|
|
43
|
-
patternTexture,
|
|
44
|
-
edgeStrength,
|
|
45
|
-
pulseSpeed,
|
|
46
|
-
visibleEdgeColor,
|
|
47
|
-
hiddenEdgeColor,
|
|
48
|
-
width,
|
|
49
|
-
height,
|
|
50
|
-
kernelSize,
|
|
51
|
-
blur,
|
|
52
|
-
xRay,
|
|
53
|
-
...props,
|
|
54
|
-
}),
|
|
55
|
-
// NOTE: `props` is an unstable reference, so we can't memoize it
|
|
56
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
57
|
-
[
|
|
58
|
-
blendFunction,
|
|
59
|
-
blur,
|
|
60
|
-
camera,
|
|
61
|
-
edgeStrength,
|
|
62
|
-
height,
|
|
63
|
-
hiddenEdgeColor,
|
|
64
|
-
kernelSize,
|
|
65
|
-
patternTexture,
|
|
66
|
-
pulseSpeed,
|
|
67
|
-
scene,
|
|
68
|
-
visibleEdgeColor,
|
|
69
|
-
width,
|
|
70
|
-
xRay,
|
|
71
|
-
]
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
const api = useContext(selectionContext)
|
|
75
|
-
|
|
76
|
-
useEffect(() => {
|
|
77
|
-
// Do not allow array selection if declarative selection is active
|
|
78
|
-
// TODO: array selection should probably be deprecated altogether
|
|
79
|
-
if (!api && selection) {
|
|
80
|
-
effect.selection.set(
|
|
81
|
-
Array.isArray(selection) ? (selection as Object3D[]).map(resolveRef) : [resolveRef(selection) as Object3D]
|
|
82
|
-
)
|
|
83
|
-
invalidate()
|
|
84
|
-
return () => {
|
|
85
|
-
effect.selection.clear()
|
|
86
|
-
invalidate()
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}, [effect, selection, api, invalidate])
|
|
90
|
-
|
|
91
|
-
useEffect(() => {
|
|
92
|
-
effect.selectionLayer = selectionLayer
|
|
93
|
-
invalidate()
|
|
94
|
-
}, [effect, invalidate, selectionLayer])
|
|
95
|
-
|
|
96
|
-
const ref = useRef<OutlineEffect>(undefined)
|
|
97
|
-
useEffect(() => {
|
|
98
|
-
if (api && api.enabled) {
|
|
99
|
-
if (api.selected?.length) {
|
|
100
|
-
effect.selection.set(api.selected)
|
|
101
|
-
invalidate()
|
|
102
|
-
return () => {
|
|
103
|
-
effect.selection.clear()
|
|
104
|
-
invalidate()
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}, [api, effect.selection, invalidate])
|
|
109
|
-
|
|
110
|
-
useEffect(() => {
|
|
111
|
-
return () => {
|
|
112
|
-
effect.dispose()
|
|
113
|
-
}
|
|
114
|
-
}, [effect])
|
|
115
|
-
|
|
116
|
-
return <primitive ref={forwardRef} object={effect} />
|
|
117
|
-
})
|
|
1
|
+
import { OutlineEffect } from 'postprocessing'
|
|
2
|
+
import { Ref, RefObject, forwardRef, useMemo, useEffect, useContext, useRef } from 'react'
|
|
3
|
+
import { Object3D } from 'three'
|
|
4
|
+
import { useThree } from '@react-three/fiber'
|
|
5
|
+
import { EffectComposerContext } from '../EffectComposer'
|
|
6
|
+
import { selectionContext } from '../Selection'
|
|
7
|
+
import { resolveRef } from '../util'
|
|
8
|
+
|
|
9
|
+
type ObjectRef = RefObject<Object3D>
|
|
10
|
+
|
|
11
|
+
export type OutlineProps = ConstructorParameters<typeof OutlineEffect>[2] &
|
|
12
|
+
Partial<{
|
|
13
|
+
selection: Object3D | Object3D[] | ObjectRef | ObjectRef[]
|
|
14
|
+
selectionLayer: number
|
|
15
|
+
}>
|
|
16
|
+
|
|
17
|
+
export const Outline = /* @__PURE__ */ forwardRef(function Outline(
|
|
18
|
+
{
|
|
19
|
+
selection = [],
|
|
20
|
+
selectionLayer = 10,
|
|
21
|
+
blendFunction,
|
|
22
|
+
patternTexture,
|
|
23
|
+
edgeStrength,
|
|
24
|
+
pulseSpeed,
|
|
25
|
+
visibleEdgeColor,
|
|
26
|
+
hiddenEdgeColor,
|
|
27
|
+
width,
|
|
28
|
+
height,
|
|
29
|
+
kernelSize,
|
|
30
|
+
blur,
|
|
31
|
+
xRay,
|
|
32
|
+
...props
|
|
33
|
+
}: OutlineProps,
|
|
34
|
+
forwardRef: Ref<OutlineEffect>
|
|
35
|
+
) {
|
|
36
|
+
const invalidate = useThree((state) => state.invalidate)
|
|
37
|
+
const { scene, camera } = useContext(EffectComposerContext)
|
|
38
|
+
|
|
39
|
+
const effect = useMemo(
|
|
40
|
+
() =>
|
|
41
|
+
new OutlineEffect(scene, camera, {
|
|
42
|
+
blendFunction,
|
|
43
|
+
patternTexture,
|
|
44
|
+
edgeStrength,
|
|
45
|
+
pulseSpeed,
|
|
46
|
+
visibleEdgeColor,
|
|
47
|
+
hiddenEdgeColor,
|
|
48
|
+
width,
|
|
49
|
+
height,
|
|
50
|
+
kernelSize,
|
|
51
|
+
blur,
|
|
52
|
+
xRay,
|
|
53
|
+
...props,
|
|
54
|
+
}),
|
|
55
|
+
// NOTE: `props` is an unstable reference, so we can't memoize it
|
|
56
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
57
|
+
[
|
|
58
|
+
blendFunction,
|
|
59
|
+
blur,
|
|
60
|
+
camera,
|
|
61
|
+
edgeStrength,
|
|
62
|
+
height,
|
|
63
|
+
hiddenEdgeColor,
|
|
64
|
+
kernelSize,
|
|
65
|
+
patternTexture,
|
|
66
|
+
pulseSpeed,
|
|
67
|
+
scene,
|
|
68
|
+
visibleEdgeColor,
|
|
69
|
+
width,
|
|
70
|
+
xRay,
|
|
71
|
+
]
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
const api = useContext(selectionContext)
|
|
75
|
+
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
// Do not allow array selection if declarative selection is active
|
|
78
|
+
// TODO: array selection should probably be deprecated altogether
|
|
79
|
+
if (!api && selection) {
|
|
80
|
+
effect.selection.set(
|
|
81
|
+
Array.isArray(selection) ? (selection as Object3D[]).map(resolveRef) : [resolveRef(selection) as Object3D]
|
|
82
|
+
)
|
|
83
|
+
invalidate()
|
|
84
|
+
return () => {
|
|
85
|
+
effect.selection.clear()
|
|
86
|
+
invalidate()
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}, [effect, selection, api, invalidate])
|
|
90
|
+
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
effect.selectionLayer = selectionLayer
|
|
93
|
+
invalidate()
|
|
94
|
+
}, [effect, invalidate, selectionLayer])
|
|
95
|
+
|
|
96
|
+
const ref = useRef<OutlineEffect>(undefined)
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (api && api.enabled) {
|
|
99
|
+
if (api.selected?.length) {
|
|
100
|
+
effect.selection.set(api.selected)
|
|
101
|
+
invalidate()
|
|
102
|
+
return () => {
|
|
103
|
+
effect.selection.clear()
|
|
104
|
+
invalidate()
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}, [api, effect.selection, invalidate])
|
|
109
|
+
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
return () => {
|
|
112
|
+
effect.dispose()
|
|
113
|
+
}
|
|
114
|
+
}, [effect])
|
|
115
|
+
|
|
116
|
+
return <primitive ref={forwardRef} object={effect} />
|
|
117
|
+
})
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { forwardRef, useMemo, Ref } from 'react'
|
|
2
|
-
import { PixelationEffect } from 'postprocessing'
|
|
3
|
-
|
|
4
|
-
export type PixelationProps = {
|
|
5
|
-
granularity?: number
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const Pixelation = /* @__PURE__ */ forwardRef<PixelationEffect, PixelationProps>(function Pixelation(
|
|
9
|
-
{ granularity = 5 }: PixelationProps,
|
|
10
|
-
ref: Ref<PixelationEffect>
|
|
11
|
-
) {
|
|
12
|
-
/** Because GlitchEffect granularity is not an object but a number, we have to define a custom prop "granularity" */
|
|
13
|
-
const effect = useMemo(() => new PixelationEffect(granularity), [granularity])
|
|
14
|
-
return <primitive ref={ref} object={effect} dispose={null} />
|
|
15
|
-
})
|
|
1
|
+
import { forwardRef, useMemo, Ref } from 'react'
|
|
2
|
+
import { PixelationEffect } from 'postprocessing'
|
|
3
|
+
|
|
4
|
+
export type PixelationProps = {
|
|
5
|
+
granularity?: number
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const Pixelation = /* @__PURE__ */ forwardRef<PixelationEffect, PixelationProps>(function Pixelation(
|
|
9
|
+
{ granularity = 5 }: PixelationProps,
|
|
10
|
+
ref: Ref<PixelationEffect>
|
|
11
|
+
) {
|
|
12
|
+
/** Because GlitchEffect granularity is not an object but a number, we have to define a custom prop "granularity" */
|
|
13
|
+
const effect = useMemo(() => new PixelationEffect(granularity), [granularity])
|
|
14
|
+
return <primitive ref={ref} object={effect} dispose={null} />
|
|
15
|
+
})
|