@react-three/postprocessing 2.2.1 → 2.2.4
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 +3 -3
- package/dist/effects/Outline.d.ts +1 -2
- package/dist/index.cjs.js +60 -28
- package/dist/index.js +51 -17
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -60,7 +60,7 @@ function App() {
|
|
|
60
60
|
|
|
61
61
|
#### EffectComposer
|
|
62
62
|
|
|
63
|
-
The EffectComposer
|
|
63
|
+
The EffectComposer must wrap all your effects. It will manage them for you.
|
|
64
64
|
|
|
65
65
|
```jsx
|
|
66
66
|
<EffectComposer
|
|
@@ -80,7 +80,7 @@ The EffectComposer is must wrap all your effects. It will manage them for you.
|
|
|
80
80
|
|
|
81
81
|
#### Selection/Select
|
|
82
82
|
|
|
83
|
-
Some effects, like Outline or SelectiveBloom can select specific objects. To manage this in a declarative scene with just references can be messy,
|
|
83
|
+
Some effects, like Outline or SelectiveBloom can select specific objects. To manage this in a declarative scene with just references can be messy, especially when things have to be grouped. These two components take care of it:
|
|
84
84
|
|
|
85
85
|
```jsx
|
|
86
86
|
<Selection
|
|
@@ -94,7 +94,7 @@ Some effects, like Outline or SelectiveBloom can select specific objects. To man
|
|
|
94
94
|
>
|
|
95
95
|
```
|
|
96
96
|
|
|
97
|
-
You wrap everything into a selection,
|
|
97
|
+
You wrap everything into a selection, this one holds all the selections. Now you can individually select objects or groups. Effects that support selections (for instance `Outline`) will acknowledge it.
|
|
98
98
|
|
|
99
99
|
```jsx
|
|
100
100
|
<Selection>
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { OutlineEffect } from 'postprocessing';
|
|
2
2
|
import React, { MutableRefObject } from 'react';
|
|
3
3
|
import { Object3D } from 'three';
|
|
4
|
-
import { BlendFunction } from 'postprocessing';
|
|
5
4
|
declare type ObjectRef = MutableRefObject<Object3D>;
|
|
6
5
|
export declare type OutlineProps = ConstructorParameters<typeof OutlineEffect>[2] & Partial<{
|
|
7
6
|
selection: Object3D | Object3D[] | ObjectRef | ObjectRef[];
|
|
8
7
|
selectionLayer: number;
|
|
9
8
|
}>;
|
|
10
9
|
export declare const Outline: React.ForwardRefExoticComponent<Partial<{
|
|
11
|
-
blendFunction: BlendFunction;
|
|
10
|
+
blendFunction: import("postprocessing").BlendFunction;
|
|
12
11
|
patternTexture: number;
|
|
13
12
|
edgeStrength: number;
|
|
14
13
|
pulseSpeed: number;
|
package/dist/index.cjs.js
CHANGED
|
@@ -6,9 +6,9 @@ var postprocessing = require('postprocessing');
|
|
|
6
6
|
var _objectWithoutPropertiesLoose = require('@babel/runtime/helpers/objectWithoutPropertiesLoose');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var THREE = require('three');
|
|
9
|
+
var fiber = require('@react-three/fiber');
|
|
9
10
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
10
11
|
var _construct = require('@babel/runtime/helpers/construct');
|
|
11
|
-
var fiber = require('@react-three/fiber');
|
|
12
12
|
var threeStdlib = require('three-stdlib');
|
|
13
13
|
var mergeRefs = require('react-merge-refs');
|
|
14
14
|
var without = require('lodash-es/without');
|
|
@@ -60,12 +60,16 @@ var wrapEffect = function wrapEffect(effectImpl, defaultBlendMode) {
|
|
|
60
60
|
opacity = _ref.opacity,
|
|
61
61
|
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded$7);
|
|
62
62
|
|
|
63
|
+
var invalidate = fiber.useThree(function (state) {
|
|
64
|
+
return state.invalidate;
|
|
65
|
+
});
|
|
63
66
|
var effect = React.useMemo(function () {
|
|
64
67
|
return new effectImpl(props);
|
|
65
68
|
}, [props]);
|
|
66
69
|
React.useLayoutEffect(function () {
|
|
67
70
|
effect.blendMode.blendFunction = blendFunction || defaultBlendMode;
|
|
68
71
|
if (opacity !== undefined) effect.blendMode.opacity.value = opacity;
|
|
72
|
+
invalidate();
|
|
69
73
|
}, [blendFunction, effect.blendMode, opacity]);
|
|
70
74
|
return /*#__PURE__*/React__default["default"].createElement("primitive", {
|
|
71
75
|
ref: ref,
|
|
@@ -228,6 +232,10 @@ var DepthOfField = /*#__PURE__*/React.forwardRef(function DepthOfField(_ref, ref
|
|
|
228
232
|
depthTexture = _ref.depthTexture,
|
|
229
233
|
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded$6);
|
|
230
234
|
|
|
235
|
+
var invalidate = fiber.useThree(function (state) {
|
|
236
|
+
return state.invalidate;
|
|
237
|
+
});
|
|
238
|
+
|
|
231
239
|
var _useContext = React.useContext(EffectComposerContext),
|
|
232
240
|
camera = _useContext.camera;
|
|
233
241
|
|
|
@@ -241,6 +249,7 @@ var DepthOfField = /*#__PURE__*/React.forwardRef(function DepthOfField(_ref, ref
|
|
|
241
249
|
}
|
|
242
250
|
|
|
243
251
|
if (depthTexture) effect.setDepthTexture(depthTexture.texture, depthTexture.packing);
|
|
252
|
+
invalidate();
|
|
244
253
|
}, [target, depthTexture, effect]);
|
|
245
254
|
return /*#__PURE__*/React__default["default"].createElement("primitive", {
|
|
246
255
|
ref: ref,
|
|
@@ -257,6 +266,9 @@ var Glitch = /*#__PURE__*/React.forwardRef(function Glitch(_ref, ref) {
|
|
|
257
266
|
active = _ref$active === void 0 ? true : _ref$active,
|
|
258
267
|
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded$5);
|
|
259
268
|
|
|
269
|
+
var invalidate = fiber.useThree(function (state) {
|
|
270
|
+
return state.invalidate;
|
|
271
|
+
});
|
|
260
272
|
var delay = useVector2(props, 'delay');
|
|
261
273
|
var duration = useVector2(props, 'duration');
|
|
262
274
|
var strength = useVector2(props, 'strength');
|
|
@@ -269,6 +281,7 @@ var Glitch = /*#__PURE__*/React.forwardRef(function Glitch(_ref, ref) {
|
|
|
269
281
|
}, [delay, duration, props, strength]);
|
|
270
282
|
React.useLayoutEffect(function () {
|
|
271
283
|
effect.mode = active ? props.mode || postprocessing.GlitchMode.SPORADIC : postprocessing.GlitchMode.DISABLED;
|
|
284
|
+
invalidate();
|
|
272
285
|
}, [active, effect, props.mode]);
|
|
273
286
|
return /*#__PURE__*/React__default["default"].createElement("primitive", {
|
|
274
287
|
ref: ref,
|
|
@@ -296,11 +309,15 @@ var Grid = /*#__PURE__*/React.forwardRef(function Grid(_ref, ref) {
|
|
|
296
309
|
var size = _ref.size,
|
|
297
310
|
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded$4);
|
|
298
311
|
|
|
312
|
+
var invalidate = fiber.useThree(function (state) {
|
|
313
|
+
return state.invalidate;
|
|
314
|
+
});
|
|
299
315
|
var effect = React.useMemo(function () {
|
|
300
316
|
return new postprocessing.GridEffect(props);
|
|
301
317
|
}, [props]);
|
|
302
318
|
React.useLayoutEffect(function () {
|
|
303
319
|
if (size) effect.setSize(size.width, size.height);
|
|
320
|
+
invalidate();
|
|
304
321
|
}, [effect, size]);
|
|
305
322
|
return /*#__PURE__*/React__default["default"].createElement("primitive", {
|
|
306
323
|
ref: ref,
|
|
@@ -375,30 +392,23 @@ var Outline = /*#__PURE__*/React.forwardRef(function Outline(_ref, forwardRef) {
|
|
|
375
392
|
selection = _ref$selection === void 0 ? [] : _ref$selection,
|
|
376
393
|
_ref$selectionLayer = _ref.selectionLayer,
|
|
377
394
|
selectionLayer = _ref$selectionLayer === void 0 ? 10 : _ref$selectionLayer,
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
hiddenEdgeColor = _ref$hiddenEdgeColor === void 0 ? 0xffffff : _ref$hiddenEdgeColor,
|
|
390
|
-
_ref$width = _ref.width,
|
|
391
|
-
width = _ref$width === void 0 ? postprocessing.Resizer.AUTO_SIZE : _ref$width,
|
|
392
|
-
_ref$height = _ref.height,
|
|
393
|
-
height = _ref$height === void 0 ? postprocessing.Resizer.AUTO_SIZE : _ref$height,
|
|
394
|
-
_ref$kernelSize = _ref.kernelSize,
|
|
395
|
-
kernelSize = _ref$kernelSize === void 0 ? postprocessing.KernelSize.VERY_SMALL : _ref$kernelSize,
|
|
396
|
-
_ref$blur = _ref.blur,
|
|
397
|
-
blur = _ref$blur === void 0 ? false : _ref$blur,
|
|
398
|
-
_ref$xRay = _ref.xRay,
|
|
399
|
-
xRay = _ref$xRay === void 0 ? true : _ref$xRay;
|
|
395
|
+
blendFunction = _ref.blendFunction,
|
|
396
|
+
patternTexture = _ref.patternTexture,
|
|
397
|
+
edgeStrength = _ref.edgeStrength,
|
|
398
|
+
pulseSpeed = _ref.pulseSpeed,
|
|
399
|
+
visibleEdgeColor = _ref.visibleEdgeColor,
|
|
400
|
+
hiddenEdgeColor = _ref.hiddenEdgeColor,
|
|
401
|
+
width = _ref.width,
|
|
402
|
+
height = _ref.height,
|
|
403
|
+
kernelSize = _ref.kernelSize,
|
|
404
|
+
blur = _ref.blur,
|
|
405
|
+
xRay = _ref.xRay;
|
|
400
406
|
_objectWithoutPropertiesLoose__default["default"](_ref, _excluded$2);
|
|
401
407
|
|
|
408
|
+
var invalidate = fiber.useThree(function (state) {
|
|
409
|
+
return state.invalidate;
|
|
410
|
+
});
|
|
411
|
+
|
|
402
412
|
var _useContext = React.useContext(EffectComposerContext),
|
|
403
413
|
scene = _useContext.scene,
|
|
404
414
|
camera = _useContext.camera;
|
|
@@ -421,13 +431,16 @@ var Outline = /*#__PURE__*/React.forwardRef(function Outline(_ref, forwardRef) {
|
|
|
421
431
|
React.useEffect(function () {
|
|
422
432
|
if (selection) {
|
|
423
433
|
effect.selection.set(Array.isArray(selection) ? selection.map(resolveRef) : [resolveRef(selection)]);
|
|
434
|
+
invalidate();
|
|
424
435
|
return function () {
|
|
425
|
-
|
|
436
|
+
effect.selection.clear();
|
|
437
|
+
invalidate();
|
|
426
438
|
};
|
|
427
439
|
}
|
|
428
440
|
}, [effect, selection]);
|
|
429
441
|
React.useEffect(function () {
|
|
430
442
|
effect.selectionLayer = selectionLayer;
|
|
443
|
+
invalidate();
|
|
431
444
|
}, [effect, selectionLayer]);
|
|
432
445
|
var api = React.useContext(selectionContext);
|
|
433
446
|
var ref = React.useRef();
|
|
@@ -440,8 +453,11 @@ var Outline = /*#__PURE__*/React.forwardRef(function Outline(_ref, forwardRef) {
|
|
|
440
453
|
if ((_api$selected = api.selected) != null && _api$selected.length) {
|
|
441
454
|
_effect.selection.set(api.selected);
|
|
442
455
|
|
|
456
|
+
invalidate();
|
|
443
457
|
return function () {
|
|
444
|
-
|
|
458
|
+
_effect.selection.clear();
|
|
459
|
+
|
|
460
|
+
invalidate();
|
|
445
461
|
};
|
|
446
462
|
}
|
|
447
463
|
}
|
|
@@ -495,6 +511,10 @@ var SelectiveBloom = /*#__PURE__*/React.forwardRef(function SelectiveBloom(_ref,
|
|
|
495
511
|
console.warn('SelectiveBloom requires lights to work.');
|
|
496
512
|
}
|
|
497
513
|
|
|
514
|
+
var invalidate = fiber.useThree(function (state) {
|
|
515
|
+
return state.invalidate;
|
|
516
|
+
});
|
|
517
|
+
|
|
498
518
|
var _useContext = React.useContext(EffectComposerContext),
|
|
499
519
|
scene = _useContext.scene,
|
|
500
520
|
camera = _useContext.camera;
|
|
@@ -513,23 +533,28 @@ var SelectiveBloom = /*#__PURE__*/React.forwardRef(function SelectiveBloom(_ref,
|
|
|
513
533
|
React.useEffect(function () {
|
|
514
534
|
if (selection) {
|
|
515
535
|
effect.selection.set(Array.isArray(selection) ? selection.map(resolveRef) : [resolveRef(selection)]);
|
|
536
|
+
invalidate();
|
|
516
537
|
return function () {
|
|
517
|
-
|
|
538
|
+
effect.selection.clear();
|
|
539
|
+
invalidate();
|
|
518
540
|
};
|
|
519
541
|
}
|
|
520
542
|
}, [effect, selection]);
|
|
521
543
|
React.useEffect(function () {
|
|
522
544
|
effect.selection.layer = selectionLayer;
|
|
545
|
+
invalidate();
|
|
523
546
|
}, [effect, selectionLayer]);
|
|
524
547
|
React.useEffect(function () {
|
|
525
548
|
if (lights && lights.length > 0) {
|
|
526
549
|
lights.forEach(function (light) {
|
|
527
550
|
return addLight(resolveRef(light), effect);
|
|
528
551
|
});
|
|
552
|
+
invalidate();
|
|
529
553
|
return function () {
|
|
530
|
-
|
|
554
|
+
lights.forEach(function (light) {
|
|
531
555
|
return removeLight(resolveRef(light), effect);
|
|
532
556
|
});
|
|
557
|
+
invalidate();
|
|
533
558
|
};
|
|
534
559
|
}
|
|
535
560
|
}, [effect, lights, selectionLayer]);
|
|
@@ -544,8 +569,11 @@ var SelectiveBloom = /*#__PURE__*/React.forwardRef(function SelectiveBloom(_ref,
|
|
|
544
569
|
if ((_api$selected = api.selected) != null && _api$selected.length) {
|
|
545
570
|
_effect.selection.set(api.selected);
|
|
546
571
|
|
|
572
|
+
invalidate();
|
|
547
573
|
return function () {
|
|
548
|
-
|
|
574
|
+
_effect.selection.clear();
|
|
575
|
+
|
|
576
|
+
invalidate();
|
|
549
577
|
};
|
|
550
578
|
}
|
|
551
579
|
}
|
|
@@ -644,12 +672,16 @@ var LUT = /*#__PURE__*/React.forwardRef(function LUT(_ref, ref) {
|
|
|
644
672
|
tetrahedralInterpolation = _ref.tetrahedralInterpolation,
|
|
645
673
|
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded);
|
|
646
674
|
|
|
675
|
+
var invalidate = fiber.useThree(function (state) {
|
|
676
|
+
return state.invalidate;
|
|
677
|
+
});
|
|
647
678
|
var effect = React.useMemo(function () {
|
|
648
679
|
return new postprocessing.LUTEffect(lut, props);
|
|
649
680
|
}, [lut, props]);
|
|
650
681
|
React.useLayoutEffect(function () {
|
|
651
682
|
if (lut) effect.setLUT(lut);
|
|
652
683
|
if (tetrahedralInterpolation) effect.setTetrahedralInterpolationEnabled(tetrahedralInterpolation);
|
|
684
|
+
invalidate();
|
|
653
685
|
}, [effect, lut, tetrahedralInterpolation]);
|
|
654
686
|
return /*#__PURE__*/React__default["default"].createElement("primitive", {
|
|
655
687
|
ref: ref,
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BlendFunction, BloomEffect, BrightnessContrastEffect, ChromaticAberrationEffect, ColorAverageEffect, ColorDepthEffect, DepthEffect, EffectComposer as EffectComposer$1, RenderPass, NormalPass, EffectPass, DepthOfFieldEffect, DotScreenEffect, GlitchEffect, GlitchMode, GodRaysEffect, GridEffect, HueSaturationEffect, NoiseEffect,
|
|
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
2
|
import React, { forwardRef, useMemo, useLayoutEffect, createContext, useRef, useImperativeHandle, useContext, useState, useEffect } from 'react';
|
|
3
3
|
import * as THREE from 'three';
|
|
4
4
|
import { Vector2, Vector3, TextureLoader, sRGBEncoding, RepeatWrapping } from 'three';
|
|
@@ -22,10 +22,12 @@ const wrapEffect = function (effectImpl, defaultBlendMode) {
|
|
|
22
22
|
opacity,
|
|
23
23
|
...props
|
|
24
24
|
} = _ref;
|
|
25
|
+
const invalidate = useThree(state => state.invalidate);
|
|
25
26
|
const effect = useMemo(() => new effectImpl(props), [props]);
|
|
26
27
|
useLayoutEffect(() => {
|
|
27
28
|
effect.blendMode.blendFunction = blendFunction || defaultBlendMode;
|
|
28
29
|
if (opacity !== undefined) effect.blendMode.opacity.value = opacity;
|
|
30
|
+
invalidate();
|
|
29
31
|
}, [blendFunction, effect.blendMode, opacity]);
|
|
30
32
|
return /*#__PURE__*/React.createElement("primitive", {
|
|
31
33
|
ref: ref,
|
|
@@ -168,6 +170,7 @@ const DepthOfField = /*#__PURE__*/forwardRef(function DepthOfField(_ref, ref) {
|
|
|
168
170
|
depthTexture,
|
|
169
171
|
...props
|
|
170
172
|
} = _ref;
|
|
173
|
+
const invalidate = useThree(state => state.invalidate);
|
|
171
174
|
const {
|
|
172
175
|
camera
|
|
173
176
|
} = useContext(EffectComposerContext);
|
|
@@ -179,6 +182,7 @@ const DepthOfField = /*#__PURE__*/forwardRef(function DepthOfField(_ref, ref) {
|
|
|
179
182
|
}
|
|
180
183
|
|
|
181
184
|
if (depthTexture) effect.setDepthTexture(depthTexture.texture, depthTexture.packing);
|
|
185
|
+
invalidate();
|
|
182
186
|
}, [target, depthTexture, effect]);
|
|
183
187
|
return /*#__PURE__*/React.createElement("primitive", {
|
|
184
188
|
ref: ref,
|
|
@@ -194,6 +198,7 @@ const Glitch = /*#__PURE__*/forwardRef(function Glitch(_ref, ref) {
|
|
|
194
198
|
active = true,
|
|
195
199
|
...props
|
|
196
200
|
} = _ref;
|
|
201
|
+
const invalidate = useThree(state => state.invalidate);
|
|
197
202
|
const delay = useVector2(props, 'delay');
|
|
198
203
|
const duration = useVector2(props, 'duration');
|
|
199
204
|
const strength = useVector2(props, 'strength');
|
|
@@ -204,6 +209,7 @@ const Glitch = /*#__PURE__*/forwardRef(function Glitch(_ref, ref) {
|
|
|
204
209
|
}), [delay, duration, props, strength]);
|
|
205
210
|
useLayoutEffect(() => {
|
|
206
211
|
effect.mode = active ? props.mode || GlitchMode.SPORADIC : GlitchMode.DISABLED;
|
|
212
|
+
invalidate();
|
|
207
213
|
}, [active, effect, props.mode]);
|
|
208
214
|
return /*#__PURE__*/React.createElement("primitive", {
|
|
209
215
|
ref: ref,
|
|
@@ -229,9 +235,11 @@ const Grid = /*#__PURE__*/forwardRef(function Grid(_ref, ref) {
|
|
|
229
235
|
size,
|
|
230
236
|
...props
|
|
231
237
|
} = _ref;
|
|
238
|
+
const invalidate = useThree(state => state.invalidate);
|
|
232
239
|
const effect = useMemo(() => new GridEffect(props), [props]);
|
|
233
240
|
useLayoutEffect(() => {
|
|
234
241
|
if (size) effect.setSize(size.width, size.height);
|
|
242
|
+
invalidate();
|
|
235
243
|
}, [effect, size]);
|
|
236
244
|
return /*#__PURE__*/React.createElement("primitive", {
|
|
237
245
|
ref: ref,
|
|
@@ -294,19 +302,20 @@ const Outline = /*#__PURE__*/forwardRef(function Outline(_ref, forwardRef) {
|
|
|
294
302
|
let {
|
|
295
303
|
selection = [],
|
|
296
304
|
selectionLayer = 10,
|
|
297
|
-
blendFunction
|
|
298
|
-
patternTexture
|
|
299
|
-
edgeStrength
|
|
300
|
-
pulseSpeed
|
|
301
|
-
visibleEdgeColor
|
|
302
|
-
hiddenEdgeColor
|
|
303
|
-
width
|
|
304
|
-
height
|
|
305
|
-
kernelSize
|
|
306
|
-
blur
|
|
307
|
-
xRay
|
|
305
|
+
blendFunction,
|
|
306
|
+
patternTexture,
|
|
307
|
+
edgeStrength,
|
|
308
|
+
pulseSpeed,
|
|
309
|
+
visibleEdgeColor,
|
|
310
|
+
hiddenEdgeColor,
|
|
311
|
+
width,
|
|
312
|
+
height,
|
|
313
|
+
kernelSize,
|
|
314
|
+
blur,
|
|
315
|
+
xRay,
|
|
308
316
|
...props
|
|
309
317
|
} = _ref;
|
|
318
|
+
const invalidate = useThree(state => state.invalidate);
|
|
310
319
|
const {
|
|
311
320
|
scene,
|
|
312
321
|
camera
|
|
@@ -327,11 +336,16 @@ const Outline = /*#__PURE__*/forwardRef(function Outline(_ref, forwardRef) {
|
|
|
327
336
|
useEffect(() => {
|
|
328
337
|
if (selection) {
|
|
329
338
|
effect.selection.set(Array.isArray(selection) ? selection.map(resolveRef) : [resolveRef(selection)]);
|
|
330
|
-
|
|
339
|
+
invalidate();
|
|
340
|
+
return () => {
|
|
341
|
+
effect.selection.clear();
|
|
342
|
+
invalidate();
|
|
343
|
+
};
|
|
331
344
|
}
|
|
332
345
|
}, [effect, selection]);
|
|
333
346
|
useEffect(() => {
|
|
334
347
|
effect.selectionLayer = selectionLayer;
|
|
348
|
+
invalidate();
|
|
335
349
|
}, [effect, selectionLayer]);
|
|
336
350
|
const api = useContext(selectionContext);
|
|
337
351
|
const ref = useRef();
|
|
@@ -343,7 +357,11 @@ const Outline = /*#__PURE__*/forwardRef(function Outline(_ref, forwardRef) {
|
|
|
343
357
|
|
|
344
358
|
if ((_api$selected = api.selected) != null && _api$selected.length) {
|
|
345
359
|
effect.selection.set(api.selected);
|
|
346
|
-
|
|
360
|
+
invalidate();
|
|
361
|
+
return () => {
|
|
362
|
+
effect.selection.clear();
|
|
363
|
+
invalidate();
|
|
364
|
+
};
|
|
347
365
|
}
|
|
348
366
|
}
|
|
349
367
|
}, [api]);
|
|
@@ -390,6 +408,7 @@ const SelectiveBloom = /*#__PURE__*/forwardRef(function SelectiveBloom(_ref, for
|
|
|
390
408
|
console.warn('SelectiveBloom requires lights to work.');
|
|
391
409
|
}
|
|
392
410
|
|
|
411
|
+
const invalidate = useThree(state => state.invalidate);
|
|
393
412
|
const {
|
|
394
413
|
scene,
|
|
395
414
|
camera
|
|
@@ -406,16 +425,25 @@ const SelectiveBloom = /*#__PURE__*/forwardRef(function SelectiveBloom(_ref, for
|
|
|
406
425
|
useEffect(() => {
|
|
407
426
|
if (selection) {
|
|
408
427
|
effect.selection.set(Array.isArray(selection) ? selection.map(resolveRef) : [resolveRef(selection)]);
|
|
409
|
-
|
|
428
|
+
invalidate();
|
|
429
|
+
return () => {
|
|
430
|
+
effect.selection.clear();
|
|
431
|
+
invalidate();
|
|
432
|
+
};
|
|
410
433
|
}
|
|
411
434
|
}, [effect, selection]);
|
|
412
435
|
useEffect(() => {
|
|
413
436
|
effect.selection.layer = selectionLayer;
|
|
437
|
+
invalidate();
|
|
414
438
|
}, [effect, selectionLayer]);
|
|
415
439
|
useEffect(() => {
|
|
416
440
|
if (lights && lights.length > 0) {
|
|
417
441
|
lights.forEach(light => addLight(resolveRef(light), effect));
|
|
418
|
-
|
|
442
|
+
invalidate();
|
|
443
|
+
return () => {
|
|
444
|
+
lights.forEach(light => removeLight(resolveRef(light), effect));
|
|
445
|
+
invalidate();
|
|
446
|
+
};
|
|
419
447
|
}
|
|
420
448
|
}, [effect, lights, selectionLayer]);
|
|
421
449
|
const api = useContext(selectionContext);
|
|
@@ -428,7 +456,11 @@ const SelectiveBloom = /*#__PURE__*/forwardRef(function SelectiveBloom(_ref, for
|
|
|
428
456
|
|
|
429
457
|
if ((_api$selected = api.selected) != null && _api$selected.length) {
|
|
430
458
|
effect.selection.set(api.selected);
|
|
431
|
-
|
|
459
|
+
invalidate();
|
|
460
|
+
return () => {
|
|
461
|
+
effect.selection.clear();
|
|
462
|
+
invalidate();
|
|
463
|
+
};
|
|
432
464
|
}
|
|
433
465
|
}
|
|
434
466
|
}, [api]);
|
|
@@ -523,10 +555,12 @@ const LUT = /*#__PURE__*/forwardRef(function LUT(_ref, ref) {
|
|
|
523
555
|
tetrahedralInterpolation,
|
|
524
556
|
...props
|
|
525
557
|
} = _ref;
|
|
558
|
+
const invalidate = useThree(state => state.invalidate);
|
|
526
559
|
const effect = useMemo(() => new LUTEffect(lut, props), [lut, props]);
|
|
527
560
|
useLayoutEffect(() => {
|
|
528
561
|
if (lut) effect.setLUT(lut);
|
|
529
562
|
if (tetrahedralInterpolation) effect.setTetrahedralInterpolationEnabled(tetrahedralInterpolation);
|
|
563
|
+
invalidate();
|
|
530
564
|
}, [effect, lut, tetrahedralInterpolation]);
|
|
531
565
|
return /*#__PURE__*/React.createElement("primitive", {
|
|
532
566
|
ref: ref,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-three/postprocessing",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4",
|
|
4
4
|
"description": "postprocessing wrapper for React and @react-three/fiber",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"postprocessing",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"lodash-es": "^4.17.21",
|
|
42
|
-
"postprocessing": "
|
|
42
|
+
"postprocessing": "6.24.1",
|
|
43
43
|
"react-merge-refs": "^1.1.0",
|
|
44
44
|
"three-stdlib": "^2.8.6"
|
|
45
45
|
},
|