@react-three/postprocessing 2.4.6 → 2.5.2
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 -2
- package/dist/effects/SSR.d.ts +40 -34
- package/dist/index.cjs +37 -95
- package/dist/index.js +31 -81
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/@react-three/postprocessing)
|
|
5
5
|
[](https://discord.gg/ZZjjNvJ)
|
|
6
6
|
|
|
7
|
-
`react-postprocessing` is a [postprocessing](https://github.com/
|
|
7
|
+
`react-postprocessing` is a [postprocessing](https://github.com/pmndrs/postprocessing) wrapper for [@react-three/fiber](https://github.com/pmndrs/@react-three/fiber). This is not (yet) meant for complex orchestration of effects, but can save you [hundreds of LOC](https://twitter.com/0xca0a/status/1289501594698960897) for a straight forward effects-chain.
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
npm install @react-three/postprocessing
|
|
@@ -20,7 +20,7 @@ npm install @react-three/postprocessing
|
|
|
20
20
|
|
|
21
21
|
#### Why postprocessing and not three/examples/jsm/postprocessing?
|
|
22
22
|
|
|
23
|
-
From [https://github.com/
|
|
23
|
+
From [https://github.com/pmndrs/postprocessing](https://github.com/pmndrs/postprocessing#performance)
|
|
24
24
|
|
|
25
25
|
> This library provides an EffectPass which automatically organizes and merges any given combination of effects. This minimizes the amount of render operations and makes it possible to combine many effects without the performance penalties of traditional pass chaining. Additionally, every effect can choose its own blend function.
|
|
26
26
|
>
|
package/dist/effects/SSR.d.ts
CHANGED
|
@@ -1,49 +1,55 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
declare type SSRProps = {
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
/**
|
|
3
|
+
/** whether you want to use Temporal Resolving to re-use reflections from the last frames; this will reduce noise tremendously but may result in "smearing" */
|
|
4
|
+
temporalResolve?: boolean;
|
|
5
|
+
/** a value between 0 and 1 to set how much the last frame's reflections should be blended in; higher values will result in less noisy reflections when moving the camera but a more smeary look */
|
|
6
|
+
temporalResolveMix?: number;
|
|
7
|
+
/** a value between 0 and 1 to set how much the reprojected reflection should be corrected; higher values will reduce smearing but will result in less flickering at reflection edges */
|
|
8
|
+
temporalResolveCorrectionMix?: number;
|
|
9
|
+
/** the maximum number of samples for reflections; settings it to 0 means unlimited samples; setting it to a value like 6 can help make camera movements less disruptive when calculating reflections */
|
|
10
|
+
maxSamples?: number;
|
|
11
|
+
/** whether to blur the reflections and blend these blurred reflections with the raw ones depending on the blurMix value */
|
|
12
|
+
ENABLE_BLUR?: boolean;
|
|
13
|
+
/** how much the blurred reflections should be mixed with the raw reflections */
|
|
14
|
+
blurMix?: number;
|
|
15
|
+
/** the sharpness of the Bilateral Filter used to blur reflections */
|
|
16
|
+
blurSharpness?: number;
|
|
17
|
+
/** the kernel size of the Bilateral Blur Filter; higher kernel sizes will result in blurrier reflections with more artifacts */
|
|
12
18
|
blurKernelSize?: number;
|
|
13
|
-
/**
|
|
19
|
+
/** how much the reflection ray should travel in each of its iteration; higher values will give deeper reflections but with more artifacts */
|
|
14
20
|
rayStep?: number;
|
|
15
|
-
/**
|
|
21
|
+
/** the intensity of the reflections */
|
|
16
22
|
intensity?: number;
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
enableJittering?: boolean;
|
|
23
|
-
/** How intense jittering should be */
|
|
23
|
+
/** the maximum roughness a texel can have to have reflections calculated for it */
|
|
24
|
+
maxRoughness?: number;
|
|
25
|
+
/** whether jittering is enabled; jittering will randomly jitter the reflections resulting in a more noisy but overall more realistic look, enabling jittering can be expensive depending on the view angle */
|
|
26
|
+
ENABLE_JITTERING?: boolean;
|
|
27
|
+
/** how intense jittering should be */
|
|
24
28
|
jitter?: number;
|
|
25
|
-
/**
|
|
29
|
+
/** how much the jittered rays should be spread; higher values will give a rougher look regarding the reflections but are more expensive to compute with */
|
|
26
30
|
jitterSpread?: number;
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
/**
|
|
31
|
+
/** how intense jittering should be in relation to a material's roughness */
|
|
32
|
+
jitterRough?: number;
|
|
33
|
+
/** the number of steps a reflection ray can maximally do to find an object it intersected (and thus reflects) */
|
|
30
34
|
MAX_STEPS?: number;
|
|
31
|
-
/**
|
|
35
|
+
/** once we had our ray intersect something, we need to find the exact point in space it intersected and thus it reflects; this can be done through binary search with the given number of maximum steps */
|
|
32
36
|
NUM_BINARY_SEARCH_STEPS?: number;
|
|
33
|
-
/**
|
|
37
|
+
/** the maximum depth difference between a ray and the particular depth at its screen position after refining with binary search; lower values will result in better performance */
|
|
34
38
|
maxDepthDifference?: number;
|
|
35
|
-
/**
|
|
39
|
+
/** the maximum depth for which reflections will be calculated */
|
|
36
40
|
maxDepth?: number;
|
|
37
|
-
/**
|
|
41
|
+
/** the maximum depth difference between a ray and the particular depth at its screen position before refining with binary search; lower values will result in better performance */
|
|
38
42
|
thickness?: number;
|
|
39
43
|
/** Index of Refraction, used for calculating fresnel; reflections tend to be more intense the steeper the angle between them and the viewer is, the ior parameter set how much the intensity varies */
|
|
40
44
|
ior?: number;
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
|
|
45
|
+
/** if there should still be reflections for rays for which a reflecting point couldn't be found; enabling this will result in stretched looking reflections which can look good or bad depending on the angle */
|
|
46
|
+
STRETCH_MISSED_RAYS?: boolean;
|
|
47
|
+
/** WebGL2 only - whether to use multiple render targets when rendering the G-buffers (normals, depth and roughness); using them can improve performance as they will render all information to multiple buffers for each fragment in one run; this setting can't be changed during run-time */
|
|
48
|
+
USE_MRT?: boolean;
|
|
49
|
+
/** if roughness maps should be taken account of when calculating reflections */
|
|
50
|
+
USE_ROUGHNESSMAP?: boolean;
|
|
51
|
+
/** if normal maps should be taken account of when calculating reflections */
|
|
52
|
+
USE_NORMALMAP?: boolean;
|
|
47
53
|
};
|
|
48
|
-
export declare const SSR:
|
|
54
|
+
export declare const SSR: React.ForwardRefExoticComponent<SSRProps & React.RefAttributes<SSREffect>>;
|
|
49
55
|
export {};
|
package/dist/index.cjs
CHANGED
|
@@ -10,7 +10,6 @@ var fiber = require('@react-three/fiber');
|
|
|
10
10
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
11
11
|
var _construct = require('@babel/runtime/helpers/construct');
|
|
12
12
|
var threeStdlib = require('three-stdlib');
|
|
13
|
-
var mergeRefs = require('react-merge-refs');
|
|
14
13
|
var screenSpaceReflections = require('screen-space-reflections');
|
|
15
14
|
|
|
16
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -19,7 +18,6 @@ var _objectWithoutPropertiesLoose__default = /*#__PURE__*/_interopDefaultLegacy(
|
|
|
19
18
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
20
19
|
var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
|
|
21
20
|
var _construct__default = /*#__PURE__*/_interopDefaultLegacy(_construct);
|
|
22
|
-
var mergeRefs__default = /*#__PURE__*/_interopDefaultLegacy(mergeRefs);
|
|
23
21
|
|
|
24
22
|
var _excluded$8 = ["blendFunction", "opacity"];
|
|
25
23
|
|
|
@@ -446,27 +444,23 @@ var Outline = /*#__PURE__*/React.forwardRef(function Outline(_ref, forwardRef) {
|
|
|
446
444
|
effect.selectionLayer = selectionLayer;
|
|
447
445
|
invalidate();
|
|
448
446
|
}, [effect, selectionLayer]);
|
|
449
|
-
|
|
447
|
+
React.useRef();
|
|
450
448
|
React.useEffect(function () {
|
|
451
449
|
if (api && api.enabled) {
|
|
452
450
|
var _api$selected;
|
|
453
451
|
|
|
454
|
-
var _effect = ref.current;
|
|
455
|
-
|
|
456
452
|
if ((_api$selected = api.selected) != null && _api$selected.length) {
|
|
457
|
-
|
|
458
|
-
|
|
453
|
+
effect.selection.set(api.selected);
|
|
459
454
|
invalidate();
|
|
460
455
|
return function () {
|
|
461
|
-
|
|
462
|
-
|
|
456
|
+
effect.selection.clear();
|
|
463
457
|
invalidate();
|
|
464
458
|
};
|
|
465
459
|
}
|
|
466
460
|
}
|
|
467
461
|
}, [api]);
|
|
468
462
|
return /*#__PURE__*/React__default["default"].createElement("primitive", {
|
|
469
|
-
ref:
|
|
463
|
+
ref: forwardRef,
|
|
470
464
|
object: effect
|
|
471
465
|
});
|
|
472
466
|
});
|
|
@@ -564,27 +558,23 @@ var SelectiveBloom = /*#__PURE__*/React.forwardRef(function SelectiveBloom(_ref,
|
|
|
564
558
|
};
|
|
565
559
|
}
|
|
566
560
|
}, [effect, lights, selectionLayer]);
|
|
567
|
-
|
|
561
|
+
React.useRef();
|
|
568
562
|
React.useEffect(function () {
|
|
569
563
|
if (api && api.enabled) {
|
|
570
564
|
var _api$selected;
|
|
571
565
|
|
|
572
|
-
var _effect = ref.current;
|
|
573
|
-
|
|
574
566
|
if ((_api$selected = api.selected) != null && _api$selected.length) {
|
|
575
|
-
|
|
576
|
-
|
|
567
|
+
effect.selection.set(api.selected);
|
|
577
568
|
invalidate();
|
|
578
569
|
return function () {
|
|
579
|
-
|
|
580
|
-
|
|
570
|
+
effect.selection.clear();
|
|
581
571
|
invalidate();
|
|
582
572
|
};
|
|
583
573
|
}
|
|
584
574
|
}
|
|
585
575
|
}, [api]);
|
|
586
576
|
return /*#__PURE__*/React__default["default"].createElement("primitive", {
|
|
587
|
-
ref:
|
|
577
|
+
ref: forwardRef,
|
|
588
578
|
object: effect,
|
|
589
579
|
dispose: null
|
|
590
580
|
});
|
|
@@ -701,101 +691,53 @@ var LUT = /*#__PURE__*/React.forwardRef(function LUT(_ref, ref) {
|
|
|
701
691
|
});
|
|
702
692
|
});
|
|
703
693
|
|
|
704
|
-
var _excluded = ["
|
|
694
|
+
var _excluded = ["ENABLE_BLUR", "USE_MRT"];
|
|
705
695
|
|
|
706
696
|
var SSR = /*#__PURE__*/React.forwardRef(function SSR(_ref, ref) {
|
|
707
|
-
var _ref$
|
|
708
|
-
|
|
709
|
-
_ref$
|
|
710
|
-
|
|
711
|
-
_ref$enabled = _ref.enabled,
|
|
712
|
-
enabled = _ref$enabled === void 0 ? true : _ref$enabled,
|
|
697
|
+
var _ref$ENABLE_BLUR = _ref.ENABLE_BLUR,
|
|
698
|
+
ENABLE_BLUR = _ref$ENABLE_BLUR === void 0 ? true : _ref$ENABLE_BLUR,
|
|
699
|
+
_ref$USE_MRT = _ref.USE_MRT,
|
|
700
|
+
USE_MRT = _ref$USE_MRT === void 0 ? true : _ref$USE_MRT,
|
|
713
701
|
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded);
|
|
714
702
|
|
|
715
703
|
var _useThree = fiber.useThree(),
|
|
716
|
-
size = _useThree.size,
|
|
717
|
-
viewport = _useThree.viewport,
|
|
718
704
|
invalidate = _useThree.invalidate;
|
|
719
705
|
|
|
720
706
|
var _useContext = React.useContext(EffectComposerContext),
|
|
721
|
-
composer = _useContext.composer,
|
|
722
707
|
scene = _useContext.scene,
|
|
723
708
|
camera = _useContext.camera;
|
|
724
709
|
|
|
725
|
-
var
|
|
726
|
-
return new screenSpaceReflections.
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
blurWidth: blurSize,
|
|
730
|
-
blurHeight: blurSize,
|
|
731
|
-
blurKernelSize: postprocessing.KernelSize.SMALL,
|
|
732
|
-
rayStep: 0.1,
|
|
733
|
-
intensity: 1,
|
|
734
|
-
power: 1,
|
|
735
|
-
depthBlur: 0.1,
|
|
736
|
-
enableJittering: false,
|
|
737
|
-
jitter: 0.1,
|
|
738
|
-
jitterSpread: 0.1,
|
|
739
|
-
roughnessFadeOut: 1,
|
|
740
|
-
MAX_STEPS: 20,
|
|
741
|
-
NUM_BINARY_SEARCH_STEPS: 5,
|
|
742
|
-
maxDepthDifference: 1,
|
|
743
|
-
maxDepth: 1,
|
|
744
|
-
thickness: 10,
|
|
745
|
-
ior: 1.45,
|
|
746
|
-
useBlur: true,
|
|
747
|
-
useMRT: true,
|
|
748
|
-
useNormalMap: true,
|
|
749
|
-
useRoughnessMap: true
|
|
710
|
+
var effect = React.useMemo(function () {
|
|
711
|
+
return new screenSpaceReflections.SSREffect(scene, camera, _extends__default["default"]({
|
|
712
|
+
ENABLE_BLUR: ENABLE_BLUR,
|
|
713
|
+
USE_MRT: USE_MRT
|
|
750
714
|
}, props));
|
|
751
|
-
})
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
React.useEffect(function () {
|
|
715
|
+
}, [screenSpaceReflections.SSREffect, scene, camera, ENABLE_BLUR, USE_MRT]);
|
|
716
|
+
React.useLayoutEffect(function () {
|
|
755
717
|
Object.keys(props).forEach(function (key) {
|
|
756
|
-
return
|
|
718
|
+
return effect[key] = props[key];
|
|
757
719
|
});
|
|
758
720
|
invalidate();
|
|
759
721
|
}, [props]);
|
|
722
|
+
var api = React.useContext(selectionContext);
|
|
760
723
|
React.useEffect(function () {
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
pass.reflectionsPass.fullscreenMaterial.defines.NUM_BINARY_SEARCH_STEPS = Math.ceil(props.NUM_BINARY_SEARCH_STEPS); // Blur
|
|
764
|
-
|
|
765
|
-
if (props.useBlur) {
|
|
766
|
-
pass.fullscreenMaterial.defines.USE_BLUR = '';
|
|
767
|
-
pass.reflectionsPass.fullscreenMaterial.defines.USE_BLUR = '';
|
|
768
|
-
} else {
|
|
769
|
-
delete pass.fullscreenMaterial.defines.USE_BLUR;
|
|
770
|
-
delete pass.reflectionsPass.fullscreenMaterial.defines.USE_BLUR;
|
|
771
|
-
} // Jitter
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
if (props.enableJittering) {
|
|
775
|
-
pass.reflectionsPass.fullscreenMaterial.defines.USE_JITTERING = '';
|
|
776
|
-
} else {
|
|
777
|
-
delete pass.reflectionsPass.fullscreenMaterial.defines.USE_JITTERING;
|
|
778
|
-
} // Enabled
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
pass.fullscreenMaterial.defines.RENDER_MODE = enabled ? 0 : 4; // Update materials
|
|
724
|
+
if (api && api.enabled) {
|
|
725
|
+
var _api$selected;
|
|
782
726
|
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
}, [composer, pass]);
|
|
798
|
-
return null;
|
|
727
|
+
if ((_api$selected = api.selected) != null && _api$selected.length) {
|
|
728
|
+
effect.selection.set(api.selected);
|
|
729
|
+
invalidate();
|
|
730
|
+
return function () {
|
|
731
|
+
effect.selection.clear();
|
|
732
|
+
invalidate();
|
|
733
|
+
};
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
}, [api]);
|
|
737
|
+
return /*#__PURE__*/React__default["default"].createElement("primitive", {
|
|
738
|
+
ref: ref,
|
|
739
|
+
object: effect
|
|
740
|
+
});
|
|
799
741
|
});
|
|
800
742
|
|
|
801
743
|
exports.Bloom = Bloom;
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
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
|
|
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
2
|
import React, { forwardRef, useMemo, useLayoutEffect, createContext, useEffect, useRef, useImperativeHandle, useContext, useState } from 'react';
|
|
3
3
|
import { Vector2, HalfFloatType, Vector3, TextureLoader, sRGBEncoding, RepeatWrapping } from 'three';
|
|
4
4
|
import { useThree, useFrame, useLoader } from '@react-three/fiber';
|
|
5
5
|
import { isWebGL2Available } from 'three-stdlib';
|
|
6
|
-
import mergeRefs from 'react-merge-refs';
|
|
7
6
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
8
|
-
import {
|
|
7
|
+
import { SSREffect } from 'screen-space-reflections';
|
|
9
8
|
|
|
10
9
|
const isRef = ref => !!ref.current;
|
|
11
10
|
|
|
@@ -366,13 +365,11 @@ const Outline = /*#__PURE__*/forwardRef(function Outline(_ref, forwardRef) {
|
|
|
366
365
|
effect.selectionLayer = selectionLayer;
|
|
367
366
|
invalidate();
|
|
368
367
|
}, [effect, selectionLayer]);
|
|
369
|
-
|
|
368
|
+
useRef();
|
|
370
369
|
useEffect(() => {
|
|
371
370
|
if (api && api.enabled) {
|
|
372
371
|
var _api$selected;
|
|
373
372
|
|
|
374
|
-
const effect = ref.current;
|
|
375
|
-
|
|
376
373
|
if ((_api$selected = api.selected) != null && _api$selected.length) {
|
|
377
374
|
effect.selection.set(api.selected);
|
|
378
375
|
invalidate();
|
|
@@ -384,7 +381,7 @@ const Outline = /*#__PURE__*/forwardRef(function Outline(_ref, forwardRef) {
|
|
|
384
381
|
}
|
|
385
382
|
}, [api]);
|
|
386
383
|
return /*#__PURE__*/React.createElement("primitive", {
|
|
387
|
-
ref:
|
|
384
|
+
ref: forwardRef,
|
|
388
385
|
object: effect
|
|
389
386
|
});
|
|
390
387
|
});
|
|
@@ -467,13 +464,11 @@ const SelectiveBloom = /*#__PURE__*/forwardRef(function SelectiveBloom(_ref, for
|
|
|
467
464
|
};
|
|
468
465
|
}
|
|
469
466
|
}, [effect, lights, selectionLayer]);
|
|
470
|
-
|
|
467
|
+
useRef();
|
|
471
468
|
useEffect(() => {
|
|
472
469
|
if (api && api.enabled) {
|
|
473
470
|
var _api$selected;
|
|
474
471
|
|
|
475
|
-
const effect = ref.current;
|
|
476
|
-
|
|
477
472
|
if ((_api$selected = api.selected) != null && _api$selected.length) {
|
|
478
473
|
effect.selection.set(api.selected);
|
|
479
474
|
invalidate();
|
|
@@ -485,7 +480,7 @@ const SelectiveBloom = /*#__PURE__*/forwardRef(function SelectiveBloom(_ref, for
|
|
|
485
480
|
}
|
|
486
481
|
}, [api]);
|
|
487
482
|
return /*#__PURE__*/React.createElement("primitive", {
|
|
488
|
-
ref:
|
|
483
|
+
ref: forwardRef,
|
|
489
484
|
object: effect,
|
|
490
485
|
dispose: null
|
|
491
486
|
});
|
|
@@ -597,90 +592,45 @@ const LUT = /*#__PURE__*/forwardRef(function LUT(_ref, ref) {
|
|
|
597
592
|
|
|
598
593
|
const SSR = /*#__PURE__*/forwardRef(function SSR(_ref, ref) {
|
|
599
594
|
let {
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
enabled = true,
|
|
595
|
+
ENABLE_BLUR = true,
|
|
596
|
+
USE_MRT = true,
|
|
603
597
|
...props
|
|
604
598
|
} = _ref;
|
|
605
599
|
const {
|
|
606
|
-
size,
|
|
607
|
-
viewport,
|
|
608
600
|
invalidate
|
|
609
601
|
} = useThree();
|
|
610
602
|
const {
|
|
611
|
-
composer,
|
|
612
603
|
scene,
|
|
613
604
|
camera
|
|
614
605
|
} = useContext(EffectComposerContext);
|
|
615
|
-
const
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
blurWidth: blurSize,
|
|
619
|
-
blurHeight: blurSize,
|
|
620
|
-
blurKernelSize: KernelSize.SMALL,
|
|
621
|
-
rayStep: 0.1,
|
|
622
|
-
intensity: 1,
|
|
623
|
-
power: 1,
|
|
624
|
-
depthBlur: 0.1,
|
|
625
|
-
enableJittering: false,
|
|
626
|
-
jitter: 0.1,
|
|
627
|
-
jitterSpread: 0.1,
|
|
628
|
-
roughnessFadeOut: 1,
|
|
629
|
-
MAX_STEPS: 20,
|
|
630
|
-
NUM_BINARY_SEARCH_STEPS: 5,
|
|
631
|
-
maxDepthDifference: 1,
|
|
632
|
-
maxDepth: 1,
|
|
633
|
-
thickness: 10,
|
|
634
|
-
ior: 1.45,
|
|
635
|
-
useBlur: true,
|
|
636
|
-
useMRT: true,
|
|
637
|
-
useNormalMap: true,
|
|
638
|
-
useRoughnessMap: true,
|
|
606
|
+
const effect = useMemo(() => new SSREffect(scene, camera, {
|
|
607
|
+
ENABLE_BLUR,
|
|
608
|
+
USE_MRT,
|
|
639
609
|
...props
|
|
640
|
-
}));
|
|
641
|
-
|
|
642
|
-
Object.keys(props).forEach(key =>
|
|
610
|
+
}), [SSREffect, scene, camera, ENABLE_BLUR, USE_MRT]);
|
|
611
|
+
useLayoutEffect(() => {
|
|
612
|
+
Object.keys(props).forEach(key => effect[key] = props[key]);
|
|
643
613
|
invalidate();
|
|
644
614
|
}, [props]);
|
|
615
|
+
const api = useContext(selectionContext);
|
|
645
616
|
useEffect(() => {
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
pass.reflectionsPass.fullscreenMaterial.defines.NUM_BINARY_SEARCH_STEPS = Math.ceil(props.NUM_BINARY_SEARCH_STEPS); // Blur
|
|
649
|
-
|
|
650
|
-
if (props.useBlur) {
|
|
651
|
-
pass.fullscreenMaterial.defines.USE_BLUR = '';
|
|
652
|
-
pass.reflectionsPass.fullscreenMaterial.defines.USE_BLUR = '';
|
|
653
|
-
} else {
|
|
654
|
-
delete pass.fullscreenMaterial.defines.USE_BLUR;
|
|
655
|
-
delete pass.reflectionsPass.fullscreenMaterial.defines.USE_BLUR;
|
|
656
|
-
} // Jitter
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
if (props.enableJittering) {
|
|
660
|
-
pass.reflectionsPass.fullscreenMaterial.defines.USE_JITTERING = '';
|
|
661
|
-
} else {
|
|
662
|
-
delete pass.reflectionsPass.fullscreenMaterial.defines.USE_JITTERING;
|
|
663
|
-
} // Enabled
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
pass.fullscreenMaterial.defines.RENDER_MODE = enabled ? 0 : 4; // Update materials
|
|
617
|
+
if (api && api.enabled) {
|
|
618
|
+
var _api$selected;
|
|
667
619
|
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
}, [composer, pass]);
|
|
683
|
-
return null;
|
|
620
|
+
if ((_api$selected = api.selected) != null && _api$selected.length) {
|
|
621
|
+
effect.selection.set(api.selected);
|
|
622
|
+
invalidate();
|
|
623
|
+
return () => {
|
|
624
|
+
effect.selection.clear();
|
|
625
|
+
invalidate();
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}, [api]);
|
|
630
|
+
return /*#__PURE__*/React.createElement("primitive", {
|
|
631
|
+
ref: ref,
|
|
632
|
+
object: effect
|
|
633
|
+
});
|
|
684
634
|
});
|
|
685
635
|
|
|
686
636
|
export { Bloom, BrightnessContrast, ChromaticAberration, ColorAverage, ColorDepth, Depth, DepthOfField, DotScreen, EffectComposer, EffectComposerContext, Glitch, GodRays, Grid, HueSaturation, LUT, Noise, Outline, Pixelation, SMAA, SSAO, SSR, Scanline, Select, Selection, SelectiveBloom, Sepia, ShockWave, Texture, ToneMapping, Vignette, selectionContext };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-three/postprocessing",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.2",
|
|
4
4
|
"description": "postprocessing wrapper for React and @react-three/fiber",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"postprocessing",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"typegen": "tsc --emitDeclarationOnly || true"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"postprocessing": "^6.28.
|
|
42
|
+
"postprocessing": "^6.28.4",
|
|
43
43
|
"react-merge-refs": "^1.1.0",
|
|
44
|
-
"screen-space-reflections": "^
|
|
44
|
+
"screen-space-reflections": "^2.0.6",
|
|
45
45
|
"three-stdlib": "^2.8.11"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|