@react-three/postprocessing 2.16.2 → 2.16.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.
Files changed (43) hide show
  1. package/dist/EffectComposer.cjs +6 -5
  2. package/dist/EffectComposer.cjs.map +1 -1
  3. package/dist/EffectComposer.d.ts +1 -1
  4. package/dist/EffectComposer.js +7 -6
  5. package/dist/EffectComposer.js.map +1 -1
  6. package/dist/EffectComposer.test.d.ts +4 -0
  7. package/dist/effects/Autofocus.cjs.map +1 -1
  8. package/dist/effects/Autofocus.d.ts +1 -1
  9. package/dist/effects/Autofocus.js.map +1 -1
  10. package/dist/effects/Grid.cjs +1 -1
  11. package/dist/effects/Grid.cjs.map +1 -1
  12. package/dist/effects/Grid.js +1 -1
  13. package/dist/effects/Grid.js.map +1 -1
  14. package/dist/effects/N8AO/EffectCompositer.cjs +3 -1
  15. package/dist/effects/N8AO/EffectCompositer.cjs.map +1 -1
  16. package/dist/effects/N8AO/EffectCompositer.js +3 -1
  17. package/dist/effects/N8AO/EffectCompositer.js.map +1 -1
  18. package/dist/effects/N8AO/index.cjs +4 -3
  19. package/dist/effects/N8AO/index.cjs.map +1 -1
  20. package/dist/effects/N8AO/index.js +4 -3
  21. package/dist/effects/N8AO/index.js.map +1 -1
  22. package/dist/effects/Outline.cjs +2 -0
  23. package/dist/effects/Outline.cjs.map +1 -1
  24. package/dist/effects/Outline.js +2 -0
  25. package/dist/effects/Outline.js.map +1 -1
  26. package/dist/effects/SSAO.cjs +1 -1
  27. package/dist/effects/SSAO.cjs.map +1 -1
  28. package/dist/effects/SSAO.js +1 -1
  29. package/dist/effects/SSAO.js.map +1 -1
  30. package/dist/effects/SSR/index.cjs +2 -2
  31. package/dist/effects/SSR/index.cjs.map +1 -1
  32. package/dist/effects/SSR/index.js +2 -2
  33. package/dist/effects/SSR/index.js.map +1 -1
  34. package/dist/effects/ToneMapping.cjs +2 -46
  35. package/dist/effects/ToneMapping.cjs.map +1 -1
  36. package/dist/effects/ToneMapping.d.ts +2 -2
  37. package/dist/effects/ToneMapping.js +3 -47
  38. package/dist/effects/ToneMapping.js.map +1 -1
  39. package/dist/effects/Water.cjs +18 -13
  40. package/dist/effects/Water.cjs.map +1 -1
  41. package/dist/effects/Water.js +18 -13
  42. package/dist/effects/Water.js.map +1 -1
  43. package/package.json +4 -3
@@ -75,11 +75,12 @@ const EffectComposer = React.memo(
75
75
  enabled ? renderPriority : 0
76
76
  );
77
77
  const group = React.useRef(null);
