@react-three/postprocessing 2.15.0 → 2.15.1

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/index.cjs CHANGED
@@ -206,25 +206,70 @@ const useVector2 = (props, key) => {
206
206
  return new THREE__namespace.Vector2();
207
207
  }, [value]);
208
208
  };
209
- const DepthOfField = React.forwardRef(function DepthOfField2({ target, depthTexture, ...props }, ref) {
210
- const invalidate = fiber.useThree((state) => state.invalidate);
209
+ const DepthOfField = React.forwardRef(function DepthOfField2({
210
+ blendFunction,
211
+ worldFocusDistance,
212
+ worldFocusRange,
213
+ focusDistance,
214
+ focusRange,
215
+ focalLength,
216
+ bokehScale,
217
+ resolutionScale,
218
+ resolutionX,
219
+ resolutionY,
220
+ width,
221
+ height,
222
+ target,
223
+ depthTexture,
224
+ ...props
225
+ }, ref) {
211
226
  const { camera } = React.useContext(EffectComposerContext);
227
+ const autoFocus = target != null;
212
228
  const effect = React.useMemo(() => {
213
- const effect2 = new postprocessing.DepthOfFieldEffect(camera, props);
229
+ const effect2 = new postprocessing.DepthOfFieldEffect(camera, {
230
+ blendFunction,
231
+ worldFocusDistance,
232
+ worldFocusRange,
233
+ focusDistance,
234
+ focusRange,
235
+ focalLength,
236
+ bokehScale,
237
+ resolutionScale,
238
+ resolutionX,
239
+ resolutionY,
240
+ width,
241
+ height
242
+ });
243
+ if (autoFocus)
244
+ effect2.target = new THREE.Vector3();
245
+ if (depthTexture)
246
+ effect2.setDepthTexture(depthTexture.texture, depthTexture.packing);
214
247
  const maskMaterial = effect2.maskPass.getFullscreenMaterial();
215
248
  maskMaterial.maskFunction = postprocessing.MaskFunction.MULTIPLY_RGB_SET_ALPHA;
216
249
  return effect2;
217
- }, [camera, props]);
218
- React.useLayoutEffect(() => {
219
- if (target && typeof target !== "number") {
220
- const 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]);
221
- effect.target = vec;
222
- }
223
- if (depthTexture)
224
- effect.setDepthTexture(depthTexture.texture, depthTexture.packing);
225
- invalidate();
226
- }, [target, depthTexture, effect]);
227
- return /* @__PURE__ */ jsxRuntime.jsx("primitive", { ref, object: effect, dispose: null });
250
+ }, [
251
+ camera,
252
+ blendFunction,
253
+ worldFocusDistance,
254
+ worldFocusRange,
255
+ focusDistance,
256
+ focusRange,
257
+ focalLength,
258
+ bokehScale,
259
+ resolutionScale,
260
+ resolutionX,
261
+ resolutionY,
262
+ width,
263
+ height,
264
+ autoFocus,
265
+ depthTexture
266
+ ]);
267
+ React.useEffect(() => {
268
+ return () => {
269
+ effect.dispose();
270
+ };
271
+ }, [effect]);
272
+ return /* @__PURE__ */ jsxRuntime.jsx("primitive", { ...props, ref, object: effect, target });
228
273
  });
229
274
  const Autofocus = React.forwardRef(
230
275
  ({ target = void 0, mouse: followMouse = false, debug = void 0, manual = false, smoothTime = 0.25, ...props }, fref) => {