@react-three/postprocessing 3.0.4 → 3.1.0

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 (114) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +80 -81
  3. package/dist/EffectComposer.d.ts +14 -6
  4. package/dist/EffectGroup.d.ts +9 -0
  5. package/dist/Selection.d.ts +8 -8
  6. package/dist/createEffectComponent.d.ts +30 -0
  7. package/dist/effects/ASCII.d.ts +29 -7
  8. package/dist/effects/Autofocus.d.ts +8 -7
  9. package/dist/effects/Bloom.d.ts +10 -5
  10. package/dist/effects/BrightnessContrast.d.ts +15 -5
  11. package/dist/effects/ChromaticAberration.d.ts +30 -7
  12. package/dist/effects/ColorAverage.d.ts +7 -8
  13. package/dist/effects/ColorDepth.d.ts +8 -5
  14. package/dist/effects/Depth.d.ts +13 -5
  15. package/dist/effects/DepthOfField.d.ts +7 -18
  16. package/dist/effects/DotScreen.d.ts +15 -5
  17. package/dist/effects/FXAA.d.ts +11 -5
  18. package/dist/effects/Glitch.d.ts +17 -29
  19. package/dist/effects/GodRays.d.ts +7 -19
  20. package/dist/effects/Grid.d.ts +8 -8
  21. package/dist/effects/HueSaturation.d.ts +15 -5
  22. package/dist/effects/LUT.d.ts +4 -3
  23. package/dist/effects/LensFlare.d.ts +52 -11
  24. package/dist/effects/Noise.d.ts +8 -5
  25. package/dist/effects/Outline.d.ts +9 -25
  26. package/dist/effects/Pixelation.d.ts +3 -2
  27. package/dist/effects/Ramp.d.ts +58 -10
  28. package/dist/effects/SMAA.d.ts +10 -5
  29. package/dist/effects/SSAO.d.ts +7 -30
  30. package/dist/effects/ScanlineEffect.d.ts +13 -5
  31. package/dist/effects/SelectiveBloom.d.ts +5 -10
  32. package/dist/effects/Sepia.d.ts +13 -5
  33. package/dist/effects/ShockWave.d.ts +12 -5
  34. package/dist/effects/Texture.d.ts +7 -8
  35. package/dist/effects/TiltShift.d.ts +10 -5
  36. package/dist/effects/TiltShift2.d.ts +44 -8
  37. package/dist/effects/ToneMapping.d.ts +9 -7
  38. package/dist/effects/Vignette.d.ts +19 -5
  39. package/dist/effects/Water.d.ts +17 -5
  40. package/dist/index.d.ts +15 -11
  41. package/dist/index.js +1841 -45
  42. package/dist/index.js.map +1 -1
  43. package/dist/passes/DepthPicking.d.ts +11 -0
  44. package/dist/{effects → passes}/N8AO.d.ts +5 -2
  45. package/dist/util.d.ts +19 -17
  46. package/dist/wrapEffect.d.ts +12 -0
  47. package/package.json +74 -67
  48. package/src/EffectComposer.tsx +379 -200
  49. package/src/EffectGroup.tsx +74 -0
  50. package/src/Selection.tsx +86 -46
  51. package/src/createEffectComponent.tsx +71 -0
  52. package/src/effects/ASCII.tsx +183 -135
  53. package/src/effects/Autofocus.tsx +122 -153
  54. package/src/effects/Bloom.tsx +34 -6
  55. package/src/effects/BrightnessContrast.tsx +7 -4
  56. package/src/effects/ChromaticAberration.tsx +22 -5
  57. package/src/effects/ColorAverage.tsx +4 -15
  58. package/src/effects/ColorDepth.tsx +25 -4
  59. package/src/effects/Depth.tsx +6 -4
  60. package/src/effects/DepthOfField.tsx +109 -89
  61. package/src/effects/DotScreen.tsx +7 -4
  62. package/src/effects/FXAA.tsx +6 -4
  63. package/src/effects/Glitch.tsx +32 -40
  64. package/src/effects/GodRays.tsx +104 -16
  65. package/src/effects/Grid.tsx +27 -21
  66. package/src/effects/HueSaturation.tsx +7 -4
  67. package/src/effects/LUT.tsx +25 -26
  68. package/src/effects/LensFlare.tsx +765 -611
  69. package/src/effects/Noise.tsx +16 -4
  70. package/src/effects/Outline.tsx +84 -117
  71. package/src/effects/Pixelation.tsx +20 -15
  72. package/src/effects/Ramp.tsx +239 -150
  73. package/src/effects/SMAA.tsx +20 -4
  74. package/src/effects/SSAO.tsx +152 -41
  75. package/src/effects/ScanlineEffect.tsx +7 -7
  76. package/src/effects/SelectiveBloom.tsx +98 -126
  77. package/src/effects/Sepia.tsx +6 -4
  78. package/src/effects/ShockWave.tsx +32 -4
  79. package/src/effects/Texture.tsx +28 -23
  80. package/src/effects/TiltShift.tsx +32 -4
  81. package/src/effects/TiltShift2.tsx +156 -90
  82. package/src/effects/ToneMapping.tsx +19 -6
  83. package/src/effects/Vignette.tsx +7 -4
  84. package/src/effects/Water.tsx +50 -35
  85. package/src/index.ts +43 -40
  86. package/src/passes/DepthPicking.tsx +63 -0
  87. package/src/passes/N8AO.tsx +105 -0
  88. package/src/tests/Autofocus.test.tsx +38 -0
  89. package/src/tests/Bloom.test.tsx +76 -0
  90. package/src/tests/ChromaticAberration.test.tsx +81 -0
  91. package/src/tests/ColorDepth.test.tsx +71 -0
  92. package/src/tests/DepthOfField.test.tsx +130 -0
  93. package/src/tests/DepthPicking.test.tsx +250 -0
  94. package/src/tests/EffectComposer.test.tsx +1404 -0
  95. package/src/tests/EffectGroup.test.tsx +337 -0
  96. package/src/tests/Glitch.test.tsx +56 -0
  97. package/src/tests/GodRays.test.tsx +101 -0
  98. package/src/tests/Grid.test.tsx +34 -0
  99. package/src/tests/LUT.test.tsx +64 -0
  100. package/src/tests/N8AO.test.tsx +92 -0
  101. package/src/tests/Outline.test.tsx +211 -0
  102. package/src/tests/SSAO.test.tsx +140 -0
  103. package/src/tests/Selection.test.tsx +324 -0
  104. package/src/tests/SelectiveBloom.test.tsx +166 -0
  105. package/src/tests/ShockWave.test.tsx +95 -0
  106. package/src/tests/TiltShift.test.tsx +76 -0
  107. package/src/tests/createEffectComponent.test.tsx +286 -0
  108. package/src/tests/effects.smoke.test.tsx +238 -0
  109. package/src/tests/test-utils.tsx +96 -0
  110. package/src/tests/wrapEffect.test.tsx +209 -0
  111. package/src/util.tsx +221 -55
  112. package/src/wrapEffect.tsx +123 -0
  113. package/src/EffectComposer.test.tsx +0 -126
  114. package/src/effects/N8AO.tsx +0 -81
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2020 react-spring
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2020 react-spring
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,81 +1,80 @@
1
- # react-postprocessing
2
-
3
- [![Version](https://img.shields.io/npm/v/@react-three/postprocessing?style=flat&colorA=000000&colorB=000000)](https://www.npmjs.com/package/@react-three/postprocessing)
4
- [![Storybook](https://img.shields.io/static/v1?message=Storybook&style=flat&colorA=000000&colorB=000000&label=&logo=storybook&logoColor=ffffff)](https://pmndrs.github.io/react-postprocessing)
5
- [![Downloads](https://img.shields.io/npm/dt/@react-three/postprocessing.svg?style=flat&colorA=000000&colorB=000000)](https://www.npmjs.com/package/@react-three/postprocessing)
6
- [![Discord Shield](https://img.shields.io/discord/740090768164651008?style=flat&colorA=000000&colorB=000000&label=discord&logo=discord&logoColor=ffffff)](https://discord.gg/ZZjjNvJ)
7
- [![Open in GitHub Codespaces](https://img.shields.io/static/v1?&message=Open%20in%20%20Codespaces&style=flat&colorA=000000&colorB=000000&label=GitHub&logo=github&logoColor=ffffff)](https://github.com/codespaces/new?template_repository=pmndrs%2Freact-postprocessing)
8
-
9
- `react-postprocessing` is a
10
- [postprocessing](https://github.com/pmndrs/postprocessing) wrapper for
11
- [@react-three/fiber](https://github.com/pmndrs/react-three-fiber). This is not
12
- (yet) meant for complex orchestration of effects, but can save you
13
- [hundreds of LOC](https://twitter.com/0xca0a/status/1289501594698960897) for a
14
- straight forward effects-chain.
15
-
16
- ```bash
17
- npm install @react-three/postprocessing
18
- ```
19
-
20
- <p align="center">
21
- <a href="https://pqrpl.csb.app" target="_blank"><img width="274" src="bubbles.jpg" alt="Bubbles" /></a>
22
- <a href="https://5jgjz.csb.app" target="_blank"><img width="274" src="control.jpg" alt="Take Control" /></a>
23
- </p>
24
- <p align="middle">
25
- <i>These demos are real, you can click them! They contain the full code, too. 📦</i>
26
- </p>
27
-
28
- #### Why postprocessing and not three/examples/jsm/postprocessing?
29
-
30
- From
31
- [https://github.com/pmndrs/postprocessing](https://github.com/pmndrs/postprocessing#performance)
32
-
33
- > This library provides an EffectPass which automatically organizes and merges
34
- > any given combination of effects. This minimizes the amount of render
35
- > operations and makes it possible to combine many effects without the
36
- > performance penalties of traditional pass chaining. Additionally, every effect
37
- > can choose its own blend function.
38
- >
39
- > All fullscreen render operations also use a single triangle that fills the
40
- > screen. Compared to using a quad, this approach harmonizes with modern GPU
41
- > rasterization patterns and eliminates unnecessary fragment calculations along
42
- > the screen diagonal. This is especially beneficial for GPGPU passes and
43
- > effects that use complex fragment shaders.
44
-
45
- Postprocessing also supports gamma correction out of the box, as well as WebGL2
46
- MSAA (multi sample anti aliasing), which is react-postprocessing's default, you
47
- get high performance crisp results w/o jagged edges.
48
-
49
- #### What does it look like?
50
-
51
- Here's an example combining a couple of effects
52
- ([live demo](https://codesandbox.io/s/react-postprocessing-dof-blob-pqrpl?)).
53
-
54
- <a href="https://codesandbox.io/s/react-postprocessing-dof-blob-pqrpl?" target="_blank" rel="noopener">
55
- <img src="bubbles.jpg" alt="Bubbles Demo" />
56
- </a>
57
-
58
- ```jsx
59
- import React from 'react'
60
- import { Bloom, DepthOfField, EffectComposer, Noise, Vignette } from '@react-three/postprocessing'
61
- import { Canvas } from '@react-three/fiber'
62
-
63
- function App() {
64
- return (
65
- <Canvas>
66
- {/* Your regular scene contents go here, like always ... */}
67
- <EffectComposer>
68
- <DepthOfField focusDistance={0} focalLength={0.02} bokehScale={2} height={480} />
69
- <Bloom luminanceThreshold={0} luminanceSmoothing={0.9} height={300} />
70
- <Noise opacity={0.02} />
71
- <Vignette eskil={false} offset={0.1} darkness={1.1} />
72
- </EffectComposer>
73
- </Canvas>
74
- )
75
- }
76
- ```
77
-
78
- ## Documentation
79
-
80
- - [react-postprocessing docs](https://docs.pmnd.rs/react-postprocessing)
81
- - [postprocessing docs](https://pmndrs.github.io/postprocessing/public/docs/)
1
+ # react-postprocessing
2
+
3
+ [![Version](https://img.shields.io/npm/v/@react-three/postprocessing?style=flat&colorA=000000&colorB=000000)](https://www.npmjs.com/package/@react-three/postprocessing)
4
+ [![Docs](https://img.shields.io/static/v1?message=Docs&style=flat&colorA=000000&colorB=000000&label=&logo=googledocs&logoColor=ffffff)](https://pmndrs.github.io/react-postprocessing)
5
+ [![Downloads](https://img.shields.io/npm/dt/@react-three/postprocessing.svg?style=flat&colorA=000000&colorB=000000)](https://www.npmjs.com/package/@react-three/postprocessing)
6
+ [![Discord Shield](https://img.shields.io/discord/740090768164651008?style=flat&colorA=000000&colorB=000000&label=discord&logo=discord&logoColor=ffffff)](https://discord.gg/ZZjjNvJ)
7
+ [![Open in GitHub Codespaces](https://img.shields.io/static/v1?&message=Open%20in%20%20Codespaces&style=flat&colorA=000000&colorB=000000&label=GitHub&logo=github&logoColor=ffffff)](https://github.com/codespaces/new?template_repository=pmndrs%2Freact-postprocessing)
8
+
9
+ `react-postprocessing` is a
10
+ [postprocessing](https://github.com/pmndrs/postprocessing) wrapper for
11
+ [@react-three/fiber](https://github.com/pmndrs/react-three-fiber). This is not
12
+ (yet) meant for complex orchestration of effects, but can save you
13
+ [hundreds of LOC](https://twitter.com/0xca0a/status/1289501594698960897) for a
14
+ straight forward effects-chain.
15
+
16
+ ```bash
17
+ npm install @react-three/postprocessing
18
+ ```
19
+
20
+ <p align="center">
21
+ <a href="https://pmndrs.github.io/examples/bubbles" target="_blank"><img width="274" src="https://pmndrs.github.io/examples/bubbles/thumbnail.webp" alt="Bubbles" /></a>
22
+ <a href="https://pmndrs.github.io/examples/take-control" target="_blank"><img width="274" src="https://pmndrs.github.io/examples/take-control/thumbnail.webp" alt="Take Control" /></a>
23
+ </p>
24
+ <p align="middle">
25
+ <i>These demos are real, you can click them! They contain the full code, too. 📦</i>
26
+ </p>
27
+
28
+ #### Why postprocessing and not three/examples/jsm/postprocessing?
29
+
30
+ From
31
+ [https://github.com/pmndrs/postprocessing](https://github.com/pmndrs/postprocessing#performance)
32
+
33
+ > This library provides an EffectPass which automatically organizes and merges
34
+ > any given combination of effects. This minimizes the amount of render
35
+ > operations and makes it possible to combine many effects without the
36
+ > performance penalties of traditional pass chaining. Additionally, every effect
37
+ > can choose its own blend function.
38
+ >
39
+ > All fullscreen render operations also use a single triangle that fills the
40
+ > screen. Compared to using a quad, this approach harmonizes with modern GPU
41
+ > rasterization patterns and eliminates unnecessary fragment calculations along
42
+ > the screen diagonal. This is especially beneficial for GPGPU passes and
43
+ > effects that use complex fragment shaders.
44
+
45
+ Postprocessing also supports gamma correction out of the box, as well as WebGL2
46
+ MSAA (multi sample anti aliasing), which is react-postprocessing's default, you
47
+ get high performance crisp results w/o jagged edges.
48
+
49
+ #### What does it look like?
50
+
51
+ Here's an example combining a couple of effects
52
+ ([live demo](https://pmndrs.github.io/examples/bubbles)).
53
+
54
+ <a href="https://pmndrs.github.io/examples/bubbles" target="_blank" rel="noopener">
55
+ <img src="https://pmndrs.github.io/examples/bubbles/thumbnail.webp" alt="Bubbles Demo" />
56
+ </a>
57
+
58
+ ```jsx
59
+ import { Bloom, DepthOfField, EffectComposer, Noise, Vignette } from '@react-three/postprocessing'
60
+ import { Canvas } from '@react-three/fiber'
61
+
62
+ function App() {
63
+ return (
64
+ <Canvas>
65
+ {/* Your regular scene contents go here, like always ... */}
66
+ <EffectComposer>
67
+ <DepthOfField focusDistance={0} focalLength={0.02} bokehScale={2} height={480} />
68
+ <Bloom luminanceThreshold={0} luminanceSmoothing={0.9} height={300} />
69
+ <Noise opacity={0.02} />
70
+ <Vignette eskil={false} offset={0.1} darkness={1.1} />
71
+ </EffectComposer>
72
+ </Canvas>
73
+ )
74
+ }
75
+ ```
76
+
77
+ ## Documentation
78
+
79
+ - [react-postprocessing docs](https://docs.pmnd.rs/react-postprocessing)
80
+ - [postprocessing docs](https://pmndrs.github.io/postprocessing/public/docs/)
@@ -1,27 +1,35 @@
1
- import type { TextureDataType, Camera, Scene } from 'three';
2
- import { type JSX } from 'react';
3
- import { EffectComposer as EffectComposerImpl, NormalPass, DepthDownsamplingPass } from 'postprocessing';
1
+ import { DepthDownsamplingPass, EffectComposer as EffectComposerImpl, NormalPass, Pass } from 'postprocessing';
2
+ import { type ReactNode, type Ref } from 'react';
3
+ import type { Camera, Scene, TextureDataType } from 'three';
4
4
  export declare const EffectComposerContext: import("react").Context<{
5
5
  composer: EffectComposerImpl;
6
6
  normalPass: NormalPass | null;
7
7
  downSamplingPass: DepthDownsamplingPass | null;
8
8
  camera: Camera;
9
9
  scene: Scene;
10
- resolutionScale?: number | undefined;
10
+ resolutionScale?: number;
11
+ requestRebuild: () => void;
12
+ autoClear: boolean;
11
13
  }>;
12
14
  export type EffectComposerProps = {
13
15
  enabled?: boolean;
14
- children: JSX.Element | JSX.Element[];
16
+ children: ReactNode;
15
17
  depthBuffer?: boolean;
16
18
  /** Only used for SSGI currently, leave it disabled for everything else unless it's needed */
17
19
  enableNormalPass?: boolean;
18
20
  stencilBuffer?: boolean;
19
21
  autoClear?: boolean;
22
+ autoRenderToScreen?: boolean;
20
23
  resolutionScale?: number;
21
24
  multisampling?: number;
22
25
  frameBufferType?: TextureDataType;
23
26
  renderPriority?: number;
24
27
  camera?: Camera;
25
28
  scene?: Scene;
29
+ renderPass?: (scene: Scene, camera: Camera) => Pass;
30
+ mergeMode?: 'auto' | 'all' | 'none';
31
+ ref?: Ref<EffectComposerImpl>;
26
32
  };
27
- export declare const EffectComposer: import("react").NamedExoticComponent<EffectComposerProps & import("react").RefAttributes<EffectComposerImpl>>;
33
+ export declare const groupPasses: WeakSet<Pass>;
34
+ export declare function disposePassWithoutEffects(pass: Pass): void;
35
+ export declare const EffectComposer: import("react").MemoExoticComponent<({ children, camera: _camera, scene: _scene, resolutionScale, enabled, renderPriority, autoClear, autoRenderToScreen, depthBuffer, enableNormalPass, stencilBuffer, multisampling, frameBufferType, renderPass, mergeMode, ref, }: EffectComposerProps) => import("react").JSX.Element | null>;
@@ -0,0 +1,9 @@
1
+ import { EffectPass } from 'postprocessing';
2
+ import { type ReactNode, type Ref } from 'react';
3
+ export type EffectGroupProps = {
4
+ /** Toggles the whole pass, like Pass.enabled in vanilla postprocessing - cheap, no reconstruction. */
5
+ enabled?: boolean;
6
+ children: ReactNode;
7
+ ref?: Ref<EffectPass>;
8
+ };
9
+ export declare function EffectGroup({ enabled, children, ref }: EffectGroupProps): import("react").JSX.Element;
@@ -1,17 +1,17 @@
1
- import * as THREE from 'three';
2
- import React from 'react';
3
1
  import { type ThreeElements } from '@react-three/fiber';
2
+ import { type Dispatch, type ReactNode, type SetStateAction } from 'react';
3
+ import { type Object3D } from 'three';
4
4
  export type Api = {
5
- selected: THREE.Object3D[];
6
- select: React.Dispatch<React.SetStateAction<THREE.Object3D[]>>;
5
+ selected: Object3D[];
6
+ select: Dispatch<SetStateAction<Object3D[]>>;
7
7
  enabled: boolean;
8
8
  };
9
9
  export type SelectApi = Omit<ThreeElements['group'], 'ref'> & {
10
10
  enabled?: boolean;
11
11
  };
12
- export declare const selectionContext: React.Context<Api | null>;
12
+ export declare const selectionContext: import("react").Context<Api | null>;
13
13
  export declare function Selection({ children, enabled }: {
14
14
  enabled?: boolean;
15
- children: React.ReactNode;
16
- }): import("react/jsx-runtime").JSX.Element;
17
- export declare function Select({ enabled, children, ...props }: SelectApi): import("react/jsx-runtime").JSX.Element;
15
+ children: ReactNode;
16
+ }): import("react").JSX.Element;
17
+ export declare function Select({ enabled, children, ...props }: SelectApi): import("react").JSX.Element;
@@ -0,0 +1,30 @@
1
+ import type { BlendFunction, Effect, Pass } from 'postprocessing';
2
+ import type { JSX, Ref } from 'react';
3
+ export type EffectConstructor = new (...args: any[]) => Effect | Pass;
4
+ export type EffectOptions<T extends EffectConstructor> = NonNullable<ConstructorParameters<T>[0]>;
5
+ /**
6
+ * Registers `effect` as a JSX intrinsic once per class and returns a
7
+ * component that renders it. Everything else - construction from `args`,
8
+ * live prop application (with the same Color/Vector coercion and reset-
9
+ * to-default on removal any r3f element gets), disposal - is r3f's own
10
+ * reconciler, same rules as `<mesh>`/`<meshStandardMaterial>`. Only fits
11
+ * effects whose constructor works with zero arguments (`new Effect()`) -
12
+ * r3f's own reset-on-removal falls back to `0` otherwise, which is wrong
13
+ * for anything non-numeric. Effects that require e.g. scene/camera stay
14
+ * hand-rolled (see Outline.tsx, SelectiveBloom.tsx, ShockWave.tsx).
15
+ *
16
+ * `blendFunction`/`opacity` are pierced through to `blendMode-*` - every
17
+ * `Effect` has them on a nested `blendMode`, not on the effect itself, so a
18
+ * plain top-level prop would silently land on a stray, unread property.
19
+ * Applied via useLiveDefaults, not as plain JSX props: BlendMode's own
20
+ * constructor requires `blendFunction` (no default), so its constructor
21
+ * length isn't 0 either, and r3f's native reset-on-removal falls back to
22
+ * `changedProps[prop] = 0` - which is BlendFunction.SKIP, not a merely
23
+ * "wrong" blend function but one that hides the effect entirely.
24
+ */
25
+ export declare function createEffectComponent<T extends EffectConstructor, P extends object>(effect: T): (props: P & {
26
+ blendFunction?: BlendFunction;
27
+ opacity?: number;
28
+ args?: ConstructorParameters<T>;
29
+ ref?: Ref<InstanceType<T>>;
30
+ }) => JSX.Element;
@@ -1,18 +1,40 @@
1
- /// <reference types="react" />
2
- import { Texture } from 'three';
3
1
  import { Effect } from 'postprocessing';
4
- interface IASCIIEffectProps {
2
+ import type { Ref } from 'react';
3
+ import { Color, type ColorRepresentation, Texture } from 'three';
4
+ export type ASCIIProps = {
5
5
  font?: string;
6
6
  characters?: string;
7
7
  fontSize?: number;
8
8
  cellSize?: number;
9
- color?: string;
9
+ color?: ColorRepresentation;
10
10
  invert?: boolean;
11
- }
11
+ ref?: Ref<ASCIIEffect>;
12
+ };
12
13
  declare class ASCIIEffect extends Effect {
13
- constructor({ font, characters, fontSize, cellSize, color, invert, }?: IASCIIEffectProps);
14
+ private _font;
15
+ private _characters;
16
+ private _fontSize;
17
+ constructor({ font, characters, fontSize, cellSize, color, invert, }?: Omit<ASCIIProps, 'ref'>);
18
+ get cellSize(): number;
19
+ set cellSize(value: number);
20
+ get invert(): boolean;
21
+ set invert(value: boolean);
22
+ get color(): Color;
23
+ set color(value: ColorRepresentation);
24
+ get font(): string;
25
+ set font(value: string);
26
+ get characters(): string;
27
+ set characters(value: string);
28
+ get fontSize(): number;
29
+ set fontSize(value: number);
30
+ private updateCharactersTexture;
14
31
  /** Draws the characters on a Canvas and returns a texture */
15
32
  createCharactersTexture(characters: string, font: string, fontSize: number): Texture;
16
33
  }
17
- export declare const ASCII: import("react").ForwardRefExoticComponent<IASCIIEffectProps & import("react").RefAttributes<ASCIIEffect>>;
34
+ export declare const ASCII: (props: ASCIIProps & {
35
+ blendFunction?: import("postprocessing").BlendFunction;
36
+ opacity?: number;
37
+ args?: [(Omit<ASCIIProps, "ref"> | undefined)?] | undefined;
38
+ ref?: Ref<ASCIIEffect> | undefined;
39
+ }) => import("react").JSX.Element;
18
40
  export {};
@@ -1,10 +1,10 @@
1
- import * as THREE from 'three';
2
- import React, { RefObject } from 'react';
3
- import { type Vector3 } from '@react-three/fiber';
1
+ import { type Vector3 as R3FVector3 } from '@react-three/fiber';
4
2
  import { DepthOfFieldEffect } from 'postprocessing';
3
+ import { Ref, type ComponentProps, type RefObject } from 'react';
4
+ import { Vector3 } from 'three';
5
5
  import { DepthOfField } from './DepthOfField';
6
- export type AutofocusProps = React.ComponentProps<typeof DepthOfField> & {
7
- target?: Vector3;
6
+ export type AutofocusProps = Omit<ComponentProps<typeof DepthOfField>, 'ref'> & {
7
+ target?: R3FVector3;
8
8
  /** should the target follow the pointer */
9
9
  mouse?: boolean;
10
10
  /** size of the debug green point */
@@ -13,10 +13,11 @@ export type AutofocusProps = React.ComponentProps<typeof DepthOfField> & {
13
13
  manual?: boolean;
14
14
  /** approximate time to reach the target */
15
15
  smoothTime?: number;
16
+ ref?: Ref<AutofocusApi>;
16
17
  };
17
18
  export type AutofocusApi = {
18
19
  dofRef: RefObject<DepthOfFieldEffect | null>;
19
- hitpoint: THREE.Vector3;
20
+ hitpoint: Vector3;
20
21
  update: (delta: number, updateTarget: boolean) => void;
21
22
  };
22
- export declare const Autofocus: React.ForwardRefExoticComponent<Omit<AutofocusProps, "ref"> & React.RefAttributes<AutofocusApi>>;
23
+ export declare function Autofocus({ target, mouse: followMouse, debug, manual, smoothTime, ref, ...props }: AutofocusProps): import("react").JSX.Element;
@@ -1,5 +1,10 @@
1
- export declare const Bloom: ({ blendFunction, opacity, ...props }: {
2
- [x: string]: any;
3
- blendFunction?: any;
4
- opacity?: any;
5
- }) => import("react/jsx-runtime").JSX.Element;
1
+ import { BloomEffect } from 'postprocessing';
2
+ import type { Ref } from 'react';
3
+ import { type EffectOptions } from '../createEffectComponent';
4
+ type BloomOptions = EffectOptions<typeof BloomEffect>;
5
+ export type BloomProps = BloomOptions & {
6
+ opacity?: number;
7
+ ref?: Ref<BloomEffect>;
8
+ };
9
+ export declare function Bloom({ blendFunction, luminanceThreshold, luminanceSmoothing, mipmapBlur, radius, levels, resolutionScale, resolutionX, resolutionY, ...liveProps }: BloomProps): import("react").JSX.Element;
10
+ export {};
@@ -1,5 +1,15 @@
1
- export declare const BrightnessContrast: ({ blendFunction, opacity, ...props }: {
2
- [x: string]: any;
3
- blendFunction?: any;
4
- opacity?: any;
5
- }) => import("react/jsx-runtime").JSX.Element;
1
+ import { BrightnessContrastEffect } from 'postprocessing';
2
+ export declare const BrightnessContrast: (props: {
3
+ blendFunction?: import("postprocessing").BlendFunction;
4
+ brightness?: number;
5
+ contrast?: number;
6
+ } & {
7
+ blendFunction?: import("postprocessing").BlendFunction;
8
+ opacity?: number;
9
+ args?: [({
10
+ blendFunction?: import("postprocessing").BlendFunction;
11
+ brightness?: number;
12
+ contrast?: number;
13
+ } | undefined)?] | undefined;
14
+ ref?: import("react").Ref<BrightnessContrastEffect> | undefined;
15
+ }) => import("react").JSX.Element;
@@ -1,8 +1,31 @@
1
+ import type { ReactThreeFiber } from '@react-three/fiber';
1
2
  import { ChromaticAberrationEffect } from 'postprocessing';
2
- import { type EffectProps } from '../util';
3
- export type ChromaticAberrationProps = EffectProps<typeof ChromaticAberrationEffect>;
4
- export declare const ChromaticAberration: ({ blendFunction, opacity, ...props }: {
5
- [x: string]: any;
6
- blendFunction?: any;
7
- opacity?: any;
8
- }) => import("react/jsx-runtime").JSX.Element;
3
+ import type { Ref } from 'react';
4
+ import { type EffectOptions } from '../createEffectComponent';
5
+ export type ChromaticAberrationProps = Omit<EffectOptions<typeof ChromaticAberrationEffect>, 'offset' | 'radialModulation' | 'modulationOffset'> & {
6
+ offset?: ReactThreeFiber.Vector2;
7
+ radialModulation?: boolean;
8
+ modulationOffset?: number;
9
+ ref?: Ref<ChromaticAberrationEffect>;
10
+ };
11
+ export declare const ChromaticAberration: (props: Omit<{
12
+ blendFunction?: import("postprocessing").BlendFunction;
13
+ offset?: import("three").Vector2;
14
+ radialModulation: boolean;
15
+ modulationOffset: number;
16
+ }, "offset" | "radialModulation" | "modulationOffset"> & {
17
+ offset?: ReactThreeFiber.Vector2;
18
+ radialModulation?: boolean;
19
+ modulationOffset?: number;
20
+ ref?: Ref<ChromaticAberrationEffect>;
21
+ } & {
22
+ blendFunction?: import("postprocessing").BlendFunction;
23
+ opacity?: number;
24
+ args?: [({
25
+ blendFunction?: import("postprocessing").BlendFunction;
26
+ offset?: import("three").Vector2;
27
+ radialModulation: boolean;
28
+ modulationOffset: number;
29
+ } | undefined)?] | undefined;
30
+ ref?: Ref<ChromaticAberrationEffect> | undefined;
31
+ }) => import("react").JSX.Element;
@@ -1,8 +1,7 @@
1
- import { ColorAverageEffect, BlendFunction } from 'postprocessing';
2
- import React from 'react';
3
- export type ColorAverageProps = Partial<{
4
- blendFunction: BlendFunction;
5
- }>;
6
- export declare const ColorAverage: React.ForwardRefExoticComponent<Partial<{
7
- blendFunction: BlendFunction;
8
- }> & React.RefAttributes<ColorAverageEffect>>;
1
+ import { ColorAverageEffect } from 'postprocessing';
2
+ export declare const ColorAverage: (props: object & {
3
+ blendFunction?: import("postprocessing").BlendFunction;
4
+ opacity?: number;
5
+ args?: [blendFunction?: import("postprocessing").BlendFunction | undefined] | undefined;
6
+ ref?: import("react").Ref<ColorAverageEffect> | undefined;
7
+ }) => import("react").JSX.Element;
@@ -1,5 +1,8 @@
1
- export declare const ColorDepth: ({ blendFunction, opacity, ...props }: {
2
- [x: string]: any;
3
- blendFunction?: any;
4
- opacity?: any;
5
- }) => import("react/jsx-runtime").JSX.Element;
1
+ import { ColorDepthEffect } from 'postprocessing';
2
+ import type { Ref } from 'react';
3
+ import { type EffectOptions } from '../createEffectComponent';
4
+ export type ColorDepthProps = EffectOptions<typeof ColorDepthEffect> & {
5
+ opacity?: number;
6
+ ref?: Ref<ColorDepthEffect>;
7
+ };
8
+ export declare function ColorDepth({ bits, ...props }: ColorDepthProps): import("react").JSX.Element;
@@ -1,5 +1,13 @@
1
- export declare const Depth: ({ blendFunction, opacity, ...props }: {
2
- [x: string]: any;
3
- blendFunction?: any;
4
- opacity?: any;
5
- }) => import("react/jsx-runtime").JSX.Element;
1
+ import { DepthEffect } from 'postprocessing';
2
+ export declare const Depth: (props: {
3
+ blendFunction?: import("postprocessing").BlendFunction;
4
+ inverted?: boolean;
5
+ } & {
6
+ blendFunction?: import("postprocessing").BlendFunction;
7
+ opacity?: number;
8
+ args?: [({
9
+ blendFunction?: import("postprocessing").BlendFunction;
10
+ inverted?: boolean;
11
+ } | undefined)?] | undefined;
12
+ ref?: import("react").Ref<DepthEffect> | undefined;
13
+ }) => import("react").JSX.Element;
@@ -1,25 +1,14 @@
1
- /// <reference types="react" />
1
+ import type { ReactThreeFiber } from '@react-three/fiber';
2
2
  import { DepthOfFieldEffect } from 'postprocessing';
3
- import { ReactThreeFiber } from '@react-three/fiber';
4
- import { type Texture, Vector3 } from 'three';
5
- export declare const DepthOfField: import("react").ForwardRefExoticComponent<{
6
- blendFunction?: import("postprocessing").BlendFunction | undefined;
7
- worldFocusDistance?: number | undefined;
8
- worldFocusRange?: number | undefined;
9
- focusDistance?: number | undefined;
10
- focalLength?: number | undefined;
11
- focusRange?: number | undefined;
12
- bokehScale?: number | undefined;
13
- resolutionScale?: number | undefined;
14
- resolutionX?: number | undefined;
15
- resolutionY?: number | undefined;
16
- width?: number | undefined;
17
- height?: number | undefined;
18
- } & Partial<{
3
+ import type { Ref } from 'react';
4
+ import { type Texture } from 'three';
5
+ export type DepthOfFieldProps = ConstructorParameters<typeof DepthOfFieldEffect>[1] & Partial<{
6
+ ref: Ref<DepthOfFieldEffect>;
19
7
  target: ReactThreeFiber.Vector3;
20
8
  depthTexture: {
21
9
  texture: Texture;
22
10
  packing: number;
23
11
  };
24
12
  blur: number;
25
- }> & import("react").RefAttributes<DepthOfFieldEffect>>;
13
+ }>;
14
+ export declare function DepthOfField({ ref, blendFunction, worldFocusDistance, worldFocusRange, focusDistance, focusRange, focalLength, bokehScale, resolutionScale, resolutionX, resolutionY, width, height, target, depthTexture, ...props }: DepthOfFieldProps): import("react").JSX.Element;
@@ -1,5 +1,15 @@
1
- export declare const DotScreen: ({ blendFunction, opacity, ...props }: {
2
- [x: string]: any;
3
- blendFunction?: any;
4
- opacity?: any;
5
- }) => import("react/jsx-runtime").JSX.Element;
1
+ import { DotScreenEffect } from 'postprocessing';
2
+ export declare const DotScreen: (props: {
3
+ blendFunction?: import("postprocessing").BlendFunction;
4
+ angle?: number;
5
+ scale?: number;
6
+ } & {
7
+ blendFunction?: import("postprocessing").BlendFunction;
8
+ opacity?: number;
9
+ args?: [({
10
+ blendFunction?: import("postprocessing").BlendFunction;
11
+ angle?: number;
12
+ scale?: number;
13
+ } | undefined)?] | undefined;
14
+ ref?: import("react").Ref<DotScreenEffect> | undefined;
15
+ }) => import("react").JSX.Element;
@@ -1,5 +1,11 @@
1
- export declare const FXAA: ({ blendFunction, opacity, ...props }: {
2
- [x: string]: any;
3
- blendFunction?: any;
4
- opacity?: any;
5
- }) => import("react/jsx-runtime").JSX.Element;
1
+ import { FXAAEffect } from 'postprocessing';
2
+ export declare const FXAA: (props: {
3
+ blendFunction?: import("postprocessing").BlendFunction;
4
+ } & {
5
+ blendFunction?: import("postprocessing").BlendFunction;
6
+ opacity?: number;
7
+ args?: [({
8
+ blendFunction?: import("postprocessing").BlendFunction;
9
+ } | undefined)?] | undefined;
10
+ ref?: import("react").Ref<FXAAEffect> | undefined;
11
+ }) => import("react").JSX.Element;