78
- const instance = fiber.useInstanceHandle(group);
79
78
  React.useLayoutEffect(() => {
79
+ var _a;
80
80
  const passes = [];
81
- if (group.current && instance.current && composer) {
82
- const children2 = instance.current.objects;
81
+ const groupInstance = (_a = group.current) == null ? void 0 : _a.__r3f;
82
+ if (groupInstance && composer) {
83
+ const children2 = groupInstance.objects;
83
84
  for (let i = 0; i < children2.length; i++) {
84
85
  const child = children2[i];
85
86
  if (child instanceof postprocessing.Effect) {
@@ -114,14 +115,14 @@ const EffectComposer = React.memo(
114
115
  if (downSamplingPass)
115
116
  downSamplingPass.enabled = false;
116
117
  };
117
- }, [composer, children, camera, normalPass, downSamplingPass, instance]);
118
+ }, [composer, children, camera, normalPass, downSamplingPass]);
118
119
  React.useEffect(() => {
119
120
  const currentTonemapping = gl.toneMapping;
120
121
  gl.toneMapping = THREE.NoToneMapping;
121
122
  return () => {
122
123
  gl.toneMapping = currentTonemapping;
123
124
  };
124
- }, []);
125
+ }, [gl]);
125
126
  const state = React.useMemo(
126
127
  () => ({ composer, normalPass, downSamplingPass, resolutionScale, camera, scene }),
127
128
  [composer, normalPass, downSamplingPass, resolutionScale, camera, scene]
@@ -1 +1 @@
1
- {"version":3,"file":"EffectComposer.cjs","sources":["../src/EffectComposer.tsx"],"sourcesContent":["import type { TextureDataType } from 'three'\nimport { HalfFloatType, NoToneMapping } from 'three'\nimport React, {\n forwardRef,\n useMemo,\n useEffect,\n useLayoutEffect,\n createContext,\n useRef,\n useImperativeHandle,\n} from 'react'\nimport { useThree, useFrame, useInstanceHandle } from '@react-three/fiber'\nimport {\n EffectComposer as EffectComposerImpl,\n RenderPass,\n EffectPass,\n NormalPass,\n // @ts-ignore\n DepthDownsamplingPass,\n Effect,\n Pass,\n EffectAttribute,\n} from 'postprocessing'\nimport { isWebGL2Available } from 'three-stdlib'\n\nexport const EffectComposerContext = createContext<{\n composer: EffectComposerImpl\n normalPass: NormalPass | null\n downSamplingPass: DepthDownsamplingPass | null\n camera: THREE.Camera\n scene: THREE.Scene\n resolutionScale?: number\n}>(null!)\n\nexport type EffectComposerProps = { \n enabled?: boolean\n children: JSX.Element | JSX.Element[]\n depthBuffer?: boolean\n /** Only used for SSGI currently, leave it disabled for everything else unless it's needed */\n enableNormalPass?: boolean\n stencilBuffer?: boolean\n autoClear?: boolean\n resolutionScale?: number\n multisampling?: number\n frameBufferType?: TextureDataType\n renderPriority?: number\n camera?: THREE.Camera\n scene?: THREE.Scene\n}\n\nconst isConvolution = (effect: Effect): boolean =>\n (effect.getAttributes() & EffectAttribute.CONVOLUTION) === EffectAttribute.CONVOLUTION\n\nexport const EffectComposer = React.memo(\n forwardRef(\n (\n {\n children,\n camera: _camera,\n scene: _scene,\n resolutionScale,\n enabled = true,\n renderPriority = 1,\n autoClear = true,\n depthBuffer,\n enableNormalPass,\n stencilBuffer,\n multisampling = 8,\n frameBufferType = HalfFloatType,\n }: EffectComposerProps,\n ref\n ) => {\n const { gl, scene: defaultScene, camera: defaultCamera, size } = useThree()\n const scene = _scene || defaultScene\n const camera = _camera || defaultCamera\n\n const [composer, normalPass, downSamplingPass] = useMemo(() => {\n const webGL2Available = isWebGL2Available()\n // Initialize composer\n const effectComposer = new EffectComposerImpl(gl, {\n depthBuffer,\n stencilBuffer,\n multisampling: multisampling > 0 && webGL2Available ? multisampling : 0,\n frameBufferType,\n })\n\n // Add render pass\n effectComposer.addPass(new RenderPass(scene, camera))\n\n // Create normal pass\n let downSamplingPass = null\n let normalPass = null\n if (enableNormalPass) {\n normalPass = new NormalPass(scene, camera)\n normalPass.enabled = false\n effectComposer.addPass(normalPass)\n if (resolutionScale !== undefined && webGL2Available) {\n downSamplingPass = new DepthDownsamplingPass({ normalBuffer: normalPass.texture, resolutionScale })\n downSamplingPass.enabled = false\n effectComposer.addPass(downSamplingPass)\n }\n }\n\n return [effectComposer, normalPass, downSamplingPass]\n }, [\n camera,\n gl,\n depthBuffer,\n stencilBuffer,\n multisampling,\n frameBufferType,\n scene,\n enableNormalPass,\n resolutionScale,\n ])\n\n useEffect(() => composer?.setSize(size.width, size.height), [composer, size])\n useFrame(\n (_, delta) => {\n if (enabled) {\n const currentAutoClear = gl.autoClear\n gl.autoClear = autoClear\n if (stencilBuffer && !autoClear) gl.clearStencil()\n composer.render(delta)\n gl.autoClear = currentAutoClear\n }\n },\n enabled ? renderPriority : 0\n )\n\n const group = useRef(null)\n const instance = useInstanceHandle(group)\n useLayoutEffect(() => {\n const passes: Pass[] = []\n\n if (group.current && instance.current && composer) {\n const children = instance.current.objects as unknown[]\n\n for (let i = 0; i < children.length; i++) {\n const child = children[i]\n\n if (child instanceof Effect) {\n const effects: Effect[] = [child]\n\n if (!isConvolution(child)) {\n let next: unknown = null\n while ((next = children[i + 1]) instanceof Effect) {\n if (isConvolution(next)) break\n effects.push(next)\n i++\n }\n }\n\n const pass = new EffectPass(camera, ...effects)\n passes.push(pass)\n } else if (child instanceof Pass) {\n passes.push(child)\n }\n }\n\n for (const pass of passes) composer?.addPass(pass)\n\n if (normalPass) normalPass.enabled = true\n if (downSamplingPass) downSamplingPass.enabled = true\n }\n\n return () => {\n for (const pass of passes) composer?.removePass(pass)\n if (normalPass) normalPass.enabled = false\n if (downSamplingPass) downSamplingPass.enabled = false\n }\n }, [composer, children, camera, normalPass, downSamplingPass, instance])\n\n // Disable tone mapping because threejs disallows tonemapping on render targets\n useEffect(() => {\n const currentTonemapping = gl.toneMapping\n gl.toneMapping = NoToneMapping\n return () => {\n gl.toneMapping = currentTonemapping\n }\n }, [])\n\n // Memoize state, otherwise it would trigger all consumers on every render\n const state = useMemo(\n () => ({ composer, normalPass, downSamplingPass, resolutionScale, camera, scene }),\n [composer, normalPass, downSamplingPass, resolutionScale, camera, scene]\n )\n\n // Expose the composer\n useImperativeHandle(ref, () => composer, [composer])\n\n return (\n <EffectComposerContext.Provider value={state}>\n <group ref={group}>{children}</group>\n </EffectComposerContext.Provider>\n )\n }\n )\n)\n"],"names":["createContext","EffectAttribute","forwardRef","HalfFloatType","useThree","useMemo","isWebGL2Available","EffectComposerImpl","RenderPass","downSamplingPass","normalPass","NormalPass","DepthDownsamplingPass","useEffect","useFrame","useRef","useInstanceHandle","useLayoutEffect","children","Effect","EffectPass","Pass","NoToneMapping","useImperativeHandle","jsx"],"mappings":";;;;;;;;AAyBa,MAAA,wBAAwBA,oBAOlC,IAAK;AAkBR,MAAM,gBAAgB,CAAC,YACpB,OAAO,cAAkB,IAAAC,+BAAgB,iBAAiBA,eAAgB,gBAAA;AAEtE,MAAM,iBAAiB,MAAM;AAAA,EAClCC,MAAA;AAAA,IACE,CACE;AAAA,MACE;AAAA,MACA,QAAQ;AAAA,MACR,OAAO;AAAA,MACP;AAAA,MACA,UAAU;AAAA,MACV,iBAAiB;AAAA,MACjB,YAAY;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAgB;AAAA,MAChB,kBAAkBC,MAAA;AAAA,OAEpB,QACG;AACG,YAAA,EAAE,IAAI,OAAO,cAAc,QAAQ,eAAe,SAASC,MAAAA;AACjE,YAAM,QAAQ,UAAU;AACxB,YAAM,SAAS,WAAW;AAE1B,YAAM,CAAC,UAAU,YAAY,gBAAgB,IAAIC,cAAQ,MAAM;AAC7D,cAAM,kBAAkBC,YAAAA;AAElB,cAAA,iBAAiB,IAAIC,eAAA,eAAmB,IAAI;AAAA,UAChD;AAAA,UACA;AAAA,UACA,eAAe,gBAAgB,KAAK,kBAAkB,gBAAgB;AAAA,UACtE;AAAA,QAAA,CACD;AAGD,uBAAe,QAA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EJ;AAAA,EACF;AACF;;;"}
1
+ {"version":3,"file":"EffectComposer.cjs","sources":["../src/EffectComposer.tsx"],"sourcesContent":["import type { TextureDataType } from 'three'\nimport { HalfFloatType, NoToneMapping } from 'three'\nimport React, {\n forwardRef,\n useMemo,\n useEffect,\n useLayoutEffect,\n createContext,\n useRef,\n useImperativeHandle,\n} from 'react'\nimport { useThree, useFrame } from '@react-three/fiber'\nimport {\n EffectComposer as EffectComposerImpl,\n RenderPass,\n EffectPass,\n NormalPass,\n // @ts-ignore\n DepthDownsamplingPass,\n Effect,\n Pass,\n EffectAttribute,\n} from 'postprocessing'\nimport { isWebGL2Available } from 'three-stdlib'\n\nexport const EffectComposerContext = createContext<{\n composer: EffectComposerImpl\n normalPass: NormalPass | null\n downSamplingPass: DepthDownsamplingPass | null\n camera: THREE.Camera\n scene: THREE.Scene\n resolutionScale?: number\n}>(null!)\n\nexport type EffectComposerProps = {\n enabled?: boolean\n children: JSX.Element | JSX.Element[]\n depthBuffer?: boolean\n /** Only used for SSGI currently, leave it disabled for everything else unless it's needed */\n enableNormalPass?: boolean\n stencilBuffer?: boolean\n autoClear?: boolean\n resolutionScale?: number\n multisampling?: number\n frameBufferType?: TextureDataType\n renderPriority?: number\n camera?: THREE.Camera\n scene?: THREE.Scene\n}\n\nconst isConvolution = (effect: Effect): boolean =>\n (effect.getAttributes() & EffectAttribute.CONVOLUTION) === EffectAttribute.CONVOLUTION\n\nexport const EffectComposer = React.memo(\n forwardRef<EffectComposerImpl, EffectComposerProps>(\n (\n {\n children,\n camera: _camera,\n scene: _scene,\n resolutionScale,\n enabled = true,\n renderPriority = 1,\n autoClear = true,\n depthBuffer,\n enableNormalPass,\n stencilBuffer,\n multisampling = 8,\n frameBufferType = HalfFloatType,\n },\n ref\n ) => {\n const { gl, scene: defaultScene, camera: defaultCamera, size } = useThree()\n const scene = _scene || defaultScene\n const camera = _camera || defaultCamera\n\n const [composer, normalPass, downSamplingPass] = useMemo(() => {\n const webGL2Available = isWebGL2Available()\n // Initialize composer\n const effectComposer = new EffectComposerImpl(gl, {\n depthBuffer,\n stencilBuffer,\n multisampling: multisampling > 0 && webGL2Available ? multisampling : 0,\n frameBufferType,\n })\n\n // Add render pass\n effectComposer.addPass(new RenderPass(scene, camera))\n\n // Create normal pass\n let downSamplingPass = null\n let normalPass = null\n if (enableNormalPass) {\n normalPass = new NormalPass(scene, camera)\n normalPass.enabled = false\n effectComposer.addPass(normalPass)\n if (resolutionScale !== undefined && webGL2Available) {\n downSamplingPass = new DepthDownsamplingPass({ normalBuffer: normalPass.texture, resolutionScale })\n downSamplingPass.enabled = false\n effectComposer.addPass(downSamplingPass)\n }\n }\n\n return [effectComposer, normalPass, downSamplingPass]\n }, [\n camera,\n gl,\n depthBuffer,\n stencilBuffer,\n multisampling,\n frameBufferType,\n scene,\n enableNormalPass,\n resolutionScale,\n ])\n\n useEffect(() => composer?.setSize(size.width, size.height), [composer, size])\n useFrame(\n (_, delta) => {\n if (enabled) {\n const currentAutoClear = gl.autoClear\n gl.autoClear = autoClear\n if (stencilBuffer && !autoClear) gl.clearStencil()\n composer.render(delta)\n gl.autoClear = currentAutoClear\n }\n },\n enabled ? renderPriority : 0\n )\n\n const group = useRef(null)\n useLayoutEffect(() => {\n const passes: Pass[] = []\n\n // TODO: rewrite all of this with R3F v9\n const groupInstance = (group.current as any)?.__r3f as { objects: unknown[] }\n\n if (groupInstance && composer) {\n const children = groupInstance.objects\n\n for (let i = 0; i < children.length; i++) {\n const child = children[i]\n\n if (child instanceof Effect) {\n const effects: Effect[] = [child]\n\n if (!isConvolution(child)) {\n let next: unknown = null\n while ((next = children[i + 1]) instanceof Effect) {\n if (isConvolution(next)) break\n effects.push(next)\n i++\n }\n }\n\n const pass = new EffectPass(camera, ...effects)\n passes.push(pass)\n } else if (child instanceof Pass) {\n passes.push(child)\n }\n }\n\n for (const pass of passes) composer?.addPass(pass)\n\n if (normalPass) normalPass.enabled = true\n if (downSamplingPass) downSamplingPass.enabled = true\n }\n\n return () => {\n for (const pass of passes) composer?.removePass(pass)\n if (normalPass) normalPass.enabled = false\n if (downSamplingPass) downSamplingPass.enabled = false\n }\n }, [composer, children, camera, normalPass, downSamplingPass])\n\n // Disable tone mapping because threejs disallows tonemapping on render targets\n useEffect(() => {\n const currentTonemapping = gl.toneMapping\n gl.toneMapping = NoToneMapping\n return () => {\n gl.toneMapping = currentTonemapping\n }\n }, [gl])\n\n // Memoize state, otherwise it would trigger all consumers on every render\n const state = useMemo(\n () => ({ composer, normalPass, downSamplingPass, resolutionScale, camera, scene }),\n [composer, normalPass, downSamplingPass, resolutionScale, camera, scene]\n )\n\n // Expose the composer\n useImperativeHandle(ref, () => composer, [composer])\n\n return (\n <EffectComposerContext.Provider value={state}>\n <group ref={group}>{children}</group>\n </EffectComposerContext.Provider>\n )\n }\n )\n)\n"],"names":["createContext","EffectAttribute","forwardRef","HalfFloatType","useThree","useMemo","isWebGL2Available","EffectComposerImpl","RenderPass","downSamplingPass","normalPass","NormalPass","DepthDownsamplingPass","useEffect","useFrame","useRef","useLayoutEffect","children","Effect","EffectPass","Pass","NoToneMapping","useImperativeHandle","jsx"],"mappings":";;;;;;;;AAyBa,MAAA,wBAAwBA,oBAOlC,IAAK;AAkBR,MAAM,gBAAgB,CAAC,YACpB,OAAO,cAAkB,IAAAC,+BAAgB,iBAAiBA,eAAgB,gBAAA;AAEtE,MAAM,iBAAiB,MAAM;AAAA,EAClCC,MAAA;AAAA,IACE,CACE;AAAA,MACE;AAAA,MACA,QAAQ;AAAA,MACR,OAAO;AAAA,MACP;AAAA,MACA,UAAU;AAAA,MACV,iBAAiB;AAAA,MACjB,YAAY;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAgB;AAAA,MAChB,kBAAkBC,MAAA;AAAA,OAEpB,QACG;AACG,YAAA,EAAE,IAAI,OAAO,cAAc,QAAQ,eAAe,SAASC,MAAAA;AACjE,YAAM,QAAQ,UAAU;AACxB,YAAM,SAAS,WAAW;AAE1B,Y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,QAAQ,KAAK;AAAA,MAAA;AAIzEiB,YAAAA,oBAAoB,KAAK,MAAM,UAAU,CAAC,QAAQ,CAAC;AAGjD,aAAAC,2BAAAA,IAAC,sBAAsB,UAAtB,EAA+B,OAAO,OACrC,UAAAA,2BAAA,IAAC,SAAM,EAAA,KAAK,OAAQ,SAAS,CAAA,EAC/B,CAAA;AAAA,IAEJ;AAAA,EACF;AACF;;;"}
@@ -24,4 +24,4 @@ export type EffectComposerProps = {
24
24
  camera?: THREE.Camera;
25
25
  scene?: THREE.Scene;
26
26
  };
27
- export declare const EffectComposer: React.MemoExoticComponent<React.ForwardRefExoticComponent<EffectComposerProps & React.RefAttributes<unknown>>>;
27
+ export declare const EffectComposer: React.MemoExoticComponent<React.ForwardRefExoticComponent<EffectComposerProps & React.RefAttributes<EffectComposerImpl>>>;
@@ -1,7 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { NoToneMapping, HalfFloatType } from "three";
3
3
  import React, { createContext, forwardRef, useMemo, useEffect, useRef, useLayoutEffect, useImperativeHandle } from "react";
4
- import { useThree, useFrame, useInstanceHandle } from "@react-three/fiber";
4
+ import { useThree, useFrame } from "@react-three/fiber";
5
5
  import { EffectComposer as EffectComposer$1, RenderPass, NormalPass, DepthDownsamplingPass, Effect, EffectPass, EffectAttribute, Pass } from "postprocessing";
6
6
  import { isWebGL2Available } from "three-stdlib";
7
7
  const EffectComposerContext = createContext(null);
@@ -73,11 +73,12 @@ const EffectComposer = React.memo(
73
73
  enabled ? renderPriority : 0
74
74
  );
75
75
  const group = useRef(null);
76
- const instance = useInstanceHandle(group);
77
76
  useLayoutEffect(() => {
77
+ var _a;
78
78
  const passes = [];
79
- if (group.current && instance.current && composer) {
80
- const children2 = instance.current.objects;
79
+ const groupInstance = (_a = group.current) == null ? void 0 : _a.__r3f;
80
+ if (groupInstance && composer) {
81
+ const children2 = groupInstance.objects;
81
82
  for (let i = 0; i < children2.length; i++) {
82
83
  const child = children2[i];
83
84
  if (child instanceof Effect) {
@@ -112,14 +113,14 @@ const EffectComposer = React.memo(
112
113
  if (downSamplingPass)
113
114
  downSamplingPass.enabled = false;
114
115
  };
115
- }, [composer, children, camera, normalPass, downSamplingPass, instance]);
116
+ }, [composer, children, camera, normalPass, downSamplingPass]);
116
117
  useEffect(() => {
117
118
  const currentTonemapping = gl.toneMapping;
118
119
  gl.toneMapping = NoToneMapping;
119
120
  return () => {
120
121
  gl.toneMapping = currentTonemapping;
121
122
  };
122
- }, []);
123
+ }, [gl]);
123
124
  const state = useMemo(
124
125
  () => ({ composer, normalPass, downSamplingPass, resolutionScale, camera, scene }),
125
126
  [composer, normalPass, downSamplingPass, resolutionScale, camera, scene]
@@ -1 +1 @@
1
- {"version":3,"file":"EffectComposer.js","sources":["../src/EffectComposer.tsx"],"sourcesContent":["import type { TextureDataType } from 'three'\nimport { HalfFloatType, NoToneMapping } from 'three'\nimport React, {\n forwardRef,\n useMemo,\n useEffect,\n useLayoutEffect,\n createContext,\n useRef,\n useImperativeHandle,\n} from 'react'\nimport { useThree, useFrame, useInstanceHandle } from '@react-three/fiber'\nimport {\n EffectComposer as EffectComposerImpl,\n RenderPass,\n EffectPass,\n NormalPass,\n // @ts-ignore\n DepthDownsamplingPass,\n Effect,\n Pass,\n EffectAttribute,\n} from 'postprocessing'\nimport { isWebGL2Available } from 'three-stdlib'\n\nexport const EffectComposerContext = createContext<{\n composer: EffectComposerImpl\n normalPass: NormalPass | null\n downSamplingPass: DepthDownsamplingPass | null\n camera: THREE.Camera\n scene: THREE.Scene\n resolutionScale?: number\n}>(null!)\n\nexport type EffectComposerProps = { \n enabled?: boolean\n children: JSX.Element | JSX.Element[]\n depthBuffer?: boolean\n /** Only used for SSGI currently, leave it disabled for everything else unless it's needed */\n enableNormalPass?: boolean\n stencilBuffer?: boolean\n autoClear?: boolean\n resolutionScale?: number\n multisampling?: number\n frameBufferType?: TextureDataType\n renderPriority?: number\n camera?: THREE.Camera\n scene?: THREE.Scene\n}\n\nconst isConvolution = (effect: Effect): boolean =>\n (effect.getAttributes() & EffectAttribute.CONVOLUTION) === EffectAttribute.CONVOLUTION\n\nexport const EffectComposer = React.memo(\n forwardRef(\n (\n {\n children,\n camera: _camera,\n scene: _scene,\n resolutionScale,\n enabled = true,\n renderPriority = 1,\n autoClear = true,\n depthBuffer,\n enableNormalPass,\n stencilBuffer,\n multisampling = 8,\n frameBufferType = HalfFloatType,\n }: EffectComposerProps,\n ref\n ) => {\n const { gl, scene: defaultScene, camera: defaultCamera, size } = useThree()\n const scene = _scene || defaultScene\n const camera = _camera || defaultCamera\n\n const [composer, normalPass, downSamplingPass] = useMemo(() => {\n const webGL2Available = isWebGL2Available()\n // Initialize composer\n const effectComposer = new EffectComposerImpl(gl, {\n depthBuffer,\n stencilBuffer,\n multisampling: multisampling > 0 && webGL2Available ? multisampling : 0,\n frameBufferType,\n })\n\n // Add render pass\n effectComposer.addPass(new RenderPass(scene, camera))\n\n // Create normal pass\n let downSamplingPass = null\n let normalPass = null\n if (enableNormalPass) {\n normalPass = new NormalPass(scene, camera)\n normalPass.enabled = false\n effectComposer.addPass(normalPass)\n if (resolutionScale !== undefined && webGL2Available) {\n downSamplingPass = new DepthDownsamplingPass({ normalBuffer: normalPass.texture, resolutionScale })\n downSamplingPass.enabled = false\n effectComposer.addPass(downSamplingPass)\n }\n }\n\n return [effectComposer, normalPass, downSamplingPass]\n }, [\n camera,\n gl,\n depthBuffer,\n stencilBuffer,\n multisampling,\n frameBufferType,\n scene,\n enableNormalPass,\n resolutionScale,\n ])\n\n useEffect(() => composer?.setSize(size.width, size.height), [composer, size])\n useFrame(\n (_, delta) => {\n if (enabled) {\n const currentAutoClear = gl.autoClear\n gl.autoClear = autoClear\n if (stencilBuffer && !autoClear) gl.clearStencil()\n composer.render(delta)\n gl.autoClear = currentAutoClear\n }\n },\n enabled ? renderPriority : 0\n )\n\n const group = useRef(null)\n const instance = useInstanceHandle(group)\n useLayoutEffect(() => {\n const passes: Pass[] = []\n\n if (group.current && instance.current && composer) {\n const children = instance.current.objects as unknown[]\n\n for (let i = 0; i < children.length; i++) {\n const child = children[i]\n\n if (child instanceof Effect) {\n const effects: Effect[] = [child]\n\n if (!isConvolution(child)) {\n let next: unknown = null\n while ((next = children[i + 1]) instanceof Effect) {\n if (isConvolution(next)) break\n effects.push(next)\n i++\n }\n }\n\n const pass = new EffectPass(camera, ...effects)\n passes.push(pass)\n } else if (child instanceof Pass) {\n passes.push(child)\n }\n }\n\n for (const pass of passes) composer?.addPass(pass)\n\n if (normalPass) normalPass.enabled = true\n if (downSamplingPass) downSamplingPass.enabled = true\n }\n\n return () => {\n for (const pass of passes) composer?.removePass(pass)\n if (normalPass) normalPass.enabled = false\n if (downSamplingPass) downSamplingPass.enabled = false\n }\n }, [composer, children, camera, normalPass, downSamplingPass, instance])\n\n // Disable tone mapping because threejs disallows tonemapping on render targets\n useEffect(() => {\n const currentTonemapping = gl.toneMapping\n gl.toneMapping = NoToneMapping\n return () => {\n gl.toneMapping = currentTonemapping\n }\n }, [])\n\n // Memoize state, otherwise it would trigger all consumers on every render\n const state = useMemo(\n () => ({ composer, normalPass, downSamplingPass, resolutionScale, camera, scene }),\n [composer, normalPass, downSamplingPass, resolutionScale, camera, scene]\n )\n\n // Expose the composer\n useImperativeHandle(ref, () => composer, [composer])\n\n return (\n <EffectComposerContext.Provider value={state}>\n <group ref={group}>{children}</group>\n </EffectComposerContext.Provider>\n )\n }\n )\n)\n"],"names":["EffectComposerImpl","downSamplingPass","normalPass","children"],"mappings":";;;;;;AAyBa,MAAA,wBAAwB,cAOlC,IAAK;AAkBR,MAAM,gBAAgB,CAAC,YACpB,OAAO,cAAkB,IAAA,gBAAgB,iBAAiB,gBAAgB;AAEtE,MAAM,iBAAiB,MAAM;AAAA,EAClC;AAAA,IACE,CACE;AAAA,MACE;AAAA,MACA,QAAQ;AAAA,MACR,OAAO;AAAA,MACP;AAAA,MACA,UAAU;AAAA,MACV,iBAAiB;AAAA,MACjB,YAAY;AAAA,MACZ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AAA,QACZ,OAAO,EAAE,UAAU,YAAY,kBAAkB,iBAAiB,QAAQ;QAC1E,CAAC,UAAU,YAAY,kBAAkB,iBAAiB,QAAQ,KAAK;AAAA,MAAA;AAIzE,0BAAoB,KAAK,MAAM,UAAU,CAAC,QAAQ,CAAC;AAGjD,aAAA,oBAAC,sBAAsB,UAAtB,EAA+B,OAAO,OACrC,UAAA,oBAAC,SAAM,EAAA,KAAK,OAAQ,SAAS,CAAA,EAC/B,CAAA;AAAA,IAEJ;AAAA,EACF;AACF;"}
1
+ {"version":3,"file":"EffectComposer.js","sources":["../src/EffectComposer.tsx"],"sourcesContent":["import type { TextureDataType } from 'three'\nimport { HalfFloatType, NoToneMapping } from 'three'\nimport React, {\n forwardRef,\n useMemo,\n useEffect,\n useLayoutEffect,\n createContext,\n useRef,\n useImperativeHandle,\n} from 'react'\nimport { useThree, useFrame } from '@react-three/fiber'\nimport {\n EffectComposer as EffectComposerImpl,\n RenderPass,\n EffectPass,\n NormalPass,\n // @ts-ignore\n DepthDownsamplingPass,\n Effect,\n Pass,\n EffectAttribute,\n} from 'postprocessing'\nimport { isWebGL2Available } from 'three-stdlib'\n\nexport const EffectComposerContext = createContext<{\n composer: EffectComposerImpl\n normalPass: NormalPass | null\n downSamplingPass: DepthDownsamplingPass | null\n camera: THREE.Camera\n scene: THREE.Scene\n resolutionScale?: number\n}>(null!)\n\nexport type EffectComposerProps = {\n enabled?: boolean\n children: JSX.Element | JSX.Element[]\n depthBuffer?: boolean\n /** Only used for SSGI currently, leave it disabled for everything else unless it's needed */\n enableNormalPass?: boolean\n stencilBuffer?: boolean\n autoClear?: boolean\n resolutionScale?: number\n multisampling?: number\n frameBufferType?: TextureDataType\n renderPriority?: number\n camera?: THREE.Camera\n scene?: THREE.Scene\n}\n\nconst isConvolution = (effect: Effect): boolean =>\n (effect.getAttributes() & EffectAttribute.CONVOLUTION) === EffectAttribute.CONVOLUTION\n\nexport const EffectComposer = React.memo(\n forwardRef<EffectComposerImpl, EffectComposerProps>(\n (\n {\n children,\n camera: _camera,\n scene: _scene,\n resolutionScale,\n enabled = true,\n renderPriority = 1,\n autoClear = true,\n depthBuffer,\n enableNormalPass,\n stencilBuffer,\n multisampling = 8,\n frameBufferType = HalfFloatType,\n },\n ref\n ) => {\n const { gl, scene: defaultScene, camera: defaultCamera, size } = useThree()\n const scene = _scene || defaultScene\n const camera = _camera || defaultCamera\n\n const [composer, normalPass, downSamplingPass] = useMemo(() => {\n const webGL2Available = isWebGL2Available()\n // Initialize composer\n const effectComposer = new EffectComposerImpl(gl, {\n depthBuffer,\n stencilBuffer,\n multisampling: multisampling > 0 && webGL2Available ? multisampling : 0,\n frameBufferType,\n })\n\n // Add render pass\n effectComposer.addPass(new RenderPass(scene, camera))\n\n // Create normal pass\n let downSamplingPass = null\n let normalPass = null\n if (enableNormalPass) {\n normalPass = new NormalPass(scene, camera)\n normalPass.enabled = false\n effectComposer.addPass(normalPass)\n if (resolutionScale !== undefined && webGL2Available) {\n downSamplingPass = new DepthDownsamplingPass({ normalBuffer: normalPass.texture, resolutionScale })\n downSamplingPass.enabled = false\n effectComposer.addPass(downSamplingPass)\n }\n }\n\n return [effectComposer, normalPass, downSamplingPass]\n }, [\n camera,\n gl,\n depthBuffer,\n stencilBuffer,\n multisampling,\n frameBufferType,\n scene,\n enableNormalPass,\n resolutionScale,\n ])\n\n useEffect(() => composer?.setSize(size.width, size.height), [composer, size])\n useFrame(\n (_, delta) => {\n if (enabled) {\n const currentAutoClear = gl.autoClear\n gl.autoClear = autoClear\n if (stencilBuffer && !autoClear) gl.clearStencil()\n composer.render(delta)\n gl.autoClear = currentAutoClear\n }\n },\n enabled ? renderPriority : 0\n )\n\n const group = useRef(null)\n useLayoutEffect(() => {\n const passes: Pass[] = []\n\n // TODO: rewrite all of this with R3F v9\n const groupInstance = (group.current as any)?.__r3f as { objects: unknown[] }\n\n if (groupInstance && composer) {\n const children = groupInstance.objects\n\n for (let i = 0; i < children.length; i++) {\n const child = children[i]\n\n if (child instanceof Effect) {\n const effects: Effect[] = [child]\n\n if (!isConvolution(child)) {\n let next: unknown = null\n while ((next = children[i + 1]) instanceof Effect) {\n if (isConvolution(next)) break\n effects.push(next)\n i++\n }\n }\n\n const pass = new EffectPass(camera, ...effects)\n passes.push(pass)\n } else if (child instanceof Pass) {\n passes.push(child)\n }\n }\n\n for (const pass of passes) composer?.addPass(pass)\n\n if (normalPass) normalPass.enabled = true\n if (downSamplingPass) downSamplingPass.enabled = true\n }\n\n return () => {\n for (const pass of passes) composer?.removePass(pass)\n if (normalPass) normalPass.enabled = false\n if (downSamplingPass) downSamplingPass.enabled = false\n }\n }, [composer, children, camera, normalPass, downSamplingPass])\n\n // Disable tone mapping because threejs disallows tonemapping on render targets\n useEffect(() => {\n const currentTonemapping = gl.toneMapping\n gl.toneMapping = NoToneMapping\n return () => {\n gl.toneMapping = currentTonemapping\n }\n }, [gl])\n\n // Memoize state, otherwise it would trigger all consumers on every render\n const state = useMemo(\n () => ({ composer, normalPass, downSamplingPass, resolutionScale, camera, scene }),\n [composer, normalPass, downSamplingPass, resolutionScale, camera, scene]\n )\n\n // Expose the composer\n useImperativeHandle(ref, () => composer, [composer])\n\n return (\n <EffectComposerContext.Provider value={state}>\n <group ref={group}>{children}</group>\n </EffectComposerContext.Provider>\n )\n }\n )\n)\n"],"names":["EffectComposerImpl","downSamplingPass","normalPass","children"],"mappings":";;;;;;AAyBa,MAAA,wBAAwB,cAOlC,IAAK;AAkBR,MAAM,gBAAgB,CAAC,YACpB,OAAO,cAAkB,IAAA,gBAAgB,iBAAiB,gBAAgB;AAEtE,MAAM,iBAAiB,MAAM;AAAA,EAClC;AAAA,IACE,CACE;AAAA,MACE;AAAA,MACA,QAAQ;AAAA,MACR,OAAO;AAAA,MACP;AAAA,MACA,UAAU;AAAA,MACV,iBAAiB;AAAA,MACjB,YAAY;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAgB;AAAA,MAChB,kBAAkB;AAAA,OAEpB,Q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iBAAiB,QAAQ,KAAK;AAAA,MAAA;AAIzE,0BAAoB,KAAK,MAAM,UAAU,CAAC,QAAQ,CAAC;AAGjD,aAAA,oBAAC,sBAAsB,UAAtB,EAA+B,OAAO,OACrC,UAAA,oBAAC,SAAM,EAAA,KAAK,OAAQ,SAAS,CAAA,EAC/B,CAAA;AAAA,IAEJ;AAAA,EACF;AACF;"}
@@ -0,0 +1,4 @@
1
+ declare global {
2
+ var IS_REACT_ACT_ENVIRONMENT: boolean;
3
+ }
4
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"Autofocus.cjs","sources":["../../src/effects/Autofocus.tsx"],"sourcesContent":["import * as THREE from 'three'\nimport React, {\n useRef,\n useContext,\n useState,\n useEffect,\n useCallback,\n forwardRef,\n useImperativeHandle,\n RefObject,\n useMemo,\n} from 'react'\nimport { useThree, useFrame, createPortal, Vector3 } from '@react-three/fiber'\nimport { CopyPass, DepthPickingPass, DepthOfFieldEffect } from 'postprocessing'\nimport { easing } from 'maath'\n\nimport { DepthOfField } from './DepthOfField'\nimport { EffectComposerContext } from '../EffectComposer'\n\nexport type AutofocusProps = React.ComponentProps<typeof DepthOfField> & {\n target?: Vector3\n /** should the target follow the pointer */\n mouse?: boolean\n /** size of the debug green point */\n debug?: number\n /** manual update */\n manual?: boolean\n /** approximate time to reach the target */\n smoothTime?: number\n}\n\nexport type AutofocusApi = {\n dofRef: RefObject<DepthOfFieldEffect>\n hitpoint: THREE.Vector3\n update: (delta: number, updateTarget: boolean) => void\n}\n\nexport const Autofocus = forwardRef<AutofocusApi, AutofocusProps>(\n (\n { target = undefined, mouse: followMouse = false, debug = undefined, manual = false, smoothTime = 0.25, ...props },\n fref\n ) => {\n const dofRef = useRef<DepthOfFieldEffect>(null)\n const hitpointRef = useRef<THREE.Mesh>(null)\n const targetRef = useRef<THREE.Mesh>(null)\n\n const scene = useThree(({ scene }) => scene)\n const pointer = useThree(({ pointer }) => pointer)\n const { composer, camera } = useContext(EffectComposerContext)\n\n // see: https://codesandbox.io/s/depthpickingpass-x130hg\n const [depthPickingPass] = useState(() => new DepthPickingPass())\n const [copyPass] = useState(() => new CopyPass())\n useEffect(() => {\n composer.addPass(depthPickingPass)\n composer.addPass(copyPass)\n return () => {\n composer.removePass(depthPickingPass)\n composer.removePass(copyPass)\n }\n }, [composer, depthPickingPass, copyPass])\n\n useEffect(() => {\n return () => {\n depthPickingPass.dispose()\n copyPass.dispose()\n }\n }, [depthPickingPass, copyPass])\n\n const [hitpoint] = useState(() => new THREE.Vector3(0, 0, 0))\n\n const [ndc] = useState(() => new THREE.Vector3(0, 0, 0))\n const getHit = useCallback(\n async (x: number, y: number) => {\n ndc.x = x\n ndc.y = y\n ndc.z = await depthPickingPass.readDepth(ndc)\n ndc.z = ndc.z * 2.0 - 1.0\n const hit = 1 - ndc.z > 0.0000001 // it is missed if ndc.z is close to 1\n return hit ? ndc.unproject(camera) : false\n },\n [ndc, depthPickingPass, camera]\n )\n\n const update = useCallback(\n async (delta: number, updateTarget = true) => {\n // Update hitpoint\n if (target) {\n hitpoint.set(...(target as [number, number, number]))\n } else {\n const { x, y } = followMouse ? pointer : { x: 0, y: 0 }\n const hit = await getHit(x, y)\n if (hit) hitpoint.copy(hit)\n }\n\n // Update target\n if (updateTarget && dofRef.current?.target) {\n if (smoothTime > 0 && delta > 0) {\n easing.damp3(dofRef.current.target, hitpoint, smoothTime, delta)\n } else {\n dofRef.current.target.copy(hitpoint)\n }\n }\n },\n [target, hitpoint, followMouse, getHit, smoothTime, pointer]\n )\n\n useFrame(async (_, delta) => {\n if (!manual) {\n update(delta)\n }\n if (hitpointRef.current) {\n hitpointRef.current.position.copy(hitpoint)\n }\n if (targetRef.current && dofRef.current?.target) {\n targetRef.current.position.copy(dofRef.current.target)\n }\n })\n\n // Ref API\n const api = useMemo<AutofocusApi>(\n () => ({\n dofRef,\n hitpoint,\n update,\n }),\n [hitpoint, update]\n )\n useImperativeHandle(fref, () => api, [api])\n\n return (\n <>\n {debug\n ? createPortal(\n <>\n <mesh ref={hitpointRef}>\n <sphereGeometry args={[debug, 16, 16]} />\n <meshBasicMaterial color=\"#00ff00\" opacity={1} transparent depthWrite={false} />\n </mesh>\n <mesh ref={targetRef}>\n <sphereGeometry args={[debug / 2, 16, 16]} />\n <meshBasicMaterial color=\"#00ff00\" opacity={0.5} transparent depthWrite={false} />\n </mesh>\n </>,\n scene\n )\n : null}\n\n <DepthOfField ref={dofRef} {...props} target={hitpoint} />\n </>\n )\n }\n)\n"],"names":["forwardRef","useRef","useThree","scene","pointer","useContext","EffectComposerContext","useState","DepthPickingPass","CopyPass","useEffect","THREE","useCallback","easing","useFrame","useMemo","useImperativeHandle","jsxs","Fragment","createPortal","jsx","DepthOfField"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCO,MAAM,YAAYA,MAAA;AAAA,EACvB,CACE,EAAE,SAAS,QAAW,OAAO,cAAc,OAAO,QAAQ,QAAW,SAAS,OAAO,aAAa,MAAM,GAAG,SAC3G,SACG;AACG,UAAA,SAASC,aAA2B,IAAI;AACxC,UAAA,cAAcA,aAAmB,IAAI;AACrC,UAAA,YAAYA,aAAmB,IAAI;AAEzC,UAAM,QAAQC,MAAAA,SAAS,CAAC,EAAE,OAAAC,OAAAA,MAAYA,MAAK;AAC3C,UAAM,UAAUD,MAAAA,SAAS,CAAC,EAAE,SAAAE,SAAAA,MAAcA,QAAO;AACjD,UAAM,EAAE,UAAU,OAAO,IAAIC,iBAAWC,eAAqB,qBAAA;AAG7D,UAAM,CAAC,gBAAgB,IAAIC,MAAAA,SAAS,MAAM,IAAIC,eAAAA,iBAAkB,CAAA;AAChE,UAAM,CAAC,QAAQ,IAAID,MAAAA,SAAS,MAAM,IAAIE,eAAAA,SAAU,CAAA;AAChDC,UAAAA,UAAU,MAAM;AACd,eAAS,QAAQ,gBAAgB;AACjC,eAAS,QAAQ,QAAQ;AACzB,aAAO,MAAM;AACX,iBAAS,WAAW,gBAAgB;AACpC,iBAAS,WAAW,QAAQ;AA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K,QAAS,GAAG,OAAO,QAAQ,UAAU;AAAA,IAC1D,EAAA,CAAA;AAAA,EAEJ;AACF;;"}
1
+ {"version":3,"file":"Autofocus.cjs","sources":["../../src/effects/Autofocus.tsx"],"sourcesContent":["import * as THREE from 'three'\nimport React, {\n useRef,\n useContext,\n useState,\n useEffect,\n useCallback,\n forwardRef,\n useImperativeHandle,\n RefObject,\n useMemo,\n} from 'react'\nimport { useThree, useFrame, createPortal, type Vector3 } from '@react-three/fiber'\nimport { CopyPass, DepthPickingPass, DepthOfFieldEffect } from 'postprocessing'\nimport { easing } from 'maath'\n\nimport { DepthOfField } from './DepthOfField'\nimport { EffectComposerContext } from '../EffectComposer'\n\nexport type AutofocusProps = React.ComponentProps<typeof DepthOfField> & {\n target?: Vector3\n /** should the target follow the pointer */\n mouse?: boolean\n /** size of the debug green point */\n debug?: number\n /** manual update */\n manual?: boolean\n /** approximate time to reach the target */\n smoothTime?: number\n}\n\nexport type AutofocusApi = {\n dofRef: RefObject<DepthOfFieldEffect>\n hitpoint: THREE.Vector3\n update: (delta: number, updateTarget: boolean) => void\n}\n\nexport const Autofocus = forwardRef<AutofocusApi, AutofocusProps>(\n (\n { target = undefined, mouse: followMouse = false, debug = undefined, manual = false, smoothTime = 0.25, ...props },\n fref\n ) => {\n const dofRef = useRef<DepthOfFieldEffect>(null)\n const hitpointRef = useRef<THREE.Mesh>(null)\n const targetRef = useRef<THREE.Mesh>(null)\n\n const scene = useThree(({ scene }) => scene)\n const pointer = useThree(({ pointer }) => pointer)\n const { composer, camera } = useContext(EffectComposerContext)\n\n // see: https://codesandbox.io/s/depthpickingpass-x130hg\n const [depthPickingPass] = useState(() => new DepthPickingPass())\n const [copyPass] = useState(() => new CopyPass())\n useEffect(() => {\n composer.addPass(depthPickingPass)\n composer.addPass(copyPass)\n return () => {\n composer.removePass(depthPickingPass)\n composer.removePass(copyPass)\n }\n }, [composer, depthPickingPass, copyPass])\n\n useEffect(() => {\n return () => {\n depthPickingPass.dispose()\n copyPass.dispose()\n }\n }, [depthPickingPass, copyPass])\n\n const [hitpoint] = useState(() => new THREE.Vector3(0, 0, 0))\n\n const [ndc] = useState(() => new THREE.Vector3(0, 0, 0))\n const getHit = useCallback(\n async (x: number, y: number) => {\n ndc.x = x\n ndc.y = y\n ndc.z = await depthPickingPass.readDepth(ndc)\n ndc.z = ndc.z * 2.0 - 1.0\n const hit = 1 - ndc.z > 0.0000001 // it is missed if ndc.z is close to 1\n return hit ? ndc.unproject(camera) : false\n },\n [ndc, depthPickingPass, camera]\n )\n\n const update = useCallback(\n async (delta: number, updateTarget = true) => {\n // Update hitpoint\n if (target) {\n hitpoint.set(...(target as [number, number, number]))\n } else {\n const { x, y } = followMouse ? pointer : { x: 0, y: 0 }\n const hit = await getHit(x, y)\n if (hit) hitpoint.copy(hit)\n }\n\n // Update target\n if (updateTarget && dofRef.current?.target) {\n if (smoothTime > 0 && delta > 0) {\n easing.damp3(dofRef.current.target, hitpoint, smoothTime, delta)\n } else {\n dofRef.current.target.copy(hitpoint)\n }\n }\n },\n [target, hitpoint, followMouse, getHit, smoothTime, pointer]\n )\n\n useFrame(async (_, delta) => {\n if (!manual) {\n update(delta)\n }\n if (hitpointRef.current) {\n hitpointRef.current.position.copy(hitpoint)\n }\n if (targetRef.current && dofRef.current?.target) {\n targetRef.current.position.copy(dofRef.current.target)\n }\n })\n\n // Ref API\n const api = useMemo<AutofocusApi>(\n () => ({\n dofRef,\n hitpoint,\n update,\n }),\n [hitpoint, update]\n )\n useImperativeHandle(fref, () => api, [api])\n\n return (\n <>\n {debug\n ? createPortal(\n <>\n <mesh ref={hitpointRef}>\n <sphereGeometry args={[debug, 16, 16]} />\n <meshBasicMaterial color=\"#00ff00\" opacity={1} transparent depthWrite={false} />\n </mesh>\n <mesh ref={targetRef}>\n <sphereGeometry args={[debug / 2, 16, 16]} />\n <meshBasicMaterial color=\"#00ff00\" opacity={0.5} transparent depthWrite={false} />\n </mesh>\n </>,\n scene\n )\n : null}\n\n <DepthOfField ref={dofRef} {...props} target={hitpoint} />\n </>\n )\n }\n)\n"],"names":["forwardRef","useRef","useThree","scene","pointer","useContext","EffectComposerContext","useState","DepthPickingPass","CopyPass","useEffect","THREE","useCallback","easing","useFrame","useMemo","useImperativeHandle","jsxs","Fragment","createPortal","jsx","DepthOfField"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCO,MAAM,YAAYA,MAAA;AAAA,EACvB,CACE,EAAE,SAAS,QAAW,OAAO,cAAc,OAAO,QAAQ,QAAW,SAAS,OAAO,aAAa,MAAM,GAAG,SAC3G,SACG;AACG,UAAA,SAASC,aAA2B,IAAI;AACxC,UAAA,cAAcA,aAAmB,IAAI;AACrC,UAAA,YAAYA,aAAmB,IAAI;AAEzC,UAAM,QAAQC,MAAAA,SAAS,CAAC,EAAE,OAAAC,OAAAA,MAAYA,MAAK;AAC3C,UAAM,UAAUD,MAAAA,SAAS,CAAC,EAAE,SAAAE,SAAAA,MAAcA,QAAO;AACjD,UAAM,EAAE,UAAU,OAAO,IAAIC,iBAAWC,eAAqB,qBAAA;AAG7D,UAAM,CAAC,gBAAgB,IAAIC,MAAAA,SAAS,MAAM,IAAIC,eAAAA,iBAAkB,CAAA;AAChE,UAAM,CAAC,QAAQ,IAAID,MAAAA,SAAS,MAAM,IAAIE,eAAAA,SAAU,CAAA;AAChDC,UAAAA,UAAU,MAAM;AACd,eAAS,QAAQ,gBAAgB;AACjC,eAAS,QAAQ,QAAQ;AACzB,aAAO,MAAM;AACX,iBAAS,WAAW,gBAAgB;AACpC,iBAAS,WAAW,QAAQ;AAAA,MAAA;AAAA,IAE7B,GAAA,CAAC,UAAU,kBAAkB,QAAQ,CAAC;AAEzCA,UAAAA,UAAU,MAAM;AACd,aAAO,MAAM;AACX,yBAAiB,QAAQ;AACzB,iBAAS,QAAQ;AAAA,MAAA;AAAA,IACnB,GACC,CAAC,kBAAkB,QAAQ,CAAC;AAEzB,UAAA,CAAC,QAAQ,IAAIH,MAAS,SAAA,MA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AU,aAAW,YAAO,YAAP,mBAAgB,SAAQ;AAC/C,kBAAU,QAAQ,SAAS,KAAK,OAAO,QAAQ,MAAM;AAAA,MACvD;AAAA,IAAA,CACD;AAGD,UAAM,MAAMC,MAAA;AAAA,MACV,OAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,MAEF,CAAC,UAAU,MAAM;AAAA,IAAA;AAEnBC,UAAAA,oBAAoB,MAAM,MAAM,KAAK,CAAC,GAAG,CAAC;AAE1C,WAEKC,2BAAA,KAAAC,qBAAA,EAAA,UAAA;AAAA,MACG,QAAAC,MAAA;AAAA,QAEIF,gCAAAC,WAAAA,UAAA,EAAA,UAAA;AAAA,UAACD,2BAAAA,KAAA,QAAA,EAAK,KAAK,aACT,UAAA;AAAA,YAAAG,2BAAA,IAAC,oBAAe,MAAM,CAAC,OAAO,IAAI,EAAE,GAAG;AAAA,YACvCA,2BAAAA,IAAC,uBAAkB,OAAM,WAAU,SAAS,GAAG,aAAW,MAAC,YAAY,MAAO,CAAA;AAAA,UAAA,GAChF;AAAA,UACAH,2BAAAA,KAAC,QAAK,EAAA,KAAK,WACT,UAAA;AAAA,YAAAG,+BAAC,oBAAe,MAAM,CAAC,QAAQ,GAAG,IAAI,EAAE,GAAG;AAAA,YAC3CA,2BAAAA,IAAC,uBAAkB,OAAM,WAAU,SAAS,KAAK,aAAW,MAAC,YAAY,MAAO,CAAA;AAAA,UAAA,GAClF;AAAA,QAAA,GACF;AAAA,QACA;AAAA,MAAA,IAEF;AAAA,qCAEHC,aAAAA,cAAa,EAAA,KAAK,QAAS,GAAG,OAAO,QAAQ,UAAU;AAAA,IAC1D,EAAA,CAAA;AAAA,EAEJ;AACF;;"}
@@ -1,6 +1,6 @@
1
1
  import * as THREE from 'three';
2
2
  import React, { RefObject } from 'react';
3
- import { Vector3 } from '@react-three/fiber';
3
+ import { type Vector3 } from '@react-three/fiber';
4
4
  import { DepthOfFieldEffect } from 'postprocessing';
5
5
  import { DepthOfField } from './DepthOfField';
6
6
  export type AutofocusProps = React.ComponentProps<typeof DepthOfField> & {
@@ -1 +1 @@
1
- {"version":3,"file":"Autofocus.js","sources":["../../src/effects/Autofocus.tsx"],"sourcesContent":["import * as THREE from 'three'\nimport React, {\n useRef,\n useContext,\n useState,\n useEffect,\n useCallback,\n forwardRef,\n useImperativeHandle,\n RefObject,\n useMemo,\n} from 'react'\nimport { useThree, useFrame, createPortal, Vector3 } from '@react-three/fiber'\nimport { CopyPass, DepthPickingPass, DepthOfFieldEffect } from 'postprocessing'\nimport { easing } from 'maath'\n\nimport { DepthOfField } from './DepthOfField'\nimport { EffectComposerContext } from '../EffectComposer'\n\nexport type AutofocusProps = React.ComponentProps<typeof DepthOfField> & {\n target?: Vector3\n /** should the target follow the pointer */\n mouse?: boolean\n /** size of the debug green point */\n debug?: number\n /** manual update */\n manual?: boolean\n /** approximate time to reach the target */\n smoothTime?: number\n}\n\nexport type AutofocusApi = {\n dofRef: RefObject<DepthOfFieldEffect>\n hitpoint: THREE.Vector3\n update: (delta: number, updateTarget: boolean) => void\n}\n\nexport const Autofocus = forwardRef<AutofocusApi, AutofocusProps>(\n (\n { target = undefined, mouse: followMouse = false, debug = undefined, manual = false, smoothTime = 0.25, ...props },\n fref\n ) => {\n const dofRef = useRef<DepthOfFieldEffect>(null)\n const hitpointRef = useRef<THREE.Mesh>(null)\n const targetRef = useRef<THREE.Mesh>(null)\n\n const scene = useThree(({ scene }) => scene)\n const pointer = useThree(({ pointer }) => pointer)\n const { composer, camera } = useContext(EffectComposerContext)\n\n // see: https://codesandbox.io/s/depthpickingpass-x130hg\n const [depthPickingPass] = useState(() => new DepthPickingPass())\n const [copyPass] = useState(() => new CopyPass())\n useEffect(() => {\n composer.addPass(depthPickingPass)\n composer.addPass(copyPass)\n return () => {\n composer.removePass(depthPickingPass)\n composer.removePass(copyPass)\n }\n }, [composer, depthPickingPass, copyPass])\n\n useEffect(() => {\n return () => {\n depthPickingPass.dispose()\n copyPass.dispose()\n }\n }, [depthPickingPass, copyPass])\n\n const [hitpoint] = useState(() => new THREE.Vector3(0, 0, 0))\n\n const [ndc] = useState(() => new THREE.Vector3(0, 0, 0))\n const getHit = useCallback(\n async (x: number, y: number) => {\n ndc.x = x\n ndc.y = y\n ndc.z = await depthPickingPass.readDepth(ndc)\n ndc.z = ndc.z * 2.0 - 1.0\n const hit = 1 - ndc.z > 0.0000001 // it is missed if ndc.z is close to 1\n return hit ? ndc.unproject(camera) : false\n },\n [ndc, depthPickingPass, camera]\n )\n\n const update = useCallback(\n async (delta: number, updateTarget = true) => {\n // Update hitpoint\n if (target) {\n hitpoint.set(...(target as [number, number, number]))\n } else {\n const { x, y } = followMouse ? pointer : { x: 0, y: 0 }\n const hit = await getHit(x, y)\n if (hit) hitpoint.copy(hit)\n }\n\n // Update target\n if (updateTarget && dofRef.current?.target) {\n if (smoothTime > 0 && delta > 0) {\n easing.damp3(dofRef.current.target, hitpoint, smoothTime, delta)\n } else {\n dofRef.current.target.copy(hitpoint)\n }\n }\n },\n [target, hitpoint, followMouse, getHit, smoothTime, pointer]\n )\n\n useFrame(async (_, delta) => {\n if (!manual) {\n update(delta)\n }\n if (hitpointRef.current) {\n hitpointRef.current.position.copy(hitpoint)\n }\n if (targetRef.current && dofRef.current?.target) {\n targetRef.current.position.copy(dofRef.current.target)\n }\n })\n\n // Ref API\n const api = useMemo<AutofocusApi>(\n () => ({\n dofRef,\n hitpoint,\n update,\n }),\n [hitpoint, update]\n )\n useImperativeHandle(fref, () => api, [api])\n\n return (\n <>\n {debug\n ? createPortal(\n <>\n <mesh ref={hitpointRef}>\n <sphereGeometry args={[debug, 16, 16]} />\n <meshBasicMaterial color=\"#00ff00\" opacity={1} transparent depthWrite={false} />\n </mesh>\n <mesh ref={targetRef}>\n <sphereGeometry args={[debug / 2, 16, 16]} />\n <meshBasicMaterial color=\"#00ff00\" opacity={0.5} transparent depthWrite={false} />\n </mesh>\n </>,\n scene\n )\n : null}\n\n <DepthOfField ref={dofRef} {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AG,CAAC;AAE1C,WAEK,qBAAA,UAAA,EAAA,UAAA;AAAA,MACG,QAAA;AAAA,QAEI,qBAAA,UAAA,EAAA,UAAA;AAAA,UAAC,qBAAA,QAAA,EAAK,KAAK,aACT,UAAA;AAAA,YAAA,oBAAC,oBAAe,MAAM,CAAC,OAAO,IAAI,EAAE,GAAG;AAAA,YACvC,oBAAC,uBAAkB,OAAM,WAAU,SAAS,GAAG,aAAW,MAAC,YAAY,MAAO,CAAA;AAAA,UAAA,GAChF;AAAA,UACA,qBAAC,QAAK,EAAA,KAAK,WACT,UAAA;AAAA,YAAA,oBAAC,oBAAe,MAAM,CAAC,QAAQ,GAAG,IAAI,EAAE,GAAG;AAAA,YAC3C,oBAAC,uBAAkB,OAAM,WAAU,SAAS,KAAK,aAAW,MAAC,YAAY,MAAO,CAAA;AAAA,UAAA,GAClF;AAAA,QAAA,GACF;AAAA,QACA;AAAA,MAAA,IAEF;AAAA,0BAEH,cAAa,EAAA,KAAK,QAAS,GAAG,OAAO,QAAQ,UAAU;AAAA,IAC1D,EAAA,CAAA;AAAA,EAEJ;AACF;"}
1
+ {"version":3,"file":"Autofocus.js","sources":["../../src/effects/Autofocus.tsx"],"sourcesContent":["import * as THREE from 'three'\nimport React, {\n useRef,\n useContext,\n useState,\n useEffect,\n useCallback,\n forwardRef,\n useImperativeHandle,\n RefObject,\n useMemo,\n} from 'react'\nimport { useThree, useFrame, createPortal, type Vector3 } from '@react-three/fiber'\nimport { CopyPass, DepthPickingPass, DepthOfFieldEffect } from 'postprocessing'\nimport { easing } from 'maath'\n\nimport { DepthOfField } from './DepthOfField'\nimport { EffectComposerContext } from '../EffectComposer'\n\nexport type AutofocusProps = React.ComponentProps<typeof DepthOfField> & {\n target?: Vector3\n /** should the target follow the pointer */\n mouse?: boolean\n /** size of the debug green point */\n debug?: number\n /** manual update */\n manual?: boolean\n /** approximate time to reach the target */\n smoothTime?: number\n}\n\nexport type AutofocusApi = {\n dofRef: RefObject<DepthOfFieldEffect>\n hitpoint: THREE.Vector3\n update: (delta: number, updateTarget: boolean) => void\n}\n\nexport const Autofocus = forwardRef<AutofocusApi, AutofocusProps>(\n (\n { target = undefined, mouse: followMouse = false, debug = undefined, manual = false, smoothTime = 0.25, ...props },\n fref\n ) => {\n const dofRef = useRef<DepthOfFieldEffect>(null)\n const hitpointRef = useRef<THREE.Mesh>(null)\n const targetRef = useRef<THREE.Mesh>(null)\n\n const scene = useThree(({ scene }) => scene)\n const pointer = useThree(({ pointer }) => pointer)\n const { composer, camera } = useContext(EffectComposerContext)\n\n // see: https://codesandbox.io/s/depthpickingpass-x130hg\n const [depthPickingPass] = useState(() => new DepthPickingPass())\n const [copyPass] = useState(() => new CopyPass())\n useEffect(() => {\n composer.addPass(depthPickingPass)\n composer.addPass(copyPass)\n return () => {\n composer.removePass(depthPickingPass)\n composer.removePass(copyPass)\n }\n }, [composer, depthPickingPass, copyPass])\n\n useEffect(() => {\n return () => {\n depthPickingPass.dispose()\n copyPass.dispose()\n }\n }, [depthPickingPass, copyPass])\n\n const [hitpoint] = useState(() => new THREE.Vector3(0, 0, 0))\n\n const [ndc] = useState(() => new THREE.Vector3(0, 0, 0))\n const getHit = useCallback(\n async (x: number, y: number) => {\n ndc.x = x\n ndc.y = y\n ndc.z = await depthPickingPass.readDepth(ndc)\n ndc.z = ndc.z * 2.0 - 1.0\n const hit = 1 - ndc.z > 0.0000001 // it is missed if ndc.z is close to 1\n return hit ? ndc.unproject(camera) : false\n },\n [ndc, depthPickingPass, camera]\n )\n\n const update = useCallback(\n async (delta: number, updateTarget = true) => {\n // Update hitpoint\n if (target) {\n hitpoint.set(...(target as [number, number, number]))\n } else {\n const { x, y } = followMouse ? pointer : { x: 0, y: 0 }\n const hit = await getHit(x, y)\n if (hit) hitpoint.copy(hit)\n }\n\n // Update target\n if (updateTarget && dofRef.current?.target) {\n if (smoothTime > 0 && delta > 0) {\n easing.damp3(dofRef.current.target, hitpoint, smoothTime, delta)\n } else {\n dofRef.current.target.copy(hitpoint)\n }\n }\n },\n [target, hitpoint, followMouse, getHit, smoothTime, pointer]\n )\n\n useFrame(async (_, delta) => {\n if (!manual) {\n update(delta)\n }\n if (hitpointRef.current) {\n hitpointRef.current.position.copy(hitpoint)\n }\n if (targetRef.current && dofRef.current?.target) {\n targetRef.current.position.copy(dofRef.current.target)\n }\n })\n\n // Ref API\n const api = useMemo<AutofocusApi>(\n () => ({\n dofRef,\n hitpoint,\n update,\n }),\n [hitpoint, update]\n )\n useImperativeHandle(fref, () => api, [api])\n\n return (\n <>\n {debug\n ? createPortal(\n <>\n <mesh ref={hitpointRef}>\n <sphereGeometry args={[debug, 16, 16]} />\n <meshBasicMaterial color=\"#00ff00\" opacity={1} transparent depthWrite={false} />\n </mesh>\n <mesh ref={targetRef}>\n <sphereGeometry args={[debug / 2, 16, 16]} />\n <meshBasicMaterial color=\"#00ff00\" opacity={0.5} transparent depthWrite={false} />\n </mesh>\n </>,\n scene\n )\n : null}\n\n <DepthOfField ref={dofRef} {...props} target={hitpoint} />\n </>\n )\n }\n)\n"],"names":["scene","pointer"],"mappings":";;;;;;;;AAqCO,MAAM,YAAY;AAAA,EACvB,CACE,EAAE,SAAS,QAAW,OAAO,cAAc,OAAO,QAAQ,QAAW,SAAS,OAAO,aAAa,MAAM,GAAG,SAC3G,SACG;AACG,UAAA,SAAS,OAA2B,IAAI;AACxC,UAAA,cAAc,OAAmB,IAAI;AACrC,UAAA,YAAY,OAAmB,IAAI;AAEzC,UAAM,QAAQ,SAAS,CAAC,EAAE,OAAAA,OAAAA,MAAYA,MAAK;AAC3C,UAAM,UAAU,SAAS,CAAC,EAAE,SAAAC,SAAAA,MAAcA,QAAO;AACjD,UAAM,EAAE,UAAU,OAAO,IAAI,WAAW,qBAAqB;AAG7D,UAAM,CAAC,gBAAgB,IAAI,SAAS,MAAM,IAAI,iBAAkB,CAAA;AAChE,UAAM,CAAC,QAAQ,IAAI,SAAS,MAAM,IAAI,SAAU,CAAA;AAChD,cAAU,MAAM;AACd,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G,OAAO,QAAQ,UAAU;AAAA,IAC1D,EAAA,CAAA;AAAA,EAEJ;AACF;"}
@@ -11,7 +11,7 @@ const Grid = React.forwardRef(function Grid2({ size, ...props }, ref) {
11
11
  if (size)
12
12
  effect.setSize(size.width, size.height);
13
13
  invalidate();
14
- }, [effect, size]);
14
+ }, [effect, size, invalidate]);
15
15
  return /* @__PURE__ */ jsxRuntime.jsx("primitive", { ref, object: effect, dispose: null });
16
16
  });
17
17
  exports.Grid = Grid;
@@ -1 +1 @@
1
- {"version":3,"file":"Grid.cjs","sources":["../../src/effects/Grid.tsx"],"sourcesContent":["import React, { Ref, forwardRef, useMemo, useLayoutEffect } from 'react'\nimport { GridEffect } from 'postprocessing'\nimport { useThree } from '@react-three/fiber'\n\ntype GridProps = ConstructorParameters<typeof GridEffect>[0] &\n Partial<{\n size: {\n width: number\n height: number\n }\n }>\n\nexport const Grid = forwardRef(function Grid({ size, ...props }: GridProps, ref: Ref<GridEffect>) {\n const invalidate = useThree((state) => state.invalidate)\n const effect = useMemo(() => new GridEffect(props), [props])\n useLayoutEffect(() => {\n if (size) effect.setSize(size.width, size.height)\n invalidate()\n }, [effect, size])\n return <primitive ref={ref} object={effect} dispose={null} />\n})\n"],"names":["forwardRef","Grid","useThree","useMemo","GridEffect","useLayoutEffect"],"mappings":";;;;;;AAYa,MAAA,OAAOA,iBAAW,SAASC,MAAK,EAAE,MAAM,GAAG,MAAM,GAAc,KAAsB;AAChG,QAAM,aAAaC,MAAAA,SAAS,CAAC,UAAU,MAAM,UAAU;AACjD,QAAA,SAASC,cAAQ,MAAM,IAAIC,eAAAA,WAAW,KAAK,GAAG,CAAC,KAAK,CAAC;AAC3DC,QAAAA,gBAAgB,MAAM;AAChB,QAAA;AAAM,aAAO,QAAQ,KAAK,OAAO,KAAK,MAAM;AACrC;EAAA,GACV,CAAC,QAAQ,IAAI,CAAC;AACjB,wCAAQ,aAAU,EAAA,KAAU,QAAQ,QAAQ,SAAS,KAAM,CAAA;AAC7D,CAAC;;"}
1
+ {"version":3,"file":"Grid.cjs","sources":["../../src/effects/Grid.tsx"],"sourcesContent":["import React, { Ref, forwardRef, useMemo, useLayoutEffect } from 'react'\nimport { GridEffect } from 'postprocessing'\nimport { useThree } from '@react-three/fiber'\n\ntype GridProps = ConstructorParameters<typeof GridEffect>[0] &\n Partial<{\n size: {\n width: number\n height: number\n }\n }>\n\nexport const Grid = forwardRef(function Grid({ size, ...props }: GridProps, ref: Ref<GridEffect>) {\n const invalidate = useThree((state) => state.invalidate)\n const effect = useMemo(() => new GridEffect(props), [props])\n useLayoutEffect(() => {\n if (size) effect.setSize(size.width, size.height)\n invalidate()\n }, [effect, size, invalidate])\n return <primitive ref={ref} object={effect} dispose={null} />\n})\n"],"names":["forwardRef","Grid","useThree","useMemo","GridEffect","useLayoutEffect"],"mappings":";;;;;;AAYa,MAAA,OAAOA,iBAAW,SAASC,MAAK,EAAE,MAAM,GAAG,MAAM,GAAc,KAAsB;AAChG,QAAM,aAAaC,MAAAA,SAAS,CAAC,UAAU,MAAM,UAAU;AACjD,QAAA,SAASC,cAAQ,MAAM,IAAIC,eAAAA,WAAW,KAAK,GAAG,CAAC,KAAK,CAAC;AAC3DC,QAAAA,gBAAgB,MAAM;AAChB,QAAA;AAAM,aAAO,QAAQ,KAAK,OAAO,KAAK,MAAM;AACrC;EACV,GAAA,CAAC,QAAQ,MAAM,UAAU,CAAC;AAC7B,wCAAQ,aAAU,EAAA,KAAU,QAAQ,QAAQ,SAAS,KAAM,CAAA;AAC7D,CAAC;;"}
@@ -9,7 +9,7 @@ const Grid = forwardRef(function Grid2({ size, ...props }, ref) {
9
9
  if (size)
10
10
  effect.setSize(size.width, size.height);
11
11
  invalidate();
12
- }, [effect, size]);
12
+ }, [effect, size, invalidate]);
13
13
  return /* @__PURE__ */ jsx("primitive", { ref, object: effect, dispose: null });
14
14
  });
