@react-three/postprocessing 2.2.3 → 2.2.6
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/index.cjs.js +62 -15
- package/dist/index.js +50 -13
- package/package.json +1 -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>
|
package/dist/index.cjs.js
CHANGED
|
@@ -6,12 +6,11 @@ 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
|
-
var without = require('lodash-es/without');
|
|
15
14
|
|
|
16
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
17
16
|
|
|
@@ -39,7 +38,6 @@ var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
|
|
|
39
38
|
var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
|
|
40
39
|
var _construct__default = /*#__PURE__*/_interopDefaultLegacy(_construct);
|
|
41
40
|
var mergeRefs__default = /*#__PURE__*/_interopDefaultLegacy(mergeRefs);
|
|
42
|
-
var without__default = /*#__PURE__*/_interopDefaultLegacy(without);
|
|
43
41
|
|
|
44
42
|
var _excluded$7 = ["blendFunction", "opacity"];
|
|
45
43
|
|
|
@@ -60,12 +58,16 @@ var wrapEffect = function wrapEffect(effectImpl, defaultBlendMode) {
|
|
|
60
58
|
opacity = _ref.opacity,
|
|
61
59
|
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded$7);
|
|
62
60
|
|
|
61
|
+
var invalidate = fiber.useThree(function (state) {
|
|
62
|
+
return state.invalidate;
|
|
63
|
+
});
|
|
63
64
|
var effect = React.useMemo(function () {
|
|
64
65
|
return new effectImpl(props);
|
|
65
66
|
}, [props]);
|
|
66
67
|
React.useLayoutEffect(function () {
|
|
67
68
|
effect.blendMode.blendFunction = blendFunction || defaultBlendMode;
|
|
68
69
|
if (opacity !== undefined) effect.blendMode.opacity.value = opacity;
|
|
70
|
+
invalidate();
|
|
69
71
|
}, [blendFunction, effect.blendMode, opacity]);
|
|
70
72
|
return /*#__PURE__*/React__default["default"].createElement("primitive", {
|
|
71
73
|
ref: ref,
|
|
@@ -228,6 +230,10 @@ var DepthOfField = /*#__PURE__*/React.forwardRef(function DepthOfField(_ref, ref
|
|
|
228
230
|
depthTexture = _ref.depthTexture,
|
|
229
231
|
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded$6);
|
|
230
232
|
|
|
233
|
+
var invalidate = fiber.useThree(function (state) {
|
|
234
|
+
return state.invalidate;
|
|
235
|
+
});
|
|
236
|
+
|
|
231
237
|
var _useContext = React.useContext(EffectComposerContext),
|
|
232
238
|
camera = _useContext.camera;
|
|
233
239
|
|
|
@@ -241,6 +247,7 @@ var DepthOfField = /*#__PURE__*/React.forwardRef(function DepthOfField(_ref, ref
|
|
|
241
247
|
}
|
|
242
248
|
|
|
243
249
|
if (depthTexture) effect.setDepthTexture(depthTexture.texture, depthTexture.packing);
|
|
250
|
+
invalidate();
|
|
244
251
|
}, [target, depthTexture, effect]);
|
|
245
252
|
return /*#__PURE__*/React__default["default"].createElement("primitive", {
|
|
246
253
|
ref: ref,
|
|
@@ -257,6 +264,9 @@ var Glitch = /*#__PURE__*/React.forwardRef(function Glitch(_ref, ref) {
|
|
|
257
264
|
active = _ref$active === void 0 ? true : _ref$active,
|
|
258
265
|
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded$5);
|
|
259
266
|
|
|
267
|
+
var invalidate = fiber.useThree(function (state) {
|
|
268
|
+
return state.invalidate;
|
|
269
|
+
});
|
|
260
270
|
var delay = useVector2(props, 'delay');
|
|
261
271
|
var duration = useVector2(props, 'duration');
|
|
262
272
|
var strength = useVector2(props, 'strength');
|
|
@@ -269,6 +279,7 @@ var Glitch = /*#__PURE__*/React.forwardRef(function Glitch(_ref, ref) {
|
|
|
269
279
|
}, [delay, duration, props, strength]);
|
|
270
280
|
React.useLayoutEffect(function () {
|
|
271
281
|
effect.mode = active ? props.mode || postprocessing.GlitchMode.SPORADIC : postprocessing.GlitchMode.DISABLED;
|
|
282
|
+
invalidate();
|
|
272
283
|
}, [active, effect, props.mode]);
|
|
273
284
|
return /*#__PURE__*/React__default["default"].createElement("primitive", {
|
|
274
285
|
ref: ref,
|
|
@@ -296,11 +307,15 @@ var Grid = /*#__PURE__*/React.forwardRef(function Grid(_ref, ref) {
|
|
|
296
307
|
var size = _ref.size,
|
|
297
308
|
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded$4);
|
|
298
309
|
|
|
310
|
+
var invalidate = fiber.useThree(function (state) {
|
|
311
|
+
return state.invalidate;
|
|
312
|
+
});
|
|
299
313
|
var effect = React.useMemo(function () {
|
|
300
314
|
return new postprocessing.GridEffect(props);
|
|
301
315
|
}, [props]);
|
|
302
316
|
React.useLayoutEffect(function () {
|
|
303
317
|
if (size) effect.setSize(size.width, size.height);
|
|
318
|
+
invalidate();
|
|
304
319
|
}, [effect, size]);
|
|
305
320
|
return /*#__PURE__*/React__default["default"].createElement("primitive", {
|
|
306
321
|
ref: ref,
|
|
@@ -358,7 +373,9 @@ function Select(_ref2) {
|
|
|
358
373
|
});
|
|
359
374
|
return function () {
|
|
360
375
|
api.select(function (state) {
|
|
361
|
-
return
|
|
376
|
+
return state.filter(function (selected) {
|
|
377
|
+
return !current.includes(selected);
|
|
378
|
+
});
|
|
362
379
|
});
|
|
363
380
|
};
|
|
364
381
|
}
|
|
@@ -388,6 +405,10 @@ var Outline = /*#__PURE__*/React.forwardRef(function Outline(_ref, forwardRef) {
|
|
|
388
405
|
xRay = _ref.xRay;
|
|
389
406
|
_objectWithoutPropertiesLoose__default["default"](_ref, _excluded$2);
|
|
390
407
|
|
|
408
|
+
var invalidate = fiber.useThree(function (state) {
|
|
409
|
+
return state.invalidate;
|
|
410
|
+
});
|
|
411
|
+
|
|
391
412
|
var _useContext = React.useContext(EffectComposerContext),
|
|
392
413
|
scene = _useContext.scene,
|
|
393
414
|
camera = _useContext.camera;
|
|
@@ -407,18 +428,23 @@ var Outline = /*#__PURE__*/React.forwardRef(function Outline(_ref, forwardRef) {
|
|
|
407
428
|
xRay: xRay
|
|
408
429
|
});
|
|
409
430
|
}, [blendFunction, blur, camera, edgeStrength, height, hiddenEdgeColor, kernelSize, patternTexture, pulseSpeed, scene, visibleEdgeColor, width, xRay]);
|
|
431
|
+
var api = React.useContext(selectionContext);
|
|
410
432
|
React.useEffect(function () {
|
|
411
|
-
if
|
|
433
|
+
// Do not allow array selection if declarative selection is active
|
|
434
|
+
// TODO: array selection should probably be deprecated altogether
|
|
435
|
+
if (!api && selection) {
|
|
412
436
|
effect.selection.set(Array.isArray(selection) ? selection.map(resolveRef) : [resolveRef(selection)]);
|
|
437
|
+
invalidate();
|
|
413
438
|
return function () {
|
|
414
|
-
|
|
439
|
+
effect.selection.clear();
|
|
440
|
+
invalidate();
|
|
415
441
|
};
|
|
416
442
|
}
|
|
417
|
-
}, [effect, selection]);
|
|
443
|
+
}, [effect, selection, api]);
|
|
418
444
|
React.useEffect(function () {
|
|
419
445
|
effect.selectionLayer = selectionLayer;
|
|
446
|
+
invalidate();
|
|
420
447
|
}, [effect, selectionLayer]);
|
|
421
|
-
var api = React.useContext(selectionContext);
|
|
422
448
|
var ref = React.useRef();
|
|
423
449
|
React.useEffect(function () {
|
|
424
450
|
if (api && api.enabled) {
|
|
@@ -429,8 +455,11 @@ var Outline = /*#__PURE__*/React.forwardRef(function Outline(_ref, forwardRef) {
|
|
|
429
455
|
if ((_api$selected = api.selected) != null && _api$selected.length) {
|
|
430
456
|
_effect.selection.set(api.selected);
|
|
431
457
|
|
|
458
|
+
invalidate();
|
|
432
459
|
return function () {
|
|
433
|
-
|
|
460
|
+
_effect.selection.clear();
|
|
461
|
+
|
|
462
|
+
invalidate();
|
|
434
463
|
};
|
|
435
464
|
}
|
|
436
465
|
}
|
|
@@ -484,6 +513,10 @@ var SelectiveBloom = /*#__PURE__*/React.forwardRef(function SelectiveBloom(_ref,
|
|
|
484
513
|
console.warn('SelectiveBloom requires lights to work.');
|
|
485
514
|
}
|
|
486
515
|
|
|
516
|
+
var invalidate = fiber.useThree(function (state) {
|
|
517
|
+
return state.invalidate;
|
|
518
|
+
});
|
|
519
|
+
|
|
487
520
|
var _useContext = React.useContext(EffectComposerContext),
|
|
488
521
|
scene = _useContext.scene,
|
|
489
522
|
camera = _useContext.camera;
|
|
@@ -499,30 +532,37 @@ var SelectiveBloom = /*#__PURE__*/React.forwardRef(function SelectiveBloom(_ref,
|
|
|
499
532
|
kernelSize: kernelSize
|
|
500
533
|
});
|
|
501
534
|
}, [camera, height, intensity, kernelSize, luminanceSmoothing, luminanceThreshold, scene, width]);
|
|
535
|
+
var api = React.useContext(selectionContext);
|
|
502
536
|
React.useEffect(function () {
|
|
503
|
-
if
|
|
537
|
+
// Do not allow array selection if declarative selection is active
|
|
538
|
+
// TODO: array selection should probably be deprecated altogether
|
|
539
|
+
if (!api && selection) {
|
|
504
540
|
effect.selection.set(Array.isArray(selection) ? selection.map(resolveRef) : [resolveRef(selection)]);
|
|
541
|
+
invalidate();
|
|
505
542
|
return function () {
|
|
506
|
-
|
|
543
|
+
effect.selection.clear();
|
|
544
|
+
invalidate();
|
|
507
545
|
};
|
|
508
546
|
}
|
|
509
|
-
}, [effect, selection]);
|
|
547
|
+
}, [effect, selection, api]);
|
|
510
548
|
React.useEffect(function () {
|
|
511
549
|
effect.selection.layer = selectionLayer;
|
|
550
|
+
invalidate();
|
|
512
551
|
}, [effect, selectionLayer]);
|
|
513
552
|
React.useEffect(function () {
|
|
514
553
|
if (lights && lights.length > 0) {
|
|
515
554
|
lights.forEach(function (light) {
|
|
516
555
|
return addLight(resolveRef(light), effect);
|
|
517
556
|
});
|
|
557
|
+
invalidate();
|
|
518
558
|
return function () {
|
|
519
|
-
|
|
559
|
+
lights.forEach(function (light) {
|
|
520
560
|
return removeLight(resolveRef(light), effect);
|
|
521
561
|
});
|
|
562
|
+
invalidate();
|
|
522
563
|
};
|
|
523
564
|
}
|
|
524
565
|
}, [effect, lights, selectionLayer]);
|
|
525
|
-
var api = React.useContext(selectionContext);
|
|
526
566
|
var ref = React.useRef();
|
|
527
567
|
React.useEffect(function () {
|
|
528
568
|
if (api && api.enabled) {
|
|
@@ -533,8 +573,11 @@ var SelectiveBloom = /*#__PURE__*/React.forwardRef(function SelectiveBloom(_ref,
|
|
|
533
573
|
if ((_api$selected = api.selected) != null && _api$selected.length) {
|
|
534
574
|
_effect.selection.set(api.selected);
|
|
535
575
|
|
|
576
|
+
invalidate();
|
|
536
577
|
return function () {
|
|
537
|
-
|
|
578
|
+
_effect.selection.clear();
|
|
579
|
+
|
|
580
|
+
invalidate();
|
|
538
581
|
};
|
|
539
582
|
}
|
|
540
583
|
}
|
|
@@ -633,12 +676,16 @@ var LUT = /*#__PURE__*/React.forwardRef(function LUT(_ref, ref) {
|
|
|
633
676
|
tetrahedralInterpolation = _ref.tetrahedralInterpolation,
|
|
634
677
|
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded);
|
|
635
678
|
|
|
679
|
+
var invalidate = fiber.useThree(function (state) {
|
|
680
|
+
return state.invalidate;
|
|
681
|
+
});
|
|
636
682
|
var effect = React.useMemo(function () {
|
|
637
683
|
return new postprocessing.LUTEffect(lut, props);
|
|
638
684
|
}, [lut, props]);
|
|
639
685
|
React.useLayoutEffect(function () {
|
|
640
686
|
if (lut) effect.setLUT(lut);
|
|
641
687
|
if (tetrahedralInterpolation) effect.setTetrahedralInterpolationEnabled(tetrahedralInterpolation);
|
|
688
|
+
invalidate();
|
|
642
689
|
}, [effect, lut, tetrahedralInterpolation]);
|
|
643
690
|
return /*#__PURE__*/React__default["default"].createElement("primitive", {
|
|
644
691
|
ref: ref,
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,6 @@ import { useThree, useFrame, useLoader } from '@react-three/fiber';
|
|
|
6
6
|
import { isWebGL2Available } from 'three-stdlib';
|
|
7
7
|
import mergeRefs from 'react-merge-refs';
|
|
8
8
|
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
9
|
-
import without from 'lodash-es/without';
|
|
10
9
|
|
|
11
10
|
const isRef = ref => !!ref.current;
|
|
12
11
|
|
|
@@ -22,10 +21,12 @@ const wrapEffect = function (effectImpl, defaultBlendMode) {
|
|
|
22
21
|
opacity,
|
|
23
22
|
...props
|
|
24
23
|
} = _ref;
|
|
24
|
+
const invalidate = useThree(state => state.invalidate);
|
|
25
25
|
const effect = useMemo(() => new effectImpl(props), [props]);
|
|
26
26
|
useLayoutEffect(() => {
|
|
27
27
|
effect.blendMode.blendFunction = blendFunction || defaultBlendMode;
|
|
28
28
|
if (opacity !== undefined) effect.blendMode.opacity.value = opacity;
|
|
29
|
+
invalidate();
|
|
29
30
|
}, [blendFunction, effect.blendMode, opacity]);
|
|
30
31
|
return /*#__PURE__*/React.createElement("primitive", {
|
|
31
32
|
ref: ref,
|
|
@@ -168,6 +169,7 @@ const DepthOfField = /*#__PURE__*/forwardRef(function DepthOfField(_ref, ref) {
|
|
|
168
169
|
depthTexture,
|
|
169
170
|
...props
|
|
170
171
|
} = _ref;
|
|
172
|
+
const invalidate = useThree(state => state.invalidate);
|
|
171
173
|
const {
|
|
172
174
|
camera
|
|
173
175
|
} = useContext(EffectComposerContext);
|
|
@@ -179,6 +181,7 @@ const DepthOfField = /*#__PURE__*/forwardRef(function DepthOfField(_ref, ref) {
|
|
|
179
181
|
}
|
|
180
182
|
|
|
181
183
|
if (depthTexture) effect.setDepthTexture(depthTexture.texture, depthTexture.packing);
|
|
184
|
+
invalidate();
|
|
182
185
|
}, [target, depthTexture, effect]);
|
|
183
186
|
return /*#__PURE__*/React.createElement("primitive", {
|
|
184
187
|
ref: ref,
|
|
@@ -194,6 +197,7 @@ const Glitch = /*#__PURE__*/forwardRef(function Glitch(_ref, ref) {
|
|
|
194
197
|
active = true,
|
|
195
198
|
...props
|
|
196
199
|
} = _ref;
|
|
200
|
+
const invalidate = useThree(state => state.invalidate);
|
|
197
201
|
const delay = useVector2(props, 'delay');
|
|
198
202
|
const duration = useVector2(props, 'duration');
|
|
199
203
|
const strength = useVector2(props, 'strength');
|
|
@@ -204,6 +208,7 @@ const Glitch = /*#__PURE__*/forwardRef(function Glitch(_ref, ref) {
|
|
|
204
208
|
}), [delay, duration, props, strength]);
|
|
205
209
|
useLayoutEffect(() => {
|
|
206
210
|
effect.mode = active ? props.mode || GlitchMode.SPORADIC : GlitchMode.DISABLED;
|
|
211
|
+
invalidate();
|
|
207
212
|
}, [active, effect, props.mode]);
|
|
208
213
|
return /*#__PURE__*/React.createElement("primitive", {
|
|
209
214
|
ref: ref,
|
|
@@ -229,9 +234,11 @@ const Grid = /*#__PURE__*/forwardRef(function Grid(_ref, ref) {
|
|
|
229
234
|
size,
|
|
230
235
|
...props
|
|
231
236
|
} = _ref;
|
|
237
|
+
const invalidate = useThree(state => state.invalidate);
|
|
232
238
|
const effect = useMemo(() => new GridEffect(props), [props]);
|
|
233
239
|
useLayoutEffect(() => {
|
|
234
240
|
if (size) effect.setSize(size.width, size.height);
|
|
241
|
+
invalidate();
|
|
235
242
|
}, [effect, size]);
|
|
236
243
|
return /*#__PURE__*/React.createElement("primitive", {
|
|
237
244
|
ref: ref,
|
|
@@ -280,7 +287,7 @@ function Select(_ref2) {
|
|
|
280
287
|
if (changed) {
|
|
281
288
|
api.select(state => [...state, ...current]);
|
|
282
289
|
return () => {
|
|
283
|
-
api.select(state =>
|
|
290
|
+
api.select(state => state.filter(selected => !current.includes(selected)));
|
|
284
291
|
};
|
|
285
292
|
}
|
|
286
293
|
}
|
|
@@ -307,6 +314,7 @@ const Outline = /*#__PURE__*/forwardRef(function Outline(_ref, forwardRef) {
|
|
|
307
314
|
xRay,
|
|
308
315
|
...props
|
|
309
316
|
} = _ref;
|
|
317
|
+
const invalidate = useThree(state => state.invalidate);
|
|
310
318
|
const {
|
|
311
319
|
scene,
|
|
312
320
|
camera
|
|
@@ -324,16 +332,23 @@ const Outline = /*#__PURE__*/forwardRef(function Outline(_ref, forwardRef) {
|
|
|
324
332
|
blur,
|
|
325
333
|
xRay
|
|
326
334
|
}), [blendFunction, blur, camera, edgeStrength, height, hiddenEdgeColor, kernelSize, patternTexture, pulseSpeed, scene, visibleEdgeColor, width, xRay]);
|
|
335
|
+
const api = useContext(selectionContext);
|
|
327
336
|
useEffect(() => {
|
|
328
|
-
if
|
|
337
|
+
// Do not allow array selection if declarative selection is active
|
|
338
|
+
// TODO: array selection should probably be deprecated altogether
|
|
339
|
+
if (!api && selection) {
|
|
329
340
|
effect.selection.set(Array.isArray(selection) ? selection.map(resolveRef) : [resolveRef(selection)]);
|
|
330
|
-
|
|
341
|
+
invalidate();
|
|
342
|
+
return () => {
|
|
343
|
+
effect.selection.clear();
|
|
344
|
+
invalidate();
|
|
345
|
+
};
|
|
331
346
|
}
|
|
332
|
-
}, [effect, selection]);
|
|
347
|
+
}, [effect, selection, api]);
|
|
333
348
|
useEffect(() => {
|
|
334
349
|
effect.selectionLayer = selectionLayer;
|
|
350
|
+
invalidate();
|
|
335
351
|
}, [effect, selectionLayer]);
|
|
336
|
-
const api = useContext(selectionContext);
|
|
337
352
|
const ref = useRef();
|
|
338
353
|
useEffect(() => {
|
|
339
354
|
if (api && api.enabled) {
|
|
@@ -343,7 +358,11 @@ const Outline = /*#__PURE__*/forwardRef(function Outline(_ref, forwardRef) {
|
|
|
343
358
|
|
|
344
359
|
if ((_api$selected = api.selected) != null && _api$selected.length) {
|
|
345
360
|
effect.selection.set(api.selected);
|
|
346
|
-
|
|
361
|
+
invalidate();
|
|
362
|
+
return () => {
|
|
363
|
+
effect.selection.clear();
|
|
364
|
+
invalidate();
|
|
365
|
+
};
|
|
347
366
|
}
|
|
348
367
|
}
|
|
349
368
|
}, [api]);
|
|
@@ -390,6 +409,7 @@ const SelectiveBloom = /*#__PURE__*/forwardRef(function SelectiveBloom(_ref, for
|
|
|
390
409
|
console.warn('SelectiveBloom requires lights to work.');
|
|
391
410
|
}
|
|
392
411
|
|
|
412
|
+
const invalidate = useThree(state => state.invalidate);
|
|
393
413
|
const {
|
|
394
414
|
scene,
|
|
395
415
|
camera
|
|
@@ -403,22 +423,33 @@ const SelectiveBloom = /*#__PURE__*/forwardRef(function SelectiveBloom(_ref, for
|
|
|
403
423
|
height,
|
|
404
424
|
kernelSize
|
|
405
425
|
}), [camera, height, intensity, kernelSize, luminanceSmoothing, luminanceThreshold, scene, width]);
|
|
426
|
+
const api = useContext(selectionContext);
|
|
406
427
|
useEffect(() => {
|
|
407
|
-
if
|
|
428
|
+
// Do not allow array selection if declarative selection is active
|
|
429
|
+
// TODO: array selection should probably be deprecated altogether
|
|
430
|
+
if (!api && selection) {
|
|
408
431
|
effect.selection.set(Array.isArray(selection) ? selection.map(resolveRef) : [resolveRef(selection)]);
|
|
409
|
-
|
|
432
|
+
invalidate();
|
|
433
|
+
return () => {
|
|
434
|
+
effect.selection.clear();
|
|
435
|
+
invalidate();
|
|
436
|
+
};
|
|
410
437
|
}
|
|
411
|
-
}, [effect, selection]);
|
|
438
|
+
}, [effect, selection, api]);
|
|
412
439
|
useEffect(() => {
|
|
413
440
|
effect.selection.layer = selectionLayer;
|
|
441
|
+
invalidate();
|
|
414
442
|
}, [effect, selectionLayer]);
|
|
415
443
|
useEffect(() => {
|
|
416
444
|
if (lights && lights.length > 0) {
|
|
417
445
|
lights.forEach(light => addLight(resolveRef(light), effect));
|
|
418
|
-
|
|
446
|
+
invalidate();
|
|
447
|
+
return () => {
|
|
448
|
+
lights.forEach(light => removeLight(resolveRef(light), effect));
|
|
449
|
+
invalidate();
|
|
450
|
+
};
|
|
419
451
|
}
|
|
420
452
|
}, [effect, lights, selectionLayer]);
|
|
421
|
-
const api = useContext(selectionContext);
|
|
422
453
|
const ref = useRef();
|
|
423
454
|
useEffect(() => {
|
|
424
455
|
if (api && api.enabled) {
|
|
@@ -428,7 +459,11 @@ const SelectiveBloom = /*#__PURE__*/forwardRef(function SelectiveBloom(_ref, for
|
|
|
428
459
|
|
|
429
460
|
if ((_api$selected = api.selected) != null && _api$selected.length) {
|
|
430
461
|
effect.selection.set(api.selected);
|
|
431
|
-
|
|
462
|
+
invalidate();
|
|
463
|
+
return () => {
|
|
464
|
+
effect.selection.clear();
|
|
465
|
+
invalidate();
|
|
466
|
+
};
|
|
432
467
|
}
|
|
433
468
|
}
|
|
434
469
|
}, [api]);
|
|
@@ -523,10 +558,12 @@ const LUT = /*#__PURE__*/forwardRef(function LUT(_ref, ref) {
|
|
|
523
558
|
tetrahedralInterpolation,
|
|
524
559
|
...props
|
|
525
560
|
} = _ref;
|
|
561
|
+
const invalidate = useThree(state => state.invalidate);
|
|
526
562
|
const effect = useMemo(() => new LUTEffect(lut, props), [lut, props]);
|
|
527
563
|
useLayoutEffect(() => {
|
|
528
564
|
if (lut) effect.setLUT(lut);
|
|
529
565
|
if (tetrahedralInterpolation) effect.setTetrahedralInterpolationEnabled(tetrahedralInterpolation);
|
|
566
|
+
invalidate();
|
|
530
567
|
}, [effect, lut, tetrahedralInterpolation]);
|
|
531
568
|
return /*#__PURE__*/React.createElement("primitive", {
|
|
532
569
|
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.6",
|
|
4
4
|
"description": "postprocessing wrapper for React and @react-three/fiber",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"postprocessing",
|
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
"typegen": "tsc --emitDeclarationOnly || true"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"lodash-es": "^4.17.21",
|
|
42
41
|
"postprocessing": "6.24.1",
|
|
43
42
|
"react-merge-refs": "^1.1.0",
|
|
44
43
|
"three-stdlib": "^2.8.6"
|