@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.
Files changed (93) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +81 -81
  3. package/dist/EffectComposer.d.ts +28 -0
  4. package/dist/Selection.d.ts +17 -0
  5. package/dist/effects/ASCII.d.ts +19 -0
  6. package/dist/effects/Autofocus.d.ts +23 -0
  7. package/dist/effects/Bloom.d.ts +2 -0
  8. package/dist/effects/BrightnessContrast.d.ts +2 -0
  9. package/dist/effects/ChromaticAberration.d.ts +8 -0
  10. package/dist/effects/ColorAverage.d.ts +7 -0
  11. package/dist/effects/ColorDepth.d.ts +2 -0
  12. package/dist/effects/Depth.d.ts +2 -0
  13. package/dist/effects/DepthOfField.d.ts +14 -0
  14. package/dist/effects/DotScreen.d.ts +2 -0
  15. package/dist/effects/FXAA.d.ts +2 -0
  16. package/dist/effects/Glitch.d.ts +13 -0
  17. package/dist/effects/GodRays.d.ts +9 -0
  18. package/dist/effects/Grid.d.ts +11 -0
  19. package/dist/effects/HueSaturation.d.ts +2 -0
  20. package/dist/effects/LUT.d.ts +10 -0
  21. package/dist/effects/LensFlare.d.ts +54 -0
  22. package/dist/effects/N8AO.d.ts +19 -0
  23. package/dist/effects/Noise.d.ts +2 -0
  24. package/dist/effects/Outline.d.ts +11 -0
  25. package/dist/effects/Pixelation.d.ts +7 -0
  26. package/dist/effects/Ramp.d.ts +74 -0
  27. package/dist/effects/SMAA.d.ts +2 -0
  28. package/dist/effects/SSAO.d.ts +7 -0
  29. package/dist/effects/ScanlineEffect.d.ts +2 -0
  30. package/dist/effects/SelectiveBloom.d.ts +15 -0
  31. package/dist/effects/Sepia.d.ts +2 -0
  32. package/dist/effects/ShockWave.d.ts +2 -0
  33. package/dist/effects/Texture.d.ts +10 -0
  34. package/dist/effects/TiltShift.d.ts +2 -0
  35. package/dist/effects/TiltShift2.d.ts +18 -0
  36. package/dist/effects/ToneMapping.d.ts +4 -0
  37. package/dist/effects/Vignette.d.ts +2 -0
  38. package/dist/effects/Water.d.ts +8 -0
  39. package/dist/index.d.ts +38 -1
  40. package/dist/index.js +855 -551
  41. package/dist/index.js.map +1 -1
  42. package/dist/tests/test-utils.d.ts +12 -0
  43. package/dist/util.d.ts +25 -0
  44. package/dist/wrapEffect.d.ts +12 -0
  45. package/package.json +73 -66
  46. package/src/EffectComposer.tsx +278 -200
  47. package/src/Selection.tsx +86 -46
  48. package/src/effects/ASCII.tsx +136 -135
  49. package/src/effects/Autofocus.tsx +175 -153
  50. package/src/effects/Bloom.tsx +6 -6
  51. package/src/effects/BrightnessContrast.tsx +4 -4
  52. package/src/effects/ChromaticAberration.tsx +30 -5
  53. package/src/effects/ColorAverage.tsx +17 -15
  54. package/src/effects/ColorDepth.tsx +4 -4
  55. package/src/effects/Depth.tsx +4 -4
  56. package/src/effects/DepthOfField.tsx +87 -89
  57. package/src/effects/DotScreen.tsx +4 -4
  58. package/src/effects/FXAA.tsx +4 -4
  59. package/src/effects/Glitch.tsx +37 -40
  60. package/src/effects/GodRays.tsx +20 -16
  61. package/src/effects/Grid.tsx +28 -21
  62. package/src/effects/HueSaturation.tsx +4 -4
  63. package/src/effects/LUT.tsx +27 -26
  64. package/src/effects/LensFlare.tsx +611 -611
  65. package/src/effects/N8AO.tsx +81 -81
  66. package/src/effects/Noise.tsx +4 -4
  67. package/src/effects/Outline.tsx +85 -117
  68. package/src/effects/Pixelation.tsx +17 -15
  69. package/src/effects/Ramp.tsx +150 -150
  70. package/src/effects/SMAA.tsx +4 -4
  71. package/src/effects/SSAO.tsx +44 -41
  72. package/src/effects/ScanlineEffect.tsx +7 -7
  73. package/src/effects/SelectiveBloom.tsx +116 -126
  74. package/src/effects/Sepia.tsx +4 -4
  75. package/src/effects/ShockWave.tsx +4 -4
  76. package/src/effects/Texture.tsx +27 -23
  77. package/src/effects/TiltShift.tsx +4 -4
  78. package/src/effects/TiltShift2.tsx +90 -90
  79. package/src/effects/ToneMapping.tsx +6 -6
  80. package/src/effects/Vignette.tsx +4 -4
  81. package/src/effects/Water.tsx +35 -35
  82. package/src/index.ts +41 -40
  83. package/src/tests/ChromaticAberration.test.tsx +31 -0
  84. package/src/tests/EffectComposer.test.tsx +911 -0
  85. package/src/tests/Outline.test.tsx +89 -0
  86. package/src/tests/Selection.test.tsx +324 -0
  87. package/src/tests/SelectiveBloom.test.tsx +118 -0
  88. package/src/tests/effects.smoke.test.tsx +234 -0
  89. package/src/tests/test-utils.tsx +96 -0
  90. package/src/tests/wrapEffect.test.tsx +209 -0
  91. package/src/util.tsx +96 -55
  92. package/src/wrapEffect.tsx +122 -0
  93. package/src/EffectComposer.test.tsx +0 -126