15
15
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"Grid.js","sources":["../../src/effects/Grid.tsx"],"sourcesContent":["import React, { Ref, forwardRef, useMemo, useLayoutEffect } from 'react'\nimport { GridEffect } from 'postprocessing'\nimport { useThree } from '@react-three/fiber'\n\ntype GridProps = ConstructorParameters<typeof GridEffect>[0] &\n Partial<{\n size: {\n width: number\n height: number\n }\n }>\n\nexport const Grid = forwardRef(function Grid({ size, ...props }: GridProps, ref: Ref<GridEffect>) {\n const invalidate = useThree((state) => state.invalidate)\n const effect = useMemo(() => new GridEffect(props), [props])\n useLayoutEffect(() => {\n if (size) effect.setSize(size.width, size.height)\n invalidate()\n }, [effect, size])\n return <primitive ref={ref} object={effect} dispose={null} />\n})\n"],"names":["Grid"],"mappings":";;;;AAYa,MAAA,OAAO,WAAW,SAASA,MAAK,EAAE,MAAM,GAAG,MAAM,GAAc,KAAsB;AAChG,QAAM,aAAa,SAAS,CAAC,UAAU,MAAM,UAAU;AACjD,QAAA,SAAS,QAAQ,MAAM,IAAI,WAAW,KAAK,GAAG,CAAC,KAAK,CAAC;AAC3D,kBAAgB,MAAM;AAChB,QAAA;AAAM,aAAO,QAAQ,KAAK,OAAO,KAAK,MAAM;AACrC;EAAA,GACV,CAAC,QAAQ,IAAI,CAAC;AACjB,6BAAQ,aAAU,EAAA,KAAU,QAAQ,QAAQ,SAAS,KAAM,CAAA;AAC7D,CAAC;"}
1
+ {"version":3,"file":"Grid.js","sources":["../../src/effects/Grid.tsx"],"sourcesContent":["import React, { Ref, forwardRef, useMemo, useLayoutEffect } from 'react'\nimport { GridEffect } from 'postprocessing'\nimport { useThree } from '@react-three/fiber'\n\ntype GridProps = ConstructorParameters<typeof GridEffect>[0] &\n Partial<{\n size: {\n width: number\n height: number\n }\n }>\n\nexport const Grid = forwardRef(function Grid({ size, ...props }: GridProps, ref: Ref<GridEffect>) {\n const invalidate = useThree((state) => state.invalidate)\n const effect = useMemo(() => new GridEffect(props), [props])\n useLayoutEffect(() => {\n if (size) effect.setSize(size.width, size.height)\n invalidate()\n }, [effect, size, invalidate])\n return <primitive ref={ref} object={effect} dispose={null} />\n})\n"],"names":["Grid"],"mappings":";;;;AAYa,MAAA,OAAO,WAAW,SAASA,MAAK,EAAE,MAAM,GAAG,MAAM,GAAc,KAAsB;AAChG,QAAM,aAAa,SAAS,CAAC,UAAU,MAAM,UAAU;AACjD,QAAA,SAAS,QAAQ,MAAM,IAAI,WAAW,KAAK,GAAG,CAAC,KAAK,CAAC;AAC3D,kBAAgB,MAAM;AAChB,QAAA;AAAM,aAAO,QAAQ,KAAK,OAAO,KAAK,MAAM;AACrC;EACV,GAAA,CAAC,QAAQ,MAAM,UAAU,CAAC;AAC7B,6BAAQ,aAAU,EAAA,KAAU,QAAQ,QAAQ,SAAS,KAAM,CAAA;AAC7D,CAAC;"}
@@ -18,6 +18,8 @@ function _interopNamespaceDefault(e) {
18
18
  return Object.freeze(n);
19
19
  }
20
20
  const THREE__namespace = /* @__PURE__ */ _interopNamespaceDefault(THREE);
