@react-three/postprocessing 2.2.5 → 2.3.1
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/README.md +2 -0
- package/dist/EffectComposer.d.ts +4 -1
- package/dist/effects/Glitch.d.ts +2 -2
- package/dist/index.cjs.js +52 -23
- package/dist/index.js +52 -25
- package/package.json +29 -29
package/README.md
CHANGED
|
@@ -72,6 +72,8 @@ The EffectComposer must wrap all your effects. It will manage them for you.
|
|
|
72
72
|
autoClear?: boolean
|
|
73
73
|
multisampling?: number
|
|
74
74
|
frameBufferType?: TextureDataType
|
|
75
|
+
/** For effects that support DepthDownsamplingPass */
|
|
76
|
+
resolutionScale?: number
|
|
75
77
|
renderPriority?: number
|
|
76
78
|
camera?: THREE.Camera
|
|
77
79
|
scene?: THREE.Scene
|
package/dist/EffectComposer.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { EffectComposer as EffectComposerImpl, NormalPass } from 'postprocessing';
|
|
3
|
+
import { EffectComposer as EffectComposerImpl, NormalPass, DepthDownsamplingPass } from 'postprocessing';
|
|
4
4
|
import { TextureDataType } from 'three';
|
|
5
5
|
export declare const EffectComposerContext: React.Context<{
|
|
6
6
|
composer: EffectComposerImpl;
|
|
7
7
|
normalPass: NormalPass | null;
|
|
8
|
+
downSamplingPass: DepthDownsamplingPass | null;
|
|
8
9
|
camera: THREE.Camera;
|
|
9
10
|
scene: THREE.Scene;
|
|
11
|
+
resolutionScale?: number;
|
|
10
12
|
}>;
|
|
11
13
|
export declare type EffectComposerProps = {
|
|
12
14
|
enabled?: boolean;
|
|
@@ -15,6 +17,7 @@ export declare type EffectComposerProps = {
|
|
|
15
17
|
disableNormalPass?: boolean;
|
|
16
18
|
stencilBuffer?: boolean;
|
|
17
19
|
autoClear?: boolean;
|
|
20
|
+
resolutionScale?: number;
|
|
18
21
|
multisampling?: number;
|
|
19
22
|
frameBufferType?: TextureDataType;
|
|
20
23
|
renderPriority?: number;
|
package/dist/effects/Glitch.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { GlitchEffect, GlitchMode } from 'postprocessing';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { ReactThreeFiber } from '@react-three/fiber';
|
|
4
4
|
export declare type GlitchProps = ConstructorParameters<typeof GlitchEffect>[0] & Partial<{
|
|
5
|
-
mode: typeof GlitchMode;
|
|
5
|
+
mode: typeof GlitchMode[keyof typeof GlitchMode];
|
|
6
6
|
active: boolean;
|
|
7
7
|
delay: ReactThreeFiber.Vector2;
|
|
8
8
|
duration: ReactThreeFiber.Vector2;
|
|
@@ -20,7 +20,7 @@ export declare const Glitch: React.ForwardRefExoticComponent<{
|
|
|
20
20
|
columns?: number;
|
|
21
21
|
ratio?: number;
|
|
22
22
|
} & Partial<{
|
|
23
|
-
mode: typeof GlitchMode;
|
|
23
|
+
mode: typeof GlitchMode[keyof typeof GlitchMode];
|
|
24
24
|
active: boolean;
|
|
25
25
|
delay: ReactThreeFiber.Vector2;
|
|
26
26
|
duration: ReactThreeFiber.Vector2;
|
package/dist/index.cjs.js
CHANGED
|
@@ -131,6 +131,7 @@ var EffectComposer = /*#__PURE__*/React__default["default"].memo( /*#__PURE__*/R
|
|
|
131
131
|
var children = _ref.children,
|
|
132
132
|
camera = _ref.camera,
|
|
133
133
|
scene = _ref.scene,
|
|
134
|
+
resolutionScale = _ref.resolutionScale,
|
|
134
135
|
_ref$enabled = _ref.enabled,
|
|
135
136
|
enabled = _ref$enabled === void 0 ? true : _ref$enabled,
|
|
136
137
|
_ref$renderPriority = _ref.renderPriority,
|
|
@@ -155,11 +156,13 @@ var EffectComposer = /*#__PURE__*/React__default["default"].memo( /*#__PURE__*/R
|
|
|
155
156
|
camera = camera || defaultCamera;
|
|
156
157
|
|
|
157
158
|
var _useMemo = React.useMemo(function () {
|
|
159
|
+
var webGL2Available = threeStdlib.isWebGL2Available(); // Initialize composer
|
|
160
|
+
|
|
158
161
|
// Initialize composer
|
|
159
162
|
var effectComposer = new postprocessing.EffectComposer(gl, {
|
|
160
163
|
depthBuffer: depthBuffer,
|
|
161
164
|
stencilBuffer: stencilBuffer,
|
|
162
|
-
multisampling: multisampling > 0 &&
|
|
165
|
+
multisampling: multisampling > 0 && webGL2Available ? multisampling : 0,
|
|
163
166
|
frameBufferType: frameBufferType
|
|
164
167
|
}); // Add render pass
|
|
165
168
|
|
|
@@ -167,19 +170,31 @@ var EffectComposer = /*#__PURE__*/React__default["default"].memo( /*#__PURE__*/R
|
|
|
167
170
|
effectComposer.addPass(new postprocessing.RenderPass(scene, camera)); // Create normal pass
|
|
168
171
|
|
|
169
172
|
// Create normal pass
|
|
170
|
-
var
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
if (
|
|
174
|
-
|
|
173
|
+
var downSamplingPass = null;
|
|
174
|
+
var normalPass = null;
|
|
175
|
+
|
|
176
|
+
if (!disableNormalPass) {
|
|
177
|
+
normalPass = new postprocessing.NormalPass(scene, camera);
|
|
178
|
+
normalPass.enabled = false;
|
|
179
|
+
effectComposer.addPass(normalPass);
|
|
180
|
+
|
|
181
|
+
if (resolutionScale !== undefined && webGL2Available) {
|
|
182
|
+
downSamplingPass = new postprocessing.DepthDownsamplingPass({
|
|
183
|
+
normalBuffer: normalPass.texture,
|
|
184
|
+
resolutionScale: resolutionScale
|
|
185
|
+
});
|
|
186
|
+
downSamplingPass.enabled = false;
|
|
187
|
+
effectComposer.addPass(downSamplingPass);
|
|
188
|
+
}
|
|
175
189
|
}
|
|
176
190
|
|
|
177
|
-
return [effectComposer,
|
|
178
|
-
}, [camera, gl, depthBuffer, stencilBuffer, multisampling, frameBufferType, scene, disableNormalPass]),
|
|
191
|
+
return [effectComposer, normalPass, downSamplingPass];
|
|
192
|
+
}, [camera, gl, depthBuffer, stencilBuffer, multisampling, frameBufferType, scene, disableNormalPass, resolutionScale]),
|
|
179
193
|
composer = _useMemo[0],
|
|
180
|
-
normalPass = _useMemo[1]
|
|
194
|
+
normalPass = _useMemo[1],
|
|
195
|
+
downSamplingPass = _useMemo[2];
|
|
181
196
|
|
|
182
|
-
React.
|
|
197
|
+
React.useEffect(function () {
|
|
183
198
|
return composer == null ? void 0 : composer.setSize(size.width, size.height);
|
|
184
199
|
}, [composer, size]);
|
|
185
200
|
fiber.useFrame(function (_, delta) {
|
|
@@ -194,25 +209,29 @@ var EffectComposer = /*#__PURE__*/React__default["default"].memo( /*#__PURE__*/R
|
|
|
194
209
|
|
|
195
210
|
if (group.current && group.current.__r3f && composer) {
|
|
196
211
|
effectPass = _construct__default["default"](postprocessing.EffectPass, [camera].concat(group.current.__r3f.objects));
|
|
197
|
-
composer.addPass(effectPass);
|
|
198
212
|
effectPass.renderToScreen = true;
|
|
213
|
+
composer.addPass(effectPass);
|
|
199
214
|
if (normalPass) normalPass.enabled = true;
|
|
215
|
+
if (downSamplingPass) downSamplingPass.enabled = true;
|
|
200
216
|
}
|
|
201
217
|
|
|
202
218
|
return function () {
|
|
203
219
|
if (effectPass) composer == null ? void 0 : composer.removePass(effectPass);
|
|
204
220
|
if (normalPass) normalPass.enabled = false;
|
|
221
|
+
if (downSamplingPass) downSamplingPass.enabled = false;
|
|
205
222
|
};
|
|
206
|
-
}, [composer, children, camera]); // Memoize state, otherwise it would trigger all consumers on every render
|
|
223
|
+
}, [composer, children, camera, normalPass, downSamplingPass]); // Memoize state, otherwise it would trigger all consumers on every render
|
|
207
224
|
|
|
208
225
|
var state = React.useMemo(function () {
|
|
209
226
|
return {
|
|
210
227
|
composer: composer,
|
|
211
228
|
normalPass: normalPass,
|
|
229
|
+
downSamplingPass: downSamplingPass,
|
|
230
|
+
resolutionScale: resolutionScale,
|
|
212
231
|
camera: camera,
|
|
213
232
|
scene: scene
|
|
214
233
|
};
|
|
215
|
-
}, [composer, normalPass, camera, scene]); // Expose the composer
|
|
234
|
+
}, [composer, normalPass, downSamplingPass, resolutionScale, camera, scene]); // Expose the composer
|
|
216
235
|
|
|
217
236
|
React.useImperativeHandle(ref, function () {
|
|
218
237
|
return composer;
|
|
@@ -428,8 +447,11 @@ var Outline = /*#__PURE__*/React.forwardRef(function Outline(_ref, forwardRef) {
|
|
|
428
447
|
xRay: xRay
|
|
429
448
|
});
|
|
430
449
|
}, [blendFunction, blur, camera, edgeStrength, height, hiddenEdgeColor, kernelSize, patternTexture, pulseSpeed, scene, visibleEdgeColor, width, xRay]);
|
|
450
|
+
var api = React.useContext(selectionContext);
|
|
431
451
|
React.useEffect(function () {
|
|
432
|
-
if
|
|
452
|
+
// Do not allow array selection if declarative selection is active
|
|
453
|
+
// TODO: array selection should probably be deprecated altogether
|
|
454
|
+
if (!api && selection) {
|
|
433
455
|
effect.selection.set(Array.isArray(selection) ? selection.map(resolveRef) : [resolveRef(selection)]);
|
|
434
456
|
invalidate();
|
|
435
457
|
return function () {
|
|
@@ -437,12 +459,11 @@ var Outline = /*#__PURE__*/React.forwardRef(function Outline(_ref, forwardRef) {
|
|
|
437
459
|
invalidate();
|
|
438
460
|
};
|
|
439
461
|
}
|
|
440
|
-
}, [effect, selection]);
|
|
462
|
+
}, [effect, selection, api]);
|
|
441
463
|
React.useEffect(function () {
|
|
442
464
|
effect.selectionLayer = selectionLayer;
|
|
443
465
|
invalidate();
|
|
444
466
|
}, [effect, selectionLayer]);
|
|
445
|
-
var api = React.useContext(selectionContext);
|
|
446
467
|
var ref = React.useRef();
|
|
447
468
|
React.useEffect(function () {
|
|
448
469
|
if (api && api.enabled) {
|
|
@@ -530,8 +551,11 @@ var SelectiveBloom = /*#__PURE__*/React.forwardRef(function SelectiveBloom(_ref,
|
|
|
530
551
|
kernelSize: kernelSize
|
|
531
552
|
});
|
|
532
553
|
}, [camera, height, intensity, kernelSize, luminanceSmoothing, luminanceThreshold, scene, width]);
|
|
554
|
+
var api = React.useContext(selectionContext);
|
|
533
555
|
React.useEffect(function () {
|
|
534
|
-
if
|
|
556
|
+
// Do not allow array selection if declarative selection is active
|
|
557
|
+
// TODO: array selection should probably be deprecated altogether
|
|
558
|
+
if (!api && selection) {
|
|
535
559
|
effect.selection.set(Array.isArray(selection) ? selection.map(resolveRef) : [resolveRef(selection)]);
|
|
536
560
|
invalidate();
|
|
537
561
|
return function () {
|
|
@@ -539,7 +563,7 @@ var SelectiveBloom = /*#__PURE__*/React.forwardRef(function SelectiveBloom(_ref,
|
|
|
539
563
|
invalidate();
|
|
540
564
|
};
|
|
541
565
|
}
|
|
542
|
-
}, [effect, selection]);
|
|
566
|
+
}, [effect, selection, api]);
|
|
543
567
|
React.useEffect(function () {
|
|
544
568
|
effect.selection.layer = selectionLayer;
|
|
545
569
|
invalidate();
|
|
@@ -558,7 +582,6 @@ var SelectiveBloom = /*#__PURE__*/React.forwardRef(function SelectiveBloom(_ref,
|
|
|
558
582
|
};
|
|
559
583
|
}
|
|
560
584
|
}, [effect, lights, selectionLayer]);
|
|
561
|
-
var api = React.useContext(selectionContext);
|
|
562
585
|
var ref = React.useRef();
|
|
563
586
|
React.useEffect(function () {
|
|
564
587
|
if (api && api.enabled) {
|
|
@@ -590,15 +613,17 @@ var Sepia = wrapEffect(postprocessing.SepiaEffect);
|
|
|
590
613
|
var SSAO = /*#__PURE__*/React.forwardRef(function SSAO(props, ref) {
|
|
591
614
|
var _useContext = React.useContext(EffectComposerContext),
|
|
592
615
|
camera = _useContext.camera,
|
|
593
|
-
normalPass = _useContext.normalPass
|
|
616
|
+
normalPass = _useContext.normalPass,
|
|
617
|
+
downSamplingPass = _useContext.downSamplingPass,
|
|
618
|
+
resolutionScale = _useContext.resolutionScale;
|
|
594
619
|
|
|
595
620
|
var effect = React.useMemo(function () {
|
|
596
|
-
if (normalPass === null) {
|
|
621
|
+
if (normalPass === null && downSamplingPass === null) {
|
|
597
622
|
console.error('Please enable the NormalPass in the EffectComposer in order to use SSAO.');
|
|
598
623
|
return null;
|
|
599
624
|
}
|
|
600
625
|
|
|
601
|
-
return new postprocessing.SSAOEffect(camera, normalPass.
|
|
626
|
+
return new postprocessing.SSAOEffect(camera, normalPass && !downSamplingPass ? normalPass.texture : null, _extends__default["default"]({
|
|
602
627
|
blendFunction: postprocessing.BlendFunction.MULTIPLY,
|
|
603
628
|
samples: 30,
|
|
604
629
|
rings: 4,
|
|
@@ -611,7 +636,11 @@ var SSAO = /*#__PURE__*/React.forwardRef(function SSAO(props, ref) {
|
|
|
611
636
|
scale: 0.5,
|
|
612
637
|
bias: 0.5,
|
|
613
638
|
intensity: 1.0,
|
|
614
|
-
color: null
|
|
639
|
+
color: null,
|
|
640
|
+
// @ts-ignore
|
|
641
|
+
normalDepthBuffer: downSamplingPass ? downSamplingPass.texture : null,
|
|
642
|
+
resolutionScale: resolutionScale != null ? resolutionScale : 1,
|
|
643
|
+
depthAwareUpsampling: true
|
|
615
644
|
}, props));
|
|
616
645
|
}, [camera, normalPass, props]);
|
|
617
646
|
return /*#__PURE__*/React__default["default"].createElement("primitive", {
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BlendFunction, BloomEffect, BrightnessContrastEffect, ChromaticAberrationEffect, ColorAverageEffect, ColorDepthEffect, DepthEffect, EffectComposer as EffectComposer$1, RenderPass, NormalPass, EffectPass, DepthOfFieldEffect, DotScreenEffect, GlitchEffect, GlitchMode, GodRaysEffect, GridEffect, HueSaturationEffect, NoiseEffect, OutlineEffect, PixelationEffect, ScanlineEffect, SelectiveBloomEffect, SepiaEffect, SSAOEffect, SMAAPreset, EdgeDetectionMode, SMAAImageLoader, SMAAEffect, TextureEffect, ToneMappingEffect, VignetteEffect, ShockWaveEffect, LUTEffect } from 'postprocessing';
|
|
2
|
-
import React, { forwardRef, useMemo, useLayoutEffect, createContext, useRef, useImperativeHandle, useContext, useState
|
|
1
|
+
import { BlendFunction, BloomEffect, BrightnessContrastEffect, ChromaticAberrationEffect, ColorAverageEffect, ColorDepthEffect, DepthEffect, EffectComposer as EffectComposer$1, RenderPass, NormalPass, DepthDownsamplingPass, EffectPass, DepthOfFieldEffect, DotScreenEffect, GlitchEffect, GlitchMode, GodRaysEffect, GridEffect, HueSaturationEffect, NoiseEffect, OutlineEffect, PixelationEffect, ScanlineEffect, SelectiveBloomEffect, SepiaEffect, SSAOEffect, SMAAPreset, EdgeDetectionMode, SMAAImageLoader, SMAAEffect, TextureEffect, ToneMappingEffect, VignetteEffect, ShockWaveEffect, LUTEffect } from 'postprocessing';
|
|
2
|
+
import React, { forwardRef, useMemo, useLayoutEffect, createContext, useEffect, useRef, useImperativeHandle, useContext, useState } from 'react';
|
|
3
3
|
import * as THREE from 'three';
|
|
4
4
|
import { Vector2, Vector3, TextureLoader, sRGBEncoding, RepeatWrapping } from 'three';
|
|
5
5
|
import { useThree, useFrame, useLoader } from '@react-three/fiber';
|
|
@@ -87,6 +87,7 @@ const EffectComposer = /*#__PURE__*/React.memo( /*#__PURE__*/forwardRef((_ref, r
|
|
|
87
87
|
children,
|
|
88
88
|
camera,
|
|
89
89
|
scene,
|
|
90
|
+
resolutionScale,
|
|
90
91
|
enabled = true,
|
|
91
92
|
renderPriority = 1,
|
|
92
93
|
autoClear = true,
|
|
@@ -104,27 +105,39 @@ const EffectComposer = /*#__PURE__*/React.memo( /*#__PURE__*/forwardRef((_ref, r
|
|
|
104
105
|
} = useThree();
|
|
105
106
|
scene = scene || defaultScene;
|
|
106
107
|
camera = camera || defaultCamera;
|
|
107
|
-
const [composer, normalPass] = useMemo(() => {
|
|
108
|
-
// Initialize composer
|
|
108
|
+
const [composer, normalPass, downSamplingPass] = useMemo(() => {
|
|
109
|
+
const webGL2Available = isWebGL2Available(); // Initialize composer
|
|
110
|
+
|
|
109
111
|
const effectComposer = new EffectComposer$1(gl, {
|
|
110
112
|
depthBuffer,
|
|
111
113
|
stencilBuffer,
|
|
112
|
-
multisampling: multisampling > 0 &&
|
|
114
|
+
multisampling: multisampling > 0 && webGL2Available ? multisampling : 0,
|
|
113
115
|
frameBufferType
|
|
114
116
|
}); // Add render pass
|
|
115
117
|
|
|
116
118
|
effectComposer.addPass(new RenderPass(scene, camera)); // Create normal pass
|
|
117
119
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (
|
|
122
|
-
|
|
120
|
+
let downSamplingPass = null;
|
|
121
|
+
let normalPass = null;
|
|
122
|
+
|
|
123
|
+
if (!disableNormalPass) {
|
|
124
|
+
normalPass = new NormalPass(scene, camera);
|
|
125
|
+
normalPass.enabled = false;
|
|
126
|
+
effectComposer.addPass(normalPass);
|
|
127
|
+
|
|
128
|
+
if (resolutionScale !== undefined && webGL2Available) {
|
|
129
|
+
downSamplingPass = new DepthDownsamplingPass({
|
|
130
|
+
normalBuffer: normalPass.texture,
|
|
131
|
+
resolutionScale
|
|
132
|
+
});
|
|
133
|
+
downSamplingPass.enabled = false;
|
|
134
|
+
effectComposer.addPass(downSamplingPass);
|
|
135
|
+
}
|
|
123
136
|
}
|
|
124
137
|
|
|
125
|
-
return [effectComposer,
|
|
126
|
-
}, [camera, gl, depthBuffer, stencilBuffer, multisampling, frameBufferType, scene, disableNormalPass]);
|
|
127
|
-
|
|
138
|
+
return [effectComposer, normalPass, downSamplingPass];
|
|
139
|
+
}, [camera, gl, depthBuffer, stencilBuffer, multisampling, frameBufferType, scene, disableNormalPass, resolutionScale]);
|
|
140
|
+
useEffect(() => composer == null ? void 0 : composer.setSize(size.width, size.height), [composer, size]);
|
|
128
141
|
useFrame((_, delta) => {
|
|
129
142
|
if (enabled) {
|
|
130
143
|
gl.autoClear = autoClear;
|
|
@@ -137,23 +150,27 @@ const EffectComposer = /*#__PURE__*/React.memo( /*#__PURE__*/forwardRef((_ref, r
|
|
|
137
150
|
|
|
138
151
|
if (group.current && group.current.__r3f && composer) {
|
|
139
152
|
effectPass = new EffectPass(camera, ...group.current.__r3f.objects);
|
|
140
|
-
composer.addPass(effectPass);
|
|
141
153
|
effectPass.renderToScreen = true;
|
|
154
|
+
composer.addPass(effectPass);
|
|
142
155
|
if (normalPass) normalPass.enabled = true;
|
|
156
|
+
if (downSamplingPass) downSamplingPass.enabled = true;
|
|
143
157
|
}
|
|
144
158
|
|
|
145
159
|
return () => {
|
|
146
160
|
if (effectPass) composer == null ? void 0 : composer.removePass(effectPass);
|
|
147
161
|
if (normalPass) normalPass.enabled = false;
|
|
162
|
+
if (downSamplingPass) downSamplingPass.enabled = false;
|
|
148
163
|
};
|
|
149
|
-
}, [composer, children, camera]); // Memoize state, otherwise it would trigger all consumers on every render
|
|
164
|
+
}, [composer, children, camera, normalPass, downSamplingPass]); // Memoize state, otherwise it would trigger all consumers on every render
|
|
150
165
|
|
|
151
166
|
const state = useMemo(() => ({
|
|
152
167
|
composer,
|
|
153
168
|
normalPass,
|
|
169
|
+
downSamplingPass,
|
|
170
|
+
resolutionScale,
|
|
154
171
|
camera,
|
|
155
172
|
scene
|
|
156
|
-
}), [composer, normalPass, camera, scene]); // Expose the composer
|
|
173
|
+
}), [composer, normalPass, downSamplingPass, resolutionScale, camera, scene]); // Expose the composer
|
|
157
174
|
|
|
158
175
|
useImperativeHandle(ref, () => composer, [composer]);
|
|
159
176
|
return /*#__PURE__*/React.createElement(EffectComposerContext.Provider, {
|
|
@@ -332,8 +349,11 @@ const Outline = /*#__PURE__*/forwardRef(function Outline(_ref, forwardRef) {
|
|
|
332
349
|
blur,
|
|
333
350
|
xRay
|
|
334
351
|
}), [blendFunction, blur, camera, edgeStrength, height, hiddenEdgeColor, kernelSize, patternTexture, pulseSpeed, scene, visibleEdgeColor, width, xRay]);
|
|
352
|
+
const api = useContext(selectionContext);
|
|
335
353
|
useEffect(() => {
|
|
336
|
-
if
|
|
354
|
+
// Do not allow array selection if declarative selection is active
|
|
355
|
+
// TODO: array selection should probably be deprecated altogether
|
|
356
|
+
if (!api && selection) {
|
|
337
357
|
effect.selection.set(Array.isArray(selection) ? selection.map(resolveRef) : [resolveRef(selection)]);
|
|
338
358
|
invalidate();
|
|
339
359
|
return () => {
|
|
@@ -341,12 +361,11 @@ const Outline = /*#__PURE__*/forwardRef(function Outline(_ref, forwardRef) {
|
|
|
341
361
|
invalidate();
|
|
342
362
|
};
|
|
343
363
|
}
|
|
344
|
-
}, [effect, selection]);
|
|
364
|
+
}, [effect, selection, api]);
|
|
345
365
|
useEffect(() => {
|
|
346
366
|
effect.selectionLayer = selectionLayer;
|
|
347
367
|
invalidate();
|
|
348
368
|
}, [effect, selectionLayer]);
|
|
349
|
-
const api = useContext(selectionContext);
|
|
350
369
|
const ref = useRef();
|
|
351
370
|
useEffect(() => {
|
|
352
371
|
if (api && api.enabled) {
|
|
@@ -421,8 +440,11 @@ const SelectiveBloom = /*#__PURE__*/forwardRef(function SelectiveBloom(_ref, for
|
|
|
421
440
|
height,
|
|
422
441
|
kernelSize
|
|
423
442
|
}), [camera, height, intensity, kernelSize, luminanceSmoothing, luminanceThreshold, scene, width]);
|
|
443
|
+
const api = useContext(selectionContext);
|
|
424
444
|
useEffect(() => {
|
|
425
|
-
if
|
|
445
|
+
// Do not allow array selection if declarative selection is active
|
|
446
|
+
// TODO: array selection should probably be deprecated altogether
|
|
447
|
+
if (!api && selection) {
|
|
426
448
|
effect.selection.set(Array.isArray(selection) ? selection.map(resolveRef) : [resolveRef(selection)]);
|
|
427
449
|
invalidate();
|
|
428
450
|
return () => {
|
|
@@ -430,7 +452,7 @@ const SelectiveBloom = /*#__PURE__*/forwardRef(function SelectiveBloom(_ref, for
|
|
|
430
452
|
invalidate();
|
|
431
453
|
};
|
|
432
454
|
}
|
|
433
|
-
}, [effect, selection]);
|
|
455
|
+
}, [effect, selection, api]);
|
|
434
456
|
useEffect(() => {
|
|
435
457
|
effect.selection.layer = selectionLayer;
|
|
436
458
|
invalidate();
|
|
@@ -445,7 +467,6 @@ const SelectiveBloom = /*#__PURE__*/forwardRef(function SelectiveBloom(_ref, for
|
|
|
445
467
|
};
|
|
446
468
|
}
|
|
447
469
|
}, [effect, lights, selectionLayer]);
|
|
448
|
-
const api = useContext(selectionContext);
|
|
449
470
|
const ref = useRef();
|
|
450
471
|
useEffect(() => {
|
|
451
472
|
if (api && api.enabled) {
|
|
@@ -475,15 +496,17 @@ const Sepia = wrapEffect(SepiaEffect);
|
|
|
475
496
|
const SSAO = /*#__PURE__*/forwardRef(function SSAO(props, ref) {
|
|
476
497
|
const {
|
|
477
498
|
camera,
|
|
478
|
-
normalPass
|
|
499
|
+
normalPass,
|
|
500
|
+
downSamplingPass,
|
|
501
|
+
resolutionScale
|
|
479
502
|
} = useContext(EffectComposerContext);
|
|
480
503
|
const effect = useMemo(() => {
|
|
481
|
-
if (normalPass === null) {
|
|
504
|
+
if (normalPass === null && downSamplingPass === null) {
|
|
482
505
|
console.error('Please enable the NormalPass in the EffectComposer in order to use SSAO.');
|
|
483
506
|
return null;
|
|
484
507
|
}
|
|
485
508
|
|
|
486
|
-
return new SSAOEffect(camera, normalPass.
|
|
509
|
+
return new SSAOEffect(camera, normalPass && !downSamplingPass ? normalPass.texture : null, {
|
|
487
510
|
blendFunction: BlendFunction.MULTIPLY,
|
|
488
511
|
samples: 30,
|
|
489
512
|
rings: 4,
|
|
@@ -497,6 +520,10 @@ const SSAO = /*#__PURE__*/forwardRef(function SSAO(props, ref) {
|
|
|
497
520
|
bias: 0.5,
|
|
498
521
|
intensity: 1.0,
|
|
499
522
|
color: null,
|
|
523
|
+
// @ts-ignore
|
|
524
|
+
normalDepthBuffer: downSamplingPass ? downSamplingPass.texture : null,
|
|
525
|
+
resolutionScale: resolutionScale != null ? resolutionScale : 1,
|
|
526
|
+
depthAwareUpsampling: true,
|
|
500
527
|
...props
|
|
501
528
|
});
|
|
502
529
|
}, [camera, normalPass, props]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-three/postprocessing",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "postprocessing wrapper for React and @react-three/fiber",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"postprocessing",
|
|
@@ -38,48 +38,48 @@
|
|
|
38
38
|
"typegen": "tsc --emitDeclarationOnly || true"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"postprocessing": "6.
|
|
41
|
+
"postprocessing": "6.26.3",
|
|
42
42
|
"react-merge-refs": "^1.1.0",
|
|
43
|
-
"three-stdlib": "^2.8.
|
|
43
|
+
"three-stdlib": "^2.8.11"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@babel/core": "^7.
|
|
47
|
-
"@babel/plugin-transform-modules-commonjs": "7.
|
|
48
|
-
"@babel/plugin-transform-parameters": "7.16.
|
|
49
|
-
"@babel/plugin-transform-runtime": "7.
|
|
50
|
-
"@babel/plugin-transform-template-literals": "7.16.
|
|
51
|
-
"@babel/preset-env": "^7.16.
|
|
52
|
-
"@babel/preset-react": "7.16.
|
|
53
|
-
"@babel/preset-typescript": "^7.16.
|
|
54
|
-
"@react-three/fiber": "^7.0.
|
|
55
|
-
"@rollup/plugin-babel": "^5.3.
|
|
56
|
-
"@rollup/plugin-commonjs": "^21.0.
|
|
46
|
+
"@babel/core": "^7.17.8",
|
|
47
|
+
"@babel/plugin-transform-modules-commonjs": "7.17.7",
|
|
48
|
+
"@babel/plugin-transform-parameters": "7.16.7",
|
|
49
|
+
"@babel/plugin-transform-runtime": "7.17.0",
|
|
50
|
+
"@babel/plugin-transform-template-literals": "7.16.7",
|
|
51
|
+
"@babel/preset-env": "^7.16.11",
|
|
52
|
+
"@babel/preset-react": "7.16.7",
|
|
53
|
+
"@babel/preset-typescript": "^7.16.7",
|
|
54
|
+
"@react-three/fiber": "^7.0.26",
|
|
55
|
+
"@rollup/plugin-babel": "^5.3.1",
|
|
56
|
+
"@rollup/plugin-commonjs": "^21.0.3",
|
|
57
57
|
"@rollup/plugin-json": "^4.1.0",
|
|
58
|
-
"@rollup/plugin-node-resolve": "^13.1.
|
|
59
|
-
"@types/react": "^17.0.
|
|
60
|
-
"@types/react-dom": "^17.0.
|
|
58
|
+
"@rollup/plugin-node-resolve": "^13.1.3",
|
|
59
|
+
"@types/react": "^17.0.43",
|
|
60
|
+
"@types/react-dom": "^17.0.14",
|
|
61
61
|
"@types/react-test-renderer": "^17.0.1",
|
|
62
|
-
"@types/three": "^0.
|
|
63
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
64
|
-
"@typescript-eslint/parser": "^5.
|
|
65
|
-
"eslint": "^8.
|
|
66
|
-
"eslint-config-prettier": "^8.
|
|
62
|
+
"@types/three": "^0.139.0",
|
|
63
|
+
"@typescript-eslint/eslint-plugin": "^5.17.0",
|
|
64
|
+
"@typescript-eslint/parser": "^5.17.0",
|
|
65
|
+
"eslint": "^8.12.0",
|
|
66
|
+
"eslint-config-prettier": "^8.5.0",
|
|
67
67
|
"eslint-import-resolver-alias": "^1.1.2",
|
|
68
|
-
"eslint-plugin-import": "^2.25.
|
|
68
|
+
"eslint-plugin-import": "^2.25.4",
|
|
69
69
|
"eslint-plugin-prettier": "^4.0.0",
|
|
70
|
-
"eslint-plugin-react": "^7.
|
|
70
|
+
"eslint-plugin-react": "^7.29.4",
|
|
71
71
|
"eslint-plugin-react-hooks": "^4.3.0",
|
|
72
72
|
"husky": "^7.0.4",
|
|
73
73
|
"husky-run": "^0.0.0",
|
|
74
|
-
"lint-staged": "^12.
|
|
75
|
-
"prettier": "^2.
|
|
74
|
+
"lint-staged": "^12.3.7",
|
|
75
|
+
"prettier": "^2.6.1",
|
|
76
76
|
"react": "^17.0.2",
|
|
77
77
|
"react-dom": "^17.0.2",
|
|
78
78
|
"rimraf": "^3.0.2",
|
|
79
|
-
"rollup": "^2.
|
|
80
|
-
"rollup-plugin-filesize": "^9.1.
|
|
79
|
+
"rollup": "^2.70.1",
|
|
80
|
+
"rollup-plugin-filesize": "^9.1.2",
|
|
81
81
|
"rollup-plugin-terser": "^7.0.2",
|
|
82
|
-
"typescript": "^4.
|
|
82
|
+
"typescript": "^4.6.3"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
85
|
"@react-three/fiber": ">=7.0",
|