@react-three/postprocessing 2.1.2 → 2.1.3
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/effects/Outline.d.ts +2 -2
- package/dist/effects/SelectiveBloom.d.ts +2 -2
- package/dist/index.cjs.js +60 -29
- package/dist/index.js +19 -16
- package/dist/util.d.ts +5 -2
- package/package.json +4 -4
|
@@ -3,7 +3,7 @@ import React, { MutableRefObject } from 'react';
|
|
|
3
3
|
import { Object3D } from 'three';
|
|
4
4
|
declare type ObjectRef = MutableRefObject<Object3D>;
|
|
5
5
|
export declare type OutlineProps = ConstructorParameters<typeof OutlineEffect>[2] & Partial<{
|
|
6
|
-
selection: ObjectRef | ObjectRef[];
|
|
6
|
+
selection: Object3D | Object3D[] | ObjectRef | ObjectRef[];
|
|
7
7
|
selectionLayer: number;
|
|
8
8
|
}>;
|
|
9
9
|
export declare const Outline: React.ForwardRefExoticComponent<Partial<{
|
|
@@ -19,7 +19,7 @@ export declare const Outline: React.ForwardRefExoticComponent<Partial<{
|
|
|
19
19
|
blur: boolean;
|
|
20
20
|
xRay: boolean;
|
|
21
21
|
}> & Partial<{
|
|
22
|
-
selection: ObjectRef | ObjectRef[];
|
|
22
|
+
selection: Object3D | Object3D[] | ObjectRef | ObjectRef[];
|
|
23
23
|
selectionLayer: number;
|
|
24
24
|
}> & React.RefAttributes<OutlineEffect>>;
|
|
25
25
|
export {};
|
|
@@ -3,8 +3,8 @@ import React, { MutableRefObject } from 'react';
|
|
|
3
3
|
import { Object3D } from 'three';
|
|
4
4
|
declare type ObjectRef = MutableRefObject<Object3D>;
|
|
5
5
|
export declare type SelectiveBloomProps = ConstructorParameters<typeof SelectiveBloomEffect>[2] & Partial<{
|
|
6
|
-
lights: ObjectRef[];
|
|
7
|
-
selection: ObjectRef | ObjectRef[];
|
|
6
|
+
lights: Object3D[] | ObjectRef[];
|
|
7
|
+
selection: Object3D | Object3D[] | ObjectRef | ObjectRef[];
|
|
8
8
|
selectionLayer: number;
|
|
9
9
|
}>;
|
|
10
10
|
export declare const SelectiveBloom: React.ForwardRefExoticComponent<Pick<any, string | number | symbol> & React.RefAttributes<SelectiveBloomEffect>>;
|
package/dist/index.cjs.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var postprocessing = require('postprocessing');
|
|
6
6
|
var _objectWithoutPropertiesLoose = require('@babel/runtime/helpers/objectWithoutPropertiesLoose');
|
|
7
7
|
var React = require('react');
|
|
8
|
-
var
|
|
8
|
+
var THREE = require('three');
|
|
9
9
|
var _extends = require('@babel/runtime/helpers/extends');
|
|
10
10
|
var _construct = require('@babel/runtime/helpers/construct');
|
|
11
11
|
var fiber = require('@react-three/fiber');
|
|
@@ -13,12 +13,39 @@ var threeStdlib = require('three-stdlib');
|
|
|
13
13
|
|
|
14
14
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
15
|
|
|
16
|
+
function _interopNamespace(e) {
|
|
17
|
+
if (e && e.__esModule) return e;
|
|
18
|
+
var n = Object.create(null);
|
|
19
|
+
if (e) {
|
|
20
|
+
Object.keys(e).forEach(function (k) {
|
|
21
|
+
if (k !== 'default') {
|
|
22
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
23
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return e[k]; }
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
n["default"] = e;
|
|
31
|
+
return Object.freeze(n);
|
|
32
|
+
}
|
|
33
|
+
|
|
16
34
|
var _objectWithoutPropertiesLoose__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutPropertiesLoose);
|
|
17
35
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
36
|
+
var THREE__namespace = /*#__PURE__*/_interopNamespace(THREE);
|
|
18
37
|
var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
|
|
19
38
|
var _construct__default = /*#__PURE__*/_interopDefaultLegacy(_construct);
|
|
20
39
|
|
|
21
40
|
var _excluded$6 = ["blendFunction", "opacity"];
|
|
41
|
+
|
|
42
|
+
var isRef = function isRef(ref) {
|
|
43
|
+
return !!ref.current;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
var resolveRef = function resolveRef(ref) {
|
|
47
|
+
return isRef(ref) ? ref.current : ref;
|
|
48
|
+
};
|
|
22
49
|
var wrapEffect = function wrapEffect(effectImpl, defaultBlendMode) {
|
|
23
50
|
if (defaultBlendMode === void 0) {
|
|
24
51
|
defaultBlendMode = postprocessing.BlendFunction.NORMAL;
|
|
@@ -46,12 +73,12 @@ var wrapEffect = function wrapEffect(effectImpl, defaultBlendMode) {
|
|
|
46
73
|
var useVector2 = function useVector2(props, key) {
|
|
47
74
|
var vec = props[key];
|
|
48
75
|
return React.useMemo(function () {
|
|
49
|
-
if (vec instanceof
|
|
50
|
-
return new
|
|
76
|
+
if (vec instanceof THREE.Vector2) {
|
|
77
|
+
return new THREE.Vector2().set(vec.x, vec.y);
|
|
51
78
|
} else if (Array.isArray(vec)) {
|
|
52
79
|
var x = vec[0],
|
|
53
80
|
y = vec[1];
|
|
54
|
-
return new
|
|
81
|
+
return new THREE.Vector2().set(x, y);
|
|
55
82
|
}
|
|
56
83
|
}, [vec]);
|
|
57
84
|
};
|
|
@@ -107,7 +134,8 @@ var EffectComposer = /*#__PURE__*/React__default["default"].memo( /*#__PURE__*/R
|
|
|
107
134
|
stencilBuffer = _ref.stencilBuffer,
|
|
108
135
|
_ref$multisampling = _ref.multisampling,
|
|
109
136
|
multisampling = _ref$multisampling === void 0 ? 8 : _ref$multisampling,
|
|
110
|
-
frameBufferType = _ref.frameBufferType
|
|
137
|
+
_ref$frameBufferType = _ref.frameBufferType,
|
|
138
|
+
frameBufferType = _ref$frameBufferType === void 0 ? THREE__namespace.HalfFloatType : _ref$frameBufferType;
|
|
111
139
|
|
|
112
140
|
var _useThree = fiber.useThree(),
|
|
113
141
|
gl = _useThree.gl,
|
|
@@ -200,7 +228,7 @@ var DepthOfField = /*#__PURE__*/React.forwardRef(function DepthOfField(_ref, ref
|
|
|
200
228
|
}, [camera, props]);
|
|
201
229
|
React.useLayoutEffect(function () {
|
|
202
230
|
if (target) {
|
|
203
|
-
var vec = target instanceof
|
|
231
|
+
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]);
|
|
204
232
|
effect.target = vec;
|
|
205
233
|
}
|
|
206
234
|
|
|
@@ -316,10 +344,12 @@ var Outline = /*#__PURE__*/React.forwardRef(function Outline(_ref, ref) {
|
|
|
316
344
|
});
|
|
317
345
|
}, [blendFunction, blur, camera, edgeStrength, height, hiddenEdgeColor, kernelSize, patternTexture, pulseSpeed, scene, visibleEdgeColor, width, xRay]);
|
|
318
346
|
React.useEffect(function () {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
return
|
|
322
|
-
|
|
347
|
+
if (selection) {
|
|
348
|
+
effect.selection.set(Array.isArray(selection) ? selection.map(resolveRef) : [resolveRef(selection)]);
|
|
349
|
+
return function () {
|
|
350
|
+
return void effect.selection.clear();
|
|
351
|
+
};
|
|
352
|
+
}
|
|
323
353
|
}, [effect, selection]);
|
|
324
354
|
React.useEffect(function () {
|
|
325
355
|
effect.selectionLayer = selectionLayer;
|
|
@@ -349,15 +379,11 @@ var Pixelation = /*#__PURE__*/React.forwardRef(function Pixelation(_ref, ref) {
|
|
|
349
379
|
var Scanline = wrapEffect(postprocessing.ScanlineEffect, postprocessing.BlendFunction.OVERLAY);
|
|
350
380
|
|
|
351
381
|
var addLight = function addLight(light, effect) {
|
|
352
|
-
|
|
353
|
-
light.current.layers.enable(effect.selection.layer);
|
|
354
|
-
}
|
|
382
|
+
return light.layers.enable(effect.selection.layer);
|
|
355
383
|
};
|
|
356
384
|
|
|
357
385
|
var removeLight = function removeLight(light, effect) {
|
|
358
|
-
|
|
359
|
-
light.current.layers.disable(effect.selection.layer);
|
|
360
|
-
}
|
|
386
|
+
return light.layers.disable(effect.selection.layer);
|
|
361
387
|
};
|
|
362
388
|
|
|
363
389
|
var SelectiveBloom = /*#__PURE__*/React.forwardRef(function SelectiveBloom(_ref, ref) {
|
|
@@ -394,22 +420,27 @@ var SelectiveBloom = /*#__PURE__*/React.forwardRef(function SelectiveBloom(_ref,
|
|
|
394
420
|
});
|
|
395
421
|
}, [camera, height, intensity, kernelSize, luminanceSmoothing, luminanceThreshold, scene, width]);
|
|
396
422
|
React.useEffect(function () {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
423
|
+
if (selection) {
|
|
424
|
+
effect.selection.set(Array.isArray(selection) ? selection.map(resolveRef) : [resolveRef(selection)]);
|
|
425
|
+
return function () {
|
|
426
|
+
return void effect.selection.clear();
|
|
427
|
+
};
|
|
428
|
+
}
|
|
400
429
|
}, [effect, selection]);
|
|
401
430
|
React.useEffect(function () {
|
|
402
431
|
effect.selection.layer = selectionLayer;
|
|
403
432
|
}, [effect, selectionLayer]);
|
|
404
433
|
React.useEffect(function () {
|
|
405
|
-
lights.
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
return function () {
|
|
409
|
-
return lights.forEach(function (light) {
|
|
410
|
-
return removeLight(light, effect);
|
|
434
|
+
if (lights && lights.length > 0) {
|
|
435
|
+
lights.forEach(function (light) {
|
|
436
|
+
return addLight(resolveRef(light), effect);
|
|
411
437
|
});
|
|
412
|
-
|
|
438
|
+
return function () {
|
|
439
|
+
return lights.forEach(function (light) {
|
|
440
|
+
return removeLight(resolveRef(light), effect);
|
|
441
|
+
});
|
|
442
|
+
};
|
|
443
|
+
}
|
|
413
444
|
}, [effect, lights, selectionLayer]);
|
|
414
445
|
return /*#__PURE__*/React__default["default"].createElement("primitive", {
|
|
415
446
|
ref: ref,
|
|
@@ -476,10 +507,10 @@ var Texture = /*#__PURE__*/React.forwardRef(function Texture(_ref, ref) {
|
|
|
476
507
|
texture = _ref.texture,
|
|
477
508
|
props = _objectWithoutPropertiesLoose__default["default"](_ref, _excluded$1);
|
|
478
509
|
|
|
479
|
-
var t = fiber.useLoader(
|
|
510
|
+
var t = fiber.useLoader(THREE.TextureLoader, textureSrc);
|
|
480
511
|
React.useLayoutEffect(function () {
|
|
481
|
-
t.encoding =
|
|
482
|
-
t.wrapS = t.wrapT =
|
|
512
|
+
t.encoding = THREE.sRGBEncoding;
|
|
513
|
+
t.wrapS = t.wrapT = THREE.RepeatWrapping;
|
|
483
514
|
}, [t]);
|
|
484
515
|
var effect = React.useMemo(function () {
|
|
485
516
|
return new postprocessing.TextureEffect(_extends__default["default"]({}, props, {
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { BlendFunction, BloomEffect, BrightnessContrastEffect, ChromaticAberrationEffect, ColorAverageEffect, ColorDepthEffect, DepthEffect, EffectComposer as EffectComposer$2, 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, useEffect } from 'react';
|
|
3
|
+
import * as THREE from 'three';
|
|
3
4
|
import { Vector2, Vector3, TextureLoader, sRGBEncoding, RepeatWrapping } from 'three';
|
|
4
5
|
import { useThree, useFrame, useLoader } from '@react-three/fiber';
|
|
5
6
|
import { isWebGL2Available } from 'three-stdlib';
|
|
6
7
|
|
|
8
|
+
const isRef = ref => !!ref.current;
|
|
9
|
+
|
|
10
|
+
const resolveRef = ref => isRef(ref) ? ref.current : ref;
|
|
7
11
|
const wrapEffect = function (effectImpl, defaultBlendMode) {
|
|
8
12
|
if (defaultBlendMode === void 0) {
|
|
9
13
|
defaultBlendMode = BlendFunction.NORMAL;
|
|
@@ -85,7 +89,7 @@ const EffectComposer = /*#__PURE__*/React.memo( /*#__PURE__*/forwardRef((_ref, r
|
|
|
85
89
|
disableNormalPass,
|
|
86
90
|
stencilBuffer,
|
|
87
91
|
multisampling = 8,
|
|
88
|
-
frameBufferType
|
|
92
|
+
frameBufferType = THREE.HalfFloatType
|
|
89
93
|
} = _ref;
|
|
90
94
|
const {
|
|
91
95
|
gl,
|
|
@@ -267,8 +271,10 @@ const Outline = /*#__PURE__*/forwardRef(function Outline(_ref, ref) {
|
|
|
267
271
|
xRay
|
|
268
272
|
}), [blendFunction, blur, camera, edgeStrength, height, hiddenEdgeColor, kernelSize, patternTexture, pulseSpeed, scene, visibleEdgeColor, width, xRay]);
|
|
269
273
|
useEffect(() => {
|
|
270
|
-
|
|
271
|
-
|
|
274
|
+
if (selection) {
|
|
275
|
+
effect.selection.set(Array.isArray(selection) ? selection.map(resolveRef) : [resolveRef(selection)]);
|
|
276
|
+
return () => void effect.selection.clear();
|
|
277
|
+
}
|
|
272
278
|
}, [effect, selection]);
|
|
273
279
|
useEffect(() => {
|
|
274
280
|
effect.selectionLayer = selectionLayer;
|
|
@@ -296,17 +302,9 @@ const Pixelation = /*#__PURE__*/forwardRef(function Pixelation(_ref, ref) {
|
|
|
296
302
|
|
|
297
303
|
const Scanline = wrapEffect(ScanlineEffect, BlendFunction.OVERLAY);
|
|
298
304
|
|
|
299
|
-
const addLight = (light, effect) =>
|
|
300
|
-
if (light.current) {
|
|
301
|
-
light.current.layers.enable(effect.selection.layer);
|
|
302
|
-
}
|
|
303
|
-
};
|
|
305
|
+
const addLight = (light, effect) => light.layers.enable(effect.selection.layer);
|
|
304
306
|
|
|
305
|
-
const removeLight = (light, effect) =>
|
|
306
|
-
if (light.current) {
|
|
307
|
-
light.current.layers.disable(effect.selection.layer);
|
|
308
|
-
}
|
|
309
|
-
};
|
|
307
|
+
const removeLight = (light, effect) => light.layers.disable(effect.selection.layer);
|
|
310
308
|
|
|
311
309
|
const SelectiveBloom = /*#__PURE__*/forwardRef(function SelectiveBloom(_ref, ref) {
|
|
312
310
|
let {
|
|
@@ -339,14 +337,19 @@ const SelectiveBloom = /*#__PURE__*/forwardRef(function SelectiveBloom(_ref, ref
|
|
|
339
337
|
kernelSize
|
|
340
338
|
}), [camera, height, intensity, kernelSize, luminanceSmoothing, luminanceThreshold, scene, width]);
|
|
341
339
|
useEffect(() => {
|
|
342
|
-
|
|
340
|
+
if (selection) {
|
|
341
|
+
effect.selection.set(Array.isArray(selection) ? selection.map(resolveRef) : [resolveRef(selection)]);
|
|
342
|
+
return () => void effect.selection.clear();
|
|
343
|
+
}
|
|
343
344
|
}, [effect, selection]);
|
|
344
345
|
useEffect(() => {
|
|
345
346
|
effect.selection.layer = selectionLayer;
|
|
346
347
|
}, [effect, selectionLayer]);
|
|
347
348
|
useEffect(() => {
|
|
348
|
-
lights.
|
|
349
|
-
|
|
349
|
+
if (lights && lights.length > 0) {
|
|
350
|
+
lights.forEach(light => addLight(resolveRef(light), effect));
|
|
351
|
+
return () => lights.forEach(light => removeLight(resolveRef(light), effect));
|
|
352
|
+
}
|
|
350
353
|
}, [effect, lights, selectionLayer]);
|
|
351
354
|
return /*#__PURE__*/React.createElement("primitive", {
|
|
352
355
|
ref: ref,
|
package/dist/util.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Vector2 } from 'three';
|
|
1
|
+
import React, { MutableRefObject } from 'react';
|
|
2
|
+
import { Vector2, Object3D } from 'three';
|
|
3
3
|
import { Effect, BlendFunction } from 'postprocessing';
|
|
4
|
+
declare type ObjectRef = MutableRefObject<Object3D>;
|
|
5
|
+
export declare const resolveRef: (ref: Object3D | ObjectRef) => Object3D<import("three").Event>;
|
|
4
6
|
export declare const wrapEffect: <T extends new (...args: any[]) => Effect>(effectImpl: T, defaultBlendMode?: BlendFunction) => React.ForwardRefExoticComponent<React.PropsWithoutRef<ConstructorParameters<T>[0] & Partial<{
|
|
5
7
|
blendFunction: BlendFunction;
|
|
6
8
|
opacity: number;
|
|
7
9
|
}>> & React.RefAttributes<T>>;
|
|
8
10
|
export declare const useVector2: (props: any, key: string) => Vector2;
|
|
11
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-three/postprocessing",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "postprocessing wrapper for React and @react-three/fiber",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"postprocessing",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"typegen": "tsc --emitDeclarationOnly || true"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"postprocessing": "^6.
|
|
41
|
+
"postprocessing": "^6.24.0",
|
|
42
42
|
"react-merge-refs": "^1.1.0",
|
|
43
|
-
"three-stdlib": "^2.6
|
|
43
|
+
"three-stdlib": "^2.8.6"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@babel/core": "^7.16.5",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"@react-three/fiber": ">=7.0",
|
|
86
86
|
"react": ">=17.0",
|
|
87
87
|
"react-dom": ">=17.0",
|
|
88
|
-
"three": ">=0.
|
|
88
|
+
"three": ">=0.136.0"
|
|
89
89
|
},
|
|
90
90
|
"peerDependenciesMeta": {
|
|
91
91
|
"react-dom": {
|