21
+ const version = parseInt(THREE__namespace.REVISION.replace(/\D+/g, ""));
22
+ const sRGBTransferOETF = version >= 167 ? "sRGBTransferOETF" : "LinearTosRGB";
21
23
  const EffectCompositer = {
22
24
  uniforms: {
23
25
  sceneDiffuse: { value: null },
@@ -266,7 +268,7 @@ const EffectCompositer = {
266
268
  }
267
269
  #include <dithering_fragment>
268
270
  if (gammaCorrection) {
269
- gl_FragColor = LinearTosRGB(gl_FragColor);
271
+ gl_FragColor = ${sRGBTransferOETF}(gl_FragColor);
270
272
  }
271
273
  }
272
274
  `
@@ -1 +1 @@
1
- {"version":3,"file":"EffectCompositer.cjs","sources":["../../../src/effects/N8AO/EffectCompositer.js"],"sourcesContent":["import * as THREE from 'three'\n\nconst EffectCompositer = {\n uniforms: {\n sceneDiffuse: { value: null },\n sceneDepth: { value: null },\n tDiffuse: { value: null },\n projMat: { value: new THREE.Matrix4() },\n viewMat: { value: new THREE.Matrix4() },\n projectionMatrixInv: { value: new THREE.Matrix4() },\n viewMatrixInv: { value: new THREE.Matrix4() },\n cameraPos: { value: new THREE.Vector3() },\n resolution: { value: new THREE.Vector2() },\n color: { value: new THREE.Vector3(0, 0, 0) },\n blueNoise: { value: null },\n downsampledDepth: { value: null },\n time: { value: 0.0 },\n intensity: { value: 10.0 },\n renderMode: { value: 0.0 },\n gammaCorrection: { value: false },\n logDepth: { value: false },\n ortho: { value: false },\n near: { value: 0.1 },\n far: { value: 1000.0 },\n screenSpaceRadius: { value: false },\n radius: { value: 0.0 },\n distanceFalloff: { value: 1.0 },\n fog: { value: false },\n fogExp: { value: false },\n fogDensity: { value: 0.0 },\n fogNear: { value: Infinity },\n fogFar: { value: Infinity },\n colorMultiply: { value: true },\n },\n depthWrite: false,\n depthTest: false,\n\n vertexShader: /* glsl */ `\n\t\tvarying vec2 vUv;\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = vec4(position, 1);\n\t\t}`,\n fragmentShader: /* glsl */ `\n\t\tuniform sampler2D sceneDiffuse;\n uniform highp sampler2D sceneDepth;\n uniform highp sampler2D downsampledDepth;\n uniform sampler2D tDiffuse;\n uniform sampler2D blueNoise;\n uniform vec2 resolution;\n uniform vec3 color;\n uniform mat4 projectionMatrixInv;\n uniform mat4 viewMatrixInv;\n uniform float intensity;\n uniform float renderMode;\n uniform float near;\n uniform float far;\n uniform bool gammaCorrection;\n uniform bool logDepth;\n uniform bool ortho;\n uniform bool screenSpaceRadius;\n uniform bool fog;\n uniform bool fogExp;\n uniform bool colorMultiply;\n uniform float fogDensity;\n uniform float fogNear;\n uniform float fogFar;\n uniform float radius;\n uniform float distanceFalloff;\n uniform vec3 cameraPos;\n varying vec2 vUv;\n highp float linearize_depth(highp float d, highp float zNear,highp float zFar)\n {\n return (zFar * zNear) / (zFar - d * (zFar - zNear));\n }\n highp float linearize_depth_ortho(highp float d, highp float nearZ, highp float farZ) {\n return nearZ + (farZ - nearZ) * d;\n }\n highp float linearize_depth_log(highp float d, highp float nearZ,highp float farZ) {\n float depth = pow(2.0, d * log2(farZ + 1.0)) - 1.0;\n float a = farZ / (farZ - nearZ);\n float b = farZ * nearZ / (nearZ - farZ);\n float linDepth = a + b / depth;\n return ortho ? linearize_depth_ortho(\n linDepth,\n nearZ,\n farZ\n ) :linearize_depth(linDepth, nearZ, farZ);\n }\n vec3 getWorldPosLog(vec3 posS) {\n vec2 uv = posS.xy;\n float z = posS.z;\n float nearZ =near;\n float farZ = far;\n float depth = pow(2.0, z * log2(farZ + 1.0)) - 1.0;\n float a = farZ / (farZ - nearZ);\n float b = farZ * nearZ / (nearZ - farZ);\n float linDepth = a + b / depth;\n vec4 clipVec = vec4(uv, linDepth, 1.0) * 2.0 - 1.0;\n vec4 wpos = projectionMatrixInv * clipVec;\n return wpos.xyz / wpos.w;\n }\n vec3 getWorldPos(float depth, vec2 coord) {\n // if (logDepth) {\n #ifdef LOGDEPTH\n return getWorldPosLog(vec3(coord, depth));\n #endif\n // }\n float z = depth * 2.0 - 1.0;\n vec4 clipSpacePosition = vec4(coord * 2.0 - 1.0, z, 1.0);\n vec4 viewSpacePosition = projectionMatrixInv * clipSpacePosition;\n // Perspective division\n vec4 worldSpacePosition = viewSpacePosition;\n worldSpacePosition.xyz /= worldSpacePosition.w;\n return worldSpacePosition.xyz;\n }\n \n vec3 computeNormal(vec3 worldPos, vec2 vUv) {\n ivec2 p = ivec2(vUv * resolution);\n float c0 = texelFetch(sceneDepth, p, 0).x;\n float l2 = texelFetch(sceneDepth, p - ivec2(2, 0), 0).x;\n float l1 = texelFetch(sceneDepth, p - ivec2(1, 0), 0).x;\n float r1 = texelFetch(sceneDepth, p + ivec2(1, 0), 0).x;\n float r2 = texelFetch(sceneDepth, p + ivec2(2, 0), 0).x;\n float b2 = texelFetch(sceneDepth, p - ivec2(0, 2), 0).x;\n float b1 = texelFetch(sceneDepth, p - ivec2(0, 1), 0).x;\n float t1 = texelFetch(sceneDepth, p + ivec2(0, 1), 0).x;\n float t2 = texelFetch(sceneDepth, p + ivec2(0, 2), 0).x;\n \n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n \n vec3 ce = getWorldPos(c0, vUv).xyz;\n \n vec3 dpdx = (dl < dr) ? ce - getWorldPos(l1, (vUv - vec2(1.0 / resolution.x, 0.0))).xyz\n : -ce + getWorldPos(r1, (vUv + vec2(1.0 / resolution.x, 0.0))).xyz;\n vec3 dpdy = (db < dt) ? ce - getWorldPos(b1, (vUv - vec2(0.0, 1.0 / resolution.y))).xyz\n : -ce + getWorldPos(t1, (vUv + vec2(0.0, 1.0 / resolution.y))).xyz;\n \n return normalize(cross(dpdx, dpdy));\n }\n\n #include <common>\n #include <dithering_pars_fragment>\n void main() {\n //vec4 texel = texture2D(tDiffuse, vUv);//vec3(0.0);\n vec4 sceneTexel = texture2D(sceneDiffuse, vUv);\n float depth = texture2D(\n sceneDepth,\n vUv\n ).x;\n #ifdef HALFRES \n vec4 texel;\n if (depth == 1.0) {\n texel = vec4(0.0, 0.0, 0.0, 1.0);\n } else {\n vec3 worldPos = getWorldPos(depth, vUv);\n vec3 normal = computeNormal(getWorldPos(depth, vUv), vUv);\n // vec4 texel = texture2D(tDiffuse, vUv);\n // Find closest depth;\n float totalWeight = 0.0;\n float radiusToUse = screenSpaceRadius ? distance(\n worldPos,\n getWorldPos(depth, vUv +\n vec2(radius, 0.0) / resolution)\n ) : radius;\n float distanceFalloffToUse =screenSpaceRadius ?\n radiusToUse * distanceFalloff\n : distanceFalloff;\n for(float x = -1.0; x <= 1.0; x++) {\n for(float y = -1.0; y <= 1.0; y++) {\n vec2 offset = vec2(x, y);\n ivec2 p = ivec2(\n (vUv * resolution * 0.5) + offset\n );\n vec2 pUv = vec2(p) / (resolution * 0.5);\n float sampleDepth = texelFetch(downsampledDepth,p, 0).x;\n vec4 sampleInfo = texelFetch(tDiffuse, p, 0);\n vec3 normalSample = sampleInfo.xyz * 2.0 - 1.0;\n vec3 worldPosSample = getWorldPos(sampleDepth, pUv);\n float tangentPlaneDist = abs(dot(worldPos - worldPosSample, normal));\n float rangeCheck = exp(-1.0 * tangentPlaneDist * (1.0 / distanceFalloffToUse)) * max(dot(normal, normalSample), 0.0);\n float weight = rangeCheck;\n totalWeight += weight;\n texel += sampleInfo * weight;\n }\n }\n if (totalWeight == 0.0) {\n texel = texture2D(tDiffuse, vUv);\n } else {\n texel /= totalWeight;\n }\n }\n #else\n vec4 texel = texture2D(tDiffuse, vUv);\n #endif\n\n #ifdef LOGDEPTH\n texel.a = clamp(texel.a, 0.0, 1.0);\n if (texel.a == 0.0) {\n texel.a = 1.0;\n }\n #endif\n \n float finalAo = pow(texel.a, intensity);\n float fogFactor;\n float fogDepth = distance(\n cameraPos,\n getWorldPos(depth, vUv)\n );\n if (fog) {\n if (fogExp) {\n fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n } else {\n fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n }\n }\n finalAo = mix(finalAo, 1.0, fogFactor);\n vec3 aoApplied = color * mix(vec3(1.0), sceneTexel.rgb, float(colorMultiply));\n if (renderMode == 0.0) {\n gl_FragColor = vec4( mix(sceneTexel.rgb, aoApplied, 1.0 - finalAo), sceneTexel.a);\n } else if (renderMode == 1.0) {\n gl_FragColor = vec4( mix(vec3(1.0), aoApplied, 1.0 - finalAo), sceneTexel.a);\n } else if (renderMode == 2.0) {\n gl_FragColor = vec4( sceneTexel.rgb, sceneTexel.a);\n } else if (renderMode == 3.0) {\n if (vUv.x < 0.5) {\n gl_FragColor = vec4( sceneTexel.rgb, sceneTexel.a);\n } else if (abs(vUv.x - 0.5) < 1.0 / resolution.x) {\n gl_FragColor = vec4(1.0);\n } else {\n gl_FragColor = vec4( mix(sceneTexel.rgb, aoApplied, 1.0 - finalAo), sceneTexel.a);\n }\n } else if (renderMode == 4.0) {\n if (vUv.x < 0.5) {\n gl_FragColor = vec4( sceneTexel.rgb, sceneTexel.a);\n } else if (abs(vUv.x - 0.5) < 1.0 / resolution.x) {\n gl_FragColor = vec4(1.0);\n } else {\n gl_FragColor = vec4( mix(vec3(1.0), aoApplied, 1.0 - finalAo), sceneTexel.a);\n }\n }\n #include <dithering_fragment>\n if (gammaCorrection) {\n gl_FragColor = LinearTosRGB(gl_FragColor);\n }\n }\n `,\n}\n\nexport { EffectCompositer }\n"],"names":["THREE"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEK,MAAC,mBAAmB;AAAA,EACvB,UAAU;AAAA,IACR,cAAc,EAAE,OAAO,KAAM;AAAA,IAC7B,YAAY,EAAE,OAAO,KAAM;AAAA,IAC3B,UAAU,EAAE,OAAO,KAAM;AAAA,IACzB,SAAS,EAAE,OAAO,IAAIA,iBAAM,QAAO,EAAI;AAAA,IACvC,SAAS,EAAE,OAAO,IAAIA,iBAAM,QAAO,EAAI;AAAA,IACvC,qBAAqB,EAAE,OAAO,IAAIA,iBAAM,QAAO,EAAI;AAAA,IACnD,eAAe,EAAE,OAAO,IAAIA,iBAAM,QAAO,EAAI;AAAA,IAC7C,WAAW,EAAE,OAAO,IAAIA,iBAAM,QAAO,EAAI;AAAA,IACzC,YAAY,EAAE,OAAO,IAAIA,iBAAM,QAAO,EAAI;AAAA,IAC1C,OAAO,EAAE,OAAO,IAAIA,iBAAM,QAAQ,GAAG,GAAG,CAAC,EAAG;AAAA,IAC5C,WAAW,EAAE,OAAO,KAAM;AAAA,IAC1B,kBAAkB,EAAE,OAAO,KAAM;AAAA,IACjC,MAAM,EAAE,OAAO,EAAK;AAAA,IACpB,WAAW,EAAE,OAAO,GAAM;AAAA,IAC1B,YAAY,EAAE,OAAO,EAAK;AAAA,IAC1B,iBAAiB,EAAE,OAAO,MAAO;AAAA,IACjC,UAAU,EAAE,OAAO,MAAO;AAAA,IAC1B,OAAO,EAAE,OAAO,MAAO;AAAA,IACvB,MAAM,EAAE,OAAO,IAAK;AAAA,IACpB,KAAK,EAAE,OAAO,IAAQ;AAAA,IACtB,mBAAmB,EAAE,OAAO,MAAO;AAAA,IACnC,QAA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AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+M7B;;"}
1
+ {"version":3,"file":"EffectCompositer.cjs","sources":["../../../src/effects/N8AO/EffectCompositer.js"],"sourcesContent":["import * as THREE from 'three'\n\nconst version = parseInt(THREE.REVISION.replace(/\\D+/g, ''))\n\n// https://github.com/mrdoob/three.js/pull/26644\n// https://github.com/mrdoob/three.js/pull/28901\nconst sRGBTransferOETF = version >= 167 ? 'sRGBTransferOETF' : 'LinearTosRGB'\n\nconst EffectCompositer = {\n uniforms: {\n sceneDiffuse: { value: null },\n sceneDepth: { value: null },\n tDiffuse: { value: null },\n projMat: { value: new THREE.Matrix4() },\n viewMat: { value: new THREE.Matrix4() },\n projectionMatrixInv: { value: new THREE.Matrix4() },\n viewMatrixInv: { value: new THREE.Matrix4() },\n cameraPos: { value: new THREE.Vector3() },\n resolution: { value: new THREE.Vector2() },\n color: { value: new THREE.Vector3(0, 0, 0) },\n blueNoise: { value: null },\n downsampledDepth: { value: null },\n time: { value: 0.0 },\n intensity: { value: 10.0 },\n renderMode: { value: 0.0 },\n gammaCorrection: { value: false },\n logDepth: { value: false },\n ortho: { value: false },\n near: { value: 0.1 },\n far: { value: 1000.0 },\n screenSpaceRadius: { value: false },\n radius: { value: 0.0 },\n distanceFalloff: { value: 1.0 },\n fog: { value: false },\n fogExp: { value: false },\n fogDensity: { value: 0.0 },\n fogNear: { value: Infinity },\n fogFar: { value: Infinity },\n colorMultiply: { value: true },\n },\n depthWrite: false,\n depthTest: false,\n\n vertexShader: /* glsl */ `\n\t\tvarying vec2 vUv;\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = vec4(position, 1);\n\t\t}`,\n fragmentShader: /* glsl */ `\n\t\tuniform sampler2D sceneDiffuse;\n uniform highp sampler2D sceneDepth;\n uniform highp sampler2D downsampledDepth;\n uniform sampler2D tDiffuse;\n uniform sampler2D blueNoise;\n uniform vec2 resolution;\n uniform vec3 color;\n uniform mat4 projectionMatrixInv;\n uniform mat4 viewMatrixInv;\n uniform float intensity;\n uniform float renderMode;\n uniform float near;\n uniform float far;\n uniform bool gammaCorrection;\n uniform bool logDepth;\n uniform bool ortho;\n uniform bool screenSpaceRadius;\n uniform bool fog;\n uniform bool fogExp;\n uniform bool colorMultiply;\n uniform float fogDensity;\n uniform float fogNear;\n uniform float fogFar;\n uniform float radius;\n uniform float distanceFalloff;\n uniform vec3 cameraPos;\n varying vec2 vUv;\n highp float linearize_depth(highp float d, highp float zNear,highp float zFar)\n {\n return (zFar * zNear) / (zFar - d * (zFar - zNear));\n }\n highp float linearize_depth_ortho(highp float d, highp float nearZ, highp float farZ) {\n return nearZ + (farZ - nearZ) * d;\n }\n highp float linearize_depth_log(highp float d, highp float nearZ,highp float farZ) {\n float depth = pow(2.0, d * log2(farZ + 1.0)) - 1.0;\n float a = farZ / (farZ - nearZ);\n float b = farZ * nearZ / (nearZ - farZ);\n float linDepth = a + b / depth;\n return ortho ? linearize_depth_ortho(\n linDepth,\n nearZ,\n farZ\n ) :linearize_depth(linDepth, nearZ, farZ);\n }\n vec3 getWorldPosLog(vec3 posS) {\n vec2 uv = posS.xy;\n float z = posS.z;\n float nearZ =near;\n float farZ = far;\n float depth = pow(2.0, z * log2(farZ + 1.0)) - 1.0;\n float a = farZ / (farZ - nearZ);\n float b = farZ * nearZ / (nearZ - farZ);\n float linDepth = a + b / depth;\n vec4 clipVec = vec4(uv, linDepth, 1.0) * 2.0 - 1.0;\n vec4 wpos = projectionMatrixInv * clipVec;\n return wpos.xyz / wpos.w;\n }\n vec3 getWorldPos(float depth, vec2 coord) {\n // if (logDepth) {\n #ifdef LOGDEPTH\n return getWorldPosLog(vec3(coord, depth));\n #endif\n // }\n float z = depth * 2.0 - 1.0;\n vec4 clipSpacePosition = vec4(coord * 2.0 - 1.0, z, 1.0);\n vec4 viewSpacePosition = projectionMatrixInv * clipSpacePosition;\n // Perspective division\n vec4 worldSpacePosition = viewSpacePosition;\n worldSpacePosition.xyz /= worldSpacePosition.w;\n return worldSpacePosition.xyz;\n }\n \n vec3 computeNormal(vec3 worldPos, vec2 vUv) {\n ivec2 p = ivec2(vUv * resolution);\n float c0 = texelFetch(sceneDepth, p, 0).x;\n float l2 = texelFetch(sceneDepth, p - ivec2(2, 0), 0).x;\n float l1 = texelFetch(sceneDepth, p - ivec2(1, 0), 0).x;\n float r1 = texelFetch(sceneDepth, p + ivec2(1, 0), 0).x;\n float r2 = texelFetch(sceneDepth, p + ivec2(2, 0), 0).x;\n float b2 = texelFetch(sceneDepth, p - ivec2(0, 2), 0).x;\n float b1 = texelFetch(sceneDepth, p - ivec2(0, 1), 0).x;\n float t1 = texelFetch(sceneDepth, p + ivec2(0, 1), 0).x;\n float t2 = texelFetch(sceneDepth, p + ivec2(0, 2), 0).x;\n \n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n \n vec3 ce = getWorldPos(c0, vUv).xyz;\n \n vec3 dpdx = (dl < dr) ? ce - getWorldPos(l1, (vUv - vec2(1.0 / resolution.x, 0.0))).xyz\n : -ce + getWorldPos(r1, (vUv + vec2(1.0 / resolution.x, 0.0))).xyz;\n vec3 dpdy = (db < dt) ? ce - getWorldPos(b1, (vUv - vec2(0.0, 1.0 / resolution.y))).xyz\n : -ce + getWorldPos(t1, (vUv + vec2(0.0, 1.0 / resolution.y))).xyz;\n \n return normalize(cross(dpdx, dpdy));\n }\n\n #include <common>\n #include <dithering_pars_fragment>\n void main() {\n //vec4 texel = texture2D(tDiffuse, vUv);//vec3(0.0);\n vec4 sceneTexel = texture2D(sceneDiffuse, vUv);\n float depth = texture2D(\n sceneDepth,\n vUv\n ).x;\n #ifdef HALFRES \n vec4 texel;\n if (depth == 1.0) {\n texel = vec4(0.0, 0.0, 0.0, 1.0);\n } else {\n vec3 worldPos = getWorldPos(depth, vUv);\n vec3 normal = computeNormal(getWorldPos(depth, vUv), vUv);\n // vec4 texel = texture2D(tDiffuse, vUv);\n // Find closest depth;\n float totalWeight = 0.0;\n float radiusToUse = screenSpaceRadius ? distance(\n worldPos,\n getWorldPos(depth, vUv +\n vec2(radius, 0.0) / resolution)\n ) : radius;\n float distanceFalloffToUse =screenSpaceRadius ?\n radiusToUse * distanceFalloff\n : distanceFalloff;\n for(float x = -1.0; x <= 1.0; x++) {\n for(float y = -1.0; y <= 1.0; y++) {\n vec2 offset = vec2(x, y);\n ivec2 p = ivec2(\n (vUv * resolution * 0.5) + offset\n );\n vec2 pUv = vec2(p) / (resolution * 0.5);\n float sampleDepth = texelFetch(downsampledDepth,p, 0).x;\n vec4 sampleInfo = texelFetch(tDiffuse, p, 0);\n vec3 normalSample = sampleInfo.xyz * 2.0 - 1.0;\n vec3 worldPosSample = getWorldPos(sampleDepth, pUv);\n float tangentPlaneDist = abs(dot(worldPos - worldPosSample, normal));\n float rangeCheck = exp(-1.0 * tangentPlaneDist * (1.0 / distanceFalloffToUse)) * max(dot(normal, normalSample), 0.0);\n float weight = rangeCheck;\n totalWeight += weight;\n texel += sampleInfo * weight;\n }\n }\n if (totalWeight == 0.0) {\n texel = texture2D(tDiffuse, vUv);\n } else {\n texel /= totalWeight;\n }\n }\n #else\n vec4 texel = texture2D(tDiffuse, vUv);\n #endif\n\n #ifdef LOGDEPTH\n texel.a = clamp(texel.a, 0.0, 1.0);\n if (texel.a == 0.0) {\n texel.a = 1.0;\n }\n #endif\n \n float finalAo = pow(texel.a, intensity);\n float fogFactor;\n float fogDepth = distance(\n cameraPos,\n getWorldPos(depth, vUv)\n );\n if (fog) {\n if (fogExp) {\n fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n } else {\n fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n }\n }\n finalAo = mix(finalAo, 1.0, fogFactor);\n vec3 aoApplied = color * mix(vec3(1.0), sceneTexel.rgb, float(colorMultiply));\n if (renderMode == 0.0) {\n gl_FragColor = vec4( mix(sceneTexel.rgb, aoApplied, 1.0 - finalAo), sceneTexel.a);\n } else if (renderMode == 1.0) {\n gl_FragColor = vec4( mix(vec3(1.0), aoApplied, 1.0 - finalAo), sceneTexel.a);\n } else if (renderMode == 2.0) {\n gl_FragColor = vec4( sceneTexel.rgb, sceneTexel.a);\n } else if (renderMode == 3.0) {\n if (vUv.x < 0.5) {\n gl_FragColor = vec4( sceneTexel.rgb, sceneTexel.a);\n } else if (abs(vUv.x - 0.5) < 1.0 / resolution.x) {\n gl_FragColor = vec4(1.0);\n } else {\n gl_FragColor = vec4( mix(sceneTexel.rgb, aoApplied, 1.0 - finalAo), sceneTexel.a);\n }\n } else if (renderMode == 4.0) {\n if (vUv.x < 0.5) {\n gl_FragColor = vec4( sceneTexel.rgb, sceneTexel.a);\n } else if (abs(vUv.x - 0.5) < 1.0 / resolution.x) {\n gl_FragColor = vec4(1.0);\n } else {\n gl_FragColor = vec4( mix(vec3(1.0), aoApplied, 1.0 - finalAo), sceneTexel.a);\n }\n }\n #include <dithering_fragment>\n if (gammaCorrection) {\n gl_FragColor = ${sRGBTransferOETF}(gl_FragColor);\n }\n }\n `,\n}\n\nexport { EffectCompositer }\n"],"names":["THREE"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEA,MAAM,UAAU,SAASA,iBAAM,SAAS,QAAQ,QAAQ,E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AA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BA2MA;AAAA;AAAA;AAAA;AAAA;AAI7B;;"}
@@ -1,4 +1,6 @@
1
1
  import * as THREE from "three";
2
+ const version = parseInt(THREE.REVISION.replace(/\D+/g, ""));
3
+ const sRGBTransferOETF = version >= 167 ? "sRGBTransferOETF" : "LinearTosRGB";
2
4
  const EffectCompositer = {
3
5
  uniforms: {
4
6
  sceneDiffuse: { value: null },
@@ -247,7 +249,7 @@ const EffectCompositer = {
247
249
  }
248
250
  #include <dithering_fragment>
249
251
  if (gammaCorrection) {
250
- gl_FragColor = LinearTosRGB(gl_FragColor);
252
+ gl_FragColor = ${sRGBTransferOETF}(gl_FragColor);
251
253
  }
252
254
  }
253
255
  `
@@ -1 +1 @@
1
- {"version":3,"file":"EffectCompositer.js","sources":["../../../src/effects/N8AO/EffectCompositer.js"],"sourcesContent":["import * as THREE from 'three'\n\nconst EffectCompositer = {\n uniforms: {\n sceneDiffuse: { value: null },\n sceneDepth: { value: null },\n tDiffuse: { value: null },\n projMat: { value: new THREE.Matrix4() },\n viewMat: { value: new THREE.Matrix4() },\n projectionMatrixInv: { value: new THREE.Matrix4() },\n viewMatrixInv: { value: new THREE.Matrix4() },\n cameraPos: { value: new THREE.Vector3() },\n resolution: { value: new THREE.Vector2() },\n color: { value: new THREE.Vector3(0, 0, 0) },\n blueNoise: { value: null },\n downsampledDepth: { value: null },\n time: { value: 0.0 },\n intensity: { value: 10.0 },\n renderMode: { value: 0.0 },\n gammaCorrection: { value: false },\n logDepth: { value: false },\n ortho: { value: false },\n near: { value: 0.1 },\n far: { value: 1000.0 },\n screenSpaceRadius: { value: false },\n radius: { value: 0.0 },\n distanceFalloff: { value: 1.0 },\n fog: { value: false },\n fogExp: { value: false },\n fogDensity: { value: 0.0 },\n fogNear: { value: Infinity },\n fogFar: { value: Infinity },\n colorMultiply: { value: true },\n },\n depthWrite: false,\n depthTest: false,\n\n vertexShader: /* glsl */ `\n\t\tvarying vec2 vUv;\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = vec4(position, 1);\n\t\t}`,\n fragmentShader: /* glsl */ `\n\t\tuniform sampler2D sceneDiffuse;\n uniform highp sampler2D sceneDepth;\n uniform highp sampler2D downsampledDepth;\n uniform sampler2D tDiffuse;\n uniform sampler2D blueNoise;\n uniform vec2 resolution;\n uniform vec3 color;\n uniform mat4 projectionMatrixInv;\n uniform mat4 viewMatrixInv;\n uniform float intensity;\n uniform float renderMode;\n uniform float near;\n uniform float far;\n uniform bool gammaCorrection;\n uniform bool logDepth;\n uniform bool ortho;\n uniform bool screenSpaceRadius;\n uniform bool fog;\n uniform bool fogExp;\n uniform bool colorMultiply;\n uniform float fogDensity;\n uniform float fogNear;\n uniform float fogFar;\n uniform float radius;\n uniform float distanceFalloff;\n uniform vec3 cameraPos;\n varying vec2 vUv;\n highp float linearize_depth(highp float d, highp float zNear,highp float zFar)\n {\n return (zFar * zNear) / (zFar - d * (zFar - zNear));\n }\n highp float linearize_depth_ortho(highp float d, highp float nearZ, highp float farZ) {\n return nearZ + (farZ - nearZ) * d;\n }\n highp float linearize_depth_log(highp float d, highp float nearZ,highp float farZ) {\n float depth = pow(2.0, d * log2(farZ + 1.0)) - 1.0;\n float a = farZ / (farZ - nearZ);\n float b = farZ * nearZ / (nearZ - farZ);\n float linDepth = a + b / depth;\n return ortho ? linearize_depth_ortho(\n linDepth,\n nearZ,\n farZ\n ) :linearize_depth(linDepth, nearZ, farZ);\n }\n vec3 getWorldPosLog(vec3 posS) {\n vec2 uv = posS.xy;\n float z = posS.z;\n float nearZ =near;\n float farZ = far;\n float depth = pow(2.0, z * log2(farZ + 1.0)) - 1.0;\n float a = farZ / (farZ - nearZ);\n float b = farZ * nearZ / (nearZ - farZ);\n float linDepth = a + b / depth;\n vec4 clipVec = vec4(uv, linDepth, 1.0) * 2.0 - 1.0;\n vec4 wpos = projectionMatrixInv * clipVec;\n return wpos.xyz / wpos.w;\n }\n vec3 getWorldPos(float depth, vec2 coord) {\n // if (logDepth) {\n #ifdef LOGDEPTH\n return getWorldPosLog(vec3(coord, depth));\n #endif\n // }\n float z = depth * 2.0 - 1.0;\n vec4 clipSpacePosition = vec4(coord * 2.0 - 1.0, z, 1.0);\n vec4 viewSpacePosition = projectionMatrixInv * clipSpacePosition;\n // Perspective division\n vec4 worldSpacePosition = viewSpacePosition;\n worldSpacePosition.xyz /= worldSpacePosition.w;\n return worldSpacePosition.xyz;\n }\n \n vec3 computeNormal(vec3 worldPos, vec2 vUv) {\n ivec2 p = ivec2(vUv * resolution);\n float c0 = texelFetch(sceneDepth, p, 0).x;\n float l2 = texelFetch(sceneDepth, p - ivec2(2, 0), 0).x;\n float l1 = texelFetch(sceneDepth, p - ivec2(1, 0), 0).x;\n float r1 = texelFetch(sceneDepth, p + ivec2(1, 0), 0).x;\n float r2 = texelFetch(sceneDepth, p + ivec2(2, 0), 0).x;\n float b2 = texelFetch(sceneDepth, p - ivec2(0, 2), 0).x;\n float b1 = texelFetch(sceneDepth, p - ivec2(0, 1), 0).x;\n float t1 = texelFetch(sceneDepth, p + ivec2(0, 1), 0).x;\n float t2 = texelFetch(sceneDepth, p + ivec2(0, 2), 0).x;\n \n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n \n vec3 ce = getWorldPos(c0, vUv).xyz;\n \n vec3 dpdx = (dl < dr) ? ce - getWorldPos(l1, (vUv - vec2(1.0 / resolution.x, 0.0))).xyz\n : -ce + getWorldPos(r1, (vUv + vec2(1.0 / resolution.x, 0.0))).xyz;\n vec3 dpdy = (db < dt) ? ce - getWorldPos(b1, (vUv - vec2(0.0, 1.0 / resolution.y))).xyz\n : -ce + getWorldPos(t1, (vUv + vec2(0.0, 1.0 / resolution.y))).xyz;\n \n return normalize(cross(dpdx, dpdy));\n }\n\n #include <common>\n #include <dithering_pars_fragment>\n void main() {\n //vec4 texel = texture2D(tDiffuse, vUv);//vec3(0.0);\n vec4 sceneTexel = texture2D(sceneDiffuse, vUv);\n float depth = texture2D(\n sceneDepth,\n vUv\n ).x;\n #ifdef HALFRES \n vec4 texel;\n if (depth == 1.0) {\n texel = vec4(0.0, 0.0, 0.0, 1.0);\n } else {\n vec3 worldPos = getWorldPos(depth, vUv);\n vec3 normal = computeNormal(getWorldPos(depth, vUv), vUv);\n // vec4 texel = texture2D(tDiffuse, vUv);\n // Find closest depth;\n float totalWeight = 0.0;\n float radiusToUse = screenSpaceRadius ? distance(\n worldPos,\n getWorldPos(depth, vUv +\n vec2(radius, 0.0) / resolution)\n ) : radius;\n float distanceFalloffToUse =screenSpaceRadius ?\n radiusToUse * distanceFalloff\n : distanceFalloff;\n for(float x = -1.0; x <= 1.0; x++) {\n for(float y = -1.0; y <= 1.0; y++) {\n vec2 offset = vec2(x, y);\n ivec2 p = ivec2(\n (vUv * resolution * 0.5) + offset\n );\n vec2 pUv = vec2(p) / (resolution * 0.5);\n float sampleDepth = texelFetch(downsampledDepth,p, 0).x;\n vec4 sampleInfo = texelFetch(tDiffuse, p, 0);\n vec3 normalSample = sampleInfo.xyz * 2.0 - 1.0;\n vec3 worldPosSample = getWorldPos(sampleDepth, pUv);\n float tangentPlaneDist = abs(dot(worldPos - worldPosSample, normal));\n float rangeCheck = exp(-1.0 * tangentPlaneDist * (1.0 / distanceFalloffToUse)) * max(dot(normal, normalSample), 0.0);\n float weight = rangeCheck;\n totalWeight += weight;\n texel += sampleInfo * weight;\n }\n }\n if (totalWeight == 0.0) {\n texel = texture2D(tDiffuse, vUv);\n } else {\n texel /= totalWeight;\n }\n }\n #else\n vec4 texel = texture2D(tDiffuse, vUv);\n #endif\n\n #ifdef LOGDEPTH\n texel.a = clamp(texel.a, 0.0, 1.0);\n if (texel.a == 0.0) {\n texel.a = 1.0;\n }\n #endif\n \n float finalAo = pow(texel.a, intensity);\n float fogFactor;\n float fogDepth = distance(\n cameraPos,\n getWorldPos(depth, vUv)\n );\n if (fog) {\n if (fogExp) {\n fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n } else {\n fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n }\n }\n finalAo = mix(finalAo, 1.0, fogFactor);\n vec3 aoApplied = color * mix(vec3(1.0), sceneTexel.rgb, float(colorMultiply));\n if (renderMode == 0.0) {\n gl_FragColor = vec4( mix(sceneTexel.rgb, aoApplied, 1.0 - finalAo), sceneTexel.a);\n } else if (renderMode == 1.0) {\n gl_FragColor = vec4( mix(vec3(1.0), aoApplied, 1.0 - finalAo), sceneTexel.a);\n } else if (renderMode == 2.0) {\n gl_FragColor = vec4( sceneTexel.rgb, sceneTexel.a);\n } else if (renderMode == 3.0) {\n if (vUv.x < 0.5) {\n gl_FragColor = vec4( sceneTexel.rgb, sceneTexel.a);\n } else if (abs(vUv.x - 0.5) < 1.0 / resolution.x) {\n gl_FragColor = vec4(1.0);\n } else {\n gl_FragColor = vec4( mix(sceneTexel.rgb, aoApplied, 1.0 - finalAo), sceneTexel.a);\n }\n } else if (renderMode == 4.0) {\n if (vUv.x < 0.5) {\n gl_FragColor = vec4( sceneTexel.rgb, sceneTexel.a);\n } else if (abs(vUv.x - 0.5) < 1.0 / resolution.x) {\n gl_FragColor = vec4(1.0);\n } else {\n gl_FragColor = vec4( mix(vec3(1.0), aoApplied, 1.0 - finalAo), sceneTexel.a);\n }\n }\n #include <dithering_fragment>\n if (gammaCorrection) {\n gl_FragColor = LinearTosRGB(gl_FragColor);\n }\n }\n `,\n}\n\nexport { EffectCompositer }\n"],"names":[],"mappings":";AAEK,MAAC,mBAAmB;AAAA,EACvB,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A;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+M7B;"}
1
+ {"version":3,"file":"EffectCompositer.js","sources":["../../../src/effects/N8AO/EffectCompositer.js"],"sourcesContent":["import * as THREE from 'three'\n\nconst version = parseInt(THREE.REVISION.replace(/\\D+/g, ''))\n\n// https://github.com/mrdoob/three.js/pull/26644\n// https://github.com/mrdoob/three.js/pull/28901\nconst sRGBTransferOETF = version >= 167 ? 'sRGBTransferOETF' : 'LinearTosRGB'\n\nconst EffectCompositer = {\n uniforms: {\n sceneDiffuse: { value: null },\n sceneDepth: { value: null },\n tDiffuse: { value: null },\n projMat: { value: new THREE.Matrix4() },\n viewMat: { value: new THREE.Matrix4() },\n projectionMatrixInv: { value: new THREE.Matrix4() },\n viewMatrixInv: { value: new THREE.Matrix4() },\n cameraPos: { value: new THREE.Vector3() },\n resolution: { value: new THREE.Vector2() },\n color: { value: new THREE.Vector3(0, 0, 0) },\n blueNoise: { value: null },\n downsampledDepth: { value: null },\n time: { value: 0.0 },\n intensity: { value: 10.0 },\n renderMode: { value: 0.0 },\n gammaCorrection: { value: false },\n logDepth: { value: false },\n ortho: { value: false },\n near: { value: 0.1 },\n far: { value: 1000.0 },\n screenSpaceRadius: { value: false },\n radius: { value: 0.0 },\n distanceFalloff: { value: 1.0 },\n fog: { value: false },\n fogExp: { value: false },\n fogDensity: { value: 0.0 },\n fogNear: { value: Infinity },\n fogFar: { value: Infinity },\n colorMultiply: { value: true },\n },\n depthWrite: false,\n depthTest: false,\n\n vertexShader: /* glsl */ `\n\t\tvarying vec2 vUv;\n\t\tvoid main() {\n\t\t\tvUv = uv;\n\t\t\tgl_Position = vec4(position, 1);\n\t\t}`,\n fragmentShader: /* glsl */ `\n\t\tuniform sampler2D sceneDiffuse;\n uniform highp sampler2D sceneDepth;\n uniform highp sampler2D downsampledDepth;\n uniform sampler2D tDiffuse;\n uniform sampler2D blueNoise;\n uniform vec2 resolution;\n uniform vec3 color;\n uniform mat4 projectionMatrixInv;\n uniform mat4 viewMatrixInv;\n uniform float intensity;\n uniform float renderMode;\n uniform float near;\n uniform float far;\n uniform bool gammaCorrection;\n uniform bool logDepth;\n uniform bool ortho;\n uniform bool screenSpaceRadius;\n uniform bool fog;\n uniform bool fogExp;\n uniform bool colorMultiply;\n uniform float fogDensity;\n uniform float fogNear;\n uniform float fogFar;\n uniform float radius;\n uniform float distanceFalloff;\n uniform vec3 cameraPos;\n varying vec2 vUv;\n highp float linearize_depth(highp float d, highp float zNear,highp float zFar)\n {\n return (zFar * zNear) / (zFar - d * (zFar - zNear));\n }\n highp float linearize_depth_ortho(highp float d, highp float nearZ, highp float farZ) {\n return nearZ + (farZ - nearZ) * d;\n }\n highp float linearize_depth_log(highp float d, highp float nearZ,highp float farZ) {\n float depth = pow(2.0, d * log2(farZ + 1.0)) - 1.0;\n float a = farZ / (farZ - nearZ);\n float b = farZ * nearZ / (nearZ - farZ);\n float linDepth = a + b / depth;\n return ortho ? linearize_depth_ortho(\n linDepth,\n nearZ,\n farZ\n ) :linearize_depth(linDepth, nearZ, farZ);\n }\n vec3 getWorldPosLog(vec3 posS) {\n vec2 uv = posS.xy;\n float z = posS.z;\n float nearZ =near;\n float farZ = far;\n float depth = pow(2.0, z * log2(farZ + 1.0)) - 1.0;\n float a = farZ / (farZ - nearZ);\n float b = farZ * nearZ / (nearZ - farZ);\n float linDepth = a + b / depth;\n vec4 clipVec = vec4(uv, linDepth, 1.0) * 2.0 - 1.0;\n vec4 wpos = projectionMatrixInv * clipVec;\n return wpos.xyz / wpos.w;\n }\n vec3 getWorldPos(float depth, vec2 coord) {\n // if (logDepth) {\n #ifdef LOGDEPTH\n return getWorldPosLog(vec3(coord, depth));\n #endif\n // }\n float z = depth * 2.0 - 1.0;\n vec4 clipSpacePosition = vec4(coord * 2.0 - 1.0, z, 1.0);\n vec4 viewSpacePosition = projectionMatrixInv * clipSpacePosition;\n // Perspective division\n vec4 worldSpacePosition = viewSpacePosition;\n worldSpacePosition.xyz /= worldSpacePosition.w;\n return worldSpacePosition.xyz;\n }\n \n vec3 computeNormal(vec3 worldPos, vec2 vUv) {\n ivec2 p = ivec2(vUv * resolution);\n float c0 = texelFetch(sceneDepth, p, 0).x;\n float l2 = texelFetch(sceneDepth, p - ivec2(2, 0), 0).x;\n float l1 = texelFetch(sceneDepth, p - ivec2(1, 0), 0).x;\n float r1 = texelFetch(sceneDepth, p + ivec2(1, 0), 0).x;\n float r2 = texelFetch(sceneDepth, p + ivec2(2, 0), 0).x;\n float b2 = texelFetch(sceneDepth, p - ivec2(0, 2), 0).x;\n float b1 = texelFetch(sceneDepth, p - ivec2(0, 1), 0).x;\n float t1 = texelFetch(sceneDepth, p + ivec2(0, 1), 0).x;\n float t2 = texelFetch(sceneDepth, p + ivec2(0, 2), 0).x;\n \n float dl = abs((2.0 * l1 - l2) - c0);\n float dr = abs((2.0 * r1 - r2) - c0);\n float db = abs((2.0 * b1 - b2) - c0);\n float dt = abs((2.0 * t1 - t2) - c0);\n \n vec3 ce = getWorldPos(c0, vUv).xyz;\n \n vec3 dpdx = (dl < dr) ? ce - getWorldPos(l1, (vUv - vec2(1.0 / resolution.x, 0.0))).xyz\n : -ce + getWorldPos(r1, (vUv + vec2(1.0 / resolution.x, 0.0))).xyz;\n vec3 dpdy = (db < dt) ? ce - getWorldPos(b1, (vUv - vec2(0.0, 1.0 / resolution.y))).xyz\n : -ce + getWorldPos(t1, (vUv + vec2(0.0, 1.0 / resolution.y))).xyz;\n \n return normalize(cross(dpdx, dpdy));\n }\n\n #include <common>\n #include <dithering_pars_fragment>\n void main() {\n //vec4 texel = texture2D(tDiffuse, vUv);//vec3(0.0);\n vec4 sceneTexel = texture2D(sceneDiffuse, vUv);\n float depth = texture2D(\n sceneDepth,\n vUv\n ).x;\n #ifdef HALFRES \n vec4 texel;\n if (depth == 1.0) {\n texel = vec4(0.0, 0.0, 0.0, 1.0);\n } else {\n vec3 worldPos = getWorldPos(depth, vUv);\n vec3 normal = computeNormal(getWorldPos(depth, vUv), vUv);\n // vec4 texel = texture2D(tDiffuse, vUv);\n // Find closest depth;\n float totalWeight = 0.0;\n float radiusToUse = screenSpaceRadius ? distance(\n worldPos,\n getWorldPos(depth, vUv +\n vec2(radius, 0.0) / resolution)\n ) : radius;\n float distanceFalloffToUse =screenSpaceRadius ?\n radiusToUse * distanceFalloff\n : distanceFalloff;\n for(float x = -1.0; x <= 1.0; x++) {\n for(float y = -1.0; y <= 1.0; y++) {\n vec2 offset = vec2(x, y);\n ivec2 p = ivec2(\n (vUv * resolution * 0.5) + offset\n );\n vec2 pUv = vec2(p) / (resolution * 0.5);\n float sampleDepth = texelFetch(downsampledDepth,p, 0).x;\n vec4 sampleInfo = texelFetch(tDiffuse, p, 0);\n vec3 normalSample = sampleInfo.xyz * 2.0 - 1.0;\n vec3 worldPosSample = getWorldPos(sampleDepth, pUv);\n float tangentPlaneDist = abs(dot(worldPos - worldPosSample, normal));\n float rangeCheck = exp(-1.0 * tangentPlaneDist * (1.0 / distanceFalloffToUse)) * max(dot(normal, normalSample), 0.0);\n float weight = rangeCheck;\n totalWeight += weight;\n texel += sampleInfo * weight;\n }\n }\n if (totalWeight == 0.0) {\n texel = texture2D(tDiffuse, vUv);\n } else {\n texel /= totalWeight;\n }\n }\n #else\n vec4 texel = texture2D(tDiffuse, vUv);\n #endif\n\n #ifdef LOGDEPTH\n texel.a = clamp(texel.a, 0.0, 1.0);\n if (texel.a == 0.0) {\n texel.a = 1.0;\n }\n #endif\n \n float finalAo = pow(texel.a, intensity);\n float fogFactor;\n float fogDepth = distance(\n cameraPos,\n getWorldPos(depth, vUv)\n );\n if (fog) {\n if (fogExp) {\n fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n } else {\n fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n }\n }\n finalAo = mix(finalAo, 1.0, fogFactor);\n vec3 aoApplied = color * mix(vec3(1.0), sceneTexel.rgb, float(colorMultiply));\n if (renderMode == 0.0) {\n gl_FragColor = vec4( mix(sceneTexel.rgb, aoApplied, 1.0 - finalAo), sceneTexel.a);\n } else if (renderMode == 1.0) {\n gl_FragColor = vec4( mix(vec3(1.0), aoApplied, 1.0 - finalAo), sceneTexel.a);\n } else if (renderMode == 2.0) {\n gl_FragColor = vec4( sceneTexel.rgb, sceneTexel.a);\n } else if (renderMode == 3.0) {\n if (vUv.x < 0.5) {\n gl_FragColor = vec4( sceneTexel.rgb, sceneTexel.a);\n } else if (abs(vUv.x - 0.5) < 1.0 / resolution.x) {\n gl_FragColor = vec4(1.0);\n } else {\n gl_FragColor = vec4( mix(sceneTexel.rgb, aoApplied, 1.0 - finalAo), sceneTexel.a);\n }\n } else if (renderMode == 4.0) {\n if (vUv.x < 0.5) {\n gl_FragColor = vec4( sceneTexel.rgb, sceneTexel.a);\n } else if (abs(vUv.x - 0.5) < 1.0 / resolution.x) {\n gl_FragColor = vec4(1.0);\n } else {\n gl_FragColor = vec4( mix(vec3(1.0), aoApplied, 1.0 - finalAo), sceneTexel.a);\n }\n }\n #include <dithering_fragment>\n if (gammaCorrection) {\n gl_FragColor = ${sRGBTransferOETF}(gl_FragColor);\n }\n }\n `,\n}\n\nexport { EffectCompositer }\n"],"names":[],"mappings":";AAEA,MAAM,UAAU,SAAS,MAAM,SAAS,QAAQ,QAAQ,EAAE,CAAC;AAI3D,MAAM,mBAAmB,WAAW,MAAM,qBAAqB;AAE1D,MAAC,mBAAmB;AAAA,EACvB,UAAU;AAAA,IACR,cAAc,EAAE,OAAO,KAAM;AAAA,IAC7B,YAAY,EAAE,OAAO,KAAM;AAAA,IAC3B,UAAU,EAAE,OAAO,KAAM;AAAA,IACzB,SAAS,EAAE,OAAO,IAAI,MAAM,QAAO,EAAI;AAAA,IACvC,SAAS,EAAE,OAAO,IAAI,MAAM,QAAO,EAAI;AAAA,IAC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
21
  }, ref) => {
22
22
  const { camera, scene } = fiber.useThree();
23
- const effect = React.useMemo(() => new N8AOPostPass.N8AOPostPass(scene, camera), []);
23
+ const effect = React.useMemo(() => new N8AOPostPass.N8AOPostPass(scene, camera), [camera, scene]);
24
24
  React.useLayoutEffect(() => {
25
25
  fiber.applyProps(effect.configuration, {
26
26
  color,
@@ -46,12 +46,13 @@ const N8AO = React.forwardRef(
46
46
  denoiseRadius,
47
47
  renderMode,
48
48
  halfRes,
49
- depthAwareUpsampling
49
+ depthAwareUpsampling,
50
+ effect
50
51
  ]);
51
52
  React.useLayoutEffect(() => {
52
53
  if (quality)
53
54
  effect.setQualityMode(quality.charAt(0).toUpperCase() + quality.slice(1));
54
- }, [quality]);
55
+ }, [effect, quality]);
55
56
  return /* @__PURE__ */ jsxRuntime.jsx("primitive", { ref, object: effect });
56
57
  }
57
58
  );
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../src/effects/N8AO/index.tsx"],"sourcesContent":["// From https://github.com/N8python/n8ao\n// https://twitter.com/N8Programs/status/1660996748485984261\n\nimport { Ref, forwardRef, useLayoutEffect, useMemo } from 'react'\n/* @ts-ignore */\nimport { N8AOPostPass } from './N8AOPostPass'\nimport { useThree, ReactThreeFiber, applyProps } from '@react-three/fiber'\n\ntype N8AOProps = {\n aoRadius?: number\n distanceFalloff?: number\n intensity?: number\n quality?: 'performance' | 'low' | 'medium' | 'high' | 'ultra'\n aoSamples?: number\n denoiseSamples?: number\n denoiseRadius?: number\n color?: ReactThreeFiber.Color\n halfRes?: boolean\n depthAwareUpsampling?: boolean\n screenSpaceRadius?: boolean\n renderMode?: 0 | 1 | 2 | 3 | 4\n}\n\nexport const N8AO = forwardRef<N8AOPostPass, N8AOProps>(\n (\n {\n halfRes,\n screenSpaceRadius,\n quality,\n depthAwareUpsampling = true,\n aoRadius = 5,\n aoSamples = 16,\n denoiseSamples = 4,\n denoiseRadius = 12,\n distanceFalloff = 1,\n intensity = 1,\n color,\n renderMode = 0,\n },\n ref: Ref<N8AOPostPass>\n ) => {\n const { camera, scene } = useThree()\n const effect = useMemo(() => new N8AOPostPass(scene, camera), [])\n useLayoutEffect(() => {\n applyProps(effect.configuration, {\n color,\n aoRadius,\n distanceFalloff,\n intensity,\n aoSamples,\n denoiseSamples,\n denoiseRadius,\n screenSpaceRadius,\n renderMode,\n halfRes,\n depthAwareUpsampling,\n })\n }, [\n screenSpaceRadius,\n color,\n aoRadius,\n distanceFalloff,\n intensity,\n aoSamples,\n denoiseSamples,\n denoiseRadius,\n renderMode,\n halfRes,\n depthAwareUpsampling,\n ])\n useLayoutEffect(() => {\n if (quality) effect.setQualityMode(quality.charAt(0).toUpperCase() + quality.slice(1))\n }, [quality])\n return <primitive ref={ref} object={effect} />\n }\n)\n"],"names":["forwardRef","useThree","useMemo","N8AOPostPass","useLayoutEffect","applyProps","jsx"],"mappings":";;;;;;AAuBO,MAAM,OAAOA,MAAA;AAAA,EAClB,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA,uBAAuB;AAAA,IACvB,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,iBAAiB;AAAA,IACjB,gBAAgB;AAAA,IAChB,kBAAkB;AAAA,IAClB,YAAY;AAAA,IACZ;AAAA,IACA,aAAa;AAAA,KAEf,QACG;AACH,UAAM,EAAE,QAAQ,MAAM,IAAIC,MAAS,SAAA;AAC7B,UAAA,SAASC,cAAQ,MAAM,IAAIC,aAAAA,aAAa,OAAO,MAAM,GAAG,CAAA,CAAE;AAChEC,UAAAA,gBAAgB,MAAM;AACpBC,YAAA,WAAW,OAAO,eAAe;AAAA,QAC/B;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA,CACD;AAAA,IAAA,GACA;AAAA,MACD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD;AACDD,UAAAA,gBAAgB,MAAM;AAChB,UAAA;AAAgB,eAAA,eAAe,QAAQ,OAAO,CAAC,EAAE,gBAAgB,QAAQ,MAAM,CAAC,CAAC;AAAA,IAAA,GACpF,CAAC,OAAO,CAAC;AACZ,WAAQE,2BAAAA,IAAA,aAAA,EAAU,KAAU,QAAQ,OAAQ,CAAA;AAAA,EAC9C;AACF;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../src/effects/N8AO/index.tsx"],"sourcesContent":["// From https://github.com/N8python/n8ao\n// https://twitter.com/N8Programs/status/1660996748485984261\n\nimport { Ref, forwardRef, useLayoutEffect, useMemo } from 'react'\n/* @ts-ignore */\nimport { N8AOPostPass } from './N8AOPostPass'\nimport { useThree, ReactThreeFiber, applyProps } from '@react-three/fiber'\n\ntype N8AOProps = {\n aoRadius?: number\n distanceFalloff?: number\n intensity?: number\n quality?: 'performance' | 'low' | 'medium' | 'high' | 'ultra'\n aoSamples?: number\n denoiseSamples?: number\n denoiseRadius?: number\n color?: ReactThreeFiber.Color\n halfRes?: boolean\n depthAwareUpsampling?: boolean\n screenSpaceRadius?: boolean\n renderMode?: 0 | 1 | 2 | 3 | 4\n}\n\nexport const N8AO = forwardRef<N8AOPostPass, N8AOProps>(\n (\n {\n halfRes,\n screenSpaceRadius,\n quality,\n depthAwareUpsampling = true,\n aoRadius = 5,\n aoSamples = 16,\n denoiseSamples = 4,\n denoiseRadius = 12,\n distanceFalloff = 1,\n intensity = 1,\n color,\n renderMode = 0,\n },\n ref: Ref<N8AOPostPass>\n ) => {\n const { camera, scene } = useThree()\n const effect = useMemo(() => new N8AOPostPass(scene, camera), [camera, scene])\n\n // TODO: implement dispose upstream; this effect has memory leaks without\n useLayoutEffect(() => {\n applyProps(effect.configuration, {\n color,\n aoRadius,\n distanceFalloff,\n intensity,\n aoSamples,\n denoiseSamples,\n denoiseRadius,\n screenSpaceRadius,\n renderMode,\n halfRes,\n depthAwareUpsampling,\n })\n }, [\n screenSpaceRadius,\n color,\n aoRadius,\n distanceFalloff,\n intensity,\n aoSamples,\n denoiseSamples,\n denoiseRadius,\n renderMode,\n halfRes,\n depthAwareUpsampling,\n effect,\n ])\n\n useLayoutEffect(() => {\n if (quality) effect.setQualityMode(quality.charAt(0).toUpperCase() + quality.slice(1))\n }, [effect, quality])\n\n return <primitive ref={ref} object={effect} />\n }\n)\n"],"names":["forwardRef","useThree","useMemo","N8AOPostPass","useLayoutEffect","applyProps","jsx"],"mappings":";;;;;;AAuBO,MAAM,OAAOA,MAAA;AAAA,EAClB,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA,uBAAuB;AAAA,IACvB,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,iBAAiB;AAAA,IACjB,gBAAgB;AAAA,IAChB,kBAAkB;AAAA,IAClB,YAAY;AAAA,IACZ;AAAA,IACA,aAAa;AAAA,KAEf,QACG;AACH,UAAM,EAAE,QAAQ,MAAM,IAAIC,MAAS,SAAA;AAC7B,UAAA,SAASC,MAAAA,QAAQ,MAAM,IAAIC,0BAAa,OAAO,MAAM,GAAG,CAAC,QAAQ,KAAK,CAAC;AAG7EC,UAAAA,gBAAgB,MAAM;AACpBC,YAAA,WAAW,OAAO,eAAe;AAAA,QAC/B;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA,CACD;AAAA,IAAA,GACA;AAAA,MACD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD;AAEDD,UAAAA,gBAAgB,MAAM;AAChB,UAAA;AAAgB,eAAA,eAAe,QAAQ,OAAO,CAAC,EAAE,gBAAgB,QAAQ,MAAM,CAAC,CAAC;AAAA,IAAA,GACpF,CAAC,QAAQ,OAAO,CAAC;AAEpB,WAAQE,2BAAAA,IAAA,aAAA,EAAU,KAAU,QAAQ,OAAQ,CAAA;AAAA,EAC9C;AACF;;"}
@@ -18,7 +18,7 @@ const N8AO = forwardRef(
18
18
  renderMode = 0
19
19
  }, ref) => {
20
20
  const { camera, scene } = useThree();
21
- const effect = useMemo(() => new N8AOPostPass(scene, camera), []);
21
+ const effect = useMemo(() => new N8AOPostPass(scene, camera), [camera, scene]);
22
22
  useLayoutEffect(() => {
23
23
  applyProps(effect.configuration, {
24
24
  color,
@@ -44,12 +44,13 @@ const N8AO = forwardRef(
44
44
  denoiseRadius,
45
45
  renderMode,
46
46
  halfRes,
47
- depthAwareUpsampling
47
+ depthAwareUpsampling,
48
+ effect
48
49
  ]);
49
50
  useLayoutEffect(() => {
50
51
  if (quality)
51
52
  effect.setQualityMode(quality.charAt(0).toUpperCase() + quality.slice(1));
52
- }, [quality]);
53
+ }, [effect, quality]);
53
54
  return /* @__PURE__ */ jsx("primitive", { ref, object: effect });
54
55
  }
55
56
  );
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/effects/N8AO/index.tsx"],"sourcesContent":["// From https://github.com/N8python/n8ao\n// https://twitter.com/N8Programs/status/1660996748485984261\n\nimport { Ref, forwardRef, useLayoutEffect, useMemo } from 'react'\n/* @ts-ignore */\nimport { N8AOPostPass } from './N8AOPostPass'\nimport { useThree, ReactThreeFiber, applyProps } from '@react-three/fiber'\n\ntype N8AOProps = {\n aoRadius?: number\n distanceFalloff?: number\n intensity?: number\n quality?: 'performance' | 'low' | 'medium' | 'high' | 'ultra'\n aoSamples?: number\n denoiseSamples?: number\n denoiseRadius?: number\n color?: ReactThreeFiber.Color\n halfRes?: boolean\n depthAwareUpsampling?: boolean\n screenSpaceRadius?: boolean\n renderMode?: 0 | 1 | 2 | 3 | 4\n}\n\nexport const N8AO = forwardRef<N8AOPostPass, N8AOProps>(\n (\n {\n halfRes,\n screenSpaceRadius,\n quality,\n depthAwareUpsampling = true,\n aoRadius = 5,\n aoSamples = 16,\n denoiseSamples = 4,\n denoiseRadius = 12,\n distanceFalloff = 1,\n intensity = 1,\n color,\n renderMode = 0,\n },\n ref: Ref<N8AOPostPass>\n ) => {\n const { camera, scene } = useThree()\n const effect = useMemo(() => new N8AOPostPass(scene, camera), [])\n useLayoutEffect(() => {\n applyProps(effect.configuration, {\n color,\n aoRadius,\n distanceFalloff,\n intensity,\n aoSamples,\n denoiseSamples,\n denoiseRadius,\n screenSpaceRadius,\n renderMode,\n halfRes,\n depthAwareUpsampling,\n })\n }, [\n screenSpaceRadius,\n color,\n aoRadius,\n distanceFalloff,\n intensity,\n aoSamples,\n denoiseSamples,\n denoiseRadius,\n renderMode,\n halfRes,\n depthAwareUpsampling,\n ])\n useLayoutEffect(() => {\n if (quality) effect.setQualityMode(quality.charAt(0).toUpperCase() + quality.slice(1))\n }, [quality])\n return <primitive ref={ref} object={effect} />\n }\n)\n"],"names":[],"mappings":";;;;AAuBO,MAAM,OAAO;AAAA,EAClB,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA,uBAAuB;AAAA,IACvB,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,iBAAiB;AAAA,IACjB,gBAAgB;AAAA,IAChB,kBAAkB;AAAA,IAClB,YAAY;AAAA,IACZ;AAAA,IACA,aAAa;AAAA,KAEf,QACG;AACH,UAAM,EAAE,QAAQ,MAAM,IAAI,SAAS;AAC7B,UAAA,SAAS,QAAQ,MAAM,IAAI,aAAa,OAAO,MAAM,GAAG,CAAA,CAAE;AAChE,oBAAgB,MAAM;AACpB,iBAAW,OAAO,eAAe;AAAA,QAC/B;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA,CACD;AAAA,IAAA,GACA;AAAA,MACD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD;AACD,oBAAgB,MAAM;AAChB,UAAA;AAAgB,eAAA,eAAe,QAAQ,OAAO,CAAC,EAAE,gBAAgB,QAAQ,MAAM,CAAC,CAAC;AAAA,IAAA,GACpF,CAAC,OAAO,CAAC;AACZ,WAAQ,oBAAA,aAAA,EAAU,KAAU,QAAQ,OAAQ,CAAA;AAAA,EAC9C;AACF;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/effects/N8AO/index.tsx"],"sourcesContent":["// From https://github.com/N8python/n8ao\n// https://twitter.com/N8Programs/status/1660996748485984261\n\nimport { Ref, forwardRef, useLayoutEffect, useMemo } from 'react'\n/* @ts-ignore */\nimport { N8AOPostPass } from './N8AOPostPass'\nimport { useThree, ReactThreeFiber, applyProps } from '@react-three/fiber'\n\ntype N8AOProps = {\n aoRadius?: number\n distanceFalloff?: number\n intensity?: number\n quality?: 'performance' | 'low' | 'medium' | 'high' | 'ultra'\n aoSamples?: number\n denoiseSamples?: number\n denoiseRadius?: number\n color?: ReactThreeFiber.Color\n halfRes?: boolean\n depthAwareUpsampling?: boolean\n screenSpaceRadius?: boolean\n renderMode?: 0 | 1 | 2 | 3 | 4\n}\n\nexport const N8AO = forwardRef<N8AOPostPass, N8AOProps>(\n (\n {\n halfRes,\n screenSpaceRadius,\n quality,\n depthAwareUpsampling = true,\n aoRadius = 5,\n aoSamples = 16,\n denoiseSamples = 4,\n denoiseRadius = 12,\n distanceFalloff = 1,\n intensity = 1,\n color,\n renderMode = 0,\n },\n ref: Ref<N8AOPostPass>\n ) => {\n const { camera, scene } = useThree()\n const effect = useMemo(() => new N8AOPostPass(scene, camera), [camera, scene])\n\n // TODO: implement dispose upstream; this effect has memory leaks without\n useLayoutEffect(() => {\n applyProps(effect.configuration, {\n color,\n aoRadius,\n distanceFalloff,\n intensity,\n aoSamples,\n denoiseSamples,\n denoiseRadius,\n screenSpaceRadius,\n renderMode,\n halfRes,\n depthAwareUpsampling,\n })\n }, [\n screenSpaceRadius,\n color,\n aoRadius,\n distanceFalloff,\n intensity,\n aoSamples,\n denoiseSamples,\n denoiseRadius,\n renderMode,\n halfRes,\n depthAwareUpsampling,\n effect,\n ])\n\n useLayoutEffect(() => {\n if (quality) effect.setQualityMode(quality.charAt(0).toUpperCase() + quality.slice(1))\n }, [effect, quality])\n\n return <primitive ref={ref} object={effect} />\n }\n)\n"],"names":[],"mappings":";;;;AAuBO,MAAM,OAAO;AAAA,EAClB,CACE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA,uBAAuB;AAAA,IACvB,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,iBAAiB;AAAA,IACjB,gBAAgB;AAAA,IAChB,kBAAkB;AAAA,IAClB,YAAY;AAAA,IACZ;AAAA,IACA,aAAa;AAAA,KAEf,QACG;AACH,UAAM,EAAE,QAAQ,MAAM,IAAI,SAAS;AAC7B,UAAA,SAAS,QAAQ,MAAM,IAAI,aAAa,OAAO,MAAM,GAAG,CAAC,QAAQ,KAAK,CAAC;AAG7E,oBAAgB,MAAM;AACpB,iBAAW,OAAO,eAAe;AAAA,QAC/B;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA,CACD;AAAA,IAAA,GACA;AAAA,MACD;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD;AAED,oBAAgB,MAAM;AAChB,UAAA;AAAgB,eAAA,eAAe,QAAQ,OAAO,CAAC,EAAE,gBAAgB,QAAQ,MAAM,CAAC,CAAC;AAAA,IAAA,GACpF,CAAC,QAAQ,OAAO,CAAC;AAEpB,WAAQ,oBAAA,aAAA,EAAU,KAAU,QAAQ,OAAQ,CAAA;AAAA,EAC9C;AACF;"}
@@ -40,6 +40,8 @@ const Outline = React.forwardRef(function Outline2({
40
40
  xRay,
41
41
  ...props
42
42
  }),
43
+ // NOTE: `props` is an unstable reference, so we can't memoize it
44
+ // eslint-disable-next-line react-hooks/exhaustive-deps
43
45
  [
44
46
  blendFunction,
45
47
  blur,
@@ -1 +1 @@
1
- {"version":3,"file":"Outline.cjs","sources":["../../src/effects/Outline.tsx"],"sourcesContent":["import { OutlineEffect } from 'postprocessing'\nimport { Ref, MutableRefObject, forwardRef, useMemo, useEffect, useContext, useRef } from 'react'\nimport { Object3D } from 'three'\nimport { useThree } from '@react-three/fiber'\nimport { EffectComposerContext } from '../EffectComposer'\nimport { selectionContext } from '../Selection'\nimport { resolveRef } from '../util'\n\ntype ObjectRef = MutableRefObject<Object3D>\n\nexport type OutlineProps = ConstructorParameters<typeof OutlineEffect>[2] &\n Partial<{\n selection: Object3D | Object3D[] | ObjectRef | ObjectRef[]\n selectionLayer: number\n }>\n\nexport const Outline = forwardRef(function Outline(\n {\n selection = [],\n selectionLayer = 10,\n blendFunction,\n patternTexture,\n edgeStrength,\n pulseSpeed,\n visibleEdgeColor,\n hiddenEdgeColor,\n width,\n height,\n kernelSize,\n blur,\n xRay,\n ...props\n }: OutlineProps,\n forwardRef: Ref<OutlineEffect>\n) {\n const invalidate = useThree((state) => state.invalidate)\n const { scene, camera } = useContext(EffectComposerContext)\n\n const effect = useMemo(\n () =>\n new OutlineEffect(scene, camera, {\n blendFunction,\n patternTexture,\n edgeStrength,\n pulseSpeed,\n visibleEdgeColor,\n hiddenEdgeColor,\n width,\n height,\n kernelSize,\n blur,\n xRay,\n ...props,\n }),\n [\n blendFunction,\n blur,\n camera,\n edgeStrength,\n height,\n hiddenEdgeColor,\n kernelSize,\n patternTexture,\n pulseSpeed,\n scene,\n visibleEdgeColor,\n width,\n xRay,\n ]\n )\n\n const api = useContext(selectionContext)\n\n useEffect(() => {\n // Do not allow array selection if declarative selection is active\n // TODO: array selection should probably be deprecated altogether\n if (!api && selection) {\n effect.selection.set(\n Array.isArray(selection) ? (selection as Object3D[]).map(resolveRef) : [resolveRef(selection) as Object3D]\n )\n invalidate()\n return () => {\n effect.selection.clear()\n invalidate()\n }\n }\n }, [effect, selection, api, invalidate])\n\n useEffect(() => {\n effect.selectionLayer = selectionLayer\n invalidate()\n }, [effect, invalidate, selectionLayer])\n\n const ref = useRef<OutlineEffect>()\n useEffect(() => {\n if (api && api.enabled) {\n if (api.selected?.length) {\n effect.selection.set(api.selected)\n invalidate()\n return () => {\n effect.selection.clear()\n invalidate()\n }\n }\n }\n }, [api, effect.selection, invalidate])\n\n useEffect(() => {\n return () => {\n effect.dispose()\n }\n }, [effect])\n\n return <primitive ref={forwardRef} object={effect} />\n})\n"],"names":["forwardRef","Outline","useThree","useContext","EffectComposerContext","useMemo","OutlineEffect","selectionContext","useEffect","resolveRef","useRef","jsx"],"mappings":";;;;;;;;;AAgBa,MAAA,UAAUA,MAAAA,WAAW,SAASC,SACzC;AAAA,EACE,YAAY,CAAC;AAAA,EACb,iBAAiB;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GACAD,aACA;AACA,QAAM,aAAaE,MAAAA,SAAS,CAAC,UAAU,MAAM,UAAU;AACvD,QAAM,EAAE,OAAO,OAAO,IAAIC,iBAAWC,eAAqB,qBAAA;AAE1D,QAAM,SAASC,MAAA;AAAA,IACb,MACE,IAAIC,eAAAA,cAAc,OAAO,QAAQ;AAAA,MAC/B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IAAA,CACJ;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EAAA;AAGI,QAAA,MAAMH,iBAAWI,UAAAA,gBAAgB;AAEvCC,QAAAA,UAAU,MAAM;AAGV,QAAA,CAAC,OAAO,WAAW;AACrB,aAAO,UAAU;AAAA,QACf,MAAM,QAAQ,SAAS,IAAK,UAAyB,IAAIC,KAAAA,UAAU,IAAI,CAACA,gBAAW,SAAS,CAAa;AAAA,MAAA;AAEhG;AACX,aAAO,MAAM;AACX,eAAO,UAAU;AACN;MAAA;AAAA,IAEf;AAAA,KACC,CAAC,QAAQ,WAAW,KAAK,UAAU,CAAC;AAEvCD,QAAAA,UAAU,MAAM;AACd,WAAO,iBAAiB;AACb;EACV,GAAA,CAAC,QAAQ,YAAY,cAAc,CAAC;AAE3BE,eAAsB;AAClCF,QAAAA,UAAU,MAAM;;AACV,QAAA,OAAO,IAAI,SAAS;AAClB,WAAA,SAAI,aAAJ,mBAAc,QAAQ;AACjB,eAAA,UAAU,IAAI,IAAI,QAAQ;AACtB;AACX,eAAO,MAAM;AACX,iBAAO,UAAU;AACN;QAAA;AAAA,MAEf;AAAA,IACF;AAAA,KACC,CAAC,KAAK,OAAO,WAAW,UAAU,CAAC;AAEtCA,QAAAA,UAAU,MAAM;AACd,WAAO,MAAM;AACX,aAAO,QAAQ;AAAA,IAAA;AAAA,EACjB,GACC,CAAC,MAAM,CAAC;AAEX,SAAQG,2BAAAA,IAAA,aAAA,EAAU,KAAKX,aAAY,QAAQ,OAAQ,CAAA;AACrD,CAAC;;"}
1
+ {"version":3,"file":"Outline.cjs","sources":["../../src/effects/Outline.tsx"],"sourcesContent":["import { OutlineEffect } from 'postprocessing'\nimport { Ref, MutableRefObject, forwardRef, useMemo, useEffect, useContext, useRef } from 'react'\nimport { Object3D } from 'three'\nimport { useThree } from '@react-three/fiber'\nimport { EffectComposerContext } from '../EffectComposer'\nimport { selectionContext } from '../Selection'\nimport { resolveRef } from '../util'\n\ntype ObjectRef = MutableRefObject<Object3D>\n\nexport type OutlineProps = ConstructorParameters<typeof OutlineEffect>[2] &\n Partial<{\n selection: Object3D | Object3D[] | ObjectRef | ObjectRef[]\n selectionLayer: number\n }>\n\nexport const Outline = forwardRef(function Outline(\n {\n selection = [],\n selectionLayer = 10,\n blendFunction,\n patternTexture,\n edgeStrength,\n pulseSpeed,\n visibleEdgeColor,\n hiddenEdgeColor,\n width,\n height,\n kernelSize,\n blur,\n xRay,\n ...props\n }: OutlineProps,\n forwardRef: Ref<OutlineEffect>\n) {\n const invalidate = useThree((state) => state.invalidate)\n const { scene, camera } = useContext(EffectComposerContext)\n\n const effect = useMemo(\n () =>\n new OutlineEffect(scene, camera, {\n blendFunction,\n patternTexture,\n edgeStrength,\n pulseSpeed,\n visibleEdgeColor,\n hiddenEdgeColor,\n width,\n height,\n kernelSize,\n blur,\n xRay,\n ...props,\n }),\n // NOTE: `props` is an unstable reference, so we can't memoize it\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n blendFunction,\n blur,\n camera,\n edgeStrength,\n height,\n hiddenEdgeColor,\n kernelSize,\n patternTexture,\n pulseSpeed,\n scene,\n visibleEdgeColor,\n width,\n xRay,\n ]\n )\n\n const api = useContext(selectionContext)\n\n useEffect(() => {\n // Do not allow array selection if declarative selection is active\n // TODO: array selection should probably be deprecated altogether\n if (!api && selection) {\n effect.selection.set(\n Array.isArray(selection) ? (selection as Object3D[]).map(resolveRef) : [resolveRef(selection) as Object3D]\n )\n invalidate()\n return () => {\n effect.selection.clear()\n invalidate()\n }\n }\n }, [effect, selection, api, invalidate])\n\n useEffect(() => {\n effect.selectionLayer = selectionLayer\n invalidate()\n }, [effect, invalidate, selectionLayer])\n\n const ref = useRef<OutlineEffect>()\n useEffect(() => {\n if (api && api.enabled) {\n if (api.selected?.length) {\n effect.selection.set(api.selected)\n invalidate()\n return () => {\n effect.selection.clear()\n invalidate()\n }\n }\n }\n }, [api, effect.selection, invalidate])\n\n useEffect(() => {\n return () => {\n effect.dispose()\n }\n }, [effect])\n\n return <primitive ref={forwardRef} object={effect} />\n})\n"],"names":["forwardRef","Outline","useThree","useContext","EffectComposerContext","useMemo","OutlineEffect","selectionContext","useEffect","resolveRef","useRef","jsx"],"mappings":";;;;;;;;;AAgBa,MAAA,UAAUA,MAAAA,WAAW,SAASC,SACzC;AAAA,EACE,YAAY,CAAC;AAAA,EACb,iBAAiB;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GACAD,aACA;AACA,QAAM,aAAaE,MAAAA,SAAS,CAAC,UAAU,MAAM,UAAU;AACvD,QAAM,EAAE,OAAO,OAAO,IAAIC,iBAAWC,eAAqB,qBAAA;AAE1D,QAAM,SAASC,MAAA;AAAA,IACb,MACE,IAAIC,eAAAA,cAAc,OAAO,QAAQ;AAAA,MAC/B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IAAA,CACJ;AAAA;AAAA;AAAA,IAGH;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EAAA;AAGI,QAAA,MAAMH,iBAAWI,UAAAA,gBAAgB;AAEvCC,QAAAA,UAAU,MAAM;AAGV,QAAA,CAAC,OAAO,WAAW;AACrB,aAAO,UAAU;AAAA,QACf,MAAM,QAAQ,SAAS,IAAK,UAAyB,IAAIC,KAAAA,UAAU,IAAI,CAACA,gBAAW,SAAS,CAAa;AAAA,MAAA;AAEhG;AACX,aAAO,MAAM;AACX,eAAO,UAAU;AACN;MAAA;AAAA,IAEf;AAAA,KACC,CAAC,QAAQ,WAAW,KAAK,UAAU,CAAC;AAEvCD,QAAAA,UAAU,MAAM;AACd,WAAO,iBAAiB;AACb;EACV,GAAA,CAAC,QAAQ,YAAY,cAAc,CAAC;AAE3BE,eAAsB;AAClCF,QAAAA,UAAU,MAAM;;AACV,QAAA,OAAO,IAAI,SAAS;AAClB,WAAA,SAAI,aAAJ,mBAAc,QAAQ;AACjB,eAAA,UAAU,IAAI,IAAI,QAAQ;AACtB;AACX,eAAO,MAAM;AACX,iBAAO,UAAU;AACN;QAAA;AAAA,MAEf;AAAA,IACF;AAAA,KACC,CAAC,KAAK,OAAO,WAAW,UAAU,CAAC;AAEtCA,QAAAA,UAAU,MAAM;AACd,WAAO,MAAM;AACX,aAAO,QAAQ;AAAA,IAAA;AAAA,EACjB,GACC,CAAC,MAAM,CAAC;AAEX,SAAQG,2BAAAA,IAAA,aAAA,EAAU,KAAKX,aAAY,QAAQ,OAAQ,CAAA;AACrD,CAAC;;"}
@@ -38,6 +38,8 @@ const Outline = forwardRef(function Outline2({
38
38
  xRay,
39
39
  ...props
40
40
  }),
41
+ // NOTE: `props` is an unstable reference, so we can't memoize it
42
+ // eslint-disable-next-line react-hooks/exhaustive-deps
41
43
  [
42
44
  blendFunction,
43
45
  blur,
@@ -1 +1 @@
1
- {"version":3,"file":"Outline.js","sources":["../../src/effects/Outline.tsx"],"sourcesContent":["import { OutlineEffect } from 'postprocessing'\nimport { Ref, MutableRefObject, forwardRef, useMemo, useEffect, useContext, useRef } from 'react'\nimport { Object3D } from 'three'\nimport { useThree } from '@react-three/fiber'\nimport { EffectComposerContext } from '../EffectComposer'\nimport { selectionContext } from '../Selection'\nimport { resolveRef } from '../util'\n\ntype ObjectRef = MutableRefObject<Object3D>\n\nexport type OutlineProps = ConstructorParameters<typeof OutlineEffect>[2] &\n Partial<{\n selection: Object3D | Object3D[] | ObjectRef | ObjectRef[]\n selectionLayer: number\n }>\n\nexport const Outline = forwardRef(function Outline(\n {\n selection = [],\n selectionLayer = 10,\n blendFunction,\n patternTexture,\n edgeStrength,\n pulseSpeed,\n visibleEdgeColor,\n hiddenEdgeColor,\n width,\n height,\n kernelSize,\n blur,\n xRay,\n ...props\n }: OutlineProps,\n forwardRef: Ref<OutlineEffect>\n) {\n const invalidate = useThree((state) => state.invalidate)\n const { scene, camera } = useContext(EffectComposerContext)\n\n const effect = useMemo(\n () =>\n new OutlineEffect(scene, camera, {\n blendFunction,\n patternTexture,\n edgeStrength,\n pulseSpeed,\n visibleEdgeColor,\n hiddenEdgeColor,\n width,\n height,\n kernelSize,\n blur,\n xRay,\n ...props,\n }),\n [\n blendFunction,\n blur,\n camera,\n edgeStrength,\n height,\n hiddenEdgeColor,\n kernelSize,\n patternTexture,\n pulseSpeed,\n scene,\n visibleEdgeColor,\n width,\n xRay,\n ]\n )\n\n const api = useContext(selectionContext)\n\n useEffect(() => {\n // Do not allow array selection if declarative selection is active\n // TODO: array selection should probably be deprecated altogether\n if (!api && selection) {\n effect.selection.set(\n Array.isArray(selection) ? (selection as Object3D[]).map(resolveRef) : [resolveRef(selection) as Object3D]\n )\n invalidate()\n return () => {\n effect.selection.clear()\n invalidate()\n }\n }\n }, [effect, selection, api, invalidate])\n\n useEffect(() => {\n effect.selectionLayer = selectionLayer\n invalidate()\n }, [effect, invalidate, selectionLayer])\n\n const ref = useRef<OutlineEffect>()\n useEffect(() => {\n if (api && api.enabled) {\n if (api.selected?.length) {\n effect.selection.set(api.selected)\n invalidate()\n return () => {\n effect.selection.clear()\n invalidate()\n }\n }\n }\n }, [api, effect.selection, invalidate])\n\n useEffect(() => {\n return () => {\n effect.dispose()\n }\n }, [effect])\n\n return <primitive ref={forwardRef} object={effect} />\n})\n"],"names":["Outline","forwardRef"],"mappings":";;;;;;;AAgBa,MAAA,UAAU,WAAW,SAASA,SACzC;AAAA,EACE,YAAY,CAAC;AAAA,EACb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AAA;AAAA,MAEf;AAAA,IACF;AAAA,KACC,CAAC,KAAK,OAAO,WAAW,UAAU,CAAC;AAEtC,YAAU,MAAM;AACd,WAAO,MAAM;AACX,aAAO,QAAQ;AAAA,IAAA;AAAA,EACjB,GACC,CAAC,MAAM,CAAC;AAEX,SAAQ,oBAAA,aAAA,EAAU,KAAKA,aAAY,QAAQ,OAAQ,CAAA;AACrD,CAAC;"}
1
+ {"version":3,"file":"Outline.js","sources":["../../src/effects/Outline.tsx"],"sourcesContent":["import { OutlineEffect } from 'postprocessing'\nimport { Ref, MutableRefObject, forwardRef, useMemo, useEffect, useContext, useRef } from 'react'\nimport { Object3D } from 'three'\nimport { useThree } from '@react-three/fiber'\nimport { EffectComposerContext } from '../EffectComposer'\nimport { selectionContext } from '../Selection'\nimport { resolveRef } from '../util'\n\ntype ObjectRef = MutableRefObject<Object3D>\n\nexport type OutlineProps = ConstructorParameters<typeof OutlineEffect>[2] &\n Partial<{\n selection: Object3D | Object3D[] | ObjectRef | ObjectRef[]\n selectionLayer: number\n }>\n\nexport const Outline = forwardRef(function Outline(\n {\n selection = [],\n selectionLayer = 10,\n blendFunction,\n patternTexture,\n edgeStrength,\n pulseSpeed,\n visibleEdgeColor,\n hiddenEdgeColor,\n width,\n height,\n kernelSize,\n blur,\n xRay,\n ...props\n }: OutlineProps,\n forwardRef: Ref<OutlineEffect>\n) {\n const invalidate = useThree((state) => state.invalidate)\n const { scene, camera } = useContext(EffectComposerContext)\n\n const effect = useMemo(\n () =>\n new OutlineEffect(scene, camera, {\n blendFunction,\n patternTexture,\n edgeStrength,\n pulseSpeed,\n visibleEdgeColor,\n hiddenEdgeColor,\n width,\n height,\n kernelSize,\n blur,\n xRay,\n ...props,\n }),\n // NOTE: `props` is an unstable reference, so we can't memoize it\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n blendFunction,\n blur,\n camera,\n edgeStrength,\n height,\n hiddenEdgeColor,\n kernelSize,\n patternTexture,\n pulseSpeed,\n scene,\n visibleEdgeColor,\n width,\n xRay,\n ]\n )\n\n const api = useContext(selectionContext)\n\n useEffect(() => {\n // Do not allow array selection if declarative selection is active\n // TODO: array selection should probably be deprecated altogether\n if (!api && selection) {\n effect.selection.set(\n Array.isArray(selection) ? (selection as Object3D[]).map(resolveRef) : [resolveRef(selection) as Object3D]\n )\n invalidate()\n return () => {\n effect.selection.clear()\n invalidate()\n }\n }\n }, [effect, selection, api, invalidate])\n\n useEffect(() => {\n effect.selectionLayer = selectionLayer\n invalidate()\n }, [effect, invalidate, selectionLayer])\n\n const ref = useRef<OutlineEffect>()\n useEffect(() => {\n if (api && api.enabled) {\n if (api.selected?.length) {\n effect.selection.set(api.selected)\n invalidate()\n return () => {\n effect.selection.clear()\n invalidate()\n }\n }\n }\n }, [api, effect.selection, invalidate])\n\n useEffect(() => {\n return () => {\n effect.dispose()\n }\n }, [effect])\n\n return <primitive ref={forwardRef} object={effect} />\n})\n"],"names":["Outline","forwardRef"],"mappings":";;;;;;;AAgBa,MAAA,UAAU,WAAW,SAASA,SACzC;AAAA,EACE,YAAY,CAAC;AAAA,EACb,iBAAiB;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GACAC,aACA;AACA,QAAM,aAAa,SAAS,CAAC,UAAU,MAAM,UAAU;AACvD,QAAM,EAAE,OAAO,OAAO,IAAI,WAAW,qBAAqB;AAE1D,QAAM,SAAS;AAAA,IACb,MACE,IAAI,cAAc,OAAO,QAAQ;AAAA,MAC/B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IAAA,CACJ;AAAA;AAAA;AAAA,IAGH;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EAAA;AAGI,QAAA,MAAM,WAAW,gBAAgB;AAEvC,YAAU,MAAM;AAGV,QAAA,CAAC,OAAO,WAAW;AACrB,aAAO,UAAU;AAAA,QACf,MAAM,QAAQ,SAAS,IAAK,UAAyB,IAAI,UAAU,IAAI,CAAC,WAAW,SAAS,CAAa;AAAA,MAAA;AAEhG;AACX,aAAO,MAAM;AACX,eAAO,UAAU;AACN;MAAA;AAAA,IAEf;AAAA,KACC,CAAC,QAAQ,WAAW,KAAK,UAAU,CAAC;AAEvC,YAAU,MAAM;AACd,WAAO,iBAAiB;AACb;EACV,GAAA,CAAC,QAAQ,YAAY,cAAc,CAAC;AAE3B,SAAsB;AAClC,YAAU,MAAM;;AACV,QAAA,OAAO,IAAI,SAAS;AAClB,WAAA,SAAI,aAAJ,mBAAc,QAAQ;AACjB,eAAA,UAAU,IAAI,IAAI,QAAQ;AACtB;AACX,eAAO,MAAM;AACX,iBAAO,UAAU;AACN;QAAA;AAAA,MAEf;AAAA,IACF;AAAA,KACC,CAAC,KAAK,OAAO,WAAW,UAAU,CAAC;AAEtC,YAAU,MAAM;AACd,WAAO,MAAM;AACX,aAAO,QAAQ;AAAA,IAAA;AAAA,EACjB,GACC,CAAC,MAAM,CAAC;AAEX,SAAQ,oBAAA,aAAA,EAAU,KAAKA,aAAY,QAAQ,OAAQ,CAAA;AACrD,CAAC;"}
@@ -30,7 +30,7 @@ const SSAO = React.forwardRef(function SSAO2(props, ref) {
30
30
  depthAwareUpsampling: true,
31
31
  ...props
32
32
  });
33
- }, [camera, normalPass, props]);
33
+ }, [camera, downSamplingPass, normalPass, resolutionScale]);
34
34
  return /* @__PURE__ */ jsxRuntime.jsx("primitive", { ref, object: effect, dispose: null });
35
35
  });
