@react-three/postprocessing 2.8.3 → 2.9.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.
- package/dist/EffectComposer.d.ts +3 -3
- package/dist/Selection.d.ts +3 -3
- package/dist/effects/BrightnessContrast.d.ts +8 -1
- package/dist/effects/ChromaticAberration.d.ts +5 -3
- package/dist/effects/ColorAverage.d.ts +1 -1
- package/dist/effects/ColorDepth.d.ts +7 -1
- package/dist/effects/Depth.d.ts +7 -1
- package/dist/effects/DepthOfField.d.ts +16 -11
- package/dist/effects/DotScreen.d.ts +8 -1
- package/dist/effects/Glitch.d.ts +15 -15
- package/dist/effects/GodRays.d.ts +14 -11
- package/dist/effects/Grid.d.ts +5 -5
- package/dist/effects/HueSaturation.d.ts +8 -1
- package/dist/effects/LUT.d.ts +7 -7
- package/dist/effects/Outline.d.ts +22 -17
- package/dist/effects/Pixelation.d.ts +1 -1
- package/dist/effects/SMAA.d.ts +9 -5
- package/dist/effects/SSAO.d.ts +29 -16
- package/dist/effects/SSR.d.ts +1 -1
- package/dist/effects/SelectiveBloom.d.ts +8 -3
- package/dist/effects/Sepia.d.ts +7 -1
- package/dist/effects/ShockWave.d.ts +4 -1
- package/dist/effects/Texture.d.ts +7 -6
- package/dist/effects/TiltShift2.d.ts +11 -9
- package/dist/effects/ToneMapping.d.ts +15 -1
- package/dist/effects/Vignette.d.ts +10 -1
- package/dist/index.cjs +275 -350
- package/dist/index.js +82 -108
- package/dist/util.d.ts +7 -6
- package/package.json +53 -56
package/dist/index.cjs
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var postprocessing = require('postprocessing');
|
|
6
4
|
var _construct = require('@babel/runtime/helpers/construct');
|
|
7
5
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
8
6
|
var _objectWithoutPropertiesLoose = require('@babel/runtime/helpers/objectWithoutPropertiesLoose');
|
|
9
|
-
var React = require('react');
|
|
7
|
+
var React$1 = require('react');
|
|
10
8
|
var THREE = require('three');
|
|
11
9
|
var fiber = require('@react-three/fiber');
|
|
12
10
|
var threeStdlib = require('three-stdlib');
|
|
13
11
|
var _inheritsLoose = require('@babel/runtime/helpers/inheritsLoose');
|
|
14
12
|
var screenSpaceReflections = require('screen-space-reflections');
|
|
15
13
|
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
function _interopNamespace(e) {
|
|
19
|
-
if (e && e.__esModule) return e;
|
|
14
|
+
function _interopNamespaceDefault(e) {
|
|
20
15
|
var n = Object.create(null);
|
|
21
16
|
if (e) {
|
|
22
17
|
Object.keys(e).forEach(function (k) {
|
|
@@ -29,52 +24,42 @@ function _interopNamespace(e) {
|
|
|
29
24
|
}
|
|
30
25
|
});
|
|
31
26
|
}
|
|
32
|
-
n
|
|
27
|
+
n.default = e;
|
|
33
28
|
return Object.freeze(n);
|
|
34
29
|
}
|
|
35
30
|
|
|
36
|
-
var
|
|
37
|
-
var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
|
|
38
|
-
var _objectWithoutPropertiesLoose__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutPropertiesLoose);
|
|
39
|
-
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
40
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
41
|
-
var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
|
|
42
|
-
var _inheritsLoose__default = /*#__PURE__*/_interopDefaultLegacy(_inheritsLoose);
|
|
31
|
+
var THREE__namespace = /*#__PURE__*/_interopNamespaceDefault(THREE);
|
|
43
32
|
|
|
44
33
|
var _excluded$9 = ["blendFunction", "opacity"];
|
|
45
34
|
var resolveRef = function resolveRef(ref) {
|
|
46
|
-
return typeof ref === 'object' && 'current' in ref ? ref.current : ref;
|
|
35
|
+
return typeof ref === 'object' && ref != null && 'current' in ref ? ref.current : ref;
|
|
47
36
|
};
|
|
48
37
|
var i = 0;
|
|
49
38
|
var components = new WeakMap();
|
|
50
39
|
var wrapEffect = function wrapEffect(effect, defaults) {
|
|
51
|
-
return /* @__PURE__ */
|
|
40
|
+
return /* @__PURE__ */React$1.forwardRef(function Effect(_ref, ref) {
|
|
52
41
|
var _ref$blendFunction = _ref.blendFunction,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
42
|
+
blendFunction = _ref$blendFunction === void 0 ? defaults == null ? void 0 : defaults.blendFunction : _ref$blendFunction,
|
|
43
|
+
_ref$opacity = _ref.opacity,
|
|
44
|
+
opacity = _ref$opacity === void 0 ? defaults == null ? void 0 : defaults.opacity : _ref$opacity,
|
|
45
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$9);
|
|
58
46
|
var Component = components.get(effect);
|
|
59
|
-
|
|
60
47
|
if (!Component) {
|
|
61
48
|
var _extend;
|
|
62
|
-
|
|
63
49
|
var key = "@react-three/postprocessing/" + effect.name + "-" + i++;
|
|
64
50
|
fiber.extend((_extend = {}, _extend[key] = effect, _extend));
|
|
65
51
|
components.set(effect, Component = key);
|
|
66
52
|
}
|
|
67
|
-
|
|
68
53
|
var camera = fiber.useThree(function (state) {
|
|
69
54
|
return state.camera;
|
|
70
55
|
});
|
|
71
|
-
var args =
|
|
56
|
+
var args = React$1.useMemo(function () {
|
|
72
57
|
var _defaults$args, _props$args;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
58
|
+
return [].concat((_defaults$args = defaults == null ? void 0 : defaults.args) != null ? _defaults$args : [], (_props$args = props.args) != null ? _props$args : [_extends({}, defaults, props)]);
|
|
59
|
+
},
|
|
60
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
76
61
|
[JSON.stringify(props)]);
|
|
77
|
-
return /*#__PURE__*/
|
|
62
|
+
return /*#__PURE__*/React$1.createElement(Component, _extends({
|
|
78
63
|
camera: camera,
|
|
79
64
|
"blendMode-blendFunction": blendFunction,
|
|
80
65
|
"blendMode-opacity": opacity
|
|
@@ -86,8 +71,8 @@ var wrapEffect = function wrapEffect(effect, defaults) {
|
|
|
86
71
|
};
|
|
87
72
|
var useVector2 = function useVector2(props, key) {
|
|
88
73
|
var value = props[key];
|
|
89
|
-
return
|
|
90
|
-
if (typeof value === 'number') return new THREE__namespace.Vector2(value, value);else if (value) return
|
|
74
|
+
return React$1.useMemo(function () {
|
|
75
|
+
if (typeof value === 'number') return new THREE__namespace.Vector2(value, value);else if (value) return _construct(THREE__namespace.Vector2, value);else return new THREE__namespace.Vector2();
|
|
91
76
|
}, [value]);
|
|
92
77
|
};
|
|
93
78
|
|
|
@@ -97,29 +82,30 @@ var Bloom = wrapEffect(postprocessing.BloomEffect, {
|
|
|
97
82
|
|
|
98
83
|
var BrightnessContrast = wrapEffect(postprocessing.BrightnessContrastEffect);
|
|
99
84
|
|
|
100
|
-
|
|
85
|
+
// type for function args should use constructor args
|
|
86
|
+
|
|
87
|
+
var ChromaticAberration = /*#__PURE__*/React$1.forwardRef(function ChromaticAberration(props, ref) {
|
|
101
88
|
var offset = useVector2(props, 'offset');
|
|
102
|
-
var effect = React.useMemo(function () {
|
|
103
|
-
return new postprocessing.ChromaticAberrationEffect(
|
|
89
|
+
var effect = React$1.useMemo(function () {
|
|
90
|
+
return new postprocessing.ChromaticAberrationEffect(_extends({}, props, {
|
|
104
91
|
offset: offset
|
|
105
92
|
}));
|
|
106
93
|
}, [offset, props]);
|
|
107
|
-
return /*#__PURE__*/
|
|
94
|
+
return /*#__PURE__*/React$1.createElement("primitive", {
|
|
108
95
|
ref: ref,
|
|
109
96
|
object: effect,
|
|
110
97
|
dispose: null
|
|
111
98
|
});
|
|
112
99
|
});
|
|
113
100
|
|
|
114
|
-
var ColorAverage = /*#__PURE__*/React.forwardRef(function ColorAverage(_ref, ref) {
|
|
101
|
+
var ColorAverage = /*#__PURE__*/React$1.forwardRef(function ColorAverage(_ref, ref) {
|
|
115
102
|
var _ref$blendFunction = _ref.blendFunction,
|
|
116
|
-
|
|
117
|
-
|
|
103
|
+
blendFunction = _ref$blendFunction === void 0 ? postprocessing.BlendFunction.NORMAL : _ref$blendFunction;
|
|
118
104
|
/** Because ColorAverage blendFunction is not an object but a number, we have to define a custom prop "blendFunction" */
|
|
119
|
-
var effect = React.useMemo(function () {
|
|
105
|
+
var effect = React$1.useMemo(function () {
|
|
120
106
|
return new postprocessing.ColorAverageEffect(blendFunction);
|
|
121
107
|
}, [blendFunction]);
|
|
122
|
-
return /*#__PURE__*/
|
|
108
|
+
return /*#__PURE__*/React$1.createElement("primitive", {
|
|
123
109
|
ref: ref,
|
|
124
110
|
object: effect,
|
|
125
111
|
dispose: null
|
|
@@ -130,75 +116,67 @@ var ColorDepth = wrapEffect(postprocessing.ColorDepthEffect);
|
|
|
130
116
|
|
|
131
117
|
var Depth = wrapEffect(postprocessing.DepthEffect);
|
|
132
118
|
|
|
133
|
-
var EffectComposerContext = /*#__PURE__*/React.createContext(null);
|
|
134
|
-
var EffectComposer = /*#__PURE__*/
|
|
119
|
+
var EffectComposerContext = /*#__PURE__*/React$1.createContext(null);
|
|
120
|
+
var EffectComposer = /*#__PURE__*/React$1.memo( /*#__PURE__*/React$1.forwardRef(function (_ref, ref) {
|
|
135
121
|
var children = _ref.children,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
122
|
+
_camera = _ref.camera,
|
|
123
|
+
_scene = _ref.scene,
|
|
124
|
+
resolutionScale = _ref.resolutionScale,
|
|
125
|
+
_ref$enabled = _ref.enabled,
|
|
126
|
+
enabled = _ref$enabled === void 0 ? true : _ref$enabled,
|
|
127
|
+
_ref$renderPriority = _ref.renderPriority,
|
|
128
|
+
renderPriority = _ref$renderPriority === void 0 ? 1 : _ref$renderPriority,
|
|
129
|
+
_ref$autoClear = _ref.autoClear,
|
|
130
|
+
autoClear = _ref$autoClear === void 0 ? true : _ref$autoClear,
|
|
131
|
+
depthBuffer = _ref.depthBuffer,
|
|
132
|
+
disableNormalPass = _ref.disableNormalPass,
|
|
133
|
+
stencilBuffer = _ref.stencilBuffer,
|
|
134
|
+
_ref$multisampling = _ref.multisampling,
|
|
135
|
+
multisampling = _ref$multisampling === void 0 ? 8 : _ref$multisampling,
|
|
136
|
+
_ref$frameBufferType = _ref.frameBufferType,
|
|
137
|
+
frameBufferType = _ref$frameBufferType === void 0 ? THREE.HalfFloatType : _ref$frameBufferType;
|
|
153
138
|
var _useThree = fiber.useThree(),
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
multisampling: multisampling > 0 && webGL2Available ? multisampling : 0,
|
|
170
|
-
frameBufferType: frameBufferType
|
|
171
|
-
}); // Add render pass
|
|
172
|
-
|
|
173
|
-
// Add render pass
|
|
174
|
-
effectComposer.addPass(new postprocessing.RenderPass(scene, camera)); // Create normal pass
|
|
175
|
-
|
|
176
|
-
// Create normal pass
|
|
177
|
-
var downSamplingPass = null;
|
|
178
|
-
var normalPass = null;
|
|
179
|
-
|
|
180
|
-
if (!disableNormalPass) {
|
|
181
|
-
normalPass = new postprocessing.NormalPass(scene, camera);
|
|
182
|
-
normalPass.enabled = false;
|
|
183
|
-
effectComposer.addPass(normalPass);
|
|
184
|
-
|
|
185
|
-
if (resolutionScale !== undefined && webGL2Available) {
|
|
186
|
-
downSamplingPass = new postprocessing.DepthDownsamplingPass({
|
|
187
|
-
normalBuffer: normalPass.texture,
|
|
188
|
-
resolutionScale: resolutionScale
|
|
189
|
-
});
|
|
190
|
-
downSamplingPass.enabled = false;
|
|
191
|
-
effectComposer.addPass(downSamplingPass);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
return [effectComposer, normalPass, downSamplingPass];
|
|
196
|
-
}, [camera, gl, depthBuffer, stencilBuffer, multisampling, frameBufferType, scene, disableNormalPass, resolutionScale]),
|
|
197
|
-
composer = _useMemo[0],
|
|
198
|
-
normalPass = _useMemo[1],
|
|
199
|
-
downSamplingPass = _useMemo[2];
|
|
139
|
+
gl = _useThree.gl,
|
|
140
|
+
defaultScene = _useThree.scene,
|
|
141
|
+
defaultCamera = _useThree.camera,
|
|
142
|
+
size = _useThree.size;
|
|
143
|
+
var scene = _scene || defaultScene;
|
|
144
|
+
var camera = _camera || defaultCamera;
|
|
145
|
+
var _useMemo = React$1.useMemo(function () {
|
|
146
|
+
var webGL2Available = threeStdlib.isWebGL2Available();
|
|
147
|
+
// Initialize composer
|
|
148
|
+
var effectComposer = new postprocessing.EffectComposer(gl, {
|
|
149
|
+
depthBuffer: depthBuffer,
|
|
150
|
+
stencilBuffer: stencilBuffer,
|
|
151
|
+
multisampling: multisampling > 0 && webGL2Available ? multisampling : 0,
|
|
152
|
+
frameBufferType: frameBufferType
|
|
153
|
+
});
|
|
200
154
|
|
|
201
|
-
|
|
155
|
+
// Add render pass
|
|
156
|
+
effectComposer.addPass(new postprocessing.RenderPass(scene, camera));
|
|
157
|
+
|
|
158
|
+
// Create normal pass
|
|
159
|
+
var downSamplingPass = null;
|
|
160
|
+
var normalPass = null;
|
|
161
|
+
if (!disableNormalPass) {
|
|
162
|
+
normalPass = new postprocessing.NormalPass(scene, camera);
|
|
163
|
+
normalPass.enabled = false;
|
|
164
|
+
effectComposer.addPass(normalPass);
|
|
165
|
+
if (resolutionScale !== undefined && webGL2Available) {
|
|
166
|
+
downSamplingPass = new postprocessing.DepthDownsamplingPass({
|
|
167
|
+
normalBuffer: normalPass.texture,
|
|
168
|
+
resolutionScale: resolutionScale
|
|
169
|
+
});
|
|
170
|
+
downSamplingPass.enabled = false;
|
|
171
|
+
effectComposer.addPass(downSamplingPass);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return [effectComposer, normalPass, downSamplingPass];
|
|
175
|
+
}, [camera, gl, depthBuffer, stencilBuffer, multisampling, frameBufferType, scene, disableNormalPass, resolutionScale]),
|
|
176
|
+
composer = _useMemo[0],
|
|
177
|
+
normalPass = _useMemo[1],
|
|
178
|
+
downSamplingPass = _useMemo[2];
|
|
179
|
+
React$1.useEffect(function () {
|
|
202
180
|
return composer == null ? void 0 : composer.setSize(size.width, size.height);
|
|
203
181
|
}, [composer, size]);
|
|
204
182
|
fiber.useFrame(function (_, delta) {
|
|
@@ -207,26 +185,26 @@ var EffectComposer = /*#__PURE__*/React__default["default"].memo( /*#__PURE__*/R
|
|
|
207
185
|
composer.render(delta);
|
|
208
186
|
}
|
|
209
187
|
}, enabled ? renderPriority : 0);
|
|
210
|
-
var group = React.useRef(null);
|
|
211
|
-
|
|
188
|
+
var group = React$1.useRef(null);
|
|
189
|
+
var instance = fiber.useInstanceHandle(group);
|
|
190
|
+
React$1.useLayoutEffect(function () {
|
|
212
191
|
var effectPass;
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
effectPass = _construct__default["default"](postprocessing.EffectPass, [camera].concat(group.current.__r3f.objects));
|
|
192
|
+
if (group.current && instance.current && composer) {
|
|
193
|
+
effectPass = _construct(postprocessing.EffectPass, [camera].concat(instance.current.objects));
|
|
216
194
|
effectPass.renderToScreen = true;
|
|
217
195
|
composer.addPass(effectPass);
|
|
218
196
|
if (normalPass) normalPass.enabled = true;
|
|
219
197
|
if (downSamplingPass) downSamplingPass.enabled = true;
|
|
220
198
|
}
|
|
221
|
-
|
|
222
199
|
return function () {
|
|
223
200
|
if (effectPass) composer == null ? void 0 : composer.removePass(effectPass);
|
|
224
201
|
if (normalPass) normalPass.enabled = false;
|
|
225
202
|
if (downSamplingPass) downSamplingPass.enabled = false;
|
|
226
203
|
};
|
|
227
|
-
}, [composer, children, camera, normalPass, downSamplingPass]);
|
|
204
|
+
}, [composer, children, camera, normalPass, downSamplingPass, instance]);
|
|
228
205
|
|
|
229
|
-
|
|
206
|
+
// Memoize state, otherwise it would trigger all consumers on every render
|
|
207
|
+
var state = React$1.useMemo(function () {
|
|
230
208
|
return {
|
|
231
209
|
composer: composer,
|
|
232
210
|
normalPass: normalPass,
|
|
@@ -235,44 +213,41 @@ var EffectComposer = /*#__PURE__*/React__default["default"].memo( /*#__PURE__*/R
|
|
|
235
213
|
camera: camera,
|
|
236
214
|
scene: scene
|
|
237
215
|
};
|
|
238
|
-
}, [composer, normalPass, downSamplingPass, resolutionScale, camera, scene]);
|
|
216
|
+
}, [composer, normalPass, downSamplingPass, resolutionScale, camera, scene]);
|
|
239
217
|
|
|
240
|
-
|
|
218
|
+
// Expose the composer
|
|
219
|
+
React$1.useImperativeHandle(ref, function () {
|
|
241
220
|
return composer;
|
|
242
221
|
}, [composer]);
|
|
243
|
-
return /*#__PURE__*/
|
|
222
|
+
return /*#__PURE__*/React$1.createElement(EffectComposerContext.Provider, {
|
|
244
223
|
value: state
|
|
245
|
-
}, /*#__PURE__*/
|
|
224
|
+
}, /*#__PURE__*/React$1.createElement("group", {
|
|
246
225
|
ref: group
|
|
247
226
|
}, children));
|
|
248
227
|
}));
|
|
249
228
|
|
|
250
229
|
var _excluded$8 = ["target", "depthTexture"];
|
|
251
|
-
var DepthOfField = /*#__PURE__*/React.forwardRef(function DepthOfField(_ref, ref) {
|
|
230
|
+
var DepthOfField = /*#__PURE__*/React$1.forwardRef(function DepthOfField(_ref, ref) {
|
|
252
231
|
var target = _ref.target,
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
232
|
+
depthTexture = _ref.depthTexture,
|
|
233
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$8);
|
|
256
234
|
var invalidate = fiber.useThree(function (state) {
|
|
257
235
|
return state.invalidate;
|
|
258
236
|
});
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
var effect = React.useMemo(function () {
|
|
237
|
+
var _useContext = React$1.useContext(EffectComposerContext),
|
|
238
|
+
camera = _useContext.camera;
|
|
239
|
+
var effect = React$1.useMemo(function () {
|
|
264
240
|
return new postprocessing.DepthOfFieldEffect(camera, props);
|
|
265
241
|
}, [camera, props]);
|
|
266
|
-
React.useLayoutEffect(function () {
|
|
267
|
-
if (target) {
|
|
242
|
+
React$1.useLayoutEffect(function () {
|
|
243
|
+
if (target && typeof target !== 'number') {
|
|
268
244
|
var vec = target instanceof THREE.Vector3 ? new THREE.Vector3().set(target.x, target.y, target.z) : new THREE.Vector3().set(target[0], target[1], target[2]);
|
|
269
245
|
effect.target = vec;
|
|
270
246
|
}
|
|
271
|
-
|
|
272
247
|
if (depthTexture) effect.setDepthTexture(depthTexture.texture, depthTexture.packing);
|
|
273
248
|
invalidate();
|
|
274
249
|
}, [target, depthTexture, effect]);
|
|
275
|
-
return /*#__PURE__*/
|
|
250
|
+
return /*#__PURE__*/React.createElement("primitive", {
|
|
276
251
|
ref: ref,
|
|
277
252
|
object: effect,
|
|
278
253
|
dispose: null
|
|
@@ -282,43 +257,41 @@ var DepthOfField = /*#__PURE__*/React.forwardRef(function DepthOfField(_ref, ref
|
|
|
282
257
|
var DotScreen = wrapEffect(postprocessing.DotScreenEffect);
|
|
283
258
|
|
|
284
259
|
var _excluded$7 = ["active"];
|
|
285
|
-
var Glitch = /*#__PURE__*/React.forwardRef(function Glitch(_ref, ref) {
|
|
260
|
+
var Glitch = /*#__PURE__*/React$1.forwardRef(function Glitch(_ref, ref) {
|
|
286
261
|
var _ref$active = _ref.active,
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
262
|
+
active = _ref$active === void 0 ? true : _ref$active,
|
|
263
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
290
264
|
var invalidate = fiber.useThree(function (state) {
|
|
291
265
|
return state.invalidate;
|
|
292
266
|
});
|
|
293
267
|
var delay = useVector2(props, 'delay');
|
|
294
268
|
var duration = useVector2(props, 'duration');
|
|
295
269
|
var strength = useVector2(props, 'strength');
|
|
296
|
-
var effect = React.useMemo(function () {
|
|
297
|
-
return new postprocessing.GlitchEffect(
|
|
270
|
+
var effect = React$1.useMemo(function () {
|
|
271
|
+
return new postprocessing.GlitchEffect(_extends({}, props, {
|
|
298
272
|
delay: delay,
|
|
299
273
|
duration: duration,
|
|
300
274
|
strength: strength
|
|
301
275
|
}));
|
|
302
276
|
}, [delay, duration, props, strength]);
|
|
303
|
-
React.useLayoutEffect(function () {
|
|
277
|
+
React$1.useLayoutEffect(function () {
|
|
304
278
|
effect.mode = active ? props.mode || postprocessing.GlitchMode.SPORADIC : postprocessing.GlitchMode.DISABLED;
|
|
305
279
|
invalidate();
|
|
306
|
-
}, [active, effect, props.mode]);
|
|
307
|
-
return /*#__PURE__*/
|
|
280
|
+
}, [active, effect, invalidate, props.mode]);
|
|
281
|
+
return /*#__PURE__*/React.createElement("primitive", {
|
|
308
282
|
ref: ref,
|
|
309
283
|
object: effect,
|
|
310
284
|
dispose: null
|
|
311
285
|
});
|
|
312
286
|
});
|
|
313
287
|
|
|
314
|
-
var GodRays = /*#__PURE__*/React.forwardRef(function GodRays(props, ref) {
|
|
315
|
-
var _useContext = React.useContext(EffectComposerContext),
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
var effect = React.useMemo(function () {
|
|
288
|
+
var GodRays = /*#__PURE__*/React$1.forwardRef(function GodRays(props, ref) {
|
|
289
|
+
var _useContext = React$1.useContext(EffectComposerContext),
|
|
290
|
+
camera = _useContext.camera;
|
|
291
|
+
var effect = React$1.useMemo(function () {
|
|
319
292
|
return new postprocessing.GodRaysEffect(camera, props.sun, props);
|
|
320
293
|
}, [camera, props]);
|
|
321
|
-
return /*#__PURE__*/
|
|
294
|
+
return /*#__PURE__*/React$1.createElement("primitive", {
|
|
322
295
|
ref: ref,
|
|
323
296
|
object: effect,
|
|
324
297
|
dispose: null
|
|
@@ -326,21 +299,20 @@ var GodRays = /*#__PURE__*/React.forwardRef(function GodRays(props, ref) {
|
|
|
326
299
|
});
|
|
327
300
|
|
|
328
301
|
var _excluded$6 = ["size"];
|
|
329
|
-
var Grid = /*#__PURE__*/React.forwardRef(function Grid(_ref, ref) {
|
|
302
|
+
var Grid = /*#__PURE__*/React$1.forwardRef(function Grid(_ref, ref) {
|
|
330
303
|
var size = _ref.size,
|
|
331
|
-
|
|
332
|
-
|
|
304
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
333
305
|
var invalidate = fiber.useThree(function (state) {
|
|
334
306
|
return state.invalidate;
|
|
335
307
|
});
|
|
336
|
-
var effect = React.useMemo(function () {
|
|
308
|
+
var effect = React$1.useMemo(function () {
|
|
337
309
|
return new postprocessing.GridEffect(props);
|
|
338
310
|
}, [props]);
|
|
339
|
-
React.useLayoutEffect(function () {
|
|
311
|
+
React$1.useLayoutEffect(function () {
|
|
340
312
|
if (size) effect.setSize(size.width, size.height);
|
|
341
313
|
invalidate();
|
|
342
314
|
}, [effect, size]);
|
|
343
|
-
return /*#__PURE__*/
|
|
315
|
+
return /*#__PURE__*/React$1.createElement("primitive", {
|
|
344
316
|
ref: ref,
|
|
345
317
|
object: effect,
|
|
346
318
|
dispose: null
|
|
@@ -354,36 +326,33 @@ var Noise = wrapEffect(postprocessing.NoiseEffect, {
|
|
|
354
326
|
});
|
|
355
327
|
|
|
356
328
|
var _excluded$5 = ["enabled", "children"];
|
|
357
|
-
var selectionContext = /*#__PURE__*/React.createContext(null);
|
|
329
|
+
var selectionContext = /*#__PURE__*/React$1.createContext(null);
|
|
358
330
|
function Selection(_ref) {
|
|
359
331
|
var children = _ref.children,
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
var value = React.useMemo(function () {
|
|
332
|
+
_ref$enabled = _ref.enabled,
|
|
333
|
+
enabled = _ref$enabled === void 0 ? true : _ref$enabled;
|
|
334
|
+
var _useState = React$1.useState([]),
|
|
335
|
+
selected = _useState[0],
|
|
336
|
+
select = _useState[1];
|
|
337
|
+
var value = React$1.useMemo(function () {
|
|
368
338
|
return {
|
|
369
339
|
selected: selected,
|
|
370
340
|
select: select,
|
|
371
341
|
enabled: enabled
|
|
372
342
|
};
|
|
373
343
|
}, [selected, select, enabled]);
|
|
374
|
-
return /*#__PURE__*/
|
|
344
|
+
return /*#__PURE__*/React$1.createElement(selectionContext.Provider, {
|
|
375
345
|
value: value
|
|
376
346
|
}, children);
|
|
377
347
|
}
|
|
378
348
|
function Select(_ref2) {
|
|
379
349
|
var _ref2$enabled = _ref2.enabled,
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
var
|
|
385
|
-
|
|
386
|
-
React.useEffect(function () {
|
|
350
|
+
enabled = _ref2$enabled === void 0 ? false : _ref2$enabled,
|
|
351
|
+
children = _ref2.children,
|
|
352
|
+
props = _objectWithoutPropertiesLoose(_ref2, _excluded$5);
|
|
353
|
+
var group = React$1.useRef(null);
|
|
354
|
+
var api = React$1.useContext(selectionContext);
|
|
355
|
+
React$1.useEffect(function () {
|
|
387
356
|
if (api && enabled) {
|
|
388
357
|
var changed = false;
|
|
389
358
|
var current = [];
|
|
@@ -391,7 +360,6 @@ function Select(_ref2) {
|
|
|
391
360
|
o.type === 'Mesh' && current.push(o);
|
|
392
361
|
if (api.selected.indexOf(o) === -1) changed = true;
|
|
393
362
|
});
|
|
394
|
-
|
|
395
363
|
if (changed) {
|
|
396
364
|
api.select(function (state) {
|
|
397
365
|
return [].concat(state, current);
|
|
@@ -406,40 +374,37 @@ function Select(_ref2) {
|
|
|
406
374
|
}
|
|
407
375
|
}
|
|
408
376
|
}, [enabled, children]);
|
|
409
|
-
return /*#__PURE__*/
|
|
377
|
+
return /*#__PURE__*/React$1.createElement("group", _extends({
|
|
410
378
|
ref: group
|
|
411
379
|
}, props), children);
|
|
412
380
|
}
|
|
413
381
|
|
|
414
382
|
var _excluded$4 = ["selection", "selectionLayer", "blendFunction", "patternTexture", "edgeStrength", "pulseSpeed", "visibleEdgeColor", "hiddenEdgeColor", "width", "height", "kernelSize", "blur", "xRay"];
|
|
415
|
-
var Outline = /*#__PURE__*/React.forwardRef(function Outline(_ref, forwardRef) {
|
|
383
|
+
var Outline = /*#__PURE__*/React$1.forwardRef(function Outline(_ref, forwardRef) {
|
|
416
384
|
var _ref$selection = _ref.selection,
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
385
|
+
selection = _ref$selection === void 0 ? [] : _ref$selection,
|
|
386
|
+
_ref$selectionLayer = _ref.selectionLayer,
|
|
387
|
+
selectionLayer = _ref$selectionLayer === void 0 ? 10 : _ref$selectionLayer,
|
|
388
|
+
blendFunction = _ref.blendFunction,
|
|
389
|
+
patternTexture = _ref.patternTexture,
|
|
390
|
+
edgeStrength = _ref.edgeStrength,
|
|
391
|
+
pulseSpeed = _ref.pulseSpeed,
|
|
392
|
+
visibleEdgeColor = _ref.visibleEdgeColor,
|
|
393
|
+
hiddenEdgeColor = _ref.hiddenEdgeColor,
|
|
394
|
+
width = _ref.width,
|
|
395
|
+
height = _ref.height,
|
|
396
|
+
kernelSize = _ref.kernelSize,
|
|
397
|
+
blur = _ref.blur,
|
|
398
|
+
xRay = _ref.xRay,
|
|
399
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
433
400
|
var invalidate = fiber.useThree(function (state) {
|
|
434
401
|
return state.invalidate;
|
|
435
402
|
});
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
var effect = React.useMemo(function () {
|
|
442
|
-
return new postprocessing.OutlineEffect(scene, camera, _extends__default["default"]({
|
|
403
|
+
var _useContext = React$1.useContext(EffectComposerContext),
|
|
404
|
+
scene = _useContext.scene,
|
|
405
|
+
camera = _useContext.camera;
|
|
406
|
+
var effect = React$1.useMemo(function () {
|
|
407
|
+
return new postprocessing.OutlineEffect(scene, camera, _extends({
|
|
443
408
|
blendFunction: blendFunction,
|
|
444
409
|
patternTexture: patternTexture,
|
|
445
410
|
edgeStrength: edgeStrength,
|
|
@@ -452,9 +417,9 @@ var Outline = /*#__PURE__*/React.forwardRef(function Outline(_ref, forwardRef) {
|
|
|
452
417
|
blur: blur,
|
|
453
418
|
xRay: xRay
|
|
454
419
|
}, props));
|
|
455
|
-
}, [blendFunction, blur, camera, edgeStrength, height, hiddenEdgeColor, kernelSize, patternTexture, pulseSpeed, scene, visibleEdgeColor, width, xRay]);
|
|
456
|
-
var api = React.useContext(selectionContext);
|
|
457
|
-
React.useEffect(function () {
|
|
420
|
+
}, [blendFunction, blur, camera, edgeStrength, height, hiddenEdgeColor, kernelSize, patternTexture, props, pulseSpeed, scene, visibleEdgeColor, width, xRay]);
|
|
421
|
+
var api = React$1.useContext(selectionContext);
|
|
422
|
+
React$1.useEffect(function () {
|
|
458
423
|
// Do not allow array selection if declarative selection is active
|
|
459
424
|
// TODO: array selection should probably be deprecated altogether
|
|
460
425
|
if (!api && selection) {
|
|
@@ -465,16 +430,15 @@ var Outline = /*#__PURE__*/React.forwardRef(function Outline(_ref, forwardRef) {
|
|
|
465
430
|
invalidate();
|
|
466
431
|
};
|
|
467
432
|
}
|
|
468
|
-
}, [effect, selection, api]);
|
|
469
|
-
React.useEffect(function () {
|
|
433
|
+
}, [effect, selection, api, invalidate]);
|
|
434
|
+
React$1.useEffect(function () {
|
|
470
435
|
effect.selectionLayer = selectionLayer;
|
|
471
436
|
invalidate();
|
|
472
|
-
}, [effect, selectionLayer]);
|
|
473
|
-
React.useRef();
|
|
474
|
-
React.useEffect(function () {
|
|
437
|
+
}, [effect, invalidate, selectionLayer]);
|
|
438
|
+
React$1.useRef();
|
|
439
|
+
React$1.useEffect(function () {
|
|
475
440
|
if (api && api.enabled) {
|
|
476
441
|
var _api$selected;
|
|
477
|
-
|
|
478
442
|
if ((_api$selected = api.selected) != null && _api$selected.length) {
|
|
479
443
|
effect.selection.set(api.selected);
|
|
480
444
|
invalidate();
|
|
@@ -484,22 +448,21 @@ var Outline = /*#__PURE__*/React.forwardRef(function Outline(_ref, forwardRef) {
|
|
|
484
448
|
};
|
|
485
449
|
}
|
|
486
450
|
}
|
|
487
|
-
}, [api]);
|
|
488
|
-
return /*#__PURE__*/
|
|
451
|
+
}, [api, effect.selection, invalidate]);
|
|
452
|
+
return /*#__PURE__*/React.createElement("primitive", {
|
|
489
453
|
ref: forwardRef,
|
|
490
454
|
object: effect
|
|
491
455
|
});
|
|
492
456
|
});
|
|
493
457
|
|
|
494
|
-
var Pixelation = /*#__PURE__*/React.forwardRef(function Pixelation(_ref, ref) {
|
|
458
|
+
var Pixelation = /*#__PURE__*/React$1.forwardRef(function Pixelation(_ref, ref) {
|
|
495
459
|
var _ref$granularity = _ref.granularity,
|
|
496
|
-
|
|
497
|
-
|
|
460
|
+
granularity = _ref$granularity === void 0 ? 5 : _ref$granularity;
|
|
498
461
|
/** Because GlitchEffect granularity is not an object but a number, we have to define a custom prop "granularity" */
|
|
499
|
-
var effect = React.useMemo(function () {
|
|
462
|
+
var effect = React$1.useMemo(function () {
|
|
500
463
|
return new postprocessing.PixelationEffect(granularity);
|
|
501
464
|
}, [granularity]);
|
|
502
|
-
return /*#__PURE__*/
|
|
465
|
+
return /*#__PURE__*/React$1.createElement("primitive", {
|
|
503
466
|
ref: ref,
|
|
504
467
|
object: effect,
|
|
505
468
|
dispose: null
|
|
@@ -510,48 +473,39 @@ var Scanline = wrapEffect(postprocessing.ScanlineEffect, {
|
|
|
510
473
|
blendFunction: postprocessing.BlendFunction.OVERLAY
|
|
511
474
|
});
|
|
512
475
|
|
|
513
|
-
var _excluded$3 = ["selection", "selectionLayer", "lights", "luminanceThreshold", "luminanceSmoothing", "intensity", "width", "height", "kernelSize", "mipmapBlur"
|
|
514
|
-
|
|
476
|
+
var _excluded$3 = ["selection", "selectionLayer", "lights", "luminanceThreshold", "luminanceSmoothing", "intensity", "width", "height", "kernelSize", "mipmapBlur"];
|
|
515
477
|
var addLight = function addLight(light, effect) {
|
|
516
478
|
return light.layers.enable(effect.selection.layer);
|
|
517
479
|
};
|
|
518
|
-
|
|
519
480
|
var removeLight = function removeLight(light, effect) {
|
|
520
481
|
return light.layers.disable(effect.selection.layer);
|
|
521
482
|
};
|
|
522
|
-
|
|
523
|
-
var SelectiveBloom = /*#__PURE__*/React.forwardRef(function SelectiveBloom(_ref, forwardRef) {
|
|
483
|
+
var SelectiveBloom = /*#__PURE__*/React$1.forwardRef(function SelectiveBloom(_ref, forwardRef) {
|
|
524
484
|
var _ref$selection = _ref.selection,
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
levels = _ref.levels,
|
|
539
|
-
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded$3);
|
|
540
|
-
|
|
485
|
+
selection = _ref$selection === void 0 ? [] : _ref$selection,
|
|
486
|
+
_ref$selectionLayer = _ref.selectionLayer,
|
|
487
|
+
selectionLayer = _ref$selectionLayer === void 0 ? 10 : _ref$selectionLayer,
|
|
488
|
+
_ref$lights = _ref.lights,
|
|
489
|
+
lights = _ref$lights === void 0 ? [] : _ref$lights,
|
|
490
|
+
luminanceThreshold = _ref.luminanceThreshold,
|
|
491
|
+
luminanceSmoothing = _ref.luminanceSmoothing,
|
|
492
|
+
intensity = _ref.intensity,
|
|
493
|
+
width = _ref.width,
|
|
494
|
+
height = _ref.height,
|
|
495
|
+
kernelSize = _ref.kernelSize,
|
|
496
|
+
mipmapBlur = _ref.mipmapBlur,
|
|
497
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
541
498
|
if (lights.length === 0) {
|
|
542
499
|
console.warn('SelectiveBloom requires lights to work.');
|
|
543
500
|
}
|
|
544
|
-
|
|
545
501
|
var invalidate = fiber.useThree(function (state) {
|
|
546
502
|
return state.invalidate;
|
|
547
503
|
});
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
var effect = React.useMemo(function () {
|
|
554
|
-
return new postprocessing.SelectiveBloomEffect(scene, camera, _extends__default["default"]({
|
|
504
|
+
var _useContext = React$1.useContext(EffectComposerContext),
|
|
505
|
+
scene = _useContext.scene,
|
|
506
|
+
camera = _useContext.camera;
|
|
507
|
+
var effect = React$1.useMemo(function () {
|
|
508
|
+
return new postprocessing.SelectiveBloomEffect(scene, camera, _extends({
|
|
555
509
|
blendFunction: postprocessing.BlendFunction.ADD,
|
|
556
510
|
luminanceThreshold: luminanceThreshold,
|
|
557
511
|
luminanceSmoothing: luminanceSmoothing,
|
|
@@ -559,13 +513,11 @@ var SelectiveBloom = /*#__PURE__*/React.forwardRef(function SelectiveBloom(_ref,
|
|
|
559
513
|
width: width,
|
|
560
514
|
height: height,
|
|
561
515
|
kernelSize: kernelSize,
|
|
562
|
-
mipmapBlur: mipmapBlur
|
|
563
|
-
radius: radius,
|
|
564
|
-
levels: levels
|
|
516
|
+
mipmapBlur: mipmapBlur
|
|
565
517
|
}, props));
|
|
566
|
-
}, [
|
|
567
|
-
var api = React.useContext(selectionContext);
|
|
568
|
-
React.useEffect(function () {
|
|
518
|
+
}, [scene, camera, luminanceThreshold, luminanceSmoothing, intensity, width, height, kernelSize, mipmapBlur, props]);
|
|
519
|
+
var api = React$1.useContext(selectionContext);
|
|
520
|
+
React$1.useEffect(function () {
|
|
569
521
|
// Do not allow array selection if declarative selection is active
|
|
570
522
|
// TODO: array selection should probably be deprecated altogether
|
|
571
523
|
if (!api && selection) {
|
|
@@ -576,12 +528,12 @@ var SelectiveBloom = /*#__PURE__*/React.forwardRef(function SelectiveBloom(_ref,
|
|
|
576
528
|
invalidate();
|
|
577
529
|
};
|
|
578
530
|
}
|
|
579
|
-
}, [effect, selection, api]);
|
|
580
|
-
React.useEffect(function () {
|
|
531
|
+
}, [effect, selection, api, invalidate]);
|
|
532
|
+
React$1.useEffect(function () {
|
|
581
533
|
effect.selection.layer = selectionLayer;
|
|
582
534
|
invalidate();
|
|
583
|
-
}, [effect, selectionLayer]);
|
|
584
|
-
React.useEffect(function () {
|
|
535
|
+
}, [effect, invalidate, selectionLayer]);
|
|
536
|
+
React$1.useEffect(function () {
|
|
585
537
|
if (lights && lights.length > 0) {
|
|
586
538
|
lights.forEach(function (light) {
|
|
587
539
|
return addLight(resolveRef(light), effect);
|
|
@@ -594,12 +546,11 @@ var SelectiveBloom = /*#__PURE__*/React.forwardRef(function SelectiveBloom(_ref,
|
|
|
594
546
|
invalidate();
|
|
595
547
|
};
|
|
596
548
|
}
|
|
597
|
-
}, [effect, lights, selectionLayer]);
|
|
598
|
-
React.useRef();
|
|
599
|
-
React.useEffect(function () {
|
|
549
|
+
}, [effect, invalidate, lights, selectionLayer]);
|
|
550
|
+
React$1.useRef();
|
|
551
|
+
React$1.useEffect(function () {
|
|
600
552
|
if (api && api.enabled) {
|
|
601
553
|
var _api$selected;
|
|
602
|
-
|
|
603
554
|
if ((_api$selected = api.selected) != null && _api$selected.length) {
|
|
604
555
|
effect.selection.set(api.selected);
|
|
605
556
|
invalidate();
|
|
@@ -609,8 +560,8 @@ var SelectiveBloom = /*#__PURE__*/React.forwardRef(function SelectiveBloom(_ref,
|
|
|
609
560
|
};
|
|
610
561
|
}
|
|
611
562
|
}
|
|
612
|
-
}, [api]);
|
|
613
|
-
return /*#__PURE__*/
|
|
563
|
+
}, [api, effect.selection, invalidate]);
|
|
564
|
+
return /*#__PURE__*/React$1.createElement("primitive", {
|
|
614
565
|
ref: forwardRef,
|
|
615
566
|
object: effect,
|
|
616
567
|
dispose: null
|
|
@@ -619,20 +570,20 @@ var SelectiveBloom = /*#__PURE__*/React.forwardRef(function SelectiveBloom(_ref,
|
|
|
619
570
|
|
|
620
571
|
var Sepia = wrapEffect(postprocessing.SepiaEffect);
|
|
621
572
|
|
|
622
|
-
|
|
623
|
-
var _useContext = React.useContext(EffectComposerContext),
|
|
624
|
-
camera = _useContext.camera,
|
|
625
|
-
normalPass = _useContext.normalPass,
|
|
626
|
-
downSamplingPass = _useContext.downSamplingPass,
|
|
627
|
-
resolutionScale = _useContext.resolutionScale;
|
|
573
|
+
// first two args are camera and texture
|
|
628
574
|
|
|
629
|
-
|
|
575
|
+
var SSAO = /*#__PURE__*/React$1.forwardRef(function SSAO(props, ref) {
|
|
576
|
+
var _useContext = React$1.useContext(EffectComposerContext),
|
|
577
|
+
camera = _useContext.camera,
|
|
578
|
+
normalPass = _useContext.normalPass,
|
|
579
|
+
downSamplingPass = _useContext.downSamplingPass,
|
|
580
|
+
resolutionScale = _useContext.resolutionScale;
|
|
581
|
+
var effect = React$1.useMemo(function () {
|
|
630
582
|
if (normalPass === null && downSamplingPass === null) {
|
|
631
583
|
console.error('Please enable the NormalPass in the EffectComposer in order to use SSAO.');
|
|
632
|
-
return
|
|
584
|
+
return {};
|
|
633
585
|
}
|
|
634
|
-
|
|
635
|
-
return new postprocessing.SSAOEffect(camera, normalPass && !downSamplingPass ? normalPass.texture : null, _extends__default["default"]({
|
|
586
|
+
return new postprocessing.SSAOEffect(camera, normalPass && !downSamplingPass ? normalPass.texture : null, _extends({
|
|
636
587
|
blendFunction: postprocessing.BlendFunction.MULTIPLY,
|
|
637
588
|
samples: 30,
|
|
638
589
|
rings: 4,
|
|
@@ -642,56 +593,40 @@ var SSAO = /*#__PURE__*/React.forwardRef(function SSAO(props, ref) {
|
|
|
642
593
|
rangeFalloff: 0.1,
|
|
643
594
|
luminanceInfluence: 0.9,
|
|
644
595
|
radius: 20,
|
|
645
|
-
scale: 0.5,
|
|
646
596
|
bias: 0.5,
|
|
647
597
|
intensity: 1.0,
|
|
648
|
-
color:
|
|
598
|
+
color: undefined,
|
|
649
599
|
// @ts-ignore
|
|
650
600
|
normalDepthBuffer: downSamplingPass ? downSamplingPass.texture : null,
|
|
651
601
|
resolutionScale: resolutionScale != null ? resolutionScale : 1,
|
|
652
602
|
depthAwareUpsampling: true
|
|
653
603
|
}, props));
|
|
654
604
|
}, [camera, normalPass, props]);
|
|
655
|
-
return /*#__PURE__*/
|
|
605
|
+
return /*#__PURE__*/React.createElement("primitive", {
|
|
656
606
|
ref: ref,
|
|
657
607
|
object: effect,
|
|
658
608
|
dispose: null
|
|
659
609
|
});
|
|
660
610
|
});
|
|
661
611
|
|
|
662
|
-
var SMAA =
|
|
663
|
-
var _ref$preset = _ref.preset,
|
|
664
|
-
preset = _ref$preset === void 0 ? postprocessing.SMAAPreset.HIGH : _ref$preset,
|
|
665
|
-
_ref$edgeDetectionMod = _ref.edgeDetectionMode,
|
|
666
|
-
edgeDetectionMode = _ref$edgeDetectionMod === void 0 ? postprocessing.EdgeDetectionMode.COLOR : _ref$edgeDetectionMod;
|
|
667
|
-
var smaaProps = fiber.useLoader(postprocessing.SMAAImageLoader, '');
|
|
668
|
-
var effect = React.useMemo(function () {
|
|
669
|
-
return _construct__default["default"](postprocessing.SMAAEffect, smaaProps.concat([preset, edgeDetectionMode]));
|
|
670
|
-
}, [smaaProps, preset, edgeDetectionMode]);
|
|
671
|
-
return /*#__PURE__*/React__default["default"].createElement("primitive", {
|
|
672
|
-
ref: ref,
|
|
673
|
-
object: effect,
|
|
674
|
-
dispose: null
|
|
675
|
-
});
|
|
676
|
-
});
|
|
612
|
+
var SMAA = wrapEffect(postprocessing.SMAAEffect);
|
|
677
613
|
|
|
678
614
|
var _excluded$2 = ["textureSrc", "texture"];
|
|
679
|
-
var Texture = /*#__PURE__*/React.forwardRef(function Texture(_ref, ref) {
|
|
615
|
+
var Texture = /*#__PURE__*/React$1.forwardRef(function Texture(_ref, ref) {
|
|
680
616
|
var textureSrc = _ref.textureSrc,
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
617
|
+
texture = _ref.texture,
|
|
618
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
684
619
|
var t = fiber.useLoader(THREE.TextureLoader, textureSrc);
|
|
685
|
-
React.useLayoutEffect(function () {
|
|
620
|
+
React$1.useLayoutEffect(function () {
|
|
686
621
|
t.encoding = THREE.sRGBEncoding;
|
|
687
622
|
t.wrapS = t.wrapT = THREE.RepeatWrapping;
|
|
688
623
|
}, [t]);
|
|
689
|
-
var effect = React.useMemo(function () {
|
|
690
|
-
return new postprocessing.TextureEffect(
|
|
624
|
+
var effect = React$1.useMemo(function () {
|
|
625
|
+
return new postprocessing.TextureEffect(_extends({}, props, {
|
|
691
626
|
texture: t || texture
|
|
692
627
|
}));
|
|
693
628
|
}, [props, t, texture]);
|
|
694
|
-
return /*#__PURE__*/
|
|
629
|
+
return /*#__PURE__*/React.createElement("primitive", {
|
|
695
630
|
ref: ref,
|
|
696
631
|
object: effect,
|
|
697
632
|
dispose: null
|
|
@@ -705,23 +640,22 @@ var Vignette = wrapEffect(postprocessing.VignetteEffect);
|
|
|
705
640
|
var ShockWave = wrapEffect(postprocessing.ShockWaveEffect);
|
|
706
641
|
|
|
707
642
|
var _excluded$1 = ["lut", "tetrahedralInterpolation"];
|
|
708
|
-
var LUT = /*#__PURE__*/React.forwardRef(function LUT(_ref, ref) {
|
|
643
|
+
var LUT = /*#__PURE__*/React$1.forwardRef(function LUT(_ref, ref) {
|
|
709
644
|
var lut = _ref.lut,
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
645
|
+
tetrahedralInterpolation = _ref.tetrahedralInterpolation,
|
|
646
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
647
|
+
var effect = React$1.useMemo(function () {
|
|
648
|
+
return new postprocessing.LUT3DEffect(lut, props);
|
|
649
|
+
}, [lut, props]);
|
|
713
650
|
var invalidate = fiber.useThree(function (state) {
|
|
714
651
|
return state.invalidate;
|
|
715
652
|
});
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
React.useLayoutEffect(function () {
|
|
720
|
-
if (lut) effect.setLUT(lut);
|
|
721
|
-
if (tetrahedralInterpolation) effect.setTetrahedralInterpolationEnabled(tetrahedralInterpolation);
|
|
653
|
+
React$1.useLayoutEffect(function () {
|
|
654
|
+
if (tetrahedralInterpolation) effect.tetrahedralInterpolation = tetrahedralInterpolation;
|
|
655
|
+
if (lut) effect.lut = lut;
|
|
722
656
|
invalidate();
|
|
723
|
-
}, [effect, lut, tetrahedralInterpolation]);
|
|
724
|
-
return /*#__PURE__*/
|
|
657
|
+
}, [effect, invalidate, lut, tetrahedralInterpolation]);
|
|
658
|
+
return /*#__PURE__*/React$1.createElement("primitive", {
|
|
725
659
|
ref: ref,
|
|
726
660
|
object: effect,
|
|
727
661
|
dispose: null
|
|
@@ -736,69 +670,60 @@ var TiltShiftShader = {
|
|
|
736
670
|
fragmentShader: "\n\n // original shader by Evan Wallace\n\n #define MAX_ITERATIONS 100\n\n uniform float blur;\n uniform float taper;\n uniform vec2 start;\n uniform vec2 end;\n uniform vec2 direction;\n uniform int samples;\n\n float random(vec3 scale, float seed) {\n /* use the fragment position for a different seed per-pixel */\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n }\n\n void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) {\n vec4 color = vec4(0.0);\n float total = 0.0;\n vec2 startPixel = vec2(start.x * resolution.x, start.y * resolution.y);\n vec2 endPixel = vec2(end.x * resolution.x, end.y * resolution.y);\n float f_samples = float(samples);\n float half_samples = f_samples / 2.0;\n\n // use screen diagonal to normalize blur radii\n float maxScreenDistance = distance(vec2(0.0), resolution); // diagonal distance\n float gradientRadius = taper * (maxScreenDistance);\n float blurRadius = blur * (maxScreenDistance / 16.0);\n\n /* randomize the lookup values to hide the fixed number of samples */\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n vec2 normal = normalize(vec2(startPixel.y - endPixel.y, endPixel.x - startPixel.x));\n float radius = smoothstep(0.0, 1.0, abs(dot(uv * resolution - startPixel, normal)) / gradientRadius) * blurRadius;\n\n #pragma unroll_loop_start\n for (int i = 0; i <= MAX_ITERATIONS; i++) {\n if (i >= samples) { break; } // return early if over sample count\n float f_i = float(i);\n float s_i = -half_samples + f_i;\n float percent = (s_i + offset - 0.5) / half_samples;\n float weight = 1.0 - abs(percent);\n vec4 sample_i = texture2D(inputBuffer, uv + normalize(direction) / resolution * percent * radius);\n /* switch to pre-multiplied alpha to correctly blur transparent images */\n sample_i.rgb *= sample_i.a;\n color += sample_i * weight;\n total += weight;\n }\n #pragma unroll_loop_end\n\n outputColor = color / total;\n\n /* switch back from pre-multiplied alpha */\n outputColor.rgb /= outputColor.a + 0.00001;\n }\n "
|
|
737
671
|
};
|
|
738
672
|
var TiltShiftEffect = /*#__PURE__*/function (_Effect) {
|
|
739
|
-
|
|
740
|
-
|
|
673
|
+
_inheritsLoose(TiltShiftEffect, _Effect);
|
|
741
674
|
function TiltShiftEffect(_temp) {
|
|
742
675
|
var _ref = _temp === void 0 ? {} : _temp,
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
676
|
+
_ref$blendFunction = _ref.blendFunction,
|
|
677
|
+
blendFunction = _ref$blendFunction === void 0 ? postprocessing.BlendFunction.NORMAL : _ref$blendFunction,
|
|
678
|
+
_ref$blur = _ref.blur,
|
|
679
|
+
blur = _ref$blur === void 0 ? 0.15 : _ref$blur,
|
|
680
|
+
_ref$taper = _ref.taper,
|
|
681
|
+
taper = _ref$taper === void 0 ? 0.5 : _ref$taper,
|
|
682
|
+
_ref$start = _ref.start,
|
|
683
|
+
start = _ref$start === void 0 ? [0.5, 0.0] : _ref$start,
|
|
684
|
+
_ref$end = _ref.end,
|
|
685
|
+
end = _ref$end === void 0 ? [0.5, 1.0] : _ref$end,
|
|
686
|
+
_ref$samples = _ref.samples,
|
|
687
|
+
samples = _ref$samples === void 0 ? 10.0 : _ref$samples,
|
|
688
|
+
_ref$direction = _ref.direction,
|
|
689
|
+
direction = _ref$direction === void 0 ? [1, 1] : _ref$direction;
|
|
758
690
|
return _Effect.call(this, 'TiltShiftEffect', TiltShiftShader.fragmentShader, {
|
|
759
691
|
blendFunction: blendFunction,
|
|
760
692
|
attributes: postprocessing.EffectAttribute.CONVOLUTION,
|
|
761
693
|
uniforms: new Map([['blur', new THREE.Uniform(blur)], ['taper', new THREE.Uniform(taper)], ['start', new THREE.Uniform(start)], ['end', new THREE.Uniform(end)], ['samples', new THREE.Uniform(samples)], ['direction', new THREE.Uniform(direction)]])
|
|
762
694
|
}) || this;
|
|
763
695
|
}
|
|
764
|
-
|
|
765
696
|
return TiltShiftEffect;
|
|
766
697
|
}(postprocessing.Effect);
|
|
767
|
-
var TiltShift2 = wrapEffect(TiltShiftEffect
|
|
698
|
+
var TiltShift2 = wrapEffect(TiltShiftEffect, {
|
|
699
|
+
blendFunction: postprocessing.BlendFunction.NORMAL
|
|
700
|
+
});
|
|
768
701
|
|
|
769
702
|
var _excluded = ["ENABLE_BLUR", "USE_MRT"];
|
|
770
703
|
|
|
771
|
-
|
|
772
|
-
var _ref$ENABLE_BLUR = _ref.ENABLE_BLUR,
|
|
773
|
-
ENABLE_BLUR = _ref$ENABLE_BLUR === void 0 ? true : _ref$ENABLE_BLUR,
|
|
774
|
-
_ref$USE_MRT = _ref.USE_MRT,
|
|
775
|
-
USE_MRT = _ref$USE_MRT === void 0 ? true : _ref$USE_MRT,
|
|
776
|
-
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded);
|
|
704
|
+
// first two args are camera and texture
|
|
777
705
|
|
|
706
|
+
var SSR = /*#__PURE__*/React$1.forwardRef(function SSR(_ref, ref) {
|
|
707
|
+
var _ref$ENABLE_BLUR = _ref.ENABLE_BLUR,
|
|
708
|
+
ENABLE_BLUR = _ref$ENABLE_BLUR === void 0 ? true : _ref$ENABLE_BLUR,
|
|
709
|
+
_ref$USE_MRT = _ref.USE_MRT,
|
|
710
|
+
USE_MRT = _ref$USE_MRT === void 0 ? true : _ref$USE_MRT,
|
|
711
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
778
712
|
var _useThree = fiber.useThree(),
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
var effect = React.useMemo(function () {
|
|
786
|
-
return new screenSpaceReflections.SSREffect(scene, camera, _extends__default["default"]({
|
|
713
|
+
invalidate = _useThree.invalidate;
|
|
714
|
+
var _useContext = React$1.useContext(EffectComposerContext),
|
|
715
|
+
scene = _useContext.scene,
|
|
716
|
+
camera = _useContext.camera;
|
|
717
|
+
var effect = React$1.useMemo(function () {
|
|
718
|
+
return new screenSpaceReflections.SSREffect(scene, camera, _extends({
|
|
787
719
|
ENABLE_BLUR: ENABLE_BLUR,
|
|
788
720
|
USE_MRT: USE_MRT
|
|
789
721
|
}, props));
|
|
790
|
-
}, [
|
|
791
|
-
React.
|
|
792
|
-
|
|
793
|
-
return effect[key] = props[key];
|
|
794
|
-
});
|
|
795
|
-
invalidate();
|
|
796
|
-
}, [props]);
|
|
797
|
-
var api = React.useContext(selectionContext);
|
|
798
|
-
React.useEffect(function () {
|
|
722
|
+
}, [scene, camera, ENABLE_BLUR, USE_MRT, props]);
|
|
723
|
+
var api = React$1.useContext(selectionContext);
|
|
724
|
+
React$1.useEffect(function () {
|
|
799
725
|
if (api && api.enabled) {
|
|
800
726
|
var _api$selected;
|
|
801
|
-
|
|
802
727
|
if ((_api$selected = api.selected) != null && _api$selected.length) {
|
|
803
728
|
effect.selection.set(api.selected);
|
|
804
729
|
invalidate();
|
|
@@ -809,10 +734,10 @@ var SSR = /*#__PURE__*/React.forwardRef(function SSR(_ref, ref) {
|
|
|
809
734
|
}
|
|
810
735
|
}
|
|
811
736
|
}, [api]);
|
|
812
|
-
return /*#__PURE__*/
|
|
737
|
+
return /*#__PURE__*/React$1.createElement("primitive", _extends({
|
|
813
738
|
ref: ref,
|
|
814
739
|
object: effect
|
|
815
|
-
});
|
|
740
|
+
}, props));
|
|
816
741
|
});
|
|
817
742
|
|
|
818
743
|
exports.Bloom = Bloom;
|