@@ -1,4 +1,4 @@
1
- import { ShockWaveEffect } from 'postprocessing'
2
- import { wrapEffect } from '../util'
3
-
4
- export const ShockWave = /* @__PURE__ */ wrapEffect(ShockWaveEffect)
1
+ import { ShockWaveEffect } from 'postprocessing'
2
+ import { wrapEffect } from '../wrapEffect'
3
+
4
+ export const ShockWave = /* @__PURE__ */ wrapEffect(ShockWaveEffect)
@@ -1,23 +1,27 @@
1
- import { TextureEffect } from 'postprocessing'
2
- import { Ref, forwardRef, useMemo, useLayoutEffect } from 'react'
3
- import { useLoader } from '@react-three/fiber'
4
- import { TextureLoader, SRGBColorSpace, RepeatWrapping } from 'three'
5
-
6
- type TextureProps = ConstructorParameters<typeof TextureEffect>[0] & {
7
- textureSrc: string
8
- /** opacity of provided texture */
9
- opacity?: number
10
- }
11
-
12
- export const Texture = /* @__PURE__ */ forwardRef<TextureEffect, TextureProps>(function Texture(
13
- { textureSrc, texture, opacity = 1, ...props }: TextureProps,
14
- ref: Ref<TextureEffect>
15
- ) {
16
- const t = useLoader(TextureLoader, textureSrc)
17
- useLayoutEffect(() => {
18
- t.colorSpace = SRGBColorSpace
19
- t.wrapS = t.wrapT = RepeatWrapping
20
- }, [t])
21
- const effect = useMemo(() => new TextureEffect({ ...props, texture: t || texture }), [props, t, texture])
22
- return <primitive ref={ref} object={effect} blendMode-opacity-value={opacity} dispose={null} />
23
- })
1
+ import { useLoader } from '@react-three/fiber'
2
+ import { TextureEffect } from 'postprocessing'
3
+ import { Ref, useLayoutEffect, useMemo } from 'react'
4
+ import { RepeatWrapping, SRGBColorSpace, TextureLoader } from 'three'
5
+ import { useDispose } from '../util'
6
+
7
+ type TextureProps = ConstructorParameters<typeof TextureEffect>[0] & {
8
+ textureSrc: string
9
+ /** opacity of provided texture */
10
+ opacity?: number
11
+ ref?: Ref<TextureEffect>
12
+ }
13
+
14
+ export function Texture({ textureSrc, texture, opacity = 1, ref, ...props }: TextureProps) {
15
+ const t = useLoader(TextureLoader, textureSrc)
16
+
17
+ useLayoutEffect(() => {
18
+ t.colorSpace = SRGBColorSpace
19
+ t.wrapS = t.wrapT = RepeatWrapping
20
+ }, [t])
21
+
22
+ const effect = useMemo(() => new TextureEffect({ ...props, texture: t || texture }), [])
23
+
24
+ useDispose(effect)
25
+
26
+ return <primitive ref={ref} object={effect} blendMode-opacity-value={opacity} />
27
+ }
@@ -1,4 +1,4 @@
1
- import { TiltShiftEffect, BlendFunction } from 'postprocessing'
2
- import { wrapEffect } from '../util'
3
-
4
- export const TiltShift = /* @__PURE__ */ wrapEffect(TiltShiftEffect, { blendFunction: BlendFunction.ADD })
1
+ import { BlendFunction, TiltShiftEffect } from 'postprocessing'
2
+ import { wrapEffect } from '../wrapEffect'
3
+
4
+ export const TiltShift = /* @__PURE__ */ wrapEffect(TiltShiftEffect, { blendFunction: BlendFunction.ADD })
@@ -1,90 +1,90 @@
1
- import { Uniform } from 'three'
2
- import { BlendFunction, Effect, EffectAttribute } from 'postprocessing'
3
- import { wrapEffect } from '../util'
4
-
5
- const TiltShiftShader = {
6
- fragmentShader: `
7
-
8
- // original shader by Evan Wallace
9
-
10
- #define MAX_ITERATIONS 100
11
-
12
- uniform float blur;
13
- uniform float taper;
14
- uniform vec2 start;
15
- uniform vec2 end;
16
- uniform vec2 direction;
17
- uniform int samples;
18
-
19
- float random(vec3 scale, float seed) {
20
- /* use the fragment position for a different seed per-pixel */
21
- return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);
22
- }
23
-
24
- void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) {
25
- vec4 color = vec4(0.0);
26
- float total = 0.0;
27
- vec2 startPixel = vec2(start.x * resolution.x, start.y * resolution.y);
28
- vec2 endPixel = vec2(end.x * resolution.x, end.y * resolution.y);
29
- float f_samples = float(samples);
30
- float half_samples = f_samples / 2.0;
31
-
32
- // use screen diagonal to normalize blur radii
33
- float maxScreenDistance = distance(vec2(0.0), resolution); // diagonal distance
34
- float gradientRadius = taper * (maxScreenDistance);
35
- float blurRadius = blur * (maxScreenDistance / 16.0);
36
-
37
- /* randomize the lookup values to hide the fixed number of samples */
38
- float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
39
- vec2 normal = normalize(vec2(startPixel.y - endPixel.y, endPixel.x - startPixel.x));
40
- float radius = smoothstep(0.0, 1.0, abs(dot(uv * resolution - startPixel, normal)) / gradientRadius) * blurRadius;
41
-
42
- #pragma unroll_loop_start
43
- for (int i = 0; i <= MAX_ITERATIONS; i++) {
44
- if (i >= samples) { break; } // return early if over sample count
45
- float f_i = float(i);
46
- float s_i = -half_samples + f_i;
47
- float percent = (s_i + offset - 0.5) / half_samples;
48
- float weight = 1.0 - abs(percent);
49
- vec4 sample_i = texture2D(inputBuffer, uv + normalize(direction) / resolution * percent * radius);
50
- /* switch to pre-multiplied alpha to correctly blur transparent images */
51
- sample_i.rgb *= sample_i.a;
52
- color += sample_i * weight;
53
- total += weight;
54
- }
55
- #pragma unroll_loop_end
56
-
57
- outputColor = color / total;
58
-
59
- /* switch back from pre-multiplied alpha */
60
- outputColor.rgb /= outputColor.a + 0.00001;
61
- }
62
- `,
63
- }
64
-
65
- export class TiltShiftEffect extends Effect {
66
- constructor({
67
- blendFunction = BlendFunction.NORMAL,
68
- blur = 0.15, // [0, 1], can go beyond 1 for extra
69
- taper = 0.5, // [0, 1], can go beyond 1 for extra
70
- start = [0.5, 0.0], // [0,1] percentage x,y of screenspace
71
- end = [0.5, 1.0], // [0,1] percentage x,y of screenspace
72
- samples = 10.0, // number of blur samples
73
- direction = [1, 1], // direction of blur
74
- } = {}) {
75
- super('TiltShiftEffect', TiltShiftShader.fragmentShader, {
76
- blendFunction,
77
- attributes: EffectAttribute.CONVOLUTION,
78
- uniforms: new Map<string, Uniform<number | number[]>>([
79
- ['blur', new Uniform(blur)],
80
- ['taper', new Uniform(taper)],
81
- ['start', new Uniform(start)],
82
- ['end', new Uniform(end)],
83
- ['samples', new Uniform(samples)],
84
- ['direction', new Uniform(direction)],
85
- ]),
86
- })
87
- }
88
- }
89
-
90
- export const TiltShift2 = /* @__PURE__ */ wrapEffect(TiltShiftEffect, { blendFunction: BlendFunction.NORMAL })
1
+ import { BlendFunction, Effect, EffectAttribute } from 'postprocessing'
2
+ import { Uniform } from 'three'
3
+ import { wrapEffect } from '../wrapEffect'
4
+
5
+ const TiltShiftShader = {
6
+ fragmentShader: /* glsl */ `
7
+
8
+ // original shader by Evan Wallace
9
+
10
+ #define MAX_ITERATIONS 100
11
+
12
+ uniform float blur;
13
+ uniform float taper;
14
+ uniform vec2 start;
15
+ uniform vec2 end;
16
+ uniform vec2 direction;
17
+ uniform int samples;
18
+
19
+ float random(vec3 scale, float seed) {
20
+ /* use the fragment position for a different seed per-pixel */
21
+ return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);
22
+ }
23
+
24
+ void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) {
25
+ vec4 color = vec4(0.0);
26
+ float total = 0.0;
27
+ vec2 startPixel = vec2(start.x * resolution.x, start.y * resolution.y);
28
+ vec2 endPixel = vec2(end.x * resolution.x, end.y * resolution.y);
29
+ float f_samples = float(samples);
30
+ float half_samples = f_samples / 2.0;
31
+
32
+ // use screen diagonal to normalize blur radii
33
+ float maxScreenDistance = distance(vec2(0.0), resolution); // diagonal distance
34
+ float gradientRadius = taper * (maxScreenDistance);
35
+ float blurRadius = blur * (maxScreenDistance / 16.0);
36
+
37
+ /* randomize the lookup values to hide the fixed number of samples */
38
+ float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
39
+ vec2 normal = normalize(vec2(startPixel.y - endPixel.y, endPixel.x - startPixel.x));
40
+ float radius = smoothstep(0.0, 1.0, abs(dot(uv * resolution - startPixel, normal)) / gradientRadius) * blurRadius;
41
+
42
+ #pragma unroll_loop_start
43
+ for (int i = 0; i <= MAX_ITERATIONS; i++) {
44
+ if (i >= samples) { break; } // return early if over sample count
45
+ float f_i = float(i);
46
+ float s_i = -half_samples + f_i;
47
+ float percent = (s_i + offset - 0.5) / half_samples;
48
+ float weight = 1.0 - abs(percent);
49
+ vec4 sample_i = texture2D(inputBuffer, uv + normalize(direction) / resolution * percent * radius);
50
+ /* switch to pre-multiplied alpha to correctly blur transparent images */
51
+ sample_i.rgb *= sample_i.a;
52
+ color += sample_i * weight;
53
+ total += weight;
54
+ }
55
+ #pragma unroll_loop_end
56
+
57
+ outputColor = color / total;
58
+
59
+ /* switch back from pre-multiplied alpha */
60
+ outputColor.rgb /= outputColor.a + 0.00001;
61
+ }
62
+ `,
63
+ }
64
+
65
+ export class TiltShiftEffect extends Effect {
66
+ constructor({
67
+ blendFunction = BlendFunction.NORMAL,
68
+ blur = 0.15, // [0, 1], can go beyond 1 for extra
69
+ taper = 0.5, // [0, 1], can go beyond 1 for extra
70
+ start = [0.5, 0.0], // [0,1] percentage x,y of screenspace
71
+ end = [0.5, 1.0], // [0,1] percentage x,y of screenspace
72
+ samples = 10.0, // number of blur samples
73
+ direction = [1, 1], // direction of blur
74
+ } = {}) {
75
+ super('TiltShiftEffect', TiltShiftShader.fragmentShader, {
76
+ blendFunction,
77
+ attributes: EffectAttribute.CONVOLUTION,
78
+ uniforms: new Map<string, Uniform<number | number[]>>([
79
+ ['blur', new Uniform(blur)],
80
+ ['taper', new Uniform(taper)],
81
+ ['start', new Uniform(start)],
82
+ ['end', new Uniform(end)],
83
+ ['samples', new Uniform(samples)],
84
+ ['direction', new Uniform(direction)],
85
+ ]),
86
+ })
87
+ }
88
+ }
89
+
90
+ export const TiltShift2 = /* @__PURE__ */ wrapEffect(TiltShiftEffect, { blendFunction: BlendFunction.NORMAL })
@@ -1,6 +1,6 @@
1
- import { ToneMappingEffect } from 'postprocessing'
2
- import { type EffectProps, wrapEffect } from '../util'
3
-
4
- export type ToneMappingProps = EffectProps<typeof ToneMappingEffect>
5
-
6
- export const ToneMapping = /* @__PURE__ */ wrapEffect(ToneMappingEffect)
1
+ import { ToneMappingEffect } from 'postprocessing'
2
+ import { type EffectProps, wrapEffect } from '../wrapEffect'
3
+
4
+ export type ToneMappingProps = EffectProps<typeof ToneMappingEffect>
5
+
6
+ export const ToneMapping = /* @__PURE__ */ wrapEffect(ToneMappingEffect)
@@ -1,4 +1,4 @@
1
- import { VignetteEffect } from 'postprocessing'
2
- import { wrapEffect } from '../util'
3
-
4
- export const Vignette = /* @__PURE__ */ wrapEffect(VignetteEffect)
1
+ import { VignetteEffect } from 'postprocessing'
2
+ import { wrapEffect } from '../wrapEffect'
3
+
4
+ export const Vignette = /* @__PURE__ */ wrapEffect(VignetteEffect)
@@ -1,35 +1,35 @@
1
- import { Uniform } from 'three'
2
- import { BlendFunction, Effect, EffectAttribute } from 'postprocessing'
3
- import { wrapEffect } from '../util'
4
-
5
- const WaterShader = {
6
- fragmentShader: /* glsl */ `
7
- uniform float factor;
8
-
9
- void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) {
10
- vec2 vUv = uv;
11
- float frequency = 6.0 * factor;
12
- float amplitude = 0.015 * factor;
13
- float x = vUv.y * frequency + time * 0.7;
14
- float y = vUv.x * frequency + time * 0.3;
15
- vUv.x += cos(x + y) * amplitude * cos(y);
16
- vUv.y += sin(x - y) * amplitude * cos(y);
17
- vec4 rgba = texture(inputBuffer, vUv);
18
- outputColor = rgba;
19
- }
20
- `,
21
- }
22
-
23
- export class WaterEffectImpl extends Effect {
24
- constructor({ blendFunction = BlendFunction.NORMAL, factor = 0 } = {}) {
25
- super('WaterEffect', WaterShader.fragmentShader, {
26
- blendFunction,
27
- attributes: EffectAttribute.CONVOLUTION,
28
- uniforms: new Map<string, Uniform<number | number[]>>([['factor', new Uniform(factor)]]),
29
- })
30
- }
31
- }
32
-
33
- export const WaterEffect = /* @__PURE__ */ wrapEffect(WaterEffectImpl, {
34
- blendFunction: BlendFunction.NORMAL,
35
- })
1
+ import { BlendFunction, Effect, EffectAttribute } from 'postprocessing'
2
+ import { Uniform } from 'three'
3
+ import { wrapEffect } from '../wrapEffect'
4
+
5
+ const WaterShader = {
6
+ fragmentShader: /* glsl */ `
7
+ uniform float factor;
8
+
9
+ void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) {
10
+ vec2 vUv = uv;
11
+ float frequency = 6.0 * factor;
12
+ float amplitude = 0.015 * factor;
13
+ float x = vUv.y * frequency + time * 0.7;
14
+ float y = vUv.x * frequency + time * 0.3;
15
+ vUv.x += cos(x + y) * amplitude * cos(y);
16
+ vUv.y += sin(x - y) * amplitude * cos(y);
17
+ vec4 rgba = texture(inputBuffer, vUv);
18
+ outputColor = rgba;
19
+ }
20
+ `,
21
+ }
22
+
23
+ export class WaterEffectImpl extends Effect {
24
+ constructor({ blendFunction = BlendFunction.NORMAL, factor = 0 } = {}) {
25
+ super('WaterEffect', WaterShader.fragmentShader, {
26
+ blendFunction,
27
+ attributes: EffectAttribute.CONVOLUTION,
28
+ uniforms: new Map<string, Uniform<number | number[]>>([['factor', new Uniform(factor)]]),
29
+ })
30
+ }
31
+ }
32
+
33
+ export const WaterEffect = /* @__PURE__ */ wrapEffect(WaterEffectImpl, {
34
+ blendFunction: BlendFunction.NORMAL,
35
+ })
package/src/index.ts CHANGED
@@ -1,40 +1,41 @@
1
- export * from './Selection'
2
- export * from './EffectComposer'
3
- export * from './util'
4
-
5
- export * from './effects/Autofocus'
6
- export * from './effects/LensFlare'
7
- export * from './effects/Bloom'
8
- export * from './effects/BrightnessContrast'
9
- export * from './effects/ChromaticAberration'
10
- export * from './effects/ColorAverage'
11
- export * from './effects/ColorDepth'
12
- export * from './effects/Depth'
13
- export * from './effects/DepthOfField'
14
- export * from './effects/DotScreen'
15
- export * from './effects/Glitch'
16
- export * from './effects/GodRays'
17
- export * from './effects/Grid'
18
- export * from './effects/HueSaturation'
19
- export * from './effects/Noise'
20
- export * from './effects/Outline'
21
- export * from './effects/Pixelation'
22
- export * from './effects/ScanlineEffect'
23
- export * from './effects/SelectiveBloom'
24
- export * from './effects/Sepia'
25
- export * from './effects/SSAO'
26
- export * from './effects/SMAA'
27
- export * from './effects/FXAA'
28
- export * from './effects/Ramp'
29
- export * from './effects/Texture'
30
- export * from './effects/ToneMapping'
31
- export * from './effects/Vignette'
32
- export * from './effects/ShockWave'
33
- export * from './effects/LUT'
34
- export * from './effects/TiltShift'
35
- export * from './effects/TiltShift2'
36
- export * from './effects/ASCII'
37
- export * from './effects/Water'
38
-
39
- // These are not effect passes
40
- export * from './effects/N8AO'
1
+ export * from './EffectComposer'
2
+ export * from './Selection'
3
+ export * from './util'
4
+ export * from './wrapEffect'
5
+
6
+ export * from './effects/ASCII'
7
+ export * from './effects/Autofocus'
8
+ export * from './effects/Bloom'
9
+ export * from './effects/BrightnessContrast'
10
+ export * from './effects/ChromaticAberration'
11
+ export * from './effects/ColorAverage'
12
+ export * from './effects/ColorDepth'
13
+ export * from './effects/Depth'
14
+ export * from './effects/DepthOfField'
15
+ export * from './effects/DotScreen'
16
+ export * from './effects/FXAA'
17
+ export * from './effects/Glitch'
18
+ export * from './effects/GodRays'
19
+ export * from './effects/Grid'
20
+ export * from './effects/HueSaturation'
21
+ export * from './effects/LensFlare'
22
+ export * from './effects/LUT'
23
+ export * from './effects/Noise'
24
+ export * from './effects/Outline'
25
+ export * from './effects/Pixelation'
26
+ export * from './effects/Ramp'
27
+ export * from './effects/ScanlineEffect'
28
+ export * from './effects/SelectiveBloom'
29
+ export * from './effects/Sepia'
30
+ export * from './effects/ShockWave'
31
+ export * from './effects/SMAA'
32
+ export * from './effects/SSAO'
33
+ export * from './effects/Texture'
34
+ export * from './effects/TiltShift'
35
+ export * from './effects/TiltShift2'
36
+ export * from './effects/ToneMapping'
37
+ export * from './effects/Vignette'
38
+ export * from './effects/Water'
39
+
40
+ // These are not effect passes
41
+ export * from './effects/N8AO'
@@ -0,0 +1,31 @@
1
+ import { ChromaticAberrationEffect, EffectComposer as EffectComposerImpl } from 'postprocessing'
2
+ import * as React from 'react'
3
+ import { Vector2 } from 'three'
4
+ import { describe, expect, it } from 'vitest'
5
+ import { EffectComposer } from '../EffectComposer'
6
+ import { ChromaticAberration } from '../effects/ChromaticAberration'
7
+ import { flush, root } from './test-utils'
8
+
9
+ describe('ChromaticAberration', () => {
10
+ it('coerces a tuple offset into a real Vector2 (#348)', async () => {
11
+ const ref = React.createRef<ChromaticAberrationEffect>()
12
+ const composerRef = React.createRef<EffectComposerImpl>()
13
+
14
+ await React.act(async () =>
15
+ root.render(
16
+ <EffectComposer ref={composerRef}>
17
+ <ChromaticAberration ref={ref} offset={[0.001, 0.0005]} />
18
+ </EffectComposer>
19
+ )
20
+ )
21
+
22
+ await flush()
23
+
24
+ expect(ref.current!.offset).toBeInstanceOf(Vector2)
25
+ expect(() => ref.current!.offset.set(0.002, 0.001)).not.toThrow()
26
+ expect(ref.current!.offset.x).toBeCloseTo(0.002)
27
+ expect(ref.current!.offset.y).toBeCloseTo(0.001)
28
+
29
+ await React.act(async () => root.render(null))
30
+ })
31
+ })