36
36
  exports.SSAO = SSAO;
@@ -1 +1 @@
1
- {"version":3,"file":"SSAO.cjs","sources":["../../src/effects/SSAO.tsx"],"sourcesContent":["import { Ref, forwardRef, useContext, useMemo } from 'react'\nimport { SSAOEffect, BlendFunction } from 'postprocessing'\nimport { EffectComposerContext } from '../EffectComposer'\n\n// first two args are camera and texture\ntype SSAOProps = ConstructorParameters<typeof SSAOEffect>[2]\n\nexport const SSAO = forwardRef<SSAOEffect, SSAOProps>(function SSAO(props: SSAOProps, ref: Ref<SSAOEffect>) {\n const { camera, normalPass, downSamplingPass, resolutionScale } = useContext(EffectComposerContext)\n const effect = useMemo<SSAOEffect | {}>(() => {\n if (normalPass === null && downSamplingPass === null) {\n console.error('Please enable the NormalPass in the EffectComposer in order to use SSAO.')\n return {}\n }\n return new SSAOEffect(camera, normalPass && !downSamplingPass ? (normalPass as any).texture : null, {\n blendFunction: BlendFunction.MULTIPLY,\n samples: 30,\n rings: 4,\n distanceThreshold: 1.0,\n distanceFalloff: 0.0,\n rangeThreshold: 0.5,\n rangeFalloff: 0.1,\n luminanceInfluence: 0.9,\n radius: 20,\n bias: 0.5,\n intensity: 1.0,\n color: undefined,\n // @ts-ignore\n normalDepthBuffer: downSamplingPass ? downSamplingPass.texture : null,\n resolutionScale: resolutionScale ?? 1,\n depthAwareUpsampling: true,\n ...props,\n })\n }, [camera, normalPass, props])\n return <primitive ref={ref} object={effect} dispose={null} />\n})\n"],"names":["forwardRef","SSAO","useContext","EffectComposerContext","useMemo","SSAOEffect","BlendFunction"],"mappings":";;;;;;AAOO,MAAM,OAAOA,MAAAA,WAAkC,SAASC,MAAK,OAAkB,KAAsB;AAC1G,QAAM,EAAE,QAAQ,YAAY,kBAAkB,oBAAoBC,MAAAA,WAAWC,eAAAA,qBAAqB;AAC5F,QAAA,SAASC,MAAAA,QAAyB,MAAM;AACxC,QAAA,eAAe,QAAQ,qBAAqB,MAAM;AACpD,cAAQ,MAAM,0EAA0E;AACxF,aAAO;IACT;AACO,WAAA,IAAIC,eAAAA,WAAW,QAAQ,cAAc,CAAC,mBAAoB,WAAmB,UAAU,MAAM;AAAA,MAClG,eAAeC,eAAc,cAAA;AAAA,MAC7B,SAAS;AAAA,MACT,OAAO;AAAA,MACP,mBAAmB;AAAA,MACnB,iBAAiB;AAAA,MACjB,gBAAgB;AAAA,MAChB,cAAc;AAAA,MACd,oBAAoB;AAAA,MACpB,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,WAAW;AAAA,MACX,OAAO;AAAA;AAAA,MAEP,mBAAmB,mBAAmB,iBAAiB,UAAU;AAAA,MACjE,iBAAiB,4CAAmB;AAAA,MACpC,sBAAsB;AAAA,MACtB,GAAG;AAAA,IAAA,CACJ;AAAA,EACA,GAAA,CAAC,QAAQ,YAAY,KAAK,CAAC;AAC9B,wCAAQ,aAAU,EAAA,KAAU,QAAQ,QAAQ,SAAS,KAAM,CAAA;AAC7D,CAAC;;"}
1
+ {"version":3,"file":"SSAO.cjs","sources":["../../src/effects/SSAO.tsx"],"sourcesContent":["import { Ref, forwardRef, useContext, useMemo } from 'react'\nimport { SSAOEffect, BlendFunction } from 'postprocessing'\nimport { EffectComposerContext } from '../EffectComposer'\n\n// first two args are camera and texture\ntype SSAOProps = ConstructorParameters<typeof SSAOEffect>[2]\n\nexport const SSAO = forwardRef<SSAOEffect, SSAOProps>(function SSAO(props: SSAOProps, ref: Ref<SSAOEffect>) {\n const { camera, normalPass, downSamplingPass, resolutionScale } = useContext(EffectComposerContext)\n const effect = useMemo<SSAOEffect | {}>(() => {\n if (normalPass === null && downSamplingPass === null) {\n console.error('Please enable the NormalPass in the EffectComposer in order to use SSAO.')\n return {}\n }\n return new SSAOEffect(camera, normalPass && !downSamplingPass ? (normalPass as any).texture : null, {\n blendFunction: BlendFunction.MULTIPLY,\n samples: 30,\n rings: 4,\n distanceThreshold: 1.0,\n distanceFalloff: 0.0,\n rangeThreshold: 0.5,\n rangeFalloff: 0.1,\n luminanceInfluence: 0.9,\n radius: 20,\n bias: 0.5,\n intensity: 1.0,\n color: undefined,\n // @ts-ignore\n normalDepthBuffer: downSamplingPass ? downSamplingPass.texture : null,\n resolutionScale: resolutionScale ?? 1,\n depthAwareUpsampling: true,\n ...props,\n })\n // NOTE: `props` is an unstable reference, so we can't memoize it\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [camera, downSamplingPass, normalPass, resolutionScale])\n return <primitive ref={ref} object={effect} dispose={null} />\n})\n"],"names":["forwardRef","SSAO","useContext","EffectComposerContext","useMemo","SSAOEffect","BlendFunction"],"mappings":";;;;;;AAOO,MAAM,OAAOA,MAAAA,WAAkC,SAASC,MAAK,OAAkB,KAAsB;AAC1G,QAAM,EAAE,QAAQ,YAAY,kBAAkB,oBAAoBC,MAAAA,WAAWC,eAAAA,qBAAqB;AAC5F,QAAA,SAASC,MAAAA,QAAyB,MAAM;AACxC,QAAA,eAAe,QAAQ,qBAAqB,MAAM;AACpD,cAAQ,MAAM,0EAA0E;AACxF,aAAO;IACT;AACO,WAAA,IAAIC,eAAAA,WAAW,QAAQ,cAAc,CAAC,mBAAoB,WAAmB,UAAU,MAAM;AAAA,MAClG,eAAeC,eAAc,cAAA;AAAA,MAC7B,SAAS;AAAA,MACT,OAAO;AAAA,MACP,mBAAmB;AAAA,MACnB,iBAAiB;AAAA,MACjB,gBAAgB;AAAA,MAChB,cAAc;AAAA,MACd,oBAAoB;AAAA,MACpB,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,WAAW;AAAA,MACX,OAAO;AAAA;AAAA,MAEP,mBAAmB,mBAAmB,iBAAiB,UAAU;AAAA,MACjE,iBAAiB,4CAAmB;AAAA,MACpC,sBAAsB;AAAA,MACtB,GAAG;AAAA,IAAA,CACJ;AAAA,KAGA,CAAC,QAAQ,kBAAkB,YAAY,eAAe,CAAC;AAC1D,wCAAQ,aAAU,EAAA,KAAU,QAAQ,QAAQ,SAAS,KAAM,CAAA;AAC7D,CAAC;;"}
@@ -28,7 +28,7 @@ const SSAO = forwardRef(function SSAO2(props, ref) {
28
28
  depthAwareUpsampling: true,
29
29
  ...props
30
30
  });
31
- }, [camera, normalPass, props]);
31
+ }, [camera, downSamplingPass, normalPass, resolutionScale]);
32
32
  return /* @__PURE__ */ jsx("primitive", { ref, object: effect, dispose: null });
33
33
  });
34
34
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"SSAO.js","sources":["../../src/effects/SSAO.tsx"],"sourcesContent":["import { Ref, forwardRef, useContext, useMemo } from 'react'\nimport { SSAOEffect, BlendFunction } from 'postprocessing'\nimport { EffectComposerContext } from '../EffectComposer'\n\n// first two args are camera and texture\ntype SSAOProps = ConstructorParameters<typeof SSAOEffect>[2]\n\nexport const SSAO = forwardRef<SSAOEffect, SSAOProps>(function SSAO(props: SSAOProps, ref: Ref<SSAOEffect>) {\n const { camera, normalPass, downSamplingPass, resolutionScale } = useContext(EffectComposerContext)\n const effect = useMemo<SSAOEffect | {}>(() => {\n if (normalPass === null && downSamplingPass === null) {\n console.error('Please enable the NormalPass in the EffectComposer in order to use SSAO.')\n return {}\n }\n return new SSAOEffect(camera, normalPass && !downSamplingPass ? (normalPass as any).texture : null, {\n blendFunction: BlendFunction.MULTIPLY,\n samples: 30,\n rings: 4,\n distanceThreshold: 1.0,\n distanceFalloff: 0.0,\n rangeThreshold: 0.5,\n rangeFalloff: 0.1,\n luminanceInfluence: 0.9,\n radius: 20,\n bias: 0.5,\n intensity: 1.0,\n color: undefined,\n // @ts-ignore\n normalDepthBuffer: downSamplingPass ? downSamplingPass.texture : null,\n resolutionScale: resolutionScale ?? 1,\n depthAwareUpsampling: true,\n ...props,\n })\n }, [camera, normalPass, props])\n return <primitive ref={ref} object={effect} dispose={null} />\n})\n"],"names":["SSAO"],"mappings":";;;;AAOO,MAAM,OAAO,WAAkC,SAASA,MAAK,OAAkB,KAAsB;AAC1G,QAAM,EAAE,QAAQ,YAAY,kBAAkB,oBAAoB,WAAW,qBAAqB;AAC5F,QAAA,SAAS,QAAyB,MAAM;AACxC,QAAA,eAAe,QAAQ,qBAAqB,MAAM;AACpD,cAAQ,MAAM,0EAA0E;AACxF,aAAO;IACT;AACO,WAAA,IAAI,WAAW,QAAQ,cAAc,CAAC,mBAAoB,WAAmB,UAAU,MAAM;AAAA,MAClG,eAAe,cAAc;AAAA,MAC7B,SAAS;AAAA,MACT,OAAO;AAAA,MACP,mBAAmB;AAAA,MACnB,iBAAiB;AAAA,MACjB,gBAAgB;AAAA,MAChB,cAAc;AAAA,MACd,oBAAoB;AAAA,MACpB,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,WAAW;AAAA,MACX,OAAO;AAAA;AAAA,MAEP,mBAAmB,mBAAmB,iBAAiB,UAAU;AAAA,MACjE,iBAAiB,4CAAmB;AAAA,MACpC,sBAAsB;AAAA,MACtB,GAAG;AAAA,IAAA,CACJ;AAAA,EACA,GAAA,CAAC,QAAQ,YAAY,KAAK,CAAC;AAC9B,6BAAQ,aAAU,EAAA,KAAU,QAAQ,QAAQ,SAAS,KAAM,CAAA;AAC7D,CAAC;"}
1
+ {"version":3,"file":"SSAO.js","sources":["../../src/effects/SSAO.tsx"],"sourcesContent":["import { Ref, forwardRef, useContext, useMemo } from 'react'\nimport { SSAOEffect, BlendFunction } from 'postprocessing'\nimport { EffectComposerContext } from '../EffectComposer'\n\n// first two args are camera and texture\ntype SSAOProps = ConstructorParameters<typeof SSAOEffect>[2]\n\nexport const SSAO = forwardRef<SSAOEffect, SSAOProps>(function SSAO(props: SSAOProps, ref: Ref<SSAOEffect>) {\n const { camera, normalPass, downSamplingPass, resolutionScale } = useContext(EffectComposerContext)\n const effect = useMemo<SSAOEffect | {}>(() => {\n if (normalPass === null && downSamplingPass === null) {\n console.error('Please enable the NormalPass in the EffectComposer in order to use SSAO.')\n return {}\n }\n return new SSAOEffect(camera, normalPass && !downSamplingPass ? (normalPass as any).texture : null, {\n blendFunction: BlendFunction.MULTIPLY,\n samples: 30,\n rings: 4,\n distanceThreshold: 1.0,\n distanceFalloff: 0.0,\n rangeThreshold: 0.5,\n rangeFalloff: 0.1,\n luminanceInfluence: 0.9,\n radius: 20,\n bias: 0.5,\n intensity: 1.0,\n color: undefined,\n // @ts-ignore\n normalDepthBuffer: downSamplingPass ? downSamplingPass.texture : null,\n resolutionScale: resolutionScale ?? 1,\n depthAwareUpsampling: true,\n ...props,\n })\n // NOTE: `props` is an unstable reference, so we can't memoize it\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [camera, downSamplingPass, normalPass, resolutionScale])\n return <primitive ref={ref} object={effect} dispose={null} />\n})\n"],"names":["SSAO"],"mappings":";;;;AAOO,MAAM,OAAO,WAAkC,SAASA,MAAK,OAAkB,KAAsB;AAC1G,QAAM,EAAE,QAAQ,YAAY,kBAAkB,oBAAoB,WAAW,qBAAqB;AAC5F,QAAA,SAAS,QAAyB,MAAM;AACxC,QAAA,eAAe,QAAQ,qBAAqB,MAAM;AACpD,cAAQ,MAAM,0EAA0E;AACxF,aAAO;IACT;AACO,WAAA,IAAI,WAAW,QAAQ,cAAc,CAAC,mBAAoB,WAAmB,UAAU,MAAM;AAAA,MAClG,eAAe,cAAc;AAAA,MAC7B,SAAS;AAAA,MACT,OAAO;AAAA,MACP,mBAAmB;AAAA,MACnB,iBAAiB;AAAA,MACjB,gBAAgB;AAAA,MAChB,cAAc;AAAA,MACd,oBAAoB;AAAA,MACpB,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,WAAW;AAAA,MACX,OAAO;AAAA;AAAA,MAEP,mBAAmB,mBAAmB,iBAAiB,UAAU;AAAA,MACjE,iBAAiB,4CAAmB;AAAA,MACpC,sBAAsB;AAAA,MACtB,GAAG;AAAA,IAAA,CACJ;AAAA,KAGA,CAAC,QAAQ,kBAAkB,YAAY,eAAe,CAAC;AAC1D,6BAAQ,aAAU,EAAA,KAAU,QAAQ,QAAQ,SAAS,KAAM,CAAA;AAC7D,CAAC;"}
@@ -7,7 +7,7 @@ const EffectComposer = require("../../EffectComposer.cjs");
7
7
  const Selection = require("../../Selection.cjs");
8
8
  const fiber = require("@react-three/fiber");
9
9
  const SSR = React.forwardRef(function SSR2({ ENABLE_BLUR = true, USE_MRT = true, ...props }, ref) {
10
- const { invalidate } = fiber.useThree();
10
+ const invalidate = fiber.useThree((s) => s.invalidate);
11
11
  const { scene, camera } = React.useContext(EffectComposer.EffectComposerContext);
12
12
  const effect = React.useMemo(
13
13
  () => new screenSpaceReflections.SSREffect(scene, camera, { ENABLE_BLUR, USE_MRT, ...props }),
@@ -26,7 +26,7 @@ const SSR = React.forwardRef(function SSR2({ ENABLE_BLUR = true, USE_MRT = true,
26
26
  };
27
27
  }
28
28
  }
29
- }, [api]);
29
+ }, [api, effect, invalidate]);
30
30
  return /* @__PURE__ */ jsxRuntime.jsx("primitive", { ref, object: effect, ...props });
31
31
  });
32
32
  exports.SSR = SSR;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../src/effects/SSR/index.tsx"],"sourcesContent":["import React, { Ref, forwardRef, useLayoutEffect, useEffect, useContext, useMemo } from 'react'\n/* @ts-ignore */\nimport { SSREffect } from './screen-space-reflections'\nimport { EffectComposerContext } from '../../EffectComposer'\nimport { selectionContext } from '../../Selection'\nimport { useThree } from '@react-three/fiber'\n\n// first two args are camera and texture\ntype SSRProps = {\n /** whether you want to use Temporal Resolving to re-use reflections from the last frames; this will reduce noise tremendously but may result in \"smearing\" */\n temporalResolve?: boolean\n /** a value between 0 and 1 to set how much the last frame's reflections should be blended in; higher values will result in less noisy reflections when moving the camera but a more smeary look */\n temporalResolveMix?: number\n /** a value between 0 and 1 to set how much the reprojected reflection should be corrected; higher values will reduce smearing but will result in less flickering at reflection edges */\n temporalResolveCorrectionMix?: number\n /** the maximum number of samples for reflections; settings it to 0 means unlimited samples; setting it to a value like 6 can help make camera movements less disruptive when calculating reflections */\n maxSamples?: number\n /** whether to blur the reflections and blend these blurred reflections with the raw ones depending on the blurMix value */\n ENABLE_BLUR?: boolean\n /** how much the blurred reflections should be mixed with the raw reflections */\n blurMix?: number\n /** the sharpness of the Bilateral Filter used to blur reflections */\n blurSharpness?: number\n /** the kernel size of the Bilateral Blur Filter; higher kernel sizes will result in blurrier reflections with more artifacts */\n blurKernelSize?: number\n /** how much the reflection ray should travel in each of its iteration; higher values will give deeper reflections but with more artifacts */\n rayStep?: number\n /** the intensity of the reflections */\n intensity?: number\n /** the maximum roughness a texel can have to have reflections calculated for it */\n maxRoughness?: number\n /** whether jittering is enabled; jittering will randomly jitter the reflections resulting in a more noisy but overall more realistic look, enabling jittering can be expensive depending on the view angle */\n ENABLE_JITTERING?: boolean\n /** how intense jittering should be */\n jitter?: number\n /** how much the jittered rays should be spread; higher values will give a rougher look regarding the reflections but are more expensive to compute with */\n jitterSpread?: number\n /** how intense jittering should be in relation to a material's roughness */\n jitterRough?: number\n /** the number of steps a reflection ray can maximally do to find an object it intersected (and thus reflects) */\n MAX_STEPS?: number\n /** once we had our ray intersect something, we need to find the exact point in space it intersected and thus it reflects; this can be done through binary search with the given number of maximum steps */\n NUM_BINARY_SEARCH_STEPS?: number\n /** the maximum depth difference between a ray and the particular depth at its screen position after refining with binary search; lower values will result in better performance */\n maxDepthDifference?: number\n /** the maximum depth for which reflections will be calculated */\n maxDepth?: number\n /** the maximum depth difference between a ray and the particular depth at its screen position before refining with binary search; lower values will result in better performance */\n thickness?: number\n /** Index of Refraction, used for calculating fresnel; reflections tend to be more intense the steeper the angle between them and the viewer is, the ior parameter set how much the intensity varies */\n ior?: number\n /** if there should still be reflections for rays for which a reflecting point couldn't be found; enabling this will result in stretched looking reflections which can look good or bad depending on the angle */\n STRETCH_MISSED_RAYS?: boolean\n /** WebGL2 only - whether to use multiple render targets when rendering the G-buffers (normals, depth and roughness); using them can improve performance as they will render all information to multiple buffers for each fragment in one run; this setting can't be changed during run-time */\n USE_MRT?: boolean\n /** if roughness maps should be taken account of when calculating reflections */\n USE_ROUGHNESSMAP?: boolean\n /** if normal maps should be taken account of when calculating reflections */\n USE_NORMALMAP?: boolean\n}\n\nexport const SSR = forwardRef<SSREffect, SSRProps>(function SSR(\n { ENABLE_BLUR = true, USE_MRT = true, ...props }: SSRProps,\n\n ref: Ref<SSREffect>\n) {\n const { invalidate } = useThree()\n const { scene, camera } = useContext(EffectComposerContext)\n const effect = useMemo(\n () => new SSREffect(scene, camera, { ENABLE_BLUR, USE_MRT, ...props }),\n [scene, camera, ENABLE_BLUR, USE_MRT, props]\n )\n\n const api = useContext(selectionContext)\n useEffect(() => {\n if (api && api.enabled) {\n if (api.selected?.length) {\n effect.selection.set(api.selected)\n invalidate()\n return () => {\n effect.selection.clear()\n invalidate()\n }\n }\n }\n }, [api])\n\n return <primitive ref={ref} object={effect} {...props} />\n})\n"],"names":["forwardRef","SSR","useThree","useContext","EffectComposerContext","useMemo","SSREffect","selectionContext","useEffect"],"mappings":";;;;;;;;AA6DO,MAAM,MAAMA,MAAA,WAAgC,SAASC,KAC1D,EAAE,cAAc,MAAM,UAAU,MAAM,GAAG,MAAM,GAE/C,KACA;AACM,QAAA,EAAE,eAAeC,MAAAA;AACvB,QAAM,EAAE,OAAO,OAAO,IAAIC,iBAAWC,eAAqB,qBAAA;AAC1D,QAAM,SAASC,MAAA;AAAA,IACb,MAAM,IAAIC,uBAAAA,UAAU,OAAO,QAAQ,EAAE,aAAa,SAAS,GAAG,OAAO;AAAA,IACrE,CAAC,OAAO,QAAQ,aAAa,SAAS,KAAK;AAAA,EAAA;AAGvC,QAAA,MAAMH,iBAAWI,UAAAA,gBAAgB;AACvCC,QAAAA,UAAU,MAAM;;AACV,QAAA,OAAO,IAAI,SAAS;AAClB,WAAA,SAAI,aAAJ,mBAAc,QAAQ;AACjB,eAAA,UAAU,IAAI,IAAI,QAAQ;AACtB;AACX,eAAO,MAAM;AACX,iBAAO,UAAU;AACN;QAAA;AAAA,MAEf;AAAA,IACF;AAAA,EAAA,GACC,CAAC,GAAG,CAAC;AAER,wCAAQ,aAAU,EAAA,KAAU,QAAQ,QAAS,GAAG,MAAO,CAAA;AACzD,CAAC;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../src/effects/SSR/index.tsx"],"sourcesContent":["import React, { Ref, forwardRef, useLayoutEffect, useEffect, useContext, useMemo } from 'react'\n/* @ts-ignore */\nimport { SSREffect } from './screen-space-reflections'\nimport { EffectComposerContext } from '../../EffectComposer'\nimport { selectionContext } from '../../Selection'\nimport { useThree } from '@react-three/fiber'\n\n// first two args are camera and texture\ntype SSRProps = {\n /** whether you want to use Temporal Resolving to re-use reflections from the last frames; this will reduce noise tremendously but may result in \"smearing\" */\n temporalResolve?: boolean\n /** a value between 0 and 1 to set how much the last frame's reflections should be blended in; higher values will result in less noisy reflections when moving the camera but a more smeary look */\n temporalResolveMix?: number\n /** a value between 0 and 1 to set how much the reprojected reflection should be corrected; higher values will reduce smearing but will result in less flickering at reflection edges */\n temporalResolveCorrectionMix?: number\n /** the maximum number of samples for reflections; settings it to 0 means unlimited samples; setting it to a value like 6 can help make camera movements less disruptive when calculating reflections */\n maxSamples?: number\n /** whether to blur the reflections and blend these blurred reflections with the raw ones depending on the blurMix value */\n ENABLE_BLUR?: boolean\n /** how much the blurred reflections should be mixed with the raw reflections */\n blurMix?: number\n /** the sharpness of the Bilateral Filter used to blur reflections */\n blurSharpness?: number\n /** the kernel size of the Bilateral Blur Filter; higher kernel sizes will result in blurrier reflections with more artifacts */\n blurKernelSize?: number\n /** how much the reflection ray should travel in each of its iteration; higher values will give deeper reflections but with more artifacts */\n rayStep?: number\n /** the intensity of the reflections */\n intensity?: number\n /** the maximum roughness a texel can have to have reflections calculated for it */\n maxRoughness?: number\n /** whether jittering is enabled; jittering will randomly jitter the reflections resulting in a more noisy but overall more realistic look, enabling jittering can be expensive depending on the view angle */\n ENABLE_JITTERING?: boolean\n /** how intense jittering should be */\n jitter?: number\n /** how much the jittered rays should be spread; higher values will give a rougher look regarding the reflections but are more expensive to compute with */\n jitterSpread?: number\n /** how intense jittering should be in relation to a material's roughness */\n jitterRough?: number\n /** the number of steps a reflection ray can maximally do to find an object it intersected (and thus reflects) */\n MAX_STEPS?: number\n /** once we had our ray intersect something, we need to find the exact point in space it intersected and thus it reflects; this can be done through binary search with the given number of maximum steps */\n NUM_BINARY_SEARCH_STEPS?: number\n /** the maximum depth difference between a ray and the particular depth at its screen position after refining with binary search; lower values will result in better performance */\n maxDepthDifference?: number\n /** the maximum depth for which reflections will be calculated */\n maxDepth?: number\n /** the maximum depth difference between a ray and the particular depth at its screen position before refining with binary search; lower values will result in better performance */\n thickness?: number\n /** Index of Refraction, used for calculating fresnel; reflections tend to be more intense the steeper the angle between them and the viewer is, the ior parameter set how much the intensity varies */\n ior?: number\n /** if there should still be reflections for rays for which a reflecting point couldn't be found; enabling this will result in stretched looking reflections which can look good or bad depending on the angle */\n STRETCH_MISSED_RAYS?: boolean\n /** WebGL2 only - whether to use multiple render targets when rendering the G-buffers (normals, depth and roughness); using them can improve performance as they will render all information to multiple buffers for each fragment in one run; this setting can't be changed during run-time */\n USE_MRT?: boolean\n /** if roughness maps should be taken account of when calculating reflections */\n USE_ROUGHNESSMAP?: boolean\n /** if normal maps should be taken account of when calculating reflections */\n USE_NORMALMAP?: boolean\n}\n\nexport const SSR = forwardRef<SSREffect, SSRProps>(function SSR(\n { ENABLE_BLUR = true, USE_MRT = true, ...props }: SSRProps,\n\n ref: Ref<SSREffect>\n) {\n const invalidate = useThree((s) => s.invalidate)\n const { scene, camera } = useContext(EffectComposerContext)\n const effect = useMemo(\n () => new SSREffect(scene, camera, { ENABLE_BLUR, USE_MRT, ...props }),\n [scene, camera, ENABLE_BLUR, USE_MRT, props]\n )\n\n const api = useContext(selectionContext)\n useEffect(() => {\n if (api && api.enabled) {\n if (api.selected?.length) {\n effect.selection.set(api.selected)\n invalidate()\n return () => {\n effect.selection.clear()\n invalidate()\n }\n }\n }\n }, [api, effect, invalidate])\n\n return <primitive ref={ref} object={effect} {...props} />\n})\n"],"names":["forwardRef","SSR","useThree","useContext","EffectComposerContext","useMemo","SSREffect","selectionContext","useEffect"],"mappings":";;;;;;;;AA6DO,MAAM,MAAMA,MAAA,WAAgC,SAASC,KAC1D,EAAE,cAAc,MAAM,UAAU,MAAM,GAAG,MAAM,GAE/C,KACA;AACA,QAAM,aAAaC,MAAAA,SAAS,CAAC,MAAM,EAAE,UAAU;AAC/C,QAAM,EAAE,OAAO,OAAO,IAAIC,iBAAWC,eAAqB,qBAAA;AAC1D,QAAM,SAASC,MAAA;AAAA,IACb,MAAM,IAAIC,uBAAAA,UAAU,OAAO,QAAQ,EAAE,aAAa,SAAS,GAAG,OAAO;AAAA,IACrE,CAAC,OAAO,QAAQ,aAAa,SAAS,KAAK;AAAA,EAAA;AAGvC,QAAA,MAAMH,iBAAWI,UAAAA,gBAAgB;AACvCC,QAAAA,UAAU,MAAM;;AACV,QAAA,OAAO,IAAI,SAAS;AAClB,WAAA,SAAI,aAAJ,mBAAc,QAAQ;AACjB,eAAA,UAAU,IAAI,IAAI,QAAQ;AACtB;AACX,eAAO,MAAM;AACX,iBAAO,UAAU;AACN;QAAA;AAAA,MAEf;AAAA,IACF;AAAA,EACC,GAAA,CAAC,KAAK,QAAQ,UAAU,CAAC;AAE5B,wCAAQ,aAAU,EAAA,KAAU,QAAQ,QAAS,GAAG,MAAO,CAAA;AACzD,CAAC;;"}
@@ -5,7 +5,7 @@ import { EffectComposerContext } from "../../EffectComposer.js";
5
5
  import { selectionContext } from "../../Selection.js";
6
6
  import { useThree } from "@react-three/fiber";
7
7
  const SSR = forwardRef(function SSR2({ ENABLE_BLUR = true, USE_MRT = true, ...props }, ref) {
8
- const { invalidate } = useThree();
8
+ const invalidate = useThree((s) => s.invalidate);
9
9
  const { scene, camera } = useContext(EffectComposerContext);
10
10
  const effect = useMemo(
11
11
  () => new SSREffect(scene, camera, { ENABLE_BLUR, USE_MRT, ...props }),
@@ -24,7 +24,7 @@ const SSR = forwardRef(function SSR2({ ENABLE_BLUR = true, USE_MRT = true, ...pr
24
24
  };
25
25
  }
26
26
  }
27
- }, [api]);
27
+ }, [api, effect, invalidate]);
28
28
  return /* @__PURE__ */ jsx("primitive", { ref, object: effect, ...props });
29
29
  });
30
30
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/effects/SSR/index.tsx"],"sourcesContent":["import React, { Ref, forwardRef, useLayoutEffect, useEffect, useContext, useMemo } from 'react'\n/* @ts-ignore */\nimport { SSREffect } from './screen-space-reflections'\nimport { EffectComposerContext } from '../../EffectComposer'\nimport { selectionContext } from '../../Selection'\nimport { useThree } from '@react-three/fiber'\n\n// first two args are camera and texture\ntype SSRProps = {\n /** whether you want to use Temporal Resolving to re-use reflections from the last frames; this will reduce noise tremendously but may result in \"smearing\" */\n temporalResolve?: boolean\n /** a value between 0 and 1 to set how much the last frame's reflections should be blended in; higher values will result in less noisy reflections when moving the camera but a more smeary look */\n temporalResolveMix?: number\n /** a value between 0 and 1 to set how much the reprojected reflection should be corrected; higher values will reduce smearing but will result in less flickering at reflection edges */\n temporalResolveCorrectionMix?: number\n /** the maximum number of samples for reflections; settings it to 0 means unlimited samples; setting it to a value like 6 can help make camera movements less disruptive when calculating reflections */\n maxSamples?: number\n /** whether to blur the reflections and blend these blurred reflections with the raw ones depending on the blurMix value */\n ENABLE_BLUR?: boolean\n /** how much the blurred reflections should be mixed with the raw reflections */\n blurMix?: number\n /** the sharpness of the Bilateral Filter used to blur reflections */\n blurSharpness?: number\n /** the kernel size of the Bilateral Blur Filter; higher kernel sizes will result in blurrier reflections with more artifacts */\n blurKernelSize?: number\n /** how much the reflection ray should travel in each of its iteration; higher values will give deeper reflections but with more artifacts */\n rayStep?: number\n /** the intensity of the reflections */\n intensity?: number\n /** the maximum roughness a texel can have to have reflections calculated for it */\n maxRoughness?: number\n /** whether jittering is enabled; jittering will randomly jitter the reflections resulting in a more noisy but overall more realistic look, enabling jittering can be expensive depending on the view angle */\n ENABLE_JITTERING?: boolean\n /** how intense jittering should be */\n jitter?: number\n /** how much the jittered rays should be spread; higher values will give a rougher look regarding the reflections but are more expensive to compute with */\n jitterSpread?: number\n /** how intense jittering should be in relation to a material's roughness */\n jitterRough?: number\n /** the number of steps a reflection ray can maximally do to find an object it intersected (and thus reflects) */\n MAX_STEPS?: number\n /** once we had our ray intersect something, we need to find the exact point in space it intersected and thus it reflects; this can be done through binary search with the given number of maximum steps */\n NUM_BINARY_SEARCH_STEPS?: number\n /** the maximum depth difference between a ray and the particular depth at its screen position after refining with binary search; lower values will result in better performance */\n maxDepthDifference?: number\n /** the maximum depth for which reflections will be calculated */\n maxDepth?: number\n /** the maximum depth difference between a ray and the particular depth at its screen position before refining with binary search; lower values will result in better performance */\n thickness?: number\n /** Index of Refraction, used for calculating fresnel; reflections tend to be more intense the steeper the angle between them and the viewer is, the ior parameter set how much the intensity varies */\n ior?: number\n /** if there should still be reflections for rays for which a reflecting point couldn't be found; enabling this will result in stretched looking reflections which can look good or bad depending on the angle */\n STRETCH_MISSED_RAYS?: boolean\n /** WebGL2 only - whether to use multiple render targets when rendering the G-buffers (normals, depth and roughness); using them can improve performance as they will render all information to multiple buffers for each fragment in one run; this setting can't be changed during run-time */\n USE_MRT?: boolean\n /** if roughness maps should be taken account of when calculating reflections */\n USE_ROUGHNESSMAP?: boolean\n /** if normal maps should be taken account of when calculating reflections */\n USE_NORMALMAP?: boolean\n}\n\nexport const SSR = forwardRef<SSREffect, SSRProps>(function SSR(\n { ENABLE_BLUR = true, USE_MRT = true, ...props }: SSRProps,\n\n ref: Ref<SSREffect>\n) {\n const { invalidate } = useThree()\n const { scene, camera } = useContext(EffectComposerContext)\n const effect = useMemo(\n () => new SSREffect(scene, camera, { ENABLE_BLUR, USE_MRT, ...props }),\n [scene, camera, ENABLE_BLUR, USE_MRT, props]\n )\n\n const api = useContext(selectionContext)\n useEffect(() => {\n if (api && api.enabled) {\n if (api.selected?.length) {\n effect.selection.set(api.selected)\n invalidate()\n return () => {\n effect.selection.clear()\n invalidate()\n }\n }\n }\n }, [api])\n\n return <primitive ref={ref} object={effect} {...props} />\n})\n"],"names":["SSR"],"mappings":";;;;;;AA6DO,MAAM,MAAM,WAAgC,SAASA,KAC1D,EAAE,cAAc,MAAM,UAAU,MAAM,GAAG,MAAM,GAE/C,KACA;AACM,QAAA,EAAE,eAAe;AACvB,QAAM,EAAE,OAAO,OAAO,IAAI,WAAW,qBAAqB;AAC1D,QAAM,SAAS;AAAA,IACb,MAAM,IAAI,UAAU,OAAO,QAAQ,EAAE,aAAa,SAAS,GAAG,OAAO;AAAA,IACrE,CAAC,OAAO,QAAQ,aAAa,SAAS,KAAK;AAAA,EAAA;AAGvC,QAAA,MAAM,WAAW,gBAAgB;AACvC,YAAU,MAAM;;AACV,QAAA,OAAO,IAAI,SAAS;AAClB,WAAA,SAAI,aAAJ,mBAAc,QAAQ;AACjB,eAAA,UAAU,IAAI,IAAI,QAAQ;AACtB;AACX,eAAO,MAAM;AACX,iBAAO,UAAU;AACN;QAAA;AAAA,MAEf;AAAA,IACF;AAAA,EAAA,GACC,CAAC,GAAG,CAAC;AAER,6BAAQ,aAAU,EAAA,KAAU,QAAQ,QAAS,GAAG,MAAO,CAAA;AACzD,CAAC;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/effects/SSR/index.tsx"],"sourcesContent":["import React, { Ref, forwardRef, useLayoutEffect, useEffect, useContext, useMemo } from 'react'\n/* @ts-ignore */\nimport { SSREffect } from './screen-space-reflections'\nimport { EffectComposerContext } from '../../EffectComposer'\nimport { selectionContext } from '../../Selection'\nimport { useThree } from '@react-three/fiber'\n\n// first two args are camera and texture\ntype SSRProps = {\n /** whether you want to use Temporal Resolving to re-use reflections from the last frames; this will reduce noise tremendously but may result in \"smearing\" */\n temporalResolve?: boolean\n /** a value between 0 and 1 to set how much the last frame's reflections should be blended in; higher values will result in less noisy reflections when moving the camera but a more smeary look */\n temporalResolveMix?: number\n /** a value between 0 and 1 to set how much the reprojected reflection should be corrected; higher values will reduce smearing but will result in less flickering at reflection edges */\n temporalResolveCorrectionMix?: number\n /** the maximum number of samples for reflections; settings it to 0 means unlimited samples; setting it to a value like 6 can help make camera movements less disruptive when calculating reflections */\n maxSamples?: number\n /** whether to blur the reflections and blend these blurred reflections with the raw ones depending on the blurMix value */\n ENABLE_BLUR?: boolean\n /** how much the blurred reflections should be mixed with the raw reflections */\n blurMix?: number\n /** the sharpness of the Bilateral Filter used to blur reflections */\n blurSharpness?: number\n /** the kernel size of the Bilateral Blur Filter; higher kernel sizes will result in blurrier reflections with more artifacts */\n blurKernelSize?: number\n /** how much the reflection ray should travel in each of its iteration; higher values will give deeper reflections but with more artifacts */\n rayStep?: number\n /** the intensity of the reflections */\n intensity?: number\n /** the maximum roughness a texel can have to have reflections calculated for it */\n maxRoughness?: number\n /** whether jittering is enabled; jittering will randomly jitter the reflections resulting in a more noisy but overall more realistic look, enabling jittering can be expensive depending on the view angle */\n ENABLE_JITTERING?: boolean\n /** how intense jittering should be */\n jitter?: number\n /** how much the jittered rays should be spread; higher values will give a rougher look regarding the reflections but are more expensive to compute with */\n jitterSpread?: number\n /** how intense jittering should be in relation to a material's roughness */\n jitterRough?: number\n /** the number of steps a reflection ray can maximally do to find an object it intersected (and thus reflects) */\n MAX_STEPS?: number\n /** once we had our ray intersect something, we need to find the exact point in space it intersected and thus it reflects; this can be done through binary search with the given number of maximum steps */\n NUM_BINARY_SEARCH_STEPS?: number\n /** the maximum depth difference between a ray and the particular depth at its screen position after refining with binary search; lower values will result in better performance */\n maxDepthDifference?: number\n /** the maximum depth for which reflections will be calculated */\n maxDepth?: number\n /** the maximum depth difference between a ray and the particular depth at its screen position before refining with binary search; lower values will result in better performance */\n thickness?: number\n /** Index of Refraction, used for calculating fresnel; reflections tend to be more intense the steeper the angle between them and the viewer is, the ior parameter set how much the intensity varies */\n ior?: number\n /** if there should still be reflections for rays for which a reflecting point couldn't be found; enabling this will result in stretched looking reflections which can look good or bad depending on the angle */\n STRETCH_MISSED_RAYS?: boolean\n /** WebGL2 only - whether to use multiple render targets when rendering the G-buffers (normals, depth and roughness); using them can improve performance as they will render all information to multiple buffers for each fragment in one run; this setting can't be changed during run-time */\n USE_MRT?: boolean\n /** if roughness maps should be taken account of when calculating reflections */\n USE_ROUGHNESSMAP?: boolean\n /** if normal maps should be taken account of when calculating reflections */\n USE_NORMALMAP?: boolean\n}\n\nexport const SSR = forwardRef<SSREffect, SSRProps>(function SSR(\n { ENABLE_BLUR = true, USE_MRT = true, ...props }: SSRProps,\n\n ref: Ref<SSREffect>\n) {\n const invalidate = useThree((s) => s.invalidate)\n const { scene, camera } = useContext(EffectComposerContext)\n const effect = useMemo(\n () => new SSREffect(scene, camera, { ENABLE_BLUR, USE_MRT, ...props }),\n [scene, camera, ENABLE_BLUR, USE_MRT, props]\n )\n\n const api = useContext(selectionContext)\n useEffect(() => {\n if (api && api.enabled) {\n if (api.selected?.length) {\n effect.selection.set(api.selected)\n invalidate()\n return () => {\n effect.selection.clear()\n invalidate()\n }\n }\n }\n }, [api, effect, invalidate])\n\n return <primitive ref={ref} object={effect} {...props} />\n})\n"],"names":["SSR"],"mappings":";;;;;;AA6DO,MAAM,MAAM,WAAgC,SAASA,KAC1D,EAAE,cAAc,MAAM,UAAU,MAAM,GAAG,MAAM,GAE/C,KACA;AACA,QAAM,aAAa,SAAS,CAAC,MAAM,EAAE,UAAU;AAC/C,QAAM,EAAE,OAAO,OAAO,IAAI,WAAW,qBAAqB;AAC1D,QAAM,SAAS;AAAA,IACb,MAAM,IAAI,UAAU,OAAO,QAAQ,EAAE,aAAa,SAAS,GAAG,OAAO;AAAA,IACrE,CAAC,OAAO,QAAQ,aAAa,SAAS,KAAK;AAAA,EAAA;AAGvC,QAAA,MAAM,WAAW,gBAAgB;AACvC,YAAU,MAAM;;AACV,QAAA,OAAO,IAAI,SAAS;AAClB,WAAA,SAAI,aAAJ,mBAAc,QAAQ;AACjB,eAAA,UAAU,IAAI,IAAI,QAAQ;AACtB;AACX,eAAO,MAAM;AACX,iBAAO,UAAU;AACN;QAAA;AAAA,MAEf;AAAA,IACF;AAAA,EACC,GAAA,CAAC,KAAK,QAAQ,UAAU,CAAC;AAE5B,6BAAQ,aAAU,EAAA,KAAU,QAAQ,QAAS,GAAG,MAAO,CAAA;AACzD,CAAC;"}
@@ -1,51 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const jsxRuntime = require("react/jsx-runtime");
4
3
  const postprocessing = require("postprocessing");
5
- const React = require("react");
6
- const ToneMapping = React.forwardRef(function ToneMapping2({
7
- blendFunction,
8
- adaptive,
9
- mode,
10
- resolution,
11
- maxLuminance,
12
- whitePoint,
13
- middleGrey,
14
- minLuminance,
15
- averageLuminance,
16
- adaptationRate,
17
- ...props
18
- }, ref) {
19
- const effect = React.useMemo(
20
- () => new postprocessing.ToneMappingEffect({
21
- blendFunction,
22
- adaptive,
23
- mode,
24
- resolution,
25
- maxLuminance,
26
- whitePoint,
27
- middleGrey,
28
- minLuminance,
29
- averageLuminance,
30
- adaptationRate
31
- }),
32
- [
33
- blendFunction,
34
- adaptive,
35
- mode,
36
- resolution,
37
- maxLuminance,
38
- whitePoint,
39
- middleGrey,
40
- minLuminance,
41
- averageLuminance,
42
- adaptationRate
43
- ]
44
- );
45
- React.useEffect(() => {
46
- effect.dispose();
47
- }, [effect]);
48
- return /* @__PURE__ */ jsxRuntime.jsx("primitive", { ...props, ref, object: effect, attributes: postprocessing.EffectAttribute.CONVOLUTION });
49
- });
4
+ const util = require("../util.cjs");
5
+ const ToneMapping = util.wrapEffect(postprocessing.ToneMappingEffect);
50
6
  exports.ToneMapping = ToneMapping;
51
7
  //# sourceMappingURL=ToneMapping.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ToneMapping.cjs","sources":["../../src/effects/ToneMapping.tsx"],"sourcesContent":["import { ToneMappingEffect, EffectAttribute } from 'postprocessing'\nimport { EffectProps } from '../util'\nimport { forwardRef, useEffect, useMemo } from 'react'\n\nexport type ToneMappingProps = EffectProps<typeof ToneMappingEffect>\n\nexport const ToneMapping = forwardRef<ToneMappingEffect, ToneMappingProps>(function ToneMapping(\n {\n blendFunction,\n adaptive,\n mode,\n resolution,\n maxLuminance,\n whitePoint,\n middleGrey,\n minLuminance,\n averageLuminance,\n adaptationRate,\n ...props\n },\n ref\n) {\n const effect = useMemo(\n () =>\n new ToneMappingEffect({\n blendFunction,\n adaptive,\n mode,\n resolution,\n maxLuminance,\n whitePoint,\n middleGrey,\n minLuminance,\n averageLuminance,\n adaptationRate,\n }),\n [\n blendFunction,\n adaptive,\n mode,\n resolution,\n maxLuminance,\n whitePoint,\n middleGrey,\n minLuminance,\n averageLuminance,\n adaptationRate,\n ]\n )\n\n useEffect(() => {\n effect.dispose()\n }, [effect])\n\n return <primitive {...props} ref={ref} object={effect} attributes={EffectAttribute.CONVOLUTION} />\n})\n"],"names":["forwardRef","ToneMapping","useMemo","ToneMappingEffect","useEffect","jsx","EffectAttribute"],"mappings":";;;;;AAMa,MAAA,cAAcA,MAAAA,WAAgD,SAASC,aAClF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GACA,KACA;AACA,QAAM,SAASC,MAAA;AAAA,IACb,MACE,IAAIC,eAAAA,kBAAkB;AAAA,MACpB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EAAA;AAGFC,QAAAA,UAAU,MAAM;AACd,WAAO,QAAQ;AAAA,EAAA,GACd,CAAC,MAAM,CAAC;AAEJ,SAAAC,+BAAC,eAAW,GAAG,OAAO,KAAU,QAAQ,QAAQ,YAAYC,+BAAgB,YAAa,CAAA;AAClG,CAAC;;"}
1
+ {"version":3,"file":"ToneMapping.cjs","sources":["../../src/effects/ToneMapping.tsx"],"sourcesContent":["import { ToneMappingEffect } from 'postprocessing'\nimport { type EffectProps, wrapEffect } from '../util'\n\nexport type ToneMappingProps = EffectProps<typeof ToneMappingEffect>\n\nexport const ToneMapping = wrapEffect(ToneMappingEffect)\n"],"names":["wrapEffect","ToneMappingEffect"],"mappings":";;;;AAKa,MAAA,cAAcA,gBAAWC,eAAiB,iBAAA;;"}
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { ToneMappingEffect } from 'postprocessing';
3
- import { EffectProps } from '../util';
3
+ import { type EffectProps } from '../util';
4
4
  export type ToneMappingProps = EffectProps<typeof ToneMappingEffect>;
5
5
  export declare const ToneMapping: import("react").ForwardRefExoticComponent<Omit<import("@react-three/fiber").ExtendedColors<import("@react-three/fiber").Overwrite<Partial<ToneMappingEffect>, import("@react-three/fiber").NodeProps<ToneMappingEffect, typeof ToneMappingEffect>>> & {
6
6
  blendFunction?: import("postprocessing").BlendFunction | undefined;
@@ -16,4 +16,4 @@ export declare const ToneMapping: import("react").ForwardRefExoticComponent<Omit
16
16
  } & {
17
17
  blendFunction?: import("postprocessing").BlendFunction | undefined;
18
18
  opacity?: number | undefined;
19
- }, "ref"> & import("react").RefAttributes<ToneMappingEffect>>;
19
+ }, "ref"> & import("react").RefAttributes<typeof ToneMappingEffect>>;
@@ -1,50 +1,6 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { ToneMappingEffect, EffectAttribute } from "postprocessing";
3
- import { forwardRef, useMemo, useEffect } from "react";
4
- const ToneMapping = forwardRef(function ToneMapping2({
5
- blendFunction,
6
- adaptive,
7
- mode,
8
- resolution,
9
- maxLuminance,
10
- whitePoint,
11
- middleGrey,
12
- minLuminance,
13
- averageLuminance,
14
- adaptationRate,
15
- ...props
16
- }, ref) {
17
- const effect = useMemo(
18
- () => new ToneMappingEffect({
19
- blendFunction,
20
- adaptive,
21
- mode,
22
- resolution,
23
- maxLuminance,
24
- whitePoint,
25
- middleGrey,
26
- minLuminance,
27
- averageLuminance,
28
- adaptationRate
29
- }),
30
- [
31
- blendFunction,
32
- adaptive,
33
- mode,
34
- resolution,
35
- maxLuminance,
36
- whitePoint,
37
- middleGrey,
38
- minLuminance,
39
- averageLuminance,
40
- adaptationRate
41
- ]
42
- );
43
- useEffect(() => {
44
- effect.dispose();
45
- }, [effect]);
46
- return /* @__PURE__ */ jsx("primitive", { ...props, ref, object: effect, attributes: EffectAttribute.CONVOLUTION });
47
- });
1
+ import { ToneMappingEffect } from "postprocessing";
2
+ import { wrapEffect } from "../util.js";
3
+ const ToneMapping = wrapEffect(ToneMappingEffect);
48
4
  export {
49
5
  ToneMapping
50
6
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ToneMapping.js","sources":["../../src/effects/ToneMapping.tsx"],"sourcesContent":["import { ToneMappingEffect, EffectAttribute } from 'postprocessing'\nimport { EffectProps } from '../util'\nimport { forwardRef, useEffect, useMemo } from 'react'\n\nexport type ToneMappingProps = EffectProps<typeof ToneMappingEffect>\n\nexport const ToneMapping = forwardRef<ToneMappingEffect, ToneMappingProps>(function ToneMapping(\n {\n blendFunction,\n adaptive,\n mode,\n resolution,\n maxLuminance,\n whitePoint,\n middleGrey,\n minLuminance,\n averageLuminance,\n adaptationRate,\n ...props\n },\n ref\n) {\n const effect = useMemo(\n () =>\n new ToneMappingEffect({\n blendFunction,\n adaptive,\n mode,\n resolution,\n maxLuminance,\n whitePoint,\n middleGrey,\n minLuminance,\n averageLuminance,\n adaptationRate,\n }),\n [\n blendFunction,\n adaptive,\n mode,\n resolution,\n maxLuminance,\n whitePoint,\n middleGrey,\n minLuminance,\n averageLuminance,\n adaptationRate,\n ]\n )\n\n useEffect(() => {\n effect.dispose()\n }, [effect])\n\n return <primitive {...props} ref={ref} object={effect} attributes={EffectAttribute.CONVOLUTION} />\n})\n"],"names":["ToneMapping"],"mappings":";;;AAMa,MAAA,cAAc,WAAgD,SAASA,aAClF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GACA,KACA;AACA,QAAM,SAAS;AAAA,IACb,MACE,IAAI,kBAAkB;AAAA,MACpB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD;AAAA,IACH;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EAAA;AAGF,YAAU,MAAM;AACd,WAAO,QAAQ;AAAA,EAAA,GACd,CAAC,MAAM,CAAC;AAEJ,SAAA,oBAAC,eAAW,GAAG,OAAO,KAAU,QAAQ,QAAQ,YAAY,gBAAgB,YAAa,CAAA;AAClG,CAAC;"}
1
+ {"version":3,"file":"ToneMapping.js","sources":["../../src/effects/ToneMapping.tsx"],"sourcesContent":["import { ToneMappingEffect } from 'postprocessing'\nimport { type EffectProps, wrapEffect } from '../util'\n\nexport type ToneMappingProps = EffectProps<typeof ToneMappingEffect>\n\nexport const ToneMapping = wrapEffect(ToneMappingEffect)\n"],"names":[],"mappings":";;AAKa,MAAA,cAAc,WAAW,iBAAiB;"}
@@ -4,19 +4,24 @@ const THREE = require("three");
4
4
  const postprocessing = require("postprocessing");
5
5
  const util = require("../util.cjs");
6
6
  const WaterShader = {
7
- fragmentShader: `
8
- uniform float factor;
9
- void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) {
10
- vec2 vUv = uv;
11
- float frequency = 6.0 * factor;
12
- float amplitude = 0.015 * factor;
13
- float x = vUv.y * frequency + time * .7;
14
- float y = vUv.x * frequency + time * .3;
15
- vUv.x += cos(x+y) * amplitude * cos(y);
16
- vUv.y += sin(x-y) * amplitude * cos(y);
17
- vec4 rgba = texture2D(inputBuffer, vUv);
18
- outputColor = rgba;
19
- }`
7
+ fragmentShader: (
8
+ /* glsl */
9
+ `
10
+ uniform float factor;
11
+
12
+ void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) {
13
+ vec2 vUv = uv;
14
+ float frequency = 6.0 * factor;
15
+ float amplitude = 0.015 * factor;
16
+ float x = vUv.y * frequency + time * 0.7;
17
+ float y = vUv.x * frequency + time * 0.3;
18
+ vUv.x += cos(x + y) * amplitude * cos(y);
19
+ vUv.y += sin(x - y) * amplitude * cos(y);
20
+ vec4 rgba = texture(inputBuffer, vUv);
21
+ outputColor = rgba;
22
+ }
23
+ `
24
+ )
20
25
  };
21
26
  class WaterEffectImpl extends postprocessing.Effect {
22
27
  constructor({ blendFunction = postprocessing.BlendFunction.NORMAL, factor = 0 } = {}) {
@@ -1 +1 @@
1
- {"version":3,"file":"Water.cjs","sources":["../../src/effects/Water.tsx"],"sourcesContent":["import { Uniform } from 'three'\nimport { BlendFunction, Effect, EffectAttribute } from 'postprocessing'\nimport { wrapEffect } from '../util'\n\nconst WaterShader = {\n fragmentShader: `\n uniform float factor;\n void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) {\n vec2 vUv = uv;\n float frequency = 6.0 * factor;\n float amplitude = 0.015 * factor;\n float x = vUv.y * frequency + time * .7; \n float y = vUv.x * frequency + time * .3;\n vUv.x += cos(x+y) * amplitude * cos(y);\n vUv.y += sin(x-y) * amplitude * cos(y);\n vec4 rgba = texture2D(inputBuffer, vUv);\n outputColor = rgba;\n }`\n}\n\nexport class WaterEffectImpl extends Effect {\n constructor({ blendFunction = BlendFunction.NORMAL, factor = 0 } = {}) {\n super('WaterEffect', WaterShader.fragmentShader, {\n blendFunction,\n attributes: EffectAttribute.CONVOLUTION,\n uniforms: new Map<string, Uniform<number | number[]>>([['factor', new Uniform(factor)]])\n })\n }\n}\n\nexport const WaterEffect = wrapEffect(WaterEffectImpl, { blendFunction: BlendFunction.NORMAL })\n"],"names":["Effect","BlendFunction","EffectAttribute","Uniform","wrapEffect"],"mappings":";;;;;AAIA,MAAM,cAAc;AAAA,EAClB,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAalB;AAEO,MAAM,wBAAwBA,eAAAA,OAAO;AAAA,EAC1C,YAAY,EAAE,gBAAgBC,eAAA,cAAc,QAAQ,SAAS,EAAM,IAAA,IAAI;AAC/D,UAAA,eAAe,YAAY,gBAAgB;AAAA,MAC/C;AAAA,MACA,YAAYC,eAAgB,gBAAA;AAAA,MAC5B,UAAc,oBAAA,IAAwC,CAAC,CAAC,UAAU,IAAIC,cAAQ,MAAM,CAAC,CAAC,CAAC;AAAA,IAAA,CACxF;AAAA,EACH;AACF;AAEO,MAAM,cAAcC,KAAW,WAAA,iBAAiB,EAAE,eAAeH,eAAAA,cAAc,OAAQ,CAAA;;;"}
1
+ {"version":3,"file":"Water.cjs","sources":["../../src/effects/Water.tsx"],"sourcesContent":["import { Uniform } from 'three'\nimport { BlendFunction, Effect, EffectAttribute } from 'postprocessing'\nimport { wrapEffect } from '../util'\n\nconst WaterShader = {\n fragmentShader: /* glsl */ `\n uniform float factor;\n\n void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) {\n vec2 vUv = uv;\n float frequency = 6.0 * factor;\n float amplitude = 0.015 * factor;\n float x = vUv.y * frequency + time * 0.7; \n float y = vUv.x * frequency + time * 0.3;\n vUv.x += cos(x + y) * amplitude * cos(y);\n vUv.y += sin(x - y) * amplitude * cos(y);\n vec4 rgba = texture(inputBuffer, vUv);\n outputColor = rgba;\n }\n `,\n}\n\nexport class WaterEffectImpl extends Effect {\n constructor({ blendFunction = BlendFunction.NORMAL, factor = 0 } = {}) {\n super('WaterEffect', WaterShader.fragmentShader, {\n blendFunction,\n attributes: EffectAttribute.CONVOLUTION,\n uniforms: new Map<string, Uniform<number | number[]>>([['factor', new Uniform(factor)]]),\n })\n }\n}\n\nexport const WaterEffect = wrapEffect(WaterEffectImpl, { blendFunction: BlendFunction.NORMAL })\n"],"names":["Effect","BlendFunction","EffectAttribute","Uniform","wrapEffect"],"mappings":";;;;;AAIA,MAAM,cAAc;AAAA,EAClB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAe7B;AAEO,MAAM,wBAAwBA,eAAAA,OAAO;AAAA,EAC1C,YAAY,EAAE,gBAAgBC,eAAA,cAAc,QAAQ,SAAS,EAAM,IAAA,IAAI;AAC/D,UAAA,eAAe,YAAY,gBAAgB;AAAA,MAC/C;AAAA,MACA,YAAYC,eAAgB,gBAAA;AAAA,MAC5B,UAAc,oBAAA,IAAwC,CAAC,CAAC,UAAU,IAAIC,cAAQ,MAAM,CAAC,CAAC,CAAC;AAAA,IAAA,CACxF;AAAA,EACH;AACF;AAEO,MAAM,cAAcC,KAAW,WAAA,iBAAiB,EAAE,eAAeH,eAAAA,cAAc,OAAQ,CAAA;;;"}
@@ -2,19 +2,24 @@ import { Uniform } from "three";
2
2
  import { Effect, EffectAttribute, BlendFunction } from "postprocessing";
3
3
  import { wrapEffect } from "../util.js";
4
4
  const WaterShader = {
5
- fragmentShader: `
6
- uniform float factor;
7
- void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) {
8
- vec2 vUv = uv;
9
- float frequency = 6.0 * factor;
10
- float amplitude = 0.015 * factor;
11
- float x = vUv.y * frequency + time * .7;
12
- float y = vUv.x * frequency + time * .3;
13
- vUv.x += cos(x+y) * amplitude * cos(y);
14
- vUv.y += sin(x-y) * amplitude * cos(y);
15
- vec4 rgba = texture2D(inputBuffer, vUv);
16
- outputColor = rgba;
17
- }`
5
+ fragmentShader: (
6
+ /* glsl */
7
+ `
8
+ uniform float factor;
9
+
10
+ void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) {
11
+ vec2 vUv = uv;
12
+ float frequency = 6.0 * factor;
13
+ float amplitude = 0.015 * factor;
14
+ float x = vUv.y * frequency + time * 0.7;
15
+ float y = vUv.x * frequency + time * 0.3;
16
+ vUv.x += cos(x + y) * amplitude * cos(y);
17
+ vUv.y += sin(x - y) * amplitude * cos(y);
18
+ vec4 rgba = texture(inputBuffer, vUv);
19
+ outputColor = rgba;
20
+ }
21
+ `
22
+ )
18
23
  };
19
24
  class WaterEffectImpl extends Effect {
20
25
  constructor({ blendFunction = BlendFunction.NORMAL, factor = 0 } = {}) {
@@ -1 +1 @@
1
- {"version":3,"file":"Water.js","sources":["../../src/effects/Water.tsx"],"sourcesContent":["import { Uniform } from 'three'\nimport { BlendFunction, Effect, EffectAttribute } from 'postprocessing'\nimport { wrapEffect } from '../util'\n\nconst WaterShader = {\n fragmentShader: `\n uniform float factor;\n void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) {\n vec2 vUv = uv;\n float frequency = 6.0 * factor;\n float amplitude = 0.015 * factor;\n float x = vUv.y * frequency + time * .7; \n float y = vUv.x * frequency + time * .3;\n vUv.x += cos(x+y) * amplitude * cos(y);\n vUv.y += sin(x-y) * amplitude * cos(y);\n vec4 rgba = texture2D(inputBuffer, vUv);\n outputColor = rgba;\n }`\n}\n\nexport class WaterEffectImpl extends Effect {\n constructor({ blendFunction = BlendFunction.NORMAL, factor = 0 } = {}) {\n super('WaterEffect', WaterShader.fragmentShader, {\n blendFunction,\n attributes: EffectAttribute.CONVOLUTION,\n uniforms: new Map<string, Uniform<number | number[]>>([['factor', new Uniform(factor)]])\n })\n }\n}\n\nexport const WaterEffect = wrapEffect(WaterEffectImpl, { blendFunction: BlendFunction.NORMAL })\n"],"names":[],"mappings":";;;AAIA,MAAM,cAAc;AAAA,EAClB,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAalB;AAEO,MAAM,wBAAwB,OAAO;AAAA,EAC1C,YAAY,EAAE,gBAAgB,cAAc,QAAQ,SAAS,EAAM,IAAA,IAAI;AAC/D,UAAA,eAAe,YAAY,gBAAgB;AAAA,MAC/C;AAAA,MACA,YAAY,gBAAgB;AAAA,MAC5B,UAAc,oBAAA,IAAwC,CAAC,CAAC,UAAU,IAAI,QAAQ,MAAM,CAAC,CAAC,CAAC;AAAA,IAAA,CACxF;AAAA,EACH;AACF;AAEO,MAAM,cAAc,WAAW,iBAAiB,EAAE,eAAe,cAAc,OAAQ,CAAA;"}
1
+ {"version":3,"file":"Water.js","sources":["../../src/effects/Water.tsx"],"sourcesContent":["import { Uniform } from 'three'\nimport { BlendFunction, Effect, EffectAttribute } from 'postprocessing'\nimport { wrapEffect } from '../util'\n\nconst WaterShader = {\n fragmentShader: /* glsl */ `\n uniform float factor;\n\n void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) {\n vec2 vUv = uv;\n float frequency = 6.0 * factor;\n float amplitude = 0.015 * factor;\n float x = vUv.y * frequency + time * 0.7; \n float y = vUv.x * frequency + time * 0.3;\n vUv.x += cos(x + y) * amplitude * cos(y);\n vUv.y += sin(x - y) * amplitude * cos(y);\n vec4 rgba = texture(inputBuffer, vUv);\n outputColor = rgba;\n }\n `,\n}\n\nexport class WaterEffectImpl extends Effect {\n constructor({ blendFunction = BlendFunction.NORMAL, factor = 0 } = {}) {\n super('WaterEffect', WaterShader.fragmentShader, {\n blendFunction,\n attributes: EffectAttribute.CONVOLUTION,\n uniforms: new Map<string, Uniform<number | number[]>>([['factor', new Uniform(factor)]]),\n })\n }\n}\n\nexport const WaterEffect = wrapEffect(WaterEffectImpl, { blendFunction: BlendFunction.NORMAL })\n"],"names":[],"mappings":";;;AAIA,MAAM,cAAc;AAAA,EAClB;AAAA;AAAA,IAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAe7B;AAEO,MAAM,wBAAwB,OAAO;AAAA,EAC1C,YAAY,EAAE,gBAAgB,cAAc,QAAQ,SAAS,EAAM,IAAA,IAAI;AAC/D,UAAA,eAAe,YAAY,gBAAgB;AAAA,MAC/C;AAAA,MACA,YAAY,gBAAgB;AAAA,MAC5B,UAAc,oBAAA,IAAwC,CAAC,CAAC,UAAU,IAAI,QAAQ,MAAM,CAAC,CAAC,CAAC;AAAA,IAAA,CACxF;AAAA,EACH;AACF;AAEO,MAAM,cAAc,WAAW,iBAAiB,EAAE,eAAe,cAAc,OAAQ,CAAA;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/postprocessing",
3
- "version": "2.16.2",
3
+ "version": "2.16.4",
4
4
  "description": "postprocessing wrapper for React and @react-three/fiber",
5
5
  "keywords": [
6
6
  "postprocessing",
@@ -39,7 +39,7 @@
39
39
  "prepare": "yarn build",
40
40
  "eslint": "eslint . --fix --ext=js,ts,jsx,tsx",
41
41
  "eslint:ci": "eslint . --ext=js,ts,jsx,tsx",
42
- "test": "echo no tests yet",
42
+ "test": "vitest run",
43
43
  "typecheck": "tsc --noEmit false --strict --jsx react",
44
44
  "release": "semantic-release",
45
45
  "storybook": "storybook dev -p 6006",
@@ -85,7 +85,8 @@
85
85
  "storybook": "^7.0.10",
86
86
  "three": "^0.151.3",
87
87
  "typescript": "^5.0.4",
88
- "vite": "^4.3.5"
88
+ "vite": "^4.3.5",
89
+ "vitest": "^2.1.8"
89
90
  },
90
91
  "peerDependencies": {
91
92
  "@react-three/fiber": ">=